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

Function TransferInt96

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

Source from the content-addressed store, hash-verified

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