Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
fix window sort
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Zhou <[email protected]>
  • Loading branch information
zhouyuan committed Aug 4, 2022
1 parent 3cdd623 commit 2255282
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ static arrow::Status EncodeIndices(std::vector<std::shared_ptr<ArrayItemIndex>>
std::shared_ptr<arrow::Array>* out) {
arrow::UInt64Builder builder;
for (const auto& each : in) {
uint64_t encoded = ((uint64_t)(each->array_id) << 16U) ^ ((uint64_t)(each->id));
uint64_t encoded = ((uint64_t)(each->array_id) << 32U) ^ ((uint64_t)(each->id));
RETURN_NOT_OK(builder.Append(encoded));
}
RETURN_NOT_OK(builder.Finish(out));
Expand All @@ -496,7 +496,7 @@ static arrow::Status DecodeIndices(std::shared_ptr<arrow::Array> in,
std::dynamic_pointer_cast<arrow::UInt64Array>(in);
for (int i = 0; i < selected->length(); i++) {
uint64_t encoded = selected->GetView(i);
uint16_t array_id = (encoded & 0xFFFF0000U) >> 16U;
uint16_t array_id = (encoded & 0xFFFF0000U) >> 32U;
uint16_t id = encoded & 0xFFFFU;
v.push_back(std::make_shared<ArrayItemIndex>(array_id, id));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class TypedSorterImpl : public CodeGenBase {
for (int i = 0; i < selected->length(); i++) {
uint64_t encoded = selected->GetView(i);
uint16_t array_id = (encoded & 0xFFFF0000U) >> 16U;
uint16_t array_id = (encoded & 0xFFFF0000U) >> 32U;
uint16_t id = encoded & 0xFFFFU;
(indices_begin + indices_i)->array_id = array_id;
(indices_begin + indices_i)->id = id;
Expand All @@ -273,7 +273,7 @@ class TypedSorterImpl : public CodeGenBase {
arrow::UInt64Builder builder;
auto *index = (ArrayItemIndexS *) indices_out->value_data();
for (int i = 0; i < indices_out->length(); i++) {
uint64_t encoded = ((uint64_t) (index->array_id) << 16U) ^ ((uint64_t) (index->id));
uint64_t encoded = ((uint64_t) (index->array_id) << 32U) ^ ((uint64_t) (index->id));
RETURN_NOT_OK(builder.Append(encoded));
index++;
}
Expand Down Expand Up @@ -538,7 +538,7 @@ class WindowSortOnekeyKernel : public WindowSortKernel::Impl {
std::dynamic_pointer_cast<arrow::UInt64Array>(in);
for (int i = 0; i < selected->length(); i++) {
uint64_t encoded = selected->GetView(i);
uint16_t array_id = (encoded & 0xFFFF0000U) >> 16U;
uint16_t array_id = (encoded & 0xFFFF0000U) >> 32U;
uint16_t id = encoded & 0xFFFFU;
auto key_clip = cached_key_.at(array_id);
if (key_clip->IsNull(id)) {
Expand All @@ -561,7 +561,7 @@ class WindowSortOnekeyKernel : public WindowSortKernel::Impl {
// we should also support desc and asc here
for (int i = 0; i < selected->length(); i++) {
uint64_t encoded = selected->GetView(i);
uint16_t array_id = (encoded & 0xFFFF0000U) >> 16U;
uint16_t array_id = (encoded & 0xFFFF0000U) >> 32U;
uint16_t id = encoded & 0xFFFFU;
auto key_clip = cached_key_.at(array_id);
if (nulls_first_) {
Expand Down Expand Up @@ -621,7 +621,7 @@ class WindowSortOnekeyKernel : public WindowSortKernel::Impl {
arrow::UInt64Builder builder;
auto* index = (ArrayItemIndexS*)indices_out->value_data();
for (int i = 0; i < indices_out->length(); i++) {
uint64_t encoded = ((uint64_t)(index->array_id) << 16U) ^ ((uint64_t)(index->id));
uint64_t encoded = ((uint64_t)(index->array_id) << 32U) ^ ((uint64_t)(index->id));
RETURN_NOT_OK(builder.Append(encoded));
index++;
}
Expand Down

0 comments on commit 2255282

Please sign in to comment.