Github user nonstop-qfchen commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/255#discussion_r49468359
  
    --- Diff: core/sql/generator/GenPreCode.cpp ---
    @@ -11274,6 +11274,485 @@ short 
HbaseAccess::extractHbaseFilterPreds(Generator * generator,
       return 0;
     }
     
    
+////////////////////////////////////////////////////////////////////////////
    +// To push down, the predicate must have the following form:
    +//  xp:=  <column>  <op>  <value-expr>
    +//  xp:=  <column> is not null (no support for hbase lookup)
    +//  xp:=  <column> is null (no support for hbase lookup)
    +//           (xp:=<column> like <value-expr> not yet implemented)
    +//  xp:=<xp> OR <xp> (not evaluated in isHbaseFilterPredV2, but by 
extractHbaseFilterPredV2)
    +//  xp:=<xp> AND <xp>(not evaluated in isHbaseFilterPredV2, but by 
extractHbaseFilterPredV2)
    +//
    +// and all of the following conditions must be met:
    +//
    +//      <column>:       a base table or index column which can be 
serialized and belong to the table being scanned.
    +//                            serialized: either the column doesn't need 
encoding, like
    +//                                            an unsigned integer,  or the 
column
    +//                                            was declared with the 
SERIALIZED option.
    +//                                         it also must not be an added 
column with default non null.
    +//      <op>:              eq, ne, gt, ge, lt, le
    +//      <value-expr>:  an expression that only contains const or param 
values, and
    +//                     <value-expr>'s datatype is not a superset of 
<column>'s datatype.
    +//
    
+/////////////////////////////////////////////////////////////////////////////
    +NABoolean HbaseAccess::isHbaseFilterPredV2(Generator * generator, ItemExpr 
* ie,
    +                                    ValueId &colVID, ValueId &valueVID,
    +                                    NAString &op)
    +{
    +  NABoolean foundBinary = FALSE;
    +  NABoolean foundUnary = FALSE;
    +  NABoolean hbaseLookupPred = FALSE;
    +  NABoolean flipOp = FALSE;  // set to TRUE when column is child(1)
    +
    +  if (ie &&
    +      ((ie->getOperatorType() >= ITM_EQUAL) &&
    +       (ie->getOperatorType() <= ITM_GREATER_EQ))) //binary operator case
    +    {//begin expression
    +      ItemExpr * child0 = ie->child(0)->castToItemExpr();
    +      ItemExpr * child1 = ie->child(1)->castToItemExpr();
    +
    +      if ((ie->child(0)->getOperatorType() == ITM_BASECOLUMN) &&
    +     (NOT hasColReference(ie->child(1))))
    +   {
    +      foundBinary = TRUE;
    +     colVID = ie->child(0)->getValueId();
    +     valueVID = ie->child(1)->getValueId();
    +   }
    +      else if ((ie->child(1)->getOperatorType() == ITM_BASECOLUMN) &&
    +          (NOT hasColReference(ie->child(0))))
    +   {
    +      foundBinary = TRUE;
    +      flipOp = TRUE;
    +     colVID = ie->child(1)->getValueId();
    +     valueVID = ie->child(0)->getValueId();
    +   }
    +      else if ((ie->child(0)->getOperatorType() == ITM_INDEXCOLUMN) &&
    +          (NOT hasColReference(ie->child(1))))
    +   {
    +      foundBinary = TRUE;
    +     colVID = ie->child(0)->getValueId();
    +     valueVID = ie->child(1)->getValueId();
    +   }
    +      else if ((ie->child(1)->getOperatorType() == ITM_INDEXCOLUMN) &&
    +          (NOT hasColReference(ie->child(0))))
    +   {
    +      foundBinary = TRUE;
    +      flipOp = TRUE;
    +     colVID = ie->child(1)->getValueId();
    +     valueVID = ie->child(0)->getValueId();
    +   }
    +      else if ((ie->child(0)->getOperatorType() == ITM_REFERENCE) &&
    --- End diff --
    
    There is a code duplication "smell" here as well. Please consider some 
refactoring. 


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