abstractdog commented on code in PR #6344:
URL: https://github.com/apache/hive/pull/6344#discussion_r2883188117
##########
ql/src/java/org/apache/hadoop/hive/ql/plan/MapWork.java:
##########
@@ -364,20 +364,46 @@ public void internTable(Interner<TableDesc> interner) {
}
}
- /**
- * @return the aliasToPartnInfo
- */
- public Map<String, PartitionDesc> getAliasToPartnInfo() {
- return aliasToPartnInfo;
+ public Collection<PartitionDesc> getPartitionDescs() {
+ if (aliasToPartnInfo == null) {
+ return Collections.emptyList();
+ }
+ return Collections.unmodifiableCollection(aliasToPartnInfo.values());
}
- /**
- * @param aliasToPartnInfo
- * the aliasToPartnInfo to set
- */
- public void setAliasToPartnInfo(
- LinkedHashMap<String, PartitionDesc> aliasToPartnInfo) {
- this.aliasToPartnInfo = aliasToPartnInfo;
+ public PartitionDesc getPartitionDesc(String alias) {
+ return aliasToPartnInfo == null ? null : aliasToPartnInfo.get(alias);
+ }
+
+ public int getPartitionCount() {
+ return aliasToPartnInfo == null ? 0 : aliasToPartnInfo.size();
+ }
+
+ public boolean hasPartitionDesc(String alias) {
+ return aliasToPartnInfo != null && aliasToPartnInfo.containsKey(alias);
+ }
+
+ public void putPartitionDesc(String alias, PartitionDesc partitionDesc) {
+ if (aliasToPartnInfo == null) {
+ aliasToPartnInfo = new LinkedHashMap<>();
+ }
+ aliasToPartnInfo.put(alias, partitionDesc);
+ }
+
+ public void putAllPartitionDescs(Map<String, PartitionDesc> partitionDescs) {
+ if (partitionDescs == null || partitionDescs.isEmpty()) {
+ return;
+ }
+ if (aliasToPartnInfo == null) {
+ aliasToPartnInfo = new LinkedHashMap<>();
Review Comment:
can we rely on the current instance, like:
```
private Map<String, PartitionDesc> aliasToPartnInfo = new
LinkedHashMap<String, PartitionDesc>();
```
this ensures that we have an instance and don't need the extra null checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]