Skip to content

Commit

Permalink
Allow sub agg in filter rewrite opt
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <[email protected]>
  • Loading branch information
finnegancarroll committed Aug 18, 2024
1 parent e291bdc commit 9e19ad9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ protected long getOrd(int rangeIdx) {
return ord;
}
};
filterRewriteOptimizationContext = new FilterRewriteOptimizationContext(bridge, parent, subAggregators.length, context);
filterRewriteOptimizationContext = new FilterRewriteOptimizationContext(bridge, parent, context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,20 @@ public final class FilterRewriteOptimizationContext {
public FilterRewriteOptimizationContext(
AggregatorBridge aggregatorBridge,
final Object parent,
final int subAggLength,
SearchContext context
) throws IOException {
this.aggregatorBridge = aggregatorBridge;
this.canOptimize = this.canOptimize(parent, subAggLength, context);
this.canOptimize = this.canOptimize(parent, context);
}

/**
* common logic for checking whether the optimization can be applied and prepare at shard level
* if the aggregation has any special logic, it should be done using {@link AggregatorBridge}
*/
private boolean canOptimize(final Object parent, final int subAggLength, SearchContext context) throws IOException {
private boolean canOptimize(final Object parent, SearchContext context) throws IOException {
if (context.maxAggRewriteFilters() == 0) return false;

if (parent != null || subAggLength != 0) return false;
if (parent != null) return false;

boolean canOptimize = aggregatorBridge.canOptimize();
if (canOptimize) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ protected long getOrd(int rangeIdx) {
return ord;
}
};
filterRewriteOptimizationContext = new FilterRewriteOptimizationContext(bridge, parent, subAggregators.length, context);
filterRewriteOptimizationContext = new FilterRewriteOptimizationContext(bridge, parent, context);
}

protected abstract LongKeyedBucketOrds getBucketOrds();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected long getOrd(int rangeIdx) {
return ord;
}
};
filterRewriteOptimizationContext = new FilterRewriteOptimizationContext(bridge, parent, subAggregators.length, context);
filterRewriteOptimizationContext = new FilterRewriteOptimizationContext(bridge, parent, context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ protected void prepare() {
buildRanges(ranges);
}
};
filterRewriteOptimizationContext = new FilterRewriteOptimizationContext(bridge, parent, subAggregators.length, context);
filterRewriteOptimizationContext = new FilterRewriteOptimizationContext(bridge, parent, context);
}

@Override
Expand Down

0 comments on commit 9e19ad9

Please sign in to comment.