soumyakanti3578 commented on code in PR #6700:
URL: https://github.com/apache/hive/pull/6700#discussion_r3858099288
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnAccessInfo.java:
##########
@@ -92,6 +92,20 @@ public Map<String, List<String>>
getTableToColumnAllAccessMap() {
return mapping;
}
+ /**
+ * Merge direct column accesses from another ColumnAccessInfo into this one.
+ */
+ public void merge(ColumnAccessInfo other) {
+ if (other == null) {
+ return;
+ }
+ for (Map.Entry<String, List<String>> entry :
other.getTableToColumnAccessMap().entrySet()) {
+ for (String col : entry.getValue()) {
+ add(entry.getKey(), col);
+ }
+ }
+ }
Review Comment:
Currently the merge method is super inefficient as there are two for loops,
call to `getTableToColumnAccessMap`, which itself has a nested for and streams,
and this `merge` method is also called from a `for` loop.
Correct me if I am wrong, but I believe you are calling
`getTableToColumnAccessMap` to get just the `Access.DIRECT` columns. But then
we are also creating new `ColumnAccess` objects in `add`. Instead can we use
this:
```
public void merge(ColumnAccessInfo other) {
if (other == null) {
return;
}
for (Map.Entry<String, ColumnAccess> entry :
other.tableToColumnAccessMap.entries()) {
if (entry.getValue().access == Access.DIRECT) {
tableToColumnAccessMap.put(entry.getKey(), entry.getValue());
}
}
}
```
--
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]