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