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

Method FillBytesToBuffer

be/src/exec/json/hdfs-json-scanner.cc:277–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275}
276
277Status HdfsJsonScanner::FillBytesToBuffer(uint8_t** buffer, int64_t* bytes_read) {
278 if (scanner_state_ == PAST_SCANNING) {
279 // In the PAST_SCANNING state, we only read a small block data at a time for scanning.
280 // If the parser completes the parsing of the last json object, it will exit the loop
281 // due to BreakParse().
282 Status status;
283 if (UNLIKELY(!stream_->GetBytes(NEXT_BLOCK_READ_SIZE, buffer, bytes_read, &status))) {
284 DCHECK(!status.ok());
285 return status;
286 }
287
288 // A special case is when the first character of the next scan range is a newline
289 // character (perhaps with other whitespace characters before it). Our scan should
290 // stop at the first newline character in the next range, while the parser skips
291 // whitespace characters. If we don't handle this case, the first line of the next
292 // range will be scanned twice. Therefore, we need to return directly here to inform
293 // the parser that eos has been reached.
294 if (UNLIKELY(AllWhitespaceBeforeNewline(*buffer, *bytes_read))) {
295 scanner_state_ = FINISHED;
296 *bytes_read = 0;
297 }
298 } else {
299 RETURN_IF_ERROR(stream_->GetBuffer(false, buffer, bytes_read));
300 }
301 return Status::OK();
302}
303
304void HdfsJsonScanner::GetNextBuffer(const char** begin, const char** end) {
305 DCHECK(*begin == *end);

Callers

nothing calls this directly

Calls 5

OKFunction · 0.85
GetBytesMethod · 0.45
okMethod · 0.45
GetBufferMethod · 0.45

Tested by

no test coverage detected