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


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

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


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

void 
VSTree::split(VNode* _p_node_being_split, const SigEntry& _insert_entry, VNode* _p_insert_node)
{
#ifdef DEBUG_VSTREE
		stringstream _ss;
		_ss << "**********************split happen at "
			<< _p_node_being_split->getFileLine() << endl;
		_ss << _p_node_being_split->to_str() << endl;
		Util::logging(_ss.str());
#endif
    // first, add the new child node(if not leaf) or child entry(if leaf) to the full node.
	bool just_insert_entry = (_p_insert_node == NULL);
    if(just_insert_entry)
    {
        _p_node_being_split->addChildEntry(_insert_entry, true);
    }
    else
    {
        _p_node_being_split->addChildNode(_p_insert_node, true);
    }

    SigEntry entryA, entryB;

	//BETTER: use hanming, xor result or the vector included angle to guess the distince.
	//And then also use the farest two as seeds.
	//
     //two seeds to generate two new nodes.
	 //seedA kernel: the SigEntry with the minimal count of signature.
	 //seedB kernel: the SigEntry with the maximal count of signature.
     

    int maxCount = 0; // record the minimal signature count.
    int entryA_index = 0; // record the seedA kernel index.
    for(int i = 0; i < VNode::MAX_CHILD_NUM; i++)
    {
        int currentCount = (int) _p_node_being_split->getChildEntry(i).getSigCount();
        if(maxCount < currentCount)
        {
            maxCount = currentCount;
            entryA_index = i;
        }
    }
    entryA = _p_node_being_split->getChildEntry(entryA_index);

	maxCount = 0;
    int entryB_index = 0; // record the seedB kernel index.
    for(int i = 0; i < VNode::MAX_CHILD_NUM; i++)
    {
		//NOTICE:I think xOR should be used here to choose the farest two
		int currentCount = entryA.xOR(_p_node_being_split->getChildEntry(i));
		//int currentCount = entryA.xEpsilen(_p_node_being_split->getChildEntry(i));
        if(i != entryA_index && maxCount <= currentCount)
        {
            maxCount = currentCount;
            entryB_index = i;
        }
    }
    entryB = _p_node_being_split->getChildEntry(entryB_index);

    // AEntryIndex: the entry index near seedA.
    // BEntryIndex: the entry index near seedB.
    std::vector<int> entryIndex_nearA, entryIndex_nearB;
    entryIndex_nearA.clear();
    entryIndex_nearB.clear();
    entryIndex_nearA.push_back(entryA_index);
    entryIndex_nearB.push_back(entryB_index);

    int nearA_max_size, nearB_max_size;
    bool nearA_tooSmall, nearB_tooSmall;

    for(int i = 0; i < VNode::MAX_CHILD_NUM; i++)
    {
        if(i == entryA_index || i == entryB_index) continue;

		//should guarantee that each new node has at least MIN_CHILD_NUM children. 
        nearA_max_size = VNode::MAX_CHILD_NUM - entryIndex_nearB.size();
        nearA_tooSmall = (nearA_max_size <= VNode::MIN_CHILD_NUM);

        if(nearA_tooSmall)
        {
            for(; i < VNode::MAX_CHILD_NUM; i++)
            {
                if (i == entryA_index || i == entryB_index) continue;
                entryIndex_nearA.push_back(i);
            }
            break;
        }

        nearB_max_size = VNode::MAX_CHILD_NUM - entryIndex_nearA.size();
        nearB_tooSmall = (nearB_max_size <= VNode::MIN_CHILD_NUM);
        if(nearB_tooSmall)
        {
            for(; i < VNode::MAX_CHILD_NUM; i++)
            {
                if(i == entryA_index || i == entryB_index) continue;
                entryIndex_nearB.push_back(i);
            }
            break;
        }

//.........这里部分代码省略.........
开发者ID:smilezcc,项目名称:gStore,代码行数:101,代码来源:VSTree.cpp

示例6: 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());
//.........这里部分代码省略.........
开发者ID:smilezcc,项目名称:gStore,代码行数:101,代码来源:VSTree.cpp

示例7: if


//.........这里部分代码省略.........
				ccase = 4;
		}
		if(ccase > 2)
		{
			p = tp;
			n = tn;
		}
	}

	VNode* tmp = NULL;
	int child_no = _child->getFileLine();
	int father_no = _father->getFileLine();

#ifdef DEBUG
	if(ccase == 1 || ccase == 3)
	{
		cout << "union happened" << endl;
	}
	else if(ccase == 2 || ccase == 4)
	{
		cout << "move happened" << endl;
	}
	cout<< "father num: "<<fn<<"   child num: "<<cn<<"   neighbor num: "<<n<<endl;
	cout<<"child file line "<<child_no<<endl;
	cout<<"neighbor file line "<<p->getFileLine()<<endl;
#endif

	switch(ccase)
	{
	case 1:    //union right to this
		if(_child->isLeaf())
		{
			_child->setChildFileLine(_entry_index, p->getChildFileLine(0));
			_child->setChildEntry(_entry_index, p->getChildEntry(0));
			for(int i = 1; i < n; ++i)
			{
				_child->setChildFileLine(cn+i-1, p->getChildFileLine(i));
				_child->addChildEntry(p->getChildEntry(i));
			}
		}
		else
		{
			_child->setChildFileLine(_entry_index, p->getChildFileLine(0));
			_child->setChildEntry(_entry_index, p->getChildEntry(0));
			tmp = p->getChild(0, *(this->node_buffer));
			tmp->setFatherFileLine(child_no);
			for(int i = 1; i < n; ++i)
			{
				tmp = p->getChild(i, *(this->node_buffer));
				//cout<<i<<"   "<<_child->getChildNum()<<endl;
				_child->addChildNode(tmp);
				//_child->setChildNum(cn+i);
				//tmp->setFatherFileLine(child_no);
			}
		}
		this->removeNode(p);
		_child->refreshSignature();
		//recursive:to remove child index+1 in father
		this->coalesce(_father, _child_index+1);
		break;

	case 2:    //move one from right
		_child->setChildFileLine(_entry_index, p->getChildFileLine(n-1));
		_child->setChildEntry(_entry_index, p->getChildEntry(n-1));
		_child->refreshSignature();
		if(!_child->isLeaf())
开发者ID:bnu05pp,项目名称:gStoreD,代码行数:67,代码来源:VSTree.cpp

示例8:

//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

示例9: split

void VSTree::split(VNode* _p_node_being_split, const SigEntry& _insert_entry, VNode* _p_insert_node)
{
    //debug
//	{
//		stringstream _ss;
//		_ss << "**********************split happen at "
//			<< _p_node_being_split->getFileLine() << endl;
//		_ss << _p_node_being_split->to_str() << endl;
//		Util::logging(_ss.str());
//	}
    // first, add the new child node(if not leaf) or child entry(if leaf) to the full node.
	bool just_insert_entry = (_p_insert_node == NULL);
    if (just_insert_entry)
    {
        _p_node_being_split->addChildEntry(_insert_entry, true);
    }
    else
    {
        _p_node_being_split->addChildNode(_p_insert_node, true);
    }

    SigEntry entryA, entryB;
    /* two seeds to generate two new nodes.
     * seedA kernel: the SigEntry with the minimal count of signature.
     * seedB kernel: the SigEntry with the second minimal count of signature.
     * */

    int minCount = 0; // record the minimal signature count.
    int entryA_index = 0; // record the seedA kernel index.
    for (int i=0;i<VNode::MAX_CHILD_NUM;i++)
    {
        int currentCount = (int) _p_node_being_split->getChildEntry(i).getSigCount();
        if (minCount < currentCount)
        {
            minCount = currentCount;
            entryA_index = i;
        }
    }
    entryA = _p_node_being_split->getChildEntry(entryA_index);

    minCount = 0;
    int entryB_index = 0; // record the seedB kernel index.
    for (int i=0;i<VNode::MAX_CHILD_NUM;i++)
    {
        int currentCount = entryA.xEpsilen(_p_node_being_split->getChildEntry(i));
        if (i != entryA_index && minCount <= currentCount)
        {
            minCount = currentCount;
            entryB_index = i;
        }
    }
    entryB = _p_node_being_split->getChildEntry(entryB_index);

    // AEntryIndex: the entry index near seedA.
    // BEntryIndex: the entry index near seedB.
    std::vector<int> entryIndex_nearA, entryIndex_nearB;
    entryIndex_nearA.clear();
    entryIndex_nearB.clear();
    entryIndex_nearA.push_back(entryA_index);
    entryIndex_nearB.push_back(entryB_index);

    /* just tmp variables, for more readibility */
    int nearA_max_size, nearB_max_size;
    bool nearA_tooSmall, nearB_tooSmall;

    for (int i=0;i<VNode::MAX_CHILD_NUM;i++)
    {
        if (i == entryA_index || i == entryB_index) continue;

        /* should guarantee that each new node has at least MIN_CHILD_NUM children. */
        nearA_max_size = VNode::MAX_CHILD_NUM - entryIndex_nearB.size();
        nearA_tooSmall = (nearA_max_size <= VNode::MIN_CHILD_NUM);

        if (nearA_tooSmall)
        {
            for (;i<VNode::MAX_CHILD_NUM;i++)
            {
                if (i == entryA_index || i == entryB_index) continue;
                entryIndex_nearA.push_back(i);
            }
            break;
        }

        nearB_max_size = VNode::MAX_CHILD_NUM - entryIndex_nearA.size();
        nearB_tooSmall = (nearB_max_size <= VNode::MIN_CHILD_NUM);
        if (nearB_tooSmall)
        {
            for (;i<VNode::MAX_CHILD_NUM;i++)
            {
                if (i == entryA_index || i == entryB_index) continue;
                entryIndex_nearB.push_back(i);
            }
            break;
        }

        /* calculate the distance from
         * the i-th child entry signature to seedA(or seedB).*/

        /*debug target 1*/
        int disToSeedA = entryA.xEpsilen(_p_node_being_split->getChildEntry(i));
//.........这里部分代码省略.........
开发者ID:zhangxiaoyang,项目名称:gStore,代码行数:101,代码来源:VSTree.cpp


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