Skip to content

Commit

Permalink
Spotless apply
Browse files Browse the repository at this point in the history
Signed-off-by: Harsha Vamsi Kalluri <[email protected]>
  • Loading branch information
harshavamsi committed Jul 19, 2024
1 parent a135cca commit 207831a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

package org.opensearch.search.approximate;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.PointValues;
Expand Down Expand Up @@ -224,17 +222,20 @@ private boolean checkValidPointValues(PointValues values) throws IOException {
return true;
}

private void intersectLeft(PointValues.PointTree pointTree, PointValues.IntersectVisitor visitor, int count) throws IOException {
private void intersectLeft(PointValues.PointTree pointTree, PointValues.IntersectVisitor visitor, int count)
throws IOException {
intersectLeft(visitor, pointTree, count);
assert pointTree.moveToParent() == false;
}

private void intersectRight(PointValues.PointTree pointTree, PointValues.IntersectVisitor visitor, int count) throws IOException {
private void intersectRight(PointValues.PointTree pointTree, PointValues.IntersectVisitor visitor, int count)
throws IOException {
intersectRight(visitor, pointTree, count);
assert pointTree.moveToParent() == false;
}

private long intersectLeft(PointValues.IntersectVisitor visitor, PointValues.PointTree pointTree, int count) throws IOException {
private long intersectLeft(PointValues.IntersectVisitor visitor, PointValues.PointTree pointTree, int count)
throws IOException {
PointValues.Relation r = visitor.compare(pointTree.getMinPackedValue(), pointTree.getMaxPackedValue());
if (docCount[0] >= count) {
return 0;
Expand All @@ -244,7 +245,8 @@ private long intersectLeft(PointValues.IntersectVisitor visitor, PointValues.Poi
// This cell is fully outside the query shape: stop recursing
break;
case CELL_INSIDE_QUERY:
// If the cell is fully inside, we keep moving to child until we reach a point where we can no longer move or when we have sufficient doc count
// If the cell is fully inside, we keep moving to child until we reach a point where we can no longer move or when
// we have sufficient doc count
if (pointTree.moveToChild()) {
do {
docCount[0] += intersectLeft(visitor, pointTree, count);
Expand Down Expand Up @@ -285,7 +287,8 @@ private long intersectLeft(PointValues.IntersectVisitor visitor, PointValues.Poi
return docCount[0] > 0 ? docCount[0] : 0;
}

private long intersectRight(PointValues.IntersectVisitor visitor, PointValues.PointTree pointTree, int count) throws IOException {
private long intersectRight(PointValues.IntersectVisitor visitor, PointValues.PointTree pointTree, int count)
throws IOException {
PointValues.Relation r = visitor.compare(pointTree.getMinPackedValue(), pointTree.getMaxPackedValue());
if (docCount[0] >= count) {
return 0;
Expand All @@ -295,9 +298,10 @@ private long intersectRight(PointValues.IntersectVisitor visitor, PointValues.Po
// This cell is fully outside the query shape: stop recursing
break;
case CELL_INSIDE_QUERY:
// If the cell is fully inside, we keep moving to child until we reach a point where we can no longer move or when we have sufficient doc count
// If the cell is fully inside, we keep moving to child until we reach a point where we can no longer move or when
// we have sufficient doc count
if (pointTree.moveToChild()) {
while (pointTree.moveToSibling() && docCount[0] <= count){
while (pointTree.moveToSibling() && docCount[0] <= count) {
docCount[0] += intersectRight(visitor, pointTree, count);
}
pointTree.moveToParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,8 @@ private void searchLeaf(LeafReaderContext ctx, Weight weight, Collector collecto
if (searchContext.size() > 10_000) ((ApproximatePointRangeQuery) query.getApproximationQuery()).setSize(searchContext.size());
if (searchContext.request() != null && searchContext.request().source() != null) {
FieldSortBuilder primarySortField = FieldSortBuilder.getPrimaryFieldSortOrNull(searchContext.request().source());
if (primarySortField != null
&& primarySortField.missing() == null) {
if(primarySortField.order() == SortOrder.DESC){
if (primarySortField != null && primarySortField.missing() == null) {
if (primarySortField.order() == SortOrder.DESC) {
((ApproximatePointRangeQuery) query.getApproximationQuery()).setSortOrder(SortOrder.DESC);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void testApproximateRangeWithSize() throws IOException {
pack(upper).bytes,
dims,
10,
SortOrder.ASC
SortOrder.ASC
) {
protected String toString(int dimension, byte[] value) {
return Long.toString(LongPoint.decodeDimension(value, 0));
Expand All @@ -114,7 +114,7 @@ protected String toString(int dimension, byte[] value) {
pack(upper).bytes,
dims,
100,
SortOrder.ASC
SortOrder.ASC
) {
protected String toString(int dimension, byte[] value) {
return Long.toString(LongPoint.decodeDimension(value, 0));
Expand Down Expand Up @@ -159,7 +159,14 @@ public void testApproximateRangeShortCircuit() throws IOException {
try {
long lower = 0;
long upper = 100;
Query approximateQuery = new ApproximatePointRangeQuery("point", pack(lower).bytes, pack(upper).bytes, dims, 10, SortOrder.ASC) {
Query approximateQuery = new ApproximatePointRangeQuery(
"point",
pack(lower).bytes,
pack(upper).bytes,
dims,
10,
SortOrder.ASC
) {
protected String toString(int dimension, byte[] value) {
return Long.toString(LongPoint.decodeDimension(value, 0));
}
Expand Down

0 comments on commit 207831a

Please sign in to comment.