-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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-100: [C++] Computing RowBatch size #61
Changes from all commits
aa48cdf
9b69f12
67af8e1
6b798f8
3484458
253c9f0
e95fc5c
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 |
---|---|---|
|
@@ -195,6 +195,34 @@ INSTANTIATE_TEST_CASE_P(RoundTripTests, TestWriteRowBatch, | |
::testing::Values(&MakeIntRowBatch, &MakeListRowBatch, &MakeNonNullRowBatch, | ||
&MakeZeroLengthRowBatch, &MakeDeeplyNestedList)); | ||
|
||
void TestGetRowBatchSize(std::shared_ptr<RowBatch> batch) { | ||
MockMemorySource mock_source(1 << 16); | ||
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 probably pays to move the verification of GetRowBatchSize to a separate unit test. 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. +1 |
||
int64_t mock_header_location; | ||
int64_t size; | ||
ASSERT_OK(WriteRowBatch(&mock_source, batch.get(), 0, &mock_header_location)); | ||
ASSERT_OK(GetRowBatchSize(batch.get(), &size)); | ||
ASSERT_EQ(mock_source.GetExtentBytesWritten(), size); | ||
} | ||
|
||
TEST_F(TestWriteRowBatch, IntegerGetRowBatchSize) { | ||
std::shared_ptr<RowBatch> batch; | ||
|
||
ASSERT_OK(MakeIntRowBatch(&batch)); | ||
TestGetRowBatchSize(batch); | ||
|
||
ASSERT_OK(MakeListRowBatch(&batch)); | ||
TestGetRowBatchSize(batch); | ||
|
||
ASSERT_OK(MakeZeroLengthRowBatch(&batch)); | ||
TestGetRowBatchSize(batch); | ||
|
||
ASSERT_OK(MakeNonNullRowBatch(&batch)); | ||
TestGetRowBatchSize(batch); | ||
|
||
ASSERT_OK(MakeDeeplyNestedList(&batch)); | ||
TestGetRowBatchSize(batch); | ||
} | ||
|
||
class RecursionLimits : public ::testing::Test, public MemoryMapFixture { | ||
public: | ||
void SetUp() { pool_ = default_memory_pool(); } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,28 @@ class MemoryMappedSource : public MemorySource { | |
std::unique_ptr<Impl> impl_; | ||
}; | ||
|
||
// A MemorySource that tracks the size of allocations from a memory source | ||
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 probably belongs in test-common.h (along with the implementation, I'm not sure if it is worth creating a new .cc file or just inlining) |
||
class MockMemorySource : public MemorySource { | ||
public: | ||
explicit MockMemorySource(int64_t size); | ||
|
||
Status Close() override; | ||
|
||
Status ReadAt(int64_t position, int64_t nbytes, std::shared_ptr<Buffer>* out) override; | ||
|
||
Status Write(int64_t position, const uint8_t* data, int64_t nbytes) override; | ||
|
||
int64_t Size() const override; | ||
|
||
// @return: the smallest number of bytes containing the modified region of the | ||
// MockMemorySource | ||
int64_t GetExtentBytesWritten() const; | ||
|
||
private: | ||
int64_t size_; | ||
int64_t extent_bytes_written_; | ||
}; | ||
|
||
} // namespace ipc | ||
} // namespace arrow | ||
|
||
|
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.
It looks like the
MockMemorySource
is used in the implementation of ofGetTotalSize
. This is OK for now