Package io.druid.query.extraction

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


  {
    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

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.