Read a TIMESTAMP-annotated FLBA(12) column as a 64-bit Arrow timestamp.
| 878 | |
| 879 | // Read a TIMESTAMP-annotated FLBA(12) column as a 64-bit Arrow timestamp. |
| 880 | Result<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 |
no test coverage detected