Skip to content

ARROW-18342: [C++] AsofJoinNode support for Boolean data field #14658

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 2 commits into from
Nov 17, 2022

Conversation

rtpsw
Copy link
Contributor

@rtpsw rtpsw commented Nov 16, 2022

@github-actions
Copy link

Copy link
Member

@wjones127 wjones127 left a comment

Choose a reason for hiding this comment

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

I have two suggestions, but looks good so far.

Comment on lines 679 to 687
template <class Type, class Builder = typename TypeTraits<Type>::BuilderType>
enable_if_t<is_fixed_width_type<Type>::value && !is_boolean_type<Type>::value,
Status> static BuilderAppend(Builder& builder,
const std::shared_ptr<ArrayData>& source,
row_index_t row) {
if (source->IsNull(row)) {
builder.UnsafeAppendNull();
return Status::OK();
}
Copy link
Member

Choose a reason for hiding this comment

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

One pattern we've been moving to in the code base is using constexpr conditions:

Suggested change
template <class Type, class Builder = typename TypeTraits<Type>::BuilderType>
enable_if_t<is_fixed_width_type<Type>::value && !is_boolean_type<Type>::value,
Status> static BuilderAppend(Builder& builder,
const std::shared_ptr<ArrayData>& source,
row_index_t row) {
if (source->IsNull(row)) {
builder.UnsafeAppendNull();
return Status::OK();
}
template <class Type, class Builder = typename TypeTraits<Type>::BuilderType>
enable_if_fixed_width_type<Type, Status> static BuilderAppend(Builder& builder,
const std::shared_ptr<ArrayData>& source,
row_index_t row) {
if (source->IsNull(row)) {
builder.UnsafeAppendNull();
return Status::OK();
}
if constexpr (is_boolean_type<Type>::value) {
builder.UnsafeAppend(bit_util::GetBit(source->template GetValues<uint8_t>(1), row));
} else {
using CType = typename TypeTraits<Type>::CType;
builder.UnsafeAppend(source->template GetValues<CType>(1)[row]);
}

(Note this suggestion is incomplete, since GitHub limits which lines I can diff.)

@@ -83,6 +85,7 @@ Result<BatchesWithSchema> MakeBatchesFromNumString(
batches.schema = schema;
int n_fields = schema->num_fields();
for (auto num_batch : num_batches.batches) {
Datum two(ConstantArrayGenerator::Int32(num_batch.length, 2));
Copy link
Member

Choose a reason for hiding this comment

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

Why not a scalar here? (and remove #include "arrow/testing/generator.h" above)

Suggested change
Datum two(ConstantArrayGenerator::Int32(num_batch.length, 2));
Datum two(Int32Scalar(2));

Comment on lines +103 to +106
ARROW_ASSIGN_OR_RAISE(Datum div_two, Divide(num_batch.values[i], two));
ARROW_ASSIGN_OR_RAISE(Datum rounded, Multiply(div_two, two));
ARROW_ASSIGN_OR_RAISE(Datum low_bit, Subtract(num_batch.values[i], rounded));
ARROW_ASSIGN_OR_RAISE(Datum as_bool, Cast(low_bit, type));
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, we have a bit_wise_and kernel but I don't think there is a C++ helper function (e.g. BitWiseAnd) wrapping it. This is probably fine.

@westonpace westonpace merged commit 84c9ac7 into apache:master Nov 17, 2022
@ursabot
Copy link

ursabot commented Nov 18, 2022

Benchmark runs are scheduled for baseline = 6697826 and contender = 84c9ac7. 84c9ac7 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Failed ⬇️0.37% ⬆️0.03%] test-mac-arm
[Failed ⬇️0.0% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.35% ⬆️0.14%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] 84c9ac73 ec2-t3-xlarge-us-east-2
[Failed] 84c9ac73 test-mac-arm
[Failed] 84c9ac73 ursa-i9-9960x
[Finished] 84c9ac73 ursa-thinkcentre-m75q
[Finished] 66978267 ec2-t3-xlarge-us-east-2
[Failed] 66978267 test-mac-arm
[Failed] 66978267 ursa-i9-9960x
[Finished] 66978267 ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants