This is an automated email from the ASF dual-hosted git repository.

felixybw pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 6b92e88e0c [GLUTEN-8520][VL] Fix bitwise operators (#8521)
6b92e88e0c is described below

commit 6b92e88e0c0c519dcfde848ece25d35e4fabda3d
Author: jkhaliqi <[email protected]>
AuthorDate: Wed Jan 15 10:34:07 2025 -0800

    [GLUTEN-8520][VL] Fix bitwise operators (#8521)
    
    Use bitwise operators only on unsigned operands
---
 cpp/core/shuffle/FallbackRangePartitioner.cc                  | 2 +-
 cpp/core/shuffle/HashPartitioner.cc                           | 2 +-
 cpp/core/shuffle/RandomPartitioner.cc                         | 2 +-
 cpp/core/shuffle/RoundRobinPartitioner.cc                     | 2 +-
 cpp/velox/operators/serializer/VeloxRowToColumnarConverter.cc | 4 ++--
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/cpp/core/shuffle/FallbackRangePartitioner.cc 
b/cpp/core/shuffle/FallbackRangePartitioner.cc
index 902abbfc29..c76940b563 100644
--- a/cpp/core/shuffle/FallbackRangePartitioner.cc
+++ b/cpp/core/shuffle/FallbackRangePartitioner.cc
@@ -44,7 +44,7 @@ arrow::Status gluten::FallbackRangePartitioner::compute(
   auto index = static_cast<int64_t>(vectorIndex) << 32;
   for (auto i = 0; i < numRows; ++i) {
     auto pid = pidArr[i];
-    int64_t combined = index | (i & 0xFFFFFFFFLL);
+    int64_t combined = index | (static_cast<int64_t>(i) & 0xFFFFFFFFLL);
     auto& vec = rowVectorIndexMap[pid];
     vec.push_back(combined);
     if (pid >= numPartitions_) {
diff --git a/cpp/core/shuffle/HashPartitioner.cc 
b/cpp/core/shuffle/HashPartitioner.cc
index f4b567384b..1f64e567d9 100644
--- a/cpp/core/shuffle/HashPartitioner.cc
+++ b/cpp/core/shuffle/HashPartitioner.cc
@@ -55,7 +55,7 @@ arrow::Status gluten::HashPartitioner::compute(
   auto index = static_cast<int64_t>(vectorIndex) << 32;
   for (auto i = 0; i < numRows; ++i) {
     auto pid = computePid(pidArr, i, numPartitions_);
-    int64_t combined = index | (i & 0xFFFFFFFFLL);
+    int64_t combined = index | (static_cast<int64_t>(i) & 0xFFFFFFFFLL);
     auto& vec = rowVectorIndexMap[pid];
     vec.push_back(combined);
   }
diff --git a/cpp/core/shuffle/RandomPartitioner.cc 
b/cpp/core/shuffle/RandomPartitioner.cc
index 0c08e63258..890125c337 100644
--- a/cpp/core/shuffle/RandomPartitioner.cc
+++ b/cpp/core/shuffle/RandomPartitioner.cc
@@ -35,7 +35,7 @@ arrow::Status gluten::RandomPartitioner::compute(
     std::unordered_map<int32_t, std::vector<int64_t>>& rowVectorIndexMap) {
   auto index = static_cast<int64_t>(vectorIndex) << 32;
   for (int32_t i = 0; i < numRows; ++i) {
-    int64_t combined = index | (i & 0xFFFFFFFFLL);
+    int64_t combined = index | (static_cast<int64_t>(i) & 0xFFFFFFFFLL);
     auto& vec = rowVectorIndexMap[dist_(rng_)];
     vec.push_back(combined);
   }
diff --git a/cpp/core/shuffle/RoundRobinPartitioner.cc 
b/cpp/core/shuffle/RoundRobinPartitioner.cc
index 2e06c421dd..4365e33475 100644
--- a/cpp/core/shuffle/RoundRobinPartitioner.cc
+++ b/cpp/core/shuffle/RoundRobinPartitioner.cc
@@ -38,7 +38,7 @@ arrow::Status gluten::RoundRobinPartitioner::compute(
     std::unordered_map<int32_t, std::vector<int64_t>>& rowVectorIndexMap) {
   auto index = static_cast<int64_t>(vectorIndex) << 32;
   for (int32_t i = 0; i < numRows; ++i) {
-    int64_t combined = index | (i & 0xFFFFFFFFLL);
+    int64_t combined = index | (static_cast<int64_t>(i) & 0xFFFFFFFFLL);
     auto& vec = rowVectorIndexMap[pidSelection_];
     vec.push_back(combined);
     pidSelection_ = (pidSelection_ + 1) % numPartitions_;
diff --git a/cpp/velox/operators/serializer/VeloxRowToColumnarConverter.cc 
b/cpp/velox/operators/serializer/VeloxRowToColumnarConverter.cc
index 19a2bbafd2..1ec043e660 100644
--- a/cpp/velox/operators/serializer/VeloxRowToColumnarConverter.cc
+++ b/cpp/velox/operators/serializer/VeloxRowToColumnarConverter.cc
@@ -33,8 +33,8 @@ inline int64_t getFieldOffset(int64_t nullBitsetWidthInBytes, 
int32_t index) {
 }
 
 inline bool isNull(uint8_t* buffer_address, int32_t index) {
-  int64_t mask = 1L << (index & 0x3f); // mod 64 and shift
-  int64_t wordOffset = (index >> 6) * 8;
+  int64_t mask = 1L << (static_cast<int64_t>(index) & 0x3f); // mod 64 and 
shift
+  int64_t wordOffset = (static_cast<int64_t>(index) >> 6) * 8;
   int64_t value = *((int64_t*)(buffer_address + wordOffset));
   return (value & mask) != 0;
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to