@@ -41,82 +41,6 @@ class TimestampColumnReader : public IntegerColumnReader {
4141 prepareRead<int128_t >(offset, rows, nullptr );
4242 readCommon<IntegerColumnReader>(rows);
4343 }
44-
45- void getValues (RowSet rows, VectorPtr* result) override {
46- auto type = nodeType_->type ;
47- VELOX_CHECK (type->kind () == TypeKind::TIMESTAMP, " Timestamp expected." );
48- VELOX_CHECK_NE (valueSize_, kNoValueSize );
49- VELOX_CHECK (mayGetValues_);
50- if (allNull_) {
51- *result = std::make_shared<ConstantVector<Timestamp>>(
52- &memoryPool_,
53- rows.size (),
54- true ,
55- type,
56- Timestamp (),
57- SimpleVectorStats<Timestamp>{},
58- sizeof (Timestamp) * rows.size ());
59- return ;
60- }
61- VELOX_CHECK_LE (rows.size (), numValues_);
62- VELOX_CHECK (!rows.empty ());
63- if (!values_) {
64- return ;
65- }
66-
67- auto tsValues = AlignedBuffer::allocate<Timestamp>(
68- rows.size (), &memoryPool_, Timestamp ());
69- auto * valuesPtr = tsValues->asMutable <Timestamp>();
70- char * rawValues = reinterpret_cast <char *>(rawValues_);
71-
72- vector_size_t rowIndex = 0 ;
73- auto nextRow = rows[rowIndex];
74- bool moveNulls = shouldMoveNulls (rows);
75- bool emptyOutputRows = outputRows_.size () == 0 ;
76- for (size_t i = 0 ; i < numValues_; i++) {
77- if (!emptyOutputRows && outputRows_[i] < nextRow) {
78- continue ;
79- }
80- VELOX_DCHECK (emptyOutputRows || (outputRows_[i] == nextRow));
81-
82- // Convert the timestamp into seconds and nanos since the Unix epoch,
83- // 00:00:00.000000 on 1 January 1970.
84- uint64_t nanos;
85- memcpy (&nanos, rawValues + nextRow * sizeof (int96_t ), sizeof (uint64_t ));
86- int32_t days;
87- memcpy (
88- &days,
89- rawValues + nextRow * sizeof (int96_t ) + sizeof (uint64_t ),
90- sizeof (int32_t ));
91- valuesPtr[rowIndex] = Timestamp (
92- (days - JULIAN_TO_UNIX_EPOCH_DAYS) * SECONDS_PER_DAY, nanos);
93-
94- if (moveNulls && rowIndex != i) {
95- bits::setBit (
96- rawResultNulls_, rowIndex, bits::isBitSet (rawResultNulls_, i));
97- }
98- if (!emptyOutputRows) {
99- outputRows_[rowIndex] = nextRow;
100- }
101- rowIndex++;
102- if (rowIndex >= rows.size ()) {
103- break ;
104- }
105- nextRow = rows[rowIndex];
106- }
107-
108- BufferPtr nulls = anyNulls_
109- ? (returnReaderNulls_ ? nullsInReadRange_ : resultNulls_)
110- : nullptr ;
111-
112- *result = std::make_shared<FlatVector<Timestamp>>(
113- &memoryPool_,
114- type,
115- nulls,
116- rows.size (),
117- tsValues,
118- std::move (stringBuffers_));
119- }
12044};
12145
12246} // namespace facebook::velox::parquet
0 commit comments