Пример #1
0
GiSTnode *
MTnode::PickSplit()
{
	MTnode *rightnode;
	int leftdeletes, rightdeletes;	// number of entries to be deleted from each node
	int *leftvec=new int[NumEntries()], *rightvec=new int[NumEntries()];	// array of entries to be deleted from each node

	// promote the right node (possibly reassigning the left node);
	// the right node's page is copied from left node; 
	// we'll delete from the nodes as appropriate after the splitting phase
//	cout << "In PickSplit with node " << this << "\n";
	rightnode=PromotePart();
	// now perform the split
	Split(rightnode, leftvec, rightvec, &leftdeletes, &rightdeletes);	// complexity: O(n)
	// given the deletion vectors, do bulk deletes
	DeleteBulk(leftvec, leftdeletes);
	rightnode->DeleteBulk(rightvec, rightdeletes);
//	cout << "Nodes:\n" << this << rightnode;
	// order the entries in both nodes
	Order();
	rightnode->Order();
	delete []leftvec;
	delete []rightvec;
	// return the right node
	return rightnode;
}
Пример #2
0
GiSTnode *
MTnode::PickSplit ()
{
	int lDel, rDel;  // number of entries to be deleted from each node
	int *lArray = new int[NumEntries()], *rArray = new int[NumEntries()];  // array of entries to be deleted from each node

	// promote the right node (possibly reassigning the left node);
	// the right node's page is copied from left node;
	// we'll delete from the nodes as appropriate after the splitting phase
	MTnode *rNode = PromotePart ();
	// now perform the split
	Split (rNode, lArray, rArray, &lDel, &rDel);  // complexity: O(n)
	// given the deletion vectors, do bulk deletes
	DeleteBulk (lArray, lDel);
	rNode->DeleteBulk(rArray, rDel);
	// order the entries in both nodes
	SortEntries ();
	rNode->SortEntries();

	delete []lArray;
	delete []rArray;
	return rNode;  // return the right node
}