fix casing to be consistent with other classes

This commit is contained in:
Xavier Léauté 2016-01-08 10:13:54 -08:00
parent 0665b49e65
commit 46a7f2660d
4 changed files with 17 additions and 17 deletions

View File

@ -30,7 +30,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
@JsonSubTypes.Type(name = "regex", value = RegexDimExtractionFn.class), @JsonSubTypes.Type(name = "regex", value = RegexDimExtractionFn.class),
@JsonSubTypes.Type(name = "partial", value = MatchingDimExtractionFn.class), @JsonSubTypes.Type(name = "partial", value = MatchingDimExtractionFn.class),
@JsonSubTypes.Type(name = "searchQuery", value = SearchQuerySpecDimExtractionFn.class), @JsonSubTypes.Type(name = "searchQuery", value = SearchQuerySpecDimExtractionFn.class),
@JsonSubTypes.Type(name = "javascript", value = JavascriptExtractionFn.class), @JsonSubTypes.Type(name = "javascript", value = JavaScriptExtractionFn.class),
@JsonSubTypes.Type(name = "timeFormat", value = TimeFormatExtractionFn.class), @JsonSubTypes.Type(name = "timeFormat", value = TimeFormatExtractionFn.class),
@JsonSubTypes.Type(name = "identity", value = IdentityExtractionFn.class), @JsonSubTypes.Type(name = "identity", value = IdentityExtractionFn.class),
@JsonSubTypes.Type(name = "lookup", value = LookupExtractionFn.class), @JsonSubTypes.Type(name = "lookup", value = LookupExtractionFn.class),

View File

@ -31,7 +31,7 @@ import org.mozilla.javascript.ScriptableObject;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
public class JavascriptExtractionFn implements ExtractionFn public class JavaScriptExtractionFn implements ExtractionFn
{ {
private static Function<Object, String> compile(String function) private static Function<Object, String> compile(String function)
{ {
@ -68,7 +68,7 @@ public class JavascriptExtractionFn implements ExtractionFn
private final boolean injective; private final boolean injective;
@JsonCreator @JsonCreator
public JavascriptExtractionFn( public JavaScriptExtractionFn(
@JsonProperty("function") String function, @JsonProperty("function") String function,
@JsonProperty("injective") boolean injective @JsonProperty("injective") boolean injective
) )
@ -150,7 +150,7 @@ public class JavascriptExtractionFn implements ExtractionFn
return false; return false;
} }
JavascriptExtractionFn that = (JavascriptExtractionFn) o; JavaScriptExtractionFn that = (JavaScriptExtractionFn) o;
if (!function.equals(that.function)) { if (!function.equals(that.function)) {
return false; return false;

View File

@ -29,7 +29,7 @@ import org.junit.Test;
import java.util.Iterator; import java.util.Iterator;
public class JavascriptExtractionFnTest public class JavaScriptExtractionFnTest
{ {
private static final String[] testStrings = { private static final String[] testStrings = {
"Quito", "Quito",
@ -46,7 +46,7 @@ public class JavascriptExtractionFnTest
public void testJavascriptSubstring() public void testJavascriptSubstring()
{ {
String function = "function(str) { return str.substring(0,3); }"; String function = "function(str) { return str.substring(0,3); }";
ExtractionFn extractionFn = new JavascriptExtractionFn(function, false); ExtractionFn extractionFn = new JavaScriptExtractionFn(function, false);
for (String str : testStrings) { for (String str : testStrings) {
String res = extractionFn.apply(str); String res = extractionFn.apply(str);
@ -59,28 +59,28 @@ public class JavascriptExtractionFnTest
{ {
String utcHour = "function(t) {\nreturn 'Second ' + Math.floor((t % 60000) / 1000);\n}"; String utcHour = "function(t) {\nreturn 'Second ' + Math.floor((t % 60000) / 1000);\n}";
final long millis = new DateTime("2015-01-02T13:00:59.999Z").getMillis(); final long millis = new DateTime("2015-01-02T13:00:59.999Z").getMillis();
Assert.assertEquals("Second 59" , new JavascriptExtractionFn(utcHour, false).apply(millis)); Assert.assertEquals("Second 59" , new JavaScriptExtractionFn(utcHour, false).apply(millis));
} }
@Test @Test
public void testLongs() throws Exception public void testLongs() throws Exception
{ {
String typeOf = "function(x) {\nreturn typeof x\n}"; String typeOf = "function(x) {\nreturn typeof x\n}";
Assert.assertEquals("number", new JavascriptExtractionFn(typeOf, false).apply(1234L)); Assert.assertEquals("number", new JavaScriptExtractionFn(typeOf, false).apply(1234L));
} }
@Test @Test
public void testFloats() throws Exception public void testFloats() throws Exception
{ {
String typeOf = "function(x) {\nreturn typeof x\n}"; String typeOf = "function(x) {\nreturn typeof x\n}";
Assert.assertEquals("number", new JavascriptExtractionFn(typeOf, false).apply(1234.0)); Assert.assertEquals("number", new JavaScriptExtractionFn(typeOf, false).apply(1234.0));
} }
@Test @Test
public void testCastingAndNull() public void testCastingAndNull()
{ {
String function = "function(x) {\n x = Number(x);\n if(isNaN(x)) return null;\n return Math.floor(x / 5) * 5;\n}"; String function = "function(x) {\n x = Number(x);\n if(isNaN(x)) return null;\n return Math.floor(x / 5) * 5;\n}";
ExtractionFn extractionFn = new JavascriptExtractionFn(function, false); ExtractionFn extractionFn = new JavaScriptExtractionFn(function, false);
Iterator<String> it = Iterators.forArray("0", "5", "5", "10", null); Iterator<String> it = Iterators.forArray("0", "5", "5", "10", null);
@ -95,7 +95,7 @@ public class JavascriptExtractionFnTest
public void testJavascriptRegex() public void testJavascriptRegex()
{ {
String function = "function(str) { return str.replace(/[aeiou]/g, ''); }"; String function = "function(str) { return str.replace(/[aeiou]/g, ''); }";
ExtractionFn extractionFn = new JavascriptExtractionFn(function, false); ExtractionFn extractionFn = new JavaScriptExtractionFn(function, false);
Iterator it = Iterators.forArray("Qt", "Clgry", "Tky", "Stckhlm", "Vncvr", "Prtr", "Wllngtn", "Ontr"); Iterator it = Iterators.forArray("Qt", "Clgry", "Tky", "Stckhlm", "Vncvr", "Prtr", "Wllngtn", "Ontr");
for (String str : testStrings) { for (String str : testStrings) {
@ -299,7 +299,7 @@ public class JavascriptExtractionFnTest
+ "" + ""
+ "}"; + "}";
ExtractionFn extractionFn = new JavascriptExtractionFn(function, false); ExtractionFn extractionFn = new JavaScriptExtractionFn(function, false);
Iterator<String> inputs = Iterators.forArray("introducing", "exploratory", "analytics", "on", "large", "datasets"); Iterator<String> inputs = Iterators.forArray("introducing", "exploratory", "analytics", "on", "large", "datasets");
Iterator<String> it = Iterators.forArray("introduc", "exploratori", "analyt", "on", "larg", "dataset"); Iterator<String> it = Iterators.forArray("introduc", "exploratori", "analyt", "on", "larg", "dataset");
@ -315,7 +315,7 @@ public class JavascriptExtractionFnTest
{ {
final ObjectMapper objectMapper = new DefaultObjectMapper(); final ObjectMapper objectMapper = new DefaultObjectMapper();
final String json = "{ \"type\" : \"javascript\", \"function\" : \"function(str) { return str.substring(0,3); }\" }"; final String json = "{ \"type\" : \"javascript\", \"function\" : \"function(str) { return str.substring(0,3); }\" }";
JavascriptExtractionFn extractionFn = (JavascriptExtractionFn) objectMapper.readValue(json, ExtractionFn.class); JavaScriptExtractionFn extractionFn = (JavaScriptExtractionFn) objectMapper.readValue(json, ExtractionFn.class);
Assert.assertEquals("function(str) { return str.substring(0,3); }", extractionFn.getFunction()); Assert.assertEquals("function(str) { return str.substring(0,3); }", extractionFn.getFunction());
@ -332,7 +332,7 @@ public class JavascriptExtractionFnTest
@Test @Test
public void testInjective() public void testInjective()
{ {
Assert.assertEquals(ExtractionFn.ExtractionType.MANY_TO_ONE, new JavascriptExtractionFn("function(str) { return str; }", false).getExtractionType()); Assert.assertEquals(ExtractionFn.ExtractionType.MANY_TO_ONE, new JavaScriptExtractionFn("function(str) { return str; }", false).getExtractionType());
Assert.assertEquals(ExtractionFn.ExtractionType.ONE_TO_ONE, new JavascriptExtractionFn("function(str) { return str; }", true).getExtractionType()); Assert.assertEquals(ExtractionFn.ExtractionType.ONE_TO_ONE, new JavaScriptExtractionFn("function(str) { return str; }", true).getExtractionType());
} }
} }

View File

@ -50,7 +50,7 @@ import io.druid.query.aggregation.hyperloglog.HyperUniquesAggregatorFactory;
import io.druid.query.dimension.ExtractionDimensionSpec; import io.druid.query.dimension.ExtractionDimensionSpec;
import io.druid.query.extraction.DimExtractionFn; import io.druid.query.extraction.DimExtractionFn;
import io.druid.query.extraction.ExtractionFn; import io.druid.query.extraction.ExtractionFn;
import io.druid.query.extraction.JavascriptExtractionFn; import io.druid.query.extraction.JavaScriptExtractionFn;
import io.druid.query.extraction.LookupExtractionFn; import io.druid.query.extraction.LookupExtractionFn;
import io.druid.query.extraction.MapLookupExtractor; import io.druid.query.extraction.MapLookupExtractor;
import io.druid.query.extraction.RegexDimExtractionFn; import io.druid.query.extraction.RegexDimExtractionFn;
@ -1460,7 +1460,7 @@ public class TopNQueryRunnerTest
new ExtractionDimensionSpec( new ExtractionDimensionSpec(
QueryRunnerTestHelper.marketDimension, QueryRunnerTestHelper.marketDimension,
QueryRunnerTestHelper.marketDimension, QueryRunnerTestHelper.marketDimension,
new JavascriptExtractionFn("function(f) { return \"POTATO\"; }", false), new JavaScriptExtractionFn("function(f) { return \"POTATO\"; }", false),
null null
) )
) )