Skip to content

[core] Optimize data evolution row-id assignment - #8904

Open
leaves12138 wants to merge 5 commits into
apache:masterfrom
leaves12138:agent/optimize-row-id-assignment
Open

[core] Optimize data evolution row-id assignment#8904
leaves12138 wants to merge 5 commits into
apache:masterfrom
leaves12138:agent/optimize-row-id-assignment

Conversation

@leaves12138

Copy link
Copy Markdown
Contributor

What changed

  • Store live-file planning state as three primitive words per file and replace the monolithic comparison quicksort with fixed-size radix-sorted chunks plus merge.
  • Exclude strictly contiguous same-partition logical runs larger than one billion rows from row-id mappings and manifest rewriting.
  • Avoid a redundant reassignment when filtering leaves only one contiguous logical run in a partition.
  • Rebind an existing assignment plan to current manifests after a concurrent APPEND performs manifest merging, using projected BinaryManifestEntry scans.
  • Add boundary, retry, radix ordering, multi-chunk merge, failure cleanup, and second-run regression coverage.

Why

Large data-evolution tables could allocate a very large backing array and spend most of planning time in comparison sorting. In addition, an APPEND-side manifest merge changed manifest file names and invalidated an otherwise reusable plan.

The planner now bounds temporary sorting arrays by chunk size, keeps primitive state, reduces mappings and rewrite work for large contiguous runs, and discovers the current manifests that contain already-planned ranges after an APPEND retry.

Impact

This changes only data-evolution row-id reassignment planning and retry handling. The large contiguous-run threshold defaults to 1,000,000,000 rows; setting data-evolution.reassign.skip-contiguous-row-count to 0 disables that filtering. COMPACT and OVERWRITE snapshots still abort plan reuse.

Validation

  • mvn -pl paimon-core -am -Dtest=DataEvolutionRowIdReassignerTest,LiveFileRowIdRangeCollectorTest -Dsurefire.failIfNoSpecifiedTests=false test
  • 58 targeted tests passed.

@leaves12138
leaves12138 marked this pull request as ready for review July 29, 2026 08:52
private static final int EXCLUDED_PARTITION_CACHE_SIZE = 1024;
private static final int MAX_INITIAL_LIVE_FILE_RANGES = 1 << 24;
private static final String SKIP_CONTIGUOUS_ROW_COUNT =
"data-evolution.reassign.skip-contiguous-row-count";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add it to CoreOptions.

return false;
}

private static boolean rangesOverlap(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add this method to PrimitiveRowRanges.

partitions.sort(
(left, right) -> {
int comparison = typedComparator.compare(left.partition, right.partition);
// Row IDs are globally unique, so this also orders binary-distinct

@JingsongLi JingsongLi Jul 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add tests for delete entries. They might move the deletion to the beginning here, but we should put it at the end. I understand that compaction will be performed here, so it won’t have any impact, but we want to make sure the tests run without any issues.

this.logicalRanges = logicalRanges;
}

private void removeLargeContiguousRuns(long threshold, long[] result) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove result and return real result.

private static final String COMMIT_USER_PREFIX = "reassign-row-id";
private static final int MAX_COMMIT_ATTEMPTS = 3;
private static final Projection RETRY_PROJECTION =
retryProjection(DataFileMeta.ROW_COUNT, DataFileMeta.FIRST_ROW_ID);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ROW_RANGE_PROJECTION, move this to BinaryManifestEntry.

Sign up for free to 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.

2 participants