Github user zellerh commented on a diff in the pull request:

    
https://github.com/apache/incubator-trafodion/pull/1051#discussion_r111205972
  
    --- Diff: core/sql/optimizer/ValueDesc.cpp ---
    @@ -2764,6 +2764,54 @@ NABoolean 
ValueIdSet::containsAsEquiLocalPred(ValueId x) const
     
     } // ValueIdSet::containsAsEquiPred()
     
    +NABoolean ValueIdSet::containsAsRangeLocalPred(ValueId x) const
    +{
    +  NABoolean result = FALSE; // until proven otherwise
    +  if (entries() <= 0)
    +    return result; // has no predicates at all
    +  ItemExpr* constExpr = NULL;
    +  NABoolean found = FALSE;
    +
    +  for (ValueId vid = init(); next(vid); advance(vid))
    +  {
    +    ItemExpr *expr = vid.getItemExpr();
    +    switch (expr->getOperatorType())
    +    {      
    +    case ITM_LESS:
    +    case ITM_LESS_EQ:
    +    case ITM_LESS_OR_LE:
    +    case ITM_GREATER:
    +    case ITM_GREATER_EQ:
    +    case ITM_GREATER_OR_GE:
    +      
    +      // consider range-predicate "a<1", "1>a", "a>1" or "1<xa" 
    +      for (CollIndex i=0; i<2; i++ ) {
    +        if ( expr->child(i)->getOperatorType() == ITM_VEG_REFERENCE ) 
    +        {
    +          ItemExpr* childExpr = expr->child(i);
    +          found = ((VEGReference*)(childExpr))->getVEG()
    +            ->getAllValues().contains(x);
    +        } else
    +          found = (expr->child(i) == x);
    +        
    +        if (found) {
    +          CollIndex j = (i==0) ? 1 : 0;
    +          ValueIdSet vset(expr->child(j));
    --- End diff --
    
    Would it make sense to bypass creation of a ValueIdSet with one member and 
call method ItemExpr::doesExprEvaluateToConstant(FALSE, TRUE) directly? Maybe 
we don't even need this entire method if we go with the proposal above?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to