Skip to content

Commit

Permalink
Spotless apply
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <[email protected]>
  • Loading branch information
finnegancarroll committed Aug 14, 2024
1 parent f3b19ba commit 8943b8e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import org.apache.lucene.document.LongPoint;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.search.Weight;
import org.opensearch.common.Rounding;
import org.opensearch.index.mapper.DateFieldMapper;
import org.opensearch.index.mapper.MappedFieldType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.opensearch.index.mapper.MappedFieldType;
import org.opensearch.index.mapper.NumericPointEncoder;
import org.opensearch.search.aggregations.bucket.range.RangeAggregator;
import org.opensearch.search.aggregations.support.ValuesSource;
import org.opensearch.search.aggregations.support.ValuesSourceConfig;
import org.opensearch.search.internal.SearchContext;

import java.io.IOException;
import java.util.function.BiConsumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,8 @@ public void testTopLevelFilterTermQuery() throws IOException {
Query boolQuery = builder.build();

List<Document> docList = new ArrayList<>();
for (int i = 0; i < 3; i++) docList.add(new Document());
for (int i = 0; i < 3; i++)
docList.add(new Document());

docList.get(0).addAll(numType.createFields(numType.typeName(), 3.0, true, true, false));
docList.get(1).addAll(numType.createFields(numType.typeName(), 11.0, true, true, false));
Expand All @@ -548,22 +549,15 @@ public void testTopLevelFilterTermQuery() throws IOException {
docList.get(1).add(new KeywordField(KEYWORD_FIELD_NAME, "route1", Field.Store.NO));
docList.get(2).add(new KeywordField(KEYWORD_FIELD_NAME, "route2", Field.Store.NO));

testRewriteOptimizationCase(
NUM_FIELD_TYPE,
new double[][] { { 0.0, 10.0 }, { 10.0, 20.0 } },
boolQuery,
docList,
range -> {
List<? extends InternalRange.Bucket> ranges = range.getBuckets();
assertEquals(2, ranges.size());
assertEquals("0.0-10.0", ranges.get(0).getKeyAsString());
assertEquals(1, ranges.get(0).getDocCount());
assertEquals("10.0-20.0", ranges.get(1).getKeyAsString());
assertEquals(1, ranges.get(1).getDocCount());
assertTrue(AggregationInspectionHelper.hasValue(range));
},
false
);
testRewriteOptimizationCase(NUM_FIELD_TYPE, new double[][] { { 0.0, 10.0 }, { 10.0, 20.0 } }, boolQuery, docList, range -> {
List<? extends InternalRange.Bucket> ranges = range.getBuckets();
assertEquals(2, ranges.size());
assertEquals("0.0-10.0", ranges.get(0).getKeyAsString());
assertEquals(1, ranges.get(0).getDocCount());
assertEquals("10.0-20.0", ranges.get(1).getKeyAsString());
assertEquals(1, ranges.get(1).getDocCount());
assertTrue(AggregationInspectionHelper.hasValue(range));
}, false);
}

/**
Expand All @@ -580,7 +574,8 @@ public void testTopLevelEffectiveMatchAll() throws IOException {
Query boolQuery = builder.build();

List<Document> docList = new ArrayList<>();
for (int i = 0; i < 3; i++) docList.add(new Document());
for (int i = 0; i < 3; i++)
docList.add(new Document());

docList.get(0).addAll(numType.createFields(numType.typeName(), 3.0, true, true, false));
docList.get(1).addAll(numType.createFields(numType.typeName(), 11.0, true, true, false));
Expand All @@ -589,22 +584,15 @@ public void testTopLevelEffectiveMatchAll() throws IOException {
docList.get(1).add(new KeywordField(KEYWORD_FIELD_NAME, "route1", Field.Store.NO));
docList.get(2).add(new KeywordField(KEYWORD_FIELD_NAME, "route1", Field.Store.NO));

testRewriteOptimizationCase(
NUM_FIELD_TYPE,
new double[][]{{0.0, 10.0}, {10.0, 20.0}},
boolQuery,
docList,
range -> {
List<? extends InternalRange.Bucket> ranges = range.getBuckets();
assertEquals(2, ranges.size());
assertEquals("0.0-10.0", ranges.get(0).getKeyAsString());
assertEquals(1, ranges.get(0).getDocCount());
assertEquals("10.0-20.0", ranges.get(1).getKeyAsString());
assertEquals(2, ranges.get(1).getDocCount());
assertTrue(AggregationInspectionHelper.hasValue(range));
},
true
);
testRewriteOptimizationCase(NUM_FIELD_TYPE, new double[][] { { 0.0, 10.0 }, { 10.0, 20.0 } }, boolQuery, docList, range -> {
List<? extends InternalRange.Bucket> ranges = range.getBuckets();
assertEquals(2, ranges.size());
assertEquals("0.0-10.0", ranges.get(0).getKeyAsString());
assertEquals(1, ranges.get(0).getDocCount());
assertEquals("10.0-20.0", ranges.get(1).getKeyAsString());
assertEquals(2, ranges.get(1).getDocCount());
assertTrue(AggregationInspectionHelper.hasValue(range));
}, true);
}

private void testCase(
Expand Down Expand Up @@ -675,7 +663,8 @@ private void testRewriteOptimizationCase(
for (Number dataPoint : dataPoints) {
Document doc = new Document();
List<Field> fieldList = numberType.createFields(fieldName, dataPoint, true, true, false);
for (Field fld : fieldList) doc.add(fld);
for (Field fld : fieldList)
doc.add(fld);
docs.add(doc);
}

Expand Down

0 comments on commit 8943b8e

Please sign in to comment.