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

Docstrings for public functions, structs, enums #50

Merged
merged 1 commit into from
Mar 16, 2022
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
2 changes: 2 additions & 0 deletions src/arrow1/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use parquet::file::reader::{FileReader, SerializedFileReader};
use parquet::file::serialized_reader::SliceableCursor;
use std::sync::Arc;

/// Internal function to read a buffer with Parquet data into a buffer with Arrow IPC Stream data
/// using the arrow and parquet crates
pub fn read_parquet(parquet_file: &[u8]) -> Result<Vec<u8>, ParquetError> {
// Create Parquet reader
let sliceable_cursor = SliceableCursor::new(Arc::new(parquet_file.to_vec()));
Expand Down
5 changes: 5 additions & 0 deletions src/arrow1/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use crate::utils::copy_vec_to_uint8_array;
use js_sys::Uint8Array;
use wasm_bindgen::prelude::*;

/// Read a Parquet file into a buffer of Arrow data in IPC Stream format, using the arrow and
/// parquet Rust crates.
#[wasm_bindgen(js_name = readParquet)]
pub fn read_parquet(parquet_file: &[u8]) -> Result<Uint8Array, JsValue> {
match crate::arrow1::reader::read_parquet(parquet_file) {
Expand All @@ -10,6 +12,9 @@ pub fn read_parquet(parquet_file: &[u8]) -> Result<Uint8Array, JsValue> {
}
}

/// Write a Parquet file from a buffer of Arrow data in IPC Stream format, using the arrow and
/// parquet Rust crates. Requires a writer_properties argument that can be built from
/// WriterPropertiesBuilder.
#[wasm_bindgen(js_name = writeParquet)]
pub fn write_parquet(
arrow_file: &[u8],
Expand Down
2 changes: 2 additions & 0 deletions src/arrow1/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use parquet::errors::ParquetError;
use parquet::file::writer::InMemoryWriteableCursor;
use std::io::Cursor;

/// Internal function to write a buffer of data in Arrow IPC Stream format to a Parquet file using
/// the arrow and parquet crates
pub fn write_parquet(
arrow_file: &[u8],
writer_properties: crate::arrow1::writer_properties::WriterProperties,
Expand Down
2 changes: 2 additions & 0 deletions src/arrow2/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use arrow2::io::ipc::write::{StreamWriter as IPCStreamWriter, WriteOptions as IP
use arrow2::io::parquet::read::FileReader as ParquetFileReader;
use std::io::Cursor;

/// Internal function to read a buffer with Parquet data into a buffer with Arrow IPC Stream data
/// using the arrow2 and parquet2 crates
pub fn read_parquet(parquet_file: &[u8]) -> Result<Vec<u8>, ArrowError> {
// Create Parquet reader
let input_file = Cursor::new(parquet_file);
Expand Down
5 changes: 5 additions & 0 deletions src/arrow2/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use crate::utils::copy_vec_to_uint8_array;
use js_sys::Uint8Array;
use wasm_bindgen::prelude::*;

/// Read a Parquet file into a buffer of Arrow data in IPC Stream format, using the arrow2 and
/// parquet2 Rust crates.
#[wasm_bindgen(js_name = readParquet2)]
pub fn read_parquet2(parquet_file: &[u8]) -> Result<Uint8Array, JsValue> {
match crate::arrow2::reader::read_parquet(parquet_file) {
Expand All @@ -10,6 +12,9 @@ pub fn read_parquet2(parquet_file: &[u8]) -> Result<Uint8Array, JsValue> {
}
}

/// Write a Parquet file from a buffer of Arrow data in IPC **File** format, using the arrow and
/// parquet Rust crates. Requires a writer_properties argument that can be built from
/// WriterPropertiesBuilder.
#[wasm_bindgen(js_name = writeParquet2)]
pub fn write_parquet2(
arrow_file: &[u8],
Expand Down
2 changes: 2 additions & 0 deletions src/arrow2/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use arrow2::io::ipc::read::{read_file_metadata, FileReader as IPCFileReader};
use arrow2::io::parquet::write::{FileWriter as ParquetFileWriter, RowGroupIterator};
use std::io::Cursor;

/// Internal function to write a buffer of data in Arrow IPC File format to a Parquet file using
/// the arrow2 and parquet2 crates
pub fn write_parquet(
arrow_file: &[u8],
writer_properties: crate::arrow2::writer_properties::WriterProperties,
Expand Down
2 changes: 2 additions & 0 deletions src/arrow2/writer_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl WriterVersion {
}
}

/// Immutable struct to hold writing configuration for writeParquet2
#[wasm_bindgen]
pub struct WriterProperties {
write_options: arrow2::io::parquet::write::WriteOptions,
Expand All @@ -60,6 +61,7 @@ impl WriterProperties {
}
}

/// Builder to create a writing configuration for writeParquet2
#[wasm_bindgen]
pub struct WriterPropertiesBuilder {
write_options: arrow2::io::parquet::write::WriteOptions,
Expand Down
1 change: 1 addition & 0 deletions src/common/writer_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub enum Encoding {
BYTE_STREAM_SPLIT,
}

/// The Parquet version to use when writing
#[allow(non_camel_case_types)]
#[wasm_bindgen]
pub enum WriterVersion {
Expand Down