Skip to content

feat(aggregate): add Java-compatible field aggregators - #463

Closed
liangjie3138 wants to merge 14 commits into
alibaba:mainfrom
liangjie3138:feat/java-compatible-aggregators
Closed

feat(aggregate): add Java-compatible field aggregators#463
liangjie3138 wants to merge 14 commits into
alibaba:mainfrom
liangjie3138:feat/java-compatible-aggregators

Conversation

@liangjie3138

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close#457

Port the six practical field aggregators missing on the C++ side — collect,
merge_map, nested_update, rbm64, hll_sketch, theta_sketch .

Also adds GenericArray / GenericMap, the in-memory InternalArray /
InternalMap implementations these aggregators need to build ARRAY and MAP
results.

Tests

18 new unit test cases in paimon-core-test, covering each aggregator's
aggregate / retract / null / type-validation paths.

Three pin behaviour that is easy to "fix" incorrectly, and each was checked by
reverting the corresponding production change and confirming it fails:

  • BinaryAggMergeFunctionTest.OwnedAccumulatorSurvivesNullInput — drives a real
    AggregateMergeFunction so the use-after-free is exercised through the
    production path.
  • FieldNestedUpdateAggTest.CountLimitCountsNullElementsOfAccumulator — count
    limit is measured against the raw element count, matching Java.
  • FieldIgnoreRetractAggTest.ReversedAggBypassesWrappedOverride — the wrapper
    does not preserve the wrapped aggregator's reversed-aggregation override, also
    matching Java.

No integration tests added.

API and Format

Additive only, no signatures changed:

  • include/paimon/defs.h: four new Options constants — NESTED_KEY,
    NESTED_KEY_NULL_STRATEGY, NESTED_SEQUENCE_FIELD, COUNT_LIMIT.
  • CoreOptions: a NestedKeyNullStrategy enum plus accessors.
  • FieldAggregator: new virtuals default to the existing Agg / AggReversed.

New dependency: Apache DataSketches 5.2.0 (Apache-2.0), resolved through
resolve_dependency() like the other bundled dependencies.

Documentation

None.

Generative AI tooling

Generated-by: Claude Code 2.1.220 (Claude Opus 5)

Comment threadsrc/paimon/core/mergetree/compact/aggregate/field_roaring_bitmap64_agg.cpp Outdated
Comment threadsrc/paimon/core/core_options.cpp
pooled_unique_ptr<Bytes> result =
Bytes::AllocateBytes(serialized.size() * sizeof(T), GetDefaultPool().get());
if (!serialized.empty()) {
std::memcpy(result->data(), serialized.data(), result->size());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify: I noticed many places are using GetDefaultPool(). Will the data volume during merging be relatively large? In paimon-cpp, batches are merged together, and data that has not yet been converted into Arrow arrays may stay held in memory for a while. Is it appropriate for that memory to be allocated from a default pool that is separate from the user-provided memory pool?

Comment threadsrc/paimon/core/mergetree/compact/aggregate/field_nested_update_agg.cpp Outdated
Comment threadsrc/paimon/core/mergetree/compact/aggregate/field_nested_update_agg.cpp Outdated
liangjie3138and others added 9 commits August 4, 2026 10:30
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…esult
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…lookups
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…:Equals
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… suite
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ses from Java
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…new aggregators
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@liangjie3138
liangjie3138force-pushed the feat/java-compatible-aggregators branch from 21c7ee0 to 428a47dCompareAugust 4, 2026 02:49
liangjie3138and others added 5 commits August 4, 2026 11:44
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@lxy-9602lxy-9602 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@lxy-9602

Copy link
Copy Markdown
Collaborator

This has already been merged in apache/paimon-cpp#183, so we can close this PR.

@lxy-9602lxy-9602 closed this Aug 6, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add practical field aggregators available in Java Paimon

2 participants

@liangjie3138@lxy-9602