Skip to content
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

fix: Allow parquet to be compiled without arrow (fix --no-default-features) #731

Merged
merged 4 commits into from
Sep 9, 2021
Merged
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
7 changes: 6 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ jobs:
cargo run --example dynamic_types
cargo run --example read_csv
cargo run --example read_csv_infer_schema
# Exit arrow directory
cd ..
(cd parquet && cargo check --no-default-features)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 Thank you for adding the tests

(cd arrow && cargo check --no-default-features)
(cd arrow-flight && cargo check --no-default-features)

# test the --features "simd" of the arrow crate. This requires nightly.
linux-test-simd:
Expand Down Expand Up @@ -234,7 +239,7 @@ jobs:
run: |
export CARGO_HOME="/github/home/.cargo"
export CARGO_TARGET_DIR="/github/home/target"
cargo clippy --all-targets --workspace -- -D warnings -A clippy::redundant_field_names
cargo clippy --features test_common --all-targets --workspace -- -D warnings -A clippy::redundant_field_names

lint:
name: Lint
Expand Down
3 changes: 2 additions & 1 deletion parquet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ serde_json = { version = "1.0", features = ["preserve_order"] }
[features]
default = ["arrow", "snap", "brotli", "flate2", "lz4", "zstd", "base64"]
cli = ["serde_json", "base64", "clap"]
test_common = []

[[ bin ]]
name = "parquet-read"
Expand All @@ -79,4 +80,4 @@ harness = false

[[bench]]
name = "arrow_array_reader"
harness = false
harness = false
3 changes: 1 addition & 2 deletions parquet/src/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,9 @@ impl AsBytes for str {

pub(crate) mod private {
use crate::encodings::decoding::PlainDecoderDetails;
use crate::util::bit_util::{BitReader, BitWriter};
use crate::util::bit_util::{round_upto_power_of_2, BitReader, BitWriter};
use crate::util::memory::ByteBufferPtr;

use arrow::util::bit_util::round_upto_power_of_2;
use byteorder::ByteOrder;
use std::convert::TryInto;

Expand Down
9 changes: 9 additions & 0 deletions parquet/src/util/bit_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,15 @@ impl From<Vec<u8>> for BitReader {
}
}

/// Returns the nearest multiple of `factor` that is `>=` than `num`. Here `factor` must
/// be a power of 2.
///
/// Copied from the arrow crate to make arrow optional
pub fn round_upto_power_of_2(num: usize, factor: usize) -> usize {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was copied from arrow/src/util/bit_util.rs (which is fine, I am just pointing it out)

debug_assert!(factor > 0 && (factor & (factor - 1)) == 0);
(num + (factor - 1)) & !(factor - 1)
}

#[cfg(test)]
mod tests {
use super::super::test_common::*;
Expand Down
2 changes: 2 additions & 0 deletions parquet/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ pub mod bit_util;
mod bit_packing;
pub mod cursor;
pub mod hash_util;
#[cfg(any(test, feature = "test_common"))]
pub(crate) mod test_common;
#[cfg(any(test, feature = "test_common"))]
pub use self::test_common::page_util::{
DataPageBuilder, DataPageBuilderImpl, InMemoryPageIterator,
};