From 46a7f2660d9d37fce9dce733f77934731f07f0db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Fri, 8 Jan 2016 10:13:54 -0800 Subject: [PATCH] fix casing to be consistent with other classes --- .../druid/query/extraction/ExtractionFn.java | 2 +- ...ionFn.java => JavaScriptExtractionFn.java} | 6 ++--- ...t.java => JavaScriptExtractionFnTest.java} | 22 +++++++++---------- .../druid/query/topn/TopNQueryRunnerTest.java | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) rename processing/src/main/java/io/druid/query/extraction/{JavascriptExtractionFn.java => JavaScriptExtractionFn.java} (96%) rename processing/src/test/java/io/druid/query/extraction/{JavascriptExtractionFnTest.java => JavaScriptExtractionFnTest.java} (95%) diff --git a/processing/src/main/java/io/druid/query/extraction/ExtractionFn.java b/processing/src/main/java/io/druid/query/extraction/ExtractionFn.java index 9bd99157473..f32aefc252d 100644 --- a/processing/src/main/java/io/druid/query/extraction/ExtractionFn.java +++ b/processing/src/main/java/io/druid/query/extraction/ExtractionFn.java @@ -30,7 +30,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; @JsonSubTypes.Type(name = "regex", value = RegexDimExtractionFn.class), @JsonSubTypes.Type(name = "partial", value = MatchingDimExtractionFn.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 = "identity", value = IdentityExtractionFn.class), @JsonSubTypes.Type(name = "lookup", value = LookupExtractionFn.class), diff --git a/processing/src/main/java/io/druid/query/extraction/JavascriptExtractionFn.java b/processing/src/main/java/io/druid/query/extraction/JavaScriptExtractionFn.java similarity index 96% rename from processing/src/main/java/io/druid/query/extraction/JavascriptExtractionFn.java rename to processing/src/main/java/io/druid/query/extraction/JavaScriptExtractionFn.java index 68975d31f5a..4830abb58eb 100644 --- a/processing/src/main/java/io/druid/query/extraction/JavascriptExtractionFn.java +++ b/processing/src/main/java/io/druid/query/extraction/JavaScriptExtractionFn.java @@ -31,7 +31,7 @@ import org.mozilla.javascript.ScriptableObject; import java.nio.ByteBuffer; -public class JavascriptExtractionFn implements ExtractionFn +public class JavaScriptExtractionFn implements ExtractionFn { private static Function compile(String function) { @@ -68,7 +68,7 @@ public class JavascriptExtractionFn implements ExtractionFn private final boolean injective; @JsonCreator - public JavascriptExtractionFn( + public JavaScriptExtractionFn( @JsonProperty("function") String function, @JsonProperty("injective") boolean injective ) @@ -150,7 +150,7 @@ public class JavascriptExtractionFn implements ExtractionFn return false; } - JavascriptExtractionFn that = (JavascriptExtractionFn) o; + JavaScriptExtractionFn that = (JavaScriptExtractionFn) o; if (!function.equals(that.function)) { return false; diff --git a/processing/src/test/java/io/druid/query/extraction/JavascriptExtractionFnTest.java b/processing/src/test/java/io/druid/query/extraction/JavaScriptExtractionFnTest.java similarity index 95% rename from processing/src/test/java/io/druid/query/extraction/JavascriptExtractionFnTest.java rename to processing/src/test/java/io/druid/query/extraction/JavaScriptExtractionFnTest.java index 5b8bac46d3d..f861f97ce19 100644 --- a/processing/src/test/java/io/druid/query/extraction/JavascriptExtractionFnTest.java +++ b/processing/src/test/java/io/druid/query/extraction/JavaScriptExtractionFnTest.java @@ -29,7 +29,7 @@ import org.junit.Test; import java.util.Iterator; -public class JavascriptExtractionFnTest +public class JavaScriptExtractionFnTest { private static final String[] testStrings = { "Quito", @@ -46,7 +46,7 @@ public class JavascriptExtractionFnTest public void testJavascriptSubstring() { 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) { String res = extractionFn.apply(str); @@ -59,28 +59,28 @@ public class JavascriptExtractionFnTest { String utcHour = "function(t) {\nreturn 'Second ' + Math.floor((t % 60000) / 1000);\n}"; 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 public void testLongs() throws Exception { 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 public void testFloats() throws Exception { 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 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}"; - ExtractionFn extractionFn = new JavascriptExtractionFn(function, false); + ExtractionFn extractionFn = new JavaScriptExtractionFn(function, false); Iterator it = Iterators.forArray("0", "5", "5", "10", null); @@ -95,7 +95,7 @@ public class JavascriptExtractionFnTest public void testJavascriptRegex() { 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"); for (String str : testStrings) { @@ -299,7 +299,7 @@ public class JavascriptExtractionFnTest + "" + "}"; - ExtractionFn extractionFn = new JavascriptExtractionFn(function, false); + ExtractionFn extractionFn = new JavaScriptExtractionFn(function, false); Iterator inputs = Iterators.forArray("introducing", "exploratory", "analytics", "on", "large", "datasets"); Iterator it = Iterators.forArray("introduc", "exploratori", "analyt", "on", "larg", "dataset"); @@ -315,7 +315,7 @@ public class JavascriptExtractionFnTest { final ObjectMapper objectMapper = new DefaultObjectMapper(); 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()); @@ -332,7 +332,7 @@ public class JavascriptExtractionFnTest @Test public void testInjective() { - 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.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()); } } diff --git a/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java b/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java index 59e7cc20271..ccd8420c82e 100644 --- a/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java +++ b/processing/src/test/java/io/druid/query/topn/TopNQueryRunnerTest.java @@ -50,7 +50,7 @@ import io.druid.query.aggregation.hyperloglog.HyperUniquesAggregatorFactory; import io.druid.query.dimension.ExtractionDimensionSpec; import io.druid.query.extraction.DimExtractionFn; 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.MapLookupExtractor; import io.druid.query.extraction.RegexDimExtractionFn; @@ -1460,7 +1460,7 @@ public class TopNQueryRunnerTest new ExtractionDimensionSpec( QueryRunnerTestHelper.marketDimension, QueryRunnerTestHelper.marketDimension, - new JavascriptExtractionFn("function(f) { return \"POTATO\"; }", false), + new JavaScriptExtractionFn("function(f) { return \"POTATO\"; }", false), null ) )