Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private void updateWithSequenceGroup(KeyValue kv) {
row.setField(
i, aggregator == null ? field : aggregator.agg(accumulator, field));
} else if (aggregator != null) {
row.setField(i, aggregator.agg(field, accumulator));
row.setField(i, aggregator.aggReversed(accumulator, field));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ private static FieldAggregator createFieldNestedUpdateAgg(

public abstract Object agg(Object accumulator, Object inputField);

public Object aggReversed(Object accumulator, Object inputField) {
return agg(inputField, accumulator);
}

/** reset the aggregator to a clean start state. */
public void reset() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ String name() {
return NAME;
}

@Override
public Object aggReversed(Object accumulator, Object inputField) {
// we don't need to actually do the reverse here for this agg
// because accumulator has been distinct, just let accumulator be accumulator will speed up
// dinstinct process
return agg(accumulator, inputField);
}

@Override
public Object agg(Object accumulator, Object inputField) {
if (accumulator == null && inputField == null) {
Expand All @@ -99,7 +107,9 @@ public Object agg(Object accumulator, Object inputField) {

if (equaliser != null) {
List<Object> collection = new ArrayList<>();
collectWithEqualiser(collection, accumulator);
// do not need to distinct accumulator, because the accumulator is always distinct, no
// need to distinct it every time
collect(collection, accumulator);
collectWithEqualiser(collection, inputField);
return new GenericArray(collection.toArray());
} else {
Expand Down