MCPcopy Create free account
hub / github.com/apache/impala / GrowBuffer

Method GrowBuffer

be/src/runtime/string-buffer.h:82–97  ·  view source on GitHub ↗

Grows the buffer to be at least 'new_size', copying over the previous data into the new buffer. The old buffer is not freed. Return an error status if growing the buffer will exceed memory limit.

Source from the content-addressed store, hash-verified

80 /// into the new buffer. The old buffer is not freed. Return an error status if
81 /// growing the buffer will exceed memory limit.
82 Status GrowBuffer(int64_t new_size) WARN_UNUSED_RESULT {
83 if (LIKELY(new_size > buffer_size_)) {
84 int64_t old_size = buffer_size_;
85 buffer_size_ = std::max<int64_t>(buffer_size_ * 2, new_size);
86 char* new_buffer = reinterpret_cast<char*>(pool_->TryAllocate(buffer_size_));
87 if (UNLIKELY(new_buffer == NULL)) {
88 string details =
89 strings::Substitute("StringBuffer failed to grow buffer from $0 to $1 bytes.",
90 old_size, buffer_size_);
91 return pool_->mem_tracker()->MemLimitExceeded(NULL, details, buffer_size_);
92 }
93 if (LIKELY(len_ > 0)) memcpy(new_buffer, buffer_, len_);
94 buffer_ = new_buffer;
95 }
96 return Status::OK();
97 }
98
99 /// Returns the number of bytes consumed in the buffer.
100 int64_t len() const { return len_; }

Callers 1

GetBytesInternalMethod · 0.80

Calls 5

SubstituteFunction · 0.85
OKFunction · 0.85
TryAllocateMethod · 0.45
MemLimitExceededMethod · 0.45
mem_trackerMethod · 0.45

Tested by

no test coverage detected