| 496 | } |
| 497 | |
| 498 | void TupleCacheNode::ComputeFragmentInstanceKey(const RuntimeState* state) { |
| 499 | const PlanFragmentInstanceCtxPB& ctx = state->instance_ctx_pb(); |
| 500 | uint32_t hash = 0; |
| 501 | // Collect the HdfsScanNodes below this point. The HdfsScanNodes have information about |
| 502 | // the partitions that we need to include in the fragment instance key. Some locations |
| 503 | // may have a large number of scan nodes below them, so construct a map from the node |
| 504 | // id to the HdfsScanNodeBase. |
| 505 | vector<ExecNode*> scan_nodes; |
| 506 | CollectNodes(TPlanNodeType::HDFS_SCAN_NODE, &scan_nodes); |
| 507 | unordered_map<int, const HdfsScanNodeBase*> id_to_scan_node_map; |
| 508 | for (const ExecNode* exec_node : scan_nodes) { |
| 509 | const HdfsScanNodeBase* scan_node = |
| 510 | static_cast<const HdfsScanNodeBase*>(exec_node); |
| 511 | int node_id = exec_node->plan_node().tnode_->node_id; |
| 512 | DCHECK(id_to_scan_node_map.find(node_id) == id_to_scan_node_map.end()) |
| 513 | << "Duplicate scan node id: " << node_id; |
| 514 | id_to_scan_node_map[node_id] = scan_node; |
| 515 | } |
| 516 | for (int32_t node_id : plan_node().tnode_->tuple_cache_node.input_scan_node_ids) { |
| 517 | const HdfsTableDescriptor* hdfs_table = id_to_scan_node_map[node_id]->hdfs_table(); |
| 518 | DCHECK(hdfs_table != nullptr); |
| 519 | auto ranges = ctx.per_node_scan_ranges().find(node_id); |
| 520 | if (ranges == ctx.per_node_scan_ranges().end()) continue; |
| 521 | for (const ScanRangeParamsPB& params : ranges->second.scan_ranges()) { |
| 522 | // This only supports HDFS right now |
| 523 | DCHECK(params.scan_range().has_hdfs_file_split()); |
| 524 | const HdfsFileSplitPB& split = params.scan_range().hdfs_file_split(); |
| 525 | // Information on the partition can influence how files are processed. For example, |
| 526 | // for text files, the delimiter can be specified on the partition level. There |
| 527 | // are several such attributes. We need to incorporate the partition information |
| 528 | // into the hash for each file split. |
| 529 | const HdfsPartitionDescriptor* partition_desc = |
| 530 | hdfs_table->GetPartition(split.partition_id()); |
| 531 | DCHECK(partition_desc != nullptr); |
| 532 | if (partition_desc != nullptr) { |
| 533 | hash = HashHdfsPartitionDescriptor(partition_desc, hash); |
| 534 | } else { |
| 535 | LOG(WARNING) << "Partition id " << split.partition_id() |
| 536 | << " not found in table " << hdfs_table->fully_qualified_name() |
| 537 | << " split filename: " << split.relative_path(); |
| 538 | } |
| 539 | hash = HashHdfsFileSplit(split, hash); |
| 540 | } |
| 541 | } |
| 542 | fragment_instance_key_ = hash; |
| 543 | } |
| 544 | |
| 545 | } |
nothing calls this directly
no test coverage detected