-
Notifications
You must be signed in to change notification settings - Fork 139
feat: puffin Reader and Writer #676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Shreyas220
wants to merge
7
commits into
apache:main
Choose a base branch
from
Shreyas220:feat/puffin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,130
−0
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
744bf10
feat: init puffin
Shreyas220 7f9c6d0
feat: puffin writer
Shreyas220 87c2634
feat: puffin reader
Shreyas220 e563a73
chore: lint fix
Shreyas220 1aa0e7a
chore: hanlding review changes
Shreyas220 91c2a6a
chore: adding test
Shreyas220 3e3ea83
feat: fmt + review comments + tests
Shreyas220 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| // | ||
| // Package puffin provides reading and writing of Puffin files. | ||
| // | ||
| // Puffin is a file format designed to store statistics and indexes | ||
| // for Iceberg tables. A Puffin file contains blobs (opaque byte sequences) | ||
| // with associated metadata, such as Apache DataSketches or deletion vectors. | ||
| // | ||
| // File structure: | ||
| // | ||
| // [Magic] [Blob]* [Magic] [Footer Payload] [Footer Payload Size] [Flags] [Magic] | ||
| // | ||
| // See the specification at https://iceberg.apache.org/puffin-spec/ | ||
| package puffin | ||
|
|
||
| var magic = [4]byte{'P', 'F', 'A', '1'} | ||
|
|
||
| const ( | ||
| //[Magic] [FooterPayload] [FooterPayloadSize] [Flags] [Magic] | ||
| // MagicSize is the number of bytes in the magic marker. | ||
| MagicSize = 4 | ||
|
|
||
| // footerTrailerSize accounts for footer length (4)+ flags (4) + trailing magic (4). | ||
| footerTrailerSize = 12 | ||
|
|
||
| // FooterFlagCompressed indicates a compressed footer; unsupported in this implementation. | ||
| FooterFlagCompressed = 1 // bit 0 | ||
|
|
||
| // Prevents OOM | ||
| // DefaultMaxBlobSize is the maximum blob size allowed when reading (256 MB). | ||
| // Override with WithMaxBlobSize when creating a reader. | ||
| DefaultMaxBlobSize = 256 << 20 | ||
|
|
||
| // CreatedBy is a human-readable identification of the application writing the file, along with its version. | ||
| // Example: "Trino version 381". | ||
| CreatedBy = "created-by" | ||
| ) | ||
|
|
||
| type BlobMetadata struct { | ||
| Type BlobType `json:"type"` | ||
| SnapshotID int64 `json:"snapshot-id"` | ||
| SequenceNumber int64 `json:"sequence-number"` | ||
| Fields []int32 `json:"fields"` | ||
| Offset int64 `json:"offset"` | ||
| Length int64 `json:"length"` | ||
| CompressionCodec *string `json:"compression-codec,omitempty"` | ||
| Properties map[string]string `json:"properties,omitempty"` | ||
| } | ||
|
|
||
| // Footer describes the blobs and file-level properties stored in a Puffin file. | ||
| type Footer struct { | ||
| Blobs []BlobMetadata `json:"blobs"` | ||
| Properties map[string]string `json:"properties,omitempty"` | ||
| } | ||
|
|
||
| type BlobType string | ||
|
|
||
| const ( | ||
| // BlobTypeDataSketchesTheta is a serialized compact Theta sketch | ||
| // produced by the Apache DataSketches library. | ||
| BlobTypeDataSketchesTheta BlobType = "apache-datasketches-theta-v1" | ||
|
|
||
| // BlobTypeDeletionVector is a serialized deletion vector per the | ||
| // Iceberg spec. Requires snapshot-id and sequence-number to be -1. | ||
| BlobTypeDeletionVector BlobType = "deletion-vector-v1" | ||
| ) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.