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

Method GetBuffer

be/src/exec/scanner-context.cc:216–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216Status ScannerContext::Stream::GetBuffer(bool peek, uint8_t** out_buffer, int64_t* len) {
217 *out_buffer = nullptr;
218 *len = 0;
219 if (eosr()) return Status::OK();
220
221 if (UNLIKELY(parent_->cancelled())) {
222 DCHECK(*out_buffer == nullptr);
223 return CONTEXT_CANCELLED;
224 }
225
226 if (boundary_buffer_bytes_left_ > 0) {
227 DCHECK(ValidateBufferPointers());
228 DCHECK_EQ(output_buffer_bytes_left_, &boundary_buffer_bytes_left_);
229 *out_buffer = boundary_buffer_pos_;
230 // Don't return more bytes past eosr
231 *len = min(boundary_buffer_bytes_left_, bytes_left());
232 DCHECK_GE(*len, 0);
233 if (!peek) {
234 AdvanceBufferPos(*len, &boundary_buffer_pos_, &boundary_buffer_bytes_left_);
235 total_bytes_returned_ += *len;
236 }
237 return Status::OK();
238 }
239
240 if (io_buffer_bytes_left_ == 0) {
241 // We're at the end of the boundary buffer and the current IO buffer. Get a new IO
242 // buffer and set the current buffer to it.
243 RETURN_IF_ERROR(GetNextBuffer());
244 // Check that we're not pointing to the IO buffer if there are bytes left in the
245 // boundary buffer.
246 DCHECK_EQ(boundary_buffer_bytes_left_, 0);
247 output_buffer_pos_ = &io_buffer_pos_;
248 output_buffer_bytes_left_ = &io_buffer_bytes_left_;
249 }
250 DCHECK(io_buffer_ != nullptr);
251
252 *out_buffer = io_buffer_pos_;
253 *len = io_buffer_bytes_left_;
254 if (!peek) {
255 AdvanceBufferPos(*len, &io_buffer_pos_, &io_buffer_bytes_left_);
256 total_bytes_returned_ += *len;
257 }
258 DCHECK_GE(bytes_left(), 0);
259 DCHECK(ValidateBufferPointers());
260 return Status::OK();
261}
262
263Status ScannerContext::Stream::GetBytesInternal(int64_t requested_len,
264 uint8_t** out_buffer, bool peek, int64_t* out_len) {

Callers 5

SkipToSyncMethod · 0.45
DecompressStreamMethod · 0.45
ReadPageHeaderMethod · 0.45
FillBytesToBufferMethod · 0.45
FillByteBufferMethod · 0.45

Calls 3

OKFunction · 0.85
minFunction · 0.85
cancelledMethod · 0.45

Tested by

no test coverage detected