Skip to content

Commit

Permalink
[GLUTEN-8520][VL] Fix bitwise operators (#8521)
Browse files Browse the repository at this point in the history
Use bitwise operators only on unsigned operands
  • Loading branch information
jkhaliqi authored Jan 15, 2025
1 parent eec5461 commit 6b92e88
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cpp/core/shuffle/FallbackRangePartitioner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/core/shuffle/HashPartitioner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/core/shuffle/RandomPartitioner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/core/shuffle/RoundRobinPartitioner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
4 changes: 2 additions & 2 deletions cpp/velox/operators/serializer/VeloxRowToColumnarConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 6b92e88

Please sign in to comment.