From dab6556deec682f8b9393172ea85fd0cefb6f024 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sun, 28 Aug 2022 17:42:48 -0700 Subject: [PATCH] add benchmark --- rust/Cargo.toml | 5 +++++ rust/src/action/parquet2_read/boolean.rs | 14 ++++++------ rust/src/action/parquet2_read/map.rs | 14 ++++++------ rust/src/action/parquet2_read/string.rs | 27 ++++++++++++++---------- 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 47f7ae2e76..1365532a3b 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -147,3 +147,8 @@ tempfile = "3" maplit = { version = "1" } anyhow = "1" rand = "0.8" +criterion = "0" + +[[bench]] +name = "read_checkpoint" +harness = false diff --git a/rust/src/action/parquet2_read/boolean.rs b/rust/src/action/parquet2_read/boolean.rs index 5c7e95733d..553ba36709 100644 --- a/rust/src/action/parquet2_read/boolean.rs +++ b/rust/src/action/parquet2_read/boolean.rs @@ -1,7 +1,6 @@ use parquet2::encoding::hybrid_rle::BitmapIter; use parquet2::metadata::ColumnDescriptor; use parquet2::page::DataPage; -use parquet2::schema::types::PhysicalType; use super::validity::ValidityRowIndexIter; use super::{split_page, ActionVariant, ParseError}; @@ -56,11 +55,14 @@ where SetFn: Fn(&mut ActType, bool), { #[cfg(debug_assertions)] - if page.descriptor.primitive_type.physical_type != PhysicalType::Boolean { - return Err(ParseError::InvalidAction(format!( - "expect physical parquet type boolean, got {:?}", - page.descriptor.primitive_type, - ))); + { + use parquet2::schema::types::PhysicalType; + if page.descriptor.primitive_type.physical_type != PhysicalType::Boolean { + return Err(ParseError::InvalidAction(format!( + "expect physical parquet type boolean, got {:?}", + page.descriptor.primitive_type, + ))); + } } let some_value_iter = SomeBooleanValueIter::try_new(page, descriptor)?; diff --git a/rust/src/action/parquet2_read/map.rs b/rust/src/action/parquet2_read/map.rs index b0b25536e4..e259e43c67 100644 --- a/rust/src/action/parquet2_read/map.rs +++ b/rust/src/action/parquet2_read/map.rs @@ -2,7 +2,6 @@ use parquet2::metadata::ColumnDescriptor; use parquet2::page::{DataPage, DictPage}; -use parquet2::schema::types::PhysicalType; use super::string::for_each_repeated_string_field_value_with_idx; use super::{ActionVariant, ParseError}; @@ -29,11 +28,14 @@ where { debug_assert!(field[0] == "key_value"); #[cfg(debug_assertions)] - if page.descriptor.primitive_type.physical_type != PhysicalType::ByteArray { - return Err(ParseError::InvalidAction(format!( - "expect parquet utf8 type for map key/value, got primitive type: {:?}", - page.descriptor.primitive_type, - ))); + { + use parquet2::schema::types::PhysicalType; + if page.descriptor.primitive_type.physical_type != PhysicalType::ByteArray { + return Err(ParseError::InvalidAction(format!( + "expect parquet utf8 type for map key/value, got primitive type: {:?}", + page.descriptor.primitive_type, + ))); + } } match field[1].as_str() { diff --git a/rust/src/action/parquet2_read/string.rs b/rust/src/action/parquet2_read/string.rs index db5fddac56..1d246bd42a 100644 --- a/rust/src/action/parquet2_read/string.rs +++ b/rust/src/action/parquet2_read/string.rs @@ -4,7 +4,6 @@ use parquet2::encoding::hybrid_rle::HybridRleDecoder; use parquet2::encoding::Encoding; use parquet2::metadata::ColumnDescriptor; use parquet2::page::{DataPage, DictPage}; -use parquet2::schema::types::PhysicalType; use super::dictionary; use super::dictionary::binary::BinaryPageDict; @@ -206,11 +205,14 @@ where MapFn: FnMut(Result<(usize, Vec), ParseError>) -> Result<(), ParseError>, { #[cfg(debug_assertions)] - if page.descriptor.primitive_type.physical_type != PhysicalType::ByteArray { - return Err(ParseError::InvalidAction(format!( - "expect parquet utf8 type, got primitive type: {:?}", - page.descriptor.primitive_type, - ))); + { + use parquet2::schema::types::PhysicalType; + if page.descriptor.primitive_type.physical_type != PhysicalType::ByteArray { + return Err(ParseError::InvalidAction(format!( + "expect parquet utf8 type, got primitive type: {:?}", + page.descriptor.primitive_type, + ))); + } } match page.encoding() { @@ -271,11 +273,14 @@ where SetFn: Fn(&mut ActType, String), { #[cfg(debug_assertions)] - if page.descriptor.primitive_type.physical_type != PhysicalType::ByteArray { - return Err(ParseError::InvalidAction(format!( - "expect parquet utf8 type, got primitive type: {:?}", - page.descriptor.primitive_type, - ))); + { + use parquet2::schema::types::PhysicalType; + if page.descriptor.primitive_type.physical_type != PhysicalType::ByteArray { + return Err(ParseError::InvalidAction(format!( + "expect parquet utf8 type, got primitive type: {:?}", + page.descriptor.primitive_type, + ))); + } } let map_fn = |entry: Result<(usize, String), ParseError>| -> Result<(), ParseError> {