simpledb.index.btree
Class BTreeDir

java.lang.Object
  extended by simpledb.index.btree.BTreeDir

public class BTreeDir
extends Object

A B-tree directory block.

Author:
Edward Sciore

Method Summary
 void close()
          Closes the directory page.
 DirEntry insert(DirEntry e)
          Inserts a new directory entry into the B-tree block.
 void makeNewRoot(DirEntry e)
          Creates a new root block for the B-tree.
 int search(Constant searchkey)
          Returns the block number of the B-tree leaf block that contains the specified search key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public void close()
Closes the directory page.


search

public int search(Constant searchkey)
Returns the block number of the B-tree leaf block that contains the specified search key.

Parameters:
searchkey - the search key value
Returns:
the block number of the leaf block containing that search key

makeNewRoot

public void makeNewRoot(DirEntry e)
Creates a new root block for the B-tree. The new root will have two children: the old root, and the specified block. Since the root must always be in block 0 of the file, the contents of the old root will get transferred to a new block.

Parameters:
e - the directory entry to be added as a child of the new root

insert

public DirEntry insert(DirEntry e)
Inserts a new directory entry into the B-tree block. If the block is at level 0, then the entry is inserted there. Otherwise, the entry is inserted into the appropriate child node, and the return value is examined. A non-null return value indicates that the child node split, and so the returned entry is inserted into this block. If this block splits, then the method similarly returns the entry information of the new block to its caller; otherwise, the method returns null.

Parameters:
e - the directory entry to be inserted
Returns:
the directory entry of the newly-split block, if one exists; otherwise, null


Copyright © 2011. All Rights Reserved.