-
Notifications
You must be signed in to change notification settings - Fork 11
Add arrow-ipc Array -> Byes codec #41
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
rabernat
wants to merge
1
commit into
zarr-developers:main
Choose a base branch
from
rabernat:codecs/arrow-ipc
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.
Open
Changes from all commits
Commits
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,50 @@ | ||
| # Arrow IPC Codec | ||
|
|
||
| Defines and `array -> bytes` that serializes arrays into the [Arrow IPC format](https://arrow.apache.org/docs/format/IPC.html). | ||
| This codec can be used in place of the standard `Bytes` codec with any data type which can be safely interpreted as an [Arrow Data Type](https://arrow.apache.org/docs/python/api/datatypes.html). | ||
|
|
||
| ## Codec name | ||
|
|
||
| The value of the `name` member in the codec object MUST be `arrow-ipc`. | ||
|
|
||
| ## Configuration parameters | ||
|
|
||
| - `column_name`: the name of column used for generating an Arrow record batch from the Zarr array data. Implementations SHOULD use the name of the Zarr array here. | ||
|
|
||
| ## Example | ||
|
|
||
| ```json | ||
| { | ||
| "codecs": [{ | ||
| "name": "arrow-ipc", | ||
| "configuration": {"column_name": "temperature"} | ||
| }], | ||
| } | ||
| ``` | ||
|
|
||
| ## Format and algorithm | ||
|
|
||
| This is a `array -> bytes` codec. | ||
|
|
||
| The codec encodes each Zarr chunk as a standalone Arrow IPC Stream containing a single Record Batch with a single Column. | ||
|
|
||
| The encoding process is as follows. For each chunk input array: | ||
|
|
||
| 1. Flatten the array to a 1D array using C ordering. | ||
| 1. Interpret the 1D array as an Arrow Array. | ||
| 1. Wrap the Arrow Array in an Arrow Table with a single column, using the `column_name` configuration parameter to define the name of the column. | ||
| 1. Write the Arrow Table to an in-memory buffer as an Arrow IPC Stream. | ||
|
|
||
| For the decoding process, this is reversed: | ||
| 1. Read a the bytes as an Arrow IPC Stream, reading only a single Record Batch. | ||
| 1. Extract the Arrow Array column identified by `column_name`. | ||
| 1. Interpret this 1D Arrow Array as a slice of a Zarr Array using an appropriate Zarr Data Type. | ||
| 1. Reshape the array according to the chunk shape assuming C ordering of the items. | ||
|
|
||
| ## Change log | ||
|
|
||
| No changes yet. | ||
|
|
||
| ## Current maintainers | ||
|
|
||
| * [Ryan Abernathey](https://github.com/rabernat) | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why should implementations use the name of the array here? an array only gets a name when its stored, so IMO it might be better to recommend a default that can be determined purely from information available when creating array metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, deciding on the "name" of the array would depend on various heuristics depending on how it is stored. It might be simpler to eliminate this parameter altogether and always use a fixed name like
data.