Skip to content

Commit

Permalink
fix ambiguous std::map call
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikeyann committed Oct 21, 2024
1 parent 732f234 commit ffdd817
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions cpp/include/cudf/io/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,21 @@ struct schema_element {
* @param column_order Allows specifying the order of the columns
*/
schema_element(data_type type,
std::map<std::string, schema_element> child_types = {},
std::map<std::string, schema_element> child_types,
std::optional<std::vector<std::string>> column_order = std::nullopt)
: type{type}, child_types{std::move(child_types)}, column_order{std::move(column_order)}
: type{std::move(type)},
child_types{std::move(child_types)},
column_order{std::move(column_order)}
{
}

/**
* @brief Constructor to create a schema_element from a data_type
*
* @param type The type that this column should be converted to
*/
schema_element(data_type type) : schema_element{type, {}, std::nullopt} {}
schema_element() = default;
/**
* @brief Constructor to create a schema_element with a specific order of columns
*
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/io/json/parser_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ std::optional<schema_element> child_schema_element(std::string const& col_name,
[col_name](
std::map<std::string, data_type> const& user_dtypes) -> std::optional<schema_element> {
return (user_dtypes.find(col_name) != std::end(user_dtypes))
? std::optional<schema_element>{user_dtypes.find(col_name)->second}
? std::optional<schema_element>{{user_dtypes.find(col_name)->second}}
: std::optional<schema_element>{};
},
[col_name](
Expand Down
3 changes: 2 additions & 1 deletion cpp/tests/io/json/json_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ TEST_P(JsonReaderParamTest, JsonLinesStrings)

cudf::io::json_reader_options in_options =
cudf::io::json_reader_options::builder(cudf::io::source_info{data.data(), data.size()})
.dtypes({{"2", dtype<cudf::string_view>()}, {"0", dtype<int32_t>()}, {"1", dtype<double>()}})
.dtypes(std::map<std::string, data_type>{
{"2", dtype<cudf::string_view>()}, {"0", dtype<int32_t>()}, {"1", dtype<double>()}})
.lines(true);

cudf::io::table_with_metadata result = cudf::io::read_json(in_options);
Expand Down

0 comments on commit ffdd817

Please sign in to comment.