-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/branch-22.04' into refactor/fram…
…e_api_consolidation # Conflicts: # python/cudf/cudf/core/index.py # python/cudf/cudf/core/multiindex.py # python/cudf/cudf/core/series.py
- Loading branch information
Showing
48 changed files
with
2,169 additions
and
1,419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (c) 2022, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cudf/utilities/error.hpp> | ||
|
||
#include <cstdint> | ||
#include <vector> | ||
|
||
namespace cudf { | ||
namespace io { | ||
namespace text { | ||
|
||
/** | ||
* @brief stores offset and size used to indicate a byte range | ||
*/ | ||
class byte_range_info { | ||
private: | ||
int64_t _offset; | ||
int64_t _size; | ||
|
||
public: | ||
constexpr byte_range_info() noexcept : _offset(0), _size(0) {} | ||
constexpr byte_range_info(int64_t offset, int64_t size) : _offset(offset), _size(size) | ||
{ | ||
CUDF_EXPECTS(offset >= 0, "offset must be non-negative"); | ||
CUDF_EXPECTS(size >= 0, "size must be non-negative"); | ||
} | ||
|
||
constexpr byte_range_info(byte_range_info const& other) noexcept = default; | ||
constexpr byte_range_info& operator=(byte_range_info const& other) noexcept = default; | ||
|
||
[[nodiscard]] constexpr int64_t offset() { return _offset; } | ||
[[nodiscard]] constexpr int64_t size() { return _size; } | ||
}; | ||
|
||
/** | ||
* @brief Create a collection of consecutive ranges between [0, total_bytes). | ||
* | ||
* Each range wil be the same size except if `total_bytes` is not evenly divisible by | ||
* `range_count`, in which case the last range size will be the remainder. | ||
* | ||
* @param total_bytes total number of bytes in all ranges | ||
* @param range_count total number of ranges in which to divide bytes | ||
* @return Vector of range objects | ||
*/ | ||
std::vector<byte_range_info> create_byte_range_infos_consecutive(int64_t total_bytes, | ||
int64_t range_count); | ||
|
||
/** | ||
* @brief Create a byte_range_info which represents as much of a file as possible. Specifically, | ||
* `[0, numeric_limit<int64_t>::max())`. | ||
* | ||
* @return `[0, numeric_limit<int64_t>::max())` | ||
*/ | ||
byte_range_info create_byte_range_info_max(); | ||
|
||
} // namespace text | ||
} // namespace io | ||
} // namespace cudf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2022, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <cudf/detail/utilities/integer_utils.hpp> | ||
#include <cudf/io/text/byte_range_info.hpp> | ||
|
||
#include <limits> | ||
|
||
namespace cudf { | ||
namespace io { | ||
namespace text { | ||
|
||
byte_range_info create_byte_range_info_max() { return {0, std::numeric_limits<int64_t>::max()}; } | ||
|
||
std::vector<byte_range_info> create_byte_range_infos_consecutive(int64_t total_bytes, | ||
int64_t range_count) | ||
{ | ||
auto range_size = util::div_rounding_up_safe(total_bytes, range_count); | ||
auto ranges = std::vector<byte_range_info>(); | ||
|
||
ranges.reserve(range_size); | ||
|
||
for (int64_t i = 0; i < range_count; i++) { | ||
auto offset = i * range_size; | ||
auto size = std::min(range_size, total_bytes - offset); | ||
ranges.emplace_back(offset, size); | ||
} | ||
|
||
return ranges; | ||
} | ||
|
||
} // namespace text | ||
} // namespace io | ||
} // namespace cudf |
Oops, something went wrong.