You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2017/05/30 08:34:06 UTC
[5/7] lucene-solr:master: LUCENE-7850: Move support for legacy
numerics to solr/.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/759fa42b/lucene/backward-codecs/src/test/org/apache/lucene/legacy/TestNumericRangeQuery32.java
----------------------------------------------------------------------
diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/legacy/TestNumericRangeQuery32.java b/lucene/backward-codecs/src/test/org/apache/lucene/legacy/TestNumericRangeQuery32.java
deleted file mode 100644
index acd0c04..0000000
--- a/lucene/backward-codecs/src/test/org/apache/lucene/legacy/TestNumericRangeQuery32.java
+++ /dev/null
@@ -1,461 +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.lucene.legacy;
-
-
-import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.index.DirectoryReader;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.MultiTermQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.QueryUtils;
-import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.search.Sort;
-import org.apache.lucene.search.TopDocs;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.NumericUtils;
-import org.apache.lucene.util.TestUtil;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class TestNumericRangeQuery32 extends LuceneTestCase {
- // distance of entries
- private static int distance;
- // shift the starting of the values to the left, to also have negative values:
- private static final int startOffset = - 1 << 15;
- // number of docs to generate for testing
- private static int noDocs;
-
- private static Directory directory = null;
- private static IndexReader reader = null;
- private static IndexSearcher searcher = null;
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- noDocs = atLeast(4096);
- distance = (1 << 30) / noDocs;
- directory = newDirectory();
- RandomIndexWriter writer = new RandomIndexWriter(random(), directory,
- newIndexWriterConfig(new MockAnalyzer(random()))
- .setMaxBufferedDocs(TestUtil.nextInt(random(), 100, 1000))
- .setMergePolicy(newLogMergePolicy()));
-
- final LegacyFieldType storedInt = new LegacyFieldType(LegacyIntField.TYPE_NOT_STORED);
- storedInt.setStored(true);
- storedInt.freeze();
-
- final LegacyFieldType storedInt8 = new LegacyFieldType(storedInt);
- storedInt8.setNumericPrecisionStep(8);
-
- final LegacyFieldType storedInt4 = new LegacyFieldType(storedInt);
- storedInt4.setNumericPrecisionStep(4);
-
- final LegacyFieldType storedInt2 = new LegacyFieldType(storedInt);
- storedInt2.setNumericPrecisionStep(2);
-
- final LegacyFieldType storedIntNone = new LegacyFieldType(storedInt);
- storedIntNone.setNumericPrecisionStep(Integer.MAX_VALUE);
-
- final LegacyFieldType unstoredInt = LegacyIntField.TYPE_NOT_STORED;
-
- final LegacyFieldType unstoredInt8 = new LegacyFieldType(unstoredInt);
- unstoredInt8.setNumericPrecisionStep(8);
-
- final LegacyFieldType unstoredInt4 = new LegacyFieldType(unstoredInt);
- unstoredInt4.setNumericPrecisionStep(4);
-
- final LegacyFieldType unstoredInt2 = new LegacyFieldType(unstoredInt);
- unstoredInt2.setNumericPrecisionStep(2);
-
- LegacyIntField
- field8 = new LegacyIntField("field8", 0, storedInt8),
- field4 = new LegacyIntField("field4", 0, storedInt4),
- field2 = new LegacyIntField("field2", 0, storedInt2),
- fieldNoTrie = new LegacyIntField("field"+Integer.MAX_VALUE, 0, storedIntNone),
- ascfield8 = new LegacyIntField("ascfield8", 0, unstoredInt8),
- ascfield4 = new LegacyIntField("ascfield4", 0, unstoredInt4),
- ascfield2 = new LegacyIntField("ascfield2", 0, unstoredInt2);
-
- Document doc = new Document();
- // add fields, that have a distance to test general functionality
- doc.add(field8); doc.add(field4); doc.add(field2); doc.add(fieldNoTrie);
- // add ascending fields with a distance of 1, beginning at -noDocs/2 to test the correct splitting of range and inclusive/exclusive
- doc.add(ascfield8); doc.add(ascfield4); doc.add(ascfield2);
-
- // Add a series of noDocs docs with increasing int values
- for (int l=0; l<noDocs; l++) {
- int val=distance*l+startOffset;
- field8.setIntValue(val);
- field4.setIntValue(val);
- field2.setIntValue(val);
- fieldNoTrie.setIntValue(val);
-
- val=l-(noDocs/2);
- ascfield8.setIntValue(val);
- ascfield4.setIntValue(val);
- ascfield2.setIntValue(val);
- writer.addDocument(doc);
- }
-
- reader = writer.getReader();
- searcher=newSearcher(reader);
- writer.close();
- }
-
- @AfterClass
- public static void afterClass() throws Exception {
- searcher = null;
- reader.close();
- reader = null;
- directory.close();
- directory = null;
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- // set the theoretical maximum term count for 8bit (see docs for the number)
- // super.tearDown will restore the default
- BooleanQuery.setMaxClauseCount(3*255*2 + 255);
- }
-
- /** test for both constant score and boolean query, the other tests only use the constant score mode */
- private void testRange(int precisionStep) throws Exception {
- String field="field"+precisionStep;
- int count=3000;
- int lower=(distance*3/2)+startOffset, upper=lower + count*distance + (distance/3);
- LegacyNumericRangeQuery<Integer> q = LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, true, true);
- for (byte i=0; i<2; i++) {
- TopDocs topDocs;
- String type;
- switch (i) {
- case 0:
- type = " (constant score filter rewrite)";
- q.setRewriteMethod(MultiTermQuery.CONSTANT_SCORE_REWRITE);
- topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
- break;
- case 1:
- type = " (constant score boolean rewrite)";
- q.setRewriteMethod(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_REWRITE);
- topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
- break;
- default:
- return;
- }
- ScoreDoc[] sd = topDocs.scoreDocs;
- assertNotNull(sd);
- assertEquals("Score doc count"+type, count, sd.length );
- Document doc=searcher.doc(sd[0].doc);
- assertEquals("First doc"+type, 2*distance+startOffset, doc.getField(field).numericValue().intValue());
- doc=searcher.doc(sd[sd.length-1].doc);
- assertEquals("Last doc"+type, (1+count)*distance+startOffset, doc.getField(field).numericValue().intValue());
- }
- }
-
- @Test
- public void testRange_8bit() throws Exception {
- testRange(8);
- }
-
- @Test
- public void testRange_4bit() throws Exception {
- testRange(4);
- }
-
- @Test
- public void testRange_2bit() throws Exception {
- testRange(2);
- }
-
- @Test
- public void testOneMatchQuery() throws Exception {
- LegacyNumericRangeQuery<Integer> q = LegacyNumericRangeQuery.newIntRange("ascfield8", 8, 1000, 1000, true, true);
- TopDocs topDocs = searcher.search(q, noDocs);
- ScoreDoc[] sd = topDocs.scoreDocs;
- assertNotNull(sd);
- assertEquals("Score doc count", 1, sd.length );
- }
-
- private void testLeftOpenRange(int precisionStep) throws Exception {
- String field="field"+precisionStep;
- int count=3000;
- int upper=(count-1)*distance + (distance/3) + startOffset;
- LegacyNumericRangeQuery<Integer> q= LegacyNumericRangeQuery.newIntRange(field, precisionStep, null, upper, true, true);
- TopDocs topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
- ScoreDoc[] sd = topDocs.scoreDocs;
- assertNotNull(sd);
- assertEquals("Score doc count", count, sd.length );
- Document doc=searcher.doc(sd[0].doc);
- assertEquals("First doc", startOffset, doc.getField(field).numericValue().intValue());
- doc=searcher.doc(sd[sd.length-1].doc);
- assertEquals("Last doc", (count-1)*distance+startOffset, doc.getField(field).numericValue().intValue());
-
- q= LegacyNumericRangeQuery.newIntRange(field, precisionStep, null, upper, false, true);
- topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
- sd = topDocs.scoreDocs;
- assertNotNull(sd);
- assertEquals("Score doc count", count, sd.length );
- doc=searcher.doc(sd[0].doc);
- assertEquals("First doc", startOffset, doc.getField(field).numericValue().intValue());
- doc=searcher.doc(sd[sd.length-1].doc);
- assertEquals("Last doc", (count-1)*distance+startOffset, doc.getField(field).numericValue().intValue());
- }
-
- @Test
- public void testLeftOpenRange_8bit() throws Exception {
- testLeftOpenRange(8);
- }
-
- @Test
- public void testLeftOpenRange_4bit() throws Exception {
- testLeftOpenRange(4);
- }
-
- @Test
- public void testLeftOpenRange_2bit() throws Exception {
- testLeftOpenRange(2);
- }
-
- private void testRightOpenRange(int precisionStep) throws Exception {
- String field="field"+precisionStep;
- int count=3000;
- int lower=(count-1)*distance + (distance/3) +startOffset;
- LegacyNumericRangeQuery<Integer> q= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, null, true, true);
- TopDocs topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
- ScoreDoc[] sd = topDocs.scoreDocs;
- assertNotNull(sd);
- assertEquals("Score doc count", noDocs-count, sd.length );
- Document doc=searcher.doc(sd[0].doc);
- assertEquals("First doc", count*distance+startOffset, doc.getField(field).numericValue().intValue());
- doc=searcher.doc(sd[sd.length-1].doc);
- assertEquals("Last doc", (noDocs-1)*distance+startOffset, doc.getField(field).numericValue().intValue());
-
- q= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, null, true, false);
- topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
- sd = topDocs.scoreDocs;
- assertNotNull(sd);
- assertEquals("Score doc count", noDocs-count, sd.length );
- doc=searcher.doc(sd[0].doc);
- assertEquals("First doc", count*distance+startOffset, doc.getField(field).numericValue().intValue() );
- doc=searcher.doc(sd[sd.length-1].doc);
- assertEquals("Last doc", (noDocs-1)*distance+startOffset, doc.getField(field).numericValue().intValue() );
- }
-
- @Test
- public void testRightOpenRange_8bit() throws Exception {
- testRightOpenRange(8);
- }
-
- @Test
- public void testRightOpenRange_4bit() throws Exception {
- testRightOpenRange(4);
- }
-
- @Test
- public void testRightOpenRange_2bit() throws Exception {
- testRightOpenRange(2);
- }
-
- @Test
- public void testInfiniteValues() throws Exception {
- Directory dir = newDirectory();
- RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
- newIndexWriterConfig(new MockAnalyzer(random())));
- Document doc = new Document();
- doc.add(new LegacyFloatField("float", Float.NEGATIVE_INFINITY, Field.Store.NO));
- doc.add(new LegacyIntField("int", Integer.MIN_VALUE, Field.Store.NO));
- writer.addDocument(doc);
-
- doc = new Document();
- doc.add(new LegacyFloatField("float", Float.POSITIVE_INFINITY, Field.Store.NO));
- doc.add(new LegacyIntField("int", Integer.MAX_VALUE, Field.Store.NO));
- writer.addDocument(doc);
-
- doc = new Document();
- doc.add(new LegacyFloatField("float", 0.0f, Field.Store.NO));
- doc.add(new LegacyIntField("int", 0, Field.Store.NO));
- writer.addDocument(doc);
-
- for (float f : TestLegacyNumericUtils.FLOAT_NANs) {
- doc = new Document();
- doc.add(new LegacyFloatField("float", f, Field.Store.NO));
- writer.addDocument(doc);
- }
-
- writer.close();
-
- IndexReader r = DirectoryReader.open(dir);
- IndexSearcher s = newSearcher(r);
-
- Query q= LegacyNumericRangeQuery.newIntRange("int", null, null, true, true);
- TopDocs topDocs = s.search(q, 10);
- assertEquals("Score doc count", 3, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newIntRange("int", null, null, false, false);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 3, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newIntRange("int", Integer.MIN_VALUE, Integer.MAX_VALUE, true, true);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 3, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newIntRange("int", Integer.MIN_VALUE, Integer.MAX_VALUE, false, false);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 1, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newFloatRange("float", null, null, true, true);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 3, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newFloatRange("float", null, null, false, false);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 3, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newFloatRange("float", Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, true, true);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 3, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newFloatRange("float", Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, false, false);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 1, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newFloatRange("float", Float.NaN, Float.NaN, true, true);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", TestLegacyNumericUtils.FLOAT_NANs.length, topDocs.scoreDocs.length );
-
- r.close();
- dir.close();
- }
-
- private void testRangeSplit(int precisionStep) throws Exception {
- String field="ascfield"+precisionStep;
- // 10 random tests
- int num = TestUtil.nextInt(random(), 10, 20);
- for (int i =0; i< num; i++) {
- int lower=(int)(random().nextDouble()*noDocs - noDocs/2);
- int upper=(int)(random().nextDouble()*noDocs - noDocs/2);
- if (lower>upper) {
- int a=lower; lower=upper; upper=a;
- }
- // test inclusive range
- Query tq= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, true, true);
- TopDocs tTopDocs = searcher.search(tq, 1);
- assertEquals("Returned count of range query must be equal to inclusive range length", upper-lower+1, tTopDocs.totalHits );
- // test exclusive range
- tq= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, false, false);
- tTopDocs = searcher.search(tq, 1);
- assertEquals("Returned count of range query must be equal to exclusive range length", Math.max(upper-lower-1, 0), tTopDocs.totalHits );
- // test left exclusive range
- tq= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, false, true);
- tTopDocs = searcher.search(tq, 1);
- assertEquals("Returned count of range query must be equal to half exclusive range length", upper-lower, tTopDocs.totalHits );
- // test right exclusive range
- tq= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, true, false);
- tTopDocs = searcher.search(tq, 1);
- assertEquals("Returned count of range query must be equal to half exclusive range length", upper-lower, tTopDocs.totalHits );
- }
- }
-
- @Test
- public void testRangeSplit_8bit() throws Exception {
- testRangeSplit(8);
- }
-
- @Test
- public void testRangeSplit_4bit() throws Exception {
- testRangeSplit(4);
- }
-
- @Test
- public void testRangeSplit_2bit() throws Exception {
- testRangeSplit(2);
- }
-
- /** we fake a float test using int2float conversion of LegacyNumericUtils */
- private void testFloatRange(int precisionStep) throws Exception {
- final String field="ascfield"+precisionStep;
- final int lower=-1000, upper=+2000;
-
- Query tq= LegacyNumericRangeQuery.newFloatRange(field, precisionStep,
- NumericUtils.sortableIntToFloat(lower), NumericUtils.sortableIntToFloat(upper), true, true);
- TopDocs tTopDocs = searcher.search(tq, 1);
- assertEquals("Returned count of range query must be equal to inclusive range length", upper-lower+1, tTopDocs.totalHits );
- }
-
- @Test
- public void testFloatRange_8bit() throws Exception {
- testFloatRange(8);
- }
-
- @Test
- public void testFloatRange_4bit() throws Exception {
- testFloatRange(4);
- }
-
- @Test
- public void testFloatRange_2bit() throws Exception {
- testFloatRange(2);
- }
-
- @Test
- public void testEqualsAndHash() throws Exception {
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test1", 4, 10, 20, true, true));
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test2", 4, 10, 20, false, true));
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test3", 4, 10, 20, true, false));
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test4", 4, 10, 20, false, false));
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test5", 4, 10, null, true, true));
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test6", 4, null, 20, true, true));
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test7", 4, null, null, true, true));
- QueryUtils.checkEqual(
- LegacyNumericRangeQuery.newIntRange("test8", 4, 10, 20, true, true),
- LegacyNumericRangeQuery.newIntRange("test8", 4, 10, 20, true, true)
- );
- QueryUtils.checkUnequal(
- LegacyNumericRangeQuery.newIntRange("test9", 4, 10, 20, true, true),
- LegacyNumericRangeQuery.newIntRange("test9", 8, 10, 20, true, true)
- );
- QueryUtils.checkUnequal(
- LegacyNumericRangeQuery.newIntRange("test10a", 4, 10, 20, true, true),
- LegacyNumericRangeQuery.newIntRange("test10b", 4, 10, 20, true, true)
- );
- QueryUtils.checkUnequal(
- LegacyNumericRangeQuery.newIntRange("test11", 4, 10, 20, true, true),
- LegacyNumericRangeQuery.newIntRange("test11", 4, 20, 10, true, true)
- );
- QueryUtils.checkUnequal(
- LegacyNumericRangeQuery.newIntRange("test12", 4, 10, 20, true, true),
- LegacyNumericRangeQuery.newIntRange("test12", 4, 10, 20, false, true)
- );
- QueryUtils.checkUnequal(
- LegacyNumericRangeQuery.newIntRange("test13", 4, 10, 20, true, true),
- LegacyNumericRangeQuery.newFloatRange("test13", 4, 10f, 20f, true, true)
- );
- // the following produces a hash collision, because Long and Integer have the same hashcode, so only test equality:
- Query q1 = LegacyNumericRangeQuery.newIntRange("test14", 4, 10, 20, true, true);
- Query q2 = LegacyNumericRangeQuery.newLongRange("test14", 4, 10L, 20L, true, true);
- assertFalse(q1.equals(q2));
- assertFalse(q2.equals(q1));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/759fa42b/lucene/backward-codecs/src/test/org/apache/lucene/legacy/TestNumericRangeQuery64.java
----------------------------------------------------------------------
diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/legacy/TestNumericRangeQuery64.java b/lucene/backward-codecs/src/test/org/apache/lucene/legacy/TestNumericRangeQuery64.java
deleted file mode 100644
index b3ce55a..0000000
--- a/lucene/backward-codecs/src/test/org/apache/lucene/legacy/TestNumericRangeQuery64.java
+++ /dev/null
@@ -1,490 +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.lucene.legacy;
-
-
-import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.index.DirectoryReader;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.MultiTermQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.QueryUtils;
-import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.search.Sort;
-import org.apache.lucene.search.TopDocs;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.NumericUtils;
-import org.apache.lucene.util.TestUtil;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class TestNumericRangeQuery64 extends LuceneTestCase {
- // distance of entries
- private static long distance;
- // shift the starting of the values to the left, to also have negative values:
- private static final long startOffset = - 1L << 31;
- // number of docs to generate for testing
- private static int noDocs;
-
- private static Directory directory = null;
- private static IndexReader reader = null;
- private static IndexSearcher searcher = null;
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- noDocs = atLeast(4096);
- distance = (1L << 60) / noDocs;
- directory = newDirectory();
- RandomIndexWriter writer = new RandomIndexWriter(random(), directory,
- newIndexWriterConfig(new MockAnalyzer(random()))
- .setMaxBufferedDocs(TestUtil.nextInt(random(), 100, 1000))
- .setMergePolicy(newLogMergePolicy()));
-
- final LegacyFieldType storedLong = new LegacyFieldType(LegacyLongField.TYPE_NOT_STORED);
- storedLong.setStored(true);
- storedLong.freeze();
-
- final LegacyFieldType storedLong8 = new LegacyFieldType(storedLong);
- storedLong8.setNumericPrecisionStep(8);
-
- final LegacyFieldType storedLong4 = new LegacyFieldType(storedLong);
- storedLong4.setNumericPrecisionStep(4);
-
- final LegacyFieldType storedLong6 = new LegacyFieldType(storedLong);
- storedLong6.setNumericPrecisionStep(6);
-
- final LegacyFieldType storedLong2 = new LegacyFieldType(storedLong);
- storedLong2.setNumericPrecisionStep(2);
-
- final LegacyFieldType storedLongNone = new LegacyFieldType(storedLong);
- storedLongNone.setNumericPrecisionStep(Integer.MAX_VALUE);
-
- final LegacyFieldType unstoredLong = LegacyLongField.TYPE_NOT_STORED;
-
- final LegacyFieldType unstoredLong8 = new LegacyFieldType(unstoredLong);
- unstoredLong8.setNumericPrecisionStep(8);
-
- final LegacyFieldType unstoredLong6 = new LegacyFieldType(unstoredLong);
- unstoredLong6.setNumericPrecisionStep(6);
-
- final LegacyFieldType unstoredLong4 = new LegacyFieldType(unstoredLong);
- unstoredLong4.setNumericPrecisionStep(4);
-
- final LegacyFieldType unstoredLong2 = new LegacyFieldType(unstoredLong);
- unstoredLong2.setNumericPrecisionStep(2);
-
- LegacyLongField
- field8 = new LegacyLongField("field8", 0L, storedLong8),
- field6 = new LegacyLongField("field6", 0L, storedLong6),
- field4 = new LegacyLongField("field4", 0L, storedLong4),
- field2 = new LegacyLongField("field2", 0L, storedLong2),
- fieldNoTrie = new LegacyLongField("field"+Integer.MAX_VALUE, 0L, storedLongNone),
- ascfield8 = new LegacyLongField("ascfield8", 0L, unstoredLong8),
- ascfield6 = new LegacyLongField("ascfield6", 0L, unstoredLong6),
- ascfield4 = new LegacyLongField("ascfield4", 0L, unstoredLong4),
- ascfield2 = new LegacyLongField("ascfield2", 0L, unstoredLong2);
-
- Document doc = new Document();
- // add fields, that have a distance to test general functionality
- doc.add(field8); doc.add(field6); doc.add(field4); doc.add(field2); doc.add(fieldNoTrie);
- // add ascending fields with a distance of 1, beginning at -noDocs/2 to test the correct splitting of range and inclusive/exclusive
- doc.add(ascfield8); doc.add(ascfield6); doc.add(ascfield4); doc.add(ascfield2);
-
- // Add a series of noDocs docs with increasing long values, by updating the fields
- for (int l=0; l<noDocs; l++) {
- long val=distance*l+startOffset;
- field8.setLongValue(val);
- field6.setLongValue(val);
- field4.setLongValue(val);
- field2.setLongValue(val);
- fieldNoTrie.setLongValue(val);
-
- val=l-(noDocs/2);
- ascfield8.setLongValue(val);
- ascfield6.setLongValue(val);
- ascfield4.setLongValue(val);
- ascfield2.setLongValue(val);
- writer.addDocument(doc);
- }
- reader = writer.getReader();
- searcher=newSearcher(reader);
- writer.close();
- }
-
- @AfterClass
- public static void afterClass() throws Exception {
- searcher = null;
- reader.close();
- reader = null;
- directory.close();
- directory = null;
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- // set the theoretical maximum term count for 8bit (see docs for the number)
- // super.tearDown will restore the default
- BooleanQuery.setMaxClauseCount(7*255*2 + 255);
- }
-
- /** test for constant score + boolean query + filter, the other tests only use the constant score mode */
- private void testRange(int precisionStep) throws Exception {
- String field="field"+precisionStep;
- int count=3000;
- long lower=(distance*3/2)+startOffset, upper=lower + count*distance + (distance/3);
- LegacyNumericRangeQuery<Long> q = LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, true);
- for (byte i=0; i<2; i++) {
- TopDocs topDocs;
- String type;
- switch (i) {
- case 0:
- type = " (constant score filter rewrite)";
- q.setRewriteMethod(MultiTermQuery.CONSTANT_SCORE_REWRITE);
- topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
- break;
- case 1:
- type = " (constant score boolean rewrite)";
- q.setRewriteMethod(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_REWRITE);
- topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
- break;
- default:
- return;
- }
- ScoreDoc[] sd = topDocs.scoreDocs;
- assertNotNull(sd);
- assertEquals("Score doc count"+type, count, sd.length );
- Document doc=searcher.doc(sd[0].doc);
- assertEquals("First doc"+type, 2*distance+startOffset, doc.getField(field).numericValue().longValue() );
- doc=searcher.doc(sd[sd.length-1].doc);
- assertEquals("Last doc"+type, (1+count)*distance+startOffset, doc.getField(field).numericValue().longValue() );
- }
- }
-
- @Test
- public void testRange_8bit() throws Exception {
- testRange(8);
- }
-
- @Test
- public void testRange_6bit() throws Exception {
- testRange(6);
- }
-
- @Test
- public void testRange_4bit() throws Exception {
- testRange(4);
- }
-
- @Test
- public void testRange_2bit() throws Exception {
- testRange(2);
- }
-
- @Test
- public void testOneMatchQuery() throws Exception {
- LegacyNumericRangeQuery<Long> q = LegacyNumericRangeQuery.newLongRange("ascfield8", 8, 1000L, 1000L, true, true);
- TopDocs topDocs = searcher.search(q, noDocs);
- ScoreDoc[] sd = topDocs.scoreDocs;
- assertNotNull(sd);
- assertEquals("Score doc count", 1, sd.length );
- }
-
- private void testLeftOpenRange(int precisionStep) throws Exception {
- String field="field"+precisionStep;
- int count=3000;
- long upper=(count-1)*distance + (distance/3) + startOffset;
- LegacyNumericRangeQuery<Long> q= LegacyNumericRangeQuery.newLongRange(field, precisionStep, null, upper, true, true);
- TopDocs topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
- ScoreDoc[] sd = topDocs.scoreDocs;
- assertNotNull(sd);
- assertEquals("Score doc count", count, sd.length );
- Document doc=searcher.doc(sd[0].doc);
- assertEquals("First doc", startOffset, doc.getField(field).numericValue().longValue() );
- doc=searcher.doc(sd[sd.length-1].doc);
- assertEquals("Last doc", (count-1)*distance+startOffset, doc.getField(field).numericValue().longValue() );
-
- q= LegacyNumericRangeQuery.newLongRange(field, precisionStep, null, upper, false, true);
- topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
- sd = topDocs.scoreDocs;
- assertNotNull(sd);
- assertEquals("Score doc count", count, sd.length );
- doc=searcher.doc(sd[0].doc);
- assertEquals("First doc", startOffset, doc.getField(field).numericValue().longValue() );
- doc=searcher.doc(sd[sd.length-1].doc);
- assertEquals("Last doc", (count-1)*distance+startOffset, doc.getField(field).numericValue().longValue() );
- }
-
- @Test
- public void testLeftOpenRange_8bit() throws Exception {
- testLeftOpenRange(8);
- }
-
- @Test
- public void testLeftOpenRange_6bit() throws Exception {
- testLeftOpenRange(6);
- }
-
- @Test
- public void testLeftOpenRange_4bit() throws Exception {
- testLeftOpenRange(4);
- }
-
- @Test
- public void testLeftOpenRange_2bit() throws Exception {
- testLeftOpenRange(2);
- }
-
- private void testRightOpenRange(int precisionStep) throws Exception {
- String field="field"+precisionStep;
- int count=3000;
- long lower=(count-1)*distance + (distance/3) +startOffset;
- LegacyNumericRangeQuery<Long> q= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, null, true, true);
- TopDocs topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
- ScoreDoc[] sd = topDocs.scoreDocs;
- assertNotNull(sd);
- assertEquals("Score doc count", noDocs-count, sd.length );
- Document doc=searcher.doc(sd[0].doc);
- assertEquals("First doc", count*distance+startOffset, doc.getField(field).numericValue().longValue() );
- doc=searcher.doc(sd[sd.length-1].doc);
- assertEquals("Last doc", (noDocs-1)*distance+startOffset, doc.getField(field).numericValue().longValue() );
-
- q= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, null, true, false);
- topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
- sd = topDocs.scoreDocs;
- assertNotNull(sd);
- assertEquals("Score doc count", noDocs-count, sd.length );
- doc=searcher.doc(sd[0].doc);
- assertEquals("First doc", count*distance+startOffset, doc.getField(field).numericValue().longValue() );
- doc=searcher.doc(sd[sd.length-1].doc);
- assertEquals("Last doc", (noDocs-1)*distance+startOffset, doc.getField(field).numericValue().longValue() );
- }
-
- @Test
- public void testRightOpenRange_8bit() throws Exception {
- testRightOpenRange(8);
- }
-
- @Test
- public void testRightOpenRange_6bit() throws Exception {
- testRightOpenRange(6);
- }
-
- @Test
- public void testRightOpenRange_4bit() throws Exception {
- testRightOpenRange(4);
- }
-
- @Test
- public void testRightOpenRange_2bit() throws Exception {
- testRightOpenRange(2);
- }
-
- @Test
- public void testInfiniteValues() throws Exception {
- Directory dir = newDirectory();
- RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
- newIndexWriterConfig(new MockAnalyzer(random())));
- Document doc = new Document();
- doc.add(new LegacyDoubleField("double", Double.NEGATIVE_INFINITY, Field.Store.NO));
- doc.add(new LegacyLongField("long", Long.MIN_VALUE, Field.Store.NO));
- writer.addDocument(doc);
-
- doc = new Document();
- doc.add(new LegacyDoubleField("double", Double.POSITIVE_INFINITY, Field.Store.NO));
- doc.add(new LegacyLongField("long", Long.MAX_VALUE, Field.Store.NO));
- writer.addDocument(doc);
-
- doc = new Document();
- doc.add(new LegacyDoubleField("double", 0.0, Field.Store.NO));
- doc.add(new LegacyLongField("long", 0L, Field.Store.NO));
- writer.addDocument(doc);
-
- for (double d : TestLegacyNumericUtils.DOUBLE_NANs) {
- doc = new Document();
- doc.add(new LegacyDoubleField("double", d, Field.Store.NO));
- writer.addDocument(doc);
- }
-
- writer.close();
-
- IndexReader r = DirectoryReader.open(dir);
- IndexSearcher s = newSearcher(r);
-
- Query q= LegacyNumericRangeQuery.newLongRange("long", null, null, true, true);
- TopDocs topDocs = s.search(q, 10);
- assertEquals("Score doc count", 3, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newLongRange("long", null, null, false, false);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 3, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newLongRange("long", Long.MIN_VALUE, Long.MAX_VALUE, true, true);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 3, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newLongRange("long", Long.MIN_VALUE, Long.MAX_VALUE, false, false);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 1, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newDoubleRange("double", null, null, true, true);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 3, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newDoubleRange("double", null, null, false, false);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 3, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newDoubleRange("double", Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, true, true);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 3, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newDoubleRange("double", Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, false, false);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", 1, topDocs.scoreDocs.length );
-
- q= LegacyNumericRangeQuery.newDoubleRange("double", Double.NaN, Double.NaN, true, true);
- topDocs = s.search(q, 10);
- assertEquals("Score doc count", TestLegacyNumericUtils.DOUBLE_NANs.length, topDocs.scoreDocs.length );
-
- r.close();
- dir.close();
- }
-
- private void testRangeSplit(int precisionStep) throws Exception {
- String field="ascfield"+precisionStep;
- // 10 random tests
- int num = TestUtil.nextInt(random(), 10, 20);
- for (int i = 0; i < num; i++) {
- long lower=(long)(random().nextDouble()*noDocs - noDocs/2);
- long upper=(long)(random().nextDouble()*noDocs - noDocs/2);
- if (lower>upper) {
- long a=lower; lower=upper; upper=a;
- }
- // test inclusive range
- Query tq= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, true);
- TopDocs tTopDocs = searcher.search(tq, 1);
- assertEquals("Returned count of range query must be equal to inclusive range length", upper-lower+1, tTopDocs.totalHits );
- // test exclusive range
- tq= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, false, false);
- tTopDocs = searcher.search(tq, 1);
- assertEquals("Returned count of range query must be equal to exclusive range length", Math.max(upper-lower-1, 0), tTopDocs.totalHits );
- // test left exclusive range
- tq= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, false, true);
- tTopDocs = searcher.search(tq, 1);
- assertEquals("Returned count of range query must be equal to half exclusive range length", upper-lower, tTopDocs.totalHits );
- // test right exclusive range
- tq= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, false);
- tTopDocs = searcher.search(tq, 1);
- assertEquals("Returned count of range query must be equal to half exclusive range length", upper-lower, tTopDocs.totalHits );
- }
- }
-
- @Test
- public void testRangeSplit_8bit() throws Exception {
- testRangeSplit(8);
- }
-
- @Test
- public void testRangeSplit_6bit() throws Exception {
- testRangeSplit(6);
- }
-
- @Test
- public void testRangeSplit_4bit() throws Exception {
- testRangeSplit(4);
- }
-
- @Test
- public void testRangeSplit_2bit() throws Exception {
- testRangeSplit(2);
- }
-
- /** we fake a double test using long2double conversion of LegacyNumericUtils */
- private void testDoubleRange(int precisionStep) throws Exception {
- final String field="ascfield"+precisionStep;
- final long lower=-1000L, upper=+2000L;
-
- Query tq= LegacyNumericRangeQuery.newDoubleRange(field, precisionStep,
- NumericUtils.sortableLongToDouble(lower), NumericUtils.sortableLongToDouble(upper), true, true);
- TopDocs tTopDocs = searcher.search(tq, 1);
- assertEquals("Returned count of range query must be equal to inclusive range length", upper-lower+1, tTopDocs.totalHits );
- }
-
- @Test
- public void testDoubleRange_8bit() throws Exception {
- testDoubleRange(8);
- }
-
- @Test
- public void testDoubleRange_6bit() throws Exception {
- testDoubleRange(6);
- }
-
- @Test
- public void testDoubleRange_4bit() throws Exception {
- testDoubleRange(4);
- }
-
- @Test
- public void testDoubleRange_2bit() throws Exception {
- testDoubleRange(2);
- }
-
- @Test
- public void testEqualsAndHash() throws Exception {
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test1", 4, 10L, 20L, true, true));
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test2", 4, 10L, 20L, false, true));
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test3", 4, 10L, 20L, true, false));
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test4", 4, 10L, 20L, false, false));
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test5", 4, 10L, null, true, true));
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test6", 4, null, 20L, true, true));
- QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test7", 4, null, null, true, true));
- QueryUtils.checkEqual(
- LegacyNumericRangeQuery.newLongRange("test8", 4, 10L, 20L, true, true),
- LegacyNumericRangeQuery.newLongRange("test8", 4, 10L, 20L, true, true)
- );
- QueryUtils.checkUnequal(
- LegacyNumericRangeQuery.newLongRange("test9", 4, 10L, 20L, true, true),
- LegacyNumericRangeQuery.newLongRange("test9", 8, 10L, 20L, true, true)
- );
- QueryUtils.checkUnequal(
- LegacyNumericRangeQuery.newLongRange("test10a", 4, 10L, 20L, true, true),
- LegacyNumericRangeQuery.newLongRange("test10b", 4, 10L, 20L, true, true)
- );
- QueryUtils.checkUnequal(
- LegacyNumericRangeQuery.newLongRange("test11", 4, 10L, 20L, true, true),
- LegacyNumericRangeQuery.newLongRange("test11", 4, 20L, 10L, true, true)
- );
- QueryUtils.checkUnequal(
- LegacyNumericRangeQuery.newLongRange("test12", 4, 10L, 20L, true, true),
- LegacyNumericRangeQuery.newLongRange("test12", 4, 10L, 20L, false, true)
- );
- QueryUtils.checkUnequal(
- LegacyNumericRangeQuery.newLongRange("test13", 4, 10L, 20L, true, true),
- LegacyNumericRangeQuery.newFloatRange("test13", 4, 10f, 20f, true, true)
- );
- // difference to int range is tested in TestNumericRangeQuery32
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/759fa42b/lucene/backward-codecs/src/test/org/apache/lucene/legacy/TestNumericTokenStream.java
----------------------------------------------------------------------
diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/legacy/TestNumericTokenStream.java b/lucene/backward-codecs/src/test/org/apache/lucene/legacy/TestNumericTokenStream.java
deleted file mode 100644
index a507af0..0000000
--- a/lucene/backward-codecs/src/test/org/apache/lucene/legacy/TestNumericTokenStream.java
+++ /dev/null
@@ -1,188 +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.lucene.legacy;
-
-
-import org.apache.lucene.util.AttributeImpl;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
-import org.apache.lucene.analysis.tokenattributes.TypeAttribute;
-import org.apache.lucene.legacy.LegacyNumericTokenStream;
-import org.apache.lucene.legacy.LegacyNumericUtils;
-import org.apache.lucene.legacy.LegacyNumericTokenStream.LegacyNumericTermAttributeImpl;
-import org.apache.lucene.analysis.BaseTokenStreamTestCase;
-import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-import org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl;
-
-@Deprecated
-public class TestNumericTokenStream extends BaseTokenStreamTestCase {
-
- final long lvalue = random().nextLong();
- final int ivalue = random().nextInt();
-
- public void testLongStream() throws Exception {
- @SuppressWarnings("resource")
- final LegacyNumericTokenStream stream=new LegacyNumericTokenStream().setLongValue(lvalue);
- final TermToBytesRefAttribute bytesAtt = stream.getAttribute(TermToBytesRefAttribute.class);
- assertNotNull(bytesAtt);
- final TypeAttribute typeAtt = stream.getAttribute(TypeAttribute.class);
- assertNotNull(typeAtt);
- final LegacyNumericTokenStream.LegacyNumericTermAttribute numericAtt = stream.getAttribute(LegacyNumericTokenStream.LegacyNumericTermAttribute.class);
- assertNotNull(numericAtt);
- stream.reset();
- assertEquals(64, numericAtt.getValueSize());
- for (int shift=0; shift<64; shift+= LegacyNumericUtils.PRECISION_STEP_DEFAULT) {
- assertTrue("New token is available", stream.incrementToken());
- assertEquals("Shift value wrong", shift, numericAtt.getShift());
- assertEquals("Term is incorrectly encoded", lvalue & ~((1L << shift) - 1L), LegacyNumericUtils.prefixCodedToLong(bytesAtt.getBytesRef()));
- assertEquals("Term raw value is incorrectly encoded", lvalue & ~((1L << shift) - 1L), numericAtt.getRawValue());
- assertEquals("Type incorrect", (shift == 0) ? LegacyNumericTokenStream.TOKEN_TYPE_FULL_PREC : LegacyNumericTokenStream.TOKEN_TYPE_LOWER_PREC, typeAtt.type());
- }
- assertFalse("More tokens available", stream.incrementToken());
- stream.end();
- stream.close();
- }
-
- public void testIntStream() throws Exception {
- @SuppressWarnings("resource")
- final LegacyNumericTokenStream stream=new LegacyNumericTokenStream().setIntValue(ivalue);
- final TermToBytesRefAttribute bytesAtt = stream.getAttribute(TermToBytesRefAttribute.class);
- assertNotNull(bytesAtt);
- final TypeAttribute typeAtt = stream.getAttribute(TypeAttribute.class);
- assertNotNull(typeAtt);
- final LegacyNumericTokenStream.LegacyNumericTermAttribute numericAtt = stream.getAttribute(LegacyNumericTokenStream.LegacyNumericTermAttribute.class);
- assertNotNull(numericAtt);
- stream.reset();
- assertEquals(32, numericAtt.getValueSize());
- for (int shift=0; shift<32; shift+= LegacyNumericUtils.PRECISION_STEP_DEFAULT) {
- assertTrue("New token is available", stream.incrementToken());
- assertEquals("Shift value wrong", shift, numericAtt.getShift());
- assertEquals("Term is incorrectly encoded", ivalue & ~((1 << shift) - 1), LegacyNumericUtils.prefixCodedToInt(bytesAtt.getBytesRef()));
- assertEquals("Term raw value is incorrectly encoded", ((long) ivalue) & ~((1L << shift) - 1L), numericAtt.getRawValue());
- assertEquals("Type incorrect", (shift == 0) ? LegacyNumericTokenStream.TOKEN_TYPE_FULL_PREC : LegacyNumericTokenStream.TOKEN_TYPE_LOWER_PREC, typeAtt.type());
- }
- assertFalse("More tokens available", stream.incrementToken());
- stream.end();
- stream.close();
- }
-
- public void testNotInitialized() throws Exception {
- final LegacyNumericTokenStream stream=new LegacyNumericTokenStream();
-
- expectThrows(IllegalStateException.class, () -> {
- stream.reset();
- });
-
- expectThrows(IllegalStateException.class, () -> {
- stream.incrementToken();
- });
-
- stream.close();
- }
-
- public static interface TestAttribute extends CharTermAttribute {}
- public static class TestAttributeImpl extends CharTermAttributeImpl implements TestAttribute {}
-
- public void testCTA() throws Exception {
- final LegacyNumericTokenStream stream=new LegacyNumericTokenStream();
- IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> {
- stream.addAttribute(CharTermAttribute.class);
- });
- assertTrue(e.getMessage().startsWith("LegacyNumericTokenStream does not support"));
-
- e = expectThrows(IllegalArgumentException.class, () -> {
- stream.addAttribute(TestAttribute.class);
- });
- assertTrue(e.getMessage().startsWith("LegacyNumericTokenStream does not support"));
- stream.close();
- }
-
- /** LUCENE-7027 */
- public void testCaptureStateAfterExhausted() throws Exception {
- // default precstep
- try (LegacyNumericTokenStream stream=new LegacyNumericTokenStream()) {
- // int
- stream.setIntValue(ivalue);
- stream.reset();
- while (stream.incrementToken());
- stream.captureState();
- stream.end();
- stream.captureState();
- // long
- stream.setLongValue(lvalue);
- stream.reset();
- while (stream.incrementToken());
- stream.captureState();
- stream.end();
- stream.captureState();
- }
- // huge precstep
- try (LegacyNumericTokenStream stream=new LegacyNumericTokenStream(Integer.MAX_VALUE)) {
- // int
- stream.setIntValue(ivalue);
- stream.reset();
- while (stream.incrementToken());
- stream.captureState();
- stream.end();
- stream.captureState();
- // long
- stream.setLongValue(lvalue);
- stream.reset();
- while (stream.incrementToken());
- stream.captureState();
- stream.end();
- stream.captureState();
- }
- }
-
- public void testAttributeClone() throws Exception {
- LegacyNumericTermAttributeImpl att = new LegacyNumericTermAttributeImpl();
- att.init(lvalue, 64, 8, 0); // set some value, to make getBytesRef() work
- LegacyNumericTermAttributeImpl copy = assertCloneIsEqual(att);
- assertNotSame(att.getBytesRef(), copy.getBytesRef());
- LegacyNumericTermAttributeImpl copy2 = assertCopyIsEqual(att);
- assertNotSame(att.getBytesRef(), copy2.getBytesRef());
-
- // LUCENE-7027 test
- att.init(lvalue, 64, 8, 64); // Exhausted TokenStream -> should return empty BytesRef
- assertEquals(new BytesRef(), att.getBytesRef());
- copy = assertCloneIsEqual(att);
- assertEquals(new BytesRef(), copy.getBytesRef());
- assertNotSame(att.getBytesRef(), copy.getBytesRef());
- copy2 = assertCopyIsEqual(att);
- assertEquals(new BytesRef(), copy2.getBytesRef());
- assertNotSame(att.getBytesRef(), copy2.getBytesRef());
- }
-
- public static <T extends AttributeImpl> T assertCloneIsEqual(T att) {
- @SuppressWarnings("unchecked")
- T clone = (T) att.clone();
- assertEquals("Clone must be equal", att, clone);
- assertEquals("Clone's hashcode must be equal", att.hashCode(), clone.hashCode());
- return clone;
- }
-
- public static <T extends AttributeImpl> T assertCopyIsEqual(T att) throws Exception {
- @SuppressWarnings("unchecked")
- T copy = (T) att.getClass().newInstance();
- att.copyTo(copy);
- assertEquals("Copied instance must be equal", att, copy);
- assertEquals("Copied instance's hashcode must be equal", att.hashCode(), copy.hashCode());
- return copy;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/759fa42b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java
index 90e36d8..7536b60 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java
@@ -25,11 +25,6 @@ import org.apache.lucene.document.StringField;
import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.Term;
-import org.apache.lucene.legacy.LegacyDoubleField;
-import org.apache.lucene.legacy.LegacyFieldType;
-import org.apache.lucene.legacy.LegacyNumericRangeQuery;
-import org.apache.lucene.legacy.LegacyNumericType;
-import org.apache.lucene.legacy.LegacyNumericUtils;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
@@ -41,8 +36,6 @@ import org.apache.lucene.spatial.query.SpatialArgs;
import org.apache.lucene.spatial.query.SpatialOperation;
import org.apache.lucene.spatial.query.UnsupportedSpatialOperation;
import org.apache.lucene.spatial.util.DistanceToShapeValueSource;
-import org.apache.lucene.util.BytesRefBuilder;
-import org.apache.lucene.util.NumericUtils;
import org.locationtech.spatial4j.context.SpatialContext;
import org.locationtech.spatial4j.shape.Point;
import org.locationtech.spatial4j.shape.Rectangle;
@@ -88,8 +81,6 @@ public class BBoxStrategy extends SpatialStrategy {
*/
public static FieldType DEFAULT_FIELDTYPE;
- @Deprecated
- public static LegacyFieldType LEGACY_FIELDTYPE;
static {
// Default: pointValues + docValues
FieldType type = new FieldType();
@@ -98,15 +89,6 @@ public class BBoxStrategy extends SpatialStrategy {
type.setStored(false);
type.freeze();
DEFAULT_FIELDTYPE = type;
- // Legacy default: legacyNumerics + docValues
- LegacyFieldType legacyType = new LegacyFieldType();
- legacyType.setIndexOptions(IndexOptions.DOCS);
- legacyType.setNumericType(LegacyNumericType.DOUBLE);
- legacyType.setNumericPrecisionStep(8);// same as solr default
- legacyType.setDocValuesType(DocValuesType.NUMERIC);//docValues
- legacyType.setStored(false);
- legacyType.freeze();
- LEGACY_FIELDTYPE = legacyType;
}
public static final String SUFFIX_MINX = "__minX";
@@ -131,8 +113,6 @@ public class BBoxStrategy extends SpatialStrategy {
private final boolean hasStored;
private final boolean hasDocVals;
private final boolean hasPointVals;
- // equiv to "hasLegacyNumerics":
- private final LegacyFieldType legacyNumericFieldType; // not stored; holds precision step.
private final FieldType xdlFieldType;
/**
@@ -143,15 +123,6 @@ public class BBoxStrategy extends SpatialStrategy {
}
/**
- * Creates a new {@link BBoxStrategy} instance that uses {@link LegacyDoubleField} for backwards compatibility
- * @deprecated LegacyNumerics will be removed
- */
- @Deprecated
- public static BBoxStrategy newLegacyInstance(SpatialContext ctx, String fieldNamePrefix) {
- return new BBoxStrategy(ctx, fieldNamePrefix, LEGACY_FIELDTYPE);
- }
-
- /**
* Creates this strategy.
* {@code fieldType} is used to customize the indexing options of the 4 number fields, and to a lesser degree the XDL
* field too. Search requires pointValues (or legacy numerics), and relevancy requires docValues. If these features
@@ -179,23 +150,8 @@ public class BBoxStrategy extends SpatialStrategy {
if ((this.hasPointVals = fieldType.pointDimensionCount() > 0)) {
numQuads++;
}
- if (fieldType.indexOptions() != IndexOptions.NONE && fieldType instanceof LegacyFieldType && ((LegacyFieldType)fieldType).numericType() != null) {
- if (hasPointVals) {
- throw new IllegalArgumentException("pointValues and LegacyNumericType are mutually exclusive");
- }
- final LegacyFieldType legacyType = (LegacyFieldType) fieldType;
- if (legacyType.numericType() != LegacyNumericType.DOUBLE) {
- throw new IllegalArgumentException(getClass() + " does not support " + legacyType.numericType());
- }
- numQuads++;
- legacyNumericFieldType = new LegacyFieldType(LegacyDoubleField.TYPE_NOT_STORED);
- legacyNumericFieldType.setNumericPrecisionStep(legacyType.numericPrecisionStep());
- legacyNumericFieldType.freeze();
- } else {
- legacyNumericFieldType = null;
- }
- if (hasPointVals || legacyNumericFieldType != null) { // if we have an index...
+ if (hasPointVals) { // if we have an index...
xdlFieldType = new FieldType(StringField.TYPE_NOT_STORED);
xdlFieldType.setIndexOptions(IndexOptions.DOCS);
xdlFieldType.freeze();
@@ -242,12 +198,6 @@ public class BBoxStrategy extends SpatialStrategy {
fields[++idx] = new DoublePoint(field_maxX, bbox.getMaxX());
fields[++idx] = new DoublePoint(field_maxY, bbox.getMaxY());
}
- if (legacyNumericFieldType != null) {
- fields[++idx] = new LegacyDoubleField(field_minX, bbox.getMinX(), legacyNumericFieldType);
- fields[++idx] = new LegacyDoubleField(field_minY, bbox.getMinY(), legacyNumericFieldType);
- fields[++idx] = new LegacyDoubleField(field_maxX, bbox.getMaxX(), legacyNumericFieldType);
- fields[++idx] = new LegacyDoubleField(field_maxY, bbox.getMaxY(), legacyNumericFieldType);
- }
if (xdlFieldType != null) {
fields[++idx] = new Field(field_xdl, bbox.getCrossesDateLine()?"T":"F", xdlFieldType);
}
@@ -664,17 +614,12 @@ public class BBoxStrategy extends SpatialStrategy {
private Query makeNumberTermQuery(String field, double number) {
if (hasPointVals) {
return DoublePoint.newExactQuery(field, number);
- } else if (legacyNumericFieldType != null) {
- BytesRefBuilder bytes = new BytesRefBuilder();
- LegacyNumericUtils.longToPrefixCoded(NumericUtils.doubleToSortableLong(number), 0, bytes);
- return new TermQuery(new Term(field, bytes.get()));
}
throw new UnsupportedOperationException("An index is required for this operation.");
}
/**
* Returns a numeric range query based on FieldType
- * {@link LegacyNumericRangeQuery} is used for indexes created using {@code FieldType.LegacyNumericType}
* {@link DoublePoint#newRangeQuery} is used for indexes created using {@link DoublePoint} fields
*
* @param fieldname field name. must not be <code>null</code>.
@@ -702,8 +647,6 @@ public class BBoxStrategy extends SpatialStrategy {
}
return DoublePoint.newRangeQuery(fieldname, min, max);
- } else if (legacyNumericFieldType != null) {// todo remove legacy numeric support in 7.0
- return LegacyNumericRangeQuery.newDoubleRange(fieldname, legacyNumericFieldType.numericPrecisionStep(), min, max, minInclusive, maxInclusive);
}
throw new UnsupportedOperationException("An index is required for this operation.");
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/759fa42b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/BytesRefIteratorTokenStream.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/BytesRefIteratorTokenStream.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/BytesRefIteratorTokenStream.java
index 757e2bd..ca38abf 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/BytesRefIteratorTokenStream.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/BytesRefIteratorTokenStream.java
@@ -26,8 +26,6 @@ import org.apache.lucene.util.BytesRefIterator;
/**
* A TokenStream used internally by {@link org.apache.lucene.spatial.prefix.PrefixTreeStrategy}.
*
- * This is modelled after {@link org.apache.lucene.legacy.LegacyNumericTokenStream}.
- *
* @lucene.internal
*/
class BytesRefIteratorTokenStream extends TokenStream {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/759fa42b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/vector/PointVectorStrategy.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/vector/PointVectorStrategy.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/vector/PointVectorStrategy.java
index 59aff49..ef3eaa4 100644
--- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/vector/PointVectorStrategy.java
+++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/vector/PointVectorStrategy.java
@@ -22,11 +22,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.DocValuesType;
-import org.apache.lucene.index.IndexOptions;
-import org.apache.lucene.legacy.LegacyDoubleField;
-import org.apache.lucene.legacy.LegacyFieldType;
-import org.apache.lucene.legacy.LegacyNumericRangeQuery;
-import org.apache.lucene.legacy.LegacyNumericType;
import org.apache.lucene.queries.function.FunctionRangeQuery;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.BooleanClause;
@@ -86,8 +81,6 @@ public class PointVectorStrategy extends SpatialStrategy {
*/
public static FieldType DEFAULT_FIELDTYPE;
- @Deprecated
- public static LegacyFieldType LEGACY_FIELDTYPE;
static {
// Default: pointValues + docValues
FieldType type = new FieldType();
@@ -96,15 +89,6 @@ public class PointVectorStrategy extends SpatialStrategy {
type.setStored(false);
type.freeze();
DEFAULT_FIELDTYPE = type;
- // Legacy default: legacyNumerics
- LegacyFieldType legacyType = new LegacyFieldType();
- legacyType.setIndexOptions(IndexOptions.DOCS);
- legacyType.setNumericType(LegacyNumericType.DOUBLE);
- legacyType.setNumericPrecisionStep(8);// same as solr default
- legacyType.setDocValuesType(DocValuesType.NONE);//no docValues!
- legacyType.setStored(false);
- legacyType.freeze();
- LEGACY_FIELDTYPE = legacyType;
}
public static final String SUFFIX_X = "__x";
@@ -117,8 +101,6 @@ public class PointVectorStrategy extends SpatialStrategy {
private final boolean hasStored;
private final boolean hasDocVals;
private final boolean hasPointVals;
- // equiv to "hasLegacyNumerics":
- private final LegacyFieldType legacyNumericFieldType; // not stored; holds precision step.
/**
* Create a new {@link PointVectorStrategy} instance that uses {@link DoublePoint} and {@link DoublePoint#newRangeQuery}
@@ -128,18 +110,6 @@ public class PointVectorStrategy extends SpatialStrategy {
}
/**
- * Create a new {@link PointVectorStrategy} instance that uses {@link LegacyDoubleField} for backwards compatibility.
- * However, back-compat is limited; we don't support circle queries or {@link #makeDistanceValueSource(Point, double)}
- * since that requires docValues (the legacy config didn't have that).
- *
- * @deprecated LegacyNumerics will be removed
- */
- @Deprecated
- public static PointVectorStrategy newLegacyInstance(SpatialContext ctx, String fieldNamePrefix) {
- return new PointVectorStrategy(ctx, fieldNamePrefix, LEGACY_FIELDTYPE);
- }
-
- /**
* Create a new instance configured with the provided FieldType options. See {@link #DEFAULT_FIELDTYPE}.
* a field type is used to articulate the desired options (namely pointValues, docValues, stored). Legacy numerics
* is configurable this way too.
@@ -159,21 +129,6 @@ public class PointVectorStrategy extends SpatialStrategy {
if ((this.hasPointVals = fieldType.pointDimensionCount() > 0)) {
numPairs++;
}
- if (fieldType.indexOptions() != IndexOptions.NONE && fieldType instanceof LegacyFieldType && ((LegacyFieldType)fieldType).numericType() != null) {
- if (hasPointVals) {
- throw new IllegalArgumentException("pointValues and LegacyNumericType are mutually exclusive");
- }
- final LegacyFieldType legacyType = (LegacyFieldType) fieldType;
- if (legacyType.numericType() != LegacyNumericType.DOUBLE) {
- throw new IllegalArgumentException(getClass() + " does not support " + legacyType.numericType());
- }
- numPairs++;
- legacyNumericFieldType = new LegacyFieldType(LegacyDoubleField.TYPE_NOT_STORED);
- legacyNumericFieldType.setNumericPrecisionStep(legacyType.numericPrecisionStep());
- legacyNumericFieldType.freeze();
- } else {
- legacyNumericFieldType = null;
- }
this.fieldsLen = numPairs * 2;
}
@@ -209,10 +164,6 @@ public class PointVectorStrategy extends SpatialStrategy {
fields[++idx] = new DoublePoint(fieldNameX, point.getX());
fields[++idx] = new DoublePoint(fieldNameY, point.getY());
}
- if (legacyNumericFieldType != null) {
- fields[++idx] = new LegacyDoubleField(fieldNameX, point.getX(), legacyNumericFieldType);
- fields[++idx] = new LegacyDoubleField(fieldNameY, point.getY(), legacyNumericFieldType);
- }
assert idx == fields.length - 1;
return fields;
}
@@ -268,7 +219,6 @@ public class PointVectorStrategy extends SpatialStrategy {
/**
* Returns a numeric range query based on FieldType
- * {@link LegacyNumericRangeQuery} is used for indexes created using {@code FieldType.LegacyNumericType}
* {@link DoublePoint#newRangeQuery} is used for indexes created using {@link DoublePoint} fields
*/
private Query rangeQuery(String fieldName, Double min, Double max) {
@@ -283,8 +233,6 @@ public class PointVectorStrategy extends SpatialStrategy {
return DoublePoint.newRangeQuery(fieldName, min, max);
- } else if (legacyNumericFieldType != null) {// todo remove legacy numeric support in 7.0
- return LegacyNumericRangeQuery.newDoubleRange(fieldName, legacyNumericFieldType.numericPrecisionStep(), min, max, true, true);//inclusive
}
//TODO try doc-value range query?
throw new UnsupportedOperationException("An index is required for this operation.");
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/759fa42b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/DistanceStrategyTest.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/DistanceStrategyTest.java b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/DistanceStrategyTest.java
index d54e1c9..536436b 100644
--- a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/DistanceStrategyTest.java
+++ b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/DistanceStrategyTest.java
@@ -68,9 +68,6 @@ public class DistanceStrategyTest extends StrategyTestCase {
strategy = BBoxStrategy.newInstance(ctx, "bbox");
ctorArgs.add(new Object[]{strategy.getFieldName(), strategy});
- strategy = BBoxStrategy.newLegacyInstance(ctx, "bbox_legacy");
- ctorArgs.add(new Object[]{strategy.getFieldName(), strategy});
-
strategy = new SerializedDVStrategy(ctx, "serialized");
ctorArgs.add(new Object[]{strategy.getFieldName(), strategy});
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/759fa42b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/QueryEqualsHashCodeTest.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/QueryEqualsHashCodeTest.java b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/QueryEqualsHashCodeTest.java
index c14fe54..f52ef2b 100644
--- a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/QueryEqualsHashCodeTest.java
+++ b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/QueryEqualsHashCodeTest.java
@@ -58,9 +58,7 @@ public class QueryEqualsHashCodeTest extends LuceneTestCase {
strategies.add(recursive_geohash);
strategies.add(new TermQueryPrefixTreeStrategy(gridQuad, "termquery_quad"));
strategies.add(PointVectorStrategy.newInstance(ctx, "pointvector"));
- strategies.add(PointVectorStrategy.newLegacyInstance(ctx, "pointvector_legacy"));
strategies.add(BBoxStrategy.newInstance(ctx, "bbox"));
- strategies.add(BBoxStrategy.newLegacyInstance(ctx, "bbox_legacy"));
final SerializedDVStrategy serialized = new SerializedDVStrategy(ctx, "serialized");
strategies.add(serialized);
strategies.add(new CompositeSpatialStrategy("composite", recursive_geohash, serialized));
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/759fa42b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java
index 20df730..210ab38 100644
--- a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java
+++ b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/bbox/TestBBoxStrategy.java
@@ -21,8 +21,6 @@ import java.io.IOException;
import com.carrotsearch.randomizedtesting.annotations.Repeat;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.index.DocValuesType;
-import org.apache.lucene.index.IndexOptions;
-import org.apache.lucene.legacy.LegacyFieldType;
import org.apache.lucene.search.Query;
import org.apache.lucene.spatial.SpatialMatchConcern;
import org.apache.lucene.spatial.prefix.RandomSpatialOpStrategyTestCase;
@@ -93,20 +91,10 @@ public class TestBBoxStrategy extends RandomSpatialOpStrategyTestCase {
factory.worldBounds = new RectangleImpl(-300, 300, -100, 100, null);
this.ctx = factory.newSpatialContext();
}
- // randomly test legacy (numeric) and point based bbox strategy
- if (random().nextBoolean()) {
- this.strategy = BBoxStrategy.newInstance(ctx, "bbox");
- } else {
- this.strategy = BBoxStrategy.newLegacyInstance(ctx, "bbox");
- }
+ this.strategy = BBoxStrategy.newInstance(ctx, "bbox");
//test we can disable docValues for predicate tests
if (random().nextBoolean()) {
- FieldType fieldType = ((BBoxStrategy)strategy).getFieldType();
- if (fieldType instanceof LegacyFieldType) {
- fieldType = new LegacyFieldType((LegacyFieldType)fieldType);
- } else {
- fieldType = new FieldType(fieldType);
- }
+ FieldType fieldType = new FieldType(((BBoxStrategy)strategy).getFieldType());
fieldType.setDocValuesType(DocValuesType.NONE);
strategy = new BBoxStrategy(ctx, strategy.getFieldName(), fieldType);
}
@@ -194,11 +182,7 @@ public class TestBBoxStrategy extends RandomSpatialOpStrategyTestCase {
private void setupGeo() {
this.ctx = SpatialContext.GEO;
- if (random().nextBoolean()) {
- this.strategy = BBoxStrategy.newInstance(ctx, "bbox");
- } else {
- this.strategy = BBoxStrategy.newLegacyInstance(ctx, "bbox");
- }
+ this.strategy = BBoxStrategy.newInstance(ctx, "bbox");
}
// OLD STATIC TESTS (worthless?)
@@ -239,16 +223,9 @@ public class TestBBoxStrategy extends RandomSpatialOpStrategyTestCase {
FieldType fieldType;
// random legacy or not legacy
String FIELD_PREFIX = "bbox";
+ fieldType = new FieldType(BBoxStrategy.DEFAULT_FIELDTYPE);
if (random().nextBoolean()) {
- fieldType = new FieldType(BBoxStrategy.DEFAULT_FIELDTYPE);
- if (random().nextBoolean()) {
- fieldType.setDimensions(0, 0);
- }
- } else {
- fieldType = new FieldType(BBoxStrategy.LEGACY_FIELDTYPE);
- if (random().nextBoolean()) {
- fieldType.setIndexOptions(IndexOptions.NONE);
- }
+ fieldType.setDimensions(0, 0);
}
strategy = new BBoxStrategy(ctx, FIELD_PREFIX, fieldType);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/759fa42b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/vector/TestPointVectorStrategy.java
----------------------------------------------------------------------
diff --git a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/vector/TestPointVectorStrategy.java b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/vector/TestPointVectorStrategy.java
index ac5ab95..901594e 100644
--- a/lucene/spatial-extras/src/test/org/apache/lucene/spatial/vector/TestPointVectorStrategy.java
+++ b/lucene/spatial-extras/src/test/org/apache/lucene/spatial/vector/TestPointVectorStrategy.java
@@ -63,12 +63,7 @@ public class TestPointVectorStrategy extends StrategyTestCase {
@Test
public void testCitiesIntersectsBBox() throws IOException {
// note: does not require docValues
- if (random().nextBoolean()) {
- this.strategy = PointVectorStrategy.newInstance(ctx, getClass().getSimpleName());
- } else {
- // switch to legacy instance sometimes, which has no docValues
- this.strategy = PointVectorStrategy.newLegacyInstance(ctx, getClass().getSimpleName());
- }
+ this.strategy = PointVectorStrategy.newInstance(ctx, getClass().getSimpleName());
getAddAndVerifyIndexedDocuments(DATA_WORLD_CITIES_POINTS);
executeQueries(SpatialMatchConcern.FILTER, QTEST_Cities_Intersects_BBox);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/759fa42b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/AnalyticsParsers.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/AnalyticsParsers.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/AnalyticsParsers.java
index aadb9e2..dd64c3f 100644
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/AnalyticsParsers.java
+++ b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/AnalyticsParsers.java
@@ -20,7 +20,7 @@ import java.io.IOException;
import java.time.Instant;
import java.util.Arrays;
-import org.apache.lucene.legacy.LegacyNumericUtils;
+import org.apache.solr.legacy.LegacyNumericUtils;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.NumericUtils;
import org.apache.solr.schema.FieldType;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/759fa42b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DateFieldSource.java
----------------------------------------------------------------------
diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DateFieldSource.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DateFieldSource.java
index d13795d..803d8e0 100644
--- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DateFieldSource.java
+++ b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/valuesource/DateFieldSource.java
@@ -24,7 +24,7 @@ import java.util.Map;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.NumericDocValues;
-import org.apache.lucene.legacy.LegacyNumericUtils;
+import org.apache.solr.legacy.LegacyNumericUtils;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.docvalues.LongDocValues;
import org.apache.lucene.queries.function.valuesource.LongFieldSource;