Package io.druid.query.extraction

Examples of io.druid.query.extraction.DimExtractionFn.apply()


    DimExtractionFn dimExtractionFn = new SearchQuerySpecDimExtractionFn(spec);
    List<String> expected = Arrays.asList("Kyoto", "Tokyo", "Toyokawa", "Yorktown");
    Set<String> extracted = Sets.newHashSet();

    for (String str : testStrings) {
      String res = dimExtractionFn.apply(str);
      if (res != null) {
        extracted.add(res);
      }
    }
View Full Code Here


                    final DimensionSelector dimSelector = dimensions.get(i);
                    final DimExtractionFn fn = dimensionSpecs.get(i).getDimExtractionFn();
                    final int dimVal = keyBuffer.getInt();
                    if (dimSelector.getValueCardinality() != dimVal) {
                      if (fn != null) {
                        theEvent.put(dimNames.get(i), fn.apply(dimSelector.lookupName(dimVal)));
                      } else {
                        theEvent.put(dimNames.get(i), dimSelector.lookupName(dimVal));
                      }
                    }
                  }
View Full Code Here

    String regex = "/([^/]+)/";
    DimExtractionFn dimExtractionFn = new RegexDimExtractionFn(regex);
    Set<String> extracted = Sets.newHashSet();

    for (String path : paths) {
      extracted.add(dimExtractionFn.apply(path));
    }

    Assert.assertEquals(2, extracted.size());
    Assert.assertTrue(extracted.contains("druid"));
    Assert.assertTrue(extracted.contains("dash"));
View Full Code Here

    String regex = "^/([^/]+/[^/]+)(/|$)";
    DimExtractionFn dimExtractionFn = new RegexDimExtractionFn(regex);
    Set<String> extracted = Sets.newHashSet();

    for (String path : paths) {
      extracted.add(dimExtractionFn.apply(path));
    }

    Assert.assertEquals(4, extracted.size());
    Assert.assertTrue(extracted.contains("druid/prod"));
    Assert.assertTrue(extracted.contains("druid/demo"));
View Full Code Here

    String regex = "(.)";
    DimExtractionFn dimExtractionFn = new RegexDimExtractionFn(regex);
    Set<String> extracted = Sets.newHashSet();

    for (String testString : testStrings) {
      extracted.add(dimExtractionFn.apply(testString));
    }

    Assert.assertEquals(3, extracted.size());
    Assert.assertTrue(extracted.contains("a"));
    Assert.assertTrue(extracted.contains("b"));
View Full Code Here

  {
    String function = "function(str) { return str.substring(0,3); }";
    DimExtractionFn dimExtractionFn = new JavascriptDimExtractionFn(function);

    for (String str : testStrings) {
      String res = dimExtractionFn.apply(str);
      Assert.assertEquals(str.substring(0, 3), res);
    }
  }

  @Test
View Full Code Here

    DimExtractionFn dimExtractionFn = new JavascriptDimExtractionFn(function);

    Iterator<String> it = Iterators.forArray("0", "5", "5", "10", null);

    for(String str : Lists.newArrayList("1", "5", "6", "10", "CA")) {
      String res = dimExtractionFn.apply(str);
      String expected = it.next();
      Assert.assertEquals(expected, res);
    }
  }
View Full Code Here

    String function = "function(str) { return str.replace(/[aeiou]/g, ''); }";
    DimExtractionFn dimExtractionFn = new JavascriptDimExtractionFn(function);

    Iterator it = Iterators.forArray("Qt", "Clgry", "Tky", "Stckhlm", "Vncvr", "Prtr", "Wllngtn", "Ontr");
    for (String str : testStrings) {
      String res = dimExtractionFn.apply(str);
      Assert.assertEquals(it.next(), res);
    }
  }

  @Test
View Full Code Here

    Iterator<String> inputs = Iterators.forArray("introducing", "exploratory", "analytics", "on", "large", "datasets");
    Iterator<String> it = Iterators.forArray("introduc", "exploratori", "analyt", "on", "larg", "dataset");

    while(inputs.hasNext()) {
      String res = dimExtractionFn.apply(inputs.next());
      Assert.assertEquals(it.next(), res);
    }
  }
}
View Full Code Here

  {
    Set<String> months = Sets.newHashSet();
    DimExtractionFn dimExtractionFn = new TimeDimExtractionFn("MM/dd/yyyy", "MM/yyyy");

    for (String dim : dims) {
      months.add(dimExtractionFn.apply(dim));
    }

    Assert.assertEquals(months.size(), 4);
    Assert.assertTrue(months.contains("01/2012"));
    Assert.assertTrue(months.contains("03/2012"));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.