| 243 | } |
| 244 | |
| 245 | Status HdfsScanPlanNode::ProcessScanRangesAndInitSharedState(FragmentState* state) { |
| 246 | // Initialize the template tuple pool. |
| 247 | using namespace org::apache::impala::fb; |
| 248 | shared_state_.template_pool_.reset(new MemPool(state->query_mem_tracker())); |
| 249 | auto& template_tuple_map_ = shared_state_.partition_template_tuple_map_; |
| 250 | ObjectPool* obj_pool = shared_state_.obj_pool(); |
| 251 | auto& file_descs = shared_state_.file_descs_; |
| 252 | HdfsFsCache::HdfsFsMap fs_cache; |
| 253 | int num_ranges_missing_volume_id = 0; |
| 254 | int64_t total_splits = 0; |
| 255 | const vector<const PlanFragmentInstanceCtxPB*>& instance_ctx_pbs = |
| 256 | state->instance_ctx_pbs(); |
| 257 | auto instance_ctxs = state->instance_ctxs(); |
| 258 | DCHECK_EQ(instance_ctxs.size(), instance_ctx_pbs.size()); |
| 259 | for (int i = 0; i < instance_ctxs.size(); ++i) { |
| 260 | auto ctx = instance_ctx_pbs[i]; |
| 261 | auto instance_ctx = instance_ctxs[i]; |
| 262 | auto ranges = ctx->per_node_scan_ranges().find(tnode_->node_id); |
| 263 | if (ranges == ctx->per_node_scan_ranges().end()) continue; |
| 264 | for (const ScanRangeParamsPB& params : ranges->second.scan_ranges()) { |
| 265 | DCHECK(params.scan_range().has_hdfs_file_split()); |
| 266 | const HdfsFileSplitPB& split = params.scan_range().hdfs_file_split(); |
| 267 | const org::apache::impala::fb::FbSplitFileMetadata* file_metadata = nullptr; |
| 268 | if (params.scan_range().has_file_metadata()) { |
| 269 | file_metadata = |
| 270 | flatbuffers::GetRoot<org::apache::impala::fb::FbSplitFileMetadata>( |
| 271 | params.scan_range().file_metadata().c_str()); |
| 272 | } |
| 273 | HdfsPartitionDescriptor* partition_desc = |
| 274 | hdfs_table_->GetPartition(split.partition_id()); |
| 275 | if (template_tuple_map_.find(split.partition_id()) == template_tuple_map_.end()) { |
| 276 | template_tuple_map_[split.partition_id()] = |
| 277 | InitTemplateTuple(partition_desc->partition_key_value_evals(), |
| 278 | shared_state_.template_pool_.get()); |
| 279 | } |
| 280 | // Convert the ScanRangeParamsPB into per-file DiskIO::ScanRange objects and |
| 281 | // populate partition_ids_, file_descs_, and per_type_files_. |
| 282 | if (partition_desc == nullptr) { |
| 283 | // TODO: this should be a DCHECK but we sometimes hit it. It's likely IMPALA-1702. |
| 284 | LOG(ERROR) << "Bad table descriptor! table_id=" << hdfs_table_->id() |
| 285 | << " partition_id=" << split.partition_id() << "\n" |
| 286 | << state->fragment() |
| 287 | << state->fragment_ctx().DebugString(); |
| 288 | return Status("Query encountered invalid metadata, likely due to IMPALA-1702." |
| 289 | " Try rerunning the query."); |
| 290 | } |
| 291 | |
| 292 | filesystem::path file_path; |
| 293 | if (hdfs_table_->IsIcebergTable() && split.relative_path().empty()) { |
| 294 | file_path.append(split.absolute_path(), filesystem::path::codecvt()); |
| 295 | } else { |
| 296 | file_path.append(partition_desc->location(), filesystem::path::codecvt()) |
| 297 | .append(split.relative_path(), filesystem::path::codecvt()); |
| 298 | } |
| 299 | |
| 300 | const string& native_file_path = file_path.native(); |
| 301 | |
| 302 | auto file_desc_map_key = make_pair(partition_desc->id(), native_file_path); |
nothing calls this directly
no test coverage detected