本文整理汇总了C++中GiSTnode::SearchNeighbors方法的典型用法代码示例。如果您正苦于以下问题:C++ GiSTnode::SearchNeighbors方法的具体用法?C++ GiSTnode::SearchNeighbors怎么用?C++ GiSTnode::SearchNeighbors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GiSTnode
的用法示例。
在下文中一共展示了GiSTnode::SearchNeighbors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadNode
// handle underfull leaf nodes
int
GiST::CondenseTree (GiSTnode *leaf)
{
GiSTlist<GiSTentry*> Q;
int deleted = 0;
// Must be condensing a leaf
assert (leaf->IsLeaf());
while (!leaf->Path().IsRoot()) {
GiSTpath parent_path = leaf->Path();
parent_path.MakeParent ();
GiSTnode *P = ReadNode (parent_path);
GiSTentry *En = P->SearchPtr(leaf->Path().Page());
assert (En != NULL);
// Handle under-full node
if (leaf->IsUnderFull(*store)) {
if (!IsOrdered()) {
TruePredicate truePredicate;
GiSTlist<GiSTentry*> list = leaf->Search(truePredicate);
while (!list.IsEmpty()) {
GiSTentry *e = list.RemoveFront();
Q.Append (e);
}
P->DeleteEntry(En->Position());
WriteNode (P);
deleted = 1;
AdjustKeys (P, NULL);
} else {
// Try to borrow entries, else coalesce with a neighbor
GiSTpage neighbor_page = P->SearchNeighbors(leaf->Path().Page()); // right and then left
if (neighbor_page != 0) {
GiSTpath neighbor_path = leaf->Path();
neighbor_path.MakeSibling (neighbor_page);
GiSTnode *neighbor;
if (leaf->Sibling() == neighbor_page) { // RIGHT sibling...
neighbor = ReadNode (neighbor_path);
} else { // LEFT sibling
neighbor = leaf;
leaf = ReadNode (neighbor_path);
}
leaf->Coalesce(*neighbor);
// If not overfull, coalesce, kill right node
if (!leaf->IsOverFull(*store)) {
leaf->SetSibling(neighbor->Sibling());
WriteNode (leaf);
// Delete the neighbor from parent
GiSTentry *e = P->SearchPtr(neighbor->Path().Page());
P->DeleteEntry(e->Position());
WriteNode (P);
delete e;
store->Deallocate(neighbor->Path().Page());
deleted = 1;
} else { // If overfull, split (same as borrowing)
GiSTnode *node2 = leaf->PickSplit();
node2->Path() = neighbor->Path();
node2->SetSibling(neighbor->Sibling());
WriteNode (leaf);
WriteNode (node2);
AdjustKeys (node2, &P);
delete node2;
deleted = 1;
}
delete neighbor;
}
}
}
// Adjust covering predicate
if (!deleted) {
AdjustKeys (leaf, &P);
}
parent_path = leaf->Path();
parent_path.MakeParent ();
delete leaf;
// Propagate deletes
if (!deleted) {
break;
}
leaf = P;
}
// Re-insert orphaned entries
while (!Q.IsEmpty()) {
GiSTentry *e = Q.RemoveFront ();
InsertHelper (*e, e->Level());
delete e;
}
return (deleted);
}