Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[native] Change C-style casts to C++-style #24237

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>(usage.ru_utime.tv_sec) * 1'000'000 +
static_cast<int64_t>(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<int64_t>(usage.ru_stime.tv_sec) * 1'000'000 +
static_cast<int64_t>(usage.ru_stime.tv_usec)};
RECORD_METRIC_VALUE(
kCounterOsSystemCpuTimeMicros, systemCpuTimeUs - lastSystemCpuTimeUs_);
lastSystemCpuTimeUs_ = systemCpuTimeUs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char*>(body->data()), body->length());
if (pool != nullptr) {
pool->free(body->writableData(), body->capacity());
}
Expand Down
3 changes: 2 additions & 1 deletion presto-native-execution/presto_cpp/main/common/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char*>(buf->data()), buf->length());
}
return oss.str();
}
Expand Down
4 changes: 2 additions & 2 deletions presto-native-execution/presto_cpp/main/http/HttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(1 << 20);
options.receiveStreamWindowSize = static_cast<uint32_t>(1 << 20);
options.receiveSessionWindowSize = 10 * (1 << 20);
options.h2cEnabled = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ class BroadcastTest : public exec::test::OperatorTestBase {
std::vector<ByteRange> ranges;
for (const auto& range : *ioBuf) {
ranges.emplace_back(ByteRange{
const_cast<uint8_t*>(range.data()), (int32_t)range.size(), 0});
const_cast<uint8_t*>(range.data()),
static_cast<int32_t>(range.size()),
0});
}
auto byteStream = std::make_unique<BufferInputStream>(std::move(ranges));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>(100), 0));
}
auto& summaryMetric = summaryFamily.Add({impl_->labels}, quantiles);
registeredMetricsMap_.emplace(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<folly::Executor*>(nullptr), core::QueryConfig({}));
queryCtxs[queryId] = queryCtx;
queryContextCache.insert(queryId, queryCtx);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ class Cursor {
std::vector<ByteRange> byteRanges;
for (auto& range : *buffer) {
byteRanges.emplace_back(ByteRange{
const_cast<uint8_t*>(range.data()), (int32_t)range.size(), 0});
const_cast<uint8_t*>(range.data()),
static_cast<int32_t>(range.size()),
0});
}

const auto input =
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ RowTypePtr toRowType(

template <typename T>
std::string toJsonString(const T& value) {
return ((json)value).dump();
return (static_cast<json>(value)).dump();
}

std::shared_ptr<connector::ColumnHandle> toColumnHandle(
Expand Down Expand Up @@ -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<int>(strategy));
}

// Presto doesn't have PartitionedOutputNode and assigns its source node's plan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace {
std::unique_ptr<ByteInputStream> toByteStream(const std::string& input) {
ByteRange byteRange{
reinterpret_cast<uint8_t*>(const_cast<char*>(input.data())),
(int32_t)input.length(),
static_cast<int32_t>(input.length()),
0};
return std::make_unique<BufferInputStream>(std::vector<ByteRange>{byteRange});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ TEST_F(VariableReferenceExpressionTest, basic) {
testJsonRoundtrip(j, p);

ASSERT_EQ(json_map_key(p), "segment<integer>") << "... json_map_key";
ASSERT_EQ((json)VariableReferenceExpression("segment<integer>"), (json)p)
ASSERT_EQ(
static_cast<json>(VariableReferenceExpression("segment<integer>")),
static_cast<json>(p))
<< "... string constructor";
}
Loading