orcxx-rs
Rust wrapper for the official C++ library for Apache ORC.
It uses a submodule pointing to an Apache ORC release, builds its C++ part
(including vendored protobuf, lz4, zstd, ...), and links against that,
unless the ORC_USE_SYSTEM_LIBRARIES environment variable is set.
If it is, you need to make sure the dependencies are installed
(apt-get install libprotoc-dev liblz4-dev libsnappy-dev libzstd-dev zlib1g-dev
on Debian-based distributions).
The orcxx_derive crate provides a custom derive macro.
orcxx_derive examples
RowIterator API
extern crate orcxx;
extern crate orcxx_derive;
use NonZeroU64;
use ;
use RowIterator;
use reader;
use OrcDeserialize;
// Define structure
// Open file
let orc_path = "../orcxx/orc/examples/TestOrcFile.test1.orc";
let input_stream = from_local_file.expect;
let reader = new.expect;
let batch_size = new.unwrap;
let mut rows: = new
.expect
.collect;
assert_eq!;
Loop API
RowIterator clones structures before yielding them. This can be avoided by looping
and writing directly to a buffer:
extern crate orcxx;
extern crate orcxx_derive;
use ;
use reader;
use OrcDeserialize;
// Define structure
// Open file
let orc_path = "../orcxx/orc/examples/TestOrcFile.test1.orc";
let input_stream = from_local_file.expect;
let reader = new.expect;
// Only read columns we need
let options = default.include_names;
let mut row_reader = reader.row_reader.expect;
check_kind.expect;
let mut rows: = Vecnew;
// Allocate work buffer
let mut batch = row_reader.row_batch;
// Read structs until the end
while row_reader.read_into
assert_eq!;
Nested structures
The above two examples also work with nested structures:
extern crate orcxx;
extern crate orcxx_derive;
use OrcDeserialize;
orcxx examples
ColumnTree API
Columns can also be read directly without writing their values to structures. This is particularly useful to read files whose schema is not known at compile time.
Low-level API
This reads batches directly from the C++ library, and leaves the Rust code to dynamically cast base vectors to more specific types; here string vectors.
extern crate orcxx;
extern crate orcxx_derive;
use reader;
use ColumnVectorBatch;
let input_stream = from_local_file
.expect;
let reader = new.expect;
println!; // Prints the type of columns in the file
let mut row_reader = reader.row_reader.unwrap;
let mut batch = row_reader.row_batch;
let mut total_elements = 0;
let mut all_strings: = Vecnew;
while row_reader.read_into
assert_eq!;
assert_eq!;