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


C++ GiSTnode::Insert方法代码示例

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


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

示例1: Split

void 
GiST::InsertHelper(const GiSTentry &entry, 
		   int level, // level of tree at which to insert
		   int *splitvec) // a vector to trigger Split instead of forced reinsert
{
	GiSTnode *leaf;
	int overflow=0;

	leaf=ChooseSubtree(GiSTRootPage, entry, level);
	leaf->Insert(entry);
	if (leaf->IsOverFull(*store)) {
		if(ForcedReinsert()&&!leaf->Path().IsRoot()&&(!splitvec||!splitvec[level])) {
			int split[GIST_MAX_LEVELS];

			// R*-tree-style forced reinsert
			for(int i=0; i<GIST_MAX_LEVELS; i++) split[i]=0;
			OverflowTreatment(leaf, entry, split);
			overflow=1;
		}
		else Split(&leaf, entry);
		if(leaf->IsOverFull(*store)) {
			// we only should get here if we reinserted, and the node re-filled
			assert(overflow);
			leaf->DeleteEntry(entry.Position());
			Split(&leaf, entry);
		}
	}
	else WriteNode(leaf);
	if(!overflow) AdjustKeys(leaf, NULL);
	delete leaf;
}
开发者ID:voidcycles,项目名称:m3,代码行数:31,代码来源:GiST.cpp

示例2: ReadNode

// adjust the keys of node, which is used during the final phase of the BulkLoad algorithm
void
MT::AdjKeys (GiSTnode *node)
{
	if (node->Path().IsRoot()) {
		return;
	}

	GiSTpath parentPath = node->Path();
	parentPath.MakeParent ();
	GiSTnode *parentNode = ReadNode (parentPath);
	GiSTentry *parentEntry = parentNode->SearchPtr(node->Path().Page());  // parent entry
	assert (parentEntry != NULL);
	GiSTentry *unionEntry = node->Union();
	unionEntry->SetPtr(node->Path().Page());
	((MTkey *) unionEntry->Key())->distance = ((MTkey *) parentEntry->Key())->distance;  // necessary to keep track of the distance from the parent
	if (!parentEntry->IsEqual(*unionEntry)) {  // replace this entry
		parentNode->DeleteEntry(parentEntry->Position());
		parentNode->Insert(*unionEntry);
		WriteNode (parentNode);
		AdjKeys (parentNode);
	}
	delete unionEntry;
	delete parentEntry;
	delete parentNode;
}
开发者ID:jsc0218,项目名称:MxTree,代码行数:26,代码来源:BulkLoad.cpp

示例3: EntrySize


//.........这里部分代码省略.........
		GiSTpath path;
		path.MakeRoot ();
		MTnode *node = (MTnode *) ReadNode (path);
		GiSTlist<MTnode *> *oldList = new GiSTlist<MTnode *>;  // upper level nodes
		oldList->Append(node);
		int level = node->Level();
		while (level > 0) {  // build the leaves list for super tree
			GiSTlist<MTnode *> *newList = new GiSTlist<MTnode *>;  // lower level nodes
			while (!oldList->IsEmpty()) {
				node = oldList->RemoveFront();
				path = node->Path();
				node->SetLevel(node->Level() + minHeight);  // update level of the upper nodes of the super tree
				WriteNode (node);
				for (int i=0; i<node->NumEntries(); i++) {
					MTentry *entry = (MTentry *) (*node)[i].Ptr();
					path.MakeChild (entry->Ptr());
					newList->Append((MTnode *)ReadNode(path));
					path.MakeParent ();
				}
				delete node;
			}
			delete oldList;
			oldList = newList;
			level--;
		}
		while (!oldList->IsEmpty()) {  // attach each subtree to its leaf
			node = oldList->RemoveFront();  // retrieve next leaf (root of subtree)
			node->SetLevel(minHeight);  // update level of the root of the subtree
			path = node->Path();
			for (int i=0; i<node->NumEntries(); i++) {
				MTentry *entry = (MTentry *) (*node)[i].Ptr();
				path.MakeChild(Store()->Allocate());
				MTnode *newNode = (MTnode *) CreateNode ();
				newNode->Path() = path;
				entry->SetPtr(path.Page());
				path.MakeParent ();
				int j = 0;
				for (; entry->object() != topEntrArr[j]->object(); j++);  // search the position to append
				subtree->Open(subNameArr[j]);
				GiSTpath rootPath;
				rootPath.MakeRoot ();
				Append (newNode, (MTnode *)subtree->ReadNode(rootPath));  // append this subtree to the super tree
				subtree->Close();
				delete subtree->Store();  // it was created in tree->Open()
				delete newNode;
			}
			WriteNode (node);
			delete node;
		}
		subtree->Open(subNameArr[0]);  // in order to destroy the object tree
		delete subtree;
		for (int i=0; i<nSamples; i++) {
			delete []subNameArr[i];
		}
		delete []subNameArr;
		delete []topEntrArr;

		// update radii of the upper nodes of the result M-tree
		path.MakeRoot ();
		node = (MTnode *) ReadNode (path);
		oldList->Append(node);
		level = node->Level();
		while (level >= minHeight) {  // build the list of the nodes which radii should be recomputed
			GiSTlist<MTnode *> *newList = new GiSTlist<MTnode *>;
			while (!oldList->IsEmpty()) {
				node = oldList->RemoveFront();
				path = node->Path();
				for (int i=0; i<node->NumEntries(); i++) {
					path.MakeChild ((*node)[i].Ptr()->Ptr());
					newList->Append((MTnode *)ReadNode(path));
					path.MakeParent ();
				}
				delete node;
			}
			delete oldList;
			oldList = newList;
			level--;
		}
		while (!oldList->IsEmpty()) {  // adjust the radii of the nodes
			MTnode *node = oldList->RemoveFront();
			AdjKeys (node);
			delete node;
		}
		delete oldList;
		for (int i=0; i<=nCreated; i++) {  // delete all temporary subtrees
			sprintf (newName, "%s.%i", name, i);
			unlink (newName);
		}
	} else {  // we can insert all the entries in a single node
		GiSTpath path;
		path.MakeRoot ();
		GiSTnode *node = ReadNode (path);
		for (int i=0; i<n; i++) {
			node->Insert(*(data[i]));
		}
		assert (!node->IsOverFull(*Store()));
		WriteNode (node);
		delete node;
	}
}
开发者ID:jsc0218,项目名称:MxTree,代码行数:101,代码来源:BulkLoad.cpp


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