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

Method TestRoundtripAlignment

cpp/src/arrow/util/bpacking_test.cc:110–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108 protected:
109 template <typename Int>
110 void TestRoundtripAlignment(UnpackFunc<Int> unpack, const UnpackOptions& opts) {
111 const auto original =
112 GenerateRandomValuesForPacking<Int>(opts.batch_size, opts.bit_width);
113 const auto packed =
114 PackValues(original, opts.batch_size, opts.bit_width, opts.bit_offset);
115 const auto unpacked = UnpackValues(packed.data(), opts, unpack);
116
117 ASSERT_EQ(unpacked.size(), opts.batch_size);
118 const auto [iter_original, iter_unpacked] =
119 std::mismatch(original.cbegin(), original.cend(), unpacked.cbegin());
120 Int val_original = 0;
121 Int val_unpacked = 0;
122 const auto mismatch_idx = static_cast<std::size_t>(iter_original - original.cbegin());
123 if (mismatch_idx < unpacked.size()) {
124 val_original = *iter_original;
125 val_unpacked = *iter_unpacked;
126 }
127 EXPECT_EQ(original, unpacked) << "At position " << mismatch_idx << "/"
128 << unpacked.size() << ", expected original value "
129 << val_original << " but unpacked " << val_unpacked;
130 }
131
132 template <typename Int>
133 void TestUnpackZeros(UnpackFunc<Int> unpack, const UnpackOptions& opts) {

Callers

nothing calls this directly

Calls 6

PackValuesFunction · 0.85
UnpackValuesFunction · 0.85
cbeginMethod · 0.80
cendMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected