MCPcopy Create free account
hub / github.com/bytedance/bolt / extend

Method extend

bolt/common/memory/ByteStream.cpp:337–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335}
336
337void ByteOutputStream::extend(int32_t bytes) {
338 if (current_ && current_->position != current_->size) {
339 LOG(FATAL) << "Extend ByteOutputStream before range full: "
340 << current_->position << " vs. " << current_->size;
341 }
342
343 // Check if rewriting existing content. If so, move to next range and start at
344 // 0.
345 if ((current_ != nullptr) && (current_ != &ranges_.back())) {
346 ++current_;
347 current_->position = 0;
348 return;
349 }
350
351 ranges_.emplace_back();
352 current_ = &ranges_.back();
353 lastRangeEnd_ = 0;
354 arena_->newRange(
355 newRangeSize(bytes),
356 ranges_.size() == 1 ? nullptr : &ranges_[ranges_.size() - 2],
357 current_);
358 allocatedBytes_ += current_->size;
359 BOLT_CHECK_GT(allocatedBytes_, 0);
360 if (isBits_) {
361 // size and position are in units of bits for a bits stream.
362 current_->size *= 8;
363 }
364}
365
366int32_t ByteOutputStream::newRangeSize(int32_t bytes) const {
367 const int32_t newSize = allocatedBytes_ + bytes;

Callers 5

package_infoMethod · 0.45
normalize_postFunction · 0.45
validateMethod · 0.45
package_infoMethod · 0.45
run_sqlFunction · 0.45

Calls 3

backMethod · 0.80
newRangeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected