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

Function TransferFlbaTimestamp

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

Read a TIMESTAMP-annotated FLBA(12) column as a 64-bit Arrow timestamp.

Source from the content-addressed store, hash-verified

878
879// Read a TIMESTAMP-annotated FLBA(12) column as a 64-bit Arrow timestamp.
880Result<Datum> TransferFlbaTimestamp(RecordReader* reader, MemoryPool* pool,
881 const std::shared_ptr<Field>& field,
882 bool clamp_on_overflow) {
883 auto binary_reader = dynamic_cast<BinaryRecordReader*>(reader);
884 DCHECK(binary_reader);
885 ::arrow::ArrayVector chunks = binary_reader->GetBuilderChunks();
886
887 for (size_t i = 0; i < chunks.size(); ++i) {
888 const auto& values = checked_cast<const ::arrow::FixedSizeBinaryArray&>(*chunks[i]);
889 const int64_t length = values.length();
890 ARROW_ASSIGN_OR_RAISE(auto data,
891 ::arrow::AllocateBuffer(length * sizeof(int64_t), pool));
892 auto out_ptr = reinterpret_cast<int64_t*>(data->mutable_data());
893
894 int64_t j = 0;
895 RETURN_NOT_OK(::arrow::VisitArraySpanInline<::arrow::FixedSizeBinaryType>(
896 ::arrow::ArraySpan(*values.data()),
897 [&](std::string_view v) {
898 ARROW_ASSIGN_OR_RAISE(
899 out_ptr[j++],
900 FlbaTimestampToInt64(reinterpret_cast<const uint8_t*>(v.data()),
901 clamp_on_overflow));
902 return Status::OK();
903 },
904 [&]() {
905 out_ptr[j++] = 0;
906 return ::arrow::Status::OK();
907 }));
908
909 chunks[i] = std::make_shared<::arrow::TimestampArray>(
910 field->type(), length, std::move(data), values.null_bitmap(),
911 values.null_count());
912 }
913 if (!field->nullable()) {
914 ReconstructChunksWithoutNulls(&chunks);
915 }
916 return Datum(std::make_shared<ChunkedArray>(std::move(chunks), field->type()));
917}
918
919} // namespace
920

Callers 1

TransferColumnDataFunction · 0.85

Calls 14

FlbaTimestampToInt64Function · 0.85
nullableMethod · 0.80
ARROW_ASSIGN_OR_RAISEFunction · 0.70
ArraySpanClass · 0.50
OKFunction · 0.50
DatumFunction · 0.50
GetBuilderChunksMethod · 0.45
sizeMethod · 0.45
lengthMethod · 0.45
mutable_dataMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected