| 279 | template <typename SpecializedOptions, bool UseBulkFilter, typename ValueDescWriter, |
| 280 | typename DataWriter, typename BulkFilter> |
| 281 | Status ParseLine(ValueDescWriter* values_writer, DataWriter* parsed_writer, |
| 282 | const char* data, const char* data_end, bool is_final, |
| 283 | const char** out_data, const BulkFilter& bulk_filter) { |
| 284 | int32_t num_cols = 0; |
| 285 | char c; |
| 286 | const auto start = data; |
| 287 | |
| 288 | DCHECK_GT(data_end, data); |
| 289 | |
| 290 | auto FinishField = [&]() { values_writer->FinishField(parsed_writer); }; |
| 291 | |
| 292 | values_writer->BeginLine(); |
| 293 | parsed_writer->BeginLine(); |
| 294 | |
| 295 | // The parsing state machine |
| 296 | |
| 297 | // Special case empty lines: do we start with a newline separator? |
| 298 | c = *data; |
| 299 | if (ARROW_PREDICT_FALSE(IsControlChar(c))) { |
| 300 | if (c == '\r') { |
| 301 | data++; |
| 302 | if (data < data_end && *data == '\n') { |
| 303 | data++; |
| 304 | } |
| 305 | goto EmptyLine; |
| 306 | } |
| 307 | if (c == '\n') { |
| 308 | data++; |
| 309 | goto EmptyLine; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | FieldStart: |
| 314 | // At the start of a field |
| 315 | if (*data == options_.delimiter) { |
| 316 | // Empty cells are very common in some files, shortcut them |
| 317 | values_writer->StartField(false /* quoted */); |
| 318 | FinishField(); |
| 319 | ++data; |
| 320 | ++num_cols; |
| 321 | if (ARROW_PREDICT_FALSE(data == data_end)) { |
| 322 | goto AbortLine; |
| 323 | } |
| 324 | goto FieldStart; |
| 325 | } |
| 326 | |
| 327 | // Quoting is only recognized at start of field |
| 328 | if (SpecializedOptions::quoting && |
| 329 | ARROW_PREDICT_FALSE(*data == options_.quote_char)) { |
| 330 | ++data; |
| 331 | values_writer->StartField(true /* quoted */); |
| 332 | goto InQuotedField; |
| 333 | } else { |
| 334 | values_writer->StartField(false /* quoted */); |
| 335 | goto InField; |
| 336 | } |
| 337 | |
| 338 | InField: |
nothing calls this directly
no test coverage detected