Skip to content
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
4 changes: 2 additions & 2 deletions parquet/src/arrow/array_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2469,8 +2469,8 @@ mod tests {

#[test]
fn test_complex_array_reader_dict_enc_string() {
use crate::encoding::{DictEncoder, Encoder};
use crate::memory::MemTracker;
use crate::encodings::encoding::{DictEncoder, Encoder};
use crate::util::memory::MemTracker;
// Construct column schema
let message_type = "
message test_schema {
Expand Down
8 changes: 4 additions & 4 deletions parquet/src/arrow/arrow_array_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ use super::array_reader::ArrayReader;
use crate::arrow::schema::parquet_to_arrow_field;
use crate::basic::Encoding;
use crate::data_type::{ByteArray, ByteArrayType};
use crate::decoding::{Decoder, DeltaByteArrayDecoder};
use crate::encodings::decoding::{Decoder, DeltaByteArrayDecoder};
use crate::errors::{ParquetError, Result};
use crate::{
column::page::{Page, PageIterator},
memory::ByteBufferPtr,
schema::types::{ColumnDescPtr, ColumnDescriptor},
util::memory::ByteBufferPtr,
};
use arrow::{
array::{ArrayRef, Int16Array},
Expand Down Expand Up @@ -1263,12 +1263,12 @@ mod tests {
use crate::column::writer::ColumnWriter;
use crate::data_type::ByteArray;
use crate::data_type::ByteArrayType;
use crate::encoding::{DictEncoder, Encoder};
use crate::encodings::encoding::{DictEncoder, Encoder};
use crate::file::properties::WriterProperties;
use crate::file::reader::SerializedFileReader;
use crate::file::serialized_reader::SliceableCursor;
use crate::file::writer::{FileWriter, SerializedFileWriter, TryClone};
use crate::memory::MemTracker;
use crate::util::memory::MemTracker;
use crate::schema::parser::parse_message_type;
use crate::schema::types::SchemaDescriptor;
use crate::util::test_common::page_util::{
Expand Down
7 changes: 4 additions & 3 deletions parquet/src/arrow/arrow_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ use arrow_array::Array;

use super::levels::LevelInfo;
use super::schema::{
add_encoded_arrow_schema_to_metadata, decimal_length_from_precision,
add_encoded_arrow_schema_to_metadata, arrow_to_parquet_schema,
decimal_length_from_precision,
};

use crate::column::writer::ColumnWriter;
Expand Down Expand Up @@ -62,7 +63,7 @@ impl<W: 'static + ParquetWriter> ArrowWriter<W> {
arrow_schema: SchemaRef,
props: Option<WriterProperties>,
) -> Result<Self> {
let schema = crate::arrow::arrow_to_parquet_schema(&arrow_schema)?;
let schema = arrow_to_parquet_schema(&arrow_schema)?;
// add serialized arrow schema
let mut props = props.unwrap_or_else(|| WriterProperties::builder().build());
add_encoded_arrow_schema_to_metadata(&arrow_schema, &mut props);
Expand Down Expand Up @@ -470,7 +471,7 @@ macro_rules! def_get_binary_array_fn {
($name:ident, $ty:ty) => {
fn $name(array: &$ty) -> Vec<ByteArray> {
let mut byte_array = ByteArray::new();
let ptr = crate::memory::ByteBufferPtr::new(
let ptr = crate::util::memory::ByteBufferPtr::new(
unsafe { array.value_data().typed_data::<u8>() }.to_vec(),
);
byte_array.set_data(ptr);
Expand Down
8 changes: 5 additions & 3 deletions parquet/src/arrow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,19 @@
//! ```

experimental_mod!(array_reader);
pub mod arrow_array_reader;
experimental_mod!(arrow_array_reader);
pub mod arrow_reader;
pub mod arrow_writer;
pub mod converter;
experimental_mod!(converter);
pub(in crate::arrow) mod levels;
pub(in crate::arrow) mod record_reader;
pub mod schema;
experimental_mod!(schema);

pub use self::arrow_reader::ArrowReader;
pub use self::arrow_reader::ParquetFileArrowReader;
pub use self::arrow_writer::ArrowWriter;

#[cfg(feature = "experimental")]
pub use self::schema::{
arrow_to_parquet_schema, parquet_to_arrow_schema, parquet_to_arrow_schema_by_columns,
parquet_to_arrow_schema_by_root_columns,
Expand Down
44 changes: 24 additions & 20 deletions parquet/src/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,30 @@
//! See [`Compression`](crate::basic::Compression) enum for all available compression
//! algorithms.
//!
//! # Example
//!
//! ```no_run
//! use parquet::{basic::Compression, compression::create_codec};
//!
//! let mut codec = match create_codec(Compression::SNAPPY) {
//! Ok(Some(codec)) => codec,
//! _ => panic!(),
//! };
//!
//! let data = vec![b'p', b'a', b'r', b'q', b'u', b'e', b't'];
//! let mut compressed = vec![];
//! codec.compress(&data[..], &mut compressed).unwrap();
//!
//! let mut output = vec![];
//! codec.decompress(&compressed[..], &mut output).unwrap();
//!
//! assert_eq!(output, data);
//! ```
#[cfg_attr(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is necessary because without the experimental feature this will fail to compile complaining about compression being private.

FWIW this module is never documented now, but I opted to preserve the test.

You can see it running with:

$ cargo test --all-features --doc
    Finished test [unoptimized + debuginfo] target(s) in 0.04s
   Doc-tests parquet

running 19 tests
test src/arrow/array_reader.rs - arrow::array_reader::StructArrayReader::next_batch (line 1092) ... ignored
test src/arrow/array_reader.rs - arrow::array_reader::StructArrayReader::next_batch (line 1098) ... ignored
test src/arrow/array_reader.rs - arrow::array_reader::StructArrayReader::next_batch (line 1103) ... ignored
test src/file/mod.rs - file (line 64) - compile ... ok
test src/compression.rs - compression::CodecType (line 27) - compile ... ok
test src/file/mod.rs - file (line 29) - compile ... ok
test src/file/mod.rs - file (line 81) - compile ... ok
test src/record/api.rs - record::api::Row::get_column_iter (line 62) - compile ... ok
test src/column/mod.rs - column (line 38) - compile ... ok
test src/file/properties.rs - file::properties (line 22) ... ok
test src/schema/types.rs - schema::types::ColumnPath::append (line 674) ... ok
test src/arrow/mod.rs - arrow (line 58) ... ok
test src/schema/types.rs - schema::types::ColumnPath::string (line 663) ... ok
test src/schema/mod.rs - schema (line 22) ... ok
test src/schema/printer.rs - schema::printer (line 23) ... ok
test src/schema/parser.rs - schema::parser (line 24) ... ok
test src/file/statistics.rs - file::statistics (line 23) ... ok
test src/arrow/mod.rs - arrow (line 25) ... ok
test src/arrow/mod.rs - arrow (line 71) ... ok

test result: ok. 16 passed; 0 failed; 3 ignored; 0 measured; 0 filtered out; finished in 3.12s

feature = "experimental",
doc = r##"
# Example
```no_run
use parquet::{basic::Compression, compression::create_codec};
let mut codec = match create_codec(Compression::SNAPPY) {
Ok(Some(codec)) => codec,
_ => panic!(),
};
let data = vec![b'p', b'a', b'r', b'q', b'u', b'e', b't'];
let mut compressed = vec![];
codec.compress(&data[..], &mut compressed).unwrap();
let mut output = vec![];
codec.decompress(&compressed[..], &mut output).unwrap();
assert_eq!(output, data);
```
"##
)]
use crate::basic::Compression as CodecType;
use crate::errors::{ParquetError, Result};

Expand Down
2 changes: 1 addition & 1 deletion parquet/src/encodings/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ mod tests {

use std::sync::Arc;

use crate::decoding::{get_decoder, Decoder, DictDecoder, PlainDecoder};
use crate::encodings::decoding::{get_decoder, Decoder, DictDecoder, PlainDecoder};
use crate::schema::types::{
ColumnDescPtr, ColumnDescriptor, ColumnPath, Type as SchemaType,
};
Expand Down
17 changes: 11 additions & 6 deletions parquet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,36 @@
///
/// Experimental modules have no stability guarantees
macro_rules! experimental_mod {
($module:ident) => {
($module:ident $(, #[$meta:meta])*) => {
#[cfg(feature = "experimental")]
#[doc(hidden)]
$(#[$meta])*
pub mod $module;
#[cfg(not(feature = "experimental"))]
$(#[$meta])*
mod $module;
};
}

#[macro_use]
pub mod errors;
pub mod basic;
#[macro_use]
pub mod data_type;
experimental_mod!(data_type, #[macro_use]);

// Exported for external use, such as benchmarks
#[cfg(feature = "experimental")]
#[doc(hidden)]
pub use self::encodings::{decoding, encoding};

#[cfg(feature = "experimental")]
#[doc(hidden)]
pub use self::util::memory;

#[macro_use]
pub mod util;
experimental_mod!(util, #[macro_use]);
#[cfg(any(feature = "arrow", test))]
pub mod arrow;
pub mod column;
pub mod compression;
experimental_mod!(compression);
mod encodings;
pub mod file;
pub mod record;
Expand Down