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

Method getIOBuf

bolt/common/memory/ByteStream.cpp:444–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442} // namespace
443
444std::unique_ptr<folly::IOBuf> IOBufOutputStream::getIOBuf(
445 const std::function<void()>& releaseFn) {
446 // Make an IOBuf for each range. The IOBufs keep shared ownership of
447 // 'arena_'.
448 std::unique_ptr<folly::IOBuf> iobuf;
449 auto& ranges = out_->ranges();
450 for (auto& range : ranges) {
451 auto numValues =
452 &range == &ranges.back() ? out_->lastRangeEnd() : range.size;
453 auto userData = newFreeData(arena_, releaseFn);
454 auto newBuf = folly::IOBuf::takeOwnership(
455 reinterpret_cast<char*>(range.buffer), numValues, freeFunc, userData);
456 if (iobuf) {
457 iobuf->prev()->appendChain(std::move(newBuf));
458 } else {
459 iobuf = std::move(newBuf);
460 }
461 }
462 return iobuf;
463}
464
465std::streampos IOBufOutputStream::tellp() const {
466 return out_->tellp();

Callers 4

rowVectorToIOBufFunction · 0.45
flushMethod · 0.45
flushCompressedFunction · 0.45
TEST_FFunction · 0.45

Calls 3

newFreeDataFunction · 0.85
backMethod · 0.80
lastRangeEndMethod · 0.80

Tested by

no test coverage detected