-
Notifications
You must be signed in to change notification settings - Fork 4.3k
GH-50967: [C++] Allow CSV reader to ignore extra columns in rows with more columns #51118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,8 @@ | |
| #include <cstdint> | ||
| #include <cstring> | ||
| #include <string_view> | ||
| #include <type_traits> | ||
| #include <utility> | ||
|
|
||
| #include "arrow/csv/options.h" | ||
| #include "arrow/util/simd.h" | ||
|
|
@@ -35,6 +37,30 @@ class SpecializedOptions { | |
| static constexpr bool escaping = Escaping; | ||
| }; | ||
|
|
||
| /// Convert runtime boolean options into template arguments for a callable. | ||
| template <bool... CompiledBools, typename Fn, typename... Rest> | ||
| decltype(auto) DispatchBool(Fn&& fn, Rest... rest) | ||
| requires requires { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double "requires"?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. The first |
||
| std::forward<Fn>(fn) | ||
| .template operator()<CompiledBools..., std::is_convertible_v<Rest, bool>...>(); | ||
| } | ||
| { | ||
| if constexpr (sizeof...(Rest) == 0) { | ||
| // All runtime booleans have been appended to the compile-time pack. | ||
| return std::forward<Fn>(fn).template operator()<CompiledBools...>(); | ||
| } else { | ||
| // Split off the next runtime boolean, append its value to the compile-time pack, | ||
| // and recursively dispatch the remaining booleans. | ||
| return [&](bool head, auto... tail) -> decltype(auto) { | ||
| if (head) { | ||
| return DispatchBool<CompiledBools..., true>(std::forward<Fn>(fn), tail...); | ||
| } else { | ||
| return DispatchBool<CompiledBools..., false>(std::forward<Fn>(fn), tail...); | ||
| } | ||
| }(rest...); | ||
| } | ||
| } | ||
|
|
||
| // | ||
| // Bulk filters for packed character matching. | ||
| // These filters allow checking multiple CSV bytes at once for specific | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.