simpledb.index.btree
Class BTreeLeaf

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

public class BTreeLeaf
extends Object

An object that holds the contents of a B-tree leaf block.

Author:
Edward Sciore

Constructor Summary
BTreeLeaf(Block blk, TableInfo ti, Constant searchkey, Transaction tx)
          Opens a page to hold the specified leaf block.
 
Method Summary
 void close()
          Closes the leaf page.
 void delete(RID datarid)
          Deletes the leaf record having the specified dataRID
 RID getDataRid()
          Returns the dataRID value of the current leaf record.
 DirEntry insert(RID datarid)
          Inserts a new leaf record having the specified dataRID and the previously-specified search key.
 boolean next()
          Moves to the next leaf record having the previously-specified search key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BTreeLeaf

public BTreeLeaf(Block blk,
                 TableInfo ti,
                 Constant searchkey,
                 Transaction tx)
Opens a page to hold the specified leaf block. The page is positioned immediately before the first record having the specified search key (if any).

Parameters:
blk - a reference to the disk block
ti - the metadata of the B-tree leaf file
searchkey - the search key value
tx - the calling transaction
Method Detail

close

public void close()
Closes the leaf page.


next

public boolean next()
Moves to the next leaf record having the previously-specified search key. Returns false if there is no more such records.

Returns:
false if there are no more leaf records for the search key

getDataRid

public RID getDataRid()
Returns the dataRID value of the current leaf record.

Returns:
the dataRID of the current record

delete

public void delete(RID datarid)
Deletes the leaf record having the specified dataRID

Parameters:
datarid - the dataRId whose record is to be deleted

insert

public DirEntry insert(RID datarid)
Inserts a new leaf record having the specified dataRID and the previously-specified search key. If the record does not fit in the page, then the page splits and the method returns the directory entry for the new page; otherwise, the method returns null. If all of the records in the page have the same dataval, then the block does not split; instead, all but one of the records are placed into an overflow block.

Parameters:
datarid - the dataRID value of the new record
Returns:
the directory entry of the newly-split page, if one exists.


Copyright © 2011. All Rights Reserved.