本文整理汇总了C++中Space::allocateAndCopyToAlignedSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ Space::allocateAndCopyToAlignedSpace方法的具体用法?C++ Space::allocateAndCopyToAlignedSpace怎么用?C++ Space::allocateAndCopyToAlignedSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Space
的用法示例。
在下文中一共展示了Space::allocateAndCopyToAlignedSpace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateSPIOExpr
/////////////////////////////////////////////////////////////////////
//
// Contents:
//
// RelStoredProc::codeGen()
//
//////////////////////////////////////////////////////////////////////
short generateSPIOExpr(RelInternalSP * sp,
Generator * generator,
ExSPInputOutput * &inputExpr,
ExSPInputOutput * &outputExpr)
{
ExpGenerator * expGen = generator->getExpGenerator();
Space * genSpace = generator->getSpace();
// Generate input(extract) expr
FragmentDir * compFragDir = generator->getFragmentDir();
// create the fragment (independent code space) for this expression
CollIndex myFragmentId = compFragDir->pushFragment(FragmentDir::MASTER);
Space * space = generator->getSpace();
// Start generation by creating the ExSPInputOutput class.
//It will be initialized later.
ExSPInputOutput * lInputExpr = new(space) ExSPInputOutput();
ULng32 recordLen;
ExpTupleDesc * tupleDesc = NULL;
if (expGen->processValIdList(sp->procTypes(),
ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
recordLen,
0, 1,
&tupleDesc,
ExpTupleDesc::LONG_FORMAT) == -1)
return -1;
ConvInstruction * cia =
(ConvInstruction *)space->allocateMemory(sp->procTypes().entries() *
sizeof(ConvInstruction));
ULng32 totalLen = space->getAllocatedSpaceSize();
lInputExpr->initialize(tupleDesc, totalLen, cia);
ExSPInputOutputPtr(lInputExpr).pack(space);
// the generated expr is generated in chunks internally by
// the space class. Make it contiguous by allocating and
// moving it to a contiguous area.
char * expr = new(generator->wHeap()) char[totalLen];
space->makeContiguous((char *)expr, totalLen);
inputExpr =
(ExSPInputOutput *)(genSpace->allocateAndCopyToAlignedSpace((char *)expr, totalLen, 0));
compFragDir->removeFragment();
// Delete expr
NADELETEBASIC(expr, generator->wHeap());
expr = NULL;
// Now generate the move to output row expr
myFragmentId = compFragDir->pushFragment(FragmentDir::MASTER);
space = generator->getSpace();
ExSPInputOutput * lOutputExpr = new(space) ExSPInputOutput();
if (expGen->processValIdList(sp->getTableDesc()->getColumnList(),
ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
recordLen,
0, 1,
&tupleDesc,
ExpTupleDesc::LONG_FORMAT) == -1)
return -1;
cia =
(ConvInstruction *)space->allocateMemory(sp->getTableDesc()->getColumnList().entries() *
sizeof(ConvInstruction));
for (short i = 0; i < (short) tupleDesc->numAttrs(); i++)
{
ex_conv_clause tempClause;
cia[i] = tempClause.findInstruction(REC_BYTE_V_ASCII,
-1, // no op
tupleDesc->getAttr(i)->getDatatype(),
tupleDesc->getAttr(i)->getLength(),
0);
}
totalLen = space->getAllocatedSpaceSize();
lOutputExpr->initialize(tupleDesc, totalLen, cia);
ExSPInputOutputPtr(lOutputExpr).pack(space);
expr = new(generator->wHeap()) char[totalLen];
space->makeContiguous((char *)expr, totalLen);
outputExpr =
//.........这里部分代码省略.........
示例2: codeGen
//.........这里部分代码省略.........
&input_tuple_desc,
ExpTupleDesc::LONG_FORMAT);
// add all columns from this SP to the map table.
ULng32 tupleLength;
exp_gen->processValIdList(getTableDesc()->getColumnList(),
ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
tupleLength,
work_atp,
work_atp_index);
// Generate expression to move the output row returned by the
// stored proc back to parent.
ULng32 outputRowlen_ = 0;
MapTable * returnedMapTable = 0;
exp_gen->generateContiguousMoveExpr(getTableDesc()->getColumnList(),
-1 /*add conv nodes*/,
0, returned_desc->noTuples() - 1,
ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
outputRowlen_,
&output_expr,
&output_tuple_desc,
ExpTupleDesc::LONG_FORMAT,
&returnedMapTable);
// Now generate expressions used to extract or move input or
// output values. See class ExSPInputOutput.
ExSPInputOutput * extractInputExpr = NULL;
ExSPInputOutput * moveOutputExpr = NULL;
generateSPIOExpr(this, generator,
extractInputExpr,
moveOutputExpr);
// done with expressions at this operator. Remove the appended map tables.
generator->removeAll(last_map_table);
// append the map table containing the returned columns
generator->appendAtEnd(returnedMapTable);
NAString procNameAsNAString(procName_);
char * sp_name =
space->allocateAndCopyToAlignedSpace(procNameAsNAString,
procNameAsNAString.length(), 0);
ExpGenerator *expGen = generator->getExpGenerator();
// expression to conditionally return 0 or more rows.
ex_expr *predExpr = NULL;
// generate tuple selection expression, if present
if(NOT selectionPred().isEmpty())
{
ItemExpr* pred = selectionPred().rebuildExprTree(ITM_AND,TRUE,TRUE);
expGen->generateExpr(pred->getValueId(),ex_expr::exp_SCAN_PRED,&predExpr);
}
ComTdbStoredProc * sp_tdb = new(space)
ComTdbStoredProc(sp_name,
input_expr,
inputRowlen_,
output_expr,
outputRowlen_,
work_cri_desc,
work_atp_index,
given_desc,
returned_desc,
extractInputExpr,
moveOutputExpr,
2,
1024,
(Cardinality) getGroupAttr()->
getOutputLogPropList()[0]->
getResultCardinality().value(),
5,
64000, //10240
predExpr,
(UInt16) arkcmpInfo_);
generator->initTdbFields(sp_tdb);
if(!generator->explainDisabled())
{
generator->setExplainTuple(
addExplainInfo(sp_tdb, 0, 0, generator));
}
// Do not infer that any transaction started can
// be in READ ONLY mode if ISPs are present.
generator->setNeedsReadWriteTransaction(TRUE);
generator->setCriDesc(given_desc, Generator::DOWN);
generator->setCriDesc(returned_desc, Generator::UP);
generator->setGenObj(this, sp_tdb);
// Some built-in functions require a TMF transaction
// because they get their information from catman
generator->setTransactionFlag(getRequiresTMFTransaction());
return 0;
}