| 250 | |
| 251 | template <typename ValueDescWriter, typename DataWriter> |
| 252 | Status HandleInvalidRow(ValueDescWriter* values_writer, DataWriter* parsed_writer, |
| 253 | const char* start, const char* data, int32_t num_cols, |
| 254 | const char** out_data) { |
| 255 | // Find the end of the line without newline or carriage return |
| 256 | auto end = data; |
| 257 | if (*(end - 1) == '\n') { |
| 258 | --end; |
| 259 | } |
| 260 | if (*(end - 1) == '\r') { |
| 261 | --end; |
| 262 | } |
| 263 | const int32_t batch_row_including_skipped = |
| 264 | batch_.num_rows_ + batch_.num_skipped_rows(); |
| 265 | InvalidRow row{batch_.num_cols_, num_cols, |
| 266 | first_row_ < 0 ? -1 : first_row_ + batch_row_including_skipped, |
| 267 | std::string_view(start, end - start)}; |
| 268 | |
| 269 | if (options_.invalid_row_handler && |
| 270 | options_.invalid_row_handler(row) == InvalidRowResult::Skip) { |
| 271 | values_writer->RollbackLine(); |
| 272 | parsed_writer->RollbackLine(); |
| 273 | if (!batch_.skipped_rows_.empty()) { |
| 274 | // Should be increasing (non-strictly) |
| 275 | DCHECK_GE(batch_.num_rows_, batch_.skipped_rows_.back()); |
| 276 | } |
| 277 | // Record the logical row number (not including skipped) since that |
| 278 | // is what we are going to look for later. |
| 279 | batch_.skipped_rows_.push_back(batch_.num_rows_); |
| 280 | *out_data = data; |
| 281 | return Status::OK(); |
| 282 | } |
| 283 | |
| 284 | return MismatchingColumns(row); |
| 285 | } |
| 286 | |
| 287 | template <typename SpecializedOptions, bool UseBulkFilter, bool IgnoreExtraColumns, |
| 288 | typename ValueDescWriter, typename DataWriter, typename BulkFilter> |
nothing calls this directly
no test coverage detected