Skip to content

Commit

Permalink
more size_type use
Browse files Browse the repository at this point in the history
  • Loading branch information
vuule committed Oct 27, 2021
1 parent 2148b94 commit 3c0d862
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
12 changes: 6 additions & 6 deletions cpp/src/io/orc/orc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ void metadata::init_column_names()
if (not column_has_parent(col_id)) return std::string{};
auto const& parent_field_names = ff.types[parent_id(col_id)].fieldNames;
// Child columns of lists don't have a name in ORC files, generate placeholder in that case
return field_index(col_id) < static_cast<int32_t>(parent_field_names.size())
return field_index(col_id) < static_cast<size_type>(parent_field_names.size())
? parent_field_names[field_index(col_id)]
: std::to_string(col_id);
});
Expand All @@ -489,14 +489,14 @@ void metadata::init_column_names()

void metadata::init_parent_descriptors()
{
auto const num_columns = static_cast<int32_t>(ff.types.size());
auto const num_columns = static_cast<size_type>(ff.types.size());
parents.resize(num_columns);

for (int32_t col_id = 0; col_id < num_columns; ++col_id) {
for (size_type col_id = 0; col_id < num_columns; ++col_id) {
auto const& subtypes = ff.types[col_id].subtypes;
auto const num_children = static_cast<int32_t>(subtypes.size());
for (int32_t field_idx = 0; field_idx < num_children; ++field_idx) {
auto const child_id = static_cast<int32_t>(subtypes[field_idx]);
auto const num_children = static_cast<size_type>(subtypes.size());
for (size_type field_idx = 0; field_idx < num_children; ++field_idx) {
auto const child_id = static_cast<size_type>(subtypes[field_idx]);
CUDF_EXPECTS(child_id > col_id && child_id < num_columns, "Invalid column id");
CUDF_EXPECTS(not column_has_parent(child_id), "Same node referenced twice");
parents[child_id] = {col_id, field_idx};
Expand Down
17 changes: 9 additions & 8 deletions cpp/src/io/orc/reader_impl.cu
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ void reader::impl::aggregate_child_meta(cudf::detail::host_2dspan<gpu::ColumnDes
cudf::detail::host_2dspan<gpu::RowGroup> row_groups,
std::vector<column_buffer>& out_buffers,
std::vector<orc_column_meta> const& list_col,
const int32_t level)
const size_type level)
{
const auto num_of_stripes = chunks.size().first;
const auto num_of_rowgroups = row_groups.size().first;
Expand Down Expand Up @@ -678,7 +678,7 @@ void reader::impl::aggregate_child_meta(cudf::detail::host_2dspan<gpu::ColumnDes
for (size_t rowgroup_id = 0; rowgroup_id < stripe_num_row_groups;
rowgroup_id++, processed_row_groups++) {
const auto child_rows = row_groups[processed_row_groups][parent_col_idx].num_child_rows;
for (int32_t id = 0; id < p_col.num_children; id++) {
for (size_type id = 0; id < p_col.num_children; id++) {
const auto child_col_idx = index + id;
rwgrp_meta[processed_row_groups][child_col_idx].start_row = processed_child_rows;
rwgrp_meta[processed_row_groups][child_col_idx].num_rows = child_rows;
Expand All @@ -689,7 +689,7 @@ void reader::impl::aggregate_child_meta(cudf::detail::host_2dspan<gpu::ColumnDes

// Aggregate start row, number of rows per chunk and total number of rows in a column
const auto child_rows = chunks[stripe_id][parent_col_idx].num_child_rows;
for (int32_t id = 0; id < p_col.num_children; id++) {
for (size_type id = 0; id < p_col.num_children; id++) {
const auto child_col_idx = index + id;

num_child_rows[child_col_idx] += child_rows;
Expand All @@ -707,7 +707,7 @@ void reader::impl::aggregate_child_meta(cudf::detail::host_2dspan<gpu::ColumnDes
auto parent_valid_map = out_buffers[parent_col_idx].null_mask();
auto num_rows = out_buffers[parent_col_idx].size;

for (int32_t id = 0; id < p_col.num_children; id++) {
for (size_type id = 0; id < p_col.num_children; id++) {
const auto child_col_idx = index + id;
_col_meta.parent_column_index[child_col_idx] = parent_col_idx;
if (type == type_id::STRUCT) {
Expand All @@ -724,7 +724,7 @@ void reader::impl::aggregate_child_meta(cudf::detail::host_2dspan<gpu::ColumnDes

std::string get_map_child_col_name(size_t const idx) { return (idx == 0) ? "key" : "value"; }

std::unique_ptr<column> reader::impl::create_empty_column(const int32_t orc_col_id,
std::unique_ptr<column> reader::impl::create_empty_column(const size_type orc_col_id,
column_name_info& schema_info,
rmm::cuda_stream_view stream)
{
Expand Down Expand Up @@ -798,7 +798,7 @@ std::unique_ptr<column> reader::impl::create_empty_column(const int32_t orc_col_
}

// Adds child column buffers to parent column
column_buffer&& reader::impl::assemble_buffer(const int32_t orc_col_id,
column_buffer&& reader::impl::assemble_buffer(const size_type orc_col_id,
std::vector<std::vector<column_buffer>>& col_buffers,
const size_t level,
rmm::cuda_stream_view stream)
Expand Down Expand Up @@ -952,7 +952,8 @@ table_with_metadata reader::impl::read(size_type skip_rows,
// sign of the scale is changed since cuDF follows c++ libraries like CNL
// which uses negative scaling, but liborc and other libraries
// follow positive scaling.
auto const scale = -static_cast<int32_t>(_metadata.get_col_type(col.id).scale.value_or(0));
auto const scale =
-static_cast<size_type>(_metadata.get_col_type(col.id).scale.value_or(0));
column_types.emplace_back(col_type, scale);
} else {
column_types.emplace_back(col_type);
Expand Down Expand Up @@ -1127,7 +1128,7 @@ table_with_metadata reader::impl::read(size_type skip_rows,
? sizeof(string_index_pair)
: ((column_types[col_idx].id() == type_id::LIST) or
(column_types[col_idx].id() == type_id::STRUCT))
? sizeof(int32_t)
? sizeof(size_type)
: cudf::size_of(column_types[col_idx]);
chunk.num_rowgroups = stripe_num_rowgroups;
if (chunk.type_kind == orc::TIMESTAMP) {
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/io/orc/reader_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct stripe_source_mapping;
* @brief Keeps track of orc mapping and child column details.
*/
struct reader_column_meta {
std::vector<std::vector<int32_t>>
std::vector<std::vector<size_type>>
orc_col_map; // Mapping between column id in orc to processing order.
std::vector<uint32_t> num_child_rows; // number of rows in child columns

Expand Down Expand Up @@ -173,7 +173,7 @@ class reader::impl {
* @param col_buffers Column buffers for columns and children.
* @param level Current nesting level.
*/
column_buffer&& assemble_buffer(const int32_t orc_col_id,
column_buffer&& assemble_buffer(const size_type orc_col_id,
std::vector<std::vector<column_buffer>>& col_buffers,
const size_t level,
rmm::cuda_stream_view stream);
Expand All @@ -200,7 +200,7 @@ class reader::impl {
*
* @return An empty column equivalent to orc column type.
*/
std::unique_ptr<column> create_empty_column(const int32_t orc_col_id,
std::unique_ptr<column> create_empty_column(const size_type orc_col_id,
column_name_info& schema_info,
rmm::cuda_stream_view stream);

Expand Down

0 comments on commit 3c0d862

Please sign in to comment.