本文整理汇总了C++中Join类的典型用法代码示例。如果您正苦于以下问题:C++ Join类的具体用法?C++ Join怎么用?C++ Join使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Join类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleLeaveMessage
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: showExample012
void showExample012()
{
Join *j = new Join();
Base *b = j;
cout << j->method() << endl;
cout << b << endl;
}
示例3: CMPASSERT
// 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: CCMPASSERT
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: handleNewMessage
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;
}
示例6: getGroupAttr
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());
}
示例7: if
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;
}
示例8: nonCacheableInLP
// 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
示例9: handleJoinMessage
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;
}
示例10: Link
//.........这里部分代码省略.........
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))));
示例11: main
int main() {
Join* test = new Join();
test->foo();
return 0;
}
示例12: INet4Address
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;
}
示例13: Scan
// 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();
}
//.........这里部分代码省略.........
示例14: getJBBSubset
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
}
//.........这里部分代码省略.........