MCPcopy Create free account
hub / github.com/apache/arrow / CheckRoundTrip

Function CheckRoundTrip

cpp/src/arrow/util/rle_encoding_test.cc:693–738  ·  view source on GitHub ↗

A version of ValidateRle that round-trips the values and returns false if the returned values are not all the same

Source from the content-addressed store, hash-verified

691// A version of ValidateRle that round-trips the values and returns false if
692// the returned values are not all the same
693bool CheckRoundTrip(const std::vector<int>& values, int bit_width) {
694 const int len = 64 * 1024;
695#ifdef __EMSCRIPTEN__
696 // don't make this on the stack as it is
697 // too big for emscripten
698 std::vector<uint8_t> buffer_vec(static_cast<size_t>(len));
699 uint8_t* buffer = buffer_vec.data();
700#else
701 uint8_t buffer[len];
702#endif
703 RleBitPackedEncoder encoder(buffer, len, bit_width);
704 for (size_t i = 0; i < values.size(); ++i) {
705 bool result = encoder.Put(values[i]);
706 if (!result) {
707 return false;
708 }
709 }
710 int encoded_len = encoder.Flush();
711 int out = 0;
712
713 {
714 RleBitPackedDecoder<int> decoder(buffer, encoded_len, bit_width);
715 for (size_t i = 0; i < values.size(); ++i) {
716 EXPECT_TRUE(decoder.Get(&out));
717 if (values[i] != out) {
718 return false;
719 }
720 }
721 }
722
723 // Verify batch read
724 {
725 RleBitPackedDecoder<int> decoder(buffer, encoded_len, bit_width);
726 std::vector<int> values_read(values.size());
727 if (static_cast<int>(values.size()) !=
728 decoder.GetBatch(values_read.data(), static_cast<int>(values.size()))) {
729 return false;
730 }
731
732 if (values != values_read) {
733 return false;
734 }
735 }
736
737 return true;
738}
739
740TEST(RleBitPacked, SpecificSequences) {
741 const int len = 1024;

Callers 2

TESTFunction · 0.85
TEST_FFunction · 0.85

Calls 15

resizeMethod · 0.80
GetBatchSpacedMethod · 0.80
GetBatchWithDictMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
PutMethod · 0.45
FlushMethod · 0.45
GetMethod · 0.45
GetBatchMethod · 0.45
lengthMethod · 0.45
null_countMethod · 0.45

Tested by

no test coverage detected