当前位置: 首页>>代码示例>>C++>>正文


C++ VNode::refreshAncestorSignature方法代码示例

本文整理汇总了C++中VNode::refreshAncestorSignature方法的典型用法代码示例。如果您正苦于以下问题:C++ VNode::refreshAncestorSignature方法的具体用法?C++ VNode::refreshAncestorSignature怎么用?C++ VNode::refreshAncestorSignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VNode的用法示例。


在下文中一共展示了VNode::refreshAncestorSignature方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: newEntry

//Replace the Entry(_enitty_id)'s EntityBitSet with _bitset
//Entry of _entity_id must exists    
bool 
VSTree::replaceEntry(int _entity_id, const EntityBitSet& _bitset)
{
    VNode* leafNodePtr = this->getLeafNodeByEntityID(_entity_id);

    if (leafNodePtr == NULL)
    {
        cerr << "error, can not find the mapping leaf node. @VSTree::replaceEntry" << endl;
        return false;
    }

    // find the mapping child entry, update it and refresh signature.
    int childNum = leafNodePtr->getChildNum();
    bool findFlag = false;
    for (int i = 0; i < childNum; i++)
    {
        const SigEntry& entry = leafNodePtr->getChildEntry(i);
        if (entry.getEntityId() == _entity_id)
        {
            SigEntry newEntry(EntitySig(_bitset), _entity_id);
            leafNodePtr->setChildEntry(i, newEntry);
            leafNodePtr->refreshAncestorSignature(*(this->node_buffer));
            findFlag = true;
            break;
        }
    }

    if (!findFlag)
    {
        cerr << "error, can not find the mapping child entry in the leaf node. @VSTree::replaceEntry" << endl;
        return false;
    }

    return true;
}
开发者ID:smilezcc,项目名称:gStore,代码行数:37,代码来源:VSTree.cpp

示例2: updateEntry

//Incrementally update bitset of _entity_id
//conduct OR operation on Entry(_entity_id)'s EntityBitSet with _bitset
//Entry of _entity_id must exists    
bool VSTree::updateEntry(int _entity_id, const EntityBitSet& _bitset)
{
    VNode* leafNodePtr = this->getLeafNodeByEntityID(_entity_id);

    if (leafNodePtr == NULL)
    {
        cerr << "error, can not find the mapping leaf node. @VSTree::updateEntry" << endl;
        return false;
    }

    // find the mapping child entry, update it and refresh signature.
    int childNum = leafNodePtr->getChildNum();
    bool findFlag = false;
    for (int i = 0; i < childNum; i++)
    {
        const SigEntry& entry = leafNodePtr->getChildEntry(i);

        if (entry.getEntityId() == _entity_id)
        {
            SigEntry newEntry = entry;
            newEntry |= SigEntry(EntitySig(_bitset), _entity_id);

            //debug
//            {
//                if (_entity_id == 10)
//                {
//                    stringstream _ss;
//                    _ss << "lead node line: " << leafNodePtr->getFileLine() << endl;
//                    _ss << "old entry:\n " << Signature::BitSet2str(entry.getEntitySig().entityBitSet) << endl;
//                    _ss << "new entry:\n " << Signature::BitSet2str(newEntry.getEntitySig().entityBitSet) << endl;
//                    Util::logging(_ss.str());
//                }
//            }

            leafNodePtr->setChildEntry(i, newEntry);
            leafNodePtr->refreshAncestorSignature(*(this->node_buffer));
            findFlag = true;

            break;
        }
    }

    if (!findFlag)
    {
        cerr<< "error, can not find the mapping child entry in the leaf node. @VSTree::updateEntry" << endl;
        return false;
    }

    return true;
}
开发者ID:smilezcc,项目名称:gStore,代码行数:53,代码来源:VSTree.cpp

示例3:

//remove an existed Entry(_entity_id) from VSTree 
bool 
VSTree::removeEntry(int _entity_id)
{
    VNode* leafNodePtr = this->getLeafNodeByEntityID(_entity_id);

    if (leafNodePtr == NULL)
    {
        cerr<< "error, can not find the mapping leaf node. @VSTree::removeEntry" << endl;
        return false;
    }

    // seek the entry index of the leaf node.
    int entryIndex = -1;
    int childNum = leafNodePtr->getChildNum();
    for (int i=0;i<childNum;i++)
    {
        if (leafNodePtr->getChildEntry(i).getEntityId() == _entity_id)
        {
            entryIndex = i;
            break;
        }
    }

    if (entryIndex == -1)
    {
        cerr << "error, can not find the entry in leaf node. @VSTree::removeEntry" << endl;
        return false;
    }

    // remove the entry in this leaf node and refresh itself and its ancestors' signature.
    leafNodePtr->removeChild(entryIndex);
    leafNodePtr->refreshAncestorSignature(*(this->node_buffer));
    this->entry_num --;

     //we do not consider the situation which the leaf node is to be empty by now...
	 //in a better way, if the leaf node is empty after removing entry, we should delete it. and recursively judge whether its
	 //father is empty, and delete its father node if true. to make the VSTree more balanced, we should combine two nodes if
	 //their child number are less than the MIN_CHILD_NUM. when deleting one node from the tree, we should also remove it from
	 //tree node file in hard disk by doing some operations on the node_buffer.

    return true;
}
开发者ID:smilezcc,项目名称:gStore,代码行数:43,代码来源:VSTree.cpp

示例4: refreshAncestorSignature

void VNode::refreshAncestorSignature(LRUCache& _nodeBuffer)
{
    // refresh self node's signature.
    this->refreshSignature();

    // refresh father node's signature.
    VNode* fatherNodePtr = this->getFather(_nodeBuffer);
    if (fatherNodePtr == NULL)
    {
        if (!this->isRoot())
            cerr << "error, can not find father node. @VNode::refreshSignature" << endl;
        return;
    }

    int rank = this->getIndexInFatherNode(_nodeBuffer);
    if (fatherNodePtr->getChildEntry(rank).getEntitySig() != this->entry.getEntitySig())
    {
        fatherNodePtr->setChildEntry(rank, this->entry);
        fatherNodePtr->refreshAncestorSignature(_nodeBuffer);
    }
}
开发者ID:ZhangXinboPKU,项目名称:gStore,代码行数:21,代码来源:VNode.cpp

示例5: sort


//.........这里部分代码省略.........

    		_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());
//        }

         //should keep the root node always being
         //at the first line(line zero) of the tree node file.
        this->swapNodeFileLine(RootNewPtr, oldNodePtr);
        this->height++;

        //debug
//        {
//            stringstream _ss;
//            _ss << "create new root:" << endl;
//            _ss << "two sons are: " << oldNodePtr->getFileLine() << " " << newNodePtr->getFileLine() << endl;
//            _ss << Signature::BitSet2str(oldNodePtr->getEntry().getEntitySig().entityBitSet) << endl;
//            _ss << RootNewPtr->to_str() << endl;
//            Util::logging(_ss.str());
//        }
    }
    else
    {
         //if the (OldNode) is not Root,
         //change the old node's signature to A's signature.
    	oldNodeFatherPtr->setChildEntry(oldNode_index, oldNodePtr->getEntry());


        if(oldNodeFatherPtr->isFull())
        {
        	oldNodeFatherPtr->refreshAncestorSignature(*(this->node_buffer));
            this->split(oldNodeFatherPtr, newNodePtr->getEntry(), newNodePtr);
        }
        else
        {
        	oldNodeFatherPtr->addChildNode(newNodePtr);
        	oldNodeFatherPtr->refreshAncestorSignature(*(this->node_buffer));
        }
    }

    //debug
//    if (!oldNodePtr->checkState())
//    {
//        stringstream _ss;
//        _ss << "node " << oldNodePtr->getFileLine() << " childFileLine error. oldNode when split" << endl;
//        Util::logging(_ss.str());
//    }
//    if (!newNodePtr->checkState())
//    {
//        stringstream _ss;
//        _ss << "node " << newNodePtr->getFileLine() << " childFileLine error. newNode when split" << endl;
//        Util::logging(_ss.str());
//    }

    // update the entityID2FileLineMap by these two nodes.
    this->updateEntityID2FileLineMap(oldNodePtr);
    this->updateEntityID2FileLineMap(newNodePtr);
}
开发者ID:smilezcc,项目名称:gStore,代码行数:101,代码来源:VSTree.cpp

示例6:

//remove an existed Entry(_entity_id) from VSTree 
bool 
VSTree::removeEntry(int _entity_id)
{
    VNode* leafNodePtr = this->getLeafNodeByEntityID(_entity_id);

    if (leafNodePtr == NULL)
    {
        cerr<< "error, can not find the mapping leaf node. @VSTree::removeEntry" << endl;
        return false;
    }

    // seek the entry index of the leaf node.
    int entryIndex = -1;
    int childNum = leafNodePtr->getChildNum();

	//cout<<"root file line: "<<this->root_file_line<<"   "<<"max nid num: "<<this->max_nid_alloc<<endl;
	//cout<<"node num: "<<this->node_num<<"   "<<"file line: "<<leafNodePtr->getFileLine()<<"   "<<"child num: "<<childNum<<endl;

    for(int i = 0; i < childNum; i++)
    {
        if(leafNodePtr->getChildEntry(i).getEntityId() == _entity_id)
        {
            entryIndex = i;
            break;
        }
    }

    if(entryIndex == -1)
    {
        cerr << "error, can not find the entry in leaf node. @VSTree::removeEntry" << endl;
        return false;
    }

	//BETTER?:consider up->bopttom to deal, not find leaf and recursively
	if(leafNodePtr->isRoot())
	{
		if(childNum == 1)
		{   //the tree is empty now
			leafNodePtr->removeChild(entryIndex);
			leafNodePtr->refreshAncestorSignature(*(this->node_buffer));
			this->removeNode(leafNodePtr);
			this->root_file_line = -1;
			this->height = 0;
			this->entry_num = 0;
			this->node_num = 0;
		}
		else
		{
			leafNodePtr->removeChild(entryIndex);
			leafNodePtr->refreshAncestorSignature(*(this->node_buffer));
		}
	}
	else
	{
		if(childNum <= VNode::MIN_CHILD_NUM)
		{
			//cerr << "In VSTree::remove() -- the node is invalid" << endl;
			//TODO+BETTER:this may search again, too costly
			//VNode* fatherNodePtr = leafNodePtr->getFather(*(this->node_buffer));
			////int index = leafNodePtr->getIndexInFatherNode(*(this->node_buffer));
			//int n = fatherNodePtr->getChildNum();
			//for (int i = 0; i < n; ++i)
			//{
				//if (fatherNodePtr->getChildFileLine(i) == leafNodePtr->getFileLine())
				//{
					//this->coalesce(fatherNodePtr, i, leafNodePtr, entryIndex);
					//break;
				//}
			//}
			//return false;
			this->coalesce(leafNodePtr, entryIndex);
		}
		else
		{
			leafNodePtr->removeChild(entryIndex);
			leafNodePtr->refreshAncestorSignature(*(this->node_buffer));
		}
	}


	this->entry_num--;
	this->entityID2FileLineMap.erase(_entity_id);

     //NOTICE:insert is costly but can keep balance.
	 //However, remove is not too costly but can not keep balance at all.
	 //And remove maybe error if without coalesce!
	 //If remove and insert are both wonderful, update/replace can both be balanced using delete and insert again.
	 //(not care the balance now, if insert/delete many times, rebuilding is suggested)

	 //we do not consider the situation which the leaf node is to be empty by now...
	 //in a better way, if the leaf node is empty after removing entry, we should delete it. and recursively judge whether its
	 //father is empty, and delete its father node if true. to make the VSTree more balanced, we should combine two nodes if
	 //their child number are less than the MIN_CHILD_NUM. when deleting one node from the tree, we should also remove it from
	 //tree node file in hard disk by doing some operations on the node_buffer.

    return true;
}
开发者ID:bnu05pp,项目名称:gStoreD,代码行数:98,代码来源:VSTree.cpp

示例7: split


//.........这里部分代码省略.........
//
//    		_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());
//        }

        /* should keep the root node always being
         * at the first line(line zero) of the tree node file.*/
        this->swapNodeFileLine(RootNewPtr, oldNodePtr);
        this->height ++;

        //debug
//        {
//            stringstream _ss;
//            _ss << "create new root:" << endl;
//            _ss << "two sons are: " << oldNodePtr->getFileLine() << " " << newNodePtr->getFileLine() << endl;
//            _ss << Signature::BitSet2str(oldNodePtr->getEntry().getEntitySig().entityBitSet) << endl;
//            _ss << RootNewPtr->to_str() << endl;
//            Util::logging(_ss.str());
//        }
    }
    else
    {
        /* if the (OldNode) is not Root,
         * change the old node's signature to A's signature.*/
    	oldNodeFatherPtr->setChildEntry(oldNode_index, oldNodePtr->getEntry());


        if (oldNodeFatherPtr->isFull())
        {
        	oldNodeFatherPtr->refreshAncestorSignature(*(this->node_buffer));
            this->split(oldNodeFatherPtr, newNodePtr->getEntry(), newNodePtr);
        }
        else
        {
        	oldNodeFatherPtr->addChildNode(newNodePtr);
        	oldNodeFatherPtr->refreshAncestorSignature(*(this->node_buffer));
        }
    }

    //debug
//    if (!oldNodePtr->checkState())
//    {
//        stringstream _ss;
//        _ss << "node " << oldNodePtr->getFileLine() << " childFileLine error. oldNode when split" << endl;
//        Util::logging(_ss.str());
//    }
//    if (!newNodePtr->checkState())
//    {
//        stringstream _ss;
//        _ss << "node " << newNodePtr->getFileLine() << " childFileLine error. newNode when split" << endl;
//        Util::logging(_ss.str());
//    }

    // update the entityID2FileLineMap by these two nodes.
    this->updateEntityID2FileLineMap(oldNodePtr);
    this->updateEntityID2FileLineMap(newNodePtr);
}
开发者ID:zhangxiaoyang,项目名称:gStore,代码行数:101,代码来源:VSTree.cpp


注:本文中的VNode::refreshAncestorSignature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。