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

Function CheckRoundTrip

cpp/src/arrow/util/rle_encoding_test.cc:719–764  ·  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

717// A version of ValidateRle that round-trips the values and returns false if
718// the returned values are not all the same
719bool CheckRoundTrip(const std::vector<int>& values, int bit_width) {
720 const int len = 64 * 1024;
721#ifdef __EMSCRIPTEN__
722 // don't make this on the stack as it is
723 // too big for emscripten
724 std::vector<uint8_t> buffer_vec(static_cast<size_t>(len));
725 uint8_t* buffer = buffer_vec.data();
726#else
727 uint8_t buffer[len];
728#endif
729 RleBitPackedEncoder encoder(buffer, len, bit_width);
730 for (size_t i = 0; i < values.size(); ++i) {
731 bool result = encoder.Put(values[i]);
732 if (!result) {
733 return false;
734 }
735 }
736 int encoded_len = encoder.Flush();
737 int out = 0;
738
739 {
740 RleBitPackedDecoder<int> decoder(buffer, encoded_len, bit_width);
741 for (size_t i = 0; i < values.size(); ++i) {
742 EXPECT_TRUE(decoder.Get(&out));
743 if (values[i] != out) {
744 return false;
745 }
746 }
747 }
748
749 // Verify batch read
750 {
751 RleBitPackedDecoder<int> decoder(buffer, encoded_len, bit_width);
752 std::vector<int> values_read(values.size());
753 if (static_cast<int>(values.size()) !=
754 decoder.GetBatch(values_read.data(), static_cast<int>(values.size()))) {
755 return false;
756 }
757
758 if (values != values_read) {
759 return false;
760 }
761 }
762
763 return true;
764}
765
766TEST(RleBitPacked, SpecificSequences) {
767 const int len = 1024;

Callers 3

TESTFunction · 0.85
CheckRoundTripMethod · 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
raw_valuesMethod · 0.45

Tested by

no test coverage detected