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

Function EqualBinaryView

cpp/src/arrow/util/binary_view_util.h:75–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73
74template <typename BufferPtr>
75bool EqualBinaryView(BinaryViewType::c_type l, BinaryViewType::c_type r,
76 const BufferPtr* l_buffers, const BufferPtr* r_buffers) {
77 int64_t l_size_and_prefix, r_size_and_prefix;
78 memcpy(&l_size_and_prefix, &l, sizeof(l_size_and_prefix));
79 memcpy(&r_size_and_prefix, &r, sizeof(r_size_and_prefix));
80
81 if (l_size_and_prefix != r_size_and_prefix) return false;
82
83 if (l.is_inline()) {
84 // The columnar spec mandates that the inlined part be zero-padded, so we can compare
85 // a word at a time regardless of the exact size.
86 int64_t l_inlined, r_inlined;
87 memcpy(&l_inlined, l.inline_data() + BinaryViewType::kPrefixSize, sizeof(l_inlined));
88 memcpy(&r_inlined, r.inline_data() + BinaryViewType::kPrefixSize, sizeof(r_inlined));
89 return l_inlined == r_inlined;
90 }
91
92 // Sizes are equal and this is not inline, therefore both are out
93 // of line and have kPrefixSize first in common.
94 const uint8_t* l_data = l_buffers[l.ref.buffer_index]->data() + l.ref.offset;
95 const uint8_t* r_data = r_buffers[r.ref.buffer_index]->data() + r.ref.offset;
96 return memcmp(l_data + BinaryViewType::kPrefixSize,
97 r_data + BinaryViewType::kPrefixSize,
98 l.size() - BinaryViewType::kPrefixSize) == 0;
99}
100
101/// \brief Compute the total size of a list of binary views including null
102/// views.

Callers 1

VisitMethod · 0.85

Calls 2

dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected