Skip to content

Commit

Permalink
replace std::make_pair with std::pair (C++17 CTAD)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikeyann committed Apr 25, 2022
1 parent 399c910 commit 2950e28
Show file tree
Hide file tree
Showing 51 changed files with 149 additions and 162 deletions.
2 changes: 1 addition & 1 deletion cpp/benchmarks/reduction/segment_reduce.cu
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ std::pair<std::unique_ptr<column>, thrust::device_vector<size_type>> make_test_d

thrust::device_vector<size_type> d_offsets(offset_it, offset_it + num_segments + 1);

return std::make_pair(std::move((input->release())[0]), d_offsets);
return std::pair(std::move((input->release())[0]), d_offsets);
}

template <typename InputType, typename OutputType, aggregation::Kind kind>
Expand Down
4 changes: 2 additions & 2 deletions cpp/docs/DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ The preferred style for how inputs are passed in and outputs are returned is the

Sometimes it is necessary for functions to have multiple outputs. There are a few ways this can be
done in C++ (including creating a `struct` for the output). One convenient way to do this is
using `std::tie` and `std::make_pair`. Note that objects passed to `std::make_pair` will invoke
using `std::tie` and `std::pair`. Note that objects passed to `std::pair` will invoke
either the copy constructor or the move constructor of the object, and it may be preferable to move
non-trivially copyable objects (and required for types with deleted copy constructors, like
`std::unique_ptr`).
Expand All @@ -585,7 +585,7 @@ std::pair<table, table> return_two_tables(void){
// Do stuff with out0, out1

// Return a std::pair of the two outputs
return std::make_pair(std::move(out0), std::move(out1));
return std::pair(std::move(out0), std::move(out1));
}

cudf::table out0;
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/cudf/detail/null_mask.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ std::pair<rmm::device_buffer, size_type> bitmask_binop(
stream,
mr);

return std::make_pair(std::move(dest_mask), null_count);
return std::pair(std::move(dest_mask), null_count);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/cudf/detail/valid_if.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ std::pair<rmm::device_buffer, size_type> valid_if(

null_count = size - valid_count.value(stream);
}
return std::make_pair(std::move(null_mask), null_count);
return std::pair(std::move(null_mask), null_count);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/cudf/strings/detail/utilities.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ auto make_strings_children(
for_each_fn(size_and_exec_fn);
}

return std::make_pair(std::move(offsets_column), std::move(chars_column));
return std::pair(std::move(offsets_column), std::move(chars_column));
}

/**
Expand Down
13 changes: 6 additions & 7 deletions cpp/include/cudf/table/experimental/row_operators.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,13 @@ class device_row_comparator {
bool const rhs_is_null{_rhs.is_null(rhs_element_index)};

if (lhs_is_null or rhs_is_null) { // at least one is null
return cuda::std::make_pair(null_compare(lhs_is_null, rhs_is_null, _null_precedence),
_depth);
return cuda::std::pair(null_compare(lhs_is_null, rhs_is_null, _null_precedence), _depth);
}
}

return cuda::std::make_pair(relational_compare(_lhs.element<Element>(lhs_element_index),
_rhs.element<Element>(rhs_element_index)),
std::numeric_limits<int>::max());
return cuda::std::pair(relational_compare(_lhs.element<Element>(lhs_element_index),
_rhs.element<Element>(rhs_element_index)),
std::numeric_limits<int>::max());
}

template <typename Element,
Expand All @@ -197,11 +196,11 @@ class device_row_comparator {

if (lhs_is_null or rhs_is_null) { // at least one is null
weak_ordering state = null_compare(lhs_is_null, rhs_is_null, _null_precedence);
return cuda::std::make_pair(state, depth);
return cuda::std::pair(state, depth);
}

if (lcol.num_child_columns() == 0) {
return cuda::std::make_pair(weak_ordering::EQUIVALENT, depth);
return cuda::std::pair(weak_ordering::EQUIVALENT, depth);
}

// Non-empty structs have been modified to only have 1 child when using this.
Expand Down
16 changes: 8 additions & 8 deletions cpp/include/cudf_test/column_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ auto make_chars_and_offsets(StringsIterator begin, StringsIterator end, Validity
chars.insert(chars.end(), std::cbegin(tmp), std::cend(tmp));
offsets.push_back(offsets.back() + tmp.length());
}
return std::make_pair(std::move(chars), std::move(offsets));
return std::pair(std::move(chars), std::move(offsets));
};
} // namespace detail

Expand Down Expand Up @@ -1468,13 +1468,13 @@ class lists_column_wrapper : public detail::column_wrapper {
0, [&v](auto i) { return v.empty() ? true : v[i]; });

// compute the expected hierarchy and depth
auto const hierarchy_and_depth = std::accumulate(
elements.begin(),
elements.end(),
std::pair<column_view, int32_t>{{}, -1},
[](auto acc, lists_column_wrapper const& lcw) {
return lcw.depth > acc.second ? std::make_pair(lcw.get_view(), lcw.depth) : acc;
});
auto const hierarchy_and_depth =
std::accumulate(elements.begin(),
elements.end(),
std::pair<column_view, int32_t>{{}, -1},
[](auto acc, lists_column_wrapper const& lcw) {
return lcw.depth > acc.second ? std::pair(lcw.get_view(), lcw.depth) : acc;
});
column_view expected_hierarchy = hierarchy_and_depth.first;
int32_t const expected_depth = hierarchy_and_depth.second;

Expand Down
8 changes: 4 additions & 4 deletions cpp/src/bitmask/null_mask.cu
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ std::pair<rmm::device_buffer, size_type> bitmask_and(table_view const& view,
CUDF_FUNC_RANGE();
rmm::device_buffer null_mask{0, stream, mr};
if (view.num_rows() == 0 or view.num_columns() == 0) {
return std::make_pair(std::move(null_mask), 0);
return std::pair(std::move(null_mask), 0);
}

std::vector<bitmask_type const*> masks;
Expand All @@ -467,7 +467,7 @@ std::pair<rmm::device_buffer, size_type> bitmask_and(table_view const& view,
mr);
}

return std::make_pair(std::move(null_mask), 0);
return std::pair(std::move(null_mask), 0);
}

// Returns the bitwise OR of the null masks of all columns in the table view
Expand All @@ -478,7 +478,7 @@ std::pair<rmm::device_buffer, size_type> bitmask_or(table_view const& view,
CUDF_FUNC_RANGE();
rmm::device_buffer null_mask{0, stream, mr};
if (view.num_rows() == 0 or view.num_columns() == 0) {
return std::make_pair(std::move(null_mask), 0);
return std::pair(std::move(null_mask), 0);
}

std::vector<bitmask_type const*> masks;
Expand All @@ -500,7 +500,7 @@ std::pair<rmm::device_buffer, size_type> bitmask_or(table_view const& view,
mr);
}

return std::make_pair(std::move(null_mask), 0);
return std::pair(std::move(null_mask), 0);
}

} // namespace detail
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/copying/contiguous_split.cu
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,9 @@ BufInfo build_output_columns(InputIter begin,
? 0
: (current_info->num_rows - current_info->valid_count);
++current_info;
return std::make_pair(ptr, null_count);
return std::pair(ptr, null_count);
}
return std::make_pair(static_cast<bitmask_type const*>(nullptr), 0);
return std::pair(static_cast<bitmask_type const*>(nullptr), 0);
}();

// size/data pointer for the column
Expand Down
17 changes: 8 additions & 9 deletions cpp/src/groupby/groupby.cu
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ std::pair<std::unique_ptr<table>, std::vector<aggregation_result>> groupby::disp
"Unsupported groupby key type does not support equality comparison");
auto [grouped_keys, results] =
detail::hash::groupby(flattened_keys, requests, _include_null_keys, stream, mr);
return std::make_pair(unflatten_nested_columns(std::move(grouped_keys), _keys),
std::move(results));
return std::pair(unflatten_nested_columns(std::move(grouped_keys), _keys), std::move(results));
} else {
return sort_aggregate(requests, stream, mr);
}
Expand Down Expand Up @@ -193,7 +192,7 @@ std::pair<std::unique_ptr<table>, std::vector<aggregation_result>> groupby::aggr

verify_valid_requests(requests);

if (_keys.num_rows() == 0) { return std::make_pair(empty_like(_keys), empty_results(requests)); }
if (_keys.num_rows() == 0) { return std::pair(empty_like(_keys), empty_results(requests)); }

return dispatch_aggregation(requests, rmm::cuda_stream_default, mr);
}
Expand All @@ -211,7 +210,7 @@ std::pair<std::unique_ptr<table>, std::vector<aggregation_result>> groupby::scan

verify_valid_requests(requests);

if (_keys.num_rows() == 0) { return std::make_pair(empty_like(_keys), empty_results(requests)); }
if (_keys.num_rows() == 0) { return std::pair(empty_like(_keys), empty_results(requests)); }

return sort_scan(requests, rmm::cuda_stream_default, mr);
}
Expand Down Expand Up @@ -250,7 +249,7 @@ std::pair<std::unique_ptr<table>, std::unique_ptr<table>> groupby::replace_nulls
CUDF_EXPECTS(static_cast<cudf::size_type>(replace_policies.size()) == values.num_columns(),
"Size mismatch between num_columns and replace_policies.");

if (values.is_empty()) { return std::make_pair(empty_like(_keys), empty_like(values)); }
if (values.is_empty()) { return std::pair(empty_like(_keys), empty_like(values)); }
auto const stream = rmm::cuda_stream_default;

auto const& group_labels = helper().group_labels(stream);
Expand All @@ -269,8 +268,8 @@ std::pair<std::unique_ptr<table>, std::unique_ptr<table>> groupby::replace_nulls
: std::move(grouped_values);
});

return std::make_pair(std::move(helper().sorted_keys(stream, mr)),
std::make_unique<table>(std::move(results)));
return std::pair(std::move(helper().sorted_keys(stream, mr)),
std::make_unique<table>(std::move(results)));
}

// Get the sort helper object
Expand Down Expand Up @@ -310,8 +309,8 @@ std::pair<std::unique_ptr<table>, std::unique_ptr<table>> groupby::shift(
grouped_values->view(), group_offsets, offsets[i], fill_values[i].get(), stream, mr);
});

return std::make_pair(helper().sorted_keys(stream, mr),
std::make_unique<cudf::table>(std::move(results)));
return std::pair(helper().sorted_keys(stream, mr),
std::make_unique<cudf::table>(std::move(results)));
}

} // namespace groupby
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/groupby/hash/groupby.cu
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ std::pair<std::unique_ptr<table>, std::vector<aggregation_result>> groupby(
std::unique_ptr<table> unique_keys =
groupby(keys, requests, &cache, has_nulls(keys), include_null_keys, stream, mr);

return std::make_pair(std::move(unique_keys), extract_results(requests, cache, stream, mr));
return std::pair(std::move(unique_keys), extract_results(requests, cache, stream, mr));
}
} // namespace hash
} // namespace detail
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/groupby/sort/aggregate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ std::pair<std::unique_ptr<table>, std::vector<aggregation_result>> groupby::sort

auto results = detail::extract_results(requests, cache, stream, mr);

return std::make_pair(helper().unique_keys(stream, mr), std::move(results));
return std::pair(helper().unique_keys(stream, mr), std::move(results));
}
} // namespace groupby
} // namespace cudf
7 changes: 3 additions & 4 deletions cpp/src/groupby/sort/group_collect.cu
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ std::pair<std::unique_ptr<column>, std::unique_ptr<column>> purge_null_entries(
auto null_purged_offsets = strings::detail::make_offsets_child_column(
null_purged_sizes.cbegin(), null_purged_sizes.cend(), stream, mr);

return std::make_pair<std::unique_ptr<column>, std::unique_ptr<column>>(
std::move(null_purged_values), std::move(null_purged_offsets));
return std::pair(std::move(null_purged_values), std::move(null_purged_offsets));
}

std::unique_ptr<column> group_collect(column_view const& values,
Expand All @@ -109,8 +108,8 @@ std::unique_ptr<column> group_collect(column_view const& values,
return cudf::groupby::detail::purge_null_entries(
values, offsets_column->view(), num_groups, stream, mr);
} else {
return std::make_pair(std::make_unique<cudf::column>(values, stream, mr),
std::move(offsets_column));
return std::pair(std::make_unique<cudf::column>(values, stream, mr),
std::move(offsets_column));
}
}();

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/groupby/sort/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ std::pair<std::unique_ptr<table>, std::vector<aggregation_result>> groupby::sort

auto results = detail::extract_results(requests, cache, stream, mr);

return std::make_pair(helper().sorted_keys(stream, mr), std::move(results));
return std::pair(helper().sorted_keys(stream, mr), std::move(results));
}
} // namespace groupby
} // namespace cudf
6 changes: 3 additions & 3 deletions cpp/src/io/orc/aggregate_orc_metadata.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, NVIDIA CORPORATION.
* Copyright (c) 2021-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.
Expand Down Expand Up @@ -177,7 +177,7 @@ std::vector<metadata::stripe_source_mapping> aggregate_orc_metadata::select_stri
per_file_metadata[src_file_idx].ff.stripes.size()),
"Invalid stripe index");
stripe_infos.push_back(
std::make_pair(&per_file_metadata[src_file_idx].ff.stripes[stripe_idx], nullptr));
std::pair(&per_file_metadata[src_file_idx].ff.stripes[stripe_idx], nullptr));
row_count += per_file_metadata[src_file_idx].ff.stripes[stripe_idx].numberOfRows;
}
selected_stripes_mapping.push_back({static_cast<int>(src_file_idx), stripe_infos});
Expand Down Expand Up @@ -206,7 +206,7 @@ std::vector<metadata::stripe_source_mapping> aggregate_orc_metadata::select_stri
count += per_file_metadata[src_file_idx].ff.stripes[stripe_idx].numberOfRows;
if (count > row_start || count == 0) {
stripe_infos.push_back(
std::make_pair(&per_file_metadata[src_file_idx].ff.stripes[stripe_idx], nullptr));
std::pair(&per_file_metadata[src_file_idx].ff.stripes[stripe_idx], nullptr));
} else {
stripe_skip_rows = count;
}
Expand Down
18 changes: 9 additions & 9 deletions cpp/src/io/orc/reader_impl.cu
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@ constexpr std::pair<gpu::StreamIndexType, uint32_t> get_index_type_and_pos(
case orc::DATA:
skip_count += 1;
skip_count |= (skip_count & 0xff) << 8;
return std::make_pair(gpu::CI_DATA, skip_count);
return std::pair(gpu::CI_DATA, skip_count);
case orc::LENGTH:
case orc::SECONDARY:
skip_count += 1;
skip_count |= (skip_count & 0xff) << 16;
return std::make_pair(gpu::CI_DATA2, skip_count);
case orc::DICTIONARY_DATA: return std::make_pair(gpu::CI_DICTIONARY, skip_count);
return std::pair(gpu::CI_DATA2, skip_count);
case orc::DICTIONARY_DATA: return std::pair(gpu::CI_DICTIONARY, skip_count);
case orc::PRESENT:
skip_count += (non_child ? 1 : 0);
return std::make_pair(gpu::CI_PRESENT, skip_count);
case orc::ROW_INDEX: return std::make_pair(gpu::CI_INDEX, skip_count);
return std::pair(gpu::CI_PRESENT, skip_count);
case orc::ROW_INDEX: return std::pair(gpu::CI_INDEX, skip_count);
default:
// Skip this stream as it's not strictly required
return std::make_pair(gpu::CI_NUM_STREAMS, 0);
return std::pair(gpu::CI_NUM_STREAMS, 0);
}
}

Expand Down Expand Up @@ -1120,9 +1120,9 @@ table_with_metadata reader::impl::read(size_type skip_rows,
if (_metadata.per_file_metadata[stripe_source_mapping.source_idx]
.source->is_device_read_preferred(len)) {
read_tasks.push_back(
std::make_pair(_metadata.per_file_metadata[stripe_source_mapping.source_idx]
.source->device_read_async(offset, len, d_dst, stream),
len));
std::pair(_metadata.per_file_metadata[stripe_source_mapping.source_idx]
.source->device_read_async(offset, len, d_dst, stream),
len));

} else {
const auto buffer =
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/io/parquet/chunk_dict.cu
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct map_insert_fn {
if constexpr (column_device_view::has_element_accessor<T>()) {
auto hash_fn = hash_functor<T>{col};
auto equality_fn = equality_functor<T>{col};
return map.insert(std::make_pair(i, i), hash_fn, equality_fn);
return map.insert(std::pair(i, i), hash_fn, equality_fn);
} else {
CUDF_UNREACHABLE("Unsupported type to insert in map");
}
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/io/parquet/writer_impl.cu
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ auto build_chunk_dictionaries(hostdevice_2dvector<gpu::EncColumnChunk>& chunks,
std::vector<rmm::device_uvector<size_type>> dict_data;
std::vector<rmm::device_uvector<uint16_t>> dict_index;

if (h_chunks.size() == 0) { return std::make_pair(std::move(dict_data), std::move(dict_index)); }
if (h_chunks.size() == 0) { return std::pair(std::move(dict_data), std::move(dict_index)); }

// Allocate slots for each chunk
std::vector<rmm::device_uvector<gpu::slot_type>> hash_maps_storage;
Expand Down Expand Up @@ -912,7 +912,7 @@ auto build_chunk_dictionaries(hostdevice_2dvector<gpu::EncColumnChunk>& chunks,

// We don't use dictionary if the indices are > 16 bits because that's the maximum bitpacking
// bitsize we efficiently support
if (nbits > 16) { return std::make_pair(false, 0); }
if (nbits > 16) { return std::pair(false, 0); }

// Only these bit sizes are allowed for RLE encoding because it's compute optimized
constexpr auto allowed_bitsizes = std::array<size_type, 6>{1, 2, 4, 8, 12, 16};
Expand All @@ -925,7 +925,7 @@ auto build_chunk_dictionaries(hostdevice_2dvector<gpu::EncColumnChunk>& chunks,

bool use_dict = (ck.plain_data_size > dict_enc_size);
if (not use_dict) { rle_bits = 0; }
return std::make_pair(use_dict, rle_bits);
return std::pair(use_dict, rle_bits);
}();
}

Expand All @@ -946,7 +946,7 @@ auto build_chunk_dictionaries(hostdevice_2dvector<gpu::EncColumnChunk>& chunks,
gpu::collect_map_entries(chunks.device_view().flat_view(), stream);
gpu::get_dictionary_indices(frags, stream);

return std::make_pair(std::move(dict_data), std::move(dict_index));
return std::pair(std::move(dict_data), std::move(dict_index));
}

void writer::impl::init_encoder_pages(hostdevice_2dvector<gpu::EncColumnChunk>& chunks,
Expand Down
Loading

0 comments on commit 2950e28

Please sign in to comment.