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

    https://github.com/apache/incubator-trafodion/pull/132#discussion_r42408115
  
    --- Diff: core/sql/optimizer/PartFunc.cpp ---
    @@ -5009,6 +5020,118 @@ void RangePartitioningFunction::print(FILE* ofd, 
const char* indent,
       partitionBoundaries_->print(ofd, indent, title);
     
     } // RangePartitioningFunction::print()
    +
    +
    +NABoolean 
    +compareEncodedKey(const char* low, const char* key, const char* high, 
Int32 keyLen, NABoolean checkLast)
    +{
    +    Int32 cmpLow = memcmp(low, key, keyLen);
    +    Int32 cmpHigh = memcmp(key, high, keyLen);
    +
    +    if ( cmpLow <= 0 && cmpHigh < 0 )
    +       return TRUE;
    +
    +    return (checkLast && cmpLow <= 0 && cmpHigh <= 0);
    +}
    +
    +NABoolean 
    +compareAsciiKey(const char* low, const char* key, const char* high, Int32, 
NABoolean checkLast)
    +{
    +    Int32 cmpLow = strverscmp(low, key);
    +    Int32 cmpHigh = strverscmp(key, high);
    +
    +    if ( cmpLow <= 0 && cmpHigh < 0 )
    +       return TRUE;
    +
    +    return (checkLast && cmpLow <= 0 && cmpHigh <= 0);
    +}
    +
    +
    +// find a boundary pair [low, high) with smallest low value in which keys 
fall, and return the
    +// index of the boundary low. Return -1 otherwise, or the key lengths are 
different.
    +Int32 RangePartitionBoundaries::findBeginBoundary(char* encodedKey, Int32 
keyLen, 
    +                                                  compFuncPtrT compFunc) 
const
    +{
    +   // boundaries are stored in entries in the range [0, partitionCount_] 
    +   for (Lng32 i=partitionCount_-1; i>= 0; i--) {
    +
    +       const char* low = getBinaryBoundaryValue(i);
    +       const char* high = getBinaryBoundaryValue(i+1);
    +
    +       // test if encodedKey is in [low, high)
    +       if ( (*compFunc)(low, encodedKey, high, keyLen, 
i==partitionCount_-1) )
    +          return i;
    +   }
    +
    +   return -1;
    +}
    +
    +// find a boundary pair [low, high) with the largest low value in which 
keys fall, and return the
    +// index of the boundary low. Return -1 otherwise, or the key lengths are 
different.
    +Int32 RangePartitionBoundaries::findEndBoundary(char* encodedKey, Int32 
keyLen, 
    +                                                compFuncPtrT compFunc) 
const
    +{
    +   // boundaries are stored in entries in the range [0, partitionCount_] 
    +   for (Lng32 i=0; i<partitionCount_-1; i++ ) {
    +
    +       const char* low = getBinaryBoundaryValue(i);
    +       const char* high = getBinaryBoundaryValue(i+1);
    +
    +       // test if encodedKey is in [low, high)
    +       if ( (*compFunc)(low, encodedKey, high, keyLen, 
i==partitionCount_-1) )
    +          return i;
    +   }
    +
    +   return -1;
    +}
    +
    +Int32 
    +RangePartitioningFunction::computeNumOfActivePartitions(SearchKey* skey, 
const TableDesc* tDesc) const
    +{
    +   const RangePartitionBoundaries* boundaries = 
getRangePartitionBoundaries();
    +
    +   Int32 origPartitions = getCountOfPartitions();
    +   Int32 partitions = origPartitions;
    +   Int32 bIndex = 0;
    +
    +   const NATable* naTable = tDesc->getNATable();
    +   NABoolean isNativeHbase = (naTable->isHbaseCellTable() || 
naTable->isHbaseRowTable());
    +   compFuncPtrT compFuncPtr = ( isNativeHbase ) ? compareAsciiKey: 
compareEncodedKey;
    --- End diff --
    
    Do we care about Hive tables in this code path?


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