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

Fix memory size in create_byte_range_infos_consecutive #16012

Merged
merged 2 commits into from
Jun 24, 2024
Merged
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
4 changes: 2 additions & 2 deletions cpp/src/io/text/byte_range_info.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
* Copyright (c) 2022-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,7 +31,7 @@ std::vector<byte_range_info> create_byte_range_infos_consecutive(int64_t total_b
auto range_size = util::div_rounding_up_safe(total_bytes, range_count);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestion: Though not a part of this PR change set but range_size could be made const.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm, just checked that the return type of div_rounding_up_safe is constexpr anyway so auto should be good!

Copy link
Contributor

@karthikeyann karthikeyann Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function div_rounding_up_safe is constexpr. AFAIK, constexpr does not apply to return type. Return type is I, here int64_t.
range_size should be int64_t.

https://godbolt.org/z/9seajen4e

auto ranges = std::vector<byte_range_info>();

ranges.reserve(range_size);
ranges.reserve(range_count);

for (int64_t i = 0; i < range_count; i++) {
auto offset = i * range_size;
Expand Down
Loading