| 96 | Result<int64_t> BufferOutputStream::Tell() const { return position_; } |
| 97 | |
| 98 | Status BufferOutputStream::Write(const void* data, int64_t nbytes) { |
| 99 | if (ARROW_PREDICT_FALSE(!is_open_)) { |
| 100 | return Status::IOError("OutputStream is closed"); |
| 101 | } |
| 102 | DCHECK(buffer_); |
| 103 | if (ARROW_PREDICT_TRUE(nbytes > 0)) { |
| 104 | if (ARROW_PREDICT_FALSE(position_ + nbytes >= capacity_)) { |
| 105 | RETURN_NOT_OK(Reserve(nbytes)); |
| 106 | } |
| 107 | memcpy(mutable_data_ + position_, data, nbytes); |
| 108 | position_ += nbytes; |
| 109 | } |
| 110 | return Status::OK(); |
| 111 | } |
| 112 | |
| 113 | Status BufferOutputStream::Reserve(int64_t nbytes) { |
| 114 | // Always overallocate by doubling. It seems that it is a better growth |