trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DaveBirdsall <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #772: Do not merge! Preview of TRAFODION-21...
Date Wed, 26 Oct 2016 22:57:09 GMT
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/772#discussion_r85229943
  
    --- Diff: core/sql/generator/GenPreCode.cpp ---
    @@ -6058,6 +6059,98 @@ RelExpr * MapValueIds::preCodeGen(Generator * generator,
     
       getGroupAttr()->addCharacteristicInputs(pulledNewInputs);
     
    +  if (cseRef_)
    +    {
    +      // -------------------------------------------------------------
    +      // This MapValueIds represents a common subexpression.
    +      //
    +      // We need to take some actions here to help with VEG rewrite,
    +      // since we eliminated some nodes from the tree, while the
    +      // VEGies still contain all equated values, including those that
    +      // got eliminated. Furthermore, the one tree that was chosen for
    +      // materialization got moved and we need to make sure that the
    +      // place where we scan the temp table produces the same ValueIds
    +      // that were marked as "Bridge Values" when we processed the
    +      // insert into temp statement.
    +      // -------------------------------------------------------------
    +
    +      ValueIdSet cseVEGPreds;
    +      const ValueIdList &vegCols(cseRef_->getColumnList());
    +      ValueIdSet nonVegCols(cseRef_->getNonVEGColumns());
    +      NABoolean isAnalyzingConsumer =
    +        (CmpCommon::statement()->getCSEInfo(cseRef_->getName())->
    +           getIdOfAnalyzingConsumer() == cseRef_->getId());
    +
    +      // find all the VEG predicates of the original columns that this
    +      // common subexpression represents...
    +      for (CollIndex v=0; v<vegCols.entries(); v++)
    +        if (vegCols[v].getItemExpr()->getOperatorType() == ITM_VEG_REFERENCE)
    +          {
    +            // look at one particular VEG that is produced by this
    +            // query tree
    +            VEG *veg =
    +              static_cast<VEGReference *>(vegCols[v].getItemExpr())->getVEG();
    +
    +            if (isAnalyzingConsumer && veg->getBridgeValues().entries() >
0)
    +              {
    +                // If we are looking at the analyzing consumer, then
    +                // its child tree "C" got transformed into an
    +                // "insert overwrite table "temp" select * from "C".
    +
    +                // This insert into temp statement chose some VEG
    +                // member as the "bridge value". Find this bridge
    +                // value and choose it to represent the VEG here.
    +                const ValueIdSet &vegMembers(veg->getAllValues());
    +
    +                // collect all VEG members produced and subtract them
    +                // from the values to be used for VEG rewrite
    +                ValueIdSet subtractions(cseRef_->getNonVEGColumns());
    +                // then add back only the bridge value
    +                ValueIdSet additions;
    +                ValueId baseCol;
    +
    +                // get the VEG members produced by child C
    +                subtractions.intersectSet(vegMembers);
    +
    +                // augment the base columns with their index columns,
    +                // the bridge value is likely an index column
    +                for (ValueId v=subtractions.init();
    +                     subtractions.next(v);
    +                     subtractions.advance(v))
    +                  if (v.getItemExpr()->getOperatorType() == ITM_BASECOLUMN)
    +                    {
    +                      subtractions +=
    +                        static_cast<BaseColumn *>(v.getItemExpr())->getEIC();
    +                      baseCol = v;
    --- End diff --
    
    baseCol doesn't seem to be used anywhere?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message