trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nonstop-qfchen <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request: fix #JIRA 1449: missing end key.
Date Thu, 27 Aug 2015 16:23:55 GMT
Github user nonstop-qfchen commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/66#discussion_r38115277
  
    --- Diff: core/sql/optimizer/SearchKey.cpp ---
    @@ -2711,6 +2716,65 @@ void SearchKey::computeCoveredLeadingKeys()
       }
     }
     
    +void SearchKey::computeFullKeyPredicates(ValueIdSet& predicates)
    +{
    +  // If the key column is an INDEX COLUMN, convert it into a base column
    +  ValueIdList baseKeyCols;
    +
    +  ValueId vid;
    +  const ValueIdList& keyColumns = getKeyColumns();
    +  for (CollIndex i=0; i<keyColumns.entries(); i++ ) {
    +     if ( keyColumns[i].getItemExpr()->getOperatorType() == ITM_INDEXCOLUMN )
    +       vid = ((IndexColumn*)(keyColumns[i].getItemExpr()))->getDefinition();
    +     else
    +       vid = keyColumns[i];
    +
    +     baseKeyCols.insertAt(baseKeyCols.entries(), vid);
    +  }
    +
    +  // compute the # of leading key columns covered by the key columns 
    +  // in the disjunct.
    +   ValueIdSet columnsCoveredByKey;
    +
    +   vid = predicates.init();
    +   for (; predicates.next(vid); predicates.advance(vid)) {
    +
    +      columnsCoveredByKey.clear();
    +      vid.getItemExpr()->findAll(ITM_BASECOLUMN, columnsCoveredByKey, TRUE, TRUE);
    +
    +      // for each vid (or predicate), check the base column list
    +      for (CollIndex i=0; i<baseKeyCols.entries(); i++ ) {
    +
    +         NABoolean found = FALSE;
    +
    +         // the predicate directly refers the base column 
    +         if ( columnsCoveredByKey.containsTheGivenValue(baseKeyCols[i]) ) {
    +            fullKeyPredicates_ += vid;
    +            found = TRUE;
    +         } else {
    --- End diff --
    
    The new method is modeled from SearchKey::computeCoveredLeadingKeys().
    
    The case of dealing the same table twice is interesting. But I think all
    the predicates we are dealing are local, right?
    
    On Thu, Aug 27, 2015 at 10:53 AM, Suresh Subbiah <notifications@github.com>
    wrote:
    
    > In core/sql/optimizer/SearchKey.cpp
    > <https://github.com/apache/incubator-trafodion/pull/66#discussion_r38111897>
    > :
    >
    > > +   vid = predicates.init();
    > > +   for (; predicates.next(vid); predicates.advance(vid)) {
    > > +
    > > +      columnsCoveredByKey.clear();
    > > +      vid.getItemExpr()->findAll(ITM_BASECOLUMN, columnsCoveredByKey, TRUE,
TRUE);
    > > +
    > > +      // for each vid (or predicate), check the base column list
    > > +      for (CollIndex i=0; i<baseKeyCols.entries(); i++ ) {
    > > +
    > > +         NABoolean found = FALSE;
    > > +
    > > +         // the predicate directly refers the base column
    > > +         if ( columnsCoveredByKey.containsTheGivenValue(baseKeyCols[i]) ) {
    > > +            fullKeyPredicates_ += vid;
    > > +            found = TRUE;
    > > +         } else {
    >
    > I don't understand why we need this else branch? Is it because a
    > particular basecolumn may have different valueids and we may not have found
    > a match the "contains" check in the if branch.Can you please give an
    > example where the else branch was actually taken?
    > Also could comparing by position lead to a false hit in the case where the
    > same table is scanned twice? If we have an OR pred then we can get columns
    > from a the second scan in the preds for the first table scan (I think). If
    > we just compare by position we may think we have a match but the column may
    > refer to the second scan and not the first. Not sure if this will happen as
    > something else could prevent this from happening.
    >
    > —
    > Reply to this email directly or view it on GitHub
    > <https://github.com/apache/incubator-trafodion/pull/66/files#r38111897>.
    >
    
    
    
    -- 
    Regards, --Qifan



---
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