| 73 | |
| 74 | template <typename BufferPtr> |
| 75 | bool 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. |