Skip to content

Commit

Permalink
Seperate Null and Valid in BooleanKeyEncoder
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU committed Aug 17, 2024
1 parent 49be60f commit 566ce00
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cpp/src/arrow/compute/kernels/row_encoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,19 @@ Status BooleanKeyEncoder::Encode(const ExecValue& data, int64_t batch_length,
});
} else {
const auto& scalar = data.scalar_as<BooleanScalar>();
bool value = scalar.is_valid && scalar.value;
for (int64_t i = 0; i < batch_length; i++) {
auto& encoded_ptr = *encoded_bytes++;
*encoded_ptr++ = kValidByte;
*encoded_ptr++ = value;
if (!scalar.is_valid) {
for (int64_t i = 0; i < batch_length; i++) {
auto& encoded_ptr = *encoded_bytes++;
*encoded_ptr++ = kNullByte;
*encoded_ptr++ = 0;
}
} else {
const bool value = scalar.value;
for (int64_t i = 0; i < batch_length; i++) {
auto& encoded_ptr = *encoded_bytes++;
*encoded_ptr++ = kValidByte;
*encoded_ptr++ = value;
}
}
}
return Status::OK();
Expand Down

0 comments on commit 566ce00

Please sign in to comment.