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 17:27:15 GMT
Github user nonstop-qfchen commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/66#discussion_r38121957
  
    --- 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 --
    
    Can you confirm it by set a breaking point in SearchKey::init()?
    
    Thanks
    
    On Thu, Aug 27, 2015 at 12:04 PM, Suresh Subbiah <notifications@github.com>
    wrote:
    
    > In core/sql/optimizer/SearchKey.cpp
    > <https://github.com/apache/incubator-trafodion/pull/66#discussion_r38119659>
    > :
    >
    > > +   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 think we can get a nonlocal predicate if there is a OR (or a CASE)
    >
    > For example select * from t1 a, t1 b where a.col1 = 1 OR b.col2 = 2 ;
    > I think this predicate will get to pushed to both scans. It may end up
    > being a IS NOT NULL after codegen, precodegen should see the predicate I
    > think.
    >
    > —
    > Reply to this email directly or view it on GitHub
    > <https://github.com/apache/incubator-trafodion/pull/66/files#r38119659>.
    >
    
    
    
    -- 
    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