Exemplo n.º 1
0
// 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
	}
}
Exemplo n.º 2
0
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;
    }
}
Exemplo n.º 3
0
void 
GiSTnode::InsertBefore (const GiSTentry& entry, int index)
{
	assert (index <= NumEntries());
	GiSTentry *e = (GiSTentry*)entry.Copy();

	e->SetLevel (Level());
	e->SetPosition (index);
	e->SetNode (this);
	// Move everything else over
	for (int i=NumEntries(); 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
	numEntries++;
}