本文整理汇总了C++中ValueIdList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ ValueIdList::insert方法的具体用法?C++ ValueIdList::insert怎么用?C++ ValueIdList::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValueIdList
的用法示例。
在下文中一共展示了ValueIdList::insert方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getEquivVEGCols
// -----------------------------------------------------------------------
// Given a column list providing identifiers for columns of this table,
// this method returns a list of VEG expressions and/or base columns that
// show the equivalence of base columns with index columns.
// -----------------------------------------------------------------------
void TableDesc::getEquivVEGCols (const ValueIdList& columnList,
ValueIdList &VEGColumnList) const
{
for (CollIndex i=0; i < columnList.entries(); i++)
{
ItemExpr *ie = columnList[i].getItemExpr();
BaseColumn *bc = NULL;
switch (ie->getOperatorType())
{
case ITM_BASECOLUMN:
bc = (BaseColumn *) ie;
break;
case ITM_INDEXCOLUMN:
bc = (BaseColumn *) ((IndexColumn *) ie)->getDefinition().
getItemExpr();
CMPASSERT(bc->getOperatorType() == ITM_BASECOLUMN);
break;
default:
ABORT("Invalid argument to TableDesc::getEquivVEGCols()\n");
}
CMPASSERT(bc->getTableDesc() == this);
VEGColumnList.insert(getColumnVEGList()[bc->getColNumber()]);
}
}
示例2: getSystemColumnList
// -----------------------------------------------------------------------
// TableDesc::getSystemColumnList()
// -----------------------------------------------------------------------
void TableDesc::getSystemColumnList(ValueIdList &columnList) const
{
for (CollIndex i = 0; i < colList_.entries(); i++) {
ValueId valId = colList_[i];
NAColumn *column = valId.getNAColumn();
if (column->isSystemColumn())
columnList.insert(valId);
}
}
示例3: getIdentityColumn
// -----------------------------------------------------------------------
// TableDesc::getIdentityColumn()
// -----------------------------------------------------------------------
void TableDesc::getIdentityColumn(ValueIdList &columnList) const
{
for (CollIndex i = 0; i < colList_.entries(); i++)
{
ValueId valId = colList_[i];
NAColumn *column = valId.getNAColumn();
if (column->isIdentityColumn())
{
columnList.insert(valId);
break; // Break when you find the first,
// as there can only be one Identity column per table.
}
}
}
示例4: getIndexColumns
void
IndexDesc::getNonKeyColumnList(ValueIdList& nonKeyColumnList) const
{
const ValueIdList
&indexColumns = getIndexColumns(),
&keyColumns = getIndexKey();
// clean up input:
nonKeyColumnList.clear();
// Add all index columns
CollIndex i = 0;
for (i=0;
i < indexColumns.entries();
i++)
{
nonKeyColumnList.insert(indexColumns[i]);
}
// And remove all key columns:
for (i=0;
i < keyColumns.entries();
i++)
{
nonKeyColumnList.remove(keyColumns[i]);
// if this is a secondary index, the base column
// which is part of the index,
// may also be present, remove it:
const ItemExpr *colPtr = keyColumns[i].getItemExpr();
if (colPtr->getOperatorType()
==
ITM_INDEXCOLUMN)
{
const ValueId & colDef = ((IndexColumn *)(colPtr))->getDefinition();
nonKeyColumnList.remove(colDef);
}
}
} // IndexDesc::getNonKeyColumnList(ValueIdSet& nonKeyColumnSet) const
示例5: codeGen
short ProbeCache::codeGen(Generator *generator)
{
ExpGenerator * exp_gen = generator->getExpGenerator();
Space * space = generator->getSpace();
MapTable * last_map_table = generator->getLastMapTable();
ex_cri_desc * given_desc
= generator->getCriDesc(Generator::DOWN);
ex_cri_desc * returned_desc
= new(space) ex_cri_desc(given_desc->noTuples() + 1, space);
// cri descriptor for work atp has 5 entries:
// entry #0 for const
// entry #1 for temp
// entry #2 for hash value of probe input data in Probe Cache Manager
// entry #3 for encoded probe input data in Probe Cache Manager
// enrry #4 for inner table row data in this operator's cache buffer
Int32 work_atp = 1;
ex_cri_desc * work_cri_desc = new(space) ex_cri_desc(5, space);
unsigned short hashValIdx = 2;
unsigned short encodedProbeDataIdx = 3;
unsigned short innerRowDataIdx = 4;
// generate code for child tree, and get its tdb and explain tuple.
child(0)->codeGen(generator);
ComTdb * child_tdb = (ComTdb *)(generator->getGenObj());
ExplainTuple *childExplainTuple = generator->getExplainTuple();
//////////////////////////////////////////////////////
// Generate up to 4 runtime expressions.
//////////////////////////////////////////////////////
// Will use child's char. inputs (+ execution count) for the next
// two runtime expressions.
ValueIdList inputsToUse = child(0).getGroupAttr()->getCharacteristicInputs();
inputsToUse.insert(generator->getOrAddStatementExecutionCount());
// Expression #1 gets the hash value of the probe input data
ValueIdList hvAsList;
// Executor has hard-coded assumption that the result is long,
// so add a Cast node to convert result to a long.
ItemExpr *probeHashAsIe = new (generator->wHeap())
HashDistPartHash(inputsToUse.rebuildExprTree(ITM_ITEM_LIST));
probeHashAsIe->bindNode(generator->getBindWA());
NumericType &nTyp = (NumericType &)probeHashAsIe->getValueId().getType();
GenAssert(nTyp.isSigned() == FALSE,
"Unexpected signed HashDistPartHash.");
GenAssert(probeHashAsIe->getValueId().getType().supportsSQLnullLogical()
== FALSE, "Unexpected nullable HashDistPartHash.");
ItemExpr *hvAsIe = new (generator->wHeap()) Cast(
probeHashAsIe,
new (generator->wHeap())
SQLInt(FALSE, // false == unsigned.
FALSE // false == not nullable.
));
hvAsIe->bindNode(generator->getBindWA());
hvAsList.insert(hvAsIe->getValueId());
ex_expr *hvExpr = NULL;
ULng32 hvLength;
exp_gen->generateContiguousMoveExpr(
hvAsList,
0, // don't add convert node
work_atp,
hashValIdx,
ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
hvLength,
&hvExpr);
GenAssert(hvLength == sizeof(Lng32),
"Unexpected length of result of hash function.");
// Expression #2 encodes the probe input data for storage in
// the ProbeCacheManager.
ValueIdList encodeInputAsList;
CollIndex inputListIndex;
for (inputListIndex = 0;
inputListIndex < inputsToUse.entries();
inputListIndex++) {
ItemExpr *inputIe =
(inputsToUse[inputListIndex].getValueDesc())->getItemExpr();
if (inputIe->getValueId().getType().getVarLenHdrSize() > 0)
{
// This logic copied from Sort::codeGen().
//.........这里部分代码省略.........
示例6: codeGen
short RelInternalSP::codeGen(Generator * generator)
{
Space * space = generator->getSpace();
ExpGenerator * exp_gen = generator->getExpGenerator();
MapTable * last_map_table = generator->getLastMapTable();
ex_expr * input_expr = NULL;
ex_expr * output_expr = NULL;
////////////////////////////////////////////////////////////////////////////
//
// Returned atp layout:
//
// |--------------------------------|
// | input data | stored proc row |
// | ( I tupps ) | ( 1 tupp ) |
// |--------------------------------|
// <-- returned row to parent ---->
//
// input data: the atp input to this node by its parent.
// stored proc row: tupp where the row read from SP is moved.
//
////////////////////////////////////////////////////////////////////////////
ex_cri_desc * given_desc
= generator->getCriDesc(Generator::DOWN);
ex_cri_desc * returned_desc
= new(space) ex_cri_desc(given_desc->noTuples() + 1, space);
// cri descriptor for work atp has 3 entries:
// -- the first two entries for consts and temps.
// -- Entry 3(index #2) is where the input and output rows will be created.
ex_cri_desc * work_cri_desc = new(space) ex_cri_desc(3, space);
const Int32 work_atp = 1;
const Int32 work_atp_index = 2;
ExpTupleDesc * input_tuple_desc = NULL;
ExpTupleDesc * output_tuple_desc = NULL;
// Generate expression to create the input row that will be
// given to the stored proc.
// The input value is in sp->getProcAllParams()
// and has to be converted to sp->procType().
// Generate Cast node to convert procParam to ProcType.
// If procType is a varchar, explode it. This is done
// so that values could be extracted correctly.
ValueIdList procVIDList;
for (CollIndex i = 0; i < procTypes().entries(); i++)
{
Cast * cn;
if ((procTypes())[i].getType().getVarLenHdrSize() > 0)
{
// 5/9/98: add support for VARNCHAR
const CharType& char_type =
(CharType&)((procTypes())[i].getType());
// Explode varchars by moving them to a fixed field
// whose length is equal to the max length of varchar.
cn = new(generator->wHeap())
Cast ((getProcAllParamsVids())[i].getItemExpr(),
(new(generator->wHeap())
SQLChar(generator->wHeap(),
CharLenInfo(char_type.getStrCharLimit(), char_type.getDataStorageSize()),
char_type.supportsSQLnull(),
FALSE, FALSE, FALSE,
char_type.getCharSet(),
char_type.getCollation(),
char_type.getCoercibility()
/*
(procTypes())[i].getType().getNominalSize(),
(procTypes())[i].getType().supportsSQLnull()
*/
)
)
);
// Move the exploded field to a varchar field since
// procType is varchar.
// Can optimize by adding an option to convert node to
// blankpad. TBD.
//
cn = new(generator->wHeap())
Cast(cn, &((procTypes())[i].getType()));
}
else
cn = new(generator->wHeap()) Cast((getProcAllParamsVids())[i].getItemExpr(),
&((procTypes())[i].getType()));
cn->bindNode(generator->getBindWA());
procVIDList.insert(cn->getValueId());
}
ULng32 inputRowlen_ = 0;
exp_gen->generateContiguousMoveExpr(procVIDList, -1, /*add conv nodes*/
work_atp, work_atp_index,
ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
inputRowlen_,
//.........这里部分代码省略.........
示例7: ft_codegen
static short ft_codegen(Generator *generator,
RelExpr &relExpr,
ComTdbFastExtract *&newTdb,
Cardinality estimatedRowCount,
char * targetName,
char * hdfsHost,
Int32 hdfsPort,
char * hiveTableName,
char * delimiter,
char * header,
char * nullString,
char * recordSeparator,
ULng32 downQueueMaxSize,
ULng32 upQueueMaxSize,
ULng32 outputBufferSize,
ULng32 requestBufferSize,
ULng32 replyBufferSize,
ULng32 numOutputBuffers,
ComTdb * childTdb,
NABoolean isSequenceFile)
{
CmpContext *cmpContext = generator->currentCmpContext();
Space *space = generator->getSpace();
ExpGenerator *exp_gen = generator->getExpGenerator();
MapTable *map_table = generator->getMapTable();
MapTable *last_map_table = generator->getLastMapTable();
ex_expr *input_expr = NULL;
ex_expr *output_expr = NULL;
ex_expr * childData_expr = NULL ;
ex_expr * cnvChildData_expr = NULL ;
ULng32 i;
ULng32 requestRowLen = 0;
ULng32 outputRowLen = 0;
ULng32 childDataRowLen = 0;
ULng32 cnvChildDataRowLen = 0;
ExpTupleDesc *requestTupleDesc = NULL;
ExpTupleDesc *outputTupleDesc = NULL;
ExpTupleDesc *childDataTupleDesc = NULL;
ExpTupleDesc *cnvChildDataTupleDesc = NULL;
newTdb = NULL;
OperatorTypeEnum relExprType = relExpr.getOperatorType();
GenAssert(relExprType == REL_FAST_EXTRACT, "Unexpected RelExpr at FastExtract codegen")
FastExtract * fastExtract = (FastExtract *) &relExpr;
const Int32 workAtpNumber = 1;
ex_cri_desc *given_desc = generator->getCriDesc(Generator::DOWN);
ex_cri_desc *returned_desc = NULL;
ex_cri_desc *work_cri_desc = NULL;
returned_desc = given_desc;
// Setup local variables related to the work ATP
unsigned short numWorkTupps = 0;
unsigned short childDataTuppIndex = 0;
unsigned short cnvChildDataTuppIndex = 0;
numWorkTupps = 3;
childDataTuppIndex = numWorkTupps - 1 ;
numWorkTupps ++;
cnvChildDataTuppIndex = numWorkTupps - 1;
work_cri_desc = new (space) ex_cri_desc(numWorkTupps, space);
ExpTupleDesc::TupleDataFormat childReqFormat = ExpTupleDesc::SQLMX_ALIGNED_FORMAT;
ValueIdList childDataVids;
ValueIdList cnvChildDataVids;
const ValueIdList& childVals = fastExtract->getSelectList();
for (i = 0; i < childVals.entries(); i++)
{
ItemExpr &inputExpr = *(childVals[i].getItemExpr());
const NAType &formalType = childVals[i].getType();
ItemExpr *lmExpr = NULL;
ItemExpr *lmExpr2 = NULL;
int res;
lmExpr = &inputExpr; //CreateCastExpr(inputExpr, *inputExpr.getValueId().getType().newCopy(), cmpContext);
res = CreateAllCharsExpr(formalType, // [IN] Child output type
*lmExpr, // [IN] Actual input value
cmpContext, // [IN] Compilation context
lmExpr2 // [OUT] Returned expression
);
GenAssert(res == 0 && lmExpr != NULL,
"Error building expression tree for LM child Input value");
lmExpr->bindNode(generator->getBindWA());
childDataVids.insert(lmExpr->getValueId());
if (lmExpr2)
{
lmExpr2->bindNode(generator->getBindWA());
cnvChildDataVids.insert(lmExpr2->getValueId());
}
} // for (i = 0; i < childVals.entries(); i++)
//.........这里部分代码省略.........
示例8: child
short
PhysUnPackRows::codeGen(Generator *generator)
{
// Get handles on expression generator, map table, and heap allocator
//
ExpGenerator *expGen = generator->getExpGenerator();
Space *space = generator->getSpace();
// Allocate a new map table for this operation
//
MapTable *localMapTable = generator->appendAtEnd();
// Generate the child and capture the task definition block and a description
// of the reply composite row layout and the explain information.
//
child(0)->codeGen(generator);
ComTdb *childTdb = (ComTdb*)(generator->getGenObj());
ex_cri_desc *childCriDesc = generator->getCriDesc(Generator::UP);
ExplainTuple *childExplainTuple = generator->getExplainTuple();
// Make all of my child's outputs map to ATP 1. Since they are
// not needed above, they will not be in the work ATP (0).
// (Later, they will be removed from the map table)
//
localMapTable->setAllAtp(1);
// Generate the given and returned composite row descriptors.
// unPackRows adds a tupp (for the generated outputs) to the
// row given by the parent. The workAtp will have the 2 more
// tupps (1 for the generated outputs and another for the
// indexValue) than the given.
//
ex_cri_desc *givenCriDesc = generator->getCriDesc(Generator::DOWN);
ex_cri_desc *returnedCriDesc =
#pragma nowarn(1506) // warning elimination
new(space) ex_cri_desc(givenCriDesc->noTuples() + 1, space);
#pragma warn(1506) // warning elimination
ex_cri_desc *workCriDesc =
#pragma nowarn(1506) // warning elimination
new(space) ex_cri_desc(givenCriDesc->noTuples() + 2, space);
#pragma warn(1506) // warning elimination
// unPackCols is the next to the last Tp in Atp 0, the work ATP.
// and the last Tp in the returned ATP.
//
const Int32 unPackColsAtpIndex = workCriDesc->noTuples() - 2;
const Int32 unPackColsAtp = 0;
// The length of the new tuple which will contain the columns
// generated by unPackRows
//
ULng32 unPackColsTupleLen;
// The Tuple Desc describing the tuple containing the new unPacked columns
// It is generated when the expression is generated.
//
ExpTupleDesc *unPackColsTupleDesc = 0;
// indexValue is the last Tp in Atp 0, the work ATP.
//
const Int32 indexValueAtpIndex = workCriDesc->noTuples() - 1;
const Int32 indexValueAtp = 0;
// The length of the work tuple which will contain the value
// of the index. This should always be sizeof(int).
//
ULng32 indexValueTupleLen = 0;
// The Tuple Desc describing the tuple containing the new unPacked columns
// It is generated when the expression is generated.
//
ExpTupleDesc *indexValueTupleDesc = 0;
ValueIdList indexValueList;
if (indexValue() != NULL_VALUE_ID)
{
indexValueList.insert(indexValue());
expGen->processValIdList(indexValueList,
ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
indexValueTupleLen,
indexValueAtp,
indexValueAtpIndex,
&indexValueTupleDesc,
ExpTupleDesc::SHORT_FORMAT);
GenAssert(indexValueTupleLen == sizeof(Int32),
"UnPackRows::codeGen: Internal Error");
}
// If a packingFactor exists, generate a move expression for this.
// It is assumed that the packingFactor expression evaluates to a
// 4 byte integer.
//.........这里部分代码省略.........
示例9: mdamPredGen
//.........这里部分代码省略.........
// errorsCanOccur() determines if errors can occur converting the class
// datatype to the target datatype. The object on whose behalf the
// member function is called is expected to be a NAType.
NABoolean generateNarrow =
keyValue->getValueId().getType().errorsCanOccur(*mdamHelper.getTargetType());
if ((generateNarrow) &&
(getenv("NO_NARROWS"))) // for testing -- allows turning off Narrows
generateNarrow = FALSE;
if (generateNarrow)
{
vnode = new(generator->wHeap())
Narrow(keyValue,
mdamHelper.getDataConversionErrorFlag(),
mdamHelper.getTargetType()->newCopy());
}
else
{
vnode = new(generator->wHeap())
Cast(keyValue,mdamHelper.getTargetType()->newCopy());
}
#pragma nowarn(1506) // warning elimination
vnode = new CompEncode(vnode,mdamHelper.isDescending());
#pragma warn(1506) // warning elimination
vnode->bindNode(generator->getBindWA());
// add CASE
// WHEN child(2)
// CAST(round up/round down)
// ELSE
// no-op
ItemExpr * hnode = 0;
if (predType == MdamPred::MDAM_LT)
hnode = new ConstValue(2 /* ex_conv_clause::CONV_RESULT_ROUNDED_UP_TO_MIN */);
else
hnode = new ConstValue(-2 /* ex_conv_clause::CONV_RESULT_ROUNDED_DOWN_TO_MAX */);
hnode = generator->getExpGenerator()->
createExprTree("CASE WHEN @B1 THEN @A2 ELSE @A3 END",
0,
3, // number of subtree parameters
child(2), // @B1
hnode, // @A2
0); // @A3 -- results in no operation
hnode->bindNode(generator->getBindWA());
// Assign attributes for result value
ValueId vnodeId = vnode->getValueId();
ValueId hnodeId = hnode->getValueId();
ULng32 tupleLength = 0;
ValueIdList vnodeList;
vnodeList.insert(vnode->getValueId());
generator->getExpGenerator()->processValIdList(
vnodeList,
mdamHelper.getTupleDataFormat(),
tupleLength, // out
mdamHelper.getAtp(),
mdamHelper.getAtpIndex());
// Assign attributes for modifying data conversion error flag
// Note that all we do is copy the already-assigned attributes
ItemExpr * dataCEF = mdamHelper.getDataConversionErrorFlag();
ValueId dataCEFId = dataCEF->getValueId();
Attributes * dataCEFAttr =
(generator->getMapInfo(dataCEFId))->getAttr();
generator->addMapInfoToThis(generator->getLastMapTable(), hnodeId,dataCEFAttr);
// finally generate the expression and hang it off an MdamPred
ex_expr *vexpr = 0;
vnodeList.insert(hnode->getValueId()); // put hnode in there too
rc = generator->getExpGenerator()->generateListExpr(
vnodeList,
ex_expr::exp_ARITH_EXPR,
&vexpr);
#pragma nowarn(1506) // warning elimination
*head = *tail = new(generator->getSpace())
MdamPred(mdamHelper.getDisjunctNumber(),
predType,
vexpr);
#pragma warn(1506) // warning elimination
return rc;
}
示例10: getMdamPredDetails
// BiRelat for which the following is called will be a predicate for one of the
// endpoints of an MDAM_BETWEEN.
void BiRelat::getMdamPredDetails(Generator* generator,
MdamCodeGenHelper& mdamHelper,
MdamPred::MdamPredType& predType,
ex_expr** vexpr)
{
// Find out what kind of predicate this is. Inequality preds are not inverted
// for descending keys here; instead, the endpoints of the MDAM_BETWEEN
// interval are switched during creation of the mdam network in the executor.
switch (getOperatorType())
{
case ITM_LESS:
predType = MdamPred::MDAM_LT;
break;
case ITM_LESS_EQ:
predType = MdamPred::MDAM_LE;
break;
case ITM_GREATER:
predType = MdamPred::MDAM_GT;
break;
case ITM_GREATER_EQ:
predType = MdamPred::MDAM_GE;
break;
default:
GenAssert(0, "mdamPredGen: invalid comparison for subrange.");
break;
}
ItemExpr* child0 = child(0);
ItemExpr* child1 = child(1);
ValueId keyColumn = mdamHelper.getKeyColumn();
// Canonical form used by rangespec is <key> <compare> <value>.
ItemExpr* keyValue = child1;
GenAssert(child0->getValueId() == keyColumn,
"mdamPredGen: unexpected form for key predicate.");
// generate an expression to convert the key value to the
// type of the key column (in its key buffer) and encode it
ItemExpr* vnode = NULL;
// errorsCanOccur() determines if errors can occur converting the class
// datatype to the target datatype. The object on whose behalf the
// member function is called is expected to be a NAType.
NABoolean generateNarrow =
keyValue->getValueId().getType().errorsCanOccur(*mdamHelper.getTargetType());
#ifdef _DEBUG
if ((generateNarrow) &&
(getenv("NO_NARROWS"))) // for testing -- allows turning off Narrows
generateNarrow = FALSE;
#endif
if (generateNarrow)
vnode = new(generator->wHeap())
Narrow(keyValue,
mdamHelper.getDataConversionErrorFlag(),
mdamHelper.getTargetType()->newCopy(generator->wHeap()));
else
vnode = new(generator->wHeap())
Cast(keyValue,
mdamHelper.getTargetType()->newCopy(generator->wHeap()));
vnode->bindNode(generator->getBindWA());
vnode->preCodeGen(generator);
#pragma nowarn(1506) // warning elimination
vnode = new(generator->wHeap()) CompEncode(vnode,mdamHelper.isDescending());
#pragma warn(1506) // warning elimination
vnode->bindNode(generator->getBindWA());
ValueIdList vnodeList;
vnodeList.insert(vnode->getValueId());
ULng32 dummyLen = 0;
short rc =
generator->getExpGenerator()
->generateContiguousMoveExpr(vnodeList,
0, // don't add convert nodes
mdamHelper.getAtp(),
mdamHelper.getAtpIndex(),
mdamHelper.getTupleDataFormat(),
dummyLen, // out
vexpr);
GenAssert(rc == 0, "generateContiguousMoveExpr() returned error when called "
"from BiRelat::getMdamPredDetails().");
}
示例11: generatePivLayout
void RangePartitioningFunction::generatePivLayout(
Generator *generator,
Lng32 &partitionInputDataLength,
Lng32 atp,
Lng32 atpIndex,
Attributes ***pivAttrs)
{
// Make a layout of the partition input data record such that
// begin and end key are aligned in the same way.
// (layout = ((beg. key) (filler1) (end key) (filler2) (exclusion flag)))
ExpGenerator *expGen = generator->getExpGenerator();
CollIndex numPartInputs = getPartitionInputValuesLayout().entries();
CollIndex numPartKeyCols = (numPartInputs - 1) / 2;
// the number of partition input variables must be odd
GenAssert(2*numPartKeyCols+1 == numPartInputs,
"NOT 2*numPartKeyCols+1 == numPartInputs");
// ---------------------------------------------------------------------
// Start by processing the begin key PIVs
// ---------------------------------------------------------------------
ValueIdList partialPivs;
Attributes **returnedAttrs = NULL;
Attributes **localPartialAttrs;
Lng32 maxAlignment = 1;
Lng32 alignedPartKeyLen;
if (pivAttrs)
{
returnedAttrs = new(generator->wHeap()) Attributes *[numPartInputs];
}
CollIndex i = 0;
for (i = 0; i < numPartKeyCols; i++)
partialPivs.insert(getPartitionInputValuesLayout()[i]);
expGen->processValIdList(
partialPivs,
ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
(ULng32 &) partitionInputDataLength,
atp,
atpIndex,
NULL,
ExpTupleDesc::SHORT_FORMAT,
0,
&localPartialAttrs);
if (returnedAttrs)
for (i = 0; i < numPartKeyCols; i++)
returnedAttrs[i] = localPartialAttrs[i];
// ---------------------------------------------------------------------
// Now find out the max. alignment that is needed in the begin key,
// make sure that the end key starts on an offset that is a
// multiple of the max. alignment in the partition input values
// ---------------------------------------------------------------------
for (i = 0; i < numPartKeyCols; i++)
{
if (localPartialAttrs[i]->getDataAlignmentSize() > maxAlignment)
maxAlignment = localPartialAttrs[i]->getDataAlignmentSize();
if (localPartialAttrs[i]->getVCIndicatorLength() > maxAlignment)
maxAlignment = localPartialAttrs[i]->getVCIndicatorLength();
if (localPartialAttrs[i]->getNullIndicatorLength() > maxAlignment)
maxAlignment = localPartialAttrs[i]->getNullIndicatorLength();
}
alignedPartKeyLen = partitionInputDataLength;
while (alignedPartKeyLen % maxAlignment != 0)
alignedPartKeyLen++;
// ---------------------------------------------------------------------
// Now that we are starting on a good offset, process the end key
// ---------------------------------------------------------------------
partialPivs.clear();
for (i = numPartKeyCols; i < numPartInputs-1; i++)
partialPivs.insert(getPartitionInputValuesLayout()[i]);
expGen->processValIdList(
partialPivs,
ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
(ULng32 &) partitionInputDataLength,
atp,
atpIndex,
NULL,
ExpTupleDesc::SHORT_FORMAT,
alignedPartKeyLen,
&localPartialAttrs);
if (returnedAttrs)
for (i = numPartKeyCols; i < numPartInputs-1; i++)
returnedAttrs[i] = localPartialAttrs[i-numPartKeyCols];
// ---------------------------------------------------------------------
// Process the exclusion flag at offset 2*alignedPartKeyLen
// ---------------------------------------------------------------------
partialPivs.clear();
partialPivs.insert(getPartitionInputValuesLayout()[numPartInputs-1]);
expGen->processValIdList(
//.........这里部分代码省略.........
示例12: codeGen
//.........这里部分代码省略.........
alignedPartKeyLen = MINOF(
alignedPartKeyLen,
begEndAttrs[numPartKeyCols]->getVCLenIndOffset());
// generate a tuple desc for the whole PIV record and a cri desc
partInputTupleDesc = new(generator->getSpace()) ExpTupleDesc(
numPartInputs,
begEndAttrs,
myOwnPartInputDataLength,
pivFormat,
ExpTupleDesc::LONG_FORMAT,
generator->getSpace());
partInputCriDesc->setTupleDescriptor(pivMoveAtpIndex,partInputTupleDesc);
// make sure we fulfill the assertions we made
// optimizer and generator should agree on the part input data length
GenAssert(partInputDataLength == (Lng32) myOwnPartInputDataLength,
"NOT partInputDataLength == myOwnPartInputDataLength");
// the length of the begin key and the end key must be the same
// (compare offsets of their last fields)
// Commented out because this check does not work. The check needs
// to compute the LENGTH of each key field, by subtracting the current
// offset from the next offset, taking into account varchar length
// and null indicator fields (which are not part of the length but
// increase the offset).
//GenAssert(begEndAttrs[numPartKeyCols-1]->getOffset() + alignedPartKeyLen ==
// begEndAttrs[2*numPartKeyCols-1]->getOffset(),
// "begin/end piv keys have different layouts");
#pragma nowarn(1506) // warning elimination
generatedObject = new(generator->getSpace()) ExRangePartInputData(
partInputCriDesc,
partInputDataLength,
alignedPartKeyLen, //len of one part key + filler
begEndAttrs[numPartInputs-1]->getOffset(),//offset of last field
getCountOfPartitions(),
generator->getSpace(),
TRUE); // uses expressions to calculate ranges in the executor
generatedObject->setPartitionExprAtp(pivMoveAtp);
generatedObject->setPartitionExprAtpIndex(pivMoveAtpIndex);
#pragma warn(1506) // warning elimination
// now fill in the individual partition boundaries
// (NOTE: there is one more than there are partitions)
ULng32 boundaryDataLength = 0;
for (Lng32 i = 0; i <= getCountOfPartitions(); i++)
{
const ItemExprList *iel = partitionBoundaries_->getBoundaryValues(i);
ex_expr * generatedExpr = NULL;
ValueIdList boundaryColValues;
ULng32 checkedBoundaryLength;
// convert the ItemExpressionList iel into a ValueIdList
for (CollIndex kc = 0; kc < iel->entries(); kc++)
{
ItemExpr *boundaryVal = (*iel)[kc];
// create a cast node to convert the boundary value to the
// data type of the column
ItemExpr *castBoundaryVal =
new(generator->wHeap()) Cast(boundaryVal,&piv[kc].getType());
castBoundaryVal->bindNode(generator->getBindWA());
boundaryColValues.insert(castBoundaryVal->getValueId());
}
// Now generate a contiguous move expression. Only for the first time
// generate a tuple desc, since all tuples should be the same.
exp_gen->generateContiguousMoveExpr(
boundaryColValues,
0, // cast nodes created above will do the move, no conv nodes
pivMoveAtp,
pivMoveAtpIndex,
pivFormat,
checkedBoundaryLength,
&generatedExpr);
if (i == 0)
{
// first time set the actual part key data length
boundaryDataLength = checkedBoundaryLength;
}
else
{
// all boundary values (piv tuples) must have the same layout
// and therefore the same length
GenAssert(boundaryDataLength == checkedBoundaryLength,
"Partition boundary tuple layout mismatch");
}
generatedObject->setPartitionStartExpr(i,generatedExpr);
}
NADELETEBASIC(begEndAttrs, generator->wHeap());
generator->setGenObj(NULL, (ComTdb*)generatedObject);
return 0;
}
示例13: ft_codegen
//.........这里部分代码省略.........
if (hiveNAColArray)
{
const NAColumn *hiveNACol = (*hiveNAColArray)[i];
const NAType *hiveNAType = hiveNACol->getType();
// if tgt type was a hive 'string', do not return a conversion err
if ((lmExpr->getValueId().getType().errorsCanOccur(*hiveNAType)) &&
(NOT ((DFS2REC::isSQLVarChar(hiveNAType->getFSDatatype())) &&
(((SQLVarChar*)hiveNAType)->wasHiveString()))))
{
ItemExpr *newExpr =
new(generator->wHeap()) Cast(lmExpr, hiveNAType);
newExpr = newExpr->bindNode(generator->getBindWA());
if (!newExpr || generator->getBindWA()->errStatus())
{
GenAssert(0, "newExpr->bindNode failed");
}
if (hiveInsertErrMode == 3)
((Cast*)newExpr)->setConvertNullWhenError(TRUE);
lmExpr = newExpr;
}
}
res = CreateAllCharsExpr(formalType, // [IN] Child output type
*lmExpr, // [IN] Actual input value
cmpContext, // [IN] Compilation context
lmExpr2 // [OUT] Returned expression
);
GenAssert(res == 0 && lmExpr != NULL,
"Error building expression tree for LM child Input value");
childDataVids.insert(lmExpr->getValueId());
if (lmExpr2)
{
lmExpr2->bindNode(generator->getBindWA());
cnvChildDataVids.insert(lmExpr2->getValueId());
}
} // for (i = 0; i < childVals.entries(); i++)
if (childDataVids.entries() > 0 &&
cnvChildDataVids.entries()>0) //-- convertedChildDataVids
{
UInt16 pcm = exp_gen->getPCodeMode();
if ((hiveNAColArray) &&
(hiveInsertErrMode == 3))
{
// if error mode is 3 (mode null when error), disable pcode.
// this feature is currently not being handled by pcode.
// (added as part of JIRA 1920 in FileScan::codeGenForHive).
exp_gen->setPCodeMode(ex_expr::PCODE_NONE);
}
exp_gen->generateContiguousMoveExpr (
childDataVids, //childDataVids// [IN] source ValueIds
TRUE, // [IN] add convert nodes?
workAtpNumber, // [IN] target atp number (0 or 1)
childDataTuppIndex, // [IN] target tupp index
childReqFormat, // [IN] target tuple data format
childDataRowLen, // [OUT] target tuple length
&childData_expr, // [OUT] move expression
&childDataTupleDesc, // [optional OUT] target tuple desc
ExpTupleDesc::LONG_FORMAT // [optional IN] target desc format
示例14: buildKeyInfo
short ExpGenerator::buildKeyInfo(keyRangeGen ** keyInfo, // out -- generated object
Generator * generator,
const NAColumnArray & keyColumns,
const ValueIdList & listOfKeyColumns,
const ValueIdList & beginKeyPred,
const ValueIdList & endKeyPred,
const SearchKey * searchKey,
const MdamKey * mdamKeyPtr,
const NABoolean reverseScan,
unsigned short keytag,
const ExpTupleDesc::TupleDataFormat tf,
// the next few parameters are here
// as part of a horrible kludge for
// the PartitionAccess::codeGen()
// method, which lacks a SearchKey
// object and therefore exposes
// things like the exclusion
// expressions; with luck, later work
// in the Optimizer will result in a
// much cleaner interface
const NABoolean useTheHorribleKludge,
ItemExpr * beginKeyExclusionExpr,
ItemExpr * endKeyExclusionExpr,
ex_expr_lean ** unique_key_expr,
ULng32 *uniqueKeyLen,
NABoolean doKeyEncodeOpt,
Lng32 * firstKeyColOffset,
Int32 in_key_atp_index
)
{
Space * space = generator->getSpace();
const Int32 work_atp = 1;
const Int32 key_atp_index = (in_key_atp_index <= 0 ? 2 : in_key_atp_index);
const Int32 exclude_flag_atp_index = 3;
const Int32 data_conv_error_atp_index = 4;
const Int32 key_column_atp_index = 5; // used only for Mdam
const Int32 key_column2_atp_index = 6; // used only for Mdam MDAM_BETWEEN pred;
// code in BiLogic::mdamPredGenSubrange
// and MdamColumn::buildDisjunct
// requires this to be 1 more than
// key_column_atp_index
ULng32 keyLen;
// add an entry to the map table for work Atp
MapTable *keyBufferPartMapTable = generator->appendAtEnd();
// generate a temporary variable, which will be used for handling
// data conversion errors during key building
ValueIdList temp_varb_list;
ItemExpr * dataConversionErrorFlag = new(generator->wHeap())
HostVar("_sys_dataConversionErrorFlag",
new(generator->wHeap()) SQLInt(TRUE,FALSE), // int not null
TRUE);
ULng32 temp_varb_tupp_len;
dataConversionErrorFlag->bindNode(generator->getBindWA());
temp_varb_list.insert(dataConversionErrorFlag->getValueId());
processValIdList(temp_varb_list,
ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
temp_varb_tupp_len, // out
work_atp,
data_conv_error_atp_index);
NABoolean doEquiKeyPredOpt = FALSE;
#ifdef _DEBUG
if (getenv("DO_EQUI_KEY_PRED_OPT"))
doEquiKeyPredOpt
= (searchKey ? searchKey->areAllChosenPredsEqualPreds() : FALSE);
#endif
if (mdamKeyPtr == NULL)
{
// check to see if there is a begin key expression; if there
// isn't, don't generate a key object
if (beginKeyPred.entries() == 0)
*keyInfo = 0;
else
{
// For subset and range operators, generate the begin key
// expression, end key expression, begin key exclusion expression
// and end key exclusion expression. For unique operators,
// generate only the begin key exppression.
ex_expr *bk_expr = 0;
ex_expr *ek_expr = 0;
ex_expr *bk_excluded_expr = 0;
ex_expr *ek_excluded_expr = 0;
short bkey_excluded = 0;
short ekey_excluded = 0;
generateKeyExpr(keyColumns,
beginKeyPred,
work_atp,
key_atp_index,
dataConversionErrorFlag,
tf,
keyLen, // out
//.........这里部分代码省略.........