-
Notifications
You must be signed in to change notification settings - Fork 4.1k
GH-45819: [C++] Add OptionalBitmapAnd utility #49848
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
Open
Shockp
wants to merge
8
commits into
apache:main
Choose a base branch
from
Shockp:feat-optional-bitmap-and
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+92
−0
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7b30060
GH-45819: [C++] Implement OptionalBitmapAnd utility
Shockp 1d4e0eb
GH-45819: [C++] Add tests for OptionalBitmapAnd
Shockp 28d69c7
GH-45819: [C++] Fix include path for bitmap_ops.h
Shockp b9e12ac
GH-45819: [C++] Remove redundant header include in bitmap_ops.cc
Shockp cb2ef2c
GH-45819: [C++] Remove redundant header include in bitmap_ops.cc
Shockp 97e64ba
GH-45819: [Testing] Restore testing submodule from main
Shockp 2741418
GH-45819: [C++] Add default value of 0 to out_offset in OptionalBitma…
Shockp c2fcd8d
GH-45819: [C++] Optimize bitmap copying by returning slices when byte…
Shockp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
|
|
||
| #include <gmock/gmock.h> | ||
| #include <gtest/gtest.h> | ||
| #include <cstring> | ||
|
|
||
| #include "arrow/array/array_base.h" | ||
| #include "arrow/array/data.h" | ||
|
|
@@ -1236,6 +1237,45 @@ TEST(BitmapOpTest, PartialLeadingByteSafety) { | |
| } | ||
| } | ||
|
|
||
| TEST(BitmapOpTest, OptionalBitmapAnd) { | ||
| MemoryPool* pool = default_memory_pool(); | ||
| int64_t length = 16; | ||
| int64_t phys_bits = length; | ||
|
|
||
| // Create two distinct test buffers | ||
| ASSERT_OK_AND_ASSIGN(auto buf1, AllocateEmptyBitmap(phys_bits, pool)); | ||
| ASSERT_OK_AND_ASSIGN(auto buf2, AllocateEmptyBitmap(phys_bits, pool)); | ||
|
|
||
| // Fill buf1 with 1s (true) | ||
| std::memset(buf1->mutable_data(), 0xFF, buf1->size()); | ||
| // Fill buf2 with alternating bits 01010101 (0xAA) | ||
| std::memset(buf2->mutable_data(), 0xAA, buf2->size()); | ||
|
|
||
| // State 1: Both nullptr | ||
| ASSERT_OK_AND_ASSIGN(auto result1, | ||
| OptionalBitmapAnd(pool, nullptr, 0, nullptr, 0, length, 0)); | ||
| ASSERT_EQ(result1, nullptr); | ||
|
|
||
| // State 2: Left nullptr, Right valid (Should copy Right) | ||
| ASSERT_OK_AND_ASSIGN(auto result2, | ||
| OptionalBitmapAnd(pool, nullptr, 0, buf2, 0, length, 0)); | ||
| ASSERT_NE(result2, nullptr); | ||
| EXPECT_TRUE(BitmapEquals(buf2->data(), 0, result2->data(), 0, length)); | ||
|
|
||
| // State 3: Left valid, Right nullptr (Should copy Left) | ||
| ASSERT_OK_AND_ASSIGN(auto result3, | ||
| OptionalBitmapAnd(pool, buf1, 0, nullptr, 0, length, 0)); | ||
| ASSERT_NE(result3, nullptr); | ||
| EXPECT_TRUE(BitmapEquals(buf1->data(), 0, result3->data(), 0, length)); | ||
|
|
||
| // State 4: Both valid (Should perform Bitwise AND) | ||
| ASSERT_OK_AND_ASSIGN(auto result4, | ||
| OptionalBitmapAnd(pool, buf1, 0, buf2, 0, length, 0)); | ||
| ASSERT_NE(result4, nullptr); | ||
| // Since buf1 is all 1s, (buf1 AND buf2) should perfectly equal buf2 | ||
|
Member
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. This is an easy case to test, but can we test with inputs where the output is not trivially equal to one of the inputs? |
||
| EXPECT_TRUE(BitmapEquals(buf2->data(), 0, result4->data(), 0, length)); | ||
| } | ||
|
|
||
| // Tests for Bitmap visiting. | ||
|
|
||
| // test the basic assumption of word level Bitmap::Visit | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.