You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2016/01/21 16:58:11 UTC
svn commit: r1725998 [3/4] - in /lucene/dev/trunk: lucene/
lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene50/
lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene53/
lucene/backward-codecs/src/java/org/apache/lucene/codecs/lu...
Copied: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java (from r1725744, lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/DimensionalRangeQuery.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java?p2=lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java&p1=lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/DimensionalRangeQuery.java&r1=1725744&r2=1725998&rev=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/DimensionalRangeQuery.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java Thu Jan 21 15:58:08 2016
@@ -21,14 +21,9 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
-import org.apache.lucene.document.DimensionalBinaryField;
-import org.apache.lucene.document.DimensionalDoubleField;
-import org.apache.lucene.document.DimensionalFloatField;
-import org.apache.lucene.document.DimensionalIntField;
-import org.apache.lucene.document.DimensionalLongField;
-import org.apache.lucene.index.DimensionalValues;
-import org.apache.lucene.index.DimensionalValues.IntersectVisitor;
-import org.apache.lucene.index.DimensionalValues.Relation;
+import org.apache.lucene.index.PointValues;
+import org.apache.lucene.index.PointValues.IntersectVisitor;
+import org.apache.lucene.index.PointValues.Relation;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
@@ -37,11 +32,11 @@ import org.apache.lucene.util.NumericUti
import org.apache.lucene.util.RamUsageEstimator;
import org.apache.lucene.util.StringHelper;
-/** Searches for ranges in fields previously indexed using dimensional
- * fields, e.g. {@link DimensionalLongField}. In a 1D field this is
+/** Searches for ranges in fields previously indexed using points e.g.
+ * {@link org.apache.lucene.document.LongPoint}. In a 1D field this is
* a simple range query; in a multi-dimensional field it's a box shape. */
-public class DimensionalRangeQuery extends Query {
+public class PointRangeQuery extends Query {
final String field;
final int numDims;
final byte[][] lowerPoint;
@@ -51,9 +46,9 @@ public class DimensionalRangeQuery exten
// This is null only in the "fully open range" case
final Integer bytesPerDim;
- public DimensionalRangeQuery(String field,
- byte[][] lowerPoint, boolean[] lowerInclusive,
- byte[][] upperPoint, boolean[] upperInclusive) {
+ public PointRangeQuery(String field,
+ byte[][] lowerPoint, boolean[] lowerInclusive,
+ byte[][] upperPoint, boolean[] upperInclusive) {
this.field = field;
if (lowerPoint == null) {
throw new IllegalArgumentException("lowerPoint must not be null");
@@ -96,29 +91,29 @@ public class DimensionalRangeQuery exten
}
}
- /** Use in the 1D case when you indexed 1D int values using {@link DimensionalIntField} */
- public static DimensionalRangeQuery new1DIntRange(String field, Integer lowerValue, boolean lowerInclusive, Integer upperValue, boolean upperInclusive) {
- return new DimensionalRangeQuery(field, pack(lowerValue), new boolean[] {lowerInclusive}, pack(upperValue), new boolean[] {upperInclusive});
+ /** Use in the 1D case when you indexed 1D int values using {@link org.apache.lucene.document.IntPoint} */
+ public static PointRangeQuery new1DIntRange(String field, Integer lowerValue, boolean lowerInclusive, Integer upperValue, boolean upperInclusive) {
+ return new PointRangeQuery(field, pack(lowerValue), new boolean[] {lowerInclusive}, pack(upperValue), new boolean[] {upperInclusive});
}
- /** Use in the 1D case when you indexed 1D long values using {@link DimensionalLongField} */
- public static DimensionalRangeQuery new1DLongRange(String field, Long lowerValue, boolean lowerInclusive, Long upperValue, boolean upperInclusive) {
- return new DimensionalRangeQuery(field, pack(lowerValue), new boolean[] {lowerInclusive}, pack(upperValue), new boolean[] {upperInclusive});
+ /** Use in the 1D case when you indexed 1D long values using {@link org.apache.lucene.document.LongPoint} */
+ public static PointRangeQuery new1DLongRange(String field, Long lowerValue, boolean lowerInclusive, Long upperValue, boolean upperInclusive) {
+ return new PointRangeQuery(field, pack(lowerValue), new boolean[] {lowerInclusive}, pack(upperValue), new boolean[] {upperInclusive});
}
- /** Use in the 1D case when you indexed 1D float values using {@link DimensionalFloatField} */
- public static DimensionalRangeQuery new1DFloatRange(String field, Float lowerValue, boolean lowerInclusive, Float upperValue, boolean upperInclusive) {
- return new DimensionalRangeQuery(field, pack(lowerValue), new boolean[] {lowerInclusive}, pack(upperValue), new boolean[] {upperInclusive});
+ /** Use in the 1D case when you indexed 1D float values using {@link org.apache.lucene.document.FloatPoint} */
+ public static PointRangeQuery new1DFloatRange(String field, Float lowerValue, boolean lowerInclusive, Float upperValue, boolean upperInclusive) {
+ return new PointRangeQuery(field, pack(lowerValue), new boolean[] {lowerInclusive}, pack(upperValue), new boolean[] {upperInclusive});
}
- /** Use in the 1D case when you indexed 1D double values using {@link DimensionalDoubleField} */
- public static DimensionalRangeQuery new1DDoubleRange(String field, Double lowerValue, boolean lowerInclusive, Double upperValue, boolean upperInclusive) {
- return new DimensionalRangeQuery(field, pack(lowerValue), new boolean[] {lowerInclusive}, pack(upperValue), new boolean[] {upperInclusive});
+ /** Use in the 1D case when you indexed 1D double values using {@link org.apache.lucene.document.DoublePoint} */
+ public static PointRangeQuery new1DDoubleRange(String field, Double lowerValue, boolean lowerInclusive, Double upperValue, boolean upperInclusive) {
+ return new PointRangeQuery(field, pack(lowerValue), new boolean[] {lowerInclusive}, pack(upperValue), new boolean[] {upperInclusive});
}
- /** Use in the 1D case when you indexed binary values using {@link DimensionalBinaryField} */
- public static DimensionalRangeQuery new1DBinaryRange(String field, byte[] lowerValue, boolean lowerInclusive, byte[] upperValue, boolean upperInclusive) {
- return new DimensionalRangeQuery(field, new byte[][] {lowerValue}, new boolean[] {lowerInclusive}, new byte[][] {upperValue}, new boolean[] {upperInclusive});
+ /** Use in the 1D case when you indexed binary values using {@link org.apache.lucene.document.BinaryPoint} */
+ public static PointRangeQuery new1DBinaryRange(String field, byte[] lowerValue, boolean lowerInclusive, byte[] upperValue, boolean upperInclusive) {
+ return new PointRangeQuery(field, new byte[][] {lowerValue}, new boolean[] {lowerInclusive}, new byte[][] {upperValue}, new boolean[] {upperInclusive});
}
private static byte[][] pack(Long value) {
@@ -172,9 +167,9 @@ public class DimensionalRangeQuery exten
@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
LeafReader reader = context.reader();
- DimensionalValues values = reader.getDimensionalValues();
+ PointValues values = reader.getPointValues();
if (values == null) {
- // No docs in this segment indexed any field dimensionally
+ // No docs in this segment indexed any points
return null;
}
FieldInfo fieldInfo = reader.getFieldInfos().fieldInfo(field);
@@ -182,13 +177,13 @@ public class DimensionalRangeQuery exten
// No docs in this segment indexed this field at all
return null;
}
- if (fieldInfo.getDimensionCount() != numDims) {
- throw new IllegalArgumentException("field=\"" + field + "\" was indexed with numDims=" + fieldInfo.getDimensionCount() + " but this query has numDims=" + numDims);
+ if (fieldInfo.getPointDimensionCount() != numDims) {
+ throw new IllegalArgumentException("field=\"" + field + "\" was indexed with numDims=" + fieldInfo.getPointDimensionCount() + " but this query has numDims=" + numDims);
}
- if (bytesPerDim != null && bytesPerDim.intValue() != fieldInfo.getDimensionNumBytes()) {
- throw new IllegalArgumentException("field=\"" + field + "\" was indexed with bytesPerDim=" + fieldInfo.getDimensionNumBytes() + " but this query has bytesPerDim=" + bytesPerDim);
+ if (bytesPerDim != null && bytesPerDim.intValue() != fieldInfo.getPointNumBytes()) {
+ throw new IllegalArgumentException("field=\"" + field + "\" was indexed with bytesPerDim=" + fieldInfo.getPointNumBytes() + " but this query has bytesPerDim=" + bytesPerDim);
}
- int bytesPerDim = fieldInfo.getDimensionNumBytes();
+ int bytesPerDim = fieldInfo.getPointNumBytes();
byte[] packedLowerIncl = new byte[numDims * bytesPerDim];
byte[] packedUpperIncl = new byte[numDims * bytesPerDim];
@@ -320,7 +315,7 @@ public class DimensionalRangeQuery exten
@Override
public boolean equals(Object other) {
if (super.equals(other)) {
- final DimensionalRangeQuery q = (DimensionalRangeQuery) other;
+ final PointRangeQuery q = (PointRangeQuery) other;
return q.numDims == numDims &&
q.bytesPerDim == bytesPerDim &&
Arrays.equals(lowerPoint, q.lowerPoint) &&
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/Query.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/Query.java?rev=1725998&r1=1725997&r2=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/Query.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/Query.java Thu Jan 21 15:58:08 2016
@@ -33,7 +33,7 @@ import org.apache.lucene.index.IndexRead
<li> {@link FuzzyQuery}
<li> {@link RegexpQuery}
<li> {@link TermRangeQuery}
- <li> {@link DimensionalRangeQuery}
+ <li> {@link PointRangeQuery}
<li> {@link ConstantScoreQuery}
<li> {@link DisjunctionMaxQuery}
<li> {@link MatchAllDocsQuery}
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/UsageTrackingQueryCachingPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/UsageTrackingQueryCachingPolicy.java?rev=1725998&r1=1725997&r2=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/UsageTrackingQueryCachingPolicy.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/UsageTrackingQueryCachingPolicy.java Thu Jan 21 15:58:08 2016
@@ -43,7 +43,7 @@ public final class UsageTrackingQueryCac
// DocIdSet in the first place
return query instanceof MultiTermQuery ||
query instanceof MultiTermQueryConstantScoreWrapper ||
- query instanceof DimensionalRangeQuery;
+ query instanceof PointRangeQuery;
}
static boolean isCheap(Query query) {
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/package-info.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/package-info.java?rev=1725998&r1=1725997&r2=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/package-info.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/package-info.java Thu Jan 21 15:58:08 2016
@@ -160,22 +160,22 @@
* and an upper
* {@link org.apache.lucene.index.Term Term}
* according to {@link org.apache.lucene.util.BytesRef#compareTo BytesRef.compareTo()}. It is not intended
- * for numerical ranges; use {@link org.apache.lucene.search.DimensionalRangeQuery DimensionalRangeQuery} instead.
+ * for numerical ranges; use {@link org.apache.lucene.search.PointRangeQuery PointRangeQuery} instead.
*
* For example, one could find all documents
* that have terms beginning with the letters <tt>a</tt> through <tt>c</tt>.
*
* <h3>
- * {@link org.apache.lucene.search.DimensionalRangeQuery DimensionalRangeQuery}
+ * {@link org.apache.lucene.search.PointRangeQuery PointRangeQuery}
* </h3>
*
* <p>The
- * {@link org.apache.lucene.search.DimensionalRangeQuery DimensionalRangeQuery}
+ * {@link org.apache.lucene.search.PointRangeQuery PointRangeQuery}
* matches all documents that occur in a numeric range.
- * For DimensionalRangeQuery to work, you must index the values
- * using a one of the numeric fields ({@link org.apache.lucene.document.DimensionalIntField DimensionalIntField},
- * {@link org.apache.lucene.document.DimensionalLongField DimensionalLongField}, {@link org.apache.lucene.document.DimensionalFloatField DimensionalFloatField},
- * or {@link org.apache.lucene.document.DimensionalDoubleField DimensionalDoubleField}).
+ * For PointRangeQuery to work, you must index the values
+ * using a one of the numeric fields ({@link org.apache.lucene.document.IntPoint IntPoint},
+ * {@link org.apache.lucene.document.LongPoint LongPoint}, {@link org.apache.lucene.document.FloatPoint FloatPoint},
+ * or {@link org.apache.lucene.document.DoublePoint DoublePoint}).
*
* <h3>
* {@link org.apache.lucene.search.PrefixQuery PrefixQuery},
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/LegacyNumericUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/LegacyNumericUtils.java?rev=1725998&r1=1725997&r2=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/LegacyNumericUtils.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/LegacyNumericUtils.java Thu Jan 21 15:58:08 2016
@@ -19,7 +19,6 @@ package org.apache.lucene.util;
import java.io.IOException;
-import org.apache.lucene.index.DimensionalValues;
import org.apache.lucene.index.FilterLeafReader;
import org.apache.lucene.index.FilteredTermsEnum;
import org.apache.lucene.index.Terms;
@@ -60,7 +59,7 @@ import org.apache.lucene.index.TermsEnum
*
* @lucene.internal
*
- * @deprecated Please use {@link DimensionalValues} instead.
+ * @deprecated Please use {@link org.apache.lucene.index.PointValues} instead.
*
* @since 2.9, API changed non backwards-compliant in 4.0
*/
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java?rev=1725998&r1=1725997&r2=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java Thu Jan 21 15:58:08 2016
@@ -21,8 +21,8 @@ import java.io.IOException;
import java.util.Arrays;
import org.apache.lucene.codecs.CodecUtil;
-import org.apache.lucene.index.DimensionalValues.IntersectVisitor;
-import org.apache.lucene.index.DimensionalValues.Relation;
+import org.apache.lucene.index.PointValues.IntersectVisitor;
+import org.apache.lucene.index.PointValues.Relation;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.BytesRef;
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestFieldType.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestFieldType.java?rev=1725998&r1=1725997&r2=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestFieldType.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestFieldType.java Thu Jan 21 15:58:08 2016
@@ -89,7 +89,7 @@ public class TestFieldType extends Lucen
if ((method.getModifiers() & Modifier.PUBLIC) != 0 && method.getName().startsWith("set")) {
final Class<?>[] parameterTypes = method.getParameterTypes();
final Object[] args = new Object[parameterTypes.length];
- if (method.getName().equals("setDimensions")) {
+ if (method.getName().equals("setPointDimensions")) {
args[0] = 1 + random().nextInt(15);
args[1] = 1 + random().nextInt(100);
} else {
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java?rev=1725998&r1=1725997&r2=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java Thu Jan 21 15:58:08 2016
@@ -32,11 +32,11 @@ import java.util.concurrent.ConcurrentHa
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Pattern;
-import org.apache.lucene.document.DimensionalLongField;
+import org.apache.lucene.document.LongPoint;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.NumericDocValuesField;
-import org.apache.lucene.search.DimensionalRangeQuery;
+import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.ScoreDoc;
@@ -681,7 +681,7 @@ public class TestDemoParallelLeafReader
Document newDoc = new Document();
long value = Long.parseLong(oldDoc.get("text").split(" ")[1]);
newDoc.add(new NumericDocValuesField("number", value));
- newDoc.add(new DimensionalLongField("number", value));
+ newDoc.add(new LongPoint("number", value));
w.addDocument(newDoc);
}
@@ -737,7 +737,7 @@ public class TestDemoParallelLeafReader
Document newDoc = new Document();
long value = Long.parseLong(oldDoc.get("text").split(" ")[1]);
newDoc.add(new NumericDocValuesField("number_" + newSchemaGen, value));
- newDoc.add(new DimensionalLongField("number", value));
+ newDoc.add(new LongPoint("number", value));
w.addDocument(newDoc);
}
} else {
@@ -832,7 +832,7 @@ public class TestDemoParallelLeafReader
Document newDoc = new Document();
long value = Long.parseLong(oldDoc.get("text").split(" ")[1]);
newDoc.add(new NumericDocValuesField("number", newSchemaGen*value));
- newDoc.add(new DimensionalLongField("number", value));
+ newDoc.add(new LongPoint("number", value));
w.addDocument(newDoc);
}
} else {
@@ -1168,7 +1168,7 @@ public class TestDemoParallelLeafReader
checkAllNumberDVs(r);
IndexSearcher s = newSearcher(r);
testNumericDVSort(s);
- testDimensionalRangeQuery(s);
+ testPointRangeQuery(s);
} finally {
reindexer.mgr.release(r);
}
@@ -1190,7 +1190,7 @@ public class TestDemoParallelLeafReader
checkAllNumberDVs(r);
IndexSearcher s = newSearcher(r);
testNumericDVSort(s);
- testDimensionalRangeQuery(s);
+ testPointRangeQuery(s);
} finally {
reindexer.mgr.release(r);
}
@@ -1209,7 +1209,7 @@ public class TestDemoParallelLeafReader
checkAllNumberDVs(r);
IndexSearcher s = newSearcher(r);
testNumericDVSort(s);
- testDimensionalRangeQuery(s);
+ testPointRangeQuery(s);
} finally {
reindexer.mgr.release(r);
}
@@ -1261,7 +1261,7 @@ public class TestDemoParallelLeafReader
checkAllNumberDVs(r);
IndexSearcher s = newSearcher(r);
testNumericDVSort(s);
- testDimensionalRangeQuery(s);
+ testPointRangeQuery(s);
} finally {
reindexer.mgr.release(r);
}
@@ -1340,7 +1340,7 @@ public class TestDemoParallelLeafReader
}
}
- private static void testDimensionalRangeQuery(IndexSearcher s) throws IOException {
+ private static void testPointRangeQuery(IndexSearcher s) throws IOException {
NumericDocValues numbers = MultiDocValues.getNumericValues(s.getIndexReader(), "number");
for(int i=0;i<100;i++) {
// Confirm we can range search by the new indexed (numeric) field:
@@ -1352,7 +1352,7 @@ public class TestDemoParallelLeafReader
max = x;
}
- TopDocs hits = s.search(DimensionalRangeQuery.new1DLongRange("number", min, true, max, true), 100);
+ TopDocs hits = s.search(PointRangeQuery.new1DLongRange("number", min, true, max, true), 100);
for(ScoreDoc scoreDoc : hits.scoreDocs) {
long value = Long.parseLong(s.doc(scoreDoc.doc).get("text").split(" ")[1]);
assertTrue(value >= min);
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexableField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexableField.java?rev=1725998&r1=1725997&r2=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexableField.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexableField.java Thu Jan 21 15:58:08 2016
@@ -92,12 +92,12 @@ public class TestIndexableField extends
}
@Override
- public int dimensionCount() {
+ public int pointDimensionCount() {
return 0;
}
@Override
- public int dimensionNumBytes() {
+ public int pointNumBytes() {
return 0;
}
};
Copied: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPointValues.java (from r1725744, lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDimensionalValues.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPointValues.java?p2=lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPointValues.java&p1=lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDimensionalValues.java&r1=1725744&r2=1725998&rev=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDimensionalValues.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPointValues.java Thu Jan 21 15:58:08 2016
@@ -26,20 +26,20 @@ import java.util.List;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.codecs.Codec;
-import org.apache.lucene.codecs.DimensionalFormat;
-import org.apache.lucene.codecs.DimensionalReader;
-import org.apache.lucene.codecs.DimensionalWriter;
+import org.apache.lucene.codecs.PointFormat;
+import org.apache.lucene.codecs.PointReader;
+import org.apache.lucene.codecs.PointWriter;
import org.apache.lucene.codecs.FilterCodec;
-import org.apache.lucene.codecs.lucene60.Lucene60DimensionalReader;
-import org.apache.lucene.codecs.lucene60.Lucene60DimensionalWriter;
-import org.apache.lucene.document.DimensionalBinaryField;
-import org.apache.lucene.document.DimensionalIntField;
+import org.apache.lucene.codecs.lucene60.Lucene60PointReader;
+import org.apache.lucene.codecs.lucene60.Lucene60PointWriter;
+import org.apache.lucene.document.BinaryPoint;
+import org.apache.lucene.document.IntPoint;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.document.StringField;
-import org.apache.lucene.index.DimensionalValues.IntersectVisitor;
-import org.apache.lucene.index.DimensionalValues.Relation;
+import org.apache.lucene.index.PointValues.IntersectVisitor;
+import org.apache.lucene.index.PointValues.Relation;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.Bits;
@@ -52,10 +52,10 @@ import org.apache.lucene.util.TestUtil;
// TODO: factor out a BaseTestDimensionFormat
-public class TestDimensionalValues extends LuceneTestCase {
+public class TestPointValues extends LuceneTestCase {
public void testBasic() throws Exception {
Directory dir = getDirectory(20);
- // TODO: randomize codec once others support dimensional format
+ // TODO: randomize codec once others support points format
IndexWriterConfig iwc = newIndexWriterConfig();
iwc.setMergePolicy(newLogMergePolicy());
IndexWriter w = new IndexWriter(dir, iwc);
@@ -63,7 +63,7 @@ public class TestDimensionalValues exten
for(int i=0;i<20;i++) {
Document doc = new Document();
NumericUtils.intToBytes(i, point, 0);
- doc.add(new DimensionalBinaryField("dim", point));
+ doc.add(new BinaryPoint("dim", point));
w.addDocument(doc);
}
w.forceMerge(1);
@@ -71,7 +71,7 @@ public class TestDimensionalValues exten
DirectoryReader r = DirectoryReader.open(dir);
LeafReader sub = getOnlySegmentReader(r);
- DimensionalValues values = sub.getDimensionalValues();
+ PointValues values = sub.getPointValues();
// Simple test: make sure intersect can visit every doc:
BitSet seen = new BitSet();
@@ -102,7 +102,7 @@ public class TestDimensionalValues exten
for(int i=0;i<20;i++) {
Document doc = new Document();
NumericUtils.intToBytes(i, point, 0);
- doc.add(new DimensionalBinaryField("dim", point));
+ doc.add(new BinaryPoint("dim", point));
w.addDocument(doc);
if (i == 10) {
w.commit();
@@ -113,7 +113,7 @@ public class TestDimensionalValues exten
DirectoryReader r = DirectoryReader.open(dir);
LeafReader sub = getOnlySegmentReader(r);
- DimensionalValues values = sub.getDimensionalValues();
+ PointValues values = sub.getPointValues();
// Simple test: make sure intersect can visit every doc:
BitSet seen = new BitSet();
@@ -135,7 +135,7 @@ public class TestDimensionalValues exten
IOUtils.close(r, dir);
}
- public void testAllDimensionalDocsDeletedInSegment() throws Exception {
+ public void testAllPointDocsDeletedInSegment() throws Exception {
Directory dir = getDirectory(20);
IndexWriterConfig iwc = newIndexWriterConfig();
IndexWriter w = new IndexWriter(dir, iwc);
@@ -143,7 +143,7 @@ public class TestDimensionalValues exten
for(int i=0;i<10;i++) {
Document doc = new Document();
NumericUtils.intToBytes(i, point, 0);
- doc.add(new DimensionalBinaryField("dim", point));
+ doc.add(new BinaryPoint("dim", point));
doc.add(new NumericDocValuesField("id", i));
doc.add(newStringField("x", "x", Field.Store.NO));
w.addDocument(doc);
@@ -156,7 +156,7 @@ public class TestDimensionalValues exten
w.close();
DirectoryReader r = DirectoryReader.open(dir);
assertEquals(1, r.numDocs());
- DimensionalValues values = MultiDimensionalValues.get(r);
+ PointValues values = MultiPointValues.get(r);
Bits liveDocs = MultiFields.getLiveDocs(r);
NumericDocValues idValues = MultiDocValues.getNumericValues(r, "id");
@@ -186,8 +186,8 @@ public class TestDimensionalValues exten
/** Make sure we close open files, delete temp files, etc., on exception */
public void testWithExceptions() throws Exception {
int numDocs = atLeast(10000);
- int numBytesPerDim = TestUtil.nextInt(random(), 2, DimensionalValues.MAX_NUM_BYTES);
- int numDims = TestUtil.nextInt(random(), 1, DimensionalValues.MAX_DIMENSIONS);
+ int numBytesPerDim = TestUtil.nextInt(random(), 2, PointValues.MAX_NUM_BYTES);
+ int numDims = TestUtil.nextInt(random(), 1, PointValues.MAX_DIMENSIONS);
byte[][][] docValues = new byte[numDocs][][];
@@ -246,8 +246,8 @@ public class TestDimensionalValues exten
}
public void testMultiValued() throws Exception {
- int numBytesPerDim = TestUtil.nextInt(random(), 2, DimensionalValues.MAX_NUM_BYTES);
- int numDims = TestUtil.nextInt(random(), 1, DimensionalValues.MAX_DIMENSIONS);
+ int numBytesPerDim = TestUtil.nextInt(random(), 2, PointValues.MAX_NUM_BYTES);
+ int numDims = TestUtil.nextInt(random(), 1, PointValues.MAX_DIMENSIONS);
int numDocs = atLeast(1000);
List<byte[][]> docValues = new ArrayList<>();
@@ -276,8 +276,8 @@ public class TestDimensionalValues exten
}
public void testAllEqual() throws Exception {
- int numBytesPerDim = TestUtil.nextInt(random(), 2, DimensionalValues.MAX_NUM_BYTES);
- int numDims = TestUtil.nextInt(random(), 1, DimensionalValues.MAX_DIMENSIONS);
+ int numBytesPerDim = TestUtil.nextInt(random(), 2, PointValues.MAX_NUM_BYTES);
+ int numDims = TestUtil.nextInt(random(), 1, PointValues.MAX_DIMENSIONS);
int numDocs = atLeast(1000);
byte[][][] docValues = new byte[numDocs][][];
@@ -299,8 +299,8 @@ public class TestDimensionalValues exten
}
public void testOneDimEqual() throws Exception {
- int numBytesPerDim = TestUtil.nextInt(random(), 2, DimensionalValues.MAX_NUM_BYTES);
- int numDims = TestUtil.nextInt(random(), 1, DimensionalValues.MAX_DIMENSIONS);
+ int numBytesPerDim = TestUtil.nextInt(random(), 2, PointValues.MAX_NUM_BYTES);
+ int numDims = TestUtil.nextInt(random(), 1, PointValues.MAX_DIMENSIONS);
int numDocs = atLeast(1000);
int theEqualDim = random().nextInt(numDims);
@@ -326,8 +326,8 @@ public class TestDimensionalValues exten
int numDocs = atLeast(1000);
try (Directory dir = getDirectory(numDocs)) {
- int numBytesPerDim = TestUtil.nextInt(random(), 2, DimensionalValues.MAX_NUM_BYTES);
- int numDims = TestUtil.nextInt(random(), 1, DimensionalValues.MAX_DIMENSIONS);
+ int numBytesPerDim = TestUtil.nextInt(random(), 2, PointValues.MAX_NUM_BYTES);
+ int numDims = TestUtil.nextInt(random(), 1, PointValues.MAX_DIMENSIONS);
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
// We rely on docIDs not changing:
iwc.setMergePolicy(newLogMergePolicy());
@@ -350,14 +350,14 @@ public class TestDimensionalValues exten
}
docs[docID] = values;
Document doc = new Document();
- doc.add(new DimensionalBinaryField("field", bytes));
+ doc.add(new BinaryPoint("field", bytes));
w.addDocument(doc);
}
DirectoryReader r = w.getReader();
w.close();
- DimensionalValues dimValues = MultiDimensionalValues.get(r);
+ PointValues dimValues = MultiPointValues.get(r);
int iters = atLeast(100);
for(int iter=0;iter<iters;iter++) {
@@ -459,8 +459,8 @@ public class TestDimensionalValues exten
doTestRandomBinary(200000);
}
- // Suddenly add dimensional values to an existing field:
- public void testUpgradeFieldToDimensional() throws Exception {
+ // Suddenly add points to an existing field:
+ public void testUpgradeFieldToPoints() throws Exception {
Directory dir = getDirectory(1);
IndexWriterConfig iwc = newIndexWriterConfig();
IndexWriter w = new IndexWriter(dir, iwc);
@@ -471,7 +471,7 @@ public class TestDimensionalValues exten
iwc = newIndexWriterConfig();
w = new IndexWriter(dir, iwc);
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
w.close();
dir.close();
}
@@ -483,13 +483,13 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
- doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4], new byte[4]));
try {
w.addDocument(doc);
} catch (IllegalArgumentException iae) {
// expected
- assertEquals("cannot change dimension count from 1 to 2 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point dimension count from 1 to 2 for field=\"dim\"", iae.getMessage());
}
w.close();
dir.close();
@@ -500,15 +500,15 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4], new byte[4]));
try {
w.addDocument(doc);
} catch (IllegalArgumentException iae) {
// expected
- assertEquals("cannot change dimension count from 1 to 2 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point dimension count from 1 to 2 for field=\"dim\"", iae.getMessage());
}
w.close();
dir.close();
@@ -519,16 +519,16 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
w.commit();
doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4], new byte[4]));
try {
w.addDocument(doc);
} catch (IllegalArgumentException iae) {
// expected
- assertEquals("cannot change dimension count from 1 to 2 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point dimension count from 1 to 2 for field=\"dim\"", iae.getMessage());
}
w.close();
dir.close();
@@ -539,18 +539,18 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
w.close();
iwc = new IndexWriterConfig(new MockAnalyzer(random()));
w = new IndexWriter(dir, iwc);
doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4], new byte[4]));
try {
w.addDocument(doc);
} catch (IllegalArgumentException iae) {
// expected
- assertEquals("cannot change dimension count from 1 to 2 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point dimension count from 1 to 2 for field=\"dim\"", iae.getMessage());
}
w.close();
dir.close();
@@ -561,7 +561,7 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
w.close();
@@ -569,12 +569,12 @@ public class TestDimensionalValues exten
iwc = new IndexWriterConfig(new MockAnalyzer(random()));
w = new IndexWriter(dir2, iwc);
doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4], new byte[4]));
w.addDocument(doc);
try {
w.addIndexes(new Directory[] {dir});
} catch (IllegalArgumentException iae) {
- assertEquals("cannot change dimension count from 2 to 1 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point dimension count from 2 to 1 for field=\"dim\"", iae.getMessage());
}
IOUtils.close(w, dir, dir2);
}
@@ -584,7 +584,7 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
w.close();
@@ -592,13 +592,13 @@ public class TestDimensionalValues exten
iwc = new IndexWriterConfig(new MockAnalyzer(random()));
w = new IndexWriter(dir2, iwc);
doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4], new byte[4]));
w.addDocument(doc);
DirectoryReader r = DirectoryReader.open(dir);
try {
w.addIndexes(new CodecReader[] {getOnlySegmentReader(r)});
} catch (IllegalArgumentException iae) {
- assertEquals("cannot change dimension count from 2 to 1 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point dimension count from 2 to 1 for field=\"dim\"", iae.getMessage());
}
IOUtils.close(r, w, dir, dir2);
}
@@ -608,7 +608,7 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
w.close();
@@ -616,13 +616,13 @@ public class TestDimensionalValues exten
iwc = new IndexWriterConfig(new MockAnalyzer(random()));
w = new IndexWriter(dir2, iwc);
doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4], new byte[4]));
w.addDocument(doc);
DirectoryReader r = DirectoryReader.open(dir);
try {
TestUtil.addIndexesSlowly(w, r);
} catch (IllegalArgumentException iae) {
- assertEquals("cannot change dimension count from 2 to 1 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point dimension count from 2 to 1 for field=\"dim\"", iae.getMessage());
}
IOUtils.close(r, w, dir, dir2);
}
@@ -632,13 +632,13 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
- doc.add(new DimensionalBinaryField("dim", new byte[6]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[6]));
try {
w.addDocument(doc);
} catch (IllegalArgumentException iae) {
// expected
- assertEquals("cannot change dimension numBytes from 4 to 6 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point numBytes from 4 to 6 for field=\"dim\"", iae.getMessage());
}
w.close();
dir.close();
@@ -649,15 +649,15 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[6]));
+ doc.add(new BinaryPoint("dim", new byte[6]));
try {
w.addDocument(doc);
} catch (IllegalArgumentException iae) {
// expected
- assertEquals("cannot change dimension numBytes from 4 to 6 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point numBytes from 4 to 6 for field=\"dim\"", iae.getMessage());
}
w.close();
dir.close();
@@ -668,16 +668,16 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
w.commit();
doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[6]));
+ doc.add(new BinaryPoint("dim", new byte[6]));
try {
w.addDocument(doc);
} catch (IllegalArgumentException iae) {
// expected
- assertEquals("cannot change dimension numBytes from 4 to 6 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point numBytes from 4 to 6 for field=\"dim\"", iae.getMessage());
}
w.close();
dir.close();
@@ -688,18 +688,18 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
w.close();
iwc = new IndexWriterConfig(new MockAnalyzer(random()));
w = new IndexWriter(dir, iwc);
doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[6]));
+ doc.add(new BinaryPoint("dim", new byte[6]));
try {
w.addDocument(doc);
} catch (IllegalArgumentException iae) {
// expected
- assertEquals("cannot change dimension numBytes from 4 to 6 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point numBytes from 4 to 6 for field=\"dim\"", iae.getMessage());
}
w.close();
dir.close();
@@ -710,7 +710,7 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
w.close();
@@ -718,12 +718,12 @@ public class TestDimensionalValues exten
iwc = new IndexWriterConfig(new MockAnalyzer(random()));
w = new IndexWriter(dir2, iwc);
doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[6]));
+ doc.add(new BinaryPoint("dim", new byte[6]));
w.addDocument(doc);
try {
w.addIndexes(new Directory[] {dir});
} catch (IllegalArgumentException iae) {
- assertEquals("cannot change dimension numBytes from 6 to 4 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point numBytes from 6 to 4 for field=\"dim\"", iae.getMessage());
}
IOUtils.close(w, dir, dir2);
}
@@ -733,7 +733,7 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
w.close();
@@ -741,13 +741,13 @@ public class TestDimensionalValues exten
iwc = new IndexWriterConfig(new MockAnalyzer(random()));
w = new IndexWriter(dir2, iwc);
doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[6]));
+ doc.add(new BinaryPoint("dim", new byte[6]));
w.addDocument(doc);
DirectoryReader r = DirectoryReader.open(dir);
try {
w.addIndexes(new CodecReader[] {getOnlySegmentReader(r)});
} catch (IllegalArgumentException iae) {
- assertEquals("cannot change dimension numBytes from 6 to 4 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point numBytes from 6 to 4 for field=\"dim\"", iae.getMessage());
}
IOUtils.close(r, w, dir, dir2);
}
@@ -757,7 +757,7 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[4]));
+ doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
w.close();
@@ -765,13 +765,13 @@ public class TestDimensionalValues exten
iwc = new IndexWriterConfig(new MockAnalyzer(random()));
w = new IndexWriter(dir2, iwc);
doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[6]));
+ doc.add(new BinaryPoint("dim", new byte[6]));
w.addDocument(doc);
DirectoryReader r = DirectoryReader.open(dir);
try {
TestUtil.addIndexesSlowly(w, r);
} catch (IllegalArgumentException iae) {
- assertEquals("cannot change dimension numBytes from 6 to 4 for field=\"dim\"", iae.getMessage());
+ assertEquals("cannot change point numBytes from 6 to 4 for field=\"dim\"", iae.getMessage());
}
IOUtils.close(r, w, dir, dir2);
}
@@ -781,7 +781,7 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("dim", new byte[DimensionalValues.MAX_NUM_BYTES+1]));
+ doc.add(new BinaryPoint("dim", new byte[PointValues.MAX_NUM_BYTES+1]));
try {
w.addDocument(doc);
fail("did not hit exception");
@@ -789,7 +789,7 @@ public class TestDimensionalValues exten
// expected
}
doc = new Document();
- doc.add(new DimensionalIntField("dim", 17));
+ doc.add(new IntPoint("dim", 17));
w.addDocument(doc);
w.close();
dir.close();
@@ -800,11 +800,11 @@ public class TestDimensionalValues exten
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
- byte[][] values = new byte[DimensionalValues.MAX_DIMENSIONS+1][];
+ byte[][] values = new byte[PointValues.MAX_DIMENSIONS+1][];
for(int i=0;i<values.length;i++) {
values[i] = new byte[4];
}
- doc.add(new DimensionalBinaryField("dim", values));
+ doc.add(new BinaryPoint("dim", values));
try {
w.addDocument(doc);
fail("did not hit exception");
@@ -812,7 +812,7 @@ public class TestDimensionalValues exten
// expected
}
doc = new Document();
- doc.add(new DimensionalIntField("dim", 17));
+ doc.add(new IntPoint("dim", 17));
w.addDocument(doc);
w.close();
dir.close();
@@ -820,8 +820,8 @@ public class TestDimensionalValues exten
private void doTestRandomBinary(int count) throws Exception {
int numDocs = TestUtil.nextInt(random(), count, count*2);
- int numBytesPerDim = TestUtil.nextInt(random(), 2, DimensionalValues.MAX_NUM_BYTES);
- int numDims = TestUtil.nextInt(random(), 1, DimensionalValues.MAX_DIMENSIONS);
+ int numBytesPerDim = TestUtil.nextInt(random(), 2, PointValues.MAX_NUM_BYTES);
+ int numDims = TestUtil.nextInt(random(), 1, PointValues.MAX_DIMENSIONS);
byte[][][] docValues = new byte[numDocs][][];
@@ -843,21 +843,21 @@ public class TestDimensionalValues exten
int maxPointsInLeafNode = TestUtil.nextInt(random(), 50, 500);
double maxMBSortInHeap = 0.1 + (3*random().nextDouble());
if (VERBOSE) {
- System.out.println("TEST: using Lucene60DimensionalFormat with maxPointsInLeafNode=" + maxPointsInLeafNode + " and maxMBSortInHeap=" + maxMBSortInHeap);
+ System.out.println("TEST: using Lucene60PointFormat with maxPointsInLeafNode=" + maxPointsInLeafNode + " and maxMBSortInHeap=" + maxMBSortInHeap);
}
return new FilterCodec("Lucene60", Codec.getDefault()) {
@Override
- public DimensionalFormat dimensionalFormat() {
- return new DimensionalFormat() {
+ public PointFormat pointFormat() {
+ return new PointFormat() {
@Override
- public DimensionalWriter fieldsWriter(SegmentWriteState writeState) throws IOException {
- return new Lucene60DimensionalWriter(writeState, maxPointsInLeafNode, maxMBSortInHeap);
+ public PointWriter fieldsWriter(SegmentWriteState writeState) throws IOException {
+ return new Lucene60PointWriter(writeState, maxPointsInLeafNode, maxMBSortInHeap);
}
@Override
- public DimensionalReader fieldsReader(SegmentReadState readState) throws IOException {
- return new Lucene60DimensionalReader(readState);
+ public PointReader fieldsReader(SegmentReadState readState) throws IOException {
+ return new Lucene60PointReader(readState);
}
};
}
@@ -931,7 +931,7 @@ public class TestDimensionalValues exten
}
// 20% of the time we add into a separate directory, then at some point use
- // addIndexes to bring the indexed dimensional values to the main directory:
+ // addIndexes to bring the indexed point values to the main directory:
Directory saveDir;
RandomIndexWriter saveW;
int addIndexesAt;
@@ -981,7 +981,7 @@ public class TestDimensionalValues exten
doc = new Document();
doc.add(new NumericDocValuesField("id", id));
}
- doc.add(new DimensionalBinaryField("field", docValues[ord]));
+ doc.add(new BinaryPoint("field", docValues[ord]));
lastID = id;
if (random().nextInt(30) == 17) {
@@ -999,7 +999,7 @@ public class TestDimensionalValues exten
if (random().nextInt(30) == 17) {
// randomly index some documents with this field, but we will delete them:
Document xdoc = new Document();
- xdoc.add(new DimensionalBinaryField("field", docValues[ord]));
+ xdoc.add(new BinaryPoint("field", docValues[ord]));
xdoc.add(new StringField("nukeme", "yes", Field.Store.NO));
if (useRealWriter) {
w.w.addDocument(xdoc);
@@ -1051,7 +1051,7 @@ public class TestDimensionalValues exten
System.out.println("TEST: reader=" + r);
}
- DimensionalValues dimValues = MultiDimensionalValues.get(r);
+ PointValues dimValues = MultiPointValues.get(r);
if (VERBOSE) {
System.out.println(" dimValues=" + dimValues);
}
@@ -1102,7 +1102,7 @@ public class TestDimensionalValues exten
final BitSet hits = new BitSet();
- dimValues.intersect("field", new DimensionalValues.IntersectVisitor() {
+ dimValues.intersect("field", new PointValues.IntersectVisitor() {
@Override
public void visit(int docID) {
if (liveDocs == null || liveDocs.get(docID)) {
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/BaseTestRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/BaseTestRangeFilter.java?rev=1725998&r1=1725997&r2=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/BaseTestRangeFilter.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/BaseTestRangeFilter.java Thu Jan 21 15:58:08 2016
@@ -21,16 +21,12 @@ import java.io.IOException;
import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.DimensionalDoubleField;
-import org.apache.lucene.document.DimensionalFloatField;
-import org.apache.lucene.document.DimensionalIntField;
-import org.apache.lucene.document.DimensionalLongField;
+import org.apache.lucene.document.DoublePoint;
+import org.apache.lucene.document.FloatPoint;
+import org.apache.lucene.document.IntPoint;
+import org.apache.lucene.document.LongPoint;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import org.apache.lucene.document.LegacyDoubleField;
-import org.apache.lucene.document.LegacyFloatField;
-import org.apache.lucene.document.LegacyIntField;
-import org.apache.lucene.document.LegacyLongField;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.document.SortedDocValuesField;
import org.apache.lucene.index.IndexReader;
@@ -127,13 +123,13 @@ public class BaseTestRangeFilter extends
Document doc = new Document();
Field idField = newStringField(random, "id", "", Field.Store.YES);
Field idDVField = new SortedDocValuesField("id", new BytesRef());
- Field intIdField = new DimensionalIntField("id_int", 0);
+ Field intIdField = new IntPoint("id_int", 0);
Field intDVField = new NumericDocValuesField("id_int", 0);
- Field floatIdField = new DimensionalFloatField("id_float", 0);
+ Field floatIdField = new FloatPoint("id_float", 0);
Field floatDVField = new NumericDocValuesField("id_float", 0);
- Field longIdField = new DimensionalLongField("id_long", 0);
+ Field longIdField = new LongPoint("id_long", 0);
Field longDVField = new NumericDocValuesField("id_long", 0);
- Field doubleIdField = new DimensionalDoubleField("id_double", 0);
+ Field doubleIdField = new DoublePoint("id_double", 0);
Field doubleDVField = new NumericDocValuesField("id_double", 0);
Field randField = newStringField(random, "rand", "", Field.Store.YES);
Field randDVField = new SortedDocValuesField("rand", new BytesRef());
Copied: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java (from r1725744, lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestDimensionalRangeQuery.java)
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java?p2=lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java&p1=lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestDimensionalRangeQuery.java&r1=1725744&r2=1725998&rev=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestDimensionalRangeQuery.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java Thu Jan 21 15:58:08 2016
@@ -27,26 +27,30 @@ import java.util.concurrent.CountDownLat
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.lucene.codecs.Codec;
-import org.apache.lucene.codecs.DimensionalFormat;
-import org.apache.lucene.codecs.DimensionalReader;
-import org.apache.lucene.codecs.DimensionalWriter;
import org.apache.lucene.codecs.FilterCodec;
-import org.apache.lucene.codecs.lucene60.Lucene60DimensionalReader;
-import org.apache.lucene.codecs.lucene60.Lucene60DimensionalWriter;
-import org.apache.lucene.document.DimensionalBinaryField;
-import org.apache.lucene.document.DimensionalLongField;
+import org.apache.lucene.codecs.PointFormat;
+import org.apache.lucene.codecs.PointReader;
+import org.apache.lucene.codecs.PointWriter;
+import org.apache.lucene.codecs.lucene60.Lucene60PointReader;
+import org.apache.lucene.codecs.lucene60.Lucene60PointWriter;
+import org.apache.lucene.document.BinaryPoint;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.DoublePoint;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FloatPoint;
+import org.apache.lucene.document.IntPoint;
+import org.apache.lucene.document.LongPoint;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.document.SortedNumericDocValuesField;
import org.apache.lucene.document.StringField;
-import org.apache.lucene.index.DimensionalValues;
+import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.MultiDocValues;
import org.apache.lucene.index.NumericDocValues;
+import org.apache.lucene.index.PointValues;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.SegmentReadState;
import org.apache.lucene.index.SegmentWriteState;
@@ -60,7 +64,7 @@ import org.apache.lucene.util.NumericUti
import org.apache.lucene.util.TestUtil;
import org.junit.BeforeClass;
-public class TestDimensionalRangeQuery extends LuceneTestCase {
+public class TestPointQueries extends LuceneTestCase {
// Controls what range of values we randomly generate, so we sometimes test narrow ranges:
static long valueMid;
@@ -225,10 +229,10 @@ public class TestDimensionalRangeQuery e
}
if (missing.get(id) == false) {
- doc.add(new DimensionalLongField("sn_value", values[id]));
+ doc.add(new LongPoint("sn_value", values[id]));
byte[] bytes = new byte[8];
NumericUtils.longToBytes(values[id], bytes, 0);
- doc.add(new DimensionalBinaryField("ss_value", bytes));
+ doc.add(new BinaryPoint("ss_value", bytes));
}
}
@@ -301,7 +305,7 @@ public class TestDimensionalRangeQuery e
}
if (random().nextBoolean()) {
- query = DimensionalRangeQuery.new1DLongRange("sn_value", lower, includeLower, upper, includeUpper);
+ query = PointRangeQuery.new1DLongRange("sn_value", lower, includeLower, upper, includeUpper);
} else {
byte[] lowerBytes;
if (lower == null) {
@@ -317,7 +321,7 @@ public class TestDimensionalRangeQuery e
upperBytes = new byte[8];
NumericUtils.longToBytes(upper, upperBytes, 0);
}
- query = DimensionalRangeQuery.new1DBinaryRange("ss_value", lowerBytes, includeLower, upperBytes, includeUpper);
+ query = PointRangeQuery.new1DBinaryRange("ss_value", lowerBytes, includeLower, upperBytes, includeUpper);
}
if (VERBOSE) {
@@ -386,8 +390,8 @@ public class TestDimensionalRangeQuery e
private void doTestRandomBinary(int count) throws Exception {
int numValues = TestUtil.nextInt(random(), count, count*2);
- int numBytesPerDim = TestUtil.nextInt(random(), 2, DimensionalValues.MAX_NUM_BYTES);
- int numDims = TestUtil.nextInt(random(), 1, DimensionalValues.MAX_DIMENSIONS);
+ int numBytesPerDim = TestUtil.nextInt(random(), 2, PointValues.MAX_NUM_BYTES);
+ int numDims = TestUtil.nextInt(random(), 1, PointValues.MAX_DIMENSIONS);
int sameValuePct = random().nextInt(100);
@@ -435,7 +439,7 @@ public class TestDimensionalRangeQuery e
Directory dir;
if (docValues.length > 100000) {
- dir = noVirusChecker(newFSDirectory(createTempDir("TestDimensionalRangeQuery")));
+ dir = noVirusChecker(newFSDirectory(createTempDir("TestPointRangeQuery")));
} else {
dir = getDirectory();
}
@@ -489,7 +493,7 @@ public class TestDimensionalRangeQuery e
}
if (missing.get(id) == false) {
- doc.add(new DimensionalBinaryField("value", docValues[ord]));
+ doc.add(new BinaryPoint("value", docValues[ord]));
if (VERBOSE) {
System.out.println("id=" + id);
for(int dim=0;dim<numDims;dim++) {
@@ -583,7 +587,7 @@ public class TestDimensionalRangeQuery e
}
}
- Query query = new DimensionalRangeQuery("value", lower, includeLower, upper, includeUpper);
+ Query query = new PointRangeQuery("value", lower, includeLower, upper, includeUpper);
if (VERBOSE) {
System.out.println(Thread.currentThread().getName() + ": using query: " + query);
@@ -722,20 +726,20 @@ public class TestDimensionalRangeQuery e
iwc.setCodec(getCodec());
RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalLongField("value", Long.MIN_VALUE));
+ doc.add(new LongPoint("value", Long.MIN_VALUE));
w.addDocument(doc);
doc = new Document();
- doc.add(new DimensionalLongField("value", Long.MAX_VALUE));
+ doc.add(new LongPoint("value", Long.MAX_VALUE));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
- assertEquals(1, s.count(DimensionalRangeQuery.new1DLongRange("value", Long.MIN_VALUE, true, 0L, true)));
- assertEquals(1, s.count(DimensionalRangeQuery.new1DLongRange("value", 0L, true, Long.MAX_VALUE, true)));
- assertEquals(2, s.count(DimensionalRangeQuery.new1DLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, true)));
+ assertEquals(1, s.count(PointRangeQuery.new1DLongRange("value", Long.MIN_VALUE, true, 0L, true)));
+ assertEquals(1, s.count(PointRangeQuery.new1DLongRange("value", 0L, true, Long.MAX_VALUE, true)));
+ assertEquals(2, s.count(PointRangeQuery.new1DLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, true)));
IOUtils.close(r, w, dir);
}
@@ -761,61 +765,61 @@ public class TestDimensionalRangeQuery e
iwc.setCodec(getCodec());
RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("value", toUTF8("abc")));
+ doc.add(new BinaryPoint("value", toUTF8("abc")));
w.addDocument(doc);
doc = new Document();
- doc.add(new DimensionalBinaryField("value", toUTF8("def")));
+ doc.add(new BinaryPoint("value", toUTF8("def")));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
- assertEquals(1, s.count(DimensionalRangeQuery.new1DBinaryRange("value",
- toUTF8("aaa"),
- true,
- toUTF8("bbb"),
- true)));
- assertEquals(1, s.count(DimensionalRangeQuery.new1DBinaryRange("value",
- toUTF8("c", 3),
- true,
- toUTF8("e", 3),
- true)));
- assertEquals(2, s.count(DimensionalRangeQuery.new1DBinaryRange("value",
- toUTF8("a", 3),
- true,
- toUTF8("z", 3),
- true)));
- assertEquals(1, s.count(DimensionalRangeQuery.new1DBinaryRange("value",
- null,
- true,
- toUTF8("abc"),
- true)));
- assertEquals(1, s.count(DimensionalRangeQuery.new1DBinaryRange("value",
- toUTF8("a", 3),
- true,
- toUTF8("abc"),
- true)));
- assertEquals(0, s.count(DimensionalRangeQuery.new1DBinaryRange("value",
- toUTF8("a", 3),
- true,
- toUTF8("abc"),
- false)));
- assertEquals(1, s.count(DimensionalRangeQuery.new1DBinaryRange("value",
- toUTF8("def"),
- true,
- null,
- false)));
- assertEquals(1, s.count(DimensionalRangeQuery.new1DBinaryRange("value",
- toUTF8(("def")),
- true,
- toUTF8("z", 3),
- true)));
- assertEquals(0, s.count(DimensionalRangeQuery.new1DBinaryRange("value",
- toUTF8("def"),
- false,
- toUTF8("z", 3),
- true)));
+ assertEquals(1, s.count(PointRangeQuery.new1DBinaryRange("value",
+ toUTF8("aaa"),
+ true,
+ toUTF8("bbb"),
+ true)));
+ assertEquals(1, s.count(PointRangeQuery.new1DBinaryRange("value",
+ toUTF8("c", 3),
+ true,
+ toUTF8("e", 3),
+ true)));
+ assertEquals(2, s.count(PointRangeQuery.new1DBinaryRange("value",
+ toUTF8("a", 3),
+ true,
+ toUTF8("z", 3),
+ true)));
+ assertEquals(1, s.count(PointRangeQuery.new1DBinaryRange("value",
+ null,
+ true,
+ toUTF8("abc"),
+ true)));
+ assertEquals(1, s.count(PointRangeQuery.new1DBinaryRange("value",
+ toUTF8("a", 3),
+ true,
+ toUTF8("abc"),
+ true)));
+ assertEquals(0, s.count(PointRangeQuery.new1DBinaryRange("value",
+ toUTF8("a", 3),
+ true,
+ toUTF8("abc"),
+ false)));
+ assertEquals(1, s.count(PointRangeQuery.new1DBinaryRange("value",
+ toUTF8("def"),
+ true,
+ null,
+ false)));
+ assertEquals(1, s.count(PointRangeQuery.new1DBinaryRange("value",
+ toUTF8(("def")),
+ true,
+ toUTF8("z", 3),
+ true)));
+ assertEquals(0, s.count(PointRangeQuery.new1DBinaryRange("value",
+ toUTF8("def"),
+ false,
+ toUTF8("z", 3),
+ true)));
IOUtils.close(r, w, dir);
}
@@ -826,22 +830,22 @@ public class TestDimensionalRangeQuery e
iwc.setCodec(getCodec());
RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalLongField("value", Long.MIN_VALUE));
+ doc.add(new LongPoint("value", Long.MIN_VALUE));
w.addDocument(doc);
doc = new Document();
- doc.add(new DimensionalLongField("value", Long.MAX_VALUE));
+ doc.add(new LongPoint("value", Long.MAX_VALUE));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
- assertEquals(2, s.count(DimensionalRangeQuery.new1DLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, true)));
- assertEquals(1, s.count(DimensionalRangeQuery.new1DLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, false)));
- assertEquals(1, s.count(DimensionalRangeQuery.new1DLongRange("value", Long.MIN_VALUE, false, Long.MAX_VALUE, true)));
- assertEquals(0, s.count(DimensionalRangeQuery.new1DLongRange("value", Long.MIN_VALUE, false, Long.MAX_VALUE, false)));
+ assertEquals(2, s.count(PointRangeQuery.new1DLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, true)));
+ assertEquals(1, s.count(PointRangeQuery.new1DLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, false)));
+ assertEquals(1, s.count(PointRangeQuery.new1DLongRange("value", Long.MIN_VALUE, false, Long.MAX_VALUE, true)));
+ assertEquals(0, s.count(PointRangeQuery.new1DLongRange("value", Long.MIN_VALUE, false, Long.MAX_VALUE, false)));
- assertEquals(2, s.count(DimensionalRangeQuery.new1DBinaryRange("value", (byte[]) null, true, null, true)));
+ assertEquals(2, s.count(PointRangeQuery.new1DBinaryRange("value", (byte[]) null, true, null, true)));
IOUtils.close(r, w, dir);
}
@@ -852,10 +856,10 @@ public class TestDimensionalRangeQuery e
iwc.setCodec(getCodec());
RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalLongField("value", Long.MIN_VALUE));
+ doc.add(new LongPoint("value", Long.MIN_VALUE));
w.addDocument(doc);
doc = new Document();
- doc.add(new DimensionalLongField("value", Long.MAX_VALUE));
+ doc.add(new LongPoint("value", Long.MAX_VALUE));
w.addDocument(doc);
IndexReader r = w.getReader();
@@ -863,12 +867,12 @@ public class TestDimensionalRangeQuery e
// We can't wrap with "exotic" readers because the query must see the RangeTreeDVFormat:
IndexSearcher s = newSearcher(r, false);
- assertEquals(2, s.count(DimensionalRangeQuery.new1DLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, true)));
- assertEquals(1, s.count(DimensionalRangeQuery.new1DLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, false)));
- assertEquals(1, s.count(DimensionalRangeQuery.new1DLongRange("value", Long.MIN_VALUE, false, Long.MAX_VALUE, true)));
- assertEquals(0, s.count(DimensionalRangeQuery.new1DLongRange("value", Long.MIN_VALUE, false, Long.MAX_VALUE, false)));
+ assertEquals(2, s.count(PointRangeQuery.new1DLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, true)));
+ assertEquals(1, s.count(PointRangeQuery.new1DLongRange("value", Long.MIN_VALUE, true, Long.MAX_VALUE, false)));
+ assertEquals(1, s.count(PointRangeQuery.new1DLongRange("value", Long.MIN_VALUE, false, Long.MAX_VALUE, true)));
+ assertEquals(0, s.count(PointRangeQuery.new1DLongRange("value", Long.MIN_VALUE, false, Long.MAX_VALUE, false)));
- assertEquals(2, s.count(DimensionalRangeQuery.new1DLongRange("value", (Long) null, true, null, true)));
+ assertEquals(2, s.count(PointRangeQuery.new1DLongRange("value", (Long) null, true, null, true)));
IOUtils.close(r, w, dir);
}
@@ -879,18 +883,18 @@ public class TestDimensionalRangeQuery e
iwc.setCodec(getCodec());
RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalBinaryField("value", toUTF8("a")));
+ doc.add(new BinaryPoint("value", toUTF8("a")));
w.addDocument(doc);
doc = new Document();
- doc.add(new DimensionalBinaryField("value", toUTF8("z")));
+ doc.add(new BinaryPoint("value", toUTF8("z")));
w.addDocument(doc);
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
- assertEquals(0, s.count(DimensionalRangeQuery.new1DBinaryRange("value", toUTF8("m"), true, toUTF8("n"), false)));
+ assertEquals(0, s.count(PointRangeQuery.new1DBinaryRange("value", toUTF8("m"), true, toUTF8("n"), false)));
- assertEquals(2, s.count(DimensionalRangeQuery.new1DBinaryRange("value", (byte[]) null, true, null, true)));
+ assertEquals(2, s.count(PointRangeQuery.new1DBinaryRange("value", (byte[]) null, true, null, true)));
IOUtils.close(r, w, dir);
}
@@ -910,7 +914,7 @@ public class TestDimensionalRangeQuery e
IndexReader r = w.getReader();
IndexSearcher s = new IndexSearcher(r);
- assertEquals(0, s.count(DimensionalRangeQuery.new1DLongRange("value", 17L, true, 13L, false)));
+ assertEquals(0, s.count(PointRangeQuery.new1DLongRange("value", 17L, true, 13L, false)));
IOUtils.close(r, w, dir);
}
@@ -925,7 +929,7 @@ public class TestDimensionalRangeQuery e
IndexReader r = w.getReader();
IndexSearcher s = newSearcher(r);
- assertEquals(0, s.count(DimensionalRangeQuery.new1DLongRange("value", 17L, true, 13L, false)));
+ assertEquals(0, s.count(PointRangeQuery.new1DLongRange("value", 17L, true, 13L, false)));
IOUtils.close(r, w, dir);
}
@@ -936,7 +940,7 @@ public class TestDimensionalRangeQuery e
iwc.setCodec(getCodec());
RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalLongField("value", Long.MIN_VALUE));
+ doc.add(new LongPoint("value", Long.MIN_VALUE));
w.addDocument(doc);
IndexReader r = w.getReader();
@@ -945,7 +949,7 @@ public class TestDimensionalRangeQuery e
IndexSearcher s = new IndexSearcher(r);
byte[][] point = new byte[2][];
try {
- s.count(new DimensionalRangeQuery("value", point, new boolean[] {true, true}, point, new boolean[] {true, true}));
+ s.count(new PointRangeQuery("value", point, new boolean[] {true, true}, point, new boolean[] {true, true}));
} catch (IllegalArgumentException iae) {
assertEquals("field=\"value\" was indexed with numDims=1 but this query has numDims=2", iae.getMessage());
}
@@ -959,7 +963,7 @@ public class TestDimensionalRangeQuery e
iwc.setCodec(getCodec());
RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
Document doc = new Document();
- doc.add(new DimensionalLongField("value", Long.MIN_VALUE));
+ doc.add(new LongPoint("value", Long.MIN_VALUE));
w.addDocument(doc);
IndexReader r = w.getReader();
@@ -969,7 +973,7 @@ public class TestDimensionalRangeQuery e
byte[][] point = new byte[1][];
point[0] = new byte[10];
try {
- s.count(new DimensionalRangeQuery("value", point, new boolean[] {true}, point, new boolean[] {true}));
+ s.count(new PointRangeQuery("value", point, new boolean[] {true}, point, new boolean[] {true}));
} catch (IllegalArgumentException iae) {
assertEquals("field=\"value\" was indexed with bytesPerDim=8 but this query has bytesPerDim=10", iae.getMessage());
}
@@ -977,14 +981,14 @@ public class TestDimensionalRangeQuery e
IOUtils.close(r, w, dir);
}
- public void testAllDimensionalDocsWereDeletedAndThenMergedAgain() throws Exception {
+ public void testAllPointDocsWereDeletedAndThenMergedAgain() throws Exception {
Directory dir = getDirectory();
IndexWriterConfig iwc = newIndexWriterConfig();
iwc.setCodec(getCodec());
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
doc.add(new StringField("id", "0", Field.Store.NO));
- doc.add(new DimensionalLongField("value", 0L));
+ doc.add(new LongPoint("value", 0L));
w.addDocument(doc);
// Add document that won't be deleted to avoid IW dropping
@@ -995,7 +999,7 @@ public class TestDimensionalRangeQuery e
// Need another segment so we invoke BKDWriter.merge
doc = new Document();
doc.add(new StringField("id", "0", Field.Store.NO));
- doc.add(new DimensionalLongField("value", 0L));
+ doc.add(new LongPoint("value", 0L));
w.addDocument(doc);
w.addDocument(new Document());
@@ -1004,7 +1008,7 @@ public class TestDimensionalRangeQuery e
doc = new Document();
doc.add(new StringField("id", "0", Field.Store.NO));
- doc.add(new DimensionalLongField("value", 0L));
+ doc.add(new LongPoint("value", 0L));
w.addDocument(doc);
w.addDocument(new Document());
@@ -1030,21 +1034,21 @@ public class TestDimensionalRangeQuery e
int maxPointsInLeafNode = TestUtil.nextInt(random(), 16, 2048);
double maxMBSortInHeap = 3.0 + (3*random().nextDouble());
if (VERBOSE) {
- System.out.println("TEST: using Lucene60DimensionalFormat with maxPointsInLeafNode=" + maxPointsInLeafNode + " and maxMBSortInHeap=" + maxMBSortInHeap);
+ System.out.println("TEST: using Lucene60PointFormat with maxPointsInLeafNode=" + maxPointsInLeafNode + " and maxMBSortInHeap=" + maxMBSortInHeap);
}
return new FilterCodec("Lucene60", Codec.getDefault()) {
@Override
- public DimensionalFormat dimensionalFormat() {
- return new DimensionalFormat() {
+ public PointFormat pointFormat() {
+ return new PointFormat() {
@Override
- public DimensionalWriter fieldsWriter(SegmentWriteState writeState) throws IOException {
- return new Lucene60DimensionalWriter(writeState, maxPointsInLeafNode, maxMBSortInHeap);
+ public PointWriter fieldsWriter(SegmentWriteState writeState) throws IOException {
+ return new Lucene60PointWriter(writeState, maxPointsInLeafNode, maxMBSortInHeap);
}
@Override
- public DimensionalReader fieldsReader(SegmentReadState readState) throws IOException {
- return new Lucene60DimensionalReader(readState);
+ public PointReader fieldsReader(SegmentReadState readState) throws IOException {
+ return new Lucene60PointReader(readState);
}
};
}
@@ -1053,4 +1057,44 @@ public class TestDimensionalRangeQuery e
return Codec.getDefault();
}
}
+
+ public void testExactPointQuery() throws Exception {
+ Directory dir = getDirectory();
+ IndexWriterConfig iwc = newIndexWriterConfig();
+ iwc.setCodec(getCodec());
+ IndexWriter w = new IndexWriter(dir, iwc);
+
+ Document doc = new Document();
+ doc.add(new LongPoint("long", 5L));
+ w.addDocument(doc);
+
+ doc = new Document();
+ doc.add(new IntPoint("int", 42));
+ w.addDocument(doc);
+
+ doc = new Document();
+ doc.add(new FloatPoint("float", 2.0f));
+ w.addDocument(doc);
+
+ doc = new Document();
+ doc.add(new DoublePoint("double", 1.0));
+ w.addDocument(doc);
+
+ IndexReader r = DirectoryReader.open(w);
+ IndexSearcher s = newSearcher(r);
+ assertEquals(1, s.count(ExactPointQuery.new1DIntExact("int", 42)));
+ assertEquals(0, s.count(ExactPointQuery.new1DIntExact("int", 41)));
+
+ assertEquals(1, s.count(ExactPointQuery.new1DLongExact("long", 5L)));
+ assertEquals(0, s.count(ExactPointQuery.new1DLongExact("long", -1L)));
+
+ assertEquals(1, s.count(ExactPointQuery.new1DFloatExact("float", 2.0f)));
+ assertEquals(0, s.count(ExactPointQuery.new1DFloatExact("float", 1.0f)));
+
+ assertEquals(1, s.count(ExactPointQuery.new1DDoubleExact("double", 1.0)));
+ assertEquals(0, s.count(ExactPointQuery.new1DDoubleExact("double", 2.0)));
+ w.close();
+ r.close();
+ dir.close();
+ }
}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestUsageTrackingFilterCachingPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestUsageTrackingFilterCachingPolicy.java?rev=1725998&r1=1725997&r2=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestUsageTrackingFilterCachingPolicy.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestUsageTrackingFilterCachingPolicy.java Thu Jan 21 15:58:08 2016
@@ -26,7 +26,7 @@ public class TestUsageTrackingFilterCach
public void testCostlyFilter() {
assertTrue(UsageTrackingQueryCachingPolicy.isCostly(new PrefixQuery(new Term("field", "prefix"))));
- assertTrue(UsageTrackingQueryCachingPolicy.isCostly(DimensionalRangeQuery.new1DIntRange("intField", 1, true, 1000, true)));
+ assertTrue(UsageTrackingQueryCachingPolicy.isCostly(PointRangeQuery.new1DIntRange("intField", 1, true, 1000, true)));
assertFalse(UsageTrackingQueryCachingPolicy.isCostly(new TermQuery(new Term("field", "value"))));
}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java?rev=1725998&r1=1725997&r2=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/bkd/TestBKD.java Thu Jan 21 15:58:08 2016
@@ -24,8 +24,8 @@ import java.util.Arrays;
import java.util.BitSet;
import java.util.List;
-import org.apache.lucene.index.DimensionalValues.IntersectVisitor;
-import org.apache.lucene.index.DimensionalValues.Relation;
+import org.apache.lucene.index.PointValues.IntersectVisitor;
+import org.apache.lucene.index.PointValues.Relation;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
Modified: lucene/dev/trunk/lucene/demo/src/java/org/apache/lucene/demo/IndexFiles.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/demo/src/java/org/apache/lucene/demo/IndexFiles.java?rev=1725998&r1=1725997&r2=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/demo/src/java/org/apache/lucene/demo/IndexFiles.java (original)
+++ lucene/dev/trunk/lucene/demo/src/java/org/apache/lucene/demo/IndexFiles.java Thu Jan 21 15:58:08 2016
@@ -32,7 +32,7 @@ import java.util.Date;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.document.DimensionalLongField;
+import org.apache.lucene.document.LongPoint;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
@@ -178,13 +178,13 @@ public class IndexFiles {
doc.add(pathField);
// Add the last modified date of the file a field named "modified".
- // Use a DimensionalLongField that is indexed (i.e. efficiently filterable with
- // DimensionalRangeQuery). This indexes to milli-second resolution, which
+ // Use a LongPoint that is indexed (i.e. efficiently filterable with
+ // PointRangeQuery). This indexes to milli-second resolution, which
// is often too fine. You could instead create a number based on
// year/month/day/hour/minutes/seconds, down the resolution you require.
// For example the long value 2011021714 would mean
// February 17, 2011, 2-3 PM.
- doc.add(new DimensionalLongField("modified", lastModified));
+ doc.add(new LongPoint("modified", lastModified));
// Add the contents of the file to a field named "contents". Specify a Reader,
// so that the text of the file is tokenized and indexed, but not stored.
Modified: lucene/dev/trunk/lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java?rev=1725998&r1=1725997&r2=1725998&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java (original)
+++ lucene/dev/trunk/lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java Thu Jan 21 15:58:08 2016
@@ -18,7 +18,7 @@ package org.apache.lucene.demo.facet;
*/
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
-import org.apache.lucene.document.DimensionalDoubleField;
+import org.apache.lucene.document.DoublePoint;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.NumericDocValuesField;
import org.apache.lucene.expressions.Expression;
@@ -40,7 +40,7 @@ import org.apache.lucene.index.IndexWrit
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.DimensionalRangeQuery;
+import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
@@ -91,25 +91,25 @@ public class DistanceFacetsExample imple
// TODO: we could index in radians instead ... saves all the conversions in getBoundingBoxFilter
// Add documents with latitude/longitude location:
- // we index these both as DimensionalDoubleFields (for bounding box/ranges) and as NumericDocValuesFields (for scoring)
+ // we index these both as DoublePoints (for bounding box/ranges) and as NumericDocValuesFields (for scoring)
Document doc = new Document();
- doc.add(new DimensionalDoubleField("latitude", 40.759011));
+ doc.add(new DoublePoint("latitude", 40.759011));
doc.add(new NumericDocValuesField("latitude", Double.doubleToRawLongBits(40.759011)));
- doc.add(new DimensionalDoubleField("longitude", -73.9844722));
+ doc.add(new DoublePoint("longitude", -73.9844722));
doc.add(new NumericDocValuesField("longitude", Double.doubleToRawLongBits(-73.9844722)));
writer.addDocument(doc);
doc = new Document();
- doc.add(new DimensionalDoubleField("latitude", 40.718266));
+ doc.add(new DoublePoint("latitude", 40.718266));
doc.add(new NumericDocValuesField("latitude", Double.doubleToRawLongBits(40.718266)));
- doc.add(new DimensionalDoubleField("longitude", -74.007819));
+ doc.add(new DoublePoint("longitude", -74.007819));
doc.add(new NumericDocValuesField("longitude", Double.doubleToRawLongBits(-74.007819)));
writer.addDocument(doc);
doc = new Document();
- doc.add(new DimensionalDoubleField("latitude", 40.7051157));
+ doc.add(new DoublePoint("latitude", 40.7051157));
doc.add(new NumericDocValuesField("latitude", Double.doubleToRawLongBits(40.7051157)));
- doc.add(new DimensionalDoubleField("longitude", -74.0088305));
+ doc.add(new DoublePoint("longitude", -74.0088305));
doc.add(new NumericDocValuesField("longitude", Double.doubleToRawLongBits(-74.0088305)));
writer.addDocument(doc);
@@ -181,7 +181,7 @@ public class DistanceFacetsExample imple
BooleanQuery.Builder f = new BooleanQuery.Builder();
// Add latitude range filter:
- f.add(DimensionalRangeQuery.new1DDoubleRange("latitude", Math.toDegrees(minLat), true, Math.toDegrees(maxLat), true),
+ f.add(PointRangeQuery.new1DDoubleRange("latitude", Math.toDegrees(minLat), true, Math.toDegrees(maxLat), true),
BooleanClause.Occur.FILTER);
// Add longitude range filter:
@@ -189,13 +189,13 @@ public class DistanceFacetsExample imple
// The bounding box crosses the international date
// line:
BooleanQuery.Builder lonF = new BooleanQuery.Builder();
- lonF.add(DimensionalRangeQuery.new1DDoubleRange("longitude", Math.toDegrees(minLng), true, null, true),
+ lonF.add(PointRangeQuery.new1DDoubleRange("longitude", Math.toDegrees(minLng), true, null, true),
BooleanClause.Occur.SHOULD);
- lonF.add(DimensionalRangeQuery.new1DDoubleRange("longitude", null, true, Math.toDegrees(maxLng), true),
+ lonF.add(PointRangeQuery.new1DDoubleRange("longitude", null, true, Math.toDegrees(maxLng), true),
BooleanClause.Occur.SHOULD);
f.add(lonF.build(), BooleanClause.Occur.MUST);
} else {
- f.add(DimensionalRangeQuery.new1DDoubleRange("longitude", Math.toDegrees(minLng), true, Math.toDegrees(maxLng), true),
+ f.add(PointRangeQuery.new1DDoubleRange("longitude", Math.toDegrees(minLng), true, Math.toDegrees(maxLng), true),
BooleanClause.Occur.FILTER);
}