-
Notifications
You must be signed in to change notification settings - Fork 822
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
Support Parquet Byte Stream Split Encoding #5293
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
aa72add
wip byte-stream-split
simonvandel a4f98a3
decoding works
simonvandel f260b0b
impl split
simonvandel a83862f
clean up
simonvandel 436f579
whitespace
simonvandel 844e7c3
remove println
mwlon 7f5083b
get compiling after rebase
mwlon 3eea8a7
integration test, as one might call it
mwlon f8a010b
update parquet-testing revision
mwlon 5e2c30c
encoding bench
mwlon 48608d0
improve performance
mwlon fd92ee4
test fix
mwlon 73f23d0
add apache headers
mwlon 08bc944
one more test and readme update
mwlon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
use criterion::*; | ||
use parquet::basic::Encoding; | ||
use parquet::data_type::{DataType, DoubleType, FloatType}; | ||
use parquet::decoding::{get_decoder, Decoder}; | ||
use parquet::encoding::get_encoder; | ||
use parquet::schema::types::{ColumnDescPtr, ColumnDescriptor, ColumnPath, Type}; | ||
use rand::prelude::*; | ||
use std::sync::Arc; | ||
|
||
fn bench_typed<T: DataType>(c: &mut Criterion, values: &[T::T], encoding: Encoding) { | ||
let name = format!( | ||
"dtype={}, encoding={:?}", | ||
std::any::type_name::<T::T>(), | ||
encoding | ||
); | ||
c.bench_function(&format!("encoding: {}", name), |b| { | ||
b.iter(|| { | ||
let mut encoder = get_encoder::<T>(encoding).unwrap(); | ||
encoder.put(values).unwrap(); | ||
encoder.flush_buffer().unwrap(); | ||
}); | ||
}); | ||
|
||
let mut encoder = get_encoder::<T>(encoding).unwrap(); | ||
encoder.put(values).unwrap(); | ||
let encoded = encoder.flush_buffer().unwrap(); | ||
println!("{} encoded as {} bytes", name, encoded.len(),); | ||
|
||
let mut buffer = vec![T::T::default(); values.len()]; | ||
let column_desc_ptr = ColumnDescPtr::new(ColumnDescriptor::new( | ||
Arc::new( | ||
Type::primitive_type_builder("", T::get_physical_type()) | ||
.build() | ||
.unwrap(), | ||
), | ||
0, | ||
0, | ||
ColumnPath::new(vec![]), | ||
)); | ||
c.bench_function(&format!("decoding: {}", name), |b| { | ||
b.iter(|| { | ||
let mut decoder: Box<dyn Decoder<T>> = | ||
get_decoder(column_desc_ptr.clone(), encoding).unwrap(); | ||
decoder.set_data(encoded.clone(), values.len()).unwrap(); | ||
decoder.get(&mut buffer).unwrap(); | ||
}); | ||
}); | ||
} | ||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
let mut rng = StdRng::seed_from_u64(0); | ||
let n = 16 * 1024; | ||
|
||
let mut f32s = Vec::new(); | ||
let mut f64s = Vec::new(); | ||
for _ in 0..n { | ||
f32s.push(rng.gen::<f32>()); | ||
f64s.push(rng.gen::<f64>()); | ||
} | ||
|
||
bench_typed::<FloatType>(c, &f32s, Encoding::BYTE_STREAM_SPLIT); | ||
bench_typed::<DoubleType>(c, &f64s, Encoding::BYTE_STREAM_SPLIT); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably do an exact comparison on a few values as well, given that the file isn't going to change :-)