Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion ql/src/java/org/apache/hadoop/hive/ql/plan/MapWork.java
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,18 @@ public String getSamplingTypeString() {
@Override
public void configureJobConf(JobConf job) {
super.configureJobConf(job);
// Configure each table only once, even if we read thousands of its partitions.
// This avoids repeating expensive work (like loading storage drivers) for every single partition.
Set<TableDesc> processedTables = new HashSet<>();

for (PartitionDesc partition : aliasToPartnInfo.values()) {
PlanUtils.configureJobConf(partition.getTableDesc(), job);
TableDesc tableDesc = partition.getTableDesc();

// If we haven't seen this table before, configure it and remember it.
// If we have seen it, skip it.
if (tableDesc != null && processedTables.add(tableDesc)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although add works here, what do you think about using contains instead? It separates the "checking" from "adding" logic and it is easier to read and maintain the code.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I agree readability is important.

I'm happy to change it to contains() + add() if you think that's clearer. Let me know your preference and I'll update the PR accordingly.

if (tableDesc != null && !processedTables.contains(tableDesc)) {
  processedTables.add(tableDesc);
  PlanUtils.configureJobConf(tableDesc, job);
}

PlanUtils.configureJobConf(tableDesc, job);
}
}
Collection<Operator<?>> mappers = aliasToWork.values();
for (IConfigureJobConf icjc : OperatorUtils.findOperators(mappers, IConfigureJobConf.class)) {
Expand Down