You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2018/11/02 11:16:20 UTC
[11/56] lucene-solr:jira/gradle: Add :solr:contrib:analytics module
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/PivotFacetTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/PivotFacetTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/PivotFacetTest.java
deleted file mode 100644
index be0e853..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/PivotFacetTest.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.facet;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class PivotFacetTest extends SolrAnalyticsFacetTestCase {
-
- @BeforeClass
- public static void populate() throws Exception {
- for (int j = 0; j < NUM_LOOPS; ++j) {
- int i = j%INT;
- long l = j%LONG;
- float f = j%FLOAT;
- double d = j%DOUBLE;
- String dt = (1800+j%DATE) + "-12-31T23:59:59Z";
- String dtm = (1800+j%DATE + 10) + "-12-31T23:59:59Z";
- String s = "str" + (j%STRING);
- List<String> fields = new ArrayList<>();
- fields.add("id"); fields.add("1000"+j);
-
- if ( i != 0 ) {
- fields.add("int_i"); fields.add("" + i);
- fields.add("int_im"); fields.add("" + i);
- fields.add("int_im"); fields.add("" + (i+10));
- }
-
- if ( l != 0l ) {
- fields.add("long_l"); fields.add("" + l);
- fields.add("long_lm"); fields.add("" + l);
- fields.add("long_lm"); fields.add("" + (l+10));
- }
-
- if ( f != 0.0f ) {
- fields.add("float_f"); fields.add("" + f);
- fields.add("float_fm"); fields.add("" + f);
- fields.add("float_fm"); fields.add("" + (f+10));
- }
-
- if ( d != 0.0d ) {
- fields.add("double_d"); fields.add("" + d);
- fields.add("double_dm"); fields.add("" + d);
- fields.add("double_dm"); fields.add("" + (d+10));
- }
-
- if ( (j%DATE) != 0 ) {
- fields.add("date_dt"); fields.add(dt);
- fields.add("date_dtm"); fields.add(dt);
- fields.add("date_dtm"); fields.add(dtm);
- }
-
- if ( (j%STRING) != 0 ) {
- fields.add("string_s"); fields.add(s);
- fields.add("string_sm"); fields.add(s);
- fields.add("string_sm"); fields.add(s + "_second");
- }
-
- addDoc(fields);
- }
- commitDocs();
- }
-
- static public final int INT = 7;
- static public final int LONG = 2;
- static public final int FLOAT = 6;
- static public final int DOUBLE = 5;
- static public final int DATE = 3;
- static public final int STRING = 4;
- static public final int NUM_LOOPS = 20;
-
- @Test
- public void pivotFacetTest() throws Exception {
- String analyticsRequest = "{"
- + "\n 'groupings': { "
- + "\n 'grouping' : { "
- + "\n 'expressions' : { "
- + "\n 'mean' : 'mean(fill_missing(int_i,0))', "
- + "\n 'count' : 'count(long_lm)' "
- + "\n }, "
- + "\n 'facets' : { "
- + "\n 'pivoting' : { "
- + "\n 'type' : 'pivot', "
- + "\n 'pivots' : [ "
- + "\n { "
- + "\n 'name' : 'strings', "
- + "\n 'expression' : 'string_sm', "
- + "\n 'sort' : { "
- + "\n 'criteria' : [ "
- + "\n { "
- + "\n 'type' : 'expression', "
- + "\n 'expression' : 'mean', "
- + "\n 'direction' : 'ascending' "
- + "\n }, "
- + "\n { "
- + "\n 'type' : 'facetvalue', "
- + "\n 'direction' : 'descending' "
- + "\n } "
- + "\n ], "
- + "\n 'limit' : 3, "
- + "\n 'offset' : 1 "
- + "\n } "
- + "\n }, "
- + "\n { "
- + "\n 'name' : 'date', "
- + "\n 'expression' : 'fill_missing(date_dt, \\'No Date\\')', "
- + "\n 'sort' : { "
- + "\n 'criteria' : [ "
- + "\n { "
- + "\n 'type' : 'expression', "
- + "\n 'expression' : 'count', "
- + "\n 'direction' : 'ascending' "
- + "\n }, "
- + "\n { "
- + "\n 'type' : 'expression', "
- + "\n 'expression' : 'mean', "
- + "\n 'direction' : 'ascending' "
- + "\n } "
- + "\n ], "
- + "\n 'limit' : 2 "
- + "\n } "
- + "\n } "
- + "\n ] "
- + "\n } "
- + "\n } "
- + "\n } "
- + "\n } "
- + "\n} ";
-
- String test = "groupings=={'grouping':{'pivoting':["
- + "\n { "
- + "\n 'pivot' : 'strings', "
- + "\n 'value' : 'str3', "
- + "\n 'results' : { "
- + "\n 'mean' : 2.6, "
- + "\n 'count' : 10 "
- + "\n }, "
- + "\n 'children' : [ "
- + "\n { "
- + "\n 'pivot' : 'date', "
- + "\n 'value' : '1802-12-31T23:59:59Z', "
- + "\n 'results' : { "
- + "\n 'mean' : 4.0, "
- + "\n 'count' : 2 "
- + "\n } "
- + "\n }, "
- + "\n { "
- + "\n 'pivot' : 'date', "
- + "\n 'value' : 'No Date', "
- + "\n 'results' : { "
- + "\n 'mean' : 2.0, "
- + "\n 'count' : 4 "
- + "\n } "
- + "\n } "
- + "\n ]"
- + "\n }, "
- + "\n { "
- + "\n 'pivot' : 'strings', "
- + "\n 'value' : 'str2_second', "
- + "\n 'results' : { "
- + "\n 'mean' : 3.0, "
- + "\n 'count' : 0 "
- + "\n }, "
- + "\n 'children' : [ "
- + "\n { "
- + "\n 'pivot' : 'date', "
- + "\n 'value' : '1802-12-31T23:59:59Z', "
- + "\n 'results' : { "
- + "\n 'mean' : 1.0, "
- + "\n 'count' : 0 "
- + "\n } "
- + "\n }, "
- + "\n { "
- + "\n 'pivot' : 'date', "
- + "\n 'value' : '1801-12-31T23:59:59Z', "
- + "\n 'results' : { "
- + "\n 'mean' : 3.0, "
- + "\n 'count' : 0 "
- + "\n } "
- + "\n } "
- + "\n ]"
- + "\n }, "
- + "\n { "
- + "\n 'pivot' : 'strings', "
- + "\n 'value' : 'str2', "
- + "\n 'results' : { "
- + "\n 'mean' : 3.0, "
- + "\n 'count' : 0 "
- + "\n }, "
- + "\n 'children' : [ "
- + "\n { "
- + "\n 'pivot' : 'date', "
- + "\n 'value' : '1802-12-31T23:59:59Z', "
- + "\n 'results' : { "
- + "\n 'mean' : 1.0, "
- + "\n 'count' : 0 "
- + "\n } "
- + "\n }, "
- + "\n { "
- + "\n 'pivot' : 'date', "
- + "\n 'value' : '1801-12-31T23:59:59Z', "
- + "\n 'results' : { "
- + "\n 'mean' : 3.0, "
- + "\n 'count' : 0 "
- + "\n } "
- + "\n } "
- + "\n ]"
- + "\n } "
- + "\n]}}";
-
- testAnalytics(analyticsRequest, test);
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/QueryFacetTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/QueryFacetTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/QueryFacetTest.java
deleted file mode 100644
index 63a62c8..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/QueryFacetTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.facet;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class QueryFacetTest extends SolrAnalyticsFacetTestCase {
-
- @BeforeClass
- public static void populate() throws Exception {
- for (int j = 0; j < NUM_LOOPS; ++j) {
- int i = j%INT;
- long l = j%LONG;
- float f = j%FLOAT;
- double d = j%DOUBLE;
- String dt = (1800+j%DATE) + "-12-31T23:59:59Z";
- String dtm = (1800+j%DATE + 10) + "-12-31T23:59:59Z";
- String s = "str" + (j%STRING);
- List<String> fields = new ArrayList<>();
- fields.add("id"); fields.add("1000"+j);
-
- if ( i != 0 ) {
- fields.add("int_i"); fields.add("" + i);
- fields.add("int_im"); fields.add("" + i);
- fields.add("int_im"); fields.add("" + (i+10));
- }
-
- if ( l != 0l ) {
- fields.add("long_l"); fields.add("" + l);
- fields.add("long_lm"); fields.add("" + l);
- fields.add("long_lm"); fields.add("" + (l+10));
- }
-
- if ( f != 0.0f ) {
- fields.add("float_f"); fields.add("" + f);
- fields.add("float_fm"); fields.add("" + f);
- fields.add("float_fm"); fields.add("" + (f+10));
- }
-
- if ( d != 0.0d ) {
- fields.add("double_d"); fields.add("" + d);
- fields.add("double_dm"); fields.add("" + d);
- fields.add("double_dm"); fields.add("" + (d+10));
- }
-
- if ( (j%DATE) != 0 ) {
- fields.add("date_dt"); fields.add(dt);
- fields.add("date_dtm"); fields.add(dt);
- fields.add("date_dtm"); fields.add(dtm);
- }
-
- if ( (j%STRING) != 0 ) {
- fields.add("string_s"); fields.add(s);
- fields.add("string_sm"); fields.add(s);
- fields.add("string_sm"); fields.add(s + "_second");
- }
-
- addDoc(fields);
- }
- commitDocs();
- }
-
- static public final int INT = 7;
- static public final int LONG = 2;
- static public final int FLOAT = 6;
- static public final int DOUBLE = 5;
- static public final int DATE = 3;
- static public final int STRING = 4;
- static public final int NUM_LOOPS = 20;
-
- @Test
- public void queryFacetTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("mean", "mean(int_i)");
- expressions.put("count", "count(string_sm)");
-
- // Value Facet "with_missing"
- addFacet("with_missing", "{ 'type':'query', 'queries':{'q1':'long_l:1 AND float_f:1.0','q2':'double_dm:[3 TO 11] OR double_dm:1'}}");
-
- addFacetValue("q1");
- addFacetResult("mean", 4.0);
- addFacetResult("count", 8L);
-
- addFacetValue("q2");
- addFacetResult("mean", 38.0/11.0);
- addFacetResult("count", 18L);
-
- testGrouping(expressions);
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/RangeFacetTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/RangeFacetTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/RangeFacetTest.java
deleted file mode 100644
index 9f482bc..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/RangeFacetTest.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.facet;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class RangeFacetTest extends SolrAnalyticsFacetTestCase {
-
- @BeforeClass
- public static void populate() throws Exception {
- for (int j = 0; j < NUM_LOOPS; ++j) {
- int i = j%INT;
- long l = j%LONG;
- float f = j%FLOAT;
- double d = j%DOUBLE;
- String dt = (1800+j%DATE) + "-12-31T23:59:59Z";
- String dtm = (1800+j%DATE + 10) + "-12-31T23:59:59Z";
- String s = "str" + (j%STRING);
- List<String> fields = new ArrayList<>();
- fields.add("id"); fields.add("1000"+j);
-
- if ( i != 0 ) {
- fields.add("int_i"); fields.add("" + i);
- fields.add("int_im"); fields.add("" + i);
- fields.add("int_im"); fields.add("" + (i+10));
- }
-
- if ( l != 0l ) {
- fields.add("long_l"); fields.add("" + l);
- fields.add("long_lm"); fields.add("" + l);
- fields.add("long_lm"); fields.add("" + (l+10));
- }
-
- if ( f != 0.0f ) {
- fields.add("float_f"); fields.add("" + f);
- fields.add("float_fm"); fields.add("" + f);
- fields.add("float_fm"); fields.add("" + (f+10));
- }
-
- if ( d != 0.0d ) {
- fields.add("double_d"); fields.add("" + d);
- fields.add("double_dm"); fields.add("" + d);
- fields.add("double_dm"); fields.add("" + (d+10));
- }
-
- if ( (j%DATE) != 0 ) {
- fields.add("date_dt"); fields.add(dt);
- fields.add("date_dtm"); fields.add(dt);
- fields.add("date_dtm"); fields.add(dtm);
- }
-
- if ( (j%STRING) != 0 ) {
- fields.add("string_s"); fields.add(s);
- fields.add("string_sm"); fields.add(s);
- fields.add("string_sm"); fields.add(s + "_second");
- }
-
- addDoc(fields);
- }
- commitDocs();
- }
-
- static public final int INT = 7;
- static public final int LONG = 2;
- static public final int FLOAT = 6;
- static public final int DOUBLE = 5;
- static public final int DATE = 3;
- static public final int STRING = 4;
- static public final int NUM_LOOPS = 20;
-
- @Test
- public void intRangeHardEndTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("mean", "mean(float_f)");
- expressions.put("count", "count(string_sm)");
-
- // Hard end on
- addFacet("hard_end_on", "{ 'type':'range', "
- + " 'field': 'int_im', "
- + " 'start': '2', "
- + " 'end' : '13', "
- + " 'gaps' : ['2', '5', '3'], "
- + " 'hardend' : true }");
-
- addFacetValue("[2 TO 4)");
- addFacetResult("mean", 3.5);
- addFacetResult("count", 10L);
-
- addFacetValue("[4 TO 9)");
- addFacetResult("mean", 16.0/5.0);
- addFacetResult("count", 12L);
-
- addFacetValue("[9 TO 12)");
- addFacetResult("mean", 2.0);
- addFacetResult("count", 4L);
-
- addFacetValue("[12 TO 13)");
- addFacetResult("mean", 3.0);
- addFacetResult("count", 4L);
-
- // Hard end off
- addFacet("hard_end_off", "{ 'type':'range', "
- + " 'field': 'int_im', "
- + " 'start': '2', "
- + " 'end' : '13', "
- + " 'gaps' : ['2', '5', '3'], "
- + " 'hardend' : false }");
-
- addFacetValue("[2 TO 4)");
- addFacetResult("mean", 3.5);
- addFacetResult("count", 10L);
-
- addFacetValue("[4 TO 9)");
- addFacetResult("mean", 16.0/5.0);
- addFacetResult("count", 12L);
-
- addFacetValue("[9 TO 12)");
- addFacetResult("mean", 2.0);
- addFacetResult("count", 4L);
-
- addFacetValue("[12 TO 15)");
- addFacetResult("mean", 30.0/8.0);
- addFacetResult("count", 14L);
-
- testGrouping(expressions);
- }
-
- @Test
- public void doubleOthersTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("mean", "mean(float_f)");
- expressions.put("count", "count(string_sm)");
-
- addFacet("before_between", "{ 'type':'range', "
- + " 'field': 'double_d', "
- + " 'start': '2', "
- + " 'end' : '4', "
- + " 'gaps' : ['1'], "
- + " 'others' : ['before', 'between'] }");
-
- addFacetValue("[2.0 TO 3.0)");
- addFacetResult("mean", 8.0/3.0);
- addFacetResult("count", 6L);
-
- addFacetValue("[3.0 TO 4.0)");
- addFacetResult("mean", 2.0);
- addFacetResult("count", 6L);
-
- addFacetValue("(* TO 2.0)");
- addFacetResult("mean", 10.0/3.0);
- addFacetResult("count", 6L);
-
- addFacetValue("[2.0 TO 4.0)");
- addFacetResult("mean", 14.0/6.0);
- addFacetResult("count", 12L);
-
- addFacet("after", "{ 'type':'range', "
- + " 'field': 'double_d', "
- + " 'start': '2', "
- + " 'end' : '4', "
- + " 'gaps' : ['1'], "
- + " 'others' : ['after'] }");
-
- addFacetValue("[2.0 TO 3.0)");
- addFacetResult("mean", 8.0/3.0);
- addFacetResult("count", 6L);
-
- addFacetValue("[3.0 TO 4.0)");
- addFacetResult("mean", 2.0);
- addFacetResult("count", 6L);
-
- addFacetValue("[4.0 TO *)");
- addFacetResult("mean", 2.5);
- addFacetResult("count", 6L);
-
- testGrouping(expressions);
- }
-
- @Test
- public void dateIncludeTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("mean", "mean(float_f)");
- expressions.put("count", "count(string_sm)");
-
- addFacet("lower_upper", "{ 'type':'range', "
- + " 'field': 'date_dt', "
- + " 'start': '1801-12-31T23:59:59Z', "
- + " 'end' : '1803-12-31T23:59:59Z', "
- + " 'gaps' : ['+1YEAR'], "
- + " 'include' : ['lower', 'upper'] }");
-
- addFacetValue("[1801-12-31T23:59:59Z TO 1802-12-31T23:59:59Z]");
- addFacetResult("mean", 37.0/13.0);
- addFacetResult("count", 20L);
-
- addFacetValue("[1802-12-31T23:59:59Z TO 1803-12-31T23:59:59Z]");
- addFacetResult("mean", 3.5);
- addFacetResult("count", 10L);
-
- testGrouping(expressions);
-
- addFacet("lower_upper", "{ 'type':'range', "
- + " 'field': 'date_dt', "
- + " 'start': '1801-12-31T23:59:59Z', "
- + " 'end' : '1803-12-31T23:59:59Z', "
- + " 'gaps' : ['+1YEAR'], "
- + " 'include' : ['lower','edge'] }");
-
- addFacetValue("[1801-12-31T23:59:59Z TO 1802-12-31T23:59:59Z)");
- addFacetResult("mean", 16.0/7.0);
- addFacetResult("count", 10L);
-
- addFacetValue("[1802-12-31T23:59:59Z TO 1803-12-31T23:59:59Z]");
- addFacetResult("mean", 3.5);
- addFacetResult("count", 10L);
-
- testGrouping(expressions);
- }
-
- @Test
- public void floatIncludeOuterTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("mean", "mean(int_i)");
- expressions.put("count", "count(string_sm)");
-
- addFacet("include_outer", "{ 'type':'range', "
- + " 'field': 'float_f', "
- + " 'start': '1', "
- + " 'end' : '5', "
- + " 'gaps' : ['2'], "
- + " 'include' : ['outer'], "
- + " 'others' : ['all'] }");
-
- addFacetValue("(1.0 TO 3.0)");
- addFacetResult("mean", 1.5);
- addFacetResult("count", 4L);
-
- addFacetValue("(3.0 TO 5.0)");
- addFacetResult("mean", 3.0);
- addFacetResult("count", 2L);
-
- addFacetValue("(* TO 1.0]");
- addFacetResult("mean", 4.0);
- addFacetResult("count", 8L);
-
- addFacetValue("[5.0 TO *)");
- addFacetResult("mean", 4.0);
- addFacetResult("count", 6L);
-
- addFacetValue("(1.0 TO 5.0)");
- addFacetResult("mean", 18.0/8.0);
- addFacetResult("count", 12L);
-
- testGrouping(expressions);
- }
-
- @Test
- public void floatIncludeAllTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("mean", "mean(int_i)");
- expressions.put("count", "count(string_sm)");
-
- addFacet("include_all", "{ 'type':'range', "
- + " 'field': 'float_f', "
- + " 'start': '1', "
- + " 'end' : '5', "
- + " 'gaps' : ['2'], "
- + " 'include' : ['all'], "
- + " 'others' : ['all'] }");
-
- addFacetValue("[1.0 TO 3.0]");
- addFacetResult("mean", 21.0/8.0);
- addFacetResult("count", 18L);
-
- addFacetValue("[3.0 TO 5.0]");
- addFacetResult("mean", 3.0);
- addFacetResult("count", 14L);
-
- addFacetValue("(* TO 1.0]");
- addFacetResult("mean", 4.0);
- addFacetResult("count", 8L);
-
- addFacetValue("[5.0 TO *)");
- addFacetResult("mean", 4.0);
- addFacetResult("count", 6L);
-
- addFacetValue("[1.0 TO 5.0]");
- addFacetResult("mean", 3.0);
- addFacetResult("count", 26L);
-
- testGrouping(expressions);
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/SolrAnalyticsFacetTestCase.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/SolrAnalyticsFacetTestCase.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/SolrAnalyticsFacetTestCase.java
deleted file mode 100644
index 22decd7..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/SolrAnalyticsFacetTestCase.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.facet;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.solr.analytics.SolrAnalyticsTestCase;
-import org.junit.Before;
-
-public class SolrAnalyticsFacetTestCase extends SolrAnalyticsTestCase {
-
- private List<FVP> facetResults;
- private Map<String, List<FVP>> results = new HashMap<>();
- private Map<String, String> facets = new HashMap<>();
- private FVP fvp;
- private int fvp_num;
-
- @Before
- protected void initData() {
- results = new HashMap<>();
- facets = new HashMap<>();
- }
-
- protected void addFacet(String name, String json) {
- facets.put(name, json);
- facetResults = new ArrayList<>();
- results.put(name, facetResults);
- fvp_num = 0;
- }
-
- protected void addFacetValue(String value) {
- fvp = new FVP(fvp_num++, value, new HashMap<>());
- facetResults.add(fvp);
- }
-
- protected void addFacetResult(String expr, Comparable<?> result) {
- fvp.expectedResults.put(expr, result);
- }
-
- protected void testGrouping(Map<String,String> expressions) {
- try {
- testGrouping("grouping", expressions, facets, results);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- protected void testGrouping(Map<String,String> expressions, boolean sortAscending) {
- try {
- testGrouping("grouping", expressions, facets, results, sortAscending);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- protected void testGrouping(Map<String,String> expressions, String sortExpression, boolean sortAscending) {
- try {
- testGrouping("grouping", expressions, facets, results, sortExpression, sortAscending);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/ValueFacetTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/ValueFacetTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/ValueFacetTest.java
deleted file mode 100644
index da117de..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/facet/ValueFacetTest.java
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.facet;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class ValueFacetTest extends SolrAnalyticsFacetTestCase {
-
- @BeforeClass
- public static void populate() throws Exception {
- for (int j = 0; j < NUM_LOOPS; ++j) {
- int i = j%INT;
- long l = j%LONG;
- float f = j%FLOAT;
- double d = j%DOUBLE;
- String dt = (1800+j%DATE) + "-12-31T23:59:59Z";
- String dtm = (1800+j%DATE + 10) + "-12-31T23:59:59Z";
- String s = "str" + (j%STRING);
- List<String> fields = new ArrayList<>();
- fields.add("id"); fields.add("1000"+j);
-
- if ( i != 0 ) {
- fields.add("int_i"); fields.add("" + i);
- fields.add("int_im"); fields.add("" + i);
- fields.add("int_im"); fields.add("" + (i+10));
- }
-
- if ( l != 0l ) {
- fields.add("long_l"); fields.add("" + l);
- fields.add("long_lm"); fields.add("" + l);
- fields.add("long_lm"); fields.add("" + (l+10));
- }
-
- if ( f != 0.0f ) {
- fields.add("float_f"); fields.add("" + f);
- fields.add("float_fm"); fields.add("" + f);
- fields.add("float_fm"); fields.add("" + (f+10));
- }
-
- if ( d != 0.0d ) {
- fields.add("double_d"); fields.add("" + d);
- fields.add("double_dm"); fields.add("" + d);
- fields.add("double_dm"); fields.add("" + (d+10));
- }
-
- if ( (j%DATE) != 0 ) {
- fields.add("date_dt"); fields.add(dt);
- fields.add("date_dtm"); fields.add(dt);
- fields.add("date_dtm"); fields.add(dtm);
- }
-
- if ( (j%STRING) != 0 ) {
- fields.add("string_s"); fields.add(s);
- fields.add("string_sm"); fields.add(s);
- fields.add("string_sm"); fields.add(s + "_second");
- }
-
- addDoc(fields);
- }
- commitDocs();
- }
-
- static public final int INT = 7;
- static public final int LONG = 2;
- static public final int FLOAT = 6;
- static public final int DOUBLE = 5;
- static public final int DATE = 3;
- static public final int STRING = 4;
- static public final int NUM_LOOPS = 20;
-
- @Test
- public void countTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("single", "count(float_f)");
- expressions.put("multi", "count(string_sm)");
-
- // Value Facet "with_missing"
- addFacet("with_missing", "{ 'type':'value', 'expression':'fill_missing(long_l,\\'No Long\\')' }");
-
- addFacetValue("1");
- addFacetResult("single", 10L);
- addFacetResult("multi", 20L);
-
- addFacetValue("No Long");
- addFacetResult("single", 6L);
- addFacetResult("multi", 10L);
-
- testGrouping(expressions, "single", true);
- }
-
- @Test
- public void docCountTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("single", "doc_count(date_dt)");
- expressions.put("multi", "doc_count(float_fm)");
-
- // Value Facet "with_missing"
- addFacet("with_missing", "{ 'type':'value', 'expression':'fill_missing(string_sm,\\'No Values\\')' }");
-
- addFacetValue("str1");
- addFacetResult("single", 4L);
- addFacetResult("multi", 5L);
-
- addFacetValue("str1_second");
- addFacetResult("single", 4L);
- addFacetResult("multi", 5L);
-
- addFacetValue("str2");
- addFacetResult("single", 3L);
- addFacetResult("multi", 3L);
-
- addFacetValue("str2_second");
- addFacetResult("single", 3L);
- addFacetResult("multi", 3L);
-
- addFacetValue("str3");
- addFacetResult("single", 3L);
- addFacetResult("multi", 5L);
-
- addFacetValue("str3_second");
- addFacetResult("single", 3L);
- addFacetResult("multi", 5L);
-
- addFacetValue("No Values");
- addFacetResult("single", 3L);
- addFacetResult("multi", 3L);
-
- // Value Facet "no_missing"
- addFacet("no_missing", "{ 'type':'value', 'expression':'long_l' }");
-
- addFacetValue("1");
- addFacetResult("single", 7L);
- addFacetResult("multi", 10L);
-
- testGrouping(expressions, false);
- }
-
- @Test
- public void missingTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("single", "missing(date_dt)");
- expressions.put("multi", "missing(float_fm)");
-
- // Value Facet "with_missing"
- addFacet("with_missing", "{ 'type':'value', 'expression':'fill_missing(string_sm,\\'No Values\\')' }");
-
- addFacetValue("str1");
- addFacetResult("single", 1L);
- addFacetResult("multi", 0L);
-
- addFacetValue("str1_second");
- addFacetResult("single", 1L);
- addFacetResult("multi", 0L);
-
- addFacetValue("str2");
- addFacetResult("single", 2L);
- addFacetResult("multi", 2L);
-
- addFacetValue("str2_second");
- addFacetResult("single", 2L);
- addFacetResult("multi", 2L);
-
- addFacetValue("str3");
- addFacetResult("single", 2L);
- addFacetResult("multi", 0L);
-
- addFacetValue("str3_second");
- addFacetResult("single", 2L);
- addFacetResult("multi", 0L);
-
- addFacetValue("No Values");
- addFacetResult("single", 2L);
- addFacetResult("multi", 2L);
-
- // Value Facet "no_missing"
- addFacet("no_missing", "{ 'type':'value', 'expression':'long_l' }");
-
- addFacetValue("1");
- addFacetResult("single", 3L);
- addFacetResult("multi", 0L);
-
- testGrouping(expressions, false);
- }
-
- @Test
- public void uniqueTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("int", "unique(int_i)");
- expressions.put("longs", "unique(long_lm)");
- expressions.put("float", "unique(float_f)");
- expressions.put("doubles", "unique(double_dm)");
- expressions.put("dates", "unique(date_dtm)");
- expressions.put("string", "unique(string_s)");
-
- // Value Facet "without_missing"
- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");
-
- addFacetValue("1801-12-31T23:59:59Z");
- addFacetResult("int", 6L);
- addFacetResult("longs", 2L);
- addFacetResult("float", 2L);
- addFacetResult("doubles", 8L);
- addFacetResult("dates", 2L);
- addFacetResult("string", 3L);
-
- addFacetValue("1802-12-31T23:59:59Z");
- addFacetResult("int", 5L);
- addFacetResult("longs", 2L);
- addFacetResult("float", 2L);
- addFacetResult("doubles", 8L);
- addFacetResult("dates", 2L);
- addFacetResult("string", 3L);
-
- testGrouping(expressions, false);
- }
-
- @Test
- public void minTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("int", "min(int_i)");
- expressions.put("longs", "min(long_lm)");
- expressions.put("float", "min(float_f)");
- expressions.put("doubles", "min(double_dm)");
- expressions.put("dates", "min(date_dtm)");
- expressions.put("string", "min(string_s)");
-
- // Value Facet "without_missing"
- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");
-
- addFacetValue("1801-12-31T23:59:59Z");
- addFacetResult("int", 1);
- addFacetResult("longs", 1L);
- addFacetResult("float", 1.0F);
- addFacetResult("doubles", 1.0);
- addFacetResult("dates", "1801-12-31T23:59:59Z");
- addFacetResult("string", "str1");
-
- addFacetValue("1802-12-31T23:59:59Z");
- addFacetResult("int", 1);
- addFacetResult("longs", 1L);
- addFacetResult("float", 2.0F);
- addFacetResult("doubles", 1.0);
- addFacetResult("dates", "1802-12-31T23:59:59Z");
- addFacetResult("string", "str1");
-
- testGrouping(expressions, false);
- }
-
- @Test
- public void maxTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("int", "max(int_i)");
- expressions.put("longs", "max(long_lm)");
- expressions.put("float", "max(float_f)");
- expressions.put("doubles", "max(double_dm)");
- expressions.put("dates", "max(date_dtm)");
- expressions.put("string", "max(string_s)");
-
- // Value Facet "without_missing"
- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");
-
- addFacetValue("1801-12-31T23:59:59Z");
- addFacetResult("int", 6);
- addFacetResult("longs", 11L);
- addFacetResult("float", 4.0F);
- addFacetResult("doubles", 14.0);
- addFacetResult("dates", "1811-12-31T23:59:59Z");
- addFacetResult("string", "str3");
-
- addFacetValue("1802-12-31T23:59:59Z");
- addFacetResult("int", 5);
- addFacetResult("longs", 11L);
- addFacetResult("float", 5.0F);
- addFacetResult("doubles", 14.0);
- addFacetResult("dates", "1812-12-31T23:59:59Z");
- addFacetResult("string", "str3");
-
- testGrouping(expressions, false);
- }
-
- @Test
- public void sumTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("single", "sum(float_f)");
- expressions.put("multi", "sum(double_dm)");
-
- // Value Facet "without_missing"
- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");
-
- addFacetValue("1801-12-31T23:59:59Z");
- addFacetResult("single", 16.0);
- addFacetResult("multi", 90.0);
-
- addFacetValue("1802-12-31T23:59:59Z");
- addFacetResult("single", 21.0);
- addFacetResult("multi", 74.0);
-
- testGrouping(expressions, false);
- }
-
- @Test
- public void meanTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("single", "mean(float_f)");
- expressions.put("multi", "mean(double_dm)");
-
- // Value Facet "without_missing"
- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");
-
- addFacetValue("1801-12-31T23:59:59Z");
- addFacetResult("single", 16.0/7.0);
- addFacetResult("multi", 90.0/12.0);
-
- addFacetValue("1802-12-31T23:59:59Z");
- addFacetResult("single", 21.0/6.0);
- addFacetResult("multi", 74.0/10.0);
-
- testGrouping(expressions, "multi", true);
- }
-
- @Test
- public void medianTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("int", "median(int_i)");
- expressions.put("longs", "median(long_lm)");
- expressions.put("float", "median(float_f)");
- expressions.put("doubles", "median(double_dm)");
- expressions.put("dates", "median(date_dtm)");
-
- // Value Facet "without_missing"
- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");
-
- addFacetValue("1801-12-31T23:59:59Z");
- addFacetResult("int", 3.5);
- addFacetResult("longs", 6.0);
- addFacetResult("float", 1.0);
- addFacetResult("doubles", 7.5);
- addFacetResult("dates", "1806-12-31T23:59:59Z");
-
- addFacetValue("1802-12-31T23:59:59Z");
- addFacetResult("int", 3.0);
- addFacetResult("longs", 6.0);
- addFacetResult("float", 3.5);
- addFacetResult("doubles", 7.50);
- addFacetResult("dates", "1808-01-01T11:59:59Z");
-
- testGrouping(expressions, false);
- }
-
- @Test
- public void percentileTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("int", "percentile(20,int_i)");
- expressions.put("longs", "percentile(80,long_lm)");
- expressions.put("float", "percentile(40,float_f)");
- expressions.put("doubles", "percentile(50,double_dm)");
- expressions.put("dates", "percentile(0,date_dtm)");
- expressions.put("string", "percentile(99.99,string_s)");
-
- // Value Facet "without_missing"
- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");
-
- addFacetValue("1801-12-31T23:59:59Z");
- addFacetResult("int", 2);
- addFacetResult("longs", 11L);
- addFacetResult("float", 1.0F);
- addFacetResult("doubles", 11.0);
- addFacetResult("dates", "1801-12-31T23:59:59Z");
- addFacetResult("string", "str3");
-
- addFacetValue("1802-12-31T23:59:59Z");
- addFacetResult("int", 2);
- addFacetResult("longs", 11L);
- addFacetResult("float", 2.0F);
- addFacetResult("doubles", 11.0);
- addFacetResult("dates", "1802-12-31T23:59:59Z");
- addFacetResult("string", "str3");
-
- testGrouping(expressions, "dates", false);
- }
-
- @Test
- public void ordinalTest() throws Exception {
- Map<String, String> expressions = new HashMap<>();
- expressions.put("int", "ordinal(3,int_i)");
- expressions.put("longs", "ordinal(-2,long_lm)");
- expressions.put("float", "ordinal(-3,float_f)");
- expressions.put("doubles", "ordinal(1,double_dm)");
- expressions.put("dates", "ordinal(-1,date_dtm)");
- expressions.put("string", "ordinal(4,string_s)");
-
- // Value Facet "without_missing"
- addFacet("without_missing", "{ 'type':'value', 'expression':'date_dt' }");
-
- addFacetValue("1801-12-31T23:59:59Z");
- addFacetResult("int", 3);
- addFacetResult("longs", 11L);
- addFacetResult("float", 4.0F);
- addFacetResult("doubles", 1.0);
- addFacetResult("dates", "1811-12-31T23:59:59Z");
- addFacetResult("string", "str3");
-
- addFacetValue("1802-12-31T23:59:59Z");
- addFacetResult("int", 3);
- addFacetResult("longs", 11L);
- addFacetResult("float", 5.0F);
- addFacetResult("doubles", 1.0);
- addFacetResult("dates", "1812-12-31T23:59:59Z");
- addFacetResult("string", "str2");
-
- testGrouping(expressions, "string", false);
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/AbstractAnalyticsFieldTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/AbstractAnalyticsFieldTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/AbstractAnalyticsFieldTest.java
deleted file mode 100644
index ae4b881..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/AbstractAnalyticsFieldTest.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.field;
-
-import java.io.IOException;
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.function.Predicate;
-
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.util.Bits;
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.analytics.ExpressionFactory;
-import org.apache.solr.schema.IndexSchema;
-import org.apache.solr.search.SolrIndexSearcher;
-import org.apache.solr.util.RefCounted;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-public class AbstractAnalyticsFieldTest extends SolrTestCaseJ4 {
-
- private static IndexSchema indexSchema;
- private static SolrIndexSearcher searcher;
- private static RefCounted<SolrIndexSearcher> ref;
-
- protected static Map<String,Integer> singleInts;
- protected static Map<String,Map<Integer,Integer>> multiInts;
- protected static Map<String,Long> singleLongs;
- protected static Map<String,Map<Long,Integer>> multiLongs;
- protected static Map<String,Float> singleFloats;
- protected static Map<String,Map<Float,Integer>> multiFloats;
- protected static Map<String,Double> singleDoubles;
- protected static Map<String,Map<Double,Integer>> multiDoubles;
- protected static Map<String,Long> singleDates;
- protected static Map<String,Map<Long,Integer>> multiDates;
- protected static Map<String,String> singleStrings;
- protected static Map<String,Map<String,Integer>> multiStrings;
- protected static Map<String,Boolean> singleBooleans;
- protected static Map<String,Map<Boolean,Integer>> multiBooleans;
-
- private static List<String> missingDocuments;
-
- @BeforeClass
- public static void createSchemaAndFields() throws Exception {
- initCore("solrconfig-analytics.xml","schema-analytics.xml");
-
- singleInts = new HashMap<>();
- multiInts = new HashMap<>();
- singleLongs = new HashMap<>();
- multiLongs = new HashMap<>();
- singleFloats = new HashMap<>();
- multiFloats = new HashMap<>();
- singleDoubles = new HashMap<>();
- multiDoubles = new HashMap<>();
- singleDates = new HashMap<>();
- multiDates = new HashMap<>();
- singleStrings = new HashMap<>();
- multiStrings = new HashMap<>();
- singleBooleans = new HashMap<>();
- multiBooleans = new HashMap<>();
-
- missingDocuments = new ArrayList<>();
-
- assertU(adoc("id", "-2"));
- missingDocuments.add("-2");
- assertU(adoc("id", "5"));
- missingDocuments.add("5");
- for (int i = -1; i < 5; ++i) {
- assertU(adoc(
- "id", "" + i,
-
- "int_i_t", "" + i,
- "int_im_t", "" + i,
- "int_im_t", "" + (i + 10),
- "int_im_t", "" + (i + 10),
- "int_im_t", "" + (i + 20),
-
- "int_i_p", "" + i,
- "int_im_p", "" + i,
- "int_im_p", "" + (i + 10),
- "int_im_p", "" + (i + 10),
- "int_im_p", "" + (i + 20),
-
- "long_l_t", "" + i,
- "long_lm_t", "" + i,
- "long_lm_t", "" + (i + 10),
- "long_lm_t", "" + (i + 10),
- "long_lm_t", "" + (i + 20),
-
- "long_l_p", "" + i,
- "long_lm_p", "" + i,
- "long_lm_p", "" + (i + 10),
- "long_lm_p", "" + (i + 10),
- "long_lm_p", "" + (i + 20),
-
- "float_f_t", "" + (i + .75F),
- "float_fm_t", "" + (i + .75F),
- "float_fm_t", "" + (i + 10.75F),
- "float_fm_t", "" + (i + 10.75F),
- "float_fm_t", "" + (i + 20.75F),
-
- "float_f_p", "" + (i + .75F),
- "float_fm_p", "" + (i + .75F),
- "float_fm_p", "" + (i + 10.75F),
- "float_fm_p", "" + (i + 10.75F),
- "float_fm_p", "" + (i + 20.75F),
-
- "double_d_t", "" + (i + .5),
- "double_dm_t", "" + (i + .5),
- "double_dm_t", "" + (i + 10.5),
- "double_dm_t", "" + (i + 10.5),
- "double_dm_t", "" + (i + 20.5),
-
- "double_d_p", "" + (i + .5),
- "double_dm_p", "" + (i + .5),
- "double_dm_p", "" + (i + 10.5),
- "double_dm_p", "" + (i + 10.5),
- "double_dm_p", "" + (i + 20.5),
-
- "date_dt_t", (1800 + i) + "-12-31T23:59:59Z",
- "date_dtm_t", (1800 + i) + "-12-31T23:59:59Z",
- "date_dtm_t", (1800 + i + 10) + "-12-31T23:59:59Z",
- "date_dtm_t", (1800 + i + 10) + "-12-31T23:59:59Z",
- "date_dtm_t", (1800 + i + 20) + "-12-31T23:59:59Z",
-
- "date_dt_p", (1800 + i) + "-12-31T23:59:59Z",
- "date_dtm_p", (1800 + i) + "-12-31T23:59:59Z",
- "date_dtm_p", (1800 + i + 10) + "-12-31T23:59:59Z",
- "date_dtm_p", (1800 + i + 10) + "-12-31T23:59:59Z",
- "date_dtm_p", (1800 + i + 20) + "-12-31T23:59:59Z",
-
- "string_s", "abc" + i,
- "string_sm", "abc" + i,
- "string_sm", "def" + i,
- "string_sm", "def" + i,
- "string_sm", "ghi" + i,
-
- "boolean_b", Boolean.toString(i % 3 == 0),
- "boolean_bm", "false",
- "boolean_bm", "true",
- "boolean_bm", "false"
- ));
-
- singleInts.put(""+i, i);
- Map<Integer, Integer> ints = new HashMap<>();
- ints.put(i, 1);
- ints.put(i + 10, 2);
- ints.put(i + 20, 1);
- multiInts.put(""+i, ints);
-
- singleLongs.put(""+i, (long) i);
- Map<Long, Integer> longs = new HashMap<>();
- longs.put((long) i, 1);
- longs.put(i + 10L, 2);
- longs.put(i + 20L, 1);
- multiLongs.put(""+i, longs);
-
- singleFloats.put(""+i, i + .75F);
- Map<Float, Integer> floats = new HashMap<>();
- floats.put(i + .75F, 1);
- floats.put(i + 10.75F, 2);
- floats.put(i + 20.75F, 1);
- multiFloats.put(""+i, floats);
-
- singleDoubles.put(""+i, i + .5);
- Map<Double, Integer> doubles = new HashMap<>();
- doubles.put(i + .5, 1);
- doubles.put(i + 10.5, 2);
- doubles.put(i + 20.5, 1);
- multiDoubles.put(""+i, doubles);
-
- singleDates.put(""+i, Instant.parse((1800 + i) + "-12-31T23:59:59Z").toEpochMilli());
- Map<Long, Integer> dates = new HashMap<>();
- dates.put(Instant.parse((1800 + i) + "-12-31T23:59:59Z").toEpochMilli(), 1);
- dates.put(Instant.parse((1800 + i + 10) + "-12-31T23:59:59Z").toEpochMilli(), 2);
- dates.put(Instant.parse((1800 + i + 20) + "-12-31T23:59:59Z").toEpochMilli(), 1);
- multiDates.put(""+i, dates);
-
- singleStrings.put(""+i, "abc" + i);
- Map<String, Integer> strings = new HashMap<>();
- strings.put("abc" + i, 1);
- strings.put("def" + i, 2);
- strings.put("ghi" + i, 1);
- multiStrings.put(""+i, strings);
-
- singleBooleans.put(""+i, i % 3 == 0);
- Map<Boolean, Integer> booleans = new HashMap<>();
- booleans.put(true, 1);
- booleans.put(false, 2);
- multiBooleans.put(""+i, booleans);
- }
- assertU(commit());
-
- ref = h.getCore().getSearcher();
- searcher = ref.get();
-
- indexSchema = h.getCore().getLatestSchema();
- }
-
- protected ExpressionFactory getExpressionFactory() {
- ExpressionFactory fact = new ExpressionFactory(indexSchema);
- fact.startRequest();
- return fact;
- }
-
- @AfterClass
- public static void closeSearcher() throws IOException {
- ref.decref();
- }
-
- protected <T> void checkSingleFieldValues(Map<String,T> expected, Map<String,T> found, Set<String> missing) {
- expected.forEach( (id, value) -> {
- assertTrue("Field does not contain value for id '" + id + "'.", found.containsKey(id));
- assertEquals(value, found.get(id));
- });
- assertEquals(expected.size(), found.size());
-
- missingDocuments.forEach( id -> assertTrue("Field does not have correct information for missing id '" + id + "'.", missing.contains(id)));
- assertEquals(missingDocuments.size(), missing.size());
- }
-
- protected <T> void checkMultiFieldValues(Map<String,Map<T,Integer>> expected, Map<String,Map<T,Integer>> found, Set<String> missing, boolean deduplicated) {
- expected.forEach( (id, expectedValues) -> {
- assertTrue("Field does not contain values for id '" + id + "'.", found.containsKey(id));
- Map<T,Integer> foundValues = found.get(id);
- expectedValues.forEach( (value, count) -> {
- assertTrue("Value '" + value + "' not found for document with id '" + id + "'.", foundValues.containsKey(value));
- if (deduplicated) {
- assertEquals(1, foundValues.get(value).intValue());
- } else {
- assertEquals(count, foundValues.get(value));
- }
- });
- assertEquals(expectedValues.size(), foundValues.size());
- });
- assertEquals(expected.size(), found.size());
-
- missingDocuments.forEach( id -> assertTrue("Field does not have correct information for missing id '" + id + "'.", missing.contains(id)));
- assertEquals(missingDocuments.size(), missing.size());
- }
-
- protected boolean emptyValueFound;
-
- protected Set<String> collectFieldValues(AnalyticsField testField, Predicate<String> valuesFiller) throws IOException {
- StringField idField = new StringField("id");
- Set<String> missing = new HashSet<>();
-
- List<LeafReaderContext> contexts = searcher.getTopReaderContext().leaves();
- for (LeafReaderContext context : contexts) {
- testField.doSetNextReader(context);
- idField.doSetNextReader(context);
- Bits liveDocs = context.reader().getLiveDocs();
- for (int doc = 0; doc < context.reader().maxDoc(); doc++) {
- if (liveDocs != null && !liveDocs.get(doc)) {
- continue;
- }
- // Add a document to the statistics being generated
- testField.collect(doc);
- idField.collect(doc);
-
- String id = idField.getString();
- if (!valuesFiller.test(id)) {
- missing.add(id);
- }
- }
- }
- return missing;
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/BooleanFieldsTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/BooleanFieldsTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/BooleanFieldsTest.java
deleted file mode 100644
index 4c3b79f..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/BooleanFieldsTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.field;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.solr.analytics.ExpressionFactory;
-import org.junit.Test;
-
-public class BooleanFieldsTest extends AbstractAnalyticsFieldTest {
-
- @Test
- public void expressionFactoryCreationTest() {
- ExpressionFactory fact = getExpressionFactory();
-
- assertTrue(fact.createExpression("boolean_b") instanceof BooleanField);
- assertTrue(fact.createExpression("boolean_bm") instanceof BooleanMultiField);
- }
-
- @Test
- public void singleValuedBooleanTest() throws IOException {
- BooleanField valueField = new BooleanField("boolean_b");
- Map<String,Boolean> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- boolean value = valueField.getBoolean();
- if (valueField.exists()) {
- values.put(id, value);
- }
- return valueField.exists();
- });
-
- checkSingleFieldValues(singleBooleans, values, missing);
- }
-
- @Test
- public void multiValuedBooleanTest() throws IOException {
- BooleanMultiField valueField = new BooleanMultiField("boolean_bm");
- Map<String,Map<Boolean,Integer>> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- Map<Boolean, Integer> doc = new HashMap<>();
- valueField.streamBooleans( value -> {
- doc.put(value, doc.getOrDefault(value, 0) + 1);
- });
- if (doc.size() > 0) {
- values.put(id, doc);
- }
- return doc.size() > 0;
- });
-
- checkMultiFieldValues(multiBooleans, values, missing, true);
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/DateFieldsTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/DateFieldsTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/DateFieldsTest.java
deleted file mode 100644
index 88356dc..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/DateFieldsTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.field;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.solr.analytics.ExpressionFactory;
-import org.junit.Test;
-
-public class DateFieldsTest extends AbstractAnalyticsFieldTest {
-
- @Test
- public void expressionFactoryCreationTest() {
- ExpressionFactory fact = getExpressionFactory();
-
- assertTrue(fact.createExpression("date_dt_t") instanceof DateField);
- assertTrue(fact.createExpression("date_dt_p") instanceof DateField);
- assertTrue(fact.createExpression("date_dtm_t") instanceof DateMultiTrieField);
- assertTrue(fact.createExpression("date_dtm_p") instanceof DateMultiPointField);
- }
-
- @Test
- public void singleValuedTrieDateTest() throws IOException {
- DateField valueField = new DateField("date_dt_t");
- Map<String,Long> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- long value = valueField.getLong();
- if (valueField.exists()) {
- values.put(id, value);
- }
- return valueField.exists();
- });
-
- checkSingleFieldValues(singleDates, values, missing);
- }
-
- @Test
- public void singleValuedPointDateTest() throws IOException {
- DateField valueField = new DateField("date_dt_p");
- Map<String,Long> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- long value = valueField.getLong();
- if (valueField.exists()) {
- values.put(id, value);
- }
- return valueField.exists();
- });
-
- checkSingleFieldValues(singleDates, values, missing);
- }
-
- @Test
- public void multiValuedTrieDateTest() throws IOException {
- DateMultiTrieField valueField = new DateMultiTrieField("date_dtm_t");
- Map<String,Map<Long,Integer>> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- Map<Long, Integer> doc = new HashMap<>();
- valueField.streamLongs( value -> {
- doc.put(value, doc.getOrDefault(value, 0) + 1);
- });
- if (doc.size() > 0) {
- values.put(id, doc);
- }
- return doc.size() > 0;
- });
-
- checkMultiFieldValues(multiDates, values, missing, true);
- }
-
- @Test
- public void multiValuedPointDateTest() throws IOException {
- DateMultiPointField valueField = new DateMultiPointField("date_dtm_p");
- Map<String,Map<Long,Integer>> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- Map<Long, Integer> doc = new HashMap<>();
- valueField.streamLongs( value -> {
- doc.put(value, doc.getOrDefault(value, 0) + 1);
- });
- if (doc.size() > 0) {
- values.put(id, doc);
- }
- return doc.size() > 0;
- });
-
- checkMultiFieldValues(multiDates, values, missing, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/DoubleFieldsTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/DoubleFieldsTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/DoubleFieldsTest.java
deleted file mode 100644
index c668b0d..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/DoubleFieldsTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.field;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.solr.analytics.ExpressionFactory;
-import org.junit.Test;
-
-public class DoubleFieldsTest extends AbstractAnalyticsFieldTest {
-
- @Test
- public void expressionFactoryCreationTest() {
- ExpressionFactory fact = getExpressionFactory();
-
- assertTrue(fact.createExpression("double_d_t") instanceof DoubleField);
- assertTrue(fact.createExpression("double_d_p") instanceof DoubleField);
- assertTrue(fact.createExpression("double_dm_t") instanceof DoubleMultiTrieField);
- assertTrue(fact.createExpression("double_dm_p") instanceof DoubleMultiPointField);
- }
-
- @Test
- public void singleValuedTrieDoubleTest() throws IOException {
- DoubleField valueField = new DoubleField("double_d_t");
- Map<String,Double> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- double value = valueField.getDouble();
- if (valueField.exists()) {
- values.put(id, value);
- }
- return valueField.exists();
- });
-
- checkSingleFieldValues(singleDoubles, values, missing);
- }
-
- @Test
- public void singleValuedPointDoubleTest() throws IOException {
- DoubleField valueField = new DoubleField("double_d_p");
- Map<String,Double> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- double value = valueField.getDouble();
- if (valueField.exists()) {
- values.put(id, value);
- }
- return valueField.exists();
- });
-
- checkSingleFieldValues(singleDoubles, values, missing);
- }
-
- @Test
- public void multiValuedTrieDoubleTest() throws IOException {
- DoubleMultiTrieField valueField = new DoubleMultiTrieField("double_dm_t");
- Map<String,Map<Double,Integer>> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- Map<Double, Integer> doc = new HashMap<>();
- valueField.streamDoubles( value -> {
- doc.put(value, doc.getOrDefault(value, 0) + 1);
- });
- if (doc.size() > 0) {
- values.put(id, doc);
- }
- return doc.size() > 0;
- });
-
- checkMultiFieldValues(multiDoubles, values, missing, true);
- }
-
- @Test
- public void multiValuedPointDoubleTest() throws IOException {
- DoubleMultiPointField valueField = new DoubleMultiPointField("double_dm_p");
- Map<String,Map<Double,Integer>> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- Map<Double, Integer> doc = new HashMap<>();
- valueField.streamDoubles( value -> {
- doc.put(value, doc.getOrDefault(value, 0) + 1);
- });
- if (doc.size() > 0) {
- values.put(id, doc);
- }
- return doc.size() > 0;
- });
-
- checkMultiFieldValues(multiDoubles, values, missing, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/FloatFieldsTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/FloatFieldsTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/FloatFieldsTest.java
deleted file mode 100644
index b1aead6..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/FloatFieldsTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.field;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.solr.analytics.ExpressionFactory;
-import org.junit.Test;
-
-public class FloatFieldsTest extends AbstractAnalyticsFieldTest {
-
- @Test
- public void expressionFactoryCreationTest() {
- ExpressionFactory fact = getExpressionFactory();
-
- assertTrue(fact.createExpression("float_f_t") instanceof FloatField);
- assertTrue(fact.createExpression("float_f_p") instanceof FloatField);
- assertTrue(fact.createExpression("float_fm_t") instanceof FloatMultiTrieField);
- assertTrue(fact.createExpression("float_fm_p") instanceof FloatMultiPointField);
- }
-
- @Test
- public void singleValuedTrieFloatTest() throws IOException {
- FloatField valueField = new FloatField("float_f_t");
- Map<String,Float> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- float value = valueField.getFloat();
- if (valueField.exists()) {
- values.put(id, value);
- }
- return valueField.exists();
- });
-
- checkSingleFieldValues(singleFloats, values, missing);
- }
-
- @Test
- public void singleValuedPointFloatTest() throws IOException {
- FloatField valueField = new FloatField("float_f_p");
- Map<String,Float> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- float value = valueField.getFloat();
- if (valueField.exists()) {
- values.put(id, value);
- }
- return valueField.exists();
- });
-
- checkSingleFieldValues(singleFloats, values, missing);
- }
-
- @Test
- public void multiValuedTrieFloatTest() throws IOException {
- FloatMultiTrieField valueField = new FloatMultiTrieField("float_fm_t");
- Map<String,Map<Float,Integer>> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- Map<Float, Integer> doc = new HashMap<>();
- valueField.streamFloats( value -> {
- doc.put(value, doc.getOrDefault(value, 0) + 1);
- });
- if (doc.size() > 0) {
- values.put(id, doc);
- }
- return doc.size() > 0;
- });
-
- checkMultiFieldValues(multiFloats, values, missing, true);
- }
-
- @Test
- public void multiValuedPointFloatTest() throws IOException {
- FloatMultiPointField valueField = new FloatMultiPointField("float_fm_p");
- Map<String,Map<Float,Integer>> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- Map<Float, Integer> doc = new HashMap<>();
- valueField.streamFloats( value -> {
- doc.put(value, doc.getOrDefault(value, 0) + 1);
- });
- if (doc.size() > 0) {
- values.put(id, doc);
- }
- return doc.size() > 0;
- });
-
- checkMultiFieldValues(multiFloats, values, missing, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/IntFieldsTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/IntFieldsTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/IntFieldsTest.java
deleted file mode 100644
index 014d9d1..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/IntFieldsTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.field;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.solr.analytics.ExpressionFactory;
-import org.junit.Test;
-
-public class IntFieldsTest extends AbstractAnalyticsFieldTest {
-
- @Test
- public void expressionFactoryCreationTest() {
- ExpressionFactory fact = getExpressionFactory();
-
- assertTrue(fact.createExpression("int_i_t") instanceof IntField);
- assertTrue(fact.createExpression("int_i_p") instanceof IntField);
- assertTrue(fact.createExpression("int_im_t") instanceof IntMultiTrieField);
- assertTrue(fact.createExpression("int_im_p") instanceof IntMultiPointField);
- }
-
- @Test
- public void singleValuedTrieIntTest() throws IOException {
- IntField valueField = new IntField("int_i_t");
- Map<String,Integer> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- int value = valueField.getInt();
- if (valueField.exists()) {
- values.put(id, value);
- }
- return valueField.exists();
- });
-
- checkSingleFieldValues(singleInts, values, missing);
- }
-
- @Test
- public void singleValuedPointIntTest() throws IOException {
- IntField valueField = new IntField("int_i_p");
- Map<String,Integer> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- int value = valueField.getInt();
- if (valueField.exists()) {
- values.put(id, value);
- }
- return valueField.exists();
- });
-
- checkSingleFieldValues(singleInts, values, missing);
- }
-
- @Test
- public void multiValuedTrieIntTest() throws IOException {
- IntMultiTrieField valueField = new IntMultiTrieField("int_im_t");
- Map<String,Map<Integer,Integer>> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- Map<Integer, Integer> doc = new HashMap<>();
- valueField.streamInts( value -> {
- doc.put(value, doc.getOrDefault(value, 0) + 1);
- });
- if (doc.size() > 0) {
- values.put(id, doc);
- }
- return doc.size() > 0;
- });
-
- checkMultiFieldValues(multiInts, values, missing, true);
- }
-
- @Test
- public void multiValuedPointIntTest() throws IOException {
- IntMultiPointField valueField = new IntMultiPointField("int_im_p");
- Map<String,Map<Integer,Integer>> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- Map<Integer, Integer> doc = new HashMap<>();
- valueField.streamInts( value -> {
- doc.put(value, doc.getOrDefault(value, 0) + 1);
- });
- if (doc.size() > 0) {
- values.put(id, doc);
- }
- return doc.size() > 0;
- });
-
- checkMultiFieldValues(multiInts, values, missing, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/LongFieldsTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/LongFieldsTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/LongFieldsTest.java
deleted file mode 100644
index d1fc6b8..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/LongFieldsTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.field;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.solr.analytics.ExpressionFactory;
-import org.junit.Test;
-
-public class LongFieldsTest extends AbstractAnalyticsFieldTest {
-
- @Test
- public void expressionFactoryCreationTest() {
- ExpressionFactory fact = getExpressionFactory();
-
- assertTrue(fact.createExpression("long_l_t") instanceof LongField);
- assertTrue(fact.createExpression("long_l_p") instanceof LongField);
- assertTrue(fact.createExpression("long_lm_t") instanceof LongMultiTrieField);
- assertTrue(fact.createExpression("long_lm_p") instanceof LongMultiPointField);
- }
-
- @Test
- public void singleValuedTrieLongTest() throws IOException {
- LongField valueField = new LongField("long_l_t");
- Map<String,Long> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- long value = valueField.getLong();
- if (valueField.exists()) {
- values.put(id, value);
- }
- return valueField.exists();
- });
-
- checkSingleFieldValues(singleLongs, values, missing);
- }
-
- @Test
- public void singleValuedPointLongTest() throws IOException {
- LongField valueField = new LongField("long_l_p");
- Map<String,Long> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- long value = valueField.getLong();
- if (valueField.exists()) {
- values.put(id, value);
- }
- return valueField.exists();
- });
-
- checkSingleFieldValues(singleLongs, values, missing);
- }
-
- @Test
- public void multiValuedTrieLongTest() throws IOException {
- LongMultiTrieField valueField = new LongMultiTrieField("long_lm_t");
- Map<String,Map<Long,Integer>> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- Map<Long, Integer> doc = new HashMap<>();
- valueField.streamLongs( value -> {
- doc.put(value, doc.getOrDefault(value, 0) + 1);
- });
- if (doc.size() > 0) {
- values.put(id, doc);
- }
- return doc.size() > 0;
- });
-
- checkMultiFieldValues(multiLongs, values, missing, true);
- }
-
- @Test
- public void multiValuedPointLongTest() throws IOException {
- LongMultiPointField valueField = new LongMultiPointField("long_lm_p");
- Map<String,Map<Long,Integer>> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- Map<Long, Integer> doc = new HashMap<>();
- valueField.streamLongs( value -> {
- doc.put(value, doc.getOrDefault(value, 0) + 1);
- });
- if (doc.size() > 0) {
- values.put(id, doc);
- }
- return doc.size() > 0;
- });
-
- checkMultiFieldValues(multiLongs, values, missing, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f0366b94/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/StringFieldsTest.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/StringFieldsTest.java b/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/StringFieldsTest.java
deleted file mode 100644
index 152a009..0000000
--- a/solr/contrib/analytics/src/test/org/apache/solr/analytics/function/field/StringFieldsTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.analytics.function.field;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.solr.analytics.ExpressionFactory;
-import org.junit.Test;
-
-public class StringFieldsTest extends AbstractAnalyticsFieldTest {
-
- @Test
- public void expressionFactoryCreationTest() {
- ExpressionFactory fact = getExpressionFactory();
-
- assertTrue(fact.createExpression("string_s") instanceof StringField);
- assertTrue(fact.createExpression("string_sm") instanceof StringMultiField);
- }
-
- @Test
- public void singleValuedStringTest() throws IOException {
- StringField valueField = new StringField("string_s");
- Map<String,String> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- String value = valueField.getString();
- if (valueField.exists()) {
- values.put(id, value);
- }
- return valueField.exists();
- });
-
- checkSingleFieldValues(singleStrings, values, missing);
- }
-
- @Test
- public void multiValuedStringTest() throws IOException {
- StringMultiField valueField = new StringMultiField("string_sm");
- Map<String,Map<String,Integer>> values = new HashMap<>();
-
- Set<String> missing = collectFieldValues(valueField, id -> {
- Map<String, Integer> doc = new HashMap<>();
- valueField.streamStrings( value -> {
- doc.put(value, doc.getOrDefault(value, 0) + 1);
- });
- if (doc.size() > 0) {
- values.put(id, doc);
- }
- return doc.size() > 0;
- });
-
- checkMultiFieldValues(multiStrings, values, missing, true);
- }
-}