// Constructor and destructor private state // // ExSamplePrivateState::ExSamplePrivateState (const ExSampleTcb * tcb) { matchCount_ = 0; step_ = ExSampleTcb::ExSamp_EMPTY; workAtp_ = allocateAtp(tcb->myTdb().criDescUp_, ((ex_tcb*)tcb)->getSpace()); }
ExpDP2Expr::ExpDP2Expr(ex_expr_base * expr, ex_cri_desc * work_cri_desc, Space * space, short allocateAtpAtRunTime) : expr_(expr), criDesc_(work_cri_desc), NAVersionedObject(-1), pCodeMode_(0) { if (allocateAtpAtRunTime) { // workAtp_ only constructed at run time. At compile-time, we only reserve // space for it. workAtpSpace_ = spaceNeededForWorkAtp(); workAtp_ = (atp_struct *) space->allocateAlignedSpace(workAtpSpace_); } else { workAtpSpace_ = -1; workAtp_ = allocateAtp(work_cri_desc, space); // allocate tuple descriptors for all the tupps (except constant and temp) // in workAtp_. for (Int32 i = 2; i < work_cri_desc->noTuples(); i++) { workAtp_->getTupp(i) = (tupp_descriptor *)(new(space) tupp_descriptor); } } // allocate space for temps, if needed. if ( (expr) && (expr->getTempsLength() > 0) && (! expr->getTempsArea()) ) { ((ex_expr*)expr)->setTempsArea(new(space) char[expr->getTempsLength()]); } }
// // Constructor for sort_grby_tcb // ex_sort_grby_tcb::ex_sort_grby_tcb(const ex_sort_grby_tdb & sort_grby_tdb, const ex_tcb & child_tcb, // child queue pair ex_globals * glob ) : ex_tcb( sort_grby_tdb, 1, glob), pool_(NULL) { Space * space = (glob ? glob->getSpace() : 0); CollHeap * heap = (glob ? glob->getDefaultHeap() : 0); childTcb_ = &child_tcb; // Allocate the buffer pool #pragma nowarn(1506) // warning elimination pool_ = new(space) ExSimpleSQLBuffer(sort_grby_tdb.numBuffers_, sort_grby_tdb.bufferSize_, recLen(), space); #pragma warn(1506) // warning elimination // get the child queue pair qchild_ = child_tcb.getParentQueue(); // Allocate the queue to communicate with parent allocateParentQueues(qparent_); // Intialize processedInputs_ to the next request to process processedInputs_ = qparent_.down->getTailIndex(); // allocate work atp workAtp_ = allocateAtp(sort_grby_tdb.criDescUp_,getSpace()); // fixup aggr expression if (aggrExpr()) (void) aggrExpr()->fixup(0, getExpressionMode(), this, space, heap, glob->computeSpace()); // fixup move expression if (moveExpr()) (void) moveExpr()->fixup(0, getExpressionMode(), this, space, heap, glob->computeSpace()); // fixup grby expression if (grbyExpr()) (void) grbyExpr()->fixup(0, getExpressionMode(), this, space, heap, glob->computeSpace()); // fixup having expression if (havingExpr()) (void) havingExpr()->fixup(0, getExpressionMode(), this, space, heap, glob->computeSpace()); }
// // Constructor for firstn_tcb // ExFirstNTcb::ExFirstNTcb(const ExFirstNTdb & firstn_tdb, const ex_tcb & child_tcb, // child queue pair ex_globals *glob ) : ex_tcb( firstn_tdb, 1, glob), step_(INITIAL_) { childTcb_ = &child_tcb; Space * space = glob->getSpace(); CollHeap * heap = (glob ? glob->getDefaultHeap() : NULL); // Allocate the buffer pool #pragma nowarn(1506) // warning elimination pool_ = new(space) sql_buffer_pool(firstn_tdb.numBuffers_, firstn_tdb.bufferSize_, space); #pragma warn(1506) // warning elimination // get the queue that child use to communicate with me qchild_ = child_tcb.getParentQueue(); // Allocate the queue to communicate with parent qparent_.down = new(space) ex_queue(ex_queue::DOWN_QUEUE, firstn_tdb.queueSizeDown_, firstn_tdb.criDescDown_, space); // Allocate the private state in each entry of the down queue ExFirstNPrivateState p(this); qparent_.down->allocatePstate(&p, this); qparent_.up = new(space) ex_queue(ex_queue::UP_QUEUE, firstn_tdb.queueSizeUp_, firstn_tdb.criDescUp_, space); workAtp_ = NULL; firstNParamVal_ = 0; if (firstn_tdb.workCriDesc_) { workAtp_ = allocateAtp(firstn_tdb.workCriDesc_, space); pool_->get_free_tuple(workAtp_->getTupp(firstn_tdb.workCriDesc_->noTuples()-1), 0); workAtp_->getTupp(firstn_tdb.workCriDesc_->noTuples()-1). setDataPointer((char*)&firstNParamVal_); } if (firstn_tdb.firstNRowsExpr_) { firstn_tdb.firstNRowsExpr_->fixup(0, getExpressionMode(), this, space, heap, FALSE, glob); } };
//////////////////////////////////////////////////////////////// // Constructor for class ExTimeoutTcb /////////////////////////////////////////////////////////////// ExTimeoutTcb::ExTimeoutTcb(const ExTimeoutTdb & timeout_tdb, ExMasterStmtGlobals * glob) : ex_tcb( timeout_tdb, 1, glob) { Space * space = (glob ? glob->getSpace() : 0); CollHeap * heap = (glob ? glob->getDefaultHeap() : 0); // Allocate the buffer pool pool_ = new(space) sql_buffer_pool(timeout_tdb.numBuffers_, timeout_tdb.bufferSize_, space); // Allocate the queue to communicate with parent qparent_.down = new(space) ex_queue(ex_queue::DOWN_QUEUE, timeout_tdb.queueSizeDown_, timeout_tdb.criDescDown_, space); // Allocate the private state in each entry of the down queue ExTimeoutPrivateState *p = new(space) ExTimeoutPrivateState(this); qparent_.down->allocatePstate(p, this); delete p; qparent_.up = new(space) ex_queue(ex_queue::UP_QUEUE, timeout_tdb.queueSizeUp_, timeout_tdb.criDescUp_, space); // Get the name of the table from the late-name-info in the root-tdb ex_root_tdb * rootTdb = (ex_root_tdb *) glob->getFragmentPtr(0) ; LateNameInfoList * lnil = rootTdb->getLateNameInfoList(); ex_assert( lnil , "No late name info list in root TDB!"); theTableName_ = lnil->getLateNameInfo(0).resolvedPhyName(); ex_assert( theTableName_ , "No table name !"); if (timeoutValueExpr()) { // allocate work atp to compute the timeout value workAtp_ = allocateAtp(timeout_tdb.workCriDesc_, space); // allocate tuple where the timeout value will be moved pool_->get_free_tuple(workAtp_-> getTupp(timeout_tdb.workCriDesc_->noTuples() - 1), sizeof(Lng32)); (void) timeoutValueExpr()->fixup(0, getExpressionMode(), this, space, heap, FALSE, glob); } else workAtp_ = 0; }
// // Constructor for ExIar tcb // ExIarTcb::ExIarTcb (const ExIarTdb& iarTdb, ex_globals *glob ) : ex_tcb( iarTdb, 1, glob) { Space * space = (glob ? glob->getSpace() : 0); CollHeap * heap = (glob ? glob->getDefaultHeap() : 0); // Allocate the buffer pool #pragma nowarn(1506) // warning elimination pool_ = new(space) sql_buffer_pool(iarTdb.numBuffers_, iarTdb.bufferSize_, space); #pragma warn(1506) // warning elimination // Allocate the queue to communicate with parent. qparent_.down = new(space) ex_queue(ex_queue::DOWN_QUEUE, iarTdb.queueSizeDown_, iarTdb.criDescDown_, space ); // Allocate the private state in each entry of the down queue ExIarPrivateState *p = new(space) ExIarPrivateState(this); qparent_.down->allocatePstate(p, this); delete p; qparent_.up = new(space) ex_queue(ex_queue::UP_QUEUE, iarTdb.queueSizeUp_, iarTdb.criDescUp_, space); // Fixup the column extraction expression, if any. if (iarTdb.getExtractExpr()) iarTdb.getExtractExpr()->fixup(0, getExpressionMode(), this, space, heap); // Fixup the scan expression, if any. if (iarTdb.getScanExpr()) iarTdb.getScanExpr()->fixup(0, getExpressionMode(), this, space, heap); // Fixup the projection expression. if (iarTdb.getProjExpr()) iarTdb.getProjExpr()->fixup(0, getExpressionMode(), this, space, heap); // Allocate the work ATP. workAtp_ = allocateAtp(iarTdb.workCriDesc_, space); };
keyRangeEx::keyRangeEx(const keyRangeGen & tdb_key, ex_globals * g, const short in_version, sql_buffer_pool *pool ) : tdbKey_(tdb_key),globals_(g),bkExcludeFlag_(0),ekExcludeFlag_(0) { #pragma nowarn(1506) // warning elimination pool->get_free_tuple(bkData_, tdb_key.getKeyLength()); #pragma warn(1506) // warning elimination #pragma nowarn(1506) // warning elimination pool->get_free_tuple(ekData_, tdb_key.getKeyLength()); #pragma warn(1506) // warning elimination workAtp_ = allocateAtp(tdbKey_.getWorkCriDesc(),g->getSpace()); pool->get_free_tuple(workAtp_->getTupp(tdbKey_.getKeyValuesAtpIndex()), 0); // note that begin and end key buffers are hooked up to the work atp // dynamically by getNextKeyRange() // workAtp->getTupp(tdbKey_.getKeyValuesAtpIndex()) = bkData_; // workAtp->getTupp(tdbKey_.getKeyValuesAtpIndex()) = ekData_; // hook up the exclusion flag tupp to the exclusion flag data member excludeFlagTupp_.init(sizeof(excludeFlag_), NULL, (char *) &excludeFlag_); workAtp_->getTupp(tdbKey_.getExcludeFlagAtpIndex()) = &excludeFlagTupp_; // hook up the data conversion error flag to appropriate member dataConvErrorFlagTupp_.init(sizeof(dataConvErrorFlag_), NULL, (char *) &dataConvErrorFlag_); workAtp_->getTupp(tdbKey_.getDataConvErrorFlagAtpIndex()) = &dataConvErrorFlagTupp_; };
//////////////////////////////////////////////////////////////// // Constructor for class ExExeUtilTcb /////////////////////////////////////////////////////////////// ExExeUtilTcb::ExExeUtilTcb(const ComTdbExeUtil & exe_util_tdb, const ex_tcb * child_tcb, // for child queue ex_globals * glob) : ex_tcb( exe_util_tdb, 1, glob), workAtp_(NULL), query_(NULL), infoList_(NULL), infoListIsOutputInfo_(TRUE), explQuery_(NULL), childQueryId_(NULL), childQueryIdLen_(0), outputBuf_(NULL) { Space * space = (glob ? glob->getSpace() : 0); CollHeap * heap = (glob ? glob->getDefaultHeap() : 0); // Allocate the buffer pool #pragma nowarn(1506) // warning elimination pool_ = new(space) sql_buffer_pool(exe_util_tdb.numBuffers_, exe_util_tdb.bufferSize_, space); #pragma warn(1506) // warning elimination childTcb_ = child_tcb; if (childTcb_) { qchild_ = childTcb_->getParentQueue(); } // Allocate the queue to communicate with parent qparent_.down = new(space) ex_queue(ex_queue::DOWN_QUEUE, exe_util_tdb.queueSizeDown_, exe_util_tdb.criDescDown_, space); qparent_.up = new(space) ex_queue(ex_queue::UP_QUEUE, exe_util_tdb.queueSizeUp_, exe_util_tdb.criDescUp_, space); if (exe_util_tdb.workCriDesc_) { workAtp_ = allocateAtp(exe_util_tdb.workCriDesc_, glob->getSpace()); pool_->get_free_tuple(workAtp_->getTupp(((ComTdbExeUtil&)exe_util_tdb).workAtpIndex()), 0); } tcbFlags_ = 0; if (exe_util_tdb.inputExpr_) (void)exe_util_tdb.inputExpr_->fixup(0, getExpressionMode(), this, space, heap, FALSE, glob); if (exe_util_tdb.outputExpr_) (void)exe_util_tdb.outputExpr_->fixup(0, getExpressionMode(), this, space, heap, FALSE, glob); if (exe_util_tdb.scanExpr_) (void)exe_util_tdb.scanExpr_->fixup(0, getExpressionMode(), this, space, heap, FALSE, glob); ContextCli * currContext = (glob->castToExExeStmtGlobals()->castToExMasterStmtGlobals() ? glob->castToExExeStmtGlobals()->castToExMasterStmtGlobals()->getStatement()->getContext() : NULL); // internal queries are already in isoMapping and do not need to be // translated before sending to mxcmp. // Set the ISO_MAPPING charset code to indicate that. char *parentQid; if (glob->castToExExeStmtGlobals()->castToExMasterStmtGlobals()) parentQid = glob->castToExExeStmtGlobals()->castToExMasterStmtGlobals()->getStatement()->getUniqueStmtId(); else if (glob->castToExExeStmtGlobals()->castToExEspStmtGlobals() && glob->castToExExeStmtGlobals()->castToExEspStmtGlobals()->getStmtStats()) parentQid = glob->castToExExeStmtGlobals()->castToExEspStmtGlobals()->getStmtStats()->getQueryId(); else parentQid = NULL; cliInterface_ = new(heap) ExeCliInterface(heap, SQLCHARSETCODE_ISO88591, // ISO_MAPPING=ISO88591 currContext, parentQid); cliInterface2_ = new(heap) ExeCliInterface(heap, SQLCHARSETCODE_ISO88591, // ISO_MAPPING=ISO88591 currContext, parentQid); //diagsArea_ = NULL; setDiagsArea(ComDiagsArea::allocate(getHeap())); pqStep_ = PROLOGUE_; VersionToString(COM_VERS_MXV, versionStr_); versionStrLen_ = DIGITS_IN_VERSION_NUMBER; VersionToString(COM_VERS_MXV, sysVersionStr_); sysVersionStrLen_ = DIGITS_IN_VERSION_NUMBER; extractedPartsObj_ = NULL; };
// ExSequenceTcb constructor // // 1. Allocate buffer pool. // 2. Allocate parent queues and initialize private state. // 3. Fixup expressions. // ExSequenceTcb::ExSequenceTcb (const ExSequenceTdb & myTdb, const ex_tcb & child_tcb, ex_globals * glob) : ex_tcb(myTdb, 1, glob), lastRow_(NULL), clusterDb_(NULL), cluster_(NULL), ioEventHandler_(NULL), OLAPBuffersFlushed_(FALSE), firstOLAPBuffer_(NULL), lastOLAPBuffer_(NULL), rc_(EXE_OK), olapBufferSize_(0), maxNumberOfOLAPBuffers_(0), numberOfOLAPBuffers_(0), minNumberOfOLAPBuffers_(0), memoryPressureDetected_(FALSE) { Space * space = (glob ? glob->getSpace() : 0); CollHeap * heap = (glob ? glob->getDefaultHeap() : 0); heap_ = heap; childTcb_ = &child_tcb; // Allocate the buffer pool #pragma nowarn(1506) // warning elimination pool_ = new(space) sql_buffer_pool(myTdb.numBuffers_, myTdb.bufferSize_, space); allocRowLength_ = ROUND8(myTdb.recLen_); #pragma warn(1506) // warning elimination // Initialize the machinery for maintaining the row history for // computing sequence functions. // maxNumberHistoryRows_ = myTdb.maxHistoryRows_; minFollowing_ = myTdb.minFollowing_; unboundedFollowing_ = myTdb.isUnboundedFollowing(); maxNumberOfOLAPBuffers_ = myTdb.maxNumberOfOLAPBuffers_;//testing olapBufferSize_ = myTdb.OLAPBufferSize_ ; maxRowsInOLAPBuffer_ = myTdb.maxRowsInOLAPBuffer_; minNumberOfOLAPBuffers_ = myTdb.minNumberOfOLAPBuffers_; numberOfWinOLAPBuffers_ = myTdb.numberOfWinOLAPBuffers_; overflowEnabled_ = ! myTdb.isNoOverflow(); ex_assert( maxNumberOfOLAPBuffers_ >= minNumberOfOLAPBuffers_ , "maxNumberOfOLAPBuffers is too small"); // Initialize history parameters // For unbounded following -- also create/initialize clusterDb, cluster initializeHistory(); // get the queue that child use to communicate with me qchild_ = child_tcb.getParentQueue(); // Allocate the queue to communicate with parent qparent_.down = new(space) ex_queue(ex_queue::DOWN_QUEUE, myTdb.initialQueueSizeDown_, myTdb.criDescDown_, space); // Allocate the private state in each entry of the down queue ExSequencePrivateState *p = new(space) ExSequencePrivateState(this); qparent_.down->allocatePstate(p, this); delete p; qparent_.up = new(space) ex_queue(ex_queue::UP_QUEUE, myTdb.initialQueueSizeUp_, myTdb.criDescUp_, space); // Intialized processedInputs_ to the next request to process processedInputs_ = qparent_.down->getTailIndex(); workAtp_ = allocateAtp(myTdb.criDescUp_, space); // Fixup the sequence function expression. This requires the standard // expression fixup plus initializing the GetRow method for the sequence // clauses. // if (sequenceExpr()) { ((ExpSequenceExpression*)sequenceExpr())->seqFixup ((void*)this, GetHistoryRow, GetHistoryRowOLAP); sequenceExpr()->fixup(0, getExpressionMode(), this, space, heap_, FALSE, glob); } if (returnExpr()) { ((ExpSequenceExpression*)returnExpr())->seqFixup ((void*)this, GetHistoryRow, GetHistoryRowFollowingOLAP); returnExpr()->fixup(0, getExpressionMode(), this, space, heap_, FALSE, glob); } if (postPred()) postPred()->fixup(0, getExpressionMode(), this, space, heap_, FALSE, glob); if (cancelExpr()) cancelExpr()->fixup(0, getExpressionMode(), this, space, heap_, FALSE, glob); if (checkPartitionChangeExpr()) { ((ExpSequenceExpression*)checkPartitionChangeExpr())->seqFixup ((void*)this, GetHistoryRow, GetHistoryRowOLAP); checkPartitionChangeExpr()->fixup(0, getExpressionMode(), this, space, heap_, FALSE, glob); } }
ExFastExtractTcb::ExFastExtractTcb( const ExFastExtractTdb &fteTdb, const ex_tcb & childTcb, ex_globals *glob) : ex_tcb(fteTdb, 1, glob), workAtp_(NULL), outputPool_(NULL), inputPool_(NULL), childTcb_(&childTcb) , inSqlBuffer_(NULL) , childOutputTD_(NULL) , sourceFieldsConvIndex_(NULL) , currBuffer_(NULL) , bufferAllocFailuresCount_(0) , modTS_(-1) { ex_globals *stmtGlobals = getGlobals(); Space *globSpace = getSpace(); CollHeap *globHeap = getHeap(); heap_ = globHeap; //convert to non constant to access the members. ExFastExtractTdb *mytdb = (ExFastExtractTdb*)&fteTdb; numBuffers_ = mytdb->getNumIOBuffers(); // Allocate queues to communicate with parent allocateParentQueues(qParent_); // get the queue that child use to communicate with me qChild_ = childTcb.getParentQueue(); // Allocate the work ATP if (myTdb().getWorkCriDesc()) workAtp_ = allocateAtp(myTdb().getWorkCriDesc(), globSpace); // Fixup expressions // NOT USED in M9 /* if (myTdb().getInputExpression()) myTdb().getInputExpression()->fixup(0, getExpressionMode(), this, globSpace, globHeap); if (myTdb().getOutputExpression()) myTdb().getOutputExpression()->fixup(0, getExpressionMode(), this, globSpace, globHeap); */ if (myTdb().getChildDataExpr()) myTdb().getChildDataExpr()->fixup(0,getExpressionMode(),this, globSpace, globHeap, FALSE, glob); //maybe we can move the below few line to the init section od work methods?? UInt32 numAttrs = myTdb().getChildTuple()->numAttrs(); sourceFieldsConvIndex_ = (int *)((NAHeap *)heap_)->allocateAlignedHeapMemory((UInt32)(sizeof(int) * numAttrs), 512, FALSE); maxExtractRowLength_ = ROUND8(myTdb().getChildDataRowLen()) ; const ULng32 sqlBufferSize = maxExtractRowLength_ + ROUND8(sizeof(SqlBufferNormal)) + sizeof(tupp_descriptor) + 16 ;//just in case inSqlBuffer_ = (SqlBuffer *) new (heap_) char[sqlBufferSize]; inSqlBuffer_->driveInit(sqlBufferSize, TRUE, SqlBuffer::NORMAL_); childOutputTD_ = inSqlBuffer_->add_tuple_desc(maxExtractRowLength_); endOfData_ = FALSE; } // ExFastExtractTcb::ExFastExtractTcb
ExProbeCacheTcb::ExProbeCacheTcb(const ExProbeCacheTdb &probeCacheTdb, const ex_tcb &child_tcb, ex_globals * glob ) : ex_tcb( probeCacheTdb, 1, glob), childTcb_(NULL), workAtp_(NULL), probeBytes_(NULL), pool_(NULL), pcm_(NULL), workUpTask_(NULL) { Space * space = (glob ? glob->getSpace() : 0); CollHeap * heap = (glob ? glob->getDefaultHeap() : 0); qparent_.up = qparent_.down = NULL; childTcb_ = &child_tcb; // Allocate the buffer pool pool_ = new(space) ExSimpleSQLBuffer( probeCacheTdb.numInnerTuples_, probeCacheTdb.recLen_, space); // get the child queue pair qchild_ = child_tcb.getParentQueue(); // Allocate the queue to communicate with parent allocateParentQueues(qparent_); // Intialize nextRequest_ to the next request to process nextRequest_ = qparent_.down->getTailIndex(); // Allocate buffer for probeBytes_. probeBytes_ = new(space) char[ probeCacheTdb.probeLen_ ]; // allocate work atp and initialize the two tupps. workAtp_ = allocateAtp(probeCacheTdb.criDescUp_,getSpace()); probeHashTupp_.init(sizeof(probeHashVal_), NULL, (char *) (&probeHashVal_)); workAtp_->getTupp(probeCacheTdb.hashValIdx_) = &probeHashTupp_; hashProbeExpr()->fixup(0, getExpressionMode(), this, space, heap, glob->computeSpace(), glob); probeEncodeTupp_.init(probeCacheTdb.probeLen_, NULL, (char *) (probeBytes_)); workAtp_->getTupp(probeCacheTdb.encodedProbeDataIdx_) = &probeEncodeTupp_; encodeProbeExpr()->fixup(0, getExpressionMode(), this, space, heap, glob->computeSpace(), glob); if (moveInnerExpr()) moveInnerExpr()->fixup(0, getExpressionMode(), this, space, heap, glob->computeSpace(), glob); if (selectPred()) selectPred()->fixup(0, getExpressionMode(), this, space, heap, glob->computeSpace(), glob); pcm_ = new(space) ExPCMgr(space, probeCacheTdb.cacheSize_, probeCacheTdb.probeLen_, this); }