You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2015/10/21 00:47:14 UTC
[1/3] incubator-trafodion git commit: fix JIRA461
Repository: incubator-trafodion
Updated Branches:
refs/heads/master bc0ad1601 -> 6abfe6074
fix JIRA461
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/6b06768a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/6b06768a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/6b06768a
Branch: refs/heads/master
Commit: 6b06768a7048c94db822d51284f642ae22e60f88
Parents: 876de2d
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Mon Oct 19 03:39:22 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Mon Oct 19 03:39:22 2015 +0000
----------------------------------------------------------------------
core/sql/export/NAStringDef.h | 2 +
core/sql/optimizer/EncodedKeyValue.cpp | 3 +-
core/sql/optimizer/EncodedKeyValue.h | 1 +
core/sql/optimizer/ItemExpr.cpp | 77 ++++++++++++++++
core/sql/optimizer/ItemExpr.h | 4 +
core/sql/optimizer/NAFileSet.cpp | 13 +++
core/sql/optimizer/NAFileSet.h | 6 ++
core/sql/optimizer/NATable.cpp | 67 +-------------
core/sql/optimizer/PartFunc.cpp | 123 ++++++++++++++++++++++++++
core/sql/optimizer/PartFunc.h | 18 ++++
core/sql/optimizer/RelExpr.cpp | 14 ++-
core/sql/optimizer/RelScan.h | 9 +-
core/sql/optimizer/ScanOptimizer.cpp | 6 ++
core/sql/optimizer/ValueDesc.cpp | 113 ++++++++++++++++++++++-
core/sql/optimizer/ValueDesc.h | 17 ++++
core/sql/qms/QmsJoinGraph.h | 1 -
core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 1 +
17 files changed, 405 insertions(+), 70 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/export/NAStringDef.h
----------------------------------------------------------------------
diff --git a/core/sql/export/NAStringDef.h b/core/sql/export/NAStringDef.h
index afcc79b..a9a3cf6 100644
--- a/core/sql/export/NAStringDef.h
+++ b/core/sql/export/NAStringDef.h
@@ -515,6 +515,8 @@ friend class NASubString;
};
+typedef NAString* NAStringPtr;
+
SQLEXPORT_LIB_FUNC NAString toLower(const NAString&); // Return lower-case version of argument.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/EncodedKeyValue.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/EncodedKeyValue.cpp b/core/sql/optimizer/EncodedKeyValue.cpp
index 5216e0f..84ab2d8 100644
--- a/core/sql/optimizer/EncodedKeyValue.cpp
+++ b/core/sql/optimizer/EncodedKeyValue.cpp
@@ -305,6 +305,7 @@ short encodeKeyValues(desc_struct * column_descs,
desc_struct * key_descs,
NAString * inValuesArray[], // INPUT
NABoolean isIndex,
+ NABoolean isMaxKey, // INPUT
char * encodedKeyBuffer, // OUTPUT
CollHeap * h,
ComDiagsArea * diagsArea)
@@ -350,7 +351,7 @@ short encodeKeyValues(desc_struct * column_descs,
}
if (inValuesArray[i] == NULL)
- inValuesArray[i] = getMinMaxValue(column, key, FALSE, h);
+ inValuesArray[i] = getMinMaxValue(column, key, isMaxKey, h);
ItemExpr * itemExpr = buildEncodeTree(column, key, inValuesArray[i],
&generator, diagsArea);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/EncodedKeyValue.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/EncodedKeyValue.h b/core/sql/optimizer/EncodedKeyValue.h
index cbff5e9..90ffaca 100644
--- a/core/sql/optimizer/EncodedKeyValue.h
+++ b/core/sql/optimizer/EncodedKeyValue.h
@@ -64,6 +64,7 @@ short encodeKeyValues(desc_struct * column_descs,
desc_struct * key_descs,
NAString * inValuesArray[], // INPUT
NABoolean isIndex,
+ NABoolean isMaxKey, // INPUT
char * encodedKeyBuffer, // OUTPUT
CollHeap * h,
ComDiagsArea * diagsArea);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index 183f7f3..8dbddc0 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -14906,3 +14906,80 @@ NABoolean LOBoper::isCovered
return FALSE;
}
+// Compute the exprssion at compile time. Assume all operands are constants.
+// Return NULL if the computation fails and CmpCommon::diags() may be side-affected.
+ConstValue* ItemExpr::compute(CollHeap* heap)
+{
+ ValueIdList exprs;
+ exprs.insert(getValueId());
+
+ const NAType& dataType = getValueId().getType();
+
+ Lng32 decodedValueLen = dataType.getNominalSize() + dataType.getSQLnullHdrSize();
+
+ char staticDecodeBuf[200];
+ Lng32 staticDecodeBufLen = 200;
+
+ char* decodeBuf = staticDecodeBuf;
+ Lng32 decodeBufLen = staticDecodeBufLen;
+
+ // For character types, multiplying by 8 to deal with conversions between
+ // any two known character sets supported.
+ Lng32 factor = (DFS2REC::isAnyCharacter(dataType.getFSDatatype())) ? 8 : 1;
+
+ if ( staticDecodeBufLen < decodedValueLen * factor) {
+ decodeBufLen = decodedValueLen * factor;
+ decodeBuf = new (STMTHEAP) char[decodeBufLen];
+ }
+
+ Lng32 resultLength = 0;
+ Lng32 resultOffset = 0;
+
+ // Produce the decoded key. Refer to
+ // ex_function_encode::decodeKeyValue() for the
+ // implementation of the decoding logic.
+ ex_expr::exp_return_type rc = exprs.evalAtCompileTime
+ (0, ExpTupleDesc::SQLARK_EXPLODED_FORMAT, decodeBuf, decodeBufLen,
+ &resultLength, &resultOffset, CmpCommon::diags()
+ );
+
+
+ ConstValue* result = NULL;
+
+ if ( rc == ex_expr::EXPR_OK ) {
+ CMPASSERT(resultOffset == dataType.getPrefixSizeWithAlignment());
+ // expect the decodeBuf to have this layout
+ // | null ind. | varchar length ind. | alignment | result |
+ // |<---getPrefixSizeWithAlignment-------------->|
+ // |<----getPrefixSize-------------->|
+
+ // The method getPrefixSizeWithAlignment(), the diagram above,
+ // and this code block assumes that varchar length ind. is
+ // 2 bytes if present. If it is 4 bytes we should fail the
+ // previous assert
+
+ // Next we get rid of alignment bytes by prepending the prefix
+ // (null ind. + varlen ind.) to the result. ConstValue constr.
+ // will process prefix + result. The assert above ensures that
+ // there are no alignment fillers at the beginning of the
+ // buffer. Given the previous assumption about size
+ // of varchar length indicator, alignment bytes will be used by
+ // expression evaluator only if column is of nullable type.
+ // For a description of how alignment is computed, please see
+ // ExpTupleDesc::sqlarkExplodedOffsets() in exp/exp_tuple_desc.cpp
+
+ if (dataType.getSQLnullHdrSize() > 0)
+ memmove(&decodeBuf[resultOffset - dataType.getPrefixSize()],
+ decodeBuf, dataType.getPrefixSize());
+ result =
+ new (heap)
+ ConstValue(&dataType,
+ (void *) &(decodeBuf[resultOffset -
+ dataType.getPrefixSize()]),
+ resultLength+dataType.getPrefixSize(),
+ NULL,
+ heap);
+ }
+
+ return result;
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/ItemExpr.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.h b/core/sql/optimizer/ItemExpr.h
index e5c6404..b0ced2a 100644
--- a/core/sql/optimizer/ItemExpr.h
+++ b/core/sql/optimizer/ItemExpr.h
@@ -1047,6 +1047,10 @@ public:
// ---------------------------------------------------------------------
// Utility methods
// ---------------------------------------------------------------------
+
+ // compute the exprssion at compile time. Assume all operands are constants.
+ // Return NULL if the computation fails and CmpCommon::diags() may be side-affected.
+ ConstValue* compute(CollHeap* heap);
// produce an ascii-version of the object (for display or saving into a file)
virtual void unparse(NAString &result,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/NAFileSet.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAFileSet.cpp b/core/sql/optimizer/NAFileSet.cpp
index 36a72e8..4551834 100644
--- a/core/sql/optimizer/NAFileSet.cpp
+++ b/core/sql/optimizer/NAFileSet.cpp
@@ -109,6 +109,7 @@ NAFileSet::NAFileSet(const QualifiedName & fileSetName,
resetAfterStatement_(FALSE),
bitFlags_(0),
keyLength_(0),
+ encodedKeyLength_(0),
thisRemoteIndexGone_(FALSE),
isDecoupledRangePartitioned_(isDecoupledRangePartitioned),
fileCode_(fileCode),
@@ -161,6 +162,18 @@ Lng32 NAFileSet::getKeyLength()
return keyLength_;
}
+// returns the length of the encoded key in bytes for this index
+Lng32 NAFileSet::getEncodedKeyLength()
+{
+ if(encodedKeyLength_ >0) return encodedKeyLength_;
+
+ for(CollIndex i=0;i<indexKeyColumns_.entries();i++)
+ {
+ encodedKeyLength_ += indexKeyColumns_[i]->getType()->getNominalSize();
+ }
+ return encodedKeyLength_;
+}
+
Lng32 NAFileSet::getCountOfPartitions() const
{
return partFunc_ ? partFunc_->getCountOfPartitions() : 1;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/NAFileSet.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAFileSet.h b/core/sql/optimizer/NAFileSet.h
index 5999a6a..1c59db0 100644
--- a/core/sql/optimizer/NAFileSet.h
+++ b/core/sql/optimizer/NAFileSet.h
@@ -160,6 +160,7 @@ public:
Lng32 getRecordLength() const { return recordLength_; }
Lng32 getLockLength() const { return lockLength_; }
Lng32 getKeyLength();
+ Lng32 getEncodedKeyLength();
Lng32 getBlockSize() const { return blockSize_; }
Int32 getIndexLevels() const { return indexLevels_; }
@@ -331,6 +332,11 @@ private:
Lng32 keyLength_;
// ---------------------------------------------------------------------
+ // Encoded key length in bytes.
+ //----------------------------------------------------------------------
+ Lng32 encodedKeyLength_;
+
+ // ---------------------------------------------------------------------
// Lock length in bytes.
//----------------------------------------------------------------------
Lng32 lockLength_;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index 05bfd2a..c6ff78c 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -1756,72 +1756,9 @@ static ItemExpr * getRangePartitionBoundaryValuesFromEncodedKeys(
keyColVal->synthTypeAndValueId();
- ValueIdList exprs;
- exprs.insert(keyColVal->getValueId());
+ keyColVal = keyColVal->compute(heap);
- char staticDecodeBuf[200];
- Lng32 staticDecodeBufLen = 200;
-
- char* decodeBuf = staticDecodeBuf;
- Lng32 decodeBufLen = staticDecodeBufLen;
-
- // For character types, multiplying by 8 to deal with conversions between
- // any two known character sets supported.
- Lng32 factor = (DFS2REC::isAnyCharacter(pkType->getFSDatatype())) ? 8 : 1;
-
- if ( staticDecodeBufLen < decodedValueLen * factor) {
- decodeBufLen = decodedValueLen * factor;
- decodeBuf = new (STMTHEAP) char[decodeBufLen];
- }
-
- Lng32 resultLength = 0;
- Lng32 resultOffset = 0;
-
- // Produce the decoded key. Refer to
- // ex_function_encode::decodeKeyValue() for the
- // implementation of the decoding logic.
- ex_expr::exp_return_type rc = exprs.evalAtCompileTime
- (0, ExpTupleDesc::SQLARK_EXPLODED_FORMAT, decodeBuf, decodeBufLen,
- &resultLength, &resultOffset, CmpCommon::diags()
- );
-
-
- if ( rc == ex_expr::EXPR_OK ) {
- CMPASSERT(resultOffset == pkType->getPrefixSizeWithAlignment());
- // expect the decodeBuf to have this layout
- // | null ind. | varchar length ind. | alignment | result |
- // |<---getPrefixSizeWithAlignment-------------->|
- // |<----getPrefixSize-------------->|
-
- // The method getPrefixSizeWithAlignment(), the diagram above,
- // and this code block assumes that varchar length ind. is
- // 2 bytes if present. If it is 4 bytes we should fail the
- // previous assert
-
- // Next we get rid of alignment bytes by prepending the prefix
- // (null ind. + varlen ind.) to the result. ConstValue constr.
- // will process prefix + result. The assert above ensures that
- // there are no alignment fillers at the beginning of the
- // buffer. Given the previous assumption about size
- // of varchar length indicator, alignment bytes will be used by
- // expression evaluator only if column is of nullable type.
- // For a description of how alignment is computed, please see
- // ExpTupleDesc::sqlarkExplodedOffsets() in exp/exp_tuple_desc.cpp
-
- if (pkType->getSQLnullHdrSize() > 0)
- memmove(&decodeBuf[resultOffset - pkType->getPrefixSize()],
- decodeBuf, pkType->getPrefixSize());
- keyColVal =
- new (heap)
- ConstValue(pkType,
- (void *) &(decodeBuf[resultOffset -
- pkType->getPrefixSize()]),
- resultLength+pkType->getPrefixSize(),
- NULL,
- heap);
- }
-
- if ( rc != ex_expr::EXPR_OK )
+ if ( !keyColVal )
return NULL;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/PartFunc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/PartFunc.cpp b/core/sql/optimizer/PartFunc.cpp
index 651bd1b..ff552a9 100644
--- a/core/sql/optimizer/PartFunc.cpp
+++ b/core/sql/optimizer/PartFunc.cpp
@@ -3995,6 +3995,17 @@ void RangePartitionBoundaries::print(FILE* ofd, const char* indent,
else
fprintf(ofd,"%s %s is empty\n",NEW_INDENT,S);
}
+
+ fprintf(ofd,"%s %s (in binary form)\n",NEW_INDENT,title);
+ Lng32 keyLen = getEncodedBoundaryKeyLength();
+ for (index = 0; index < partitionCount_; index++)
+ {
+ const char* bValues = getBinaryBoundaryValue(index);
+ for (Int32 j = 0; j < keyLen; j++) {
+ fprintf(ofd,"%04x ", (int)bValues[j]);
+ }
+ }
+
} // RangePartitionBoundaries::print()
// LCOV_EXCL_STOP
@@ -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;
+
+ char* buf = NULL;
+ Int32 len = 0;
+
+ const ValueIdList& beginKey = skey->getBeginKeyValues();
+
+ if ( beginKey.computeEncodedKey(tDesc, FALSE, buf, len) ) {
+
+ bIndex = boundaries->findBeginBoundary(buf, len, compFuncPtr);
+
+ if ( bIndex < 0 )
+ return origPartitions; // error in deciding the partiton
+ else
+ partitions -= bIndex; // bIndex is 0 based.
+ }
+
+ const ValueIdList& endKey = skey->getEndKeyValues();
+
+ if ( endKey.computeEncodedKey(tDesc, TRUE, buf, len) ) {
+
+ Int32 eIndex = boundaries->findEndBoundary(buf, len, compFuncPtr);
+
+ if ( eIndex < 0 ) // error in deciding the partition.
+ return origPartitions;
+
+ if ( eIndex >= bIndex ) //eIndex is also 0 based
+ partitions -= (getCountOfPartitions() - eIndex - 1);
+ else
+ return origPartitions; // end partition is preceeding the start partition!
+ }
+
+ return partitions;
+}
+
+
// LCOV_EXCL_STOP
// ***********************************************************************
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/PartFunc.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/PartFunc.h b/core/sql/optimizer/PartFunc.h
index d1bfdc6..b179b21 100644
--- a/core/sql/optimizer/PartFunc.h
+++ b/core/sql/optimizer/PartFunc.h
@@ -75,6 +75,7 @@ class NAColumnArray;
class SearchKey;
class SkewedValueList;
typedef LIST(Int64) Int64List;
+typedef NABoolean (*compFuncPtrT)(const char* low, const char* key, const char* high, Int32 keyLen, NABoolean checkLast);
// ----------------------------------------------------------------------
// literals for special numbers of partitions (don't care, exactly one)
@@ -2035,6 +2036,15 @@ public:
void completePartitionBoundaries(const ValueIdList& partitioningKeyOrder,
Lng32 encodedBoundaryKeyLength);
+
+ // 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 findBeginBoundary(char* encodedKey, Int32 keyLen, compFuncPtrT compFunc) const;
+
+ // 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 findEndBoundary(char* encodedKey, Int32 keyLen, compFuncPtrT compFunc) const;
+
void setupForStatement(NABoolean useStringVersion);
void resetAfterStatement();
@@ -2246,6 +2256,12 @@ public:
NABoolean
partFuncAndFuncPushDownCompatible(const PartitioningFunction&) const;
+ // ---------------------------------------------------------------------
+ // Compute the number of active partitions. Active partitions are those
+ // that will be accessed applying the search key skey.
+ // ---------------------------------------------------------------------
+ Int32 computeNumOfActivePartitions(SearchKey* skey, const TableDesc* tDesc) const;
+
virtual const NAString getText() const;
virtual void print( FILE* ofd = stdout,
const char* indent = DEFAULT_INDENT,
@@ -2689,5 +2705,7 @@ private:
}; // class RoundRobinPartitioningFunction
// LCOV_EXCL_STOP
+//
+
#endif /* PARTFUNC_H */
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/RelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExpr.cpp b/core/sql/optimizer/RelExpr.cpp
index f6a2a4a..4fb8b8b 100644
--- a/core/sql/optimizer/RelExpr.cpp
+++ b/core/sql/optimizer/RelExpr.cpp
@@ -9515,7 +9515,8 @@ FileScan::FileScan(const CorrName& tableName,
estRowsAccessed_ (0),
mdamFlag_(UNDECIDED),
skipRowsToPreventHalloween_(FALSE),
- doUseSearchKey_(TRUE)
+ doUseSearchKey_(TRUE),
+ computedNumOfActivePartiions_(-1)
{
// Set the filescan properties:
@@ -9552,6 +9553,17 @@ FileScan::FileScan(const CorrName& tableName,
dummySet, // needed by interface but not used here
indexDesc_
);
+
+
+ if ( indexDesc_->getPartitioningFunction() &&
+ indexDesc_->getPartitioningFunction()->castToRangePartitioningFunction() )
+ {
+ const RangePartitioningFunction* rangePartFunc =
+ indexDesc_->getPartitioningFunction()->castToRangePartitioningFunction();
+
+ computedNumOfActivePartiions_ =
+ rangePartFunc->computeNumOfActivePartitions(partKeys_, tableDescPtr);
+ }
}
setComputedPredicates(generatedCCPreds);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/RelScan.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelScan.h b/core/sql/optimizer/RelScan.h
index fd856d3..6b14d8b 100644
--- a/core/sql/optimizer/RelScan.h
+++ b/core/sql/optimizer/RelScan.h
@@ -813,7 +813,8 @@ public:
uniqueProbes_(0),
duplicateSuccProbes_(0),
failedProbes_(0),
- tuplesProcessed_(0)
+ tuplesProcessed_(0),
+ computedNumOfActivePartiions_(-1)
{}
// destructor
@@ -1020,6 +1021,8 @@ public:
const ValueIdList& partitioningKeyColumnsList,
const ValueIdList& partitioningKeyColumnsOrder);
+ Int32 getComputedNumOfActivePartiions() const { return computedNumOfActivePartiions_; }
+
private:
@@ -1106,6 +1109,10 @@ private:
NABoolean doUseSearchKey_;
+ // number of active partitions computed only from the Range Part Func
+ // and the search key (partKey_)
+ Int32 computedNumOfActivePartiions_;
+
}; // class FileScan
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/ScanOptimizer.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ScanOptimizer.cpp b/core/sql/optimizer/ScanOptimizer.cpp
index 556b81e..e7e912c 100644
--- a/core/sql/optimizer/ScanOptimizer.cpp
+++ b/core/sql/optimizer/ScanOptimizer.cpp
@@ -2989,6 +2989,9 @@ CollIndex ScanOptimizer::getEstNumActivePartitionsAtRuntime() const
}
}
+ if ( actParts > 1 )
+ actParts = MINOF(actParts, getFileScan().getComputedNumOfActivePartiions());
+
return actParts;
}
@@ -3023,6 +3026,9 @@ CollIndex ScanOptimizer::getEstNumActivePartitionsAtRuntimeForHbaseRegions() con
if (estActParts == 1 AND (CmpCommon::getDefault(NCM_HBASE_COSTING) == DF_ON))
actParts = estActParts;
+ if ( actParts > 1 )
+ actParts = MINOF(actParts, getFileScan().getComputedNumOfActivePartiions());
+
return actParts;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/ValueDesc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ValueDesc.cpp b/core/sql/optimizer/ValueDesc.cpp
index 2f8dfe0..edb5de1 100644
--- a/core/sql/optimizer/ValueDesc.cpp
+++ b/core/sql/optimizer/ValueDesc.cpp
@@ -59,6 +59,9 @@
//////////////////////////////
#include "Analyzer.h"
//////////////////////////////
+//
+#include "NATable.h"
+#include "EncodedKeyValue.h"
#include "SqlParserGlobals.h" // must be last #include
@@ -639,7 +642,7 @@ void ValueId::getSubExprRootedByVidUnion(ValueIdSet & vs)
// expression with the given expression.
// used in Insert::bindNode() to move constraints from the target table
// to the source table.
-// -----------------------------------------------------------------------
+// ----------------------------------------------------------------------
void ValueId::replaceBaseColWithExpr(const NAString& colName,
const ValueId & vid)
{
@@ -6397,3 +6400,111 @@ Lng32 ValueIdList::findPrefixLength(const ValueIdSet& x) const
return ct;
}
+// -----------------------------------------------------------------------
+// replace any ColReference (of the given column name) in of this value
+// expression with the given expression.
+// used in ValueId::computeEncodedKey() to assign key values into the
+// salt/DivisionByto expression.
+// ----------------------------------------------------------------------
+void ValueId::replaceColReferenceWithExpr(const NAString& colName,
+ const ValueId & vid)
+{
+ ItemExpr* thisItemExpr = getItemExpr();
+ for( Lng32 i = 0; i < thisItemExpr->getArity(); i++ )
+ {
+ ValueId childValueId = thisItemExpr->child(i).getValueId();
+ ItemExpr* childItemExpr = childValueId.getItemExpr();
+
+ if( childItemExpr->getOperatorType() == ITM_REFERENCE)
+ {
+ if( ((ColReference*)childItemExpr)->getColRefNameObj().getColName() == colName )
+ thisItemExpr->setChild( i, vid.getItemExpr() );
+ }
+ childValueId.replaceColReferenceWithExpr( colName, vid );
+ }
+}
+
+
+char*
+ValueIdList::computeEncodedKey(const TableDesc* tDesc, NABoolean isMaxKey,
+ char*& encodedKeyBuffer, Int32& keyBufLen) const
+{
+ const NATable* naTable = tDesc->getNATable();
+
+
+ CollIndex count = entries();
+ NAString** inputStrings = new (STMTHEAP) NAStringPtr[count];
+
+ for (Int32 j=0; j<count; j++ )
+ inputStrings[j] = NULL;
+
+ for (Int32 j=0; j<count; j++ ) {
+
+ ValueId vid = (*this)[j];
+ ItemExpr* ie = vid.getItemExpr();
+
+ if ( ie->getOperatorType() != ITM_CONSTANT ) {
+ ConstValue* value = ie->compute(STMTHEAP);
+ if ( !value )
+ return NULL;
+
+ inputStrings[j] = new (STMTHEAP) NAString(value->getConstStr(FALSE));
+ } else {
+ // no need to prefix with charset prefix.
+ inputStrings[j] = new (STMTHEAP) NAString(((ConstValue*) ie)->getConstStr(FALSE));
+
+ if ( *inputStrings[j] == "<min>" || *inputStrings[j] == "<max>" )
+ inputStrings[j] = NULL;
+ }
+ }
+
+ const NAFileSet * naf = naTable->getClusteringIndex();
+ const desc_struct * tableDesc = naTable->getTableDesc();
+ desc_struct * colDescs = tableDesc->body.table_desc.columns_desc;
+ desc_struct * keyDescs = (desc_struct*)naf->getKeysDesc();
+
+ // cast away const since the method may compute and store the length
+ keyBufLen = ((NAFileSet*)naf)->getEncodedKeyLength();
+
+ if ( naTable->isHbaseCellTable() || naTable->isHbaseRowTable() ) {
+ // the encoded key for Native Hbase table is a null-terminated string ('<key>')
+ NAString key;
+ key.append("(");
+
+ size_t idx = inputStrings[0]->index("_ISO88591");
+ if ( idx == 0 )
+ key.append(inputStrings[0]->remove(0, 9));
+ else
+ key.append(*inputStrings[0]);
+
+ key.append(")");
+
+ keyBufLen = inputStrings[0]->length() + 5; // extra 4 bytes for (,', ', ), and one byte for null.
+
+ if (!encodedKeyBuffer )
+ encodedKeyBuffer = new (STMTHEAP) char[keyBufLen];
+
+ memcpy(encodedKeyBuffer, key.data(), key.length());
+ encodedKeyBuffer[key.length()] = NULL;
+
+ return encodedKeyBuffer;
+
+ } else {
+ keyBufLen = ((NAFileSet*)naf)->getEncodedKeyLength();
+
+ if (!encodedKeyBuffer )
+ encodedKeyBuffer = new (STMTHEAP) char[keyBufLen];
+
+ short ok = encodeKeyValues(colDescs, keyDescs,
+ inputStrings, // INPUT
+ FALSE, // not isIndex
+ isMaxKey,
+ encodedKeyBuffer,// OUTPUT
+ STMTHEAP, CmpCommon::diags());
+
+ NADELETEARRAY(inputStrings, count, NAStringPtr, STMTHEAP);
+
+ return ( ok == 0 ) ? encodedKeyBuffer : NULL;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/optimizer/ValueDesc.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ValueDesc.h b/core/sql/optimizer/ValueDesc.h
index cb6bb94..7a7a625 100644
--- a/core/sql/optimizer/ValueDesc.h
+++ b/core/sql/optimizer/ValueDesc.h
@@ -81,6 +81,7 @@ class VEGRewritePairs;
class TableDesc;
class IndexDesc;
class ConstValue;
+class NATable;
////////////////////
class QueryAnalysis;
@@ -227,6 +228,14 @@ public:
// ---------------------------------------------------------------------
void replaceBaseColWithExpr(const NAString& colName, const ValueId & vid);
+ // -----------------------------------------------------------------------
+ // replace any ColReference (of the given column name) in of this value
+ // expression with the given expression.
+ // used in ValueId::computeEncodedKey() to assign key values into the
+ // salt/DivisionByto expression.
+ // ----------------------------------------------------------------------
+ void replaceColReferenceWithExpr(const NAString& colName, const ValueId & vid);
+
// ---------------------------------------------------------------------
// Replace the definition of this valueId to be a new itemexpr
// ---------------------------------------------------------------------
@@ -604,6 +613,14 @@ public:
// or to an equal predicate.
ValueId extractVEGRefForEquiPredicate(ValueId x) const;
+
+ // Encode this list of constants into an encoded key and save the result into
+ // encodedKeyBuffer, and the key length into keyBufLen. Allocate an buffer
+ // if encodedKeyBuffer points at NULL from STMTHEAP. Also return the buffer pointer
+ // if everything is OK. Return NULL otherwise.
+ char* computeEncodedKey(const TableDesc* tDesc, NABoolean isMaxKey, char*& encodedKeyBuffer, Int32& keyBufLen) const;
+
+
// ---------------------------------------------------------------------
// Print
// ---------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/qms/QmsJoinGraph.h
----------------------------------------------------------------------
diff --git a/core/sql/qms/QmsJoinGraph.h b/core/sql/qms/QmsJoinGraph.h
index 9aecf5a..c48a641 100644
--- a/core/sql/qms/QmsJoinGraph.h
+++ b/core/sql/qms/QmsJoinGraph.h
@@ -71,7 +71,6 @@ typedef NAPtrList<JoinGraphEqualitySetPtr> EqualitySetList;
typedef NAPtrList<JoinGraphTablePtr> JoinGraphTableList;
typedef NAPtrArray<JoinGraphTablePtr> JoinGraphTableArray;
typedef NASubArray<JoinGraphTablePtr> JoinGraphTableSubArray;
-typedef NAString* NAStringPtr;
typedef NAPtrList<QRJoinSubGraphPtr> SubGraphList;
typedef NAPtrList<QRJoinSubGraphMapPtr> SubGraphMapList;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6b06768a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index bbadd15..4438923 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -6258,6 +6258,7 @@ short CmpSeabaseDDL::createEncodedKeysBuffer(char** &encodedKeysBuffer,
keyDescs,
splitValuesAsText, // INPUT
isIndex,
+ FALSE, // encoding for Min Key
encodedKeysBuffer[i], // OUTPUT
STMTHEAP,
CmpCommon::diags());
[3/3] incubator-trafodion git commit: Merge [TRAFODION-461] PR 132
Correct number of active partitions
Posted by db...@apache.org.
Merge [TRAFODION-461] PR 132 Correct number of active partitions
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/6abfe607
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/6abfe607
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/6abfe607
Branch: refs/heads/master
Commit: 6abfe6074638ec884ddfce34cc40be422476115a
Parents: bc0ad16 f31ddf6
Author: Dave Birdsall <db...@apache.org>
Authored: Tue Oct 20 22:45:40 2015 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Tue Oct 20 22:45:40 2015 +0000
----------------------------------------------------------------------
core/sql/export/NAStringDef.h | 2 +
core/sql/optimizer/EncodedKeyValue.cpp | 3 +-
core/sql/optimizer/EncodedKeyValue.h | 1 +
core/sql/optimizer/ItemColRef.h | 2 +
core/sql/optimizer/ItemExpr.cpp | 90 ++++++++++++++++++
core/sql/optimizer/ItemExpr.h | 4 +
core/sql/optimizer/NAFileSet.cpp | 13 +++
core/sql/optimizer/NAFileSet.h | 6 ++
core/sql/optimizer/NATable.cpp | 67 +-------------
core/sql/optimizer/PartFunc.cpp | 127 ++++++++++++++++++++++++++
core/sql/optimizer/PartFunc.h | 18 ++++
core/sql/optimizer/RelExpr.cpp | 14 ++-
core/sql/optimizer/RelScan.h | 9 +-
core/sql/optimizer/ScanOptimizer.cpp | 6 ++
core/sql/optimizer/ValueDesc.cpp | 118 +++++++++++++++++++++++-
core/sql/optimizer/ValueDesc.h | 17 ++++
core/sql/qms/QmsJoinGraph.h | 1 -
core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 1 +
18 files changed, 429 insertions(+), 70 deletions(-)
----------------------------------------------------------------------
[2/3] incubator-trafodion git commit: rework for fix to JIRA461
Posted by db...@apache.org.
rework for fix to JIRA461
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/f31ddf6b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/f31ddf6b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/f31ddf6b
Branch: refs/heads/master
Commit: f31ddf6bc2e0561e4df9d470bbbc58df90dcd4ae
Parents: 6b06768
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Tue Oct 20 19:55:10 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Tue Oct 20 19:55:10 2015 +0000
----------------------------------------------------------------------
core/sql/optimizer/ItemColRef.h | 2 ++
core/sql/optimizer/ItemExpr.cpp | 23 ++++++++++++++++++-----
core/sql/optimizer/ItemExpr.h | 4 ++--
core/sql/optimizer/NAFileSet.cpp | 2 +-
core/sql/optimizer/NATable.cpp | 2 +-
core/sql/optimizer/PartFunc.cpp | 8 ++++++--
core/sql/optimizer/RelExpr.cpp | 4 ++--
core/sql/optimizer/RelScan.h | 6 +++---
core/sql/optimizer/ValueDesc.cpp | 9 +++++++--
9 files changed, 42 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/ItemColRef.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemColRef.h b/core/sql/optimizer/ItemColRef.h
index 0382f1a..b43ff50 100644
--- a/core/sql/optimizer/ItemColRef.h
+++ b/core/sql/optimizer/ItemColRef.h
@@ -838,6 +838,8 @@ public:
void setIsCachedParam(NABoolean isCachedParam = TRUE)
{ isCachedParam_ = isCachedParam; }
+ NABoolean isSystemGeneratedOutputHV() const;
+
NAString& getPrototypeValue() { return prototypeValue_; }
const NAString& getPrototypeValue() const { return prototypeValue_; } // LCOV_EXCL_LINE
NABoolean hasPrototypeValue() const { return !prototypeValue_.isNull(); }
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index 8dbddc0..3bc1dcd 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -874,6 +874,12 @@ NABoolean ItemExpr::doesExprEvaluateToConstant(NABoolean strict,
return TRUE;
case ITM_HOSTVAR:
+ {
+ HostVar* hv = (HostVar*)this;
+ if ( hv->isSystemGeneratedOutputHV() )
+ return TRUE;
+ }
+
case ITM_DYN_PARAM:
case ITM_CACHE_PARAM:
case ITM_CURRENT_USER:
@@ -14459,6 +14465,12 @@ HostVar::setPMOrdPosAndIndex( ComColumnDirection paramMode,
hvIndex_ = index;
}
+NABoolean HostVar::isSystemGeneratedOutputHV() const
+{
+ return (isSystemGenerated() &&
+ getName() == "_sys_ignored_CC_convErrorFlag");
+}
+
void
DynamicParam::setPMOrdPosAndIndex( ComColumnDirection paramMode,
Int32 ordinalPosition,
@@ -14906,9 +14918,9 @@ NABoolean LOBoper::isCovered
return FALSE;
}
-// Compute the exprssion at compile time. Assume all operands are constants.
+// Evalaute the exprssion at compile time. Assume all operands are constants.
// Return NULL if the computation fails and CmpCommon::diags() may be side-affected.
-ConstValue* ItemExpr::compute(CollHeap* heap)
+ConstValue* ItemExpr::evaluate(CollHeap* heap)
{
ValueIdList exprs;
exprs.insert(getValueId());
@@ -14923,9 +14935,10 @@ ConstValue* ItemExpr::compute(CollHeap* heap)
char* decodeBuf = staticDecodeBuf;
Lng32 decodeBufLen = staticDecodeBufLen;
- // For character types, multiplying by 8 to deal with conversions between
- // any two known character sets supported.
- Lng32 factor = (DFS2REC::isAnyCharacter(dataType.getFSDatatype())) ? 8 : 1;
+ // For character types, multiplying by 6 to deal with conversions between
+ // any two known character sets allowed. See CharInfo::maxBytesPerChar()
+ // for a list of max bytes per char for each supported character set.
+ Lng32 factor = (DFS2REC::isAnyCharacter(dataType.getFSDatatype())) ? 6 : 1;
if ( staticDecodeBufLen < decodedValueLen * factor) {
decodeBufLen = decodedValueLen * factor;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/ItemExpr.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.h b/core/sql/optimizer/ItemExpr.h
index b0ced2a..71518e4 100644
--- a/core/sql/optimizer/ItemExpr.h
+++ b/core/sql/optimizer/ItemExpr.h
@@ -1048,9 +1048,9 @@ public:
// Utility methods
// ---------------------------------------------------------------------
- // compute the exprssion at compile time. Assume all operands are constants.
+ // Evaluate the exprssion at compile time. Assume all operands are constants.
// Return NULL if the computation fails and CmpCommon::diags() may be side-affected.
- ConstValue* compute(CollHeap* heap);
+ ConstValue* evaluate(CollHeap* heap);
// produce an ascii-version of the object (for display or saving into a file)
virtual void unparse(NAString &result,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/NAFileSet.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAFileSet.cpp b/core/sql/optimizer/NAFileSet.cpp
index 4551834..f54fc77 100644
--- a/core/sql/optimizer/NAFileSet.cpp
+++ b/core/sql/optimizer/NAFileSet.cpp
@@ -169,7 +169,7 @@ Lng32 NAFileSet::getEncodedKeyLength()
for(CollIndex i=0;i<indexKeyColumns_.entries();i++)
{
- encodedKeyLength_ += indexKeyColumns_[i]->getType()->getNominalSize();
+ encodedKeyLength_ += indexKeyColumns_[i]->getType()->getEncodedKeyLength();
}
return encodedKeyLength_;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index c6ff78c..520a514 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -1756,7 +1756,7 @@ static ItemExpr * getRangePartitionBoundaryValuesFromEncodedKeys(
keyColVal->synthTypeAndValueId();
- keyColVal = keyColVal->compute(heap);
+ keyColVal = keyColVal->evaluate(heap);
if ( !keyColVal )
return NULL;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/PartFunc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/PartFunc.cpp b/core/sql/optimizer/PartFunc.cpp
index ff552a9..377c9d9 100644
--- a/core/sql/optimizer/PartFunc.cpp
+++ b/core/sql/optimizer/PartFunc.cpp
@@ -5053,7 +5053,7 @@ 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--) {
+ for (Lng32 i=0; i<=partitionCount_-1; i++ ) {
const char* low = getBinaryBoundaryValue(i);
const char* high = getBinaryBoundaryValue(i+1);
@@ -5072,7 +5072,7 @@ 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++ ) {
+ for (Lng32 i=partitionCount_-1; i>= 0; i--) {
const char* low = getBinaryBoundaryValue(i);
const char* high = getBinaryBoundaryValue(i+1);
@@ -5095,6 +5095,10 @@ RangePartitioningFunction::computeNumOfActivePartitions(SearchKey* skey, const T
Int32 bIndex = 0;
const NATable* naTable = tDesc->getNATable();
+
+ if ( naTable->isHiveTable() )
+ return origPartitions;
+
NABoolean isNativeHbase = (naTable->isHbaseCellTable() || naTable->isHbaseRowTable());
compFuncPtrT compFuncPtr = ( isNativeHbase ) ? compareAsciiKey: compareEncodedKey;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/RelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExpr.cpp b/core/sql/optimizer/RelExpr.cpp
index 4fb8b8b..9f031de 100644
--- a/core/sql/optimizer/RelExpr.cpp
+++ b/core/sql/optimizer/RelExpr.cpp
@@ -9516,7 +9516,7 @@ FileScan::FileScan(const CorrName& tableName,
mdamFlag_(UNDECIDED),
skipRowsToPreventHalloween_(FALSE),
doUseSearchKey_(TRUE),
- computedNumOfActivePartiions_(-1)
+ computedNumOfActivePartitions_(-1)
{
// Set the filescan properties:
@@ -9561,7 +9561,7 @@ FileScan::FileScan(const CorrName& tableName,
const RangePartitioningFunction* rangePartFunc =
indexDesc_->getPartitioningFunction()->castToRangePartitioningFunction();
- computedNumOfActivePartiions_ =
+ computedNumOfActivePartitions_ =
rangePartFunc->computeNumOfActivePartitions(partKeys_, tableDescPtr);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/RelScan.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelScan.h b/core/sql/optimizer/RelScan.h
index 6b14d8b..5fbaf7f 100644
--- a/core/sql/optimizer/RelScan.h
+++ b/core/sql/optimizer/RelScan.h
@@ -814,7 +814,7 @@ public:
duplicateSuccProbes_(0),
failedProbes_(0),
tuplesProcessed_(0),
- computedNumOfActivePartiions_(-1)
+ computedNumOfActivePartitions_(-1)
{}
// destructor
@@ -1021,7 +1021,7 @@ public:
const ValueIdList& partitioningKeyColumnsList,
const ValueIdList& partitioningKeyColumnsOrder);
- Int32 getComputedNumOfActivePartiions() const { return computedNumOfActivePartiions_; }
+ Int32 getComputedNumOfActivePartiions() const { return computedNumOfActivePartitions_; }
private:
@@ -1111,7 +1111,7 @@ private:
// number of active partitions computed only from the Range Part Func
// and the search key (partKey_)
- Int32 computedNumOfActivePartiions_;
+ Int32 computedNumOfActivePartitions_;
}; // class FileScan
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/ValueDesc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ValueDesc.cpp b/core/sql/optimizer/ValueDesc.cpp
index edb5de1..a23d2c9 100644
--- a/core/sql/optimizer/ValueDesc.cpp
+++ b/core/sql/optimizer/ValueDesc.cpp
@@ -6444,8 +6444,13 @@ ValueIdList::computeEncodedKey(const TableDesc* tDesc, NABoolean isMaxKey,
ItemExpr* ie = vid.getItemExpr();
if ( ie->getOperatorType() != ITM_CONSTANT ) {
- ConstValue* value = ie->compute(STMTHEAP);
- if ( !value )
+
+ ConstValue* value = NULL;
+ if ( ie->doesExprEvaluateToConstant(TRUE, TRUE) ) {
+ value = ie->evaluate(STMTHEAP);
+ if ( !value )
+ return NULL;
+ } else
return NULL;
inputStrings[j] = new (STMTHEAP) NAString(value->getConstStr(FALSE));