| 502 | } |
| 503 | |
| 504 | Status TransferInt96(RecordReader* reader, MemoryPool* pool, |
| 505 | const std::shared_ptr<Field>& field, Datum* out, |
| 506 | const ::arrow::TimeUnit::type int96_arrow_time_unit) { |
| 507 | int64_t length = reader->values_written(); |
| 508 | auto values = reinterpret_cast<const Int96*>(reader->values()); |
| 509 | ARROW_ASSIGN_OR_RAISE(auto data, |
| 510 | ::arrow::AllocateBuffer(length * sizeof(int64_t), pool)); |
| 511 | auto data_ptr = reinterpret_cast<int64_t*>(data->mutable_data()); |
| 512 | for (int64_t i = 0; i < length; i++) { |
| 513 | if (values[i].value[2] == 0) { |
| 514 | // Happens for null entries: avoid triggering UBSAN as that Int96 timestamp |
| 515 | // isn't representable as a 64-bit Unix timestamp. |
| 516 | *data_ptr++ = 0; |
| 517 | } else { |
| 518 | switch (int96_arrow_time_unit) { |
| 519 | case ::arrow::TimeUnit::NANO: |
| 520 | *data_ptr++ = Int96GetNanoSeconds(values[i]); |
| 521 | break; |
| 522 | case ::arrow::TimeUnit::MICRO: |
| 523 | *data_ptr++ = Int96GetMicroSeconds(values[i]); |
| 524 | break; |
| 525 | case ::arrow::TimeUnit::MILLI: |
| 526 | *data_ptr++ = Int96GetMilliSeconds(values[i]); |
| 527 | break; |
| 528 | case ::arrow::TimeUnit::SECOND: |
| 529 | *data_ptr++ = Int96GetSeconds(values[i]); |
| 530 | break; |
| 531 | } |
| 532 | } |
| 533 | } |
| 534 | if (field->nullable()) { |
| 535 | *out = |
| 536 | std::make_shared<TimestampArray>(field->type(), length, std::move(data), |
| 537 | reader->ReleaseIsValid(), reader->null_count()); |
| 538 | } else { |
| 539 | *out = std::make_shared<TimestampArray>(field->type(), length, std::move(data), |
| 540 | /*null_bitmap=*/nullptr, /*null_count=*/0); |
| 541 | } |
| 542 | return Status::OK(); |
| 543 | } |
| 544 | |
| 545 | Status TransferDate64(RecordReader* reader, MemoryPool* pool, |
| 546 | const std::shared_ptr<Field>& field, Datum* out) { |
no test coverage detected