Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zhli1142015 committed Nov 14, 2024
1 parent 39955b0 commit 4c28fa5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions velox/exec/prefixsort/PrefixSortEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class PrefixSortEncoder {
int32_t encodeSize) const {
if (value.has_value()) {
dest[0] = nullsFirst_ ? 1 : 0;
encodeNoNulls(value.value(), dest, encodeSize);
encodeNoNulls(value.value(), dest + 1, encodeSize - 1);
} else {
dest[0] = nullsFirst_ ? 0 : 1;
std::memset(dest + 1, 0, encodeSize - 1);
Expand All @@ -78,15 +78,15 @@ class PrefixSortEncoder {
// 'value' may be stored in non-contiguous allocation pieces in the row
// container, so we need to use 'contiguousString' method to read it out.
auto data = HashStringAllocator::contiguousString(value.value(), storage);
if (data.size() < encodeSize - 1) {
std::memcpy(dest + 1, data.data(), data.size());
std::memset(dest + 1 + data.size(), 0, encodeSize - 1 - data.size());
if (data.size() < encodeSize) {
std::memcpy(dest, data.data(), data.size());
std::memset(dest + data.size(), 0, encodeSize - data.size());
} else {
std::memcpy(dest + 1, data.data(), encodeSize - 1);
std::memcpy(dest, data.data(), encodeSize);
}

if (!ascending_) {
for (auto i = 1; i < encodeSize; ++i) {
for (auto i = 0; i < encodeSize; ++i) {
dest[i] = ~dest[i];
}
}
Expand Down

0 comments on commit 4c28fa5

Please sign in to comment.