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

Function CheckBufferRangeStarts

cpp/src/arrow/util/byte_size_test.cc:147–162  ·  view source on GitHub ↗

We can't validate the buffer addresses exactly because they are unpredictable pointer values. However, when multiple ranges come from the same buffer we can validate that the buffers are the same.

Source from the content-addressed store, hash-verified

145// values. However, when multiple ranges come from the same buffer we can validate that
146// the buffers are the same.
147void CheckBufferRangeStarts(const std::shared_ptr<Array>& starts,
148 const std::vector<ExpectedRange>& expected) {
149 const std::shared_ptr<UInt64Array>& starts_uint64 =
150 checked_pointer_cast<UInt64Array>(starts);
151 std::unordered_map<int, uint64_t> previous_buffer_starts;
152 ASSERT_NE(nullptr, starts_uint64);
153 const uint64_t* starts_data = starts_uint64->raw_values();
154 for (std::size_t i = 0; i < expected.size(); i++) {
155 const auto& previous_buffer_start = previous_buffer_starts.find(expected[i].index);
156 if (previous_buffer_start == previous_buffer_starts.end()) {
157 previous_buffer_starts.insert({expected[i].index, starts_data[i]});
158 } else {
159 ASSERT_EQ(starts_data[i], previous_buffer_start->second);
160 }
161 }
162}
163
164void CheckBufferRanges(const std::shared_ptr<Array>& input,
165 const std::vector<ExpectedRange>& expected) {

Callers 1

CheckBufferRangesFunction · 0.85

Calls 5

raw_valuesMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected