pitrou commented on code in PR #50926:
URL: https://github.com/apache/arrow/pull/50926#discussion_r3852901318
##########
cpp/src/arrow/csv/parser.h:
##########
@@ -98,16 +111,32 @@ class ARROW_EXPORT DataBatch {
const auto start_pos =
static_cast<int32_t>(values_buffer->size() / sizeof(ParsedValueDesc)) -
num_cols_ - 1;
+ const bool last_row_has_missing_fields =
+ !missing_fields_.empty() && missing_fields_.back().row == num_rows_ -
1;
for (int32_t col_index = 0; col_index < num_cols_; ++col_index) {
auto start = values[start_pos + col_index].offset;
auto stop = values[start_pos + col_index + 1].offset;
auto quoted = values[start_pos + col_index + 1].quoted;
- ARROW_RETURN_NOT_OK(visit(parsed_ + start, stop - start, quoted));
+ const bool missing = last_row_has_missing_fields &&
+ col_index >=
missing_fields_.back().first_missing_column;
+ ARROW_RETURN_NOT_OK(InvokeVisitor(std::forward<Visitor>(visit), parsed_
+ start,
+ stop - start, quoted, missing));
}
return Status::OK();
}
protected:
+ template <typename Visitor>
+ static Status InvokeVisitor(Visitor&& visit, const uint8_t* data, uint32_t
size,
+ bool quoted, bool missing) {
+ if constexpr (std::is_invocable_r_v<Status, Visitor&&, const uint8_t*,
uint32_t, bool,
+ bool>) {
+ return std::invoke(visit, data, size, quoted, missing);
+ } else {
+ return std::invoke(visit, data, size, quoted);
+ }
+ }
Review Comment:
I don't think we care about maintaining compatibility with old visitors. The
CSV parser APIs should be probably be considered private, even though they are
not marked as such.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]