This is an automated email from the ASF dual-hosted git repository.
rui 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 bb348e8b9b [VL] Change C style casts to C++ style (#8153)
bb348e8b9b is described below
commit bb348e8b9b74eb7c15a57613bfefb657a539ded0
Author: Rui Mo <[email protected]>
AuthorDate: Thu Dec 5 15:31:30 2024 +0800
[VL] Change C style casts to C++ style (#8153)
Follows facebookincubator/velox@28c319e to change C style casts to C++
style.
---
cpp/core/jni/JniWrapper.cc | 4 ++--
cpp/core/utils/Metrics.h | 4 ++--
cpp/velox/compute/WholeStageResultIterator.cc | 4 ++--
cpp/velox/substrait/SubstraitToVeloxPlan.cc | 16 ++++++++++++----
cpp/velox/tests/VeloxSubstraitRoundTripTest.cc | 14 +++++++-------
5 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/cpp/core/jni/JniWrapper.cc b/cpp/core/jni/JniWrapper.cc
index 794ca6b88f..b7bdae8175 100644
--- a/cpp/core/jni/JniWrapper.cc
+++ b/cpp/core/jni/JniWrapper.cc
@@ -475,7 +475,7 @@ JNIEXPORT jobject JNICALL
Java_org_apache_gluten_metrics_IteratorMetricsJniWrapp
}
jlongArray longArray[Metrics::kNum];
- for (auto i = (int)Metrics::kBegin; i != (int)Metrics::kEnd; ++i) {
+ for (auto i = static_cast<int>(Metrics::kBegin); i !=
static_cast<int>(Metrics::kEnd); ++i) {
longArray[i] = env->NewLongArray(numMetrics);
if (metrics) {
env->SetLongArrayRegion(longArray[i], 0, numMetrics,
metrics->get((Metrics::TYPE)i));
@@ -801,7 +801,7 @@ JNIEXPORT jlong JNICALL
Java_org_apache_gluten_vectorized_ShuffleWriterJniWrappe
.bufferSize = bufferSize,
.bufferReallocThreshold = reallocThreshold,
.partitioning = toPartitioning(jStringToCString(env,
partitioningNameJstr)),
- .taskAttemptId = (int64_t)taskAttemptId,
+ .taskAttemptId = static_cast<int64_t>(taskAttemptId),
.startPartitionId = startPartitionId,
.shuffleWriterType = ShuffleWriter::stringToType(jStringToCString(env,
shuffleWriterTypeJstr)),
.sortBufferInitialSize = sortBufferInitialSize,
diff --git a/cpp/core/utils/Metrics.h b/cpp/core/utils/Metrics.h
index 698e97f3dc..8da13bc916 100644
--- a/cpp/core/utils/Metrics.h
+++ b/cpp/core/utils/Metrics.h
@@ -95,8 +95,8 @@ struct Metrics {
Metrics& operator=(Metrics&&) = delete;
long* get(TYPE type) {
- assert((int)type >= (int)kBegin && (int)type < (int)kEnd);
- auto offset = ((int)type - (int)kBegin) * numMetrics;
+ assert(static_cast<int>(type) >= static_cast<int>(kBegin) &&
static_cast<int>(type) < static_cast<int>(kEnd));
+ auto offset = (static_cast<int>(type) - static_cast<int>(kBegin)) *
numMetrics;
return &arrayRawPtr[offset];
}
};
diff --git a/cpp/velox/compute/WholeStageResultIterator.cc
b/cpp/velox/compute/WholeStageResultIterator.cc
index 411c6c5636..e5463b96fd 100644
--- a/cpp/velox/compute/WholeStageResultIterator.cc
+++ b/cpp/velox/compute/WholeStageResultIterator.cc
@@ -478,9 +478,9 @@ std::unordered_map<std::string, std::string>
WholeStageResultIterator::getQueryC
// partial aggregation memory config
auto offHeapMemory = veloxCfg_->get<int64_t>(kSparkTaskOffHeapMemory,
facebook::velox::memory::kMaxMemory);
auto maxPartialAggregationMemory =
- (long)(veloxCfg_->get<double>(kMaxPartialAggregationMemoryRatio,
0.1) * offHeapMemory);
+
static_cast<long>((veloxCfg_->get<double>(kMaxPartialAggregationMemoryRatio,
0.1) * offHeapMemory));
auto maxExtendedPartialAggregationMemory =
-
(long)(veloxCfg_->get<double>(kMaxExtendedPartialAggregationMemoryRatio, 0.15)
* offHeapMemory);
+
static_cast<long>((veloxCfg_->get<double>(kMaxExtendedPartialAggregationMemoryRatio,
0.15) * offHeapMemory));
configs[velox::core::QueryConfig::kMaxPartialAggregationMemory] =
std::to_string(maxPartialAggregationMemory);
configs[velox::core::QueryConfig::kMaxExtendedPartialAggregationMemory] =
std::to_string(maxExtendedPartialAggregationMemory);
diff --git a/cpp/velox/substrait/SubstraitToVeloxPlan.cc
b/cpp/velox/substrait/SubstraitToVeloxPlan.cc
index e0cc5a184b..1e1ab8971e 100644
--- a/cpp/velox/substrait/SubstraitToVeloxPlan.cc
+++ b/cpp/velox/substrait/SubstraitToVeloxPlan.cc
@@ -1023,7 +1023,11 @@ core::PlanNodePtr
SubstraitToVeloxPlanConverter::toVeloxPlan(
// Handle if all sorting keys are also used as partition keys.
return std::make_shared<core::RowNumberNode>(
- nextPlanNodeId(), partitionKeys, rowNumberColumnName,
(int32_t)windowGroupLimitRel.limit(), childNode);
+ nextPlanNodeId(),
+ partitionKeys,
+ rowNumberColumnName,
+ static_cast<int32_t>(windowGroupLimitRel.limit()),
+ childNode);
}
return std::make_shared<core::TopNRowNumberNode>(
@@ -1032,7 +1036,7 @@ core::PlanNodePtr
SubstraitToVeloxPlanConverter::toVeloxPlan(
sortingKeys,
sortingOrders,
rowNumberColumnName,
- (int32_t)windowGroupLimitRel.limit(),
+ static_cast<int32_t>(windowGroupLimitRel.limit()),
childNode);
}
@@ -1122,14 +1126,18 @@ core::PlanNodePtr
SubstraitToVeloxPlanConverter::toVeloxPlan(const ::substrait::
core::PlanNodePtr SubstraitToVeloxPlanConverter::toVeloxPlan(const
::substrait::FetchRel& fetchRel) {
auto childNode = convertSingleInput<::substrait::FetchRel>(fetchRel);
return std::make_shared<core::LimitNode>(
- nextPlanNodeId(), (int32_t)fetchRel.offset(), (int32_t)fetchRel.count(),
false /*isPartial*/, childNode);
+ nextPlanNodeId(),
+ static_cast<int32_t>(fetchRel.offset()),
+ static_cast<int32_t>(fetchRel.count()),
+ false /*isPartial*/,
+ childNode);
}
core::PlanNodePtr SubstraitToVeloxPlanConverter::toVeloxPlan(const
::substrait::TopNRel& topNRel) {
auto childNode = convertSingleInput<::substrait::TopNRel>(topNRel);
auto [sortingKeys, sortingOrders] = processSortField(topNRel.sorts(),
childNode->outputType());
return std::make_shared<core::TopNNode>(
- nextPlanNodeId(), sortingKeys, sortingOrders, (int32_t)topNRel.n(),
false /*isPartial*/, childNode);
+ nextPlanNodeId(), sortingKeys, sortingOrders,
static_cast<int32_t>(topNRel.n()), false /*isPartial*/, childNode);
}
core::PlanNodePtr SubstraitToVeloxPlanConverter::constructValueStreamNode(
diff --git a/cpp/velox/tests/VeloxSubstraitRoundTripTest.cc
b/cpp/velox/tests/VeloxSubstraitRoundTripTest.cc
index 804ba6c413..b675bf4a28 100644
--- a/cpp/velox/tests/VeloxSubstraitRoundTripTest.cc
+++ b/cpp/velox/tests/VeloxSubstraitRoundTripTest.cc
@@ -366,13 +366,13 @@ TEST_F(VeloxSubstraitRoundTripTest, notNullLiteral) {
.addNode([&](std::string id, core::PlanNodePtr input) {
std::vector<std::string> projectNames = {"a", "b", "c",
"d", "e", "f", "g", "h"};
std::vector<core::TypedExprPtr> projectExpressions = {
- makeConstantExpr(BOOLEAN(), (bool)1),
- makeConstantExpr(TINYINT(), (int8_t)23),
- makeConstantExpr(SMALLINT(), (int16_t)45),
- makeConstantExpr(INTEGER(), (int32_t)678),
- makeConstantExpr(BIGINT(), (int64_t)910),
- makeConstantExpr(REAL(), (float)1.23),
- makeConstantExpr(DOUBLE(), (double)4.56),
+ makeConstantExpr(BOOLEAN(), static_cast<bool>(1)),
+ makeConstantExpr(TINYINT(), static_cast<int8_t>(23)),
+ makeConstantExpr(SMALLINT(), static_cast<int16_t>(45)),
+ makeConstantExpr(INTEGER(), static_cast<int32_t>(678)),
+ makeConstantExpr(BIGINT(), static_cast<int64_t>(910)),
+ makeConstantExpr(REAL(), static_cast<float>(1.23)),
+ makeConstantExpr(DOUBLE(), static_cast<double>(4.56)),
makeConstantExpr(VARCHAR(), "789")};
return std::make_shared<core::ProjectNode>(
id, std::move(projectNames),
std::move(projectExpressions), input);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]