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

Function AppendTimestampBatch

cpp/src/arrow/adapters/orc/util.cc:199–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199Status AppendTimestampBatch(liborc::ColumnVectorBatch* column_vector_batch,
200 int64_t offset, int64_t length, ArrayBuilder* abuilder) {
201 auto builder = checked_cast<TimestampBuilder*>(abuilder);
202 auto batch = checked_cast<liborc::TimestampVectorBatch*>(column_vector_batch);
203
204 const int64_t* seconds = batch->data.data() + offset;
205 const int64_t* nanos = batch->nanoseconds.data() + offset;
206
207 const bool has_nulls = batch->hasNulls;
208 RETURN_NOT_OK(builder->Reserve(length));
209 for (int64_t i = 0; i < length; i++) {
210 if (has_nulls && !batch->notNull[offset + i]) {
211 builder->UnsafeAppendNull();
212 continue;
213 }
214 // A timestamp past ~year 2262 does not fit in int64 nanoseconds; computing
215 // it with a bare `seconds * kOneSecondNanos` is signed overflow.
216 int64_t value;
217 if (ARROW_PREDICT_FALSE(
218 internal::MultiplyWithOverflow(seconds[i], kOneSecondNanos, &value) ||
219 internal::AddWithOverflow(value, nanos[i], &value))) {
220 return Status::Invalid("ORC timestamp (", seconds[i], "s + ", nanos[i],
221 "ns) is out of range for nanosecond resolution");
222 }
223 builder->UnsafeAppend(value);
224 }
225 return Status::OK();
226}
227
228template <class BuilderType>
229Status AppendBinaryBatch(liborc::ColumnVectorBatch* column_vector_batch, int64_t offset,

Callers 1

AppendBatchFunction · 0.85

Calls 8

MultiplyWithOverflowFunction · 0.85
AddWithOverflowFunction · 0.85
InvalidFunction · 0.50
OKFunction · 0.50
dataMethod · 0.45
ReserveMethod · 0.45
UnsafeAppendNullMethod · 0.45
UnsafeAppendMethod · 0.45

Tested by

no test coverage detected