Beispiel #1
0
GiSTnode* MXTree::ReadNode(const GiSTpath& path) const
{
	char *firstBuffer = new char[store->PageSize()];
	int startPage = (path.IsRoot() ? rootPage : path.Page());
	store->Read(startPage, firstBuffer);
	int pageNum = ceil((float)(((MXTnodeHeader *)firstBuffer)->numEntries*(EntrySize()+sizeof(GiSTpage))+sizeof(MXTnodeHeader))/(float)PAGE_SIZE);
	GiSTnode *node = new MXTnode(pageNum);
	node->SetTree((GiST *)this);
	node->Path() = path;
	if (pageNum > 1) {
		char *buffer = new char[store->PageSize()*pageNum];
		memset(buffer, 0, store->PageSize()*pageNum);
		memcpy(buffer, firstBuffer, store->PageSize());
		((MXTfile *)store)->Read(startPage+1, buffer+store->PageSize(), pageNum-1);  // do the deed
		node->Unpack(buffer);
		delete[] buffer;
	} else {
		node->Unpack(firstBuffer);
	}
	delete[] firstBuffer;

	return node;
}
Beispiel #2
0
GiSTnode* 
GiST::ReadNode (const GiSTpath& path) const
{
	char *buf = new char[store->PageSize()];
	GiSTnode *node = NewNode((GiST *)this);

	store->Read(path.Page(), buf);  // do the deed
	node->Unpack(buf);

#ifdef PRINTING_OBJECTS
	if (debug) {
		cout << "READ PAGE " << path.Page() << ":\n";
		node->Print(cout);
	}
#endif
	node->Path() = path;
	delete []buf;
	return node;
}