Must be called after addChild()/addConstExprList(). Computes the materialized result/const expr lists based on the materialized slots of this UnionNode's produced tuple. The UnionNode doesn't need an smap: like a ScanNode, it materializes an original tuple. There is no need to call assignConjuncts()
(Analyzer analyzer)
| 310 | * been evaluated during registration to set analyzer.hasEmptyResultSet_. |
| 311 | */ |
| 312 | @Override |
| 313 | public void init(Analyzer analyzer) { |
| 314 | Preconditions.checkState(conjuncts_.isEmpty()); |
| 315 | computeMemLayout(analyzer); |
| 316 | computeStats(analyzer); |
| 317 | computePassthrough(analyzer); |
| 318 | |
| 319 | // drop resultExprs/constExprs that aren't getting materialized (= where the |
| 320 | // corresponding output slot isn't being materialized) |
| 321 | materializedResultExprLists_.clear(); |
| 322 | Preconditions.checkState(resultExprLists_.size() == children_.size()); |
| 323 | List<SlotDescriptor> slots = analyzer.getDescTbl().getTupleDesc(tupleId_).getSlots(); |
| 324 | for (int i = 0; i < resultExprLists_.size(); ++i) { |
| 325 | List<Expr> exprList = resultExprLists_.get(i); |
| 326 | List<Expr> newExprList = new ArrayList<>(); |
| 327 | Preconditions.checkState(exprList.size() == slots.size()); |
| 328 | for (int j = 0; j < exprList.size(); ++j) { |
| 329 | if (slots.get(j).isMaterialized()) newExprList.add(exprList.get(j)); |
| 330 | } |
| 331 | materializedResultExprLists_.add( |
| 332 | Expr.substituteList(newExprList, getChild(i).getOutputSmap(), analyzer, true)); |
| 333 | } |
| 334 | Preconditions.checkState( |
| 335 | materializedResultExprLists_.size() == getChildren().size()); |
| 336 | |
| 337 | materializedConstExprLists_.clear(); |
| 338 | for (List<Expr> exprList: constExprLists_) { |
| 339 | Preconditions.checkState(exprList.size() == slots.size()); |
| 340 | List<Expr> newExprList = new ArrayList<>(); |
| 341 | for (int i = 0; i < exprList.size(); ++i) { |
| 342 | if (slots.get(i).isMaterialized()) { |
| 343 | Expr constExpr = exprList.get(i); |
| 344 | // Disable codegen for const expressions which will only ever be evaluated once. |
| 345 | if (!isInSubplan_) constExpr.disableCodegen(); |
| 346 | newExprList.add(constExpr); |
| 347 | } |
| 348 | } |
| 349 | materializedConstExprLists_.add(newExprList); |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | @Override |
| 354 | protected void toThrift(TPlanNode msg) { |
no test coverage detected