JingsongLi commented on code in PR #177:
URL: https://github.com/apache/paimon-rust/pull/177#discussion_r3031589816
##########
crates/paimon/src/table/table_scan.rs:
##########
@@ -313,6 +390,26 @@ impl<'a> TableScan<'a> {
return Ok(Plan::new(Vec::new()));
}
+ // --- Limit pushdown at manifest entry level (for append-only tables)
---
+ //
+ // For simple append-only tables without deletion vectors or data
evolution,
+ // we can apply limit early at the manifest entry level. This is more
efficient
+ // than waiting until splits are created.
+ //
+ // Reference:
[AppendOnlyFileStoreScan.postFilterManifestEntries](https://github.com/apache/paimon/blob/release-1.3/paimon-core/src/main/java/org/apache/paimon/operation/AppendOnlyFileStoreScan.java#L91)
+ let limit_pushdown_at_manifest_level =
self.table.schema.primary_keys().is_empty()
Review Comment:
Maybe we don't need this. Just do limit in `apply_limit_pushdown`.
##########
crates/paimon/src/table/table_scan.rs:
##########
@@ -246,6 +278,51 @@ impl<'a> TableScan<'a> {
self.plan_snapshot(snapshot).await
}
+ /// Apply a limit-pushdown hint to the generated splits.
+ ///
+ /// Iterates through splits and accumulates `merged_row_count()` until the
+ /// limit hint is reached. Returns only the splits likely needed to satisfy
+ /// that hint.
+ ///
+ /// This does not guarantee an exact final row count. If any split's
+ /// `merged_row_count()` is `None` (for example because of unknown deletion
+ /// cardinality), all remaining splits are kept and the caller or query
Review Comment:
`all remaining splits are kept`?
##########
crates/paimon/src/table/source.rs:
##########
@@ -339,3 +423,60 @@ impl Plan {
&self.splits
}
}
+
+// ======================= Helper Functions ===============================
+
+/// Merges overlapping row ID ranges into groups.
+///
+/// Files are sorted by `(start, end)` of their row ID range, then grouped
+/// by overlapping ranges. Two ranges overlap if `current.start <=
previous_group_end`.
+///
+/// Reference:
[RangeHelper.mergeOverlappingRanges()](https://github.com/apache/paimon/blob/release-1.3/paimon-common/src/main/java/org/apache/paimon/utils/RangeHelper.java#L59)
+fn merge_overlapping_row_id_ranges(files: &[DataFileMeta]) ->
Vec<Vec<&DataFileMeta>> {
Review Comment:
Just reuse `group_by_overlapping_row_id`?
--
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]