bool checkCurrentStatus(GraphX* graph1, GraphX* graph2, vector<Set_Iterator* >& currentS, int* nodesOrder, tr1::unordered_map<int, int>& selectedQueryMap) { NodeX* dataGraphNode = graph2->getNodeWithID(*(currentS[currentS.size()-1]->it)); NodeX* queryGraphNode = graph1->getNodeWithID(nodesOrder[currentS.size()-1]); for(tr1::unordered_map<int, void*>::iterator iter = queryGraphNode->getEdgesIterator();iter!=queryGraphNode->getEdgesEndIterator();++iter) { int otherNodeID = iter->first; EdgeX* edge = (EdgeX*)(iter->second); if(selectedQueryMap.find(otherNodeID)==selectedQueryMap.end()) continue; //get the data node that the current data node should be connected with int dataNodeID = *(currentS[selectedQueryMap.find(otherNodeID)->second]->it); //check the current graph edges, whether it has a connection to dataNodeID or not if(!dataGraphNode->isItConnectedWithNodeID(dataNodeID, edge->getLabel())) { //cout<<"false"<<endl; return false; } } return true; }
string checkCache (string httpMsg) { string cacheItem; string cacheKey = ""; cacheKey.append (getReqType(httpMsg)); cacheKey.append (getUri(httpMsg)); cacheKey.append (getHost(httpMsg)); // Critical Section pthread_mutex_lock(&cacheLock); if (cacheMap.size() != 0) { try { tr1::unordered_map<string,string>::const_iterator got = cacheMap.find(cacheKey); if (got == cacheMap.end()) { cacheItem = ""; } else { cacheItem = got->second; } } catch (...) { cacheItem = ""; } } else { cacheItem = ""; } pthread_mutex_unlock(&cacheLock); return cacheItem; }
void insertIntoEdgeFreq(NodeX* src, int destNodeID, double destNodeLabel, double edgeLabel, tr1::unordered_map<string, void* >& edgeToFreq, bool addSrcOnly) { string key; if(src->getLabel()>destNodeLabel) { stringstream sstmGF; if(src->getLabel()==destNodeLabel) sstmGF << src->getLabel()<<destNodeLabel<<","<<edgeLabel<<","; else sstmGF << src->getLabel()<<","<<destNodeLabel<<","<<edgeLabel<<","; key = sstmGF.str(); } else { stringstream sstmGF; if(destNodeLabel==src->getLabel()) sstmGF <<destNodeLabel<<src->getLabel()<<","<<edgeLabel<<","; else sstmGF <<destNodeLabel<<","<<src->getLabel()<<","<<edgeLabel<<","; key = sstmGF.str(); } tr1::unordered_map<string, void* >::iterator iter = edgeToFreq.find(key); Pattern* pattern; if(iter==edgeToFreq.end()) { GraphX* graph = new GraphX(); NodeX* node1 = graph->AddNode(0, src->getLabel()); NodeX* node2 = graph->AddNode(1, destNodeLabel); graph->addEdge(node1, node2, edgeLabel); pattern = new Pattern(graph); delete graph; edgeToFreq[key] = pattern; } else { pattern = (Pattern*)((*iter).second); } if(pattern->getGraph()->getNodeWithID(0)->getLabel()==src->getLabel()) { pattern->addNode(src->getID(), 0); if(!addSrcOnly) pattern->addNode(destNodeID, 1); } else { pattern->addNode(src->getID(), 1); if(!addSrcOnly) pattern->addNode(destNodeID, 0); } }
/** * load a graph from the given string. string should follow the .lg format */ bool GraphX::loadFromString(string data, tr1::unordered_map<string, void* >& edgeToFreq) { CL.clear(); istringstream str(data); bool b = parseData(str, edgeToFreq); //destruct data in the 'edgeToFreq' structure for(tr1::unordered_map<string, void* >::iterator iter = edgeToFreq.begin();iter!=edgeToFreq.end();iter++) { delete ((Pattern*)iter->second); } edgeToFreq.clear(); if(!b) return false; return true; }
bool LBIDList::GetMinMax(int64_t *min, int64_t *max, int64_t *seq, int64_t lbid, const tr1::unordered_map<int64_t, BRM::EMEntry> &entries, execplan::CalpontSystemCatalog::ColDataType colDataType) { tr1::unordered_map<int64_t, BRM::EMEntry>::const_iterator it = entries.find(lbid); if (it == entries.end()) return false; const BRM::EMEntry &entry = it->second; if (entry.partition.cprange.isValid != BRM::CP_VALID) { MinMaxPartition *mmp; mmp = new MinMaxPartition(); mmp->lbid = lbid; mmp->lbidmax = lbid + (entry.range.size * 1024); mmp->seq = entry.partition.cprange.sequenceNum; if (isUnsigned(colDataType)) { mmp->max = 0; mmp->min = static_cast<int64_t>(numeric_limits<uint64_t>::max()); } else { mmp->max = numeric_limits<int64_t>::min(); mmp->min = numeric_limits<int64_t>::max(); } mmp->isValid = entry.partition.cprange.isValid; mmp->blksScanned = 0; lbidPartitionVector.push_back(mmp); return false; } *min = entry.partition.cprange.lo_val; *max = entry.partition.cprange.hi_val; *seq = entry.partition.cprange.sequenceNum; return true; }