| 275 | } |
| 276 | |
| 277 | Status 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 | |
| 304 | void HdfsJsonScanner::GetNextBuffer(const char** begin, const char** end) { |
| 305 | DCHECK(*begin == *end); |
nothing calls this directly
no test coverage detected