-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
ARROW-1712: [C++] Add method to BinaryBuilder to reserve space for value data #1481
Closed
Closed
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
c2f8dc4
Merge pull request #1 from apache/master
xuepanchen 232024e
Update BinaryBuilder::Resize(int64_t capacity) in builder.cc
xuepanchen d021c54
Merge pull request #2 from xuepanchen/xuepanchen-arrow-1712
xuepanchen 5b73c1c
Update again BinaryBuilder::Resize(int64_t capacity) in builder.cc
xuepanchen 5ebfb32
Add capacity() method for TypedBufferBuilder
xuepanchen e0434e6
Add ReserveData(int64_t) and value_data_capacity() for methods for Bi…
xuepanchen de318f4
Implement ReserveData(int64_t) method for BinaryBuilder
xuepanchen b002e0b
Remove override keyword from ReserveData(int64_t) method for BinaryBu…
xuepanchen 8dd5eaa
Update builder.cc
xuepanchen 9b5e805
Update ReserveData(int64_t) method signature for BinaryBuilder
xuepanchen 5a5593e
Update again ReserveData(int64_t) method for BinaryBuilder
xuepanchen 15e045c
Add test case for array-test.cc
xuepanchen bbc6527
ARROW-1945: [C++] Update test case for BinaryBuild data value space r…
xuepanchen 18f90fb
ARROW-1945: [C++] Add data_capacity_ to track capacity of value data
xuepanchen 0b07895
ARROW-1945: [C++] Add data_capacity_ to track capacity of value data
xuepanchen d3c8202
ARROW-1945: [C++] Fix a small typo
xuepanchen 8e4c892
Merge pull request #3 from xuepanchen/xuepanchen-arrow-1712
xuepanchen 5a5b70e
Merge pull request #4 from apache/master
xuepanchen bc5db7d
ARROW-1712: [C++] Remove unneeded data member in BinaryBuilder and mo…
xuepanchen 77f8f3c
Merge pull request #5 from apache/master
xuepanchen d4bbd15
ARROW-1712: [C++] Modify test case for BinaryBuilder::ReserveData() a…
xuepanchen 360e601
Merge branch 'master' of https://github.com/xuepanchen/arrow
xuepanchen 707b67b
ARROW-1712: [C++] Fix lint errors
xuepanchen 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 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 |
---|---|---|
|
@@ -1154,6 +1154,41 @@ TEST_F(TestBinaryBuilder, TestScalarAppend) { | |
} | ||
} | ||
} | ||
|
||
TEST_F(TestBinaryBuilder, TestCapacityReserve) { | ||
vector<string> strings = {"aaaaa", "bbbbbbbbbb", "ccccccccccccccc", "dddddddddddddddddddd", "eeeeeeeeee"}; | ||
int N = static_cast<int>(strings.size()); | ||
int reps = 10; | ||
int64_t length = 0; | ||
int64_t capacity = 1000; | ||
|
||
ASSERT_OK(builder_->ReserveData(capacity)); | ||
|
||
ASSERT_EQ(length, builder_->value_data_length()); | ||
ASSERT_EQ(BitUtil::RoundUpToMultipleOf64(capacity), builder_->value_data_capacity()); | ||
|
||
for (int j = 0; j < reps; ++j) { | ||
for (int i = 0; i < N; ++i) { | ||
ASSERT_OK(builder_->Append(strings[i])); | ||
length += static_cast<int>(strings[i].size()); | ||
|
||
ASSERT_EQ(length, builder_->value_data_length()); | ||
ASSERT_EQ(BitUtil::RoundUpToMultipleOf64(capacity), builder_->value_data_capacity()); | ||
} | ||
} | ||
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. Can you add another call to ReserveData here, like |
||
|
||
int extra_capacity = 500; | ||
ASSERT_OK(builder_->ReserveData(extra_capacity)); | ||
|
||
ASSERT_EQ(length, builder_->value_data_length()); | ||
ASSERT_EQ(BitUtil::RoundUpToMultipleOf64(length + extra_capacity), builder_->value_data_capacity()); | ||
|
||
Done(); | ||
ASSERT_EQ(reps * N, result_->length()); | ||
ASSERT_EQ(0, result_->null_count()); | ||
ASSERT_EQ(reps * 60, result_->value_data()->size()); | ||
ASSERT_EQ(BitUtil::RoundUpToMultipleOf64(length + extra_capacity), result_->value_data()->capacity()); | ||
} | ||
|
||
TEST_F(TestBinaryBuilder, TestZeroLength) { | ||
// All buffers are null | ||
|
This file contains 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 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 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
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.
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.
These reservations should be viewed as different, because the size of the offsets buffer and the data buffer grow at different rates. The way this unit test should read is:
ReserveData
with enough space for some large-ish amount of data (say 4K bytes or so)ReserveData
made sure that no additional reallocations took place)