benibus commented on code in PR #15194:
URL: https://github.com/apache/arrow/pull/15194#discussion_r1118968927
##########
cpp/src/arrow/ipc/read_write_test.cc:
##########
@@ -735,6 +737,69 @@ TEST_F(TestWriteRecordBatch, WriteWithCompression) {
}
}
+TEST_F(TestWriteRecordBatch, WriteWithCompressionAndMinSavings) {
+ // A small batch that's known to be compressible
+ auto batch = RecordBatchFromJSON(schema({field("n", int64())}), R"([
+ {"n":0},{"n":1},{"n":2},{"n":3},{"n":4},
+ {"n":5},{"n":6},{"n":7},{"n":8},{"n":9}])");
+
+ auto prefixed_size = [](const Buffer& buffer) -> int64_t {
+ if (buffer.size() < int64_t(sizeof(int64_t))) return 0;
+ return
bit_util::FromLittleEndian(util::SafeLoadAs<int64_t>(buffer.data()));
+ };
+ auto content_size = [](const Buffer& buffer) -> int64_t {
+ return buffer.size() - sizeof(int64_t);
Review Comment:
It should be validated by the check in the loop (`ASSERT_GT(compressed_size,
0)`).
Main reason for the check in prefixed_size was because the memory-read could
theoretically yield a positive value even if `buffer.size() < 8` (due to
padding).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]