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

skip reading unused columns #133

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Changes from 2 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
28 changes: 15 additions & 13 deletions src/stripe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use std::collections::HashSet;
use std::{collections::HashMap, io::Read, sync::Arc};

use bytes::Bytes;
Expand Down Expand Up @@ -139,23 +140,23 @@ impl Stripe {
.context(IoSnafu)?;
let footer = Arc::new(deserialize_stripe_footer(footer, compression)?);

let columns = projected_data_type
let columns: Vec<Column> = projected_data_type
.children()
.iter()
.map(|col| Column::new(col.name(), col.data_type(), &footer))
.collect();
let column_ids: HashSet<u32> = columns.iter().map(|c| c.column_id()).collect();

let mut stream_map = HashMap::new();
let mut stream_offset = info.offset();
for stream in &footer.streams {
let length = stream.length();
let column_id = stream.column();
let kind = stream.kind();
let data = Column::read_stream(reader, stream_offset, length)?;

// TODO(weny): filter out unused streams.
stream_map.insert((column_id, kind), data);

if column_ids.contains(&column_id) {
let kind = stream.kind();
let data = Column::read_stream(reader, stream_offset, length)?;
stream_map.insert((column_id, kind), data);
}
stream_offset += length;
}

Expand Down Expand Up @@ -192,22 +193,23 @@ impl Stripe {
.context(IoSnafu)?;
let footer = Arc::new(deserialize_stripe_footer(footer, compression)?);

let columns = projected_data_type
let columns: Vec<Column> = projected_data_type
.children()
.iter()
.map(|col| Column::new(col.name(), col.data_type(), &footer))
.collect();
let column_ids: HashSet<u32> = columns.iter().map(|c| c.column_id()).collect();

let mut stream_map = HashMap::new();
let mut stream_offset = info.offset();
for stream in &footer.streams {
let length = stream.length();
let column_id = stream.column();
let kind = stream.kind();
let data = Column::read_stream_async(reader, stream_offset, length).await?;

// TODO(weny): filter out unused streams.
stream_map.insert((column_id, kind), data);
if column_ids.contains(&column_id) {
let kind = stream.kind();
let data = Column::read_stream_async(reader, stream_offset, length).await?;
stream_map.insert((column_id, kind), data);
}

stream_offset += length;
}
Expand Down
Loading