本文整理汇总了C++中GiSTentry类的典型用法代码示例。如果您正苦于以下问题:C++ GiSTentry类的具体用法?C++ GiSTentry怎么用?C++ GiSTentry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GiSTentry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
GiST::Delete(const GiSTpredicate& pred)
{
GiSTcursor *c=Search(pred);
int condensed;
GiSTentry *e;
do {
if(c==NULL) return;
e=c->Next();
GiSTpath path=c->Path();
delete c;
if(e==NULL) return;
// Read in the node that this belongs to
GiSTnode *node=ReadNode(path);
node->DeleteEntry(e->Position());
WriteNode(node);
condensed=CondenseTree(node);
delete node;
if(condensed) {
ShortenTree();
// because the tree changed, we need to search all over again!
// XXX - this is inefficient! users may want to avoid condensing.
c=Search(pred);
}
} while(e!=NULL);
}
示例2: Reset
void
GiSTnode::Unpack(const char *page)
{
const GiSTheader *h = (const GiSTheader *) page;
Reset();
SetLevel(h->level);
SetSibling(h->sibling);
if (!packedNode)
packedNode = new char[tree->Store()->PageSize()];
memcpy(packedNode, page, tree->Store()->PageSize());
Expand(h->numEntries);
SetNumEntries(h->numEntries);
for (int i=0; i<h->numEntries; i++) {
GiSTcompressedEntry tmpentry = Entry(i);
GiSTentry *e = CreateEntry();
e->SetLevel(Level());
e->SetPosition(i);
e->SetNode(this);
e->Decompress(tmpentry);
// be tidy
if (tmpentry.key)
delete tmpentry.key;
// Append the body with the entry
entries[i] = e;
}
}
示例3: ReadNode
void
MT::CollectStats ()
{
GiSTpath path;
path.MakeRoot ();
GiSTnode *node = ReadNode (path);
if (!node->IsLeaf()) {
int maxLevel = node->Level();
double *radii = new double[maxLevel];
int *pages = new int[maxLevel];
for (int i=0; i<maxLevel; i++) {
pages[i] = 0;
radii[i] = 0;
}
TruePredicate truePredicate;
GiSTlist<GiSTentry*> list = node->Search(truePredicate); // retrieve all the entries in this node
double overlap = ((MTnode *)node)->Overlap();
double totalOverlap = overlap;
delete node;
while (!list.IsEmpty()) {
GiSTentry *entry = list.RemoveFront ();
path.MakeChild (entry->Ptr());
node = ReadNode (path);
overlap = ((MTnode *)node)->Overlap();
totalOverlap += overlap;
pages[node->Level()]++;
radii[node->Level()] += ((MTkey *) entry->Key())->MaxRadius();
GiSTlist<GiSTentry*> newlist;
if (!node->IsLeaf()) {
newlist = node->Search(truePredicate); // recurse to next level
}
while (!newlist.IsEmpty()) {
list.Append (newlist.RemoveFront ());
}
path.MakeParent ();
delete entry;
delete node;
}
// output the results
cout << "Level:\tPages:\tAverage_Radius:"<<endl;
int totalPages = 1; // for the root
for (int i=maxLevel-1; i>=0; i--) {
totalPages += pages[i];
cout << i << ":\t" << pages[i] << "\t" << radii[i]/pages[i] << endl;
}
cout << "TotalPages:\t" << totalPages << endl;
cout << "LeafPages:\t" << pages[0] << endl;
cout << "TotalOverlap:\t" << (float)totalOverlap << endl;
delete []radii;
delete []pages;
} else {
delete node;
}
}
示例4: return
GiSTentry*
GiSTnode::SearchPtr(GiSTpage ptr) const
{
for (int i=0; i<numEntries; i++) {
GiSTentry *e = (*this)[i];
if (e->Ptr() == ptr)
return (GiSTentry*) e->Copy();
}
return NULL;
}
示例5:
GiSTlist<GiSTentry*>
GiSTnode::Search(const GiSTpredicate &query) const
{
GiSTlist<GiSTentry*> list;
for (int i=0; i<numEntries; i++) {
GiSTentry *e = (*this)[i];
if (query.Consistent(*e))
list.Append((GiSTentry*)e->Copy());
}
return list;
}
示例6: ReadNode
void
GiST::AdjustKeys (GiSTnode *node, GiSTnode **parent)
{
if (node->Path().IsRoot()) {
return;
}
GiSTnode *P;
// Read in node's parent
if (parent == NULL) {
GiSTpath parent_path = node->Path();
parent_path.MakeParent ();
P = ReadNode (parent_path);
parent = &P;
} else {
P = *parent;
}
// Get the old entry pointing to node
GiSTentry *entry = P->SearchPtr(node->Path().Page());
assert (entry != NULL);
// Get union of node
GiSTentry *actual = node->Union();
WriteNode(node); // added by myself for the splitted = false;
actual->SetPtr(node->Path().Page());
if (!entry->IsEqual(*actual)) {
int pos = entry->Position();
P->DeleteEntry(pos);
P->InsertBefore(*actual, pos);
// A split may be necessary.
// XXX: should we do Forced Reinsert here too?
if (P->IsOverFull(*store)) {
Split (parent, *actual);
GiSTpage page = node->Path().Page();
node->Path() = P->Path();
node->Path().MakeChild(page);
} else {
WriteNode (P);
AdjustKeys (P, NULL);
}
}
if (parent == &P) {
delete P;
}
delete actual;
delete entry;
}
示例7: assert
void
MTnode::InsertBefore(const GiSTentry& entry, int index)
{
int n=NumEntries();
BOOL ordered=TRUE;
if(index>0) ordered=((*this)[index-1]->Compare(entry)<=0);
if(index<n) ordered=ordered&&((*this)[index]->Compare(entry)>=0);
if(ordered) { // yes, the position is right for this entry
assert(index<=n);
GiSTentry *e=(GiSTentry *)entry.Copy();
e->SetLevel(Level());
e->SetPosition(index);
e->SetNode(this);
// Move everything else over
for(int i=n; i>index; i--) {
GiSTentry *e=(*this)[i-1];
e->SetPosition(i);
(*this)[i]=e;
}
// Stick the entry in
(*this)[index]=e;
// Bump up the count
SetNumEntries(n+1);
}
else Insert(entry); // find the right place
}
示例8: e
void
BTnode::InsertBefore(const GiSTentry& entry, int index)
{
// Only BTentry's can be inserted into BTnodes.
assert(entry.IsA() == BTENTRY_CLASS);
BTentry e((const BTentry&) entry);
// If this is an internal node, adjust the lower/upper bounds
if (!IsLeaf()) {
// If not leftmost entry...
if (index != 0) {
// -inf changes to the upper bound of previous item
BTentry *prev = (BTentry*) (*this)[index-1].Ptr();
if (e.LowerBound() == NegInf)
e.SetLowerBound(prev->UpperBound());
}
// If not rightmost entry...
if (index != NumEntries()) {
// +inf changes to the lower bound of next item
BTentry *next = (BTentry*) (*this)[index].Ptr();
if (e.UpperBound() == PosInf)
e.SetUpperBound(next->LowerBound());
}
}
// Insert it into the node
GiSTnode::InsertBefore(e, index);
}
示例9: 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;
}
示例10: NumEntries
// insert before the original number according to the sequence instead of index
void
MTnode::InsertBefore (const GiSTentry& newEntry, int index)
{
int n = NumEntries ();
assert (index>=0 && index<=n);
BOOL bOrder = TRUE;
if (index > 0) {
bOrder = (*this)[index-1]->Compare(newEntry) <= 0;
}
if (index < n) {
bOrder = bOrder && (*this)[index]->Compare(newEntry) >= 0;
}
if (bOrder) { // yes, the position is right for this entry
GiSTentry *entry = (GiSTentry *) newEntry.Copy ();
entry->SetLevel(Level());
entry->SetPosition(index);
entry->SetNode(this);
// Move everything else over
for (int i=n; i>index; i--) {
GiSTentry *e = (*this)[i-1];
e->SetPosition(i);
(*this)[i] = e;
}
// Stick the entry in
(*this)[index] = entry;
// Bump up the count
SetNumEntries (n+1);
} else {
Insert (newEntry); // find the right place
}
}
示例11: 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;
}
示例12: while
GiSTentry*
GiSTcursor::Next()
{
GiSTpage page;
while (first || !stack.IsEmpty()) {
if (first) {
page = GiSTRootPage;
first = 0;
} else {
assert(lastlevel >= 0);
GiSTentry *entry = stack.RemoveFront();
if (entry->IsLeaf())
return entry;
// Pop off the stack
for (int i=0; i < entry->Level() - lastlevel; i++)
path.MakeParent();
page = entry->Ptr();
delete entry;
}
// Entry was a pointer to another node
path.MakeChild(page);
GiSTnode *node = gist.ReadNode(path);
lastlevel = node->Level();
GiSTlist<GiSTentry*> list = node->Search(*query);
while (!list.IsEmpty()) {
GiSTentry *entry = list.RemoveRear();
stack.Prepend(entry);
}
delete node;
}
// The search is over...
return NULL;
}
示例13: assert
void
BTnode::Insert(const GiSTentry &entry)
{
// Only BTentry's can be inserted into BTnode's.
assert(entry.IsA() == BTENTRY_CLASS);
// This doesn't work for internal nodes. For internal nodes,
// the caller must know exactly where to insert.
assert(IsLeaf());
GiSTnode::Insert(entry);
}
示例14: CommandSelect
void CommandSelect(const char *table,
const GiSTpredicate& pred)
{
int i;
i = GetTable(table);
if (i == NOT_FOUND) {
cerr << "Table is not open!\n";
return;
}
GiST *gist = tables[i].gist;
GiSTcursor *c = gist->Search(pred);
GiSTentry *e;
while ((e = c->Next()) != NULL) {
Record* rec = (Record*)e->Ptr();
cout << rec->value << "\n";
delete e;
}
delete c;
}
示例15: switch
int
RTpredicate::Consistent(const GiSTentry& entry) const
{
RTentry &rtentry = (RTentry &)entry;
if (entry.IsLeaf()) {
switch (oper) {
case RToverlap:
return(rtentry.Key().overlap((RTkey)value));
break;
case RTcontains:
return(rtentry.Key().contain((RTkey)value));
break;
case RTcontained:
return(rtentry.Key().contained((RTkey)value));
break;
case RTEqual:
return(rtentry.Key() == ((RTkey)value));
break;
case RTNotDisjoint:
return(!rtentry.Key().disjoint((RTkey)value));
break;
default:
assert(0);
return (0);
break;
}
}
else {
switch (oper) {
case RToverlap:
case RTcontained:
return(rtentry.Key().overlap((RTkey)value));
break;
case RTcontains:
case RTEqual:
return(rtentry.Key().contain(((RTkey)value)));
break;
case RTNotDisjoint:
return(!rtentry.Key().disjoint((RTkey)value));
break;
default:
assert(0);
return (0);
break;
}
}
}