Repository navigation
Defer dictionary page decode on the skip path #11168
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
645a4a1
Defer dictionary page decode on the skip path (#11154)
zhuqi-lucas 021c7bf
Merge branch 'main' into lazy-dict-skip
zhuqi-lucas 57304f9
Update sync_reader I/O snapshots for deferred dictionary reads
zhuqi-lucas 593fc9e
Gate dictionary deferral on page reader support
zhuqi-lucas 9e7dd84
Cover alternating skip/read and half-forwarded page readers
zhuqi-lucas f18aaab
Show the capability gate in the deferral state diagram
zhuqi-lucas 8687610
Merge branch 'main' into lazy-dict-skip
zhuqi-lucas 7ea4a25
Update parquet/src/column/page.rs
zhuqi-lucas 593ece4
Update parquet/src/column/page.rs
zhuqi-lucas 1dc8448
Update parquet/src/column/reader.rs
zhuqi-lucas f100dc7
Update parquet/src/column/reader.rs
zhuqi-lucas 847fab3
Update parquet/src/file/serialized_reader.rs
zhuqi-lucas 2343889
Update parquet/src/file/serialized_reader.rs
zhuqi-lucas f023ca8
Update parquet/src/file/serialized_reader.rs
zhuqi-lucas 273dd06
Update parquet/src/file/serialized_reader.rs
zhuqi-lucas f0ba734
Merge branch 'main' into lazy-dict-skip
zhuqi-lucas d2b1294
Fix the call site the suggestion missed, and rustfmt
zhuqi-lucas 10bfaf5
Merge remote-tracking branch 'upstream/main' into lazy-dict-skip
zhuqi-lucas 7a7b427
Attach the mechanism docs to the method that implements it
zhuqi-lucas 9fad45c
State the deferred-dictionary behaviour rather than the change to it
zhuqi-lucas 4898c36
Merge branch 'main' into lazy-dict-skip
zhuqi-lucas 8843b6a
Merge branch 'main' of https://github.com/apache/arrow-rs into lazy-d…
alamb 118e314
Address review: move the dictionary skip timing into a benchmark
zhuqi-lucas 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 hidden or 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 hidden or 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,99 @@ | ||
| // 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. | ||
|
|
||
| //! Skipping records in a dictionary-encoded column chunk. | ||
| //! | ||
| //! The chunk is shaped like a real serving file: a zstd-compressed BYTE_ARRAY | ||
| //! column whose dictionary holds 40k distinct strings. Skipping the whole | ||
| //! chunk never needs the dictionary; skipping part of it and then reading | ||
| //! does. | ||
|
|
||
| use std::hint; | ||
| use std::sync::Arc; | ||
|
|
||
| use bytes::Bytes; | ||
| use criterion::*; | ||
| use parquet::basic::Compression; | ||
| use parquet::column::reader::ColumnReaderImpl; | ||
| use parquet::data_type::{ByteArray, ByteArrayType}; | ||
| use parquet::file::properties::WriterProperties; | ||
| use parquet::file::reader::{FileReader, SerializedFileReader}; | ||
| use parquet::file::serialized_reader::SerializedPageReader; | ||
| use parquet::file::writer::SerializedFileWriter; | ||
| use parquet::schema::parser::parse_message_type; | ||
|
|
||
| const NUM_ROWS: usize = 80_000; | ||
|
|
||
| fn write_chunk() -> Bytes { | ||
| let schema = | ||
| Arc::new(parse_message_type("message test_schema { REQUIRED BYTE_ARRAY v; }").unwrap()); | ||
| let props = Arc::new( | ||
| WriterProperties::builder() | ||
| .set_compression(Compression::ZSTD(Default::default())) | ||
| .build(), | ||
| ); | ||
| let mut out = Vec::new(); | ||
| let mut writer = SerializedFileWriter::new(&mut out, schema, props).unwrap(); | ||
| let mut row_group = writer.next_row_group().unwrap(); | ||
| let mut column = row_group.next_column().unwrap().unwrap(); | ||
| let values: Vec<ByteArray> = (0..NUM_ROWS as u32) | ||
| .map(|i| ByteArray::from(format!("ticker-{:016}", i / 2).into_bytes())) | ||
| .collect(); | ||
| column | ||
| .typed::<ByteArrayType>() | ||
| .write_batch(&values, None, None) | ||
| .unwrap(); | ||
| column.close().unwrap(); | ||
| row_group.close().unwrap(); | ||
| writer.close().unwrap(); | ||
| Bytes::from(out) | ||
| } | ||
|
|
||
| fn dictionary_skip_benchmark(c: &mut Criterion) { | ||
| let bytes = write_chunk(); | ||
| let reader = SerializedFileReader::new(bytes.clone()).unwrap(); | ||
| let metadata = reader.metadata(); | ||
| let descr = metadata.file_metadata().schema_descr().column(0); | ||
| let column_metadata = metadata.row_group(0).column(0).clone(); | ||
|
|
||
| let new_reader = || { | ||
| let pages = | ||
| SerializedPageReader::new(Arc::new(bytes.clone()), &column_metadata, NUM_ROWS, None) | ||
| .unwrap(); | ||
| ColumnReaderImpl::<ByteArrayType>::new(descr.clone(), Box::new(pages)) | ||
| }; | ||
|
|
||
| let mut group = c.benchmark_group("dictionary_skip"); | ||
| group.bench_function("skip whole chunk", |b| { | ||
| b.iter(|| { | ||
| let mut reader = new_reader(); | ||
| hint::black_box(reader.skip_records(NUM_ROWS).unwrap()) | ||
| }) | ||
| }); | ||
| group.bench_function("skip one record then read", |b| { | ||
| b.iter(|| { | ||
| let mut reader = new_reader(); | ||
| reader.skip_records(1).unwrap(); | ||
| let mut values = Vec::new(); | ||
| hint::black_box(reader.read_records(1, None, None, &mut values).unwrap()) | ||
| }) | ||
| }); | ||
| group.finish(); | ||
| } | ||
|
|
||
| criterion_group!(benches, dictionary_skip_benchmark); | ||
| criterion_main!(benches); |
This file contains hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.