Repository navigation
feat: puffin Reader and Writer - #676
Conversation
Signed-off-by: Shreyas220 <[email protected]>
Signed-off-by: Shreyas220 <[email protected]>
Signed-off-by: Shreyas220 <[email protected]>
Signed-off-by: Shreyas220 <[email protected]>
|
Hey 👋 @zeroshade , @twuebi would appreciate a review |
zeroshade
left a comment
There was a problem hiding this comment.
Thanks for starting this up! I've been wanting to get a puffin reader/writer in here for a while now. I've gone through with a bunch of questions / requests etc. But this also needs to have some tests and potentially examples if possible!
Thanks again!
Signed-off-by: Shreyas220 <[email protected]>
Signed-off-by: Shreyas220 <[email protected]>
48a86d6 to
cd19142
Compare
Signed-off-by: Shreyas220 <[email protected]>
c54c147 to
3e3ea83
Compare
zeroshade
left a comment
There was a problem hiding this comment.
Just a few remaining comments and then this looks good to me!
Is there any testing repository of existing, known-valid Puffin files that we could create an integration test with?
|
Eagerly waiting for this to add compression support, @Shreyas220 happy to help. |
Signed-off-by: Shreyas220 <[email protected]>
|
Thanks for adding the tests @Shreyas220 can we add a comment in the file saying where the testdata files came from? Also my previous two comments still need a response. Otherwise this looks good! |
Signed-off-by: Shreyas220 <[email protected]>
a2ad794 to
8bb1ac8
Compare
|
@zeroshade resolved the last 2 comments and added a readme in testdata and a comment above the tests in |
zeroshade
left a comment
There was a problem hiding this comment.
Looks good, just one nitpick to address and I'll merge
for apache#589 - Added PuffinWriter - Added PuffinReader - uncompressed only --------- Signed-off-by: Shreyas220 <[email protected]>
Closes apache#996. v3 tables with deletion vectors are now readable end-to-end. Before this change, arrow_scanner.go's GetRecords returned ErrNotImplemen- ted for any task carrying a DV manifest entry, and scan planning paired DVs with their data files but never read the bitmaps. This wires those plans through to the row-filter pipeline. Scanner read path. readAllDeletionVectors mirrors readAllDeleteFiles in shape — concurrent reads via errgroup, returns a perFilePosDeletes map keyed by referenced data file path. A compile-time signature assertion in the test file pins that both loaders share the perFilePosDeletes return type, so the merge in GetRecords (`deletesPerFile[file] = append(...)`) is type-safe by construction. The downstream collapse into a set[int64] inside recordsFromTask / producePosDeletesFromTask absorbs both sources without pipeline changes. Dedup is by referenced-data-file path, not by puffin file path: the spec permits one puffin file to carry multiple DV blobs (one per data file), and keying by the puffin path would silently drop all but the first. The same loop rejects (a) DV entries missing referenced_data_file or content_offset / content_size_in_bytes, (b) two distinct DV blobs (different puffin path OR content offset) targeting the same data file — the latter mirrors Java's DeleteFileIndex "Can't index multiple DVs for %s" ValidationException, since silently unioning two bitmaps is an over-deletion bug. Same-blob dedup across multiple tasks is a no-op (deliberate divergence from Java's stricter rejection — re-reading the same blob is wasteful, not incorrect). Validation runs entirely up front before any goroutine launches. An earlier draft mixed validation into the goroutine-dispatch loop, which created a close-on-closed-channel panic when a bad entry was reached after one or more g.Go calls had dispatched workers still trying to send to the result channel. The current shape — populate uniqueDVs in a serial pre-pass, then fan out — makes that state unreachable by construction. On goroutine error, accumulated *arrow.Chunked values are released before returning, since arrow.NewChunked allocations are not freed by GC alone. bitmapToInt64Chunked materializes a bitmap as a chunked Int64 array via the new dv.RoaringPositionBitmap.Iter() iter.Seq[uint64] method. Lazy iteration avoids the intermediate []uint64 allocation that would double memory pressure for large DVs. The Reserve hint is clamped to math.Max- Int so a 32-bit int build (or a future raised puffin blob-size limit) can't wrap the Cardinality int64 cast to a negative reservation. The int64(p) position cast trusts dv.DeserializeDV as the bytes-to-bitmap boundary — positions ≥ 2^63 would wrap, but the spec bounds positions by the data file's row count, well under that limit. scanner.go: a data file with an applicable DV no longer also has its Parquet position-delete files matched. Spec §Scan Planning predicate "There is no deletion vector that must be applied to the data file" is a precondition for pos-delete application, and Java's DeleteFileIndex. forDataFile enforces it. The gap was latent before this PR because GetRecords errored on DVs; making DVs readable also makes pairing DV+pos-deletes for the same file observable. For spec-compliant tables the set-union absorbs the overlap, but a writer whose DV omits prior pos-delete positions would silently over-delete. dv package: RoaringPositionBitmap gains Iter() (primary, lazy) and ToArray() (convenience wrapper via slices.AppendSeq). The Iter contract is single-goroutine / no-mutation-mid-iteration — the closure captures the bitmap by pointer and roaring.Bitmap doesn't support concurrent Set/Iterator. Tests build a real puffin file via puffin.Writer rather than vendoring fixture bytes, so this PR is independent of apache#1041's golden fixture. Coverage: position decoding and dedup keying by referenced data file, identical-DV dedup across multiple tasks, no-tasks no-op, the four rejection paths (missing referenced_data_file, missing content_offset, multiple distinct DVs for same data file, nil-ref-before-goroutine- dispatch panic regression), and the compile-time signature assertion. TODO(apache#1041) marks the hand-built DV envelope in writeDVPuffinFixture for replacement once that PR exports dv.SerializeDV. End-to-end coverage (DV positions actually filtered out of GetRecords output for a real Parquet data file) is deferred — would need v3 table- metadata scaffolding outside this PR's scope. Several adjacent gaps are also deferred as follow-ups: DV sequence-number guard in PlanFiles (pre-existing from apache#855), tighter ReadDV cardinality validation (pre- existing from apache#866), Puffin reader DV snapshot-id/sequence-number guard (pre-existing from apache#676), and the parallel arrow-leak in readAllDelete- Files (pre-existing).
for #589