| 197 | } |
| 198 | |
| 199 | Status 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 | |
| 228 | template <class BuilderType> |
| 229 | Status AppendBinaryBatch(liborc::ColumnVectorBatch* column_vector_batch, int64_t offset, |
no test coverage detected