コード例 #1
0
ファイル: main.cpp プロジェクト: huwdp/Chat-Client-and-Server
void handleLeaveMessage(char* inBuffer, int size, char** outBuffer, int *outSize)
{
    //Create a Leave message
    Leave *l = new Leave();
    //Decode leave message
    l->decode(inBuffer, size);
    //Search the users list for nickname
    bool deleted = false;

    pthread_mutex_lock(&userListMutex);
    for(vector<Join*>::iterator it = users.begin(); it != users.end(); ++it)
    {
        Join *user = *(it);
        //Remove nickname if it exists
        if (strcmp(l->getNickname(), user->getNickname()) == 0)
        {
            users.erase(it);
            deleted = true;
            break; //Erasing messes up iteration, so may as well just break out
        }
    }
    pthread_mutex_unlock(&userListMutex);

    //Create appropriate confirm message
    Confirm *c = new Confirm();
    c->setResponse(deleted);
    //Encode this message and return
    (*outSize)=c->encode(outBuffer);
    delete l;
    delete c;
}
コード例 #2
0
void showExample012()
{
    Join *j = new Join();
    Base *b = j;
    
    cout << j->method() << endl;
    cout << b << endl;
}
コード例 #3
0
// LCOV_EXCL_START 
// Used for other RelExpr but not MultiJoin
void MultiJoin::synthEstLogProp(const EstLogPropSharedPtr& inputEstLogProp)
{
  CMPASSERT(inputEstLogProp->getNodeSet());

  Join * preferredJoin = jbbSubset_.getPreferredJoin();
  
  CMPASSERT(preferredJoin->isJoinFromMJSynthLogProp());
  
  EstLogPropSharedPtr myEstLogProp = 
    preferredJoin->getGroupAttr()->outputLogProp(inputEstLogProp);
  
  getGroupAttr()->addInputOutputLogProp (inputEstLogProp, myEstLogProp, NULL);
} // MultiJoin::synthEstLogProp
コード例 #4
0
EstLogPropSharedPtr AppliedStatMan::synthesizeLogProp(
				const CANodeIdSet * nodeSet,
				EstLogPropSharedPtr &inLP)
{
  EstLogPropSharedPtr outputEstLogProp;
  CANodeIdSet combinedNodeSetWithInput = *nodeSet;

  if (inLP->isCacheable())
  {
    CANodeIdSet * inNodeSet = inLP->getNodeSet();

    // if inLP are cacheable these should have a nodeSet attached
    // if not, assert in debug mode. In release mode, set the properties
    // as not cacheable. These will then be looked into group attr cache
    if (inNodeSet == NULL)
    {
      CCMPASSERT(inNodeSet != NULL);
      inLP->setCacheableFlag(FALSE);
    }
    else
    {
      // check ASM cache for the estLogProps of nodeSet for the given
      // inLP

      combinedNodeSetWithInput.insert(*inNodeSet);
      if ((outputEstLogProp =\
        getCachedStatistics(&combinedNodeSetWithInput)) != NULL)
      return outputEstLogProp;
    }
  }

	if(nodeSet->entries() == 1)
    return getStatsForCANodeId(nodeSet->getFirst(), inLP);

  JBBSubset * jbbSubset = nodeSet->jbbcsToJBBSubset();

  Join * preferredJoin = jbbSubset->getPreferredJoin();

  //CMPASSERT(preferredJoin->isJoinFromMJSynthLogProp());

  outputEstLogProp = preferredJoin->getGroupAttr()->outputLogProp(inLP);

	return outputEstLogProp;
} // AppliedStatMan::synthesizeLogProp
コード例 #5
0
void MultiJoin::synthLogProp(NormWA * normWAPtr)
{
  // Check to see whether this GA has already been associated
  // with a logExpr for synthesis.  If so, no need to resynthesize
  // for this equivalent log. expression.
  if (getGroupAttr()->existsLogExprForSynthesis()) return;

  CMPASSERT ( (jbbSubset_.getGB() == NULL_CA_ID));

  const CANodeIdSet & jbbcs = jbbSubset_.getJBBCs();

  // Instead of always picking the first JBBC as the right child
  // pick the one with minimum JBBC connections. This will avoid
  // all unnecessary crossproducts

  CANodeId jbbcRight;

  jbbcRight = jbbcs.getJBBCwithMinConnectionsToThisJBBSubset();

  CANodeIdSet right(jbbcRight);
  CANodeIdSet left(jbbcs);
  left -= jbbcRight;

  Join* join = splitSubset(*(left.jbbcsToJBBSubset()),
                             *(right.jbbcsToJBBSubset()));

  join->synthLogProp(normWAPtr);

  getGroupAttr()->setLogExprForSynthesis(join);

  join->setJoinFromMJSynthLogProp();

  jbbSubset_.setSubsetMJ(this);
  
  CASortedList * synthLogPropPath =        
    new (CmpCommon::statementHeap()) 
    CASortedList(CmpCommon::statementHeap(), jbbcs.entries());
      
  synthLogPropPath->insert((*(left.jbbcsToJBBSubset()->getSynthLogPropPath())));
  synthLogPropPath->insert(right.getFirst());
  jbbSubset_.setSynthLogPropPath(synthLogPropPath);

  CMPASSERT ( getGroupAttr()->getNumJoinedTables() >= getArity());
}
コード例 #6
0
ファイル: main.cpp プロジェクト: huwdp/Chat-Client-and-Server
void handleNewMessage(char* inBuffer, int size, char** outBuffer, int *outSize)
{
    //Create a Chat Message
    ChatMessage *m = new ChatMessage();
    //Decode Chat Message
    m->decode(inBuffer, size);
    //Search the users list for nickname
    bool found = false;

    pthread_mutex_lock(&userListMutex);
    for(vector<Join*>::iterator it = users.begin(); it != users.end(); ++it)
    {
        Join *user = (*it);
        //Remove nickname if it exists
        if (strcmp(m->getSender(), user->getNickname()) == 0)
        {
            found = true;
        }
    }
    pthread_mutex_unlock(&userListMutex);

    //If the name exists add the name and message to the messages list
    if (found)
    {
        char* message = new char[strlen(m->getSender()) + 2 + strlen(m->getMessage()) + 1]; //sender + ": " + message + null
        sprintf(message, "%s: %s", m->getSender(), m->getMessage()); //easier than dealing with strcpy

        pthread_mutex_lock(&messageListMutex);
        messageList.push_back(message);
        pthread_mutex_unlock(&messageListMutex);
    }

    //Create appropriate confirm message
    Confirm *c = new Confirm();
    c->setResponse(found);
    //Encode this message and return
    (*outSize)=c->encode(outBuffer);

    delete m;
    delete c;
}
コード例 #7
0
void MultiJoin::synthLogPropWithMJReuse(NormWA * normWAPtr)
{
  // Check to see whether this GA has already been associated
  // with a logExpr for synthesis.  If so, no need to resynthesize
  // for this equivalent log. expression.
  if (getGroupAttr()->existsLogExprForSynthesis())
  {
    Join * joinExprForSynth = 
      (Join *) getGroupAttr()->getLogExprForSynthesis();
      
    if(joinExprForSynth->isJoinFromMJSynthLogProp())
      return;
  }

  NABoolean reUseMJ = TRUE;

  CMPASSERT ( (jbbSubset_.getGB() == NULL_CA_ID));

  const CANodeIdSet & jbbcs = jbbSubset_.getJBBCs();

  // Instead of always picking the first JBBC as the right child
  // pick the one with minimum JBBC connections. This will avoid
  // all unnecessary crossproducts

  CANodeId jbbcRight;

  jbbcRight = jbbcs.getJBBCwithMinConnectionsToThisJBBSubset();

  CANodeIdSet right(jbbcRight);
  CANodeIdSet left(jbbcs);
  left -= jbbcRight;

  Join* join = splitSubset(*(left.jbbcsToJBBSubset()),
                             *(right.jbbcsToJBBSubset()),
                           reUseMJ);

  //if the left is a MultiJoin, synthesize it using reUse
  //this has to be done before join->synthLogProp to avoid
  //calling MultiJoin::synthLogProp on the left MultiJoin
  //because that does not reUse
  if(left.entries() > 1)
  {
    RelExpr * leftRelExpr = join->child(0)->castToRelExpr();
    if(leftRelExpr &&
       leftRelExpr->getOperator() == REL_MULTI_JOIN)
      ((MultiJoin *) leftRelExpr)->synthLogPropWithMJReuse(normWAPtr);
  }

  join->synthLogProp(normWAPtr);

  join->setJoinFromMJSynthLogProp();

  getGroupAttr()->setLogExprForSynthesis(join);

  jbbSubset_.setSubsetMJ(this);

  CMPASSERT ( getGroupAttr()->getNumJoinedTables() >= getArity());
}
コード例 #8
0
ファイル: hall.cpp プロジェクト: wentao/chatty
bool HallAction::execute(const QString &input, QStringList* output) {
  QString head = Command::ParseHead(input);
  if (head == kActionRooms) {
    for (auto it : hall_->opens_) {
      *output << " * ";
      output->last().append(it.first);
      if (!it.second->pin().isEmpty()) {
        output->last().append(" (** pin required)");
      }
    }
  } else if (head == kActionCreate) {
    if (Hall::opens_.size() >= kMaxRoomCount) {
      *output << QString("Maximum room count reached: %1").arg(kMaxRoomCount);
    } else {
      Create* create = new Create;
      if (!create->execute(input, output)) {
        client_->registerProtocol(create);
      } else {
        delete create;
      }
    }
  } else if (head == kActionQuit) {
    emit client_->closeConnection();
    *output << "BYE!";
  } else if (head == kActionJoin) {
    Join* join = new Join(hall_, client_);
    if (!join->execute(input, output)) {
      client_->registerProtocol(join);
    } else {
      delete join;
    }
  } else {
    *output << actionList_;
  }
  return false;
}
コード例 #9
0
// get Stats after applying given join predicates on the JBBC
EstLogPropSharedPtr AppliedStatMan::getStatsForGivenJoinPredsOnJBBC(
		      const CANodeIdSet jbbSubset,
		      CANodeId jbbc,
		      const ValueIdSet joinPreds,
		      const ValueIdSet localPreds,
		      EstLogPropSharedPtr &inLP)
{
  EstLogPropSharedPtr inputLP = inLP;

  if(inputLP == (*GLOBAL_EMPTY_INPUT_LOGPROP))
    inputLP = jbbc.getJBBInput();

  EstLogPropSharedPtr outputEstLogProp;

  // form a Join expression with the given join predicates, and compute
  // output estimated logical properties. These properties should not be cached
  // in the ASM cache, hence set the "cacheable" flag to FALSE in inLP.
  // We do not want to modify the "cacheable" flag in the inLP, hence make a
  // copy of these logical properties.

  EstLogPropSharedPtr nonCacheableInLP(new (HISTHEAP) EstLogProp (*inputLP));
  nonCacheableInLP->setCacheableFlag(FALSE);

  Join * joinExpr = formJoinExprForJoinOnJBBC(jbbSubset,
						 jbbc,
                 &localPreds,
                 &joinPreds,
                 nonCacheableInLP,
                 FALSE);
                 
  
  // synthesize estimate logical properties for the join
  outputEstLogProp = joinExpr->getGroupAttr()->outputLogProp(nonCacheableInLP);

  return outputEstLogProp;
} // AppliedStatMan::getStatsForGivenJoinPreds
コード例 #10
0
// ------------------------------------------------------------------------
// Create a left linear subtree of joins from this MultiJoin
// ------------------------------------------------------------------------
Join* MultiJoin::leftLinearize(NABoolean fixJoinOrder, NABoolean createPriviledgedJoins) const
{
  // At this point assert that the subsets has no group by member.
  // If we want to allow GBs in this method in the future we should
  // remember to use computeJBBSubset() instead of the faster
  // jbbcsToJBBSubset() used currently in this method..
  CMPASSERT ( (jbbSubset_.getGB() == NULL_CA_ID));

  const CANodeIdSet & jbbcs = jbbSubset_.getJBBCs();
  // pick some child to make right child of join
  CANodeId jbbcRight(jbbcs.getFirst());

  CANodeIdSet right(jbbcRight);
  CANodeIdSet left(jbbcs);
  left -= jbbcRight;

  NABoolean nonExpander = (left.jbbcsToJBBSubset()->
    isGuaranteedNonExpandingJoin((*jbbcRight.getNodeAnalysis()->getJBBC())));

  Join* result = splitSubset(*(left.jbbcsToJBBSubset()),
                             *(right.jbbcsToJBBSubset()));

  if (fixJoinOrder)
  {
    // disallow left shift rule on the join
    result->contextInsensRules() += JoinLeftShiftRuleNumber;
    // disallow join commutativity on the join
    result->contextInsensRules() += JoinCommutativityRuleNumber;
  }

  if (createPriviledgedJoins)
  {
    result->setJoinFromPTRule();

    if ( CmpCommon::getDefault(COMP_BOOL_120) == DF_OFF)
    {
      result->updatePotential(-2);
    }
  }

  // If left subset is a multiJoin, then linearize it too.
  if (left.entries() > 1)
  {
    // left child must be multiJoin at this point. May be add assert.
    MultiJoin* leftChild = (MultiJoin*)(result->child(0).getPtr());
    result->child(0) = leftChild->leftLinearize(fixJoinOrder,createPriviledgedJoins);
  }

  return result;
} // MultiJoin::leftLinearize()
コード例 #11
0
ファイル: main.cpp プロジェクト: huwdp/Chat-Client-and-Server
void handleJoinMessage(char* inBuffer, int size, char** outBuffer, int *outSize)
{
    //Create a Join message
    Join *j = new Join();
    //Decode buffer into join message
    j->decode(inBuffer, size);
    printf("Nickname: %s\n", j->getNickname());
    //Search the users list for nickname
    //If the name exits do not add
    bool accept = true;
    pthread_mutex_lock(&userListMutex);
    for(vector<Join*>::iterator it = users.begin(); it != users.end(); ++it)
    {
        Join *user = *(it);
        if (strcmp(j->getNickname(), user->getNickname()) == 0)
        {
            //Exact match
            accept = false;
        }
    }
    pthread_mutex_unlock(&userListMutex);
    if (accept)
    {
        users.push_back(j);
    }
    else
    {
        delete j;
    }
    //Respond with confirm message
    Confirm *c = new Confirm();

    c->setResponse(accept);
    //Encode the message into the outbuffer and
    //Set the outsize
    (*outSize)=c->encode(outBuffer);
    delete c;
}
コード例 #12
0
// This method forms the join expression for join on JBBC specified by jbbcId
// inputEstLogProp should not be cacheable
Join * AppliedStatMan::formJoinExprForJoinOnJBBC(
          CANodeIdSet jbbSubset,
          CANodeId    jbbcId,
          const ValueIdSet * jbbcLocalPreds,
          const ValueIdSet * joinPreds,
          const EstLogPropSharedPtr& inputEstLogProp,
          const NABoolean cacheable)
{

  NABoolean origInputIsCacheable = inputEstLogProp->isCacheable();
  if(origInputIsCacheable)
  {
    inputEstLogProp->setCacheableFlag(FALSE);
    CCMPASSERT("Expecting Non Cacheable Input");
  }
  
  RelExpr * jbbcExpr = getExprForCANodeId(jbbcId, inputEstLogProp, jbbcLocalPreds);
  jbbcExpr->getGroupAttr()->outputLogProp(inputEstLogProp);
  RelExpr * jbbSubsetExpr = jbbSubset.jbbcsToJBBSubset()->getPreferredJoin();
  
  if(!jbbSubsetExpr)
    if(jbbSubset.entries()==1)
      if(!inputEstLogProp->isCacheable())
      {
        inputEstLogProp->setCacheableFlag(TRUE);
        jbbSubsetExpr = getExprForCANodeId(jbbSubset.getFirst(), inputEstLogProp);
        inputEstLogProp->setCacheableFlag(FALSE);
      }
      else
        jbbSubsetExpr = getExprForCANodeId(jbbSubset.getFirst(), inputEstLogProp);
    else
    {
      CCMPASSERT("No Subset expression, need at least one entry in set");
    }


  RelExpr * leftChildExpr = jbbSubsetExpr;
  RelExpr * rightChildExpr = jbbcExpr;
  
  GroupAttributes * galeft = jbbSubsetExpr->getGroupAttr();
  GroupAttributes * garight = jbbcExpr->getGroupAttr();
  
  // xxx

  JBBC * jbbc = jbbcId.getNodeAnalysis()->getJBBC();
  Join * jbbcParentJoin = jbbc->getOriginalParentJoin();
  ValueIdSet leftOuterJoinFilterPreds;


  Join * joinExpr = NULL;
  
  if(jbbcParentJoin)
  {
      if(jbbcParentJoin->isSemiJoin())
        joinExpr = new STMTHEAP Join(leftChildExpr, rightChildExpr, REL_SEMIJOIN, NULL);

      if(jbbcParentJoin->isAntiSemiJoin())
        joinExpr = new STMTHEAP Join(leftChildExpr, rightChildExpr, REL_ANTI_SEMIJOIN, NULL);

      if(jbbcParentJoin->isLeftJoin())
      {
        joinExpr = new STMTHEAP Join(leftChildExpr, rightChildExpr, REL_LEFT_JOIN, NULL);
        leftOuterJoinFilterPreds += jbbc->getLeftJoinFilterPreds();
      }

      if(joinExpr)
      {
        joinExpr->setJoinPred(jbbc->getPredsWithPredecessors());

        joinExpr->nullInstantiatedOutput().insert(jbbc->nullInstantiatedOutput());
      }
  }

  if(!joinExpr)
  {
    // now form a JoinExpr with these left and right children.
    joinExpr = new STMTHEAP Join(leftChildExpr, rightChildExpr, REL_JOIN, NULL);
  }

  ValueIdSet selPredsAndLOJFilter = leftOuterJoinFilterPreds;
  selPredsAndLOJFilter += (*joinPreds);
  joinExpr->setSelectionPredicates(selPredsAndLOJFilter);

  // set groupAttr of this Join expression
  GroupAttributes * gaJoin = new STMTHEAP GroupAttributes();

  // set required outputs of Join as sum of characteristic
  // outputs of the left and the right children
  ValueIdSet requiredOutputs;

  requiredOutputs.addSet(getPotentialOutputs(jbbSubset));

  requiredOutputs.addSet(getPotentialOutputs(jbbcId));

  gaJoin->setCharacteristicOutputs(requiredOutputs);

  // set JBBSubset for this group, if all estLogProps are cacheable.
  // Else JBBSubset is NULL

  CANodeIdSet combinedSet = jbbSubset;
  combinedSet += jbbcId;
  
  if (cacheable)
    gaJoin->getGroupAnalysis()->setLocalJBBView(combinedSet.jbbcsToJBBSubset());

  gaJoin->setMinChildEstRowCount(MINOF(garight->getMinChildEstRowCount(), galeft->getMinChildEstRowCount() ) );

  // if there are some probes coming into the join
  // then join type = tsj.
  if ((inputEstLogProp->getResultCardinality() > 1) ||
      (inputEstLogProp->getColStats().entries() > 1))
  {
    if (cacheable)
    {
      CANodeIdSet inputNodeSet =  *(inputEstLogProp->getNodeSet());
      gaJoin->setCharacteristicInputs(getPotentialOutputs(inputNodeSet));
    }
  }

  joinExpr->setGroupAttr(gaJoin);
  gaJoin->setLogExprForSynthesis(joinExpr);
  joinExpr->synthLogProp();
  inputEstLogProp->setCacheableFlag(origInputIsCacheable);
  return joinExpr;
} // AppliedStatMan::formJoinExprForJoinOnJBBC
コード例 #13
0
ファイル: QXMLLoad.cpp プロジェクト: unihd-cag/fsmdesigner
void QXMLLoad::parseFSM(QDomElement fsmElement) {

	// Preparation
	int loopcounter =0;

	// Get Core
	Core& c = *(Core::getInstance());

	// Add FSM to core
	//-----------------
	Fsm * fsm = c.getProject()->addFSM();



	//-- Generators parameters
	//--------------------------------------
	QList<QDomElement> toolsParameters = QXMLLoad::getChildElements("ToolsParameters",fsmElement);
	if (toolsParameters.size()>0) {

		//-- Get parameters for a user
		QList<QDomElement> userParameters = QXMLLoad::getChildElements("Parameters",toolsParameters.front());
		for (QList<QDomElement>::iterator it=userParameters.begin();it!=userParameters.end();it++) {

		    //---- Get user id
		    string userid = QXMLLoad::getAttributeValue("userid",*it);

		    //---- Get All parameters
		    QList<QDomElement> parameters = QXMLLoad::getChildElements("Parameter",*it);
		    for (QList<QDomElement>::iterator pit=parameters.begin();pit!=parameters.end();pit++) {

		        // Record
		        fsm->setParameter(userid,QXMLLoad::getAttributeValue("key",*pit),(*pit).text().toStdString());
		    }
		}
	}

	//-- Globals


	//-- Inputs
	QList<QDomElement> inputnames = QXMLLoad::getChildElements("name",QXMLLoad::getFirstMatchingChild("inputnames",fsmElement));
	loopcounter =0;
	for (QList<QDomElement>::iterator it=inputnames.begin();it!=inputnames.end();it++,loopcounter++) {
		fsm->addInput((*it).text().toStdString().c_str());
	}

	//-- Outputs
	QList<QDomElement> outputnames = QXMLLoad::getChildElements("name",QXMLLoad::getFirstMatchingChild("outputnames",fsmElement));
	loopcounter =0;
	for (QList<QDomElement>::iterator it=outputnames.begin();it!=outputnames.end();it++,loopcounter++) {
		fsm->addOutput((*it).text().toStdString().c_str());
	}

	//-- States
	QList<QDomElement> states = QXMLLoad::getChildElements("state",fsmElement);
	loopcounter =0;
	for (QList<QDomElement>::iterator it=states.begin();it!=states.end();it++,loopcounter++) {

		//-- Create State and set parameters
		State * currentState = new ::State(fsm->getNumberOfOutputs());
		currentState->setId(atoi(QXMLLoad::getAttributeValue("id",*it)));
		currentState->setName(QXMLLoad::getChildText("sname",*it));
		currentState->setOutput(QXMLLoad::getChildText("output",*it));
		currentState->setPosition(pair<double,double>(atof(QXMLLoad::getAttributeValue("posx",*it)),atof(QXMLLoad::getAttributeValue("posy",*it))));
		currentState->setColor(atoi(QXMLLoad::getAttributeValue("color",*it)));
		currentState->setReset(true);

		//string name = QXMLLoad::getChildText("sname",*it);

		//qDebug() << "State name: "<< QString::fromStdString(name) << "//" << QString::fromStdString(currentState->getName());

		fsm->addState(currentState);


	} // EO States --//



	//-- Links
	//----------------
	QList<QDomElement> links = QXMLLoad::getChildElements("link",fsmElement);
	loopcounter =0;
	for (QList<QDomElement>::iterator it=links.begin();it!=links.end();it++,loopcounter++) {

	    //-- Create
	    Link * link = new Link(fsm->getStatebyID(atoi(QXMLLoad::getAttributeValue("goal",*it))),atof(QXMLLoad::getAttributeValue("posx",*it)),
                atof(QXMLLoad::getAttributeValue("posy",*it)));
	    link->setId(atoi(QXMLLoad::getAttributeValue("id",*it)));

	    //-- Color
        link->setColor(atoi(QXMLLoad::getAttributeValue("color",*it)));

		//-- Add
	    fsm->addLink(link);



	}

	//-- Hypertrans
	//----------------
	QList<QDomElement> hypertrans = QXMLLoad::getChildElements("hypertrans",fsmElement);
	loopcounter =0;
	for (QList<QDomElement>::iterator it=hypertrans.begin();it!=hypertrans.end();it++,loopcounter++) {

	    //-- Create
	    Hypertrans * hyperTransition = new Hypertrans();
	    hyperTransition->setType(atoi(QXMLLoad::getChildText("type",*it).c_str()) == 0 ? Hypertrans::FromReset : Hypertrans::FromAllStates);
	    hyperTransition->setPosition(make_pair( atof(QXMLLoad::getAttributeValue("posx",*it)),atof(QXMLLoad::getAttributeValue("posy",*it))));
	    hyperTransition->setId(atoi(QXMLLoad::getAttributeValue("id",*it)));
	    hyperTransition->setTargetState(fsm->getStatebyID(atoi(QXMLLoad::getAttributeValue("targetState",*it))));
	    hyperTransition->setName(QXMLLoad::getChildText("name",*it));


		//-- Color
	    hyperTransition->setColor(atoi(QXMLLoad::getAttributeValue("color",*it)));

	    //-- Add
        Hypertrans * hypertrans =  fsm->addHypertrans(hyperTransition);

		//-- Conditions
		QList<QDomElement> conditions = QXMLLoad::getChildElements("condition",*it);
		int loopcounter2 =0;
		for (QList<QDomElement>::iterator it2=conditions.begin();it2!=conditions.end();it2++,loopcounter2++) {

			// add
		    Condition* condition = hypertrans->addCondition(fsm->getNumberOfInputs());
		    condition->setName(QXMLLoad::getChildText("cname",*it2));
		    condition->setInput(QXMLLoad::getChildText("input",*it2));

		} // EO Conditions --//

		//-- Trackpoints ?

	}


	//-- Joins
	//----------------
	QList<QDomElement> joins = QXMLLoad::getChildElements("Join",fsmElement);
	loopcounter =0;
	for (QList<QDomElement>::iterator it=joins.begin();it!=joins.end();it++,loopcounter++) {



		//-- Create
		Join * newJoin = new Join();

		//-- Id
		newJoin->setId(atoi(QXMLLoad::getAttributeValue("id",*it)));

		//-- Position
		newJoin->setPosx(atof(QXMLLoad::getAttributeValue("posx",*it)));
		newJoin->setPosy(atof(QXMLLoad::getAttributeValue("posy",*it)));

		//-- target State
		newJoin->setTargetState(fsm->getStatebyID(atoi(QXMLLoad::getAttributeValue("targetState",*it))));

		//-- Add join to FSM
        fsm->addJoin(newJoin);

		//---- Trackpoints
		//-----------------------
		QList<QDomElement> trackpoints = QXMLLoad::getChildElements("trackpoint",*it);
		int loopcounter2 =0;
		for (QList<QDomElement>::iterator it2=trackpoints.begin();it2!=trackpoints.end();it2++,loopcounter2++) {

			//-- Add
			Trackpoint * addedTrackpoint = newJoin->addTrackpoint();

			//-- Position
			addedTrackpoint->setPosition(make_pair((double)atof(QXMLLoad::getAttributeValue("posx",*it2)),(double)atof(QXMLLoad::getAttributeValue("posy",*it2))));

			//-- Link ?
			bool link = atoi(QXMLLoad::getAttributeValue("link",*it2))==1?true:false;
			addedTrackpoint->setTargetLink(fsm->getLinkbyID(atoi(QXMLLoad::getAttributeValue("linkid",*it2))));

			//-- Color
			addedTrackpoint->setColor(atoi(QXMLLoad::getAttributeValue("color",*it2)));

			//-- Hierarchy

		}

	}
	// EOF Joins



	//---- Transitions
    //--------------------
    QList<QDomElement> transitions = QXMLLoad::getChildElements("trans",fsmElement);
    loopcounter =0;
    for (QList<QDomElement>::iterator it=transitions.begin();it!=transitions.end();it++,loopcounter++) {

        //-- Create trans and set params
        //cout << "Trans: " <<atoi(QXMLLoad::getChildText("start",*it)) <<"->" <<atoi(QXMLLoad::getChildText("end",*it)) << ", Default: "<< (atoi(QXMLLoad::getChildText("default",*it))==1?true:false)  <<endl;

        //-- Get start and end
        State * start = fsm->getStatebyID(atoi(QXMLLoad::getChildText("start",*it).c_str()));
        State * end   = fsm->getStatebyID(atoi(QXMLLoad::getChildText("end",*it).c_str()));


        //-- Create
        Trans * addedTransition = new Trans(start,end);
        addedTransition->setId(atoi(QXMLLoad::getAttributeValue("id",*it)));

        //-- Text
        addedTransition->setName(string(QXMLLoad::getChildText("name",*it)));
        addedTransition->setTextPosition((double)atof(QXMLLoad::getAttributeValue("textposx",*it)),
                (double)atof(QXMLLoad::getAttributeValue("textposy",*it)));

        //-- Default
        addedTransition->setDefault((atoi(QXMLLoad::getChildText("default",*it).c_str())==1?true:false));

        //-- Add to FSM
        fsm->addTrans(addedTransition);

        //---- Manage trackpoints
        //---------------------------
        QList<QDomElement> trackpoints = QXMLLoad::getChildElements("trackpoint",*it);
        int loopcounter2 =0;
        for (QList<QDomElement>::iterator it2=trackpoints.begin();it2!=trackpoints.end();it2++,loopcounter2++) {

            //-- Add
            Trackpoint * addedTrackpoint = addedTransition->appendTrackpoint(
                    (double)atof(QXMLLoad::getAttributeValue("posx",*it2)),
                            (double)atof(QXMLLoad::getAttributeValue("posy",*it2)));

            //-- Link ?
            bool link = atoi(QXMLLoad::getAttributeValue("link",*it2))==1?true:false;
            if (link) {
                addedTrackpoint->setTargetLink(fsm->getLinkbyID(atoi(QXMLLoad::getAttributeValue("linkid",*it2))));
            }

            //-- Join
            int joinid = atoi(QXMLLoad::getAttributeValue("join",*it2));
            addedTrackpoint->setJoin(fsm->getJoin(joinid));

            //-- Color
            addedTrackpoint->setColor(atoi(QXMLLoad::getAttributeValue("color",*it2)));

        }


        //-- Conditions
        QList<QDomElement> conditions = QXMLLoad::getChildElements("condition",*it);
        loopcounter2 =0;
        for (QList<QDomElement>::iterator it2=conditions.begin();it2!=conditions.end();it2++,loopcounter2++) {

            // add
            Condition * condition = addedTransition->addCondition(fsm->getNumberOfInputs());
            condition->setName(QXMLLoad::getChildText("cname",*it2));
            condition->setInput(QXMLLoad::getChildText("input",*it2));

        } // EO Conditions --//


    } // EO Transitions --//


    //-- FSM attributes
    fsm->setName(QXMLLoad::getAttributeValue("fname",fsmElement));
    fsm->setResetState(atoi(QXMLLoad::getAttributeValue("resetstate",fsmElement)));

}
コード例 #14
0
ファイル: main.cpp プロジェクト: mitrais-cdc-cpp/CodeExamples
int main() {
    Join* test = new Join();
    test->foo();
    return 0;
}
コード例 #15
0
// LCOV_EXCL_START :cnu
EstLogPropSharedPtr AppliedStatMan::joinEstLogProps (
              const EstLogPropSharedPtr& leftEstLogProp,
              const EstLogPropSharedPtr& rightEstLogProp,
              const EstLogPropSharedPtr& inLP)
{
  EstLogPropSharedPtr outputEstLogProp;

  NABoolean cacheable = FALSE;

  CANodeIdSet * inputNodeSet = inLP->getNodeSet();

  // These nodesets could be NULL, if the estLogProps to which they
  // belong are not cacheable

  CANodeIdSet * leftNodeSet = leftEstLogProp->getNodeSet();
  CANodeIdSet * rightNodeSet = rightEstLogProp->getNodeSet();

  if ((leftEstLogProp->isCacheable()) &&
     (rightEstLogProp->isCacheable()) &&
     (inLP->isCacheable()) )
  {
    CCMPASSERT(leftNodeSet != NULL);
    CCMPASSERT(rightNodeSet != NULL);
    CCMPASSERT(inputNodeSet != NULL);
    if (leftNodeSet && rightNodeSet && inputNodeSet)
    {
      cacheable = TRUE;
    }
  }

  if (cacheable)
  {
    // check the ASM cache to see if outputEstLogProp for these
    // NodeSets appear for the given inputEstLogProp

    CANodeIdSet combineNodeSet = *leftNodeSet;
    combineNodeSet.insert(*rightNodeSet);

    CANodeIdSet combinedWithInputNodeSet = combineNodeSet;
    combinedWithInputNodeSet.insert(*inputNodeSet);

    outputEstLogProp = getCachedStatistics(&combinedWithInputNodeSet);
    if (outputEstLogProp != NULL)
      return outputEstLogProp;
  }

  JBBSubset * newJBBSubset = NULL;

  ValueIdSet setOfPredicates;

  if  (leftNodeSet && rightNodeSet)
  {
    // join predicates can be obtained from EstLogProp, only
    // if these corresponded to complete set of predicates -
    // all local or complete join. Also, we need a
    // combinedJBBSubset to set in the fake join expression
    // that we will be creating.

    newJBBSubset = leftNodeSet->computeJBBSubset();
    JBBSubset rightJBBSubset = *(rightNodeSet->computeJBBSubset());
    setOfPredicates = newJBBSubset->joinPredsWithOther(rightJBBSubset);

    // Since the properties from this group are cacheable, hence the
    // group attributes for the new join expression should contain
    // the combined JBBsubset of the left and the right children

    newJBBSubset->addSubset(rightJBBSubset);
  }

  // inputEstLogProp would be either empty input estLogProp or from the
  // outer child. If cacheable is TRUE, then newJBBsubset should
  // contain the combined left and the right JBB subset. But if
  // cacheable is FALSE, newJBBsubset should be NULL

  Join * joinExpr = formJoinExprWithEstLogProps(
				      leftEstLogProp,
				      rightEstLogProp,
				      inLP,
				      &setOfPredicates,
				      cacheable,
				      newJBBSubset);

  // Now do the actual synthesis and cache statistics in the cache

  outputEstLogProp = joinExpr->getGroupAttr()->outputLogProp(inLP);
  return outputEstLogProp;
}
コード例 #16
0
Join* MultiJoin::splitSubset(const JBBSubset & leftSet,
                             const JBBSubset & rightSet,
                             NABoolean reUseMJ) const
{
  // At this point assert that none of the subsets has a group by member
  CMPASSERT ( (jbbSubset_.getGB() == NULL_CA_ID) &&
              (leftSet.getGB() == NULL_CA_ID) &&
              (rightSet.getGB() == NULL_CA_ID) );
#ifndef NDEBUG
  // assert that left + right == subSet_
  // and left intersect right = phi

  CANodeIdSet unionSet(leftSet.getJBBCs());
  CANodeIdSet intersectSet(leftSet.getJBBCs());

  unionSet += rightSet.getJBBCs();
  intersectSet.intersectSet(rightSet.getJBBCs());

  CMPASSERT ( (unionSet == jbbSubset_.getJBBCs()) &&
              (intersectSet.entries() == 0 ));
#endif

  // Note: Joins including left, semi, anti semi are only created when
  // a single jbbc connected via one of them is split as a single right
  // child. InnerNonSemi joins can be created for any split i.e. any
  // number of jbbcs on the left and the right of the join, but special
  // joins (i.e. left, semi and anti semi joins) are only created when
  // there is a single right child i.e. the rightSet contains only one
  // jbbc that is connected via a special join. This is enforced as follows
  //
  // * The leftSet should be legal: This means that for every jbbc in the
  //   leftSet any predecessor jbbcs should be present in the leftSet.
  // * The rightSet is either a single jbbc or if the rightSet has more
  //   than one jbbc then it should be legal, note that a jbbc connected
  //   via a special join is not a legal set by itself but we allow
  //   creation of special joins assuming the predecessors are present
  //   in the leftSet.
  //
  // An implicit assumption here is that 'this' MultiJoin is legal, which
  // is fair since apart from the top level multijoin, rest of the multijoins
  // are produced by splitting the top level multijoin. This method should
  // not produce illegal multijoins, since we check both leftSet and rightSet
  // for legality. Only time we don't check for legality is when the rightChild
  // is a single jbbc, and a single jbbc does not result in a multijoin.

  if(!leftSet.legal())
    return NULL;

  if((rightSet.getJBBCs().entries() > 1) && (!rightSet.legal()))
    return NULL;

  // everything here goes to statement heap
  CollHeap* outHeap = CmpCommon::statementHeap();

  RelExpr* child0 = generateSubsetExpr(leftSet, reUseMJ);
  RelExpr* child1 = generateSubsetExpr(rightSet, reUseMJ);

  // Flag to remember to pass on the derivedFromRoutineJoin flag if needed.
  NABoolean derivedFromRoutineJoin(FALSE);

  // now form a JoinExpr with these left and right children.
  Join * result = NULL;

  // if the rightSet is a single jbbc, then it could be connected via
  // a special join. In such a case we have to create the appropriate
  // join operator
  if(rightSet.getJBBCs().entries() == 1){

    JBBC * rightChild = rightSet.getJBBCs().getFirst().getNodeAnalysis()
                         ->getJBBC();

    Join * rightChildParentJoin = rightChild->getOriginalParentJoin();

    // If rightChildParentJoin is NULL, then the child is the left
    // child of the left most join and is considered to be connected
    // via a InnerNonSemi join.
    if(rightChildParentJoin)
    {
      if(rightChildParentJoin->derivedFromRoutineJoin())
        derivedFromRoutineJoin = TRUE;

      if(rightChildParentJoin->isSemiJoin())
        result = new (outHeap) Join(child0, child1, REL_SEMIJOIN, NULL);

      if(rightChildParentJoin->isAntiSemiJoin())
        result = new (outHeap) Join(child0, child1, REL_ANTI_SEMIJOIN, NULL);

      if(rightChildParentJoin->isLeftJoin())
      {

        // left joins can have filter preds, i.e. predicates that
        // are applied as filters after applying the join predicate.
        // We need to set them here.
        result = new (outHeap) Join(child0, child1, REL_LEFT_JOIN, NULL);
        result->setSelectionPredicates(rightChild->getLeftJoinFilterPreds());
      }
      
      if(rightChildParentJoin->isRoutineJoin())
      {
        derivedFromRoutineJoin = TRUE;
        result = new (outHeap) Join(child0, child1, REL_ROUTINE_JOIN, NULL);
        ValueIdSet routineJoinFilterPreds = rightChild->getRoutineJoinFilterPreds();
        ValueIdSet predsToAddToRoutineJoin;
          
        // add covered filter preds
        for (ValueId filterPred= routineJoinFilterPreds.init();
             routineJoinFilterPreds.next(filterPred);
             routineJoinFilterPreds.advance(filterPred) )
        {
          if(jbbSubset_.coversExpr(filterPred))
            predsToAddToRoutineJoin += filterPred;
        } 
 
        result->setSelectionPredicates(predsToAddToRoutineJoin);
      }

      if(result)
      {
        // set the join predicate for special joins, note predicates
        // for regular InnerNonSemi joins are set as selection predicates
        // in the join relexpr.
        result->setJoinPred(rightChild->getPredsWithPredecessors());

        result->nullInstantiatedOutput().insert(rightChild->
                                                  nullInstantiatedOutput());
      }
    }
  }

  // The join to be created is a regular InnerNonSemi join
  if (!result)
    result = new (outHeap) Join(child0, child1, REL_JOIN, NULL);

  // Make sure we carry the derivedFromRoutineJoin flag with us 
  if (derivedFromRoutineJoin)
    result->setDerivedFromRoutineJoin();

  // Share my groupAttr with result
  result->setGroupAttr(getGroupAttr());

  // get inner join predicates
  ValueIdSet selPreds = rightSet.joinPredsWithOther(leftSet);

  // get left join filter preds if any
  selPreds += result->getSelectionPredicates();

  result->setSelectionPredicates(selPreds);

  result->findEquiJoinPredicates();

  // May be I could save a little if i pushdown only to the child(ren)
  // that are not already JBBCs, i.e. multijoins
  result->pushdownCoveredExpr
    (result->getGroupAttr()->getCharacteristicOutputs(),
     result->getGroupAttr()->getCharacteristicInputs(),
     result->selectionPred());

  // We used CutOp as children, to avoid pushing predicates to JBBCs.
  // Now put the actual expression back in case the child is a JBBCs
  if(leftSet.getJBBCs().entries() ==  1)
    result->setChild(0, getJBBCRelExpr(leftSet.getJBBCs().getFirst()));

  // We used CutOp as children, to avoid pushing predicates to JBBCs.
  // Now put the actual expression back in case the child is a JBBCs
  if(rightSet.getJBBCs().entries() ==  1)
    result->setChild(1, getJBBCRelExpr(rightSet.getJBBCs().getFirst()));

  // Temp fixup. We need to take the selectionPred out of MultiJoin
  // for now to prevent that pushed expr from being there. selectionPred
  // is not being used now in MultiJoin xxx.
  if (leftSet.getJBBCs().entries() > 1)
    result->child(0)->selectionPred().clear();
  if (rightSet.getJBBCs().entries() > 1)
    result->child(1)->selectionPred().clear();

  return result;
}
コード例 #17
0
void ChatClient::on_joinButton_clicked()
{
    Join *j;
    Confirm *c;
    INet4Address *servaddr;
    Connection *myConnection;
    char* buffer; //for encoded messages
    int bytesToSend;
    int bytesToReceive;
    int bytesReceived;

    //Get the strings out of the address, port and nickname
    //boxes and convert to strings;
    QString qip = ui.addresLine->text();
    QString qport = ui.portLine->text();
    QString qnick = ui.nicknameLine->text();

    //Create new connection objects
    servaddr = new INet4Address(qip.toLatin1().data(),qport.toInt());
    myConnection = new Connection(servaddr);

    //Connect to server

    if(myConnection->createSocket() < 0)
    {
        printf("Socket Error\n");
        return;
    }

    if(myConnection->connectSocket() < 0)
    {
        printf("Connect Error\n");
        delete(myConnection);
        delete(servaddr);
        return;
    }

    //Make a join message
    j = new Join();
    j->setNickname(qnick.toLatin1().data());

    //Send join message (as bytes)
    bytesToSend = j->encode(&buffer);

    printf("Buffer: %s, Nick: %s ",buffer, j->getNickname());

    myConnection->writeSize(bytesToSend);
    myConnection->writen(buffer,bytesToSend);

    delete(buffer);

    //Read response - take action!
    //Read byte count
    bytesToReceive = myConnection->readSize();
    buffer = new char[bytesToReceive];

    //Read message
    bytesReceived=myConnection->readn(buffer,bytesToReceive);

    if(bytesReceived < bytesToReceive)
        printf("Server response truncated!");

    //Convert to message (confirm)
    c = new Confirm();
    c->decode(buffer,bytesToReceive);
    //Destroy socket
    myConnection->closeSocket();

    //check if nick accepted
    if(c->getResponse()==true)
    {
        nickAccepted = true;
        ui.addresLine->setEnabled(false);
        ui.portLine->setEnabled(false);
        ui.nicknameLine->setEnabled(false);
        ui.joinButton->setEnabled(false);

        //Turn on the timer
        timer->start();
    }
    else
    {
        nickAccepted = false;
        ui.nicknameLine->setText(tr("Rejected!"));
    }


    delete myConnection;
    delete servaddr;
}
コード例 #18
0
// This method forms the join expression with the estLogProps.
Join * AppliedStatMan::formJoinExprWithEstLogProps(
					const EstLogPropSharedPtr& leftEstLogProp,
					const EstLogPropSharedPtr& rightEstLogProp,
					const EstLogPropSharedPtr& inputEstLogProp,
					const ValueIdSet * setOfPredicates,
					const NABoolean cacheable,
					JBBSubset * combinedJBBSubset)
{
  // Form a join expression with these estLogProps.

  // form the left child. Since the estLogProps of the left and the
  // right children exist, these can be treated as Scan expressions

  Scan * leftChildExpr = new STMTHEAP Scan();
  GroupAttributes * galeft = new STMTHEAP GroupAttributes();

  // set GroupAttr of the leftChild
  galeft->inputLogPropList().insert(inputEstLogProp);
  galeft->outputLogPropList().insert(leftEstLogProp);
  CANodeIdSet * leftNodeSet = leftEstLogProp->getNodeSet();

  CANodeId nodeId;

  if (leftNodeSet)
  {
    if (leftNodeSet->entries() == 1)
    {
      nodeId = leftNodeSet->getFirst();
      if(nodeId.getNodeAnalysis()->getTableAnalysis())
	leftChildExpr->setTableAttributes(nodeId);
    }
    CostScalar minEstCard = leftNodeSet->getMinChildEstRowCount();

    galeft->setMinChildEstRowCount(minEstCard);
  }

  leftChildExpr->setGroupAttr(galeft);
  galeft->setLogExprForSynthesis(leftChildExpr);

  // form the right child and set its groupAttr
  Scan * rightChildExpr = new STMTHEAP Scan();
  GroupAttributes * garight = new STMTHEAP GroupAttributes();
  garight->inputLogPropList().insert(inputEstLogProp);
  garight->outputLogPropList().insert(rightEstLogProp);
  CANodeIdSet * rightNodeSet = rightEstLogProp->getNodeSet();

  // xxx

  JBBC * singleRightChild = NULL;
  Join * singleRightChildParentJoin = NULL;
  ValueIdSet leftOuterJoinFilterPreds;


  if (rightNodeSet)
  {
    if (rightNodeSet->entries() == 1)
    {
      nodeId = rightNodeSet->getFirst();
      if(nodeId.getNodeAnalysis()->getTableAnalysis())
	rightChildExpr->setTableAttributes(nodeId);
	  if(nodeId.getNodeAnalysis()->getJBBC())
	  {
		  singleRightChild = nodeId.getNodeAnalysis()->getJBBC();
		  if(singleRightChild)
		    singleRightChildParentJoin = singleRightChild->getOriginalParentJoin();
	  }
    }
    CostScalar minEstCard = rightNodeSet->getMinChildEstRowCount();

    garight->setMinChildEstRowCount(minEstCard);
  }

  rightChildExpr->setGroupAttr(garight);
  garight->setLogExprForSynthesis(rightChildExpr);

  Join * joinExpr = NULL;
  if(singleRightChild &&
	 singleRightChildParentJoin)
  {
      if(singleRightChildParentJoin->isSemiJoin())
        joinExpr = new STMTHEAP Join(leftChildExpr,
                                     rightChildExpr,
                                     REL_SEMIJOIN,
                                     NULL);

      if(singleRightChildParentJoin->isAntiSemiJoin())
        joinExpr = new STMTHEAP Join(leftChildExpr,
                                     rightChildExpr,
                                     REL_ANTI_SEMIJOIN,
                                     NULL);

      if(singleRightChildParentJoin->isLeftJoin())
      {
        joinExpr = new STMTHEAP Join(leftChildExpr,
			                          rightChildExpr,
									  REL_LEFT_JOIN,
									  NULL);
        leftOuterJoinFilterPreds += singleRightChild->getLeftJoinFilterPreds();
      }

      if(joinExpr)
      {
        joinExpr->setJoinPred(singleRightChild->getPredsWithPredecessors());

        joinExpr->nullInstantiatedOutput().insert(singleRightChild->
                                                    nullInstantiatedOutput());
      }
  }

  if(!joinExpr)
  {
  // now form a JoinExpr with these left and right children.
  joinExpr = new STMTHEAP Join(leftChildExpr,  // left child
				      rightChildExpr, // right child
				      REL_JOIN,	      // join type
				      NULL);	      // join predicates
  }

  ValueIdSet selPredsAndLOJFilter = leftOuterJoinFilterPreds;
  selPredsAndLOJFilter += (*setOfPredicates);
  joinExpr->setSelectionPredicates(selPredsAndLOJFilter);

  // set groupAttr of this Join expression
  GroupAttributes * gaJoin = new STMTHEAP GroupAttributes();

  // set required outputs of Join as sum of characteristic
  // outputs of the left and the right children
  ValueIdSet requiredOutputs;

  if (leftNodeSet)
    requiredOutputs.addSet(getPotentialOutputs(*(leftNodeSet)));

  if (rightNodeSet)
    requiredOutputs.addSet(getPotentialOutputs(*(rightNodeSet)));

  gaJoin->setCharacteristicOutputs(requiredOutputs);

  // set JBBSubset for this group, if all estLogProps are cacheable.
  // Else JBBSubset is NULL

  if (cacheable)
    gaJoin->getGroupAnalysis()->setLocalJBBView(combinedJBBSubset);

  gaJoin->setMinChildEstRowCount(MINOF(garight->getMinChildEstRowCount(), galeft->getMinChildEstRowCount() ) );

  joinExpr->setGroupAttr(gaJoin);

  // if there are some probes coming into the join
  // then join type = tsj.
  if ((inputEstLogProp->getResultCardinality() > 1) ||
      (inputEstLogProp->getColStats().entries() > 1))
  {
    if (cacheable)
    {
      CANodeIdSet inputNodeSet =  *(inputEstLogProp->getNodeSet());
      gaJoin->setCharacteristicInputs(getPotentialOutputs(inputNodeSet));
    }
  }

  joinExpr->setGroupAttr(gaJoin);
  gaJoin->setLogExprForSynthesis(joinExpr);
  return joinExpr;

} // AppliedStatMan::formJoinExprWithEstLogProps
コード例 #19
0
Join* MultiJoin::createLeftLinearJoinTree
                   (const NAList<CANodeIdSet> * const leftDeepJoinSequence,
                    NAList<MJJoinDirective *> * joinDirectives) const
{
  Join* result = NULL;

  Join* currentJoin=NULL;

  NABoolean reUseMultiJoins = FALSE;

  //Set of all JBBCs in this multi-join.
  //This set will be broken up to make the join tree
  //representing the substitue.
  //The loop below will construct the join tree,
  //starting from the top join.
  CANodeIdSet childSet = getJBBSubset().getJBBCs();

  // variables used in loop below
  MultiJoin * currentMJoin = (MultiJoin *) this;

  // in an iteration this is the parent join
  // e.g. when we are create JOIN3, this will
  // be JOIN2
  Join * parentJoin = NULL;

#ifdef _DEBUG
  if ( CmpCommon::getDefault( NSK_DBG ) == DF_ON  &&
       CmpCommon::getDefault( NSK_DBG_MJRULES_TRACKING ) == DF_ON )
  {
// LCOV_EXCL_START - dpm
    CURRCONTEXT_OPTDEBUG->stream() << "Following is left deep join sequence: " << endl;
    CURRCONTEXT_OPTDEBUG->stream() << endl;
// LCOV_EXCL_STOP
  }
#endif

  UInt32 numJoinChildren = leftDeepJoinSequence->entries();

  CANodeId currentTable = NULL_CA_ID;

  for (UInt32 i = 0; i < (numJoinChildren-1); i++)
  {
    //create JBBSubset representing a comprising component of the
    //leftDeepJoinSequence.
    JBBSubset * joinRightChild = ((*leftDeepJoinSequence)[i]).computeJBBSubset();

    MJJoinDirective * joinDirective = (*joinDirectives)[i];

    //remove all tables that will become right side of join
    childSet.remove((*leftDeepJoinSequence)[i]);

#ifdef _DEBUG
    //print the right child of the current join
    if ( CmpCommon::getDefault( NSK_DBG ) == DF_ON  &&
       CmpCommon::getDefault( NSK_DBG_MJRULES_TRACKING ) == DF_ON )
    {
      CURRCONTEXT_OPTDEBUG->stream() << ((*leftDeepJoinSequence)[i]).getText() << endl; // LCOV_EXCL_LINE - dpm
    }
#endif
    //Get JBBSubset for left side of join
    JBBSubset * joinLeftChild = childSet.computeJBBSubset();

    //create the join by doing a split of the multi-join
    currentJoin = currentMJoin->splitSubset(*joinLeftChild, *joinRightChild, reUseMultiJoins);

    joinDirective->setupJoin(currentJoin);

    if ( CmpCommon::getDefault(COMP_BOOL_120) == DF_OFF)
      currentJoin->updatePotential(-3);

    // if this is the first iteration
    // set the result to be the top join
    if (i == 0)
      result = currentJoin;

    //set the current multi-join to the left child of the
    //join just created
    //change getChild to child().getPointer
    currentMJoin = (MultiJoin*) currentJoin->getChild(0);

    //if there was a parent join, set the left child to
    //point to the new join we just created i.e. currentJoin.
    if (parentJoin)
      parentJoin->setChild(0,currentJoin);

    //set currentJoin to be the parent for the next iteration
    parentJoin = currentJoin;

  }

#ifdef _DEBUG
  //print the left most child
  if ( CmpCommon::getDefault( NSK_DBG ) == DF_ON  &&
       CmpCommon::getDefault( NSK_DBG_MJRULES_TRACKING ) == DF_ON )
  {
// LCOV_EXCL_START  - dpm
    CURRCONTEXT_OPTDEBUG->stream() << ((*leftDeepJoinSequence)[(numJoinChildren-1)]).getText() << endl;
    CURRCONTEXT_OPTDEBUG->stream() << endl;
// LCOV_EXCL_STOP
  }
#endif

  // end - construct the join tree

  // synth the join
  result->synthLogProp();

  //if the right child of the top-most join is a multi-Join,
  //synthesize_it
  if(result->child(1))
    if(result->child(1)->getOperatorType()==REL_MULTI_JOIN)
      result->child(1)->synthLogProp();

  // synth the left child too
  result->child(0)->synthLogProp();

  return result;

} // MultiJoin::createLeftLinearJoinTree()