Skip to content

Commit

Permalink
handle missing input
Browse files Browse the repository at this point in the history
Signed-off-by: bowenlan-amzn <[email protected]>
  • Loading branch information
bowenlan-amzn committed May 24, 2024
1 parent 85133c4 commit 9d4701c
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public class CardinalityAggregator extends NumericMetricsAggregator.SingleValue
private final int precision;
private final ValuesSource valuesSource;

private final ValuesSourceConfig valuesSourceConfig;
private final FieldContext fieldContext;

// Expensive to initialize, so we only initialize it when we have an actual value source
Expand All @@ -105,6 +106,7 @@ public CardinalityAggregator(
) throws IOException {
super(name, context, parent, metadata);
// TODO: Stop using nulls here
this.valuesSourceConfig = valuesSourceConfig;
this.valuesSource = valuesSourceConfig.hasValues() ? valuesSourceConfig.getValuesSource() : null;
this.precision = precision;
this.fieldContext = valuesSourceConfig.fieldContext();
Expand Down Expand Up @@ -148,6 +150,9 @@ private Collector pickCollector(LeafReaderContext ctx) throws IOException {
ordinalsCollectorsUsed++;
// return new DynamicPruningCollectorWrapper(new OrdinalsCollector(counts, ordinalValues, context.bigArrays()),
// context, ctx, fieldContext, source);
if (valuesSourceConfig.missing() != null) {
return new OrdinalsCollector(counts, ordinalValues, context.bigArrays());
}
return new CompetitiveCollector(
new OrdinalsCollector(counts, ordinalValues, context.bigArrays()),
source,
Expand Down

0 comments on commit 9d4701c

Please sign in to comment.