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

Method ensureInput

bolt/dwio/common/compression/PagedInputStream.cpp:87–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87const char* PagedInputStream::ensureInput(size_t availableInputBytes) {
88 auto input = inputBufferPtr_;
89 if (remainingLength_ <= availableInputBytes) {
90 inputBufferPtr_ += availableInputBytes;
91 return input;
92 }
93 // make sure input buffer has capacity
94 if (inputBuffer_.capacity() < remainingLength_) {
95 inputBuffer_.reserve(remainingLength_);
96 }
97
98 std::copy(
99 inputBufferPtr_,
100 inputBufferPtr_ + availableInputBytes,
101 inputBuffer_.data());
102 inputBufferPtr_ += availableInputBytes;
103
104 for (size_t pos = availableInputBytes; pos < remainingLength_;) {
105 readBuffer(true);
106 availableInputBytes = std::min(
107 static_cast<size_t>(inputBufferPtrEnd_ - inputBufferPtr_),
108 remainingLength_ - pos);
109 std::copy(
110 inputBufferPtr_,
111 inputBufferPtr_ + availableInputBytes,
112 inputBuffer_.data() + pos);
113 pos += availableInputBytes;
114 inputBufferPtr_ += availableInputBytes;
115 }
116 return inputBuffer_.data();
117}
118
119bool PagedInputStream::Next(const void** data, int32_t* size) {
120 BOLT_CHECK_NOT_NULL(data);

Callers

nothing calls this directly

Calls 6

readBufferFunction · 0.85
copyFunction · 0.50
minFunction · 0.50
capacityMethod · 0.45
reserveMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected