diff --git a/presto-native-execution/presto_cpp/main/PeriodicTaskManager.cpp b/presto-native-execution/presto_cpp/main/PeriodicTaskManager.cpp index c27cb5f44f8a..00b78e2b7032 100644 --- a/presto-native-execution/presto_cpp/main/PeriodicTaskManager.cpp +++ b/presto-native-execution/presto_cpp/main/PeriodicTaskManager.cpp @@ -428,15 +428,15 @@ void PeriodicTaskManager::updateOperatingSystemStats() { getrusage(RUSAGE_SELF, &usage); const int64_t userCpuTimeUs{ - (int64_t)usage.ru_utime.tv_sec * 1'000'000 + - (int64_t)usage.ru_utime.tv_usec}; + static_cast(usage.ru_utime.tv_sec) * 1'000'000 + + static_cast(usage.ru_utime.tv_usec)}; RECORD_METRIC_VALUE( kCounterOsUserCpuTimeMicros, userCpuTimeUs - lastUserCpuTimeUs_); lastUserCpuTimeUs_ = userCpuTimeUs; const int64_t systemCpuTimeUs{ - (int64_t)usage.ru_stime.tv_sec * 1'000'000 + - (int64_t)usage.ru_stime.tv_usec}; + static_cast(usage.ru_stime.tv_sec) * 1'000'000 + + static_cast(usage.ru_stime.tv_usec)}; RECORD_METRIC_VALUE( kCounterOsSystemCpuTimeMicros, systemCpuTimeUs - lastSystemCpuTimeUs_); lastSystemCpuTimeUs_ = systemCpuTimeUs; diff --git a/presto-native-execution/presto_cpp/main/PrestoExchangeSource.cpp b/presto-native-execution/presto_cpp/main/PrestoExchangeSource.cpp index aa7c1a798586..11b878105364 100644 --- a/presto-native-execution/presto_cpp/main/PrestoExchangeSource.cpp +++ b/presto-native-execution/presto_cpp/main/PrestoExchangeSource.cpp @@ -58,7 +58,8 @@ std::string bodyAsString( std::ostringstream oss; auto iobufs = response.consumeBody(); for (auto& body : iobufs) { - oss << std::string((const char*)body->data(), body->length()); + oss << std::string( + reinterpret_cast(body->data()), body->length()); if (pool != nullptr) { pool->free(body->writableData(), body->capacity()); } diff --git a/presto-native-execution/presto_cpp/main/common/Utils.cpp b/presto-native-execution/presto_cpp/main/common/Utils.cpp index 9c9f77d25394..bc4b9ce63a92 100644 --- a/presto-native-execution/presto_cpp/main/common/Utils.cpp +++ b/presto-native-execution/presto_cpp/main/common/Utils.cpp @@ -69,7 +69,8 @@ std::string extractMessageBody( // TODO Avoid copy std::ostringstream oss; for (auto& buf : body) { - oss << std::string((const char*)buf->data(), buf->length()); + oss << std::string( + reinterpret_cast(buf->data()), buf->length()); } return oss.str(); } diff --git a/presto-native-execution/presto_cpp/main/http/HttpServer.cpp b/presto-native-execution/presto_cpp/main/http/HttpServer.cpp index 04bc6288e25d..64bb555b157c 100644 --- a/presto-native-execution/presto_cpp/main/http/HttpServer.cpp +++ b/presto-native-execution/presto_cpp/main/http/HttpServer.cpp @@ -276,8 +276,8 @@ void HttpServer::start( options.handlerFactories = handlerFactories.build(); // Increase the default flow control to 1MB/10MB - options.initialReceiveWindow = uint32_t(1 << 20); - options.receiveStreamWindowSize = uint32_t(1 << 20); + options.initialReceiveWindow = static_cast(1 << 20); + options.receiveStreamWindowSize = static_cast(1 << 20); options.receiveSessionWindowSize = 10 * (1 << 20); options.h2cEnabled = true; diff --git a/presto-native-execution/presto_cpp/main/operators/tests/BroadcastTest.cpp b/presto-native-execution/presto_cpp/main/operators/tests/BroadcastTest.cpp index 0973a8359c0b..6b54b58f0202 100644 --- a/presto-native-execution/presto_cpp/main/operators/tests/BroadcastTest.cpp +++ b/presto-native-execution/presto_cpp/main/operators/tests/BroadcastTest.cpp @@ -206,7 +206,9 @@ class BroadcastTest : public exec::test::OperatorTestBase { std::vector ranges; for (const auto& range : *ioBuf) { ranges.emplace_back(ByteRange{ - const_cast(range.data()), (int32_t)range.size(), 0}); + const_cast(range.data()), + static_cast(range.size()), + 0}); } auto byteStream = std::make_unique(std::move(ranges)); diff --git a/presto-native-execution/presto_cpp/main/runtime-metrics/PrometheusStatsReporter.cpp b/presto-native-execution/presto_cpp/main/runtime-metrics/PrometheusStatsReporter.cpp index 30e361a6bc4d..6ed3ea7c3959 100644 --- a/presto-native-execution/presto_cpp/main/runtime-metrics/PrometheusStatsReporter.cpp +++ b/presto-native-execution/presto_cpp/main/runtime-metrics/PrometheusStatsReporter.cpp @@ -133,8 +133,8 @@ void PrometheusStatsReporter::registerHistogramMetricExportType( .Register(*impl_->registry); ::prometheus::Summary::Quantiles quantiles; for (auto pct : pcts) { - quantiles.push_back( - ::prometheus::detail::CKMSQuantiles::Quantile(pct / (double)100, 0)); + quantiles.push_back(::prometheus::detail::CKMSQuantiles::Quantile( + pct / static_cast(100), 0)); } auto& summaryMetric = summaryFamily.Add({impl_->labels}, quantiles); registeredMetricsMap_.emplace( diff --git a/presto-native-execution/presto_cpp/main/tests/QueryContextCacheTest.cpp b/presto-native-execution/presto_cpp/main/tests/QueryContextCacheTest.cpp index 2d0821e8568c..f45d6d4f8e38 100644 --- a/presto-native-execution/presto_cpp/main/tests/QueryContextCacheTest.cpp +++ b/presto-native-execution/presto_cpp/main/tests/QueryContextCacheTest.cpp @@ -55,7 +55,7 @@ TEST_F(QueryContextCacheTest, basic) { for (int i = 0; i < 16; ++i) { auto queryId = fmt::format("query-{}", i); auto queryCtx = core::QueryCtx::create( - (folly::Executor*)nullptr, core::QueryConfig({})); + static_cast(nullptr), core::QueryConfig({})); queryCtxs[queryId] = queryCtx; queryContextCache.insert(queryId, queryCtx); } diff --git a/presto-native-execution/presto_cpp/main/tests/TaskManagerTest.cpp b/presto-native-execution/presto_cpp/main/tests/TaskManagerTest.cpp index 43190f2e5c03..46c17378d888 100644 --- a/presto-native-execution/presto_cpp/main/tests/TaskManagerTest.cpp +++ b/presto-native-execution/presto_cpp/main/tests/TaskManagerTest.cpp @@ -156,7 +156,9 @@ class Cursor { std::vector byteRanges; for (auto& range : *buffer) { byteRanges.emplace_back(ByteRange{ - const_cast(range.data()), (int32_t)range.size(), 0}); + const_cast(range.data()), + static_cast(range.size()), + 0}); } const auto input = diff --git a/presto-native-execution/presto_cpp/main/thrift/ProtocolToThrift.cpp b/presto-native-execution/presto_cpp/main/thrift/ProtocolToThrift.cpp index 6875d2fb2032..8a08fe121677 100644 --- a/presto-native-execution/presto_cpp/main/thrift/ProtocolToThrift.cpp +++ b/presto-native-execution/presto_cpp/main/thrift/ProtocolToThrift.cpp @@ -65,10 +65,10 @@ void toThrift(const std::vector

& p, std::vector& t) { } void toThrift(const protocol::TaskState& proto, thrift::TaskState& thrift) { - thrift = (thrift::TaskState)((int)proto); + thrift = static_cast(static_cast(proto)); } void toThrift(const protocol::ErrorType& proto, thrift::ErrorType& thrift) { - thrift = (thrift::ErrorType)((int)proto); + thrift = static_cast(static_cast(proto)); } void toThrift(const protocol::Lifespan& proto, thrift::Lifespan& thrift) { toThrift(proto.isgroup, *thrift.grouped_ref()); diff --git a/presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.cpp b/presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.cpp index ce4e2fb32280..71f2bffb27b8 100644 --- a/presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.cpp +++ b/presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.cpp @@ -79,7 +79,7 @@ RowTypePtr toRowType( template std::string toJsonString(const T& value) { - return ((json)value).dump(); + return (static_cast(value)).dump(); } std::shared_ptr toColumnHandle( @@ -1736,7 +1736,8 @@ core::ExecutionStrategy toStrategy(protocol::StageExecutionStrategy strategy) { "RECOVERABLE_GROUPED_EXECUTION " "Stage Execution Strategy is not supported"); } - VELOX_UNSUPPORTED("Unknown Stage Execution Strategy type {}", (int)strategy); + VELOX_UNSUPPORTED( + "Unknown Stage Execution Strategy type {}", static_cast(strategy)); } // Presto doesn't have PartitionedOutputNode and assigns its source node's plan diff --git a/presto-native-execution/presto_cpp/presto_protocol/Base64Util.cpp b/presto-native-execution/presto_cpp/presto_protocol/Base64Util.cpp index 4dbaa20d3ec2..27bcd5057336 100644 --- a/presto-native-execution/presto_cpp/presto_protocol/Base64Util.cpp +++ b/presto-native-execution/presto_cpp/presto_protocol/Base64Util.cpp @@ -22,7 +22,7 @@ namespace { std::unique_ptr toByteStream(const std::string& input) { ByteRange byteRange{ reinterpret_cast(const_cast(input.data())), - (int32_t)input.length(), + static_cast(input.length()), 0}; return std::make_unique(std::vector{byteRange}); } diff --git a/presto-native-execution/presto_cpp/presto_protocol/tests/VariableReferenceExpressionTest.cpp b/presto-native-execution/presto_cpp/presto_protocol/tests/VariableReferenceExpressionTest.cpp index cf8232c0273b..3a78bc0880b8 100644 --- a/presto-native-execution/presto_cpp/presto_protocol/tests/VariableReferenceExpressionTest.cpp +++ b/presto-native-execution/presto_cpp/presto_protocol/tests/VariableReferenceExpressionTest.cpp @@ -38,6 +38,8 @@ TEST_F(VariableReferenceExpressionTest, basic) { testJsonRoundtrip(j, p); ASSERT_EQ(json_map_key(p), "segment") << "... json_map_key"; - ASSERT_EQ((json)VariableReferenceExpression("segment"), (json)p) + ASSERT_EQ( + static_cast(VariableReferenceExpression("segment")), + static_cast(p)) << "... string constructor"; }