本文整理汇总了C++中VNode::getChildFileLine方法的典型用法代码示例。如果您正苦于以下问题:C++ VNode::getChildFileLine方法的具体用法?C++ VNode::getChildFileLine怎么用?C++ VNode::getChildFileLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VNode
的用法示例。
在下文中一共展示了VNode::getChildFileLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: to_str
std::string VSTree::to_str()
{
//debug
{
stringstream _ss;
_ss << "after build tree, root is:" << endl;
_ss << this->getRoot()->to_str() << endl;
Util::logging(_ss.str());
}
std::stringstream _ss;
std::queue<int> nodeFileLineQueue;
nodeFileLineQueue.push(this->getRoot()->getFileLine());
while(! nodeFileLineQueue.empty())
{
int currentNodeFileLine = nodeFileLineQueue.front();
nodeFileLineQueue.pop();
VNode* currentNodePtr = this->getNode(currentNodeFileLine);
_ss << currentNodePtr->to_str();
int childNum = currentNodePtr->getChildNum();
for(int i = 0; i < childNum; i ++)
{
if(! currentNodePtr->isLeaf())
{
int childNodeFileLine = currentNodePtr->getChildFileLine(i);
nodeFileLineQueue.push(childNodeFileLine);
}
}
}
return _ss.str();
}
示例2: getIndexInFatherNode
int VNode::getIndexInFatherNode(LRUCache& _nodeBuffer)
{
VNode * fatherNodePtr = this->getFather(_nodeBuffer);
if (fatherNodePtr == NULL)
{
return 0;
}
int n = fatherNodePtr->getChildNum();
for (int i=0;i<n;i++)
{
if (fatherNodePtr->getChildFileLine(i) == this->self_file_line)
{
return i;
}
}
cerr << "error, can not find rank in father node. @VNode::getRankFatherNode" << endl;
return 0;
}
示例3: sort
//.........这里部分代码省略.........
VNode* childPtr = oldNodePtr->getChild(entryIndex_nearB[i], *(this->node_buffer));
newNodePtr->addChildNode(childPtr);
}
}
newNodePtr->refreshSignature();
//label the child being removed with -1,
//and update the old node's entry.
sort(entryIndex_nearA.begin(), entryIndex_nearA.end(), less<int>());
#ifdef DEBUG_VSTREE
stringstream _ss1;
{
_ss1 << "nearA: ";
for(unsigned i = 0; i < entryIndex_nearA.size(); i++)
{
_ss1 << entryIndex_nearA[i] << " ";
}
_ss1 << endl;
_ss1 << "nearB: ";
for(unsigned i = 0; i < entryIndex_nearB.size(); i++)
{
_ss1 << entryIndex_nearB[i] << " ";
}
_ss1 << endl;
}
Util::logging(_ss1.str());
#endif
for(unsigned i = 0; i < entryIndex_nearA.size(); i++)
{
oldNodePtr->setChildEntry(i, oldNodePtr->getChildEntry(entryIndex_nearA[i]));
oldNodePtr->setChildFileLine(i, oldNodePtr->getChildFileLine(entryIndex_nearA[i]));
}
oldNodePtr->setChildNum(entryIndex_nearA.size());
oldNodePtr->refreshSignature();
int oldNode_index = oldNodePtr->getIndexInFatherNode(*(this->node_buffer));
// full node's father pointer.
VNode* oldNodeFatherPtr = oldNodePtr->getFather(*(this->node_buffer));
if(oldNodePtr->isRoot())
{
//if the old node is root,
//split the root, create a new root,
//and the tree height will be increased.
VNode* RootNewPtr = this->createNode();
//change the old root node to not-root node,
//and set the RootNew to root node.
oldNodePtr->setAsRoot(false);
RootNewPtr->setAsRoot(true);
//set the split two node(old node and new node) as the new root's child,
//and update signatures.
RootNewPtr->addChildNode(oldNodePtr);
RootNewPtr->addChildNode(newNodePtr);
RootNewPtr->refreshSignature();
//debug
// {
// stringstream _ss;
// _ss << "create new root:" << endl;
// _ss << "before swap file line, two sons are: " << oldNodePtr->getFileLine() << " " << newNodePtr->getFileLine() << endl;
// Util::logging(_ss.str());
// }
示例4: filterSig
//retrieve the candidate entity ID which signature can cover the _entity_bit_set, and add them to the _p_id_list.
void
VSTree::retrieveEntity(const EntityBitSet& _entity_bit_set, IDList* _p_id_list)
{
Util::logging("IN retrieveEntity");
EntitySig filterSig(_entity_bit_set);
#ifdef DEBUG_VSTREE
cerr << "the filter signature: " << filterSig.to_str() << endl;
#endif
queue<int> nodeQueue; //searching node file line queue.
//debug
{
stringstream _ss;
_ss << "filterSig=" << Signature::BitSet2str(filterSig.entityBitSet) << endl;
Util::logging(_ss.str());
}
const SigEntry& root_entry = (this->getRoot())->getEntry();
Util::logging("Get Root Entry");
if(root_entry.cover(filterSig))
{
nodeQueue.push(this->getRoot()->getFileLine());
Util::logging("root cover the filter_sig");
}
else
{
Util::logging("warning: root is not cover the filter_sig");
}
//debug
// {
// Util::logging(this->getRoot()->to_str());
// Util::logging("Before BFS");
// }
//using BFS algorithm to traverse the VSTree and retrieve the entry.
while (!nodeQueue.empty())
{
int currentNodeFileLine = nodeQueue.front();
nodeQueue.pop();
VNode* currentNodePtr = this->getNode(currentNodeFileLine);
int childNum = currentNodePtr->getChildNum();
//debug
// {
// std::stringstream _ss;
// _ss << "childNum of ["
// << currentNodePtr->getFileLine()
// << "] is " << childNum << endl;
//
// for (int i=0;i<childNum;i++)
// {
// _ss << currentNodePtr->getChildFileLine(i) << " ";
// }
// _ss << endl;
//
// Util::logging(_ss.str());
// }
int valid = 0;
for (int i = 0; i < childNum; i++)
{
const SigEntry& entry = currentNodePtr->getChildEntry(i);
#ifdef DEBUG_VSTREE
//cerr << "current entry: " << entry.to_str() << endl;
#endif
if (entry.cover(filterSig))
{
valid++;
if (currentNodePtr->isLeaf())
{
// if leaf node, add the satisfying entries' entity id to result list.
_p_id_list->addID(entry.getEntityId());
//debug
// {
// stringstream _ss;
// _ss << "child_" << i << " cover filter sig" << endl;
// _ss << Signature::BitSet2str(entry.getEntitySig().entityBitSet)<< endl;
// Util::logging(_ss.str());
// }
}
else
{
// if non-leaf node, add the child node pointer to the searching queue.
//VNode* childPtr = currentNodePtr->getChild(i, *(this->node_buffer));
// if non-leaf node, add the child node file line to the searching queue.
int childNodeFileLine = currentNodePtr->getChildFileLine(i);
nodeQueue.push(childNodeFileLine);
//debug
// {
// stringstream _ss;
// _ss << "child[" << childPtr->getFileLine() << "] cover filter sig" << endl;
// Util::logging(_ss.str());
//.........这里部分代码省略.........
示例5: if
//the _entry_index in _child is to be removed.
//node can only be deleted in this function.
void
VSTree::coalesce(VNode* _child, int _entry_index)
{
#ifdef DEBUG
cout << "coalesce happen" <<endl;
#endif
//found the father and index
VNode* _father = _child->getFather(*(this->node_buffer));
int cn = _child->getChildNum();
if(_father == NULL) //this is already root
{
//NOTICE:when root is leaf, at least one key, otherwise the tree is empty
//But when root is internal, at least two key, if one key then shrink
//(1-key internal root is not permitted)
//
//Notice that leaf-root case has been discussed in upper function removeEntry()
//so here the root must be internal node
_child->removeChild(_entry_index);
if(cn == 2)
{
//only one key after remove, shrink root
VNode* newRoot = _child->getChild(0, *(this->node_buffer));
newRoot->setAsRoot(true);
cout<<"shrink root in coalesce() -- to swap node file"<<endl;
this->swapNodeFileLine(newRoot, _child);
this->root_file_line = newRoot->getFileLine();
this->height--;
this->removeNode(_child);
}
return;
}
if(cn > VNode::MIN_CHILD_NUM)
{
cout<<"no need to move or union in coalesce()"<<endl;
_child->removeChild(_entry_index);
_child->refreshAncestorSignature(*(this->node_buffer));
return;
}
int fn = _father->getChildNum();
int i, _child_index = -1;
for (i = 0; i < fn; ++i)
{
if (_father->getChildFileLine(i) == _child->getFileLine())
{
break;
}
}
if(i == fn)
{
cerr << "not found the leaf node in VSTree::coalesce()" << endl;
return;
}
else
{
_child_index = i;
}
//_child->removeChild(_entry_index);
//_child->setChildNum(cn);
//NOTICE:we do not consider the efficiency here, so just ensure the operation is right
//BETTER:find good way to ensure signatures are separated(maybe similar ones together)
int ccase = 0;
VNode* p = NULL;
int n = 0;
if(_child_index < fn - 1)
{
p = _father->getChild(_child_index+1, *(this->node_buffer));
n = p->getChildNum();
if(n > VNode::MIN_CHILD_NUM)
{
ccase = 2;
}
else
{
ccase = 1;
}
}
if(_child_index > 0)
{
VNode* tp = _father->getChild(_child_index-1, *(this->node_buffer));
int tn = tp->getChildNum();
if(ccase < 2)
{
if(ccase == 0)
ccase = 3;
if(tn > VNode::MIN_CHILD_NUM)
ccase = 4;
}
if(ccase > 2)
{
//.........这里部分代码省略.........
示例6: split
//.........这里部分代码省略.........
newNodePtr->addChildNode(childPtr);
}
}
newNodePtr->refreshSignature();
/* label the child being removed with -1,
* and update the old node's entry.*/
std::sort(entryIndex_nearA.begin(), entryIndex_nearA.end(), less<int>());
//debug
// {
// stringstream _ss;
// {
// _ss << "nearA: ";
// for(int i = 0; i < entryIndex_nearA.size(); i ++)
// {
// _ss << entryIndex_nearA[i] << " ";
// }
// _ss << endl;
//
// _ss << "nearB: ";
// for(int i = 0; i < entryIndex_nearB.size(); i ++)
// {
// _ss << entryIndex_nearB[i] << " ";
// }
// _ss << endl;
// }
// Util::logging(_ss.str());
// }
for (unsigned i=0;i<entryIndex_nearA.size();i++)
{
oldNodePtr->setChildEntry(i, oldNodePtr->getChildEntry(entryIndex_nearA[i]));
oldNodePtr->setChildFileLine(i, oldNodePtr->getChildFileLine(entryIndex_nearA[i]));
}
oldNodePtr->setChildNum(entryIndex_nearA.size());
oldNodePtr->refreshSignature();
int oldNode_index = oldNodePtr->getIndexInFatherNode(*(this->node_buffer));
// full node's father pointer.
VNode* oldNodeFatherPtr = oldNodePtr->getFather(*(this->node_buffer));
if (oldNodePtr->isRoot())
{
/* if the old node is root,
* split the root, create a new root,
* and the tree height will be increased.*/
VNode* RootNewPtr = this->createNode();
/* change the old root node to not-root node,
* and set the RootNew to root node.*/
oldNodePtr->setAsRoot(false);
RootNewPtr->setAsRoot(true);
/* set the split two node(old node and new node) as the new root's child,
* and update signatures.*/
RootNewPtr->addChildNode(oldNodePtr);
RootNewPtr->addChildNode(newNodePtr);
RootNewPtr->refreshSignature();
//debug
// {
// stringstream _ss;
// _ss << "create new root:" << endl;
// _ss << "before swap file line, two sons are: " << oldNodePtr->getFileLine() << " " << newNodePtr->getFileLine() << endl;
// Util::logging(_ss.str());
// }