From dc4b1aa704b906617bb892833145fbb199ee0a93 Mon Sep 17 00:00:00 2001 From: Marc D'Mello Date: Sat, 21 May 2022 19:17:36 -0700 Subject: [PATCH] Addressed more revision comments --- .../document/DoublePointDocValuesField.java} | 13 +- .../document/LongPointDocValuesField.java} | 24 ++- .../hyperrectangle/DoubleHyperRectangle.java | 8 +- .../facet/hyperrectangle/HyperRectangle.java | 58 ++++-- .../HyperRectangleFacetCounts.java | 78 ++++---- .../hyperrectangle/LongHyperRectangle.java | 6 +- .../TestHyperRectangleFacetCounts.java | 173 +++++++++++++++++- 7 files changed, 281 insertions(+), 79 deletions(-) rename lucene/{facet/src/java/org/apache/lucene/facet/hyperrectangle/DoublePointFacetField.java => core/src/java/org/apache/lucene/document/DoublePointDocValuesField.java} (81%) rename lucene/{facet/src/java/org/apache/lucene/facet/hyperrectangle/LongPointFacetField.java => core/src/java/org/apache/lucene/document/LongPointDocValuesField.java} (66%) diff --git a/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/DoublePointFacetField.java b/lucene/core/src/java/org/apache/lucene/document/DoublePointDocValuesField.java similarity index 81% rename from lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/DoublePointFacetField.java rename to lucene/core/src/java/org/apache/lucene/document/DoublePointDocValuesField.java index 747ea9d96ab8..4a3ab51a6309 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/DoublePointFacetField.java +++ b/lucene/core/src/java/org/apache/lucene/document/DoublePointDocValuesField.java @@ -14,18 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.lucene.facet.hyperrectangle; +package org.apache.lucene.document; import java.util.Arrays; -import org.apache.lucene.document.BinaryDocValuesField; -import org.apache.lucene.document.LongPoint; import org.apache.lucene.util.NumericUtils; /** * Takes an array of doubles and converts them to sortable longs, then stores as a {@link * BinaryDocValuesField} + * + * @lucene.experimental */ -public class DoublePointFacetField extends BinaryDocValuesField { +public class DoublePointDocValuesField extends BinaryDocValuesField { /** * Creates a new DoublePointFacetField, indexing the provided N-dimensional long point. @@ -34,11 +34,14 @@ public class DoublePointFacetField extends BinaryDocValuesField { * @param point double[] value * @throws IllegalArgumentException if the field name or value is null. */ - public DoublePointFacetField(String name, double... point) { + public DoublePointDocValuesField(String name, double... point) { super(name, LongPoint.pack(convertToSortableLongPoint(point))); } private static long[] convertToSortableLongPoint(double[] point) { + if (point == null || point.length == 0) { + throw new IllegalArgumentException("Point value cannot be null or empty"); + } return Arrays.stream(point).mapToLong(NumericUtils::doubleToSortableLong).toArray(); } } diff --git a/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/LongPointFacetField.java b/lucene/core/src/java/org/apache/lucene/document/LongPointDocValuesField.java similarity index 66% rename from lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/LongPointFacetField.java rename to lucene/core/src/java/org/apache/lucene/document/LongPointDocValuesField.java index b9f9bcff485d..7690fc29340a 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/LongPointFacetField.java +++ b/lucene/core/src/java/org/apache/lucene/document/LongPointDocValuesField.java @@ -14,13 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.lucene.facet.hyperrectangle; +package org.apache.lucene.document; -import org.apache.lucene.document.BinaryDocValuesField; -import org.apache.lucene.document.LongPoint; - -/** Packs an array of longs into a {@link BinaryDocValuesField} */ -public class LongPointFacetField extends BinaryDocValuesField { +/** + * Packs an array of longs into a {@link BinaryDocValuesField} + * + * @lucene.experimental + */ +public class LongPointDocValuesField extends BinaryDocValuesField { /** * Creates a new LongPointFacetField, indexing the provided N-dimensional long point. @@ -29,7 +30,14 @@ public class LongPointFacetField extends BinaryDocValuesField { * @param point long[] value * @throws IllegalArgumentException if the field name or value is null. */ - public LongPointFacetField(String name, long... point) { - super(name, LongPoint.pack(point)); + public LongPointDocValuesField(String name, long... point) { + super(name, LongPoint.pack(validatePoint(point))); + } + + private static long[] validatePoint(long[] point) { + if (point == null || point.length == 0) { + throw new IllegalArgumentException("Point value cannot be null or empty"); + } + return point; } } diff --git a/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/DoubleHyperRectangle.java b/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/DoubleHyperRectangle.java index 1b61d75dd7ad..56cfaa175937 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/DoubleHyperRectangle.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/DoubleHyperRectangle.java @@ -19,7 +19,11 @@ import java.util.Arrays; import org.apache.lucene.util.NumericUtils; -/** Stores a hyper rectangle as an array of DoubleRangePairs */ +/** + * Stores a hyper rectangle as an array of DoubleRangePairs + * + * @lucene.experimental + */ public class DoubleHyperRectangle extends HyperRectangle { /** Creates DoubleHyperRectangle */ @@ -79,7 +83,7 @@ public DoubleRangePair(double minIn, boolean minInclusive, double maxIn, boolean * * @return A LongRangePair equivalent of this object */ - public LongRangePair toLongRangePair() { + private LongRangePair toLongRangePair() { long longMin = NumericUtils.doubleToSortableLong(min); long longMax = NumericUtils.doubleToSortableLong(max); return new LongRangePair(longMin, true, longMax, true); diff --git a/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/HyperRectangle.java b/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/HyperRectangle.java index 3bfe6f3edfc5..86b836fb6af3 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/HyperRectangle.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/HyperRectangle.java @@ -16,7 +16,15 @@ */ package org.apache.lucene.facet.hyperrectangle; -/** Holds the name and the number of dims for a HyperRectangle */ +import java.util.Arrays; +import org.apache.lucene.document.LongPoint; +import org.apache.lucene.util.ArrayUtil; + +/** + * Holds the label, the number of dims, and the point pairs for a HyperRectangle + * + * @lucene.experimental + */ public abstract class HyperRectangle { /** Label that identifies this range. */ public final String label; @@ -24,8 +32,11 @@ public abstract class HyperRectangle { /** How many dimensions this hyper rectangle has (IE: a regular rectangle would have dims=2) */ public final int dims; - /** All subclasses should store pairs as comparable longs */ - protected final LongRangePair[] pairs; + private final ArrayUtil.ByteArrayComparator byteComparator = + ArrayUtil.getUnsignedComparator(Long.BYTES); + + private final byte[] lowerPoints; + private final byte[] upperPoints; /** Sole constructor. */ protected HyperRectangle(String label, LongRangePair... pairs) { @@ -37,17 +48,41 @@ protected HyperRectangle(String label, LongRangePair... pairs) { } this.label = label; this.dims = pairs.length; - this.pairs = pairs; + + this.lowerPoints = + LongPoint.pack(Arrays.stream(pairs).mapToLong(pair -> pair.min).toArray()).bytes; + this.upperPoints = + LongPoint.pack(Arrays.stream(pairs).mapToLong(pair -> pair.max).toArray()).bytes; } /** - * Returns comparable long range for a provided dim + * Checked a long packed value against this HyperRectangle. If you indexed a field with {@link + * org.apache.lucene.document.LongPointDocValuesField} or {@link + * org.apache.lucene.document.DoublePointDocValuesField}, those field values will be able to be + * passed directly into this method. * - * @param dim dimension of the request range - * @return The comparable long version of the requested range + * @param packedValue a byte array representing a long value + * @return whether the packed long point intersects with this HyperRectangle */ - public LongRangePair getComparableDimRange(int dim) { - return pairs[dim]; + public final boolean matches(byte[] packedValue) { + assert packedValue.length / Long.BYTES == dims + : "Point dimension (dim=" + + packedValue.length / Long.BYTES + + ") is incompatible with hyper rectangle dimension (dim=" + + dims + + ")"; + for (int dim = 0; dim < dims; dim++) { + int offset = dim * Long.BYTES; + if (byteComparator.compare(packedValue, offset, lowerPoints, offset) < 0) { + // Doc's value is too low, in this dimension + return false; + } + if (byteComparator.compare(packedValue, offset, upperPoints, offset) > 0) { + // Doc's value is too low, in this dimension + return false; + } + } + return true; } /** Defines a single range in a HyperRectangle */ @@ -92,10 +127,5 @@ public LongRangePair(long minIn, boolean minInclusive, long maxIn, boolean maxIn this.min = minIn; this.max = maxIn; } - - /** True if this range accepts the provided value. */ - public boolean accept(long value) { - return value >= min && value <= max; - } } } diff --git a/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/HyperRectangleFacetCounts.java b/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/HyperRectangleFacetCounts.java index 123322db5e62..c5c7cf8668a5 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/HyperRectangleFacetCounts.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/HyperRectangleFacetCounts.java @@ -20,31 +20,38 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.apache.lucene.document.LongPoint; import org.apache.lucene.facet.FacetResult; import org.apache.lucene.facet.Facets; import org.apache.lucene.facet.FacetsCollector; import org.apache.lucene.facet.LabelAndValue; import org.apache.lucene.index.BinaryDocValues; import org.apache.lucene.index.DocValues; +import org.apache.lucene.search.ConjunctionUtils; import org.apache.lucene.search.DocIdSetIterator; -/** Get counts given a list of HyperRectangles (which must be of the same type) */ +/** + * Get counts given a list of HyperRectangles + * + * @lucene.experimental + */ public class HyperRectangleFacetCounts extends Facets { - /** Hypper rectangles passed to constructor. */ - protected final HyperRectangle[] hyperRectangles; + /** Hyper rectangles passed to constructor. */ + private final HyperRectangle[] hyperRectangles; - /** Counts, initialized in subclass. */ - protected final int[] counts; + /** + * Holds the number of matching documents (contains intersecting point in field) for each {@link + * HyperRectangle} + */ + private final int[] counts; /** Our field name. */ - protected final String field; + private final String field; /** Number of dimensions for field */ - protected final int dims; + private final int dims; /** Total number of hits. */ - protected int totCount; + private int totCount; /** * Create HyperRectangleFacetCounts using this @@ -56,9 +63,12 @@ public class HyperRectangleFacetCounts extends Facets { */ public HyperRectangleFacetCounts( String field, FacetsCollector hits, HyperRectangle... hyperRectangles) throws IOException { - assert hyperRectangles.length > 0 : "Hyper rectangle ranges cannot be empty"; - assert areHyperRectangleDimsConsistent(hyperRectangles) - : "All hyper rectangles must be the same dimensionality"; + if (hyperRectangles == null || hyperRectangles.length == 0) { + throw new IllegalArgumentException("Hyper rectangle ranges cannot be empty"); + } + if (areHyperRectangleDimsConsistent(hyperRectangles) == false) { + throw new IllegalArgumentException("All hyper rectangles must be the same dimensionality"); + } this.field = field; this.hyperRectangles = hyperRectangles; this.dims = hyperRectangles[0].dims; @@ -75,50 +85,34 @@ private boolean areHyperRectangleDimsConsistent(HyperRectangle[] hyperRectangles private void count(String field, List matchingDocs) throws IOException { - for (int i = 0; i < matchingDocs.size(); i++) { - - FacetsCollector.MatchingDocs hits = matchingDocs.get(i); + for (FacetsCollector.MatchingDocs hits : matchingDocs) { BinaryDocValues binaryDocValues = DocValues.getBinary(hits.context.reader(), field); - final DocIdSetIterator it = hits.bits.iterator(); + final DocIdSetIterator it = + ConjunctionUtils.intersectIterators(Arrays.asList(hits.bits.iterator(), binaryDocValues)); if (it == null) { continue; } for (int doc = it.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = it.nextDoc()) { - if (binaryDocValues.advanceExact(doc)) { - long[] point = LongPoint.unpack(binaryDocValues.binaryValue()); - assert point.length == dims - : "Point dimension (dim=" - + point.length - + ") is incompatible with hyper rectangle dimension (dim=" - + dims - + ")"; - // linear scan, change this to use R trees - boolean docIsValid = false; - for (int j = 0; j < hyperRectangles.length; j++) { - boolean validPoint = true; - for (int dim = 0; dim < dims; dim++) { - HyperRectangle.LongRangePair range = hyperRectangles[j].getComparableDimRange(dim); - if (!range.accept(point[dim])) { - validPoint = false; - break; - } - } - if (validPoint) { - counts[j]++; - docIsValid = true; - } - } - if (docIsValid) { - totCount++; + boolean shouldCountDoc = false; + // linear scan, change this to use R trees + for (int j = 0; j < hyperRectangles.length; j++) { + if (hyperRectangles[j].matches(binaryDocValues.binaryValue().bytes)) { + counts[j]++; + shouldCountDoc = true; } } + if (shouldCountDoc) { + totCount++; + } } } } + // TODO: This does not really provide "top children" functionality yet but provides "all + // children". This is being worked on in LUCENE-10550 @Override public FacetResult getTopChildren(int topN, String dim, String... path) throws IOException { validateTopN(topN); diff --git a/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/LongHyperRectangle.java b/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/LongHyperRectangle.java index db542e7a2060..d39a6b303e3c 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/LongHyperRectangle.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/hyperrectangle/LongHyperRectangle.java @@ -16,7 +16,11 @@ */ package org.apache.lucene.facet.hyperrectangle; -/** Stores a hyper rectangle as an array of LongRangePairs */ +/** + * Stores a hyper rectangle as an array of LongRangePairs + * + * @lucene.experimental + */ public class LongHyperRectangle extends HyperRectangle { /** Created LongHyperRectangle */ diff --git a/lucene/facet/src/test/org/apache/lucene/facet/hyperrectangle/TestHyperRectangleFacetCounts.java b/lucene/facet/src/test/org/apache/lucene/facet/hyperrectangle/TestHyperRectangleFacetCounts.java index 717eee06fffc..bba50889a5d0 100644 --- a/lucene/facet/src/test/org/apache/lucene/facet/hyperrectangle/TestHyperRectangleFacetCounts.java +++ b/lucene/facet/src/test/org/apache/lucene/facet/hyperrectangle/TestHyperRectangleFacetCounts.java @@ -18,6 +18,8 @@ import java.io.IOException; import org.apache.lucene.document.Document; +import org.apache.lucene.document.DoublePointDocValuesField; +import org.apache.lucene.document.LongPointDocValuesField; import org.apache.lucene.facet.FacetResult; import org.apache.lucene.facet.FacetTestCase; import org.apache.lucene.facet.Facets; @@ -38,15 +40,16 @@ public void testBasicLong() throws Exception { for (long l = 0; l < 100; l++) { Document doc = new Document(); - LongPointFacetField field = new LongPointFacetField("field", l, l + 1L, l + 2L); + LongPointDocValuesField field = new LongPointDocValuesField("field", l, l + 1L, l + 2L); doc.add(field); w.addDocument(doc); } // Also add point with Long.MAX_VALUE Document doc = new Document(); - LongPointFacetField field = - new LongPointFacetField("field", Long.MAX_VALUE - 2L, Long.MAX_VALUE - 1L, Long.MAX_VALUE); + LongPointDocValuesField field = + new LongPointDocValuesField( + "field", Long.MAX_VALUE - 2L, Long.MAX_VALUE - 1L, Long.MAX_VALUE); doc.add(field); w.addDocument(doc); @@ -110,15 +113,15 @@ public void testBasicDouble() throws Exception { for (double l = 0; l < 100; l++) { Document doc = new Document(); - DoublePointFacetField field = new DoublePointFacetField("field", l, l + 1.0, l + 2.0); + DoublePointDocValuesField field = new DoublePointDocValuesField("field", l, l + 1.0, l + 2.0); doc.add(field); w.addDocument(doc); } // Also add point with Long.MAX_VALUE Document doc = new Document(); - DoublePointFacetField field = - new DoublePointFacetField( + DoublePointDocValuesField field = + new DoublePointDocValuesField( "field", Double.MAX_VALUE - 2.0, Double.MAX_VALUE - 1.0, Double.MAX_VALUE); doc.add(field); w.addDocument(doc); @@ -181,12 +184,168 @@ public void testBasicDouble() throws Exception { d.close(); } + public void testNegativeLong() throws IOException { + Directory d = newDirectory(); + RandomIndexWriter w = new RandomIndexWriter(random(), d); + + for (long l = -99; l <= 0; l++) { + Document doc = new Document(); + LongPointDocValuesField field = new LongPointDocValuesField("field", l, l - 1L, l - 2L); + doc.add(field); + w.addDocument(doc); + } + + // Also add point with Long.MIN_VALUE + Document doc = new Document(); + LongPointDocValuesField field = + new LongPointDocValuesField( + "field", Long.MIN_VALUE + 2L, Long.MIN_VALUE + 1L, Long.MIN_VALUE); + doc.add(field); + w.addDocument(doc); + + IndexReader r = w.getReader(); + w.close(); + + IndexSearcher s = newSearcher(r); + FacetsCollector fc = s.search(new MatchAllDocsQuery(), new FacetsCollectorManager()); + + Facets facets = + new HyperRectangleFacetCounts( + "field", + fc, + new LongHyperRectangle( + "greater than (-10, -11, -12)", + new HyperRectangle.LongRangePair(-10L, false, 0L, true), + new HyperRectangle.LongRangePair(-11L, false, 0L, true), + new HyperRectangle.LongRangePair(-12L, false, 0L, true)), + new LongHyperRectangle( + "greater than or equal to (-10, -11, -12)", + new HyperRectangle.LongRangePair(-10L, true, 0L, true), + new HyperRectangle.LongRangePair(-11L, true, 0L, true), + new HyperRectangle.LongRangePair(-12L, true, 0L, true)), + new LongHyperRectangle( + "under (-90, -91, -92)", + new HyperRectangle.LongRangePair(-100L, false, -90L, false), + new HyperRectangle.LongRangePair(-101L, false, -91L, false), + new HyperRectangle.LongRangePair(-102L, false, -92L, false)), + new LongHyperRectangle( + "(90, 91, 92) or below", + new HyperRectangle.LongRangePair(-100L, false, -90L, true), + new HyperRectangle.LongRangePair(-101L, false, -91L, true), + new HyperRectangle.LongRangePair(-102L, false, -92L, true)), + new LongHyperRectangle( + "under (1000, 1000, 1000)", + new HyperRectangle.LongRangePair(Long.MIN_VALUE + 2L, true, -1000L, false), + new HyperRectangle.LongRangePair(Long.MIN_VALUE + 1L, true, -1000L, false), + new HyperRectangle.LongRangePair(Long.MIN_VALUE, true, -1000L, false))); + + FacetResult result = facets.getTopChildren(10, "field"); + + assertEquals("field", result.dim); + assertEquals(0, result.path.length); + assertEquals(22, result.value); + assertEquals(5, result.childCount); + + LabelAndValue[] expectedLabelsAndValues = new LabelAndValue[5]; + expectedLabelsAndValues[0] = new LabelAndValue("greater than (-10, -11, -12)", 10); + expectedLabelsAndValues[1] = new LabelAndValue("greater than or equal to (-10, -11, -12)", 11); + expectedLabelsAndValues[2] = new LabelAndValue("under (-90, -91, -92)", 9); + expectedLabelsAndValues[3] = new LabelAndValue("(90, 91, 92) or below", 10); + expectedLabelsAndValues[4] = new LabelAndValue("under (1000, 1000, 1000)", 1); + + assertArrayEquals(expectedLabelsAndValues, result.labelValues); + + r.close(); + d.close(); + } + + public void testNegativeDouble() throws IOException { + Directory d = newDirectory(); + RandomIndexWriter w = new RandomIndexWriter(random(), d); + + for (double i = -99; i <= 0; i++) { + Document doc = new Document(); + DoublePointDocValuesField field = new DoublePointDocValuesField("field", i, i - 1.0, i - 2.0); + doc.add(field); + w.addDocument(doc); + } + + // Also add point with Double.MIN_VALUE + Document doc = new Document(); + DoublePointDocValuesField field = + new DoublePointDocValuesField( + "field", + Double.NEGATIVE_INFINITY + 2.0, + Double.NEGATIVE_INFINITY + 1.0, + Double.NEGATIVE_INFINITY); + doc.add(field); + w.addDocument(doc); + + IndexReader r = w.getReader(); + w.close(); + + IndexSearcher s = newSearcher(r); + FacetsCollector fc = s.search(new MatchAllDocsQuery(), new FacetsCollectorManager()); + + Facets facets = + new HyperRectangleFacetCounts( + "field", + fc, + new DoubleHyperRectangle( + "greater than (-10, -11, -12)", + new DoubleHyperRectangle.DoubleRangePair(-10.0, false, 0.0, true), + new DoubleHyperRectangle.DoubleRangePair(-11.0, false, 0.0, true), + new DoubleHyperRectangle.DoubleRangePair(-12.0, false, 0.0, true)), + new DoubleHyperRectangle( + "greater than or equal to (-10, -11, -12)", + new DoubleHyperRectangle.DoubleRangePair(-10.0, true, 0.0, true), + new DoubleHyperRectangle.DoubleRangePair(-11.0, true, 0.0, true), + new DoubleHyperRectangle.DoubleRangePair(-12.0, true, 0.0, true)), + new DoubleHyperRectangle( + "under (-90, -91, -92)", + new DoubleHyperRectangle.DoubleRangePair(-100.0, false, -90.0, false), + new DoubleHyperRectangle.DoubleRangePair(-101.0, false, -91.0, false), + new DoubleHyperRectangle.DoubleRangePair(-102.0, false, -92.0, false)), + new DoubleHyperRectangle( + "(90, 91, 92) or below", + new DoubleHyperRectangle.DoubleRangePair(-100.0, false, -90.0, true), + new DoubleHyperRectangle.DoubleRangePair(-101.0, false, -91.0, true), + new DoubleHyperRectangle.DoubleRangePair(-102.0, false, -92.0, true)), + new DoubleHyperRectangle( + "under (1000, 1000, 1000)", + new DoubleHyperRectangle.DoubleRangePair( + Double.NEGATIVE_INFINITY + 2.0, true, -1000.0, false), + new DoubleHyperRectangle.DoubleRangePair( + Double.NEGATIVE_INFINITY + 1.0, true, -1000.0, false), + new DoubleHyperRectangle.DoubleRangePair( + Double.NEGATIVE_INFINITY, true, -1000.0, false))); + + FacetResult result = facets.getTopChildren(10, "field"); + + assertEquals("field", result.dim); + assertEquals(0, result.path.length); + assertEquals(22, result.value); + assertEquals(5, result.childCount); + + LabelAndValue[] expectedLabelsAndValues = new LabelAndValue[5]; + expectedLabelsAndValues[0] = new LabelAndValue("greater than (-10, -11, -12)", 10); + expectedLabelsAndValues[1] = new LabelAndValue("greater than or equal to (-10, -11, -12)", 11); + expectedLabelsAndValues[2] = new LabelAndValue("under (-90, -91, -92)", 9); + expectedLabelsAndValues[3] = new LabelAndValue("(90, 91, 92) or below", 10); + expectedLabelsAndValues[4] = new LabelAndValue("under (1000, 1000, 1000)", 1); + + assertArrayEquals(expectedLabelsAndValues, result.labelValues); + + r.close(); + d.close(); + } + public void testGetTopChildren() throws IOException { Directory d = newDirectory(); RandomIndexWriter w = new RandomIndexWriter(random(), d); Document doc = new Document(); - LongPointFacetField field = new LongPointFacetField("field", 0L); + LongPointDocValuesField field = new LongPointDocValuesField("field", 0L); doc.add(field); w.addDocument(doc);