Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions rust/arrow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ chrono = "0.4"
flatbuffers = "0.6"
hex = "0.4"
arrow-flight = { path = "../arrow-flight", optional = true }
prettytable-rs = "0.8.0"
prettytable-rs = { version = "0.8.0", optional = true }

[features]
simd = ["packed_simd"]
flight = ["arrow-flight"]
default = ["flight"]
prettyprint = ["prettytable-rs"]
default = ["flight", "prettyprint"]

[dev-dependencies]
criterion = "0.3"
Expand Down
16 changes: 14 additions & 2 deletions rust/arrow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,25 @@ The above script will run the `flatc` compiler and perform some adjustments to t
## SIMD (Single Instruction Multiple Data)

Arrow uses the [packed_simd](https://crates.io/crates/packed_simd) crate to optimize many of the implementations in the
[compute](https://github.com/apache/arrow/tree/master/rust/arrow/src/compute) module using SIMD intrinsics. These
optimizations are enabled by the `simd` feature flag and are turned on by default, but can be disabled, for example:
[compute](https://github.com/apache/arrow/tree/master/rust/arrow/src/compute) module using SIMD intrinsics.
These optimizations are enabled by the `simd` feature flag and are turned on by default, but can be disabled, for example:

```bash
cargo build --no-default-features
```

For more features, see the Features heading below.

## Features

Arrow uses the following features:

* `simd`
* `flight` which contains useful functions to convert between the Flight wire format and Arrow data
* `prettyprint` which is a utility for printing record batches

`simd` is current disabled by default, while the other features are enabled by default. Disabling `prettyprint` might be necessary in order to compile Arrow to the `wasm32-unknown-unknown` WASM target.

# Publishing to crates.io

An Arrow committer can publish this crate after an official project release has
Expand Down
9 changes: 7 additions & 2 deletions rust/arrow/examples/read_csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use std::sync::Arc;
use arrow::csv;
use arrow::datatypes::{DataType, Field, Schema};
use arrow::error::Result;
#[cfg(feature = "prettyprint")]
use arrow::util::pretty::print_batches;

fn main() -> Result<()> {
Expand All @@ -35,6 +36,10 @@ fn main() -> Result<()> {
let file = File::open("test/data/uk_cities.csv").unwrap();

let mut csv = csv::Reader::new(file, Arc::new(schema), false, None, 1024, None);
let batch = csv.next().unwrap().unwrap();
print_batches(&vec![batch])
let _batch = csv.next().unwrap().unwrap();
#[cfg(feature = "prettyprint")]
{
print_batches(&vec![_batch]).unwrap();
}
Ok(())
}
10 changes: 7 additions & 3 deletions rust/arrow/examples/read_csv_infer_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern crate arrow;

use arrow::csv;
use arrow::error::Result;
#[cfg(feature = "prettyprint")]
use arrow::util::pretty::print_batches;
use std::fs::File;

Expand All @@ -28,7 +29,10 @@ fn main() -> Result<()> {
.has_header(true)
.infer_schema(Some(100));
let mut csv = builder.build(file).unwrap();
let batch = csv.next().unwrap().unwrap();

print_batches(&vec![batch])
let _batch = csv.next().unwrap().unwrap();
#[cfg(feature = "prettyprint")]
{
print_batches(&vec![_batch]).unwrap();
}
Ok(())
}
1 change: 1 addition & 0 deletions rust/arrow/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

pub mod bit_util;
pub mod integration_util;
#[cfg(feature = "prettyprint")]
pub mod pretty;
pub mod string_writer;
pub mod test_util;