Example #1
0
//
// 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());

}
Example #2
0
ExCancelTcb::ExCancelTcb(const ExCancelTdb & cancel_tdb, ex_globals *glob) :
    ex_tcb(cancel_tdb, 1, glob)
  , step_(NOT_STARTED)
  , ioSubtask_(NULL)
  , cbServer_(NULL)
  , cancelStream_(NULL)
  , cpu_ (-1)
  , pid_ (-1)
  , retryQidNotActive_(false)
  , retryCount_(0)
{
  nodeName_[0] = '\0';

  allocateParentQueues(qparent_,
                       FALSE );     // don't alloc pstate.

  retryQidNotActive_ = (getenv("SQLMX_REGRESS") != NULL);
}
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);

}