| 156 | } |
| 157 | |
| 158 | Status BaseSequenceScanner::GetNextInternal(RowBatch* row_batch) { |
| 159 | if (only_parsing_header_) { |
| 160 | DCHECK(header_ == nullptr); |
| 161 | eos_ = true; |
| 162 | header_ = state_->obj_pool()->Add(AllocateFileHeader()); |
| 163 | Status status = ReadFileHeader(); |
| 164 | if (!status.ok()) { |
| 165 | scan_node_->UpdateRemainingScanRangeSubmissions(-1); |
| 166 | RETURN_IF_ERROR(state_->LogOrReturnError(status.msg())); |
| 167 | // We need to complete the ranges for this file. |
| 168 | CloseFileRanges(stream_->filename()); |
| 169 | return Status::OK(); |
| 170 | } |
| 171 | // Header is parsed, set the metadata in the scan node and issue more ranges. |
| 172 | scan_node_->SetFileMetadata( |
| 173 | context_->partition_descriptor()->id(), stream_->filename(), header_); |
| 174 | const HdfsFileDesc* desc = scan_node_->GetFileDesc( |
| 175 | context_->partition_descriptor()->id(), stream_->filename()); |
| 176 | // Issue the scan range with priority since it would result in producing a RowBatch. |
| 177 | status = scan_node_->AddDiskIoRanges(desc, EnqueueLocation::HEAD); |
| 178 | scan_node_->UpdateRemainingScanRangeSubmissions(-1); |
| 179 | return status; |
| 180 | } |
| 181 | if (eos_) return Status::OK(); |
| 182 | |
| 183 | int64_t tuple_buffer_size; |
| 184 | RETURN_IF_ERROR( |
| 185 | row_batch->ResizeAndAllocateTupleBuffer(state_, &tuple_buffer_size, &tuple_mem_)); |
| 186 | tuple_ = reinterpret_cast<Tuple*>(tuple_mem_); |
| 187 | DCHECK_GT(row_batch->capacity(), 0); |
| 188 | |
| 189 | Status status = ProcessRange(row_batch); |
| 190 | if (!status.ok()) { |
| 191 | // Log error from file format parsing. |
| 192 | // TODO(IMPALA-5922): Include the file and offset in errors inside the scanners. |
| 193 | if (!status.IsCancelled() && |
| 194 | !status.IsMemLimitExceeded() && |
| 195 | !status.IsInternalError() && |
| 196 | !status.IsDiskIoError() && |
| 197 | !status.IsThreadPoolError()) { |
| 198 | state_->LogError(ErrorMsg(TErrorCode::SEQUENCE_SCANNER_PARSE_ERROR, |
| 199 | stream_->filename(), stream_->file_offset(), |
| 200 | (stream_->eof() ? "(EOF)" : ""))); |
| 201 | } |
| 202 | |
| 203 | // This checks for abort_on_error. |
| 204 | RETURN_IF_ERROR(state_->LogOrReturnError(status.msg())); |
| 205 | |
| 206 | // Recover by skipping to the next sync. |
| 207 | parse_status_ = Status::OK(); |
| 208 | int64_t error_offset = stream_->file_offset(); |
| 209 | status = SkipToSync(header_->sync, SYNC_HASH_SIZE); |
| 210 | COUNTER_ADD(bytes_skipped_counter_, stream_->file_offset() - error_offset); |
| 211 | RETURN_IF_ERROR(status); |
| 212 | DCHECK(parse_status_.ok()); |
| 213 | } |
| 214 | return Status::OK(); |
| 215 | } |
nothing calls this directly
no test coverage detected