From 2161895787928a56593857b29e450a641563a031 Mon Sep 17 00:00:00 2001 From: binwei Date: Tue, 10 May 2022 11:33:52 +0800 Subject: [PATCH 1/2] fix bug of validity buffer set --- native-sql-engine/cpp/src/shuffle/splitter.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/native-sql-engine/cpp/src/shuffle/splitter.cc b/native-sql-engine/cpp/src/shuffle/splitter.cc index 9414a0e94..b8057b55d 100644 --- a/native-sql-engine/cpp/src/shuffle/splitter.cc +++ b/native-sql-engine/cpp/src/shuffle/splitter.cc @@ -1424,13 +1424,15 @@ arrow::Status Splitter::SplitFixedWidthValidityBuffer(const arrow::RecordBatch& partition_buffer_dst_offset_[pid]++; } // set the last byte - auto lastoffset = partition_buffer_dst_offset_[pid]; - uint8_t dst = dst_addrs[pid][lastoffset >> 3]; - uint8_t msk = 0x1 << (lastoffset & 0x7); - msk = ~(msk - 1); - msk &= ((lastoffset & 7) == 0) - 1; - dst |= msk; - dst_addrs[pid][lastoffset >> 3] = dst; + for (auto pid = 0; pid < num_partitions_; pid++) { + auto lastoffset = partition_buffer_dst_offset_[pid]; + uint8_t dst = dst_addrs[pid][lastoffset >> 3]; + uint8_t msk = 0x1 << (lastoffset & 0x7); + msk = ~(msk - 1); + msk &= ((lastoffset & 7) == 0) - 1; + dst |= msk; + dst_addrs[pid][lastoffset >> 3] = dst; + } } #else for (auto row = 0; row < num_rows; ++row) { From 0f82bf3e928f635911224f484bb2fe2fdbef24a5 Mon Sep 17 00:00:00 2001 From: binwei Date: Tue, 10 May 2022 12:23:10 +0800 Subject: [PATCH 2/2] fix --- native-sql-engine/cpp/src/shuffle/splitter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native-sql-engine/cpp/src/shuffle/splitter.cc b/native-sql-engine/cpp/src/shuffle/splitter.cc index b8057b55d..51d839f22 100644 --- a/native-sql-engine/cpp/src/shuffle/splitter.cc +++ b/native-sql-engine/cpp/src/shuffle/splitter.cc @@ -1424,7 +1424,7 @@ arrow::Status Splitter::SplitFixedWidthValidityBuffer(const arrow::RecordBatch& partition_buffer_dst_offset_[pid]++; } // set the last byte - for (auto pid = 0; pid < num_partitions_; pid++) { + if (partition_id_cnt_[pid] > 0 && dst_addrs[pid] != nullptr) { auto lastoffset = partition_buffer_dst_offset_[pid]; uint8_t dst = dst_addrs[pid][lastoffset >> 3]; uint8_t msk = 0x1 << (lastoffset & 0x7);