JeonDaehong commented on code in PR #1480:
URL: https://github.com/apache/paimon-rust/pull/1480#discussion_r4666514073
##########
crates/paimon/src/table/compact/primary_key/lookup.rs:
##########
@@ -108,17 +108,14 @@ fn source_row(
columns: &[usize],
schema: &SchemaRef,
) -> Result<RecordBatch> {
- let indices = UInt64Array::from(vec![row_idx as u64]);
+ // A zero-copy slice: the reader concatenates changelog rows into batches.
let values = (0..schema.fields().len())
.map(|index| {
- arrow_select::take::take(
- batches[batch_idx].column_for_output(index, columns),
- &indices,
- None,
- )
- .map_err(|error| invalid(format!("Failed to materialize lookup
value: {error}")))
+ batches[batch_idx]
+ .column_for_output(index, columns)
+ .slice(row_idx, 1)
Review Comment:
Thanks @JingsongLi, you're right. The slices kept every input batch with a
pending change alive until the changelog reached `read.batch-size`. In 89ef69f8
the reader copies its pending changelog rows into one batch whenever it
releases source batches, so they never hold more than the reader already does.
With 4 KiB values and one change per 1,024-row input batch, peak RSS of that
compaction is 83–86 MB on the parent, 325–326 MB on the previous commit and
78–85 MB now. `test_changelog_rows_do_not_keep_released_source_batches` fails
on the previous commit.
##########
crates/paimon/src/table/compact/primary_key/lookup.rs:
##########
@@ -359,13 +356,13 @@ impl MergeFunction for LookupChangelogMergeFunction {
}
_ => {}
}
- let changelog = if changes.is_empty() {
- None
- } else {
- Some(
+ let changelog = match changes.len() {
+ 0 => None,
+ 1 => changes.pop(),
Review Comment:
Thanks @SteNicholas for the repro. A lone row is now copied before it goes
to the writer too. `lookup_changelog_charges_a_lone_row_for_its_own_value` runs
a compaction under a 64 KiB limit where the only changelog row comes from a
batch of 4 KiB values, for Parquet and ORC. It passes on the parent and now,
and on the previous commit it asks for 526,749 bytes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]