| 250 | } |
| 251 | |
| 252 | Status ChunkedBinaryBuilder::Reserve(int64_t values) { |
| 253 | if (ARROW_PREDICT_FALSE(extra_capacity_ != 0)) { |
| 254 | extra_capacity_ += values; |
| 255 | return Status::OK(); |
| 256 | } |
| 257 | |
| 258 | auto current_capacity = builder_->capacity(); |
| 259 | auto min_capacity = builder_->length() + values; |
| 260 | if (current_capacity >= min_capacity) { |
| 261 | return Status::OK(); |
| 262 | } |
| 263 | |
| 264 | auto new_capacity = BufferBuilder::GrowByFactor(current_capacity, min_capacity); |
| 265 | if (ARROW_PREDICT_TRUE(new_capacity <= max_chunk_length_)) { |
| 266 | return builder_->Resize(new_capacity); |
| 267 | } |
| 268 | |
| 269 | extra_capacity_ = new_capacity - max_chunk_length_; |
| 270 | return builder_->Resize(max_chunk_length_); |
| 271 | } |
| 272 | |
| 273 | } // namespace internal |
| 274 | |