rapidsai / cudf

cuDF - GPU DataFrame Library
https://docs.rapids.ai/api/cudf/stable/
Apache License 2.0
8.03k stars 871 forks source link

Share struct member definition for parse_options and parse_options_view #15825

Open vyasr opened 1 month ago

vyasr commented 1 month ago

question: It seems a shame that one must repeat most of the fields between parse_options and parse_options_view. Shall we open an issue to discuss whether these should be shared with something like:

struct _parse_options {
   char delimiter;
   ...;
   ...;
}

struct parse_options_view {
    struct _parse_options opts;
    cudf::detail::trie_view trie_true;
    ...;
}

struct parse_options {
   struct _parse_options opts;
   cudf::detail::optional_tree trie_true;
   ...

}

WDYT?

_Originally posted by @wence- in https://github.com/rapidsai/cudf/pull/15727#discussion_r1609612576_

etseidl commented 1 month ago

how about something like

template <class TrieT>
struct _parse_options {
  char delimiter;
  ...
  TrieT trie_true;
  TrieT trie_false;
  TrieT trie_na;
  bool multi_delimiter;
};

using parse_options_view = _parse_options<cudf::detail::trie_view>;

struct parse_options : public _parse_options<cudf::detail::optional_trie> {
  [[nodiscard]] json_inference_options_view json_view() const { ... }
  ...
};

cc @vuule