pitrou commented on code in PR #47294:
URL: https://github.com/apache/arrow/pull/47294#discussion_r2322069610
##########
cpp/src/arrow/util/rle_encoding_test.cc:
##########
@@ -207,12 +209,310 @@ TEST(BitUtil, RoundTripIntValues) {
}
}
+/// A Rle run is a simple class owning some data and a repetition count.
+/// It does not know how to read such data.
+TEST(Rle, RleRun) {
+ const std::array<RleRun::byte, 4> value = {21, 2, 0, 0};
+
+ RleRun::values_count_type value_count = 12;
+
+ // 12 times the value 21 fitting over 5 bits
+ auto const run_5 = RleRun(value.data(), value_count, /* value_bit_width= */
5);
+ EXPECT_EQ(run_5.ValuesCount(), value_count);
+ EXPECT_EQ(run_5.ValuesBitWidth(), 5);
+ EXPECT_EQ(run_5.RawDataSize(), 1); // 5 bits fit in one byte
+ EXPECT_EQ(*run_5.RawDataPtr(), 21);
+
+ // 12 times the value 21 fitting over 16 bits
+ auto const run_8 = RleRun(value.data(), value_count, /* value_bit_width= */
8);
+ EXPECT_EQ(run_8.ValuesCount(), value_count);
+ EXPECT_EQ(run_8.ValuesBitWidth(), 8);
+ EXPECT_EQ(run_8.RawDataSize(), 1); // 8 bits fit in 1 byte
+ EXPECT_EQ(*run_8.RawDataPtr(), 21);
+
+ // 12 times the value {21, 2} fitting over 10 bits
+ auto const run_10 = RleRun(value.data(), value_count, /* value_bit_width= */
10);
+
+ EXPECT_EQ(run_10.ValuesCount(), value_count);
+ EXPECT_EQ(run_10.ValuesBitWidth(), 10);
+ EXPECT_EQ(run_10.RawDataSize(), 2); // 10 bits fit in 2 bytes
+ EXPECT_EQ(*(run_10.RawDataPtr() + 0), 21);
+ EXPECT_EQ(*(run_10.RawDataPtr() + 1), 2);
+
+ // 12 times the value {21, 2} fitting over 32 bits
+ auto const run_32 = RleRun(value.data(), value_count, /* value_bit_width= */
32);
+ EXPECT_EQ(run_32.ValuesCount(), value_count);
+ EXPECT_EQ(run_32.ValuesBitWidth(), 32);
+ EXPECT_EQ(run_32.RawDataSize(), 4); // 32 bits fit in 4 bytes
+ EXPECT_EQ(*(run_32.RawDataPtr() + 0), 21);
+ EXPECT_EQ(*(run_32.RawDataPtr() + 1), 2);
+ EXPECT_EQ(*(run_32.RawDataPtr() + 2), 0);
+ EXPECT_EQ(*(run_32.RawDataPtr() + 3), 0);
+}
+
+/// A BitPacked run is a simple class owning some data and its size.
+/// It does not know how to read such data.
+TEST(BitPacked, BitPackedRun) {
+ const std::array<BitPackedRun::byte, 4> value = {0b10101010, 0, 0,
0b1111111};
+
+ /// 16 values of 1 bit for a total of 16 bits
Review Comment:
Again, let's use `//` for simple comments not `///`
--
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]