Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
Signed-off-by: bowenlan-amzn <[email protected]>
  • Loading branch information
bowenlan-amzn committed Apr 22, 2024
1 parent 02f5c14 commit 1ee1070
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.opensearch.search.internal.SearchContext;

import java.io.IOException;
import java.time.Instant;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -272,7 +271,7 @@ public void setAggregationType(AggregationType aggregationType) {
}

public boolean isRewriteable(final Object parent, final int subAggLength) {
if (context.maxAggRewriteFilters() == 0) return false;
// if (context.maxAggRewriteFilters() == 0) return false;

boolean rewriteable = aggregationType.isRewriteable(parent, subAggLength);
logger.debug("Fast filter rewriteable: {} for shard {}", rewriteable, context.indexShard().shardId());
Expand Down Expand Up @@ -331,9 +330,11 @@ interface AggregationType {
boolean isRewriteable(Object parent, int subAggLength);

Weight[] buildFastFilter(SearchContext ctx) throws IOException;

Weight[] buildFastFilter(LeafReaderContext leaf, SearchContext ctx) throws IOException;

long[][] buildRanges(SearchContext ctx) throws IOException;

long[][] buildRanges(LeafReaderContext leaf, SearchContext ctx) throws IOException;

default int getSize() {
Expand Down Expand Up @@ -515,6 +516,7 @@ public static boolean tryFastFilterAggregation(
if (ctx.reader().hasDeletions()) return false;

PointValues values = ctx.reader().getPointValues(fastFilterContext.fieldName);
if (values == null) return false;
// date field is 1 dimensional
// only proceed if every document has exactly one point for this field
if (values.getDocCount() != values.size()) return false;
Expand Down Expand Up @@ -551,13 +553,7 @@ public static boolean tryFastFilterAggregation(
final DateFieldMapper.DateFieldType fieldType = ((AbstractDateHistogramAggregationType) fastFilterContext.aggregationType)
.getFieldType();
int size = fastFilterContext.aggregationType.getSize();
DebugInfoCollector debugInfo = multiRangesTraverse(
values.getPointTree(),
ranges,
incrementDocCount,
fieldType,
size
);
DebugInfoCollector debugInfo = multiRangesTraverse(values.getPointTree(), ranges, incrementDocCount, fieldType, size);
fastFilterContext.consumeDebugInfo(debugInfo);

Check warning on line 557 in server/src/main/java/org/opensearch/search/aggregations/bucket/FastFilterRewriteHelper.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/search/aggregations/bucket/FastFilterRewriteHelper.java#L553-L557

Added lines #L553 - L557 were not covered by tests

logger.debug("Fast filter optimization applied to shard {} segment {}", fastFilterContext.context.indexShard().shardId(), ctx.ord);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ final class CompositeAggregator extends BucketsAggregator {
// bucketOrds is used for saving date histogram results
bucketOrds = LongKeyedBucketOrds.build(context.bigArrays(), CardinalityUpperBound.ONE);
preparedRounding = ((CompositeAggregationType) fastFilterContext.getAggregationType()).getRoundingPrepared();
fastFilterContext.setFieldName(sourceConfigs[0].name());
fastFilterContext.buildRanges();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ private AutoDateHistogramAggregator(
)
);
if (fastFilterContext.isRewriteable(parent, subAggregators.length)) {
fastFilterContext.setFieldName(valuesSourceConfig.fieldType().name());
fastFilterContext.buildRanges();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,6 @@ public void testNanosIntervalSecond() throws IOException {
aggregation -> aggregation.calendarInterval(DateHistogramInterval.SECOND).field(AGGREGABLE_DATE).minDocCount(1L),
histogram -> {
List<? extends Histogram.Bucket> buckets = histogram.getBuckets();
System.out.println(buckets);
assertEquals(3, buckets.size());

Histogram.Bucket bucket = buckets.get(0);
Expand Down

0 comments on commit 1ee1070

Please sign in to comment.