-
Notifications
You must be signed in to change notification settings - Fork 3.8k
GH-45819: [C++] Add OptionalBitmapAnd utility function #45869
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
base: main
Are you sure you want to change the base?
Changes from all commits
8b92089
e802edf
939255c
0c3a747
1ce9d39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -394,6 +394,31 @@ Result<std::shared_ptr<Buffer>> BitmapOp(MemoryPool* pool, const uint8_t* left, | |
|
||
} // namespace | ||
|
||
Result<std::shared_ptr<Buffer>> OptionalBitmapAnd(MemoryPool* pool, | ||
const std::shared_ptr<Buffer>& left, | ||
int64_t left_offset, | ||
const std::shared_ptr<Buffer>& right, | ||
int64_t right_offset, int64_t length, | ||
int64_t out_offset) { | ||
if (left == nullptr && right == nullptr) { | ||
return nullptr; | ||
} else if (left == nullptr) { | ||
if (right_offset == out_offset) { | ||
return right; | ||
} | ||
Comment on lines
+406
to
+408
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could easily slice the input buffer if both offsets are equal modulo 8. It would avoid copying in slightly more cases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be a dedicated function |
||
return CopyBitmap(pool, right->data(), right_offset, length, out_offset); | ||
} else if (right == nullptr) { | ||
if (left_offset == out_offset) { | ||
return left; | ||
} | ||
return CopyBitmap(pool, left->data(), left_offset, length, out_offset); | ||
} else { | ||
return BitmapOp<std::bit_and>(pool, left->mutable_data(), left_offset, | ||
right->mutable_data(), right_offset, length, | ||
out_offset); | ||
} | ||
} | ||
|
||
Result<std::shared_ptr<Buffer>> BitmapAnd(MemoryPool* pool, const uint8_t* left, | ||
int64_t left_offset, const uint8_t* right, | ||
int64_t right_offset, int64_t length, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is putting too much logic in these test methods. I would suggest something else:
OptionalBitmapAnd
with both non-null arguments like you do here