You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2020/05/10 04:49:52 UTC
[hive] branch master updated: HIVE-22569 : PartitionPruner use
Collections Class (David Mollitor via Vineet Garg)
This is an automated email from the ASF dual-hosted git repository.
hashutosh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 4dccfc2 HIVE-22569 : PartitionPruner use Collections Class (David Mollitor via Vineet Garg)
4dccfc2 is described below
commit 4dccfc289e5922e03a91175bd57ab32475d23357
Author: David Mollitor <dm...@apache.org>
AuthorDate: Sat May 9 21:48:22 2020 -0700
HIVE-22569 : PartitionPruner use Collections Class (David Mollitor via Vineet Garg)
Signed-off-by: Ashutosh Chauhan <ha...@apache.org>
---
.../hive/ql/optimizer/calcite/RelOptHiveTable.java | 7 ++--
.../hive/ql/optimizer/ppr/PartitionPruner.java | 5 +--
.../apache/hadoop/hive/ql/parse/ParseContext.java | 2 +-
.../hadoop/hive/ql/parse/PrunedPartitionList.java | 37 +++++++++++-----------
4 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/RelOptHiveTable.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/RelOptHiveTable.java
index 1f6e1bc..5b0021f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/RelOptHiveTable.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/RelOptHiveTable.java
@@ -515,10 +515,11 @@ public class RelOptHiveTable implements RelOptTable {
computePartitionList(hiveConf, null, new HashSet<Integer>());
}
- ColumnStatsList colStatsCached = colStatsCache.get(partitionList.getKey());
+ String partitionListKey = partitionList.getKey().orElse(null);
+ ColumnStatsList colStatsCached = colStatsCache.get(partitionListKey);
if (colStatsCached == null) {
colStatsCached = new ColumnStatsList();
- colStatsCache.put(partitionList.getKey(), colStatsCached);
+ colStatsCache.put(partitionListKey, colStatsCached);
}
// 2. Obtain Col Stats for Non Partition Cols
@@ -751,7 +752,7 @@ public class RelOptHiveTable implements RelOptTable {
}
public String getPartitionListKey() {
- return partitionList != null ? partitionList.getKey() : null;
+ return partitionList != null ? partitionList.getKey().orElse(null) : null;
}
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ppr/PartitionPruner.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ppr/PartitionPruner.java
index 673d858..709b221 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ppr/PartitionPruner.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ppr/PartitionPruner.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hive.ql.optimizer.ppr;
import java.util.AbstractSequentialList;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -207,7 +208,7 @@ public class PartitionPruner extends Transform {
if (compactExpr == null || isBooleanExpr(compactExpr)) {
if (isFalseExpr(compactExpr)) {
return new PrunedPartitionList(tab, key + compactExpr.getExprString(true),
- new LinkedHashSet<Partition>(0), new ArrayList<String>(0), false);
+ Collections.emptySet(), Collections.emptyList(), false);
}
// For null and true values, return every partition
return getAllPartsFromCacheOrServer(tab, key, true, prunedPartitionsMap);
@@ -242,7 +243,7 @@ public class PartitionPruner extends Transform {
} catch (HiveException e) {
throw new SemanticException(e);
}
- ppList = new PrunedPartitionList(tab, key, parts, null, unknownPartitions);
+ ppList = new PrunedPartitionList(tab, key, parts, Collections.emptyList(), unknownPartitions);
if (partsCache != null) {
partsCache.put(key, ppList);
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseContext.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseContext.java
index bef0217..da443f4 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseContext.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseContext.java
@@ -431,7 +431,7 @@ public class ParseContext {
* @return col stats
*/
public ColumnStatsList getColStatsCached(PrunedPartitionList partList) {
- return ctx.getOpContext().getColStatsCache().get(partList.getKey());
+ return ctx.getOpContext().getColStatsCache().get(partList.getKey().orElse(null));
}
/**
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/PrunedPartitionList.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/PrunedPartitionList.java
index 4068735..398dbf5 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/PrunedPartitionList.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/PrunedPartitionList.java
@@ -19,7 +19,10 @@
package org.apache.hadoop.hive.ql.parse;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
import java.util.Set;
import org.apache.hadoop.hive.ql.metadata.Partition;
@@ -30,36 +33,32 @@ import org.apache.hadoop.hive.ql.metadata.Table;
*/
public class PrunedPartitionList {
- /** Key to identify this partition list. */
- private final String ppListKey;
-
/** Source table. */
private final Table source;
+ /** Key to identify this partition list. */
+ private final Optional<String> ppListKey;
+
/** Partitions that either satisfy the partition criteria, or may satisfy it. */
- private Set<Partition> partitions;
+ private final Set<Partition> partitions;
/** partition columns referred by pruner expr */
- private List<String> referred;
+ private final List<String> referred;
/** Whether there are partitions in the list that may or may not satisfy the criteria. */
- private boolean hasUnknowns;
+ private final boolean hasUnknowns;
public PrunedPartitionList(Table source, Set<Partition> partitions,
List<String> referred, boolean hasUnknowns) {
- this.source = source;
- this.ppListKey = null;
- this.referred = referred;
- this.partitions = partitions;
- this.hasUnknowns = hasUnknowns;
+ this(source, null, partitions, referred, hasUnknowns);
}
public PrunedPartitionList(Table source, String key, Set<Partition> partitions,
List<String> referred, boolean hasUnknowns) {
- this.source = source;
- this.ppListKey = key;
- this.referred = referred;
- this.partitions = partitions;
+ this.source = Objects.requireNonNull(source);
+ this.ppListKey = Optional.ofNullable(key);
+ this.referred = Objects.requireNonNull(referred);
+ this.partitions = Objects.requireNonNull(partitions);
this.hasUnknowns = hasUnknowns;
}
@@ -67,7 +66,7 @@ public class PrunedPartitionList {
return source;
}
- public String getKey() {
+ public Optional<String> getKey() {
return ppListKey;
}
@@ -75,7 +74,7 @@ public class PrunedPartitionList {
* @return partitions
*/
public Set<Partition> getPartitions() {
- return partitions;
+ return Collections.unmodifiableSet(partitions);
}
@@ -83,7 +82,7 @@ public class PrunedPartitionList {
* @return all partitions.
*/
public List<Partition> getNotDeniedPartns() {
- return new ArrayList<Partition>(partitions);
+ return Collections.unmodifiableList(new ArrayList<>(partitions));
}
/**
@@ -94,6 +93,6 @@ public class PrunedPartitionList {
}
public List<String> getReferredPartCols() {
- return referred;
+ return Collections.unmodifiableList(referred);
}
}