本文整理汇总了C++中GiSTpath类的典型用法代码示例。如果您正苦于以下问题:C++ GiSTpath类的具体用法?C++ GiSTpath怎么用?C++ GiSTpath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GiSTpath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
}
示例3: ReadNode
MTnode *
MT::ParentNode (MTnode *node)
{
GiSTpath path = node->Path();
path.MakeParent ();
return (MTnode *) ReadNode (path); // parentNode should be destroyed by the caller
}
示例4: CommandCheck
// perform a check of the nodes of the tree
void
CommandCheck()
{
GiSTpath path;
path.MakeRoot();
gist->CheckNode(path, NULL);
}
示例5: MTrecord
void
MTcursor::FetchNode ()
{
if (queue.IsEmpty()) {
return;
}
MTrecord *record = queue.RemoveFirst ();
MTnode *node = (MTnode *) tree.ReadNode (record->Path()); // retrieve next node to be examined
delete record;
// search the first children to be examined
for (int i=0; i<node->NumEntries(); i++) { // for each entry in the current node
MTentry *entry = (MTentry *) (*node)[i].Ptr();
double dist = pred->distance(entry->object());
if (!entry->IsLeaf()) { // insert the child node in the priority queue
GiSTpath path = node->Path();
path.MakeChild (entry->Ptr());
queue.Insert (new MTrecord (path, MAX(dist - entry->MaxRadius(), 0), dist));
} else { // insert the entry in the result list
MTentry *newEntry = (MTentry *) entry->Copy();
newEntry->SetMinRadius(0);
newEntry->SetMaxRadius(dist); // we insert the actual distance from the query object as the key radius
results.Insert (newEntry);
}
}
delete node; // delete examined node
}
示例6:
void
GiST::Print(ostream& os) const
{
GiSTpath path;
path.MakeRoot();
DumpNode(os, path);
}
示例7: tree
MTcursor::MTcursor (const MT& tree, const MTpred& pred): tree (tree), queue (comparedst), results (compareentry)
{
GiSTpath path;
path.MakeRoot ();
queue.Insert (new MTrecord (path, 0, MAXDOUBLE));
this->pred = (MTpred *) pred.Copy ();
}
示例8: CommandDump
// print a dump of each node of the tree
void
CommandDump()
{
GiSTpath path;
path.MakeRoot();
#ifdef PRINTING_OBJECTS
gist->DumpNode(std::cout, path);
#endif
}
示例9: queue
MTcursor::MTcursor(const MT& tree, const MTpred& query): queue(comparedst), results(compareentry), tree(tree)
{
GiSTpath path;
dst *d;
path.MakeRoot();
d=new dst(path, 0, MAXDOUBLE);
this->query=(MTpred *)query.Copy();
queue.Insert(d);
}
示例10: CommandDump
void CommandDump(const char *table, GiSTpage page)
{
int i;
if ((i = GetTable(table)) == NOT_FOUND) {
cout << "No such table is open.\n";
return;
}
GiSTpath path;
path.MakeRoot();
tables[i].gist->DumpNode(cout, path);
}
示例11: while
// append the subtree rooted at from to the node to, which is used in the "append" phase of the BulkLoad algorithm
void
MT::Append (MTnode *to, MTnode *from)
{
GiSTlist<MTnode *> *oldList = new GiSTlist<MTnode *>; // upper level nodes to append
oldList->Append(from);
GiSTlist<GiSTpath> pathList;
pathList.Append (to->Path());
MTnode *node = new MTnode, *newNode = NULL;
MT *fromTree = (MT *) from->Tree();
do {
GiSTlist<MTnode *> *newList = new GiSTlist<MTnode *>; // lower level nodes to append
while (!oldList->IsEmpty()) {
delete node;
node = oldList->RemoveFront();
GiSTpath path = pathList.RemoveFront ();
newNode = (MTnode *) ReadNode (path); // node to be appended
for (int i=0; i<node->NumEntries(); i++) {
MTentry *entry = (MTentry *) (*node)[i].Ptr()->Copy();
if (node->Level() > 0) { // if node isn't a leaf, we've to allocate its children
GiSTpath nodePath = node->Path();
nodePath.MakeChild (entry->Ptr());
newList->Append((MTnode *) fromTree->ReadNode(nodePath));
entry->SetPtr(Store()->Allocate()); // allocate its child in the inserted tree
path.MakeChild (entry->Ptr());
MTnode *childNode = (MTnode *) CreateNode ();
childNode->Path() = path;
childNode->SetTree(this);
WriteNode (childNode); // write the empty node
delete childNode;
pathList.Append (path);
path.MakeParent ();
}
newNode->Insert(*entry);
delete entry;
}
newNode->SetLevel(node->Level());
WriteNode (newNode); // write the node
delete newNode;
}
delete oldList;
oldList = newList;
} while (node->Level() > 0); // until we reach the leaves' level
delete node;
delete oldList;
}
示例12: 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;
}
示例13: ParentEntry
GiSTentry *
MTnode::Union () const
{
Object *objTemp = NULL;
if (!obj) { // retrieve the node's parent object
MTentry *parentEntry = ParentEntry ();
((MTnode *)this)->obj = (objTemp = new Object(parentEntry->object()));
delete parentEntry;
}
GiSTpath path = ((MTnode *)this)->Path();
MTentry *unionEntry = new MTentry;
unionEntry->InitKey();
if (path.Level() > 1) { // len>=3
MTentry *parentEntry = ParentEntry ();
if (parentEntry) { // copy the entry
unionEntry->Key()->distance = parentEntry->Key()->distance;
if (parentEntry->Key()->splitted) {
unionEntry->Key()->splitted = TRUE;
}
delete parentEntry;
}
if (unionEntry->Key()->distance == -MaxDist()) { // compute the distance from the parent
MTnode *parentNode = ((MT *)Tree())->ParentNode((MTnode *)this);
MTentry *grandEntry = parentNode->ParentEntry();
unionEntry->Key()->distance = obj->distance(grandEntry->object());
unionEntry->Key()->splitted = TRUE;
delete grandEntry;
delete parentNode;
}
}
unionEntry->SetObject(*obj);
unionEntry->SetMaxRadius(0);
unionEntry->SetMinRadius(MAXDOUBLE);
mMRadius (unionEntry); // compute the radii
if (objTemp) {
delete objTemp;
}
((MTnode *)this)->obj = NULL;
return unionEntry;
}
示例14: main
int main()
{
MXTree *tree = new MXTree;
tree->Create(MXTreePath.c_str());
assert(tree->IsOpen());
tree->Open(MXTreePath.c_str());
time_t time_start, time_end;
time(&time_start);
ifstream fin(path.c_str());
for (int i=0; i<amount; i++) {
Object *obj = Read(fin);
tree->Insert(MTentry(MTkey(*obj, 0, 0), i));
delete obj;
Progress(i, amount);
}
fin.close();
time(&time_end);
cout<<difftime(time_end, time_start)<<endl;
GiSTpath path;
path.MakeRoot();
//tree->DumpNode(cout, path);
tree->CheckNode(path, NULL);
tree->CollectStats();
delete tree;
//unlink(MXTreePath.c_str());
//unlink(BitMapPath.c_str());
cout << "Computed dists = " << compdists << endl;
cout << "IO reads = " << IOread << endl;
cout << "IO writes = " << IOwrite << endl;
return 0;
}
示例15: EntrySize
//.........这里部分代码省略.........
for (int i=0; i<nSamples; i++) { // convert the lists into arrays
array[i] = new MTentry *[ns[i]];
for (int j=0; j<ns[i]; j++) {
array[i][j] = (MTentry *) data[lists[i].RemoveFront ()]->Copy();
array[i][j]->Key()->distance = dists[i].RemoveFront ();
}
assert (lists[i].IsEmpty());
assert (dists[i].IsEmpty());
}
delete []lists;
delete []dists;
delete []sizes;
delete []bSampled;
for (int i=0; i<nSamples; i++) {
while (!distm[i].IsEmpty()) {
delete [](distm[i].RemoveFront());
}
}
free (distm);
// build an M-tree under each parent
int nInit = nSamples;
MT *subtree = new MT;
GiSTlist<char *> subtreeNames; // list of the subtrees names
GiSTlist<MTentry *> topEntries; // list of the parent entries of each subtree
int nCreated = 0, minHeight = MAXINT;
char newName[50];
for (int i=0; i<nInit; i++) {
sprintf (newName, "%s.%i", name, ++nCreated);
unlink (newName);
subtree->Create(newName); // create the new subtree
subtree->BulkLoad(array[i], ns[i], padFactor, newName); // build the subtree
GiSTpath path;
path.MakeRoot ();
MTnode *subtreeRoot = (MTnode *) subtree->ReadNode(path);
if (subtreeRoot->IsUnderFull(*Store())) { // if the subtree root node is underfilled, we have to split the tree
GiSTlist<MTentry *> *parentEntries = new GiSTlist<MTentry *>;
GiSTlist<char *> *newTreeNames = subtree->SplitTree(&nCreated, subtree->TreeHeight()-1, parentEntries, name); // split the tree
nSamples--;
while (!newTreeNames->IsEmpty()) { // insert all the new trees in the subtrees list
subtreeNames.Append (newTreeNames->RemoveFront());
MTentry *entry = parentEntries->RemoveFront();
for (int j=0; j<n; j++) {
if (data[j]->object() == entry->object()) { // append the parent entry to the list
topEntries.Append (data[j]);
break;
}
}
delete entry;
nSamples++;
}
delete newTreeNames;
delete parentEntries;
minHeight = MIN (minHeight, subtree->TreeHeight()-1);
} else {
subtreeNames.Append (strdup(newName));
topEntries.Append (data[samples[i]]);
minHeight = MIN (minHeight, subtree->TreeHeight());
}
delete subtreeRoot;
subtree->Close();
delete subtree->Store(); // it was created in subtree->Create()
}
delete []samples;
for (int i=0; i<nInit; i++) {