MCPcopy Create free account
hub / github.com/apache/arrow / HandleInvalidRow

Method HandleInvalidRow

cpp/src/arrow/csv/parser.cc:244–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

MismatchingColumnsFunction · 0.85
backMethod · 0.80
push_backMethod · 0.80
OKFunction · 0.50
RollbackLineMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected