Skip to content

Commit

Permalink
[tmp] fix nullable bug
Browse files Browse the repository at this point in the history
  • Loading branch information
morningman committed Dec 31, 2023
1 parent 2e99c42 commit 8a836be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 6 additions & 4 deletions be/src/vec/common/hash_table/hash_map_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,14 @@ struct MethodKeysFixed : public MethodBase<TData> {
assert_cast<const ColumnUInt8&>(*nullmap_columns[j]).get_data().data();
for (size_t i = 0; i < row_numbers; ++i) {
// make sure null cell is filled by 0x0
memcpy_fixed<Fixed>((char*)(&result[i]) + offset,
nullmap[i] ? (char*)&zero : data + i * sizeof(Fixed));
memcpy_fixed<Fixed, true>(
(char*)(&result[i]) + offset,
nullmap[i] ? (char*)&zero : data + i * sizeof(Fixed));
}
} else {
for (size_t i = 0; i < row_numbers; ++i) {
memcpy_fixed<Fixed>((char*)(&result[i]) + offset, data + i * sizeof(Fixed));
memcpy_fixed<Fixed, true>((char*)(&result[i]) + offset,
data + i * sizeof(Fixed));
}
}
};
Expand Down Expand Up @@ -476,7 +478,7 @@ struct MethodKeysFixed : public MethodBase<TData> {
auto foo = [&]<typename Fixed>(Fixed zero) {
CHECK_EQ(sizeof(Fixed), size);
for (size_t j = 0; j < num_rows; j++) {
memcpy_fixed<Fixed>(data + j * sizeof(Fixed), (char*)(&keys[j]) + pos);
memcpy_fixed<Fixed, true>(data + j * sizeof(Fixed), (char*)(&keys[j]) + pos);
}
};

Expand Down
9 changes: 7 additions & 2 deletions be/src/vec/common/memcpy_small.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ inline void memcpy_small_allow_read_write_overflow15(void* __restrict dst,

#endif

template <typename T>
// assume input address not aligned by default
template <typename T, bool aligned = false>
void memcpy_fixed(char* lhs, const char* rhs) {
*(T*)lhs = *(T*)rhs;
if constexpr (aligned || sizeof(T) <= 8) {
*(T*)lhs = *(T*)rhs;
} else {
memcpy(lhs, rhs, sizeof(T));
}
}

0 comments on commit 8a836be

Please sign in to comment.