Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhludnev committed Feb 16, 2025
1 parent bb7302f commit 94e9a78
Showing 1 changed file with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.io.IOException;
import java.util.Collections;
import java.util.List;

import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.lucene90.Lucene90DocValuesFormat;
import org.apache.lucene.document.Document;
Expand Down Expand Up @@ -157,9 +156,9 @@ private Query mrSsDvQ(String field, int... ends) {
}

private static DocValuesMultiRangeQuery.SortedSetStabbingBuilder mrSsDvBuilder(
String field, int... ends) {
String field, int... ends) {
DocValuesMultiRangeQuery.SortedSetStabbingBuilder b =
new DocValuesMultiRangeQuery.SortedSetStabbingBuilder(field);
new DocValuesMultiRangeQuery.SortedSetStabbingBuilder(field);
for (int j = 0; j < ends.length; j += 2) {
b.add(IntPoint.pack(ends[j]), IntPoint.pack(ends[j + 1]));
}
Expand All @@ -175,30 +174,30 @@ public void testToString() {

public void testOverrideToString() {
DocValuesMultiRangeQuery.SortedSetStabbingBuilder b =
new DocValuesMultiRangeQuery.SortedSetStabbingBuilder("foo") {
new DocValuesMultiRangeQuery.SortedSetStabbingBuilder("foo") {
@Override
protected Query createSortedSetDocValuesMultiRangeQuery() {
return new SortedSetDocValuesMultiRangeQuery(fieldName, clauses) {
@Override
protected Query createSortedSetDocValuesMultiRangeQuery() {
return new SortedSetDocValuesMultiRangeQuery(fieldName, clauses) {
@Override
public String toString(String fld) {
return fieldName + " " + rangeClauses.size();
}
};
public String toString(String fld) {
return fieldName + " " + rangeClauses.size();
}
};
}
};
b.add(IntPoint.pack(1), IntPoint.pack(2));
b.add(IntPoint.pack(3), IntPoint.pack(4));
assertEquals("foo 2", b.build().toString());

DocValuesMultiRangeQuery.ByteRange myrange =
new DocValuesMultiRangeQuery.ByteRange(IntPoint.pack(1), IntPoint.pack(2)) {
@Override
public String toString() {
return IntPoint.decodeDimension(lower.bytes, 0)
+ " "
+ IntPoint.decodeDimension(upper.bytes, 0);
}
};
new DocValuesMultiRangeQuery.ByteRange(IntPoint.pack(1), IntPoint.pack(2)) {
@Override
public String toString() {
return IntPoint.decodeDimension(lower.bytes, 0)
+ " "
+ IntPoint.decodeDimension(upper.bytes, 0);
}
};
assertEquals("1 2", myrange.toString());
}

Expand Down Expand Up @@ -231,8 +230,8 @@ public void testEdgeCases() throws IOException {
iw.close();
IndexSearcher searcher = newSearcher(reader);
for (DocValuesMultiRangeQuery.SortedSetStabbingBuilder builder :
List.of(
mrSsDvBuilder("foo", 2, 3, 4, 5, -5, -2), mrSsDvBuilder("foo", 2, 3, 4, 5, 12, 15))) {
List.of(
mrSsDvBuilder("foo", 2, 3, 4, 5, -5, -2), mrSsDvBuilder("foo", 2, 3, 4, 5, 12, 15))) {
assertEquals("no match", 0, searcher.search(builder.build(), 1).totalHits.value());
BytesRef lower;
BytesRef upper;
Expand All @@ -241,14 +240,14 @@ public void testEdgeCases() throws IOException {
lower.bytes = IntPoint.pack(1).bytes;
upper.bytes = IntPoint.pack(10).bytes;
assertEquals(
"updating bytes changes nothing",
0,
searcher.search(builder.build(), 1).totalHits.value());
"updating bytes changes nothing",
0,
searcher.search(builder.build(), 1).totalHits.value());
builder.add(lower, upper);
assertEquals(
"sanity check for potential match",
2,
searcher.search(builder.build(), 1).totalHits.value());
"sanity check for potential match",
2,
searcher.search(builder.build(), 1).totalHits.value());
}
// hit by value as a range upper==lower
TopDocs hit1 = searcher.search(mrSsDvQ("foo", 2, 3, 4, 5, -5, -2, 1, 1), 1);
Expand Down

0 comments on commit 94e9a78

Please sign in to comment.