Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/branch-24.12' into pylibcudf/s…
Browse files Browse the repository at this point in the history
…trings/find_multiple
  • Loading branch information
mroeschke committed Sep 30, 2024
2 parents 8291cae + 9b2f892 commit 403c890
Show file tree
Hide file tree
Showing 25 changed files with 597 additions and 276 deletions.
3 changes: 2 additions & 1 deletion cpp/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Checks:
'modernize-*,
-modernize-use-equals-default,
-modernize-concat-nested-namespaces,
-modernize-use-trailing-return-type'
-modernize-use-trailing-return-type,
-modernize-use-bool-literals'

# -modernize-use-equals-default # auto-fix is broken (doesn't insert =default correctly)
# -modernize-concat-nested-namespaces # auto-fix is broken (can delete code)
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/cudf/io/parquet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ class parquet_writer_options : public parquet_writer_options_base {
* @param sink The sink used for writer output
* @param table Table to be written to output
*/
explicit parquet_writer_options(sink_info const& sink, table_view const& table);
explicit parquet_writer_options(sink_info const& sink, table_view table);

public:
/**
Expand Down
5 changes: 2 additions & 3 deletions cpp/include/cudf_test/type_list_utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,8 @@ struct RemoveIfImpl<PRED, Types<>> {

template <class PRED, class HEAD, class... TAIL>
struct RemoveIfImpl<PRED, Types<HEAD, TAIL...>> {
using type =
Concat<typename std::conditional<PRED::template Call<HEAD>::value, Types<>, Types<HEAD>>::type,
typename RemoveIfImpl<PRED, Types<TAIL...>>::type>;
using type = Concat<std::conditional_t<PRED::template Call<HEAD>::value, Types<>, Types<HEAD>>,
typename RemoveIfImpl<PRED, Types<TAIL...>>::type>;
};
// @endcond

Expand Down
299 changes: 178 additions & 121 deletions cpp/src/io/csv/reader_impl.cu

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions cpp/src/io/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <cudf/utilities/memory_resource.hpp>

#include <algorithm>
#include <utility>

namespace cudf::io {

Expand Down Expand Up @@ -852,8 +853,8 @@ void parquet_writer_options_base::set_sorting_columns(std::vector<sorting_column
_sorting_columns = std::move(sorting_columns);
}

parquet_writer_options::parquet_writer_options(sink_info const& sink, table_view const& table)
: parquet_writer_options_base(sink), _table(table)
parquet_writer_options::parquet_writer_options(sink_info const& sink, table_view table)
: parquet_writer_options_base(sink), _table(std::move(table))
{
}

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/io/json/nested_json_gpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,12 @@ struct PdaSymbolToSymbolGroupId {
constexpr auto pda_sgid_lookup_size =
static_cast<int32_t>(sizeof(tos_sg_to_pda_sgid) / sizeof(tos_sg_to_pda_sgid[0]));
// We map the delimiter character to LINE_BREAK symbol group id, and the newline character
// to OTHER. Note that delimiter cannot be any of opening(closing) brace, bracket, quote,
// to WHITE_SPACE. Note that delimiter cannot be any of opening(closing) brace, bracket, quote,
// escape, comma, colon or whitespace characters.
auto const symbol_position =
symbol == delimiter
? static_cast<int32_t>('\n')
: (symbol == '\n' ? static_cast<int32_t>(delimiter) : static_cast<int32_t>(symbol));
: (symbol == '\n' ? static_cast<int32_t>(' ') : static_cast<int32_t>(symbol));
PdaSymbolGroupIdT symbol_gid =
tos_sg_to_pda_sgid[min(symbol_position, pda_sgid_lookup_size - 1)];
return stack_idx * static_cast<PdaSymbolGroupIdT>(symbol_group_id::NUM_PDA_INPUT_SGS) +
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/io/utilities/output_builder.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ class output_builder {
* @param mr The memory resource used to allocate the output vector.
* @return The output vector.
*/
rmm::device_uvector<T> gather(rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr) const
[[nodiscard]] rmm::device_uvector<T> gather(rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr) const
{
rmm::device_uvector<T> output{size(), stream, mr};
auto output_it = output.begin();
Expand Down
6 changes: 3 additions & 3 deletions cpp/tests/ast/transform_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ TEST_F(TransformTest, DeeplyNestedArithmeticLogicalExpression)
auto expressions = std::list<cudf::ast::operation>();

auto op = arithmetic_operator;
expressions.push_back(cudf::ast::operation(op, col_ref, col_ref));
expressions.emplace_back(op, col_ref, col_ref);

for (int64_t i = 0; i < depth_level - 1; i++) {
if (i == depth_level - 2) {
Expand All @@ -387,9 +387,9 @@ TEST_F(TransformTest, DeeplyNestedArithmeticLogicalExpression)
op = arithmetic_operator;
}
if (nested_left_tree) {
expressions.push_back(cudf::ast::operation(op, expressions.back(), col_ref));
expressions.emplace_back(op, expressions.back(), col_ref);
} else {
expressions.push_back(cudf::ast::operation(op, col_ref, expressions.back()));
expressions.emplace_back(op, col_ref, expressions.back());
}
}
return expressions;
Expand Down
44 changes: 21 additions & 23 deletions cpp/tests/binaryop/util/operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct Add {
void>* = nullptr>
OutT operator()(TypeLhs lhs, TypeRhs rhs) const
{
using TypeCommon = typename std::common_type<OutT, TypeLhs, TypeRhs>::type;
using TypeCommon = std::common_type_t<OutT, TypeLhs, TypeRhs>;
return static_cast<OutT>(static_cast<TypeCommon>(lhs) + static_cast<TypeCommon>(rhs));
}
};
Expand All @@ -72,7 +72,7 @@ struct Sub {
void>* = nullptr>
OutT operator()(TypeLhs lhs, TypeRhs rhs) const
{
using TypeCommon = typename std::common_type<OutT, TypeLhs, TypeRhs>::type;
using TypeCommon = std::common_type_t<OutT, TypeLhs, TypeRhs>;
return static_cast<OutT>(static_cast<TypeCommon>(lhs) - static_cast<TypeCommon>(rhs));
}
};
Expand All @@ -83,7 +83,7 @@ struct Mul {
std::enable_if_t<!cudf::is_duration_t<OutT>::value, void>* = nullptr>
TypeOut operator()(TypeLhs lhs, TypeRhs rhs) const
{
using TypeCommon = typename std::common_type<TypeOut, TypeLhs, TypeRhs>::type;
using TypeCommon = std::common_type_t<TypeOut, TypeLhs, TypeRhs>;
return static_cast<TypeOut>(static_cast<TypeCommon>(lhs) * static_cast<TypeCommon>(rhs));
}

Expand Down Expand Up @@ -112,7 +112,7 @@ struct Div {
std::enable_if_t<!cudf::is_duration_t<LhsT>::value, void>* = nullptr>
TypeOut operator()(TypeLhs lhs, TypeRhs rhs)
{
using TypeCommon = typename std::common_type<TypeOut, TypeLhs, TypeRhs>::type;
using TypeCommon = std::common_type_t<TypeOut, TypeLhs, TypeRhs>;
return static_cast<TypeOut>(static_cast<TypeCommon>(lhs) / static_cast<TypeCommon>(rhs));
}

Expand Down Expand Up @@ -191,33 +191,31 @@ struct FloorDiv {

template <typename TypeOut, typename TypeLhs, typename TypeRhs>
struct Mod {
template <typename OutT = TypeOut,
typename LhsT = TypeLhs,
typename RhsT = TypeRhs,
std::enable_if_t<
(std::is_integral_v<typename std::common_type<OutT, LhsT, RhsT>::type>)>* = nullptr>
template <typename OutT = TypeOut,
typename LhsT = TypeLhs,
typename RhsT = TypeRhs,
std::enable_if_t<(std::is_integral_v<std::common_type_t<OutT, LhsT, RhsT>>)>* = nullptr>
TypeOut operator()(TypeLhs lhs, TypeRhs rhs)
{
using TypeCommon = typename std::common_type<TypeOut, TypeLhs, TypeRhs>::type;
using TypeCommon = std::common_type_t<TypeOut, TypeLhs, TypeRhs>;
return static_cast<TypeOut>(static_cast<TypeCommon>(lhs) % static_cast<TypeCommon>(rhs));
}

template <typename OutT = TypeOut,
typename LhsT = TypeLhs,
typename RhsT = TypeRhs,
std::enable_if_t<(
std::is_same_v<typename std::common_type<OutT, LhsT, RhsT>::type, float>)>* = nullptr>
template <
typename OutT = TypeOut,
typename LhsT = TypeLhs,
typename RhsT = TypeRhs,
std::enable_if_t<(std::is_same_v<std::common_type_t<OutT, LhsT, RhsT>, float>)>* = nullptr>
TypeOut operator()(TypeLhs lhs, TypeRhs rhs)
{
return static_cast<TypeOut>(fmod(static_cast<float>(lhs), static_cast<float>(rhs)));
}

template <
typename OutT = TypeOut,
typename LhsT = TypeLhs,
typename RhsT = TypeRhs,
std::enable_if_t<(std::is_same_v<typename std::common_type<OutT, LhsT, RhsT>::type, double>)>* =
nullptr>
typename OutT = TypeOut,
typename LhsT = TypeLhs,
typename RhsT = TypeRhs,
std::enable_if_t<(std::is_same_v<std::common_type_t<OutT, LhsT, RhsT>, double>)>* = nullptr>
TypeOut operator()(TypeLhs lhs, TypeRhs rhs)
{
return static_cast<TypeOut>(fmod(static_cast<double>(lhs), static_cast<double>(rhs)));
Expand Down Expand Up @@ -326,7 +324,7 @@ struct LogBase {

template <typename TypeOut, typename TypeLhs, typename TypeRhs>
struct PMod {
using CommonArgsT = typename std::common_type<TypeLhs, TypeRhs>::type;
using CommonArgsT = std::common_type_t<TypeLhs, TypeRhs>;

TypeOut operator()(TypeLhs x, TypeRhs y) const
{
Expand All @@ -351,8 +349,8 @@ struct PyMod {
TypeOut operator()(TypeLhs x, TypeRhs y) const
{
if constexpr (std::is_floating_point_v<TypeLhs> or std::is_floating_point_v<TypeRhs>) {
double x1 = static_cast<double>(x);
double y1 = static_cast<double>(y);
auto x1 = static_cast<double>(x);
auto y1 = static_cast<double>(y);
return fmod(fmod(x1, y1) + y1, y1);
} else {
return ((x % y) + y) % y;
Expand Down
4 changes: 2 additions & 2 deletions cpp/tests/groupby/mean_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TYPED_TEST(groupby_mean_test, basic)
{
using V = TypeParam;
using R = cudf::detail::target_type_t<V, cudf::aggregation::MEAN>;
using RT = typename std::conditional<cudf::is_duration<R>(), int, double>::type;
using RT = std::conditional_t<cudf::is_duration<R>(), int, double>;

cudf::test::fixed_width_column_wrapper<K> keys{1, 2, 3, 1, 2, 2, 1, 3, 3, 2};
cudf::test::fixed_width_column_wrapper<V> vals{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
Expand Down Expand Up @@ -114,7 +114,7 @@ TYPED_TEST(groupby_mean_test, null_keys_and_values)
{
using V = TypeParam;
using R = cudf::detail::target_type_t<V, cudf::aggregation::MEAN>;
using RT = typename std::conditional<cudf::is_duration<R>(), int, double>::type;
using RT = std::conditional_t<cudf::is_duration<R>(), int, double>;

cudf::test::fixed_width_column_wrapper<K> keys(
{1, 2, 3, 1, 2, 2, 1, 3, 3, 2, 4},
Expand Down
27 changes: 25 additions & 2 deletions cpp/tests/io/json/json_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,7 @@ TEST_P(JsonReaderRecordTest, JsonLinesObjects)

TEST_P(JsonReaderRecordTest, JsonLinesObjectsStrings)
{
auto const test_opt = GetParam();
auto test_json_objects = [test_opt](std::string const& data) {
auto test_json_objects = [](std::string const& data) {
cudf::io::json_reader_options in_options =
cudf::io::json_reader_options::builder(cudf::io::source_info{data.data(), data.size()})
.lines(true);
Expand Down Expand Up @@ -2575,6 +2574,30 @@ TEST_F(JsonReaderTest, ViableDelimiter)
EXPECT_THROW(json_parser_options.set_delimiter('\t'), std::invalid_argument);
}

TEST_F(JsonReaderTest, ViableDelimiterNewlineWS)
{
// Test input
std::string input = R"({"a":
100})";

cudf::io::json_reader_options json_parser_options =
cudf::io::json_reader_options::builder(cudf::io::source_info{input.c_str(), input.size()})
.lines(true)
.delimiter('\0');

auto result = cudf::io::read_json(json_parser_options);
EXPECT_EQ(result.tbl->num_columns(), 1);
EXPECT_EQ(result.tbl->num_rows(), 1);

EXPECT_EQ(result.tbl->get_column(0).type().id(), cudf::type_id::INT64);

EXPECT_EQ(result.metadata.schema_info[0].name, "a");

auto col1_iterator = thrust::constant_iterator<int64_t>(100);
CUDF_TEST_EXPECT_COLUMNS_EQUAL(result.tbl->get_column(0),
int64_wrapper(col1_iterator, col1_iterator + 1));
}

// Test case for dtype prune:
// all paths, only one.
// one present, another not present, nothing present
Expand Down
Loading

0 comments on commit 403c890

Please sign in to comment.