This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support to mmap IPC format (#1197)
- Loading branch information
1 parent
4df28c9
commit 5711cfc
Showing
18 changed files
with
1,103 additions
and
80 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,35 @@ | ||
//! Example showing how to memory map an Arrow IPC file into a [`Chunk`]. | ||
use std::sync::Arc; | ||
|
||
use arrow2::error::Result; | ||
use arrow2::io::ipc::read; | ||
use arrow2::mmap::{mmap_dictionaries_unchecked, mmap_unchecked}; | ||
|
||
// Arrow2 requires a struct that implements `Clone + AsRef<[u8]>`, which | ||
// usually `Arc<Mmap>` supports. Here we mock it | ||
#[derive(Clone)] | ||
struct Mmap(Arc<Vec<u8>>); | ||
|
||
impl AsRef<[u8]> for Mmap { | ||
#[inline] | ||
fn as_ref(&self) -> &[u8] { | ||
self.0.as_ref() | ||
} | ||
} | ||
|
||
fn main() -> Result<()> { | ||
// given a mmap | ||
let mmap = Mmap(Arc::new(vec![])); | ||
|
||
// read the metadata | ||
let metadata = read::read_file_metadata(&mut std::io::Cursor::new(mmap.as_ref()))?; | ||
|
||
// mmap the dictionaries | ||
let dictionaries = unsafe { mmap_dictionaries_unchecked(&metadata, mmap.clone())? }; | ||
|
||
// and finally mmap a chunk (0 in this case). | ||
let chunk = unsafe { mmap_unchecked(&metadata, &dictionaries, mmap, 0) }?; | ||
|
||
println!("{chunk:?}"); | ||
Ok(()) | ||
} |
This file contains 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
This file contains 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,10 @@ | ||
# Read Arrow | ||
|
||
When compiled with feature `io_ipc`, this crate can be used to memory map IPC Arrow files | ||
into arrays. | ||
|
||
The example below shows how to memory map an IPC Arrow file into `Chunk`es: | ||
|
||
```rust | ||
{{#include ../../../examples/ipc_file_mmap.rs}} | ||
``` |
This file contains 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
This file contains 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
Oops, something went wrong.