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

Avoid unnecessary branching in row read/write if schema is null-free #1891

Merged
merged 3 commits into from
Mar 1, 2022

Conversation

yjshen
Copy link
Member

@yjshen yjshen commented Feb 27, 2022

Which issue does this PR close?

Part of #1861

Rationale for this change

We can avoid null bit sets in the row representation and eliminate unnecessary branching during reading/writing, for both space and performance, when the row is null-free according to its schema.

Are there any user-facing changes?

No.

@github-actions github-actions bot added the datafusion Changes in the datafusion crate label Feb 27, 2022
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me @yjshen

datafusion/src/row/mod.rs Outdated Show resolved Hide resolved
datafusion/src/row/mod.rs Outdated Show resolved Hide resolved
datafusion/src/row/mod.rs Show resolved Hide resolved
datafusion/src/row/mod.rs Outdated Show resolved Hide resolved
datafusion/src/row/mod.rs Outdated Show resolved Hide resolved
&[]
} else {
let start = self.base_offset;
&self.data[start..start + self.null_width]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if null_width is always zero, I wonder if the check for self.null_free is needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for not null_free code path. Actually this method shouldn't be touched when tuples are null-free

use arrow::array::*;
use arrow::datatypes::{DataType, Schema};
use arrow::record_batch::RecordBatch;
use arrow::util::bit_util::{ceil, round_upto_power_of_2, set_bit_raw, unset_bit_raw};
#[cfg(feature = "jit")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think over time it would be good to start trying to encapsulate the JIT'd code more (as in reduce the number of #[cfg(feature = "jit")] calls -- perhaps by defining a common interface for creating jit and non jit versions. As I am interested in getting more involved in this project, I would be happy to try and do so (or do it as part of a larger body of work)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that would be great! Thanks for the offering.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see what I can do over the next day or two

@alamb alamb merged commit cc22e17 into apache:master Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datafusion Changes in the datafusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants