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

Function TransferInt96

cpp/src/parquet/arrow/reader_internal.cc:504–543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

502}
503
504Status 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
545Status TransferDate64(RecordReader* reader, MemoryPool* pool,
546 const std::shared_ptr<Field>& field, Datum* out) {

Callers 1

TransferColumnDataFunction · 0.85

Calls 11

Int96GetNanoSecondsFunction · 0.85
Int96GetMicroSecondsFunction · 0.85
Int96GetMilliSecondsFunction · 0.85
Int96GetSecondsFunction · 0.85
nullableMethod · 0.80
ReleaseIsValidMethod · 0.80
OKFunction · 0.50
valuesMethod · 0.45
mutable_dataMethod · 0.45
typeMethod · 0.45
null_countMethod · 0.45

Tested by

no test coverage detected