本文整理汇总了C++中GiSTpath::MakeParent方法的典型用法代码示例。如果您正苦于以下问题:C++ GiSTpath::MakeParent方法的具体用法?C++ GiSTpath::MakeParent怎么用?C++ GiSTpath::MakeParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GiSTpath
的用法示例。
在下文中一共展示了GiSTpath::MakeParent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: ReadNode
MTnode *
MT::ParentNode (MTnode *node)
{
GiSTpath path = node->Path();
path.MakeParent ();
return (MTnode *) ReadNode (path); // parentNode should be destroyed by the caller
}
示例3: Path
void
MTnode::InvalidateEntry (BOOL bNew)
{
GiSTpath path = Path ();
if (path.Level() > 1) { // len>=3
MTnode *parentNode = ((MT *)Tree())->ParentNode((MTnode *)this);
for (int i=0; i<parentNode->NumEntries(); i++) { // search the entry in the parent's node
MTentry *entry = (MTentry *) (*parentNode)[i].Ptr();
if (entry->Ptr() == path.Page()) {
if (bNew) {
entry->Key()->distance = -MaxDist();
}
entry->Key()->splitted = TRUE;
break;
}
}
path.MakeParent ();
MTnode *grandNode = ((MT *)Tree())->ParentNode(parentNode);
for (int i=0; i<grandNode->NumEntries(); i++) { // search the entry in the grandparent's node
MTentry *entry = (MTentry *) (*grandNode)[i].Ptr();
if (entry->Ptr() == path.Page()) {
entry->SetMaxRadius(-1);
break;
}
}
((MT *)Tree())->WriteNode(parentNode); // write parent node (in inconsistent state)
((MT *)Tree())->WriteNode(grandNode); // write grandparent node (to invalidate the parent's entry)
delete parentNode;
delete grandNode;
}
}
示例4: ReadNode
void
GiST::DumpNode (ostream& os, GiSTpath path) const
{
GiSTnode *node = ReadNode(path);
node->Print(os);
if (!node->IsLeaf()) {
TruePredicate truePredicate;
GiSTlist<GiSTentry*> list = node->Search(truePredicate);
while (!list.IsEmpty()) {
GiSTentry *e = list.RemoveFront();
path.MakeChild(e->Ptr());
DumpNode (os, path);
path.MakeParent();
delete e;
}
}
delete node;
}
示例5: Split
void MXTree::Split(GiSTnode **node, const GiSTentry& entry)
{
double radii[2], dist, *dists = new double[(*node)->NumEntries()*2];
int pageNums[2], cands[2];
vector<vector<int>> vec(2);
((MXTnode *)(*node))->TestPromotion(radii, &dist, pageNums, cands, dists, vec);
if (Trade((*node)->Path().IsRoot(), radii, dist, pageNums, ((MXTnode *)(*node))->GetPageNum()+1, (*node)->NumEntries())) {
// don't split now
delete[] dists;
GiSTpath oldPath = (*node)->Path();
int startPage = ((*node)->Path().IsRoot() ? rootPage : (*node)->Path().Page());
int pageNum = ((MXTnode *)(*node))->GetPageNum();
((MXTfile *)store)->Deallocate(startPage, pageNum);
startPage = ((MXTfile *)store)->Allocate(++pageNum);
(*node)->Path().MakeSibling(startPage);
rootPage = ((*node)->Path().IsRoot() ? startPage : rootPage);
((MXTnode *)(*node))->SetPageNum(pageNum);
WriteNode(*node);
if (!(*node)->Path().IsRoot() && startPage != oldPath.Page()) {
GiSTpath parentPath = oldPath;
parentPath.MakeParent();
GiSTnode *parentNode = ReadNode(parentPath);
GiSTentry *e = parentNode->SearchPtr(oldPath.Page());
assert(e != NULL);
int pos = e->Position();
e->SetPtr(startPage);
parentNode->DeleteEntry(pos);
parentNode->InsertBefore(*e, pos);
WriteNode(parentNode);
delete parentNode;
delete e;
}
} else {
// split now
bool bLeft = false, bNewRoot = false;
if ((*node)->Path().IsRoot()) {
bNewRoot = true;
(*node)->Path().MakeChild(rootPage);
rootPage = store->Allocate();
}
int oldPageNum = ((MXTnode *)(*node))->GetPageNum();
GiSTnode *node2 = ((MXTnode *)(*node))->PickSplit(cands, dists, vec);
delete[] dists;
int curPageNum = ((MXTnode *)(*node))->GetPageNum();
assert(oldPageNum >= curPageNum);
if (oldPageNum > curPageNum) {
((MXTfile *)store)->Deallocate((*node)->Path().Page()+curPageNum, oldPageNum-curPageNum);
}
node2->Path().MakeSibling(((MXTfile *)store)->Allocate(((MXTnode *)node2)->GetPageNum()));
WriteNode(*node);
WriteNode(node2);
GiSTentry *e = (*node)->SearchPtr(entry.Ptr());
if (e != NULL) {
bLeft = true;
delete e;
}
GiSTentry *e1 = (*node)->Union();
GiSTentry *e2 = node2->Union();
e1->SetPtr((*node)->Path().Page());
e2->SetPtr(node2->Path().Page());
// Create new root if root is being split
if (bNewRoot) {
GiSTnode *root = NewNode(this);
root->SetLevel((*node)->Level() + 1);
root->InsertBefore(*e1, 0);
root->InsertBefore(*e2, 1);
root->Path().MakeRoot();
WriteNode(root);
delete root;
} else {
// Insert entry for N' in parent
GiSTpath parentPath = (*node)->Path();
parentPath.MakeParent();
GiSTnode *parent = ReadNode(parentPath);
// Find the entry for N in parent
GiSTentry *e = parent->SearchPtr((*node)->Path().Page());
assert(e != NULL);
// Insert the new entry right after it
int pos = e->Position();
parent->DeleteEntry(pos);
parent->InsertBefore(*e1, pos);
parent->InsertBefore(*e2, pos+1);
delete e;
if (!parent->IsOverFull(*store)) {
WriteNode(parent);
} else {
Split(&parent, bLeft? *e1: *e2); // parent is the node which contains the entry inserted
GiSTpage page = (*node)->Path().Page();
(*node)->Path() = parent->Path(); // parent's path may change
(*node)->Path().MakeChild(page);
page = node2->Path().Page();
node2->Path() = (*node)->Path();
//.........这里部分代码省略.........
示例6: EntrySize
//.........这里部分代码省略.........
subtree->Close();
delete subtree->Store(); // it was created in tree->Open()
}
// build the super tree upon the parents
MTentry **topEntrArr = new MTentry *[nSamples]; // array of the parent entries for each subtree
char **subNameArr = new char *[nSamples]; // array of the subtrees names
for (int i=0; i<nSamples; i++) { // convert the lists into arrays
topEntrArr[i] = topEntries2.RemoveFront ();
subNameArr[i] = subtreeNames2.RemoveFront ();
}
assert (topEntries2.IsEmpty());
assert (subtreeNames2.IsEmpty());
sprintf (newName, "%s.0", name);
BulkLoad (topEntrArr, nSamples, padFactor, newName);
// attach each subtree to the leaves of the super tree
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