All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class btree.BTreeFile

java.lang.Object
   |
   +----btree.IndexFile
           |
           +----btree.BTreeFile

public class BTreeFile
extends IndexFile
implements GlobalConst
btfile.java This is the main definition of class BTreeFile, which derives from abstract base class IndexFile. It provides an insert/delete interface.


Constructor Index

 o BTreeFile(String)
BTreeFile class an index file with given filename should already exist; this opens it.
 o BTreeFile(String, int, int, int)
if index file exists, open it; else create it.

Method Index

 o close()
Close the B+ tree file.
 o Delete(KeyClass, RID)
delete leaf entry given its pair.
 o destroyFile()
Destroy entire B+ tree file.
 o insert(KeyClass, RID)
insert record with the given key and rid
 o new_scan(KeyClass, KeyClass)
create a scan with given keys Cases: (1) lo_key = null, hi_key = null scan the whole index (2) lo_key = null, hi_key!= null range scan from min to the hi_key (3) lo_key!= null, hi_key = null range scan from the lo_key to max (4) lo_key!= null, hi_key!= null, lo_key = hi_key exact match ( might not unique) (5) lo_key!= null, hi_key!= null, lo_key < hi_key range scan from lo_key to hi_key

Constructors

 o BTreeFile
 public BTreeFile(String filename)
BTreeFile class an index file with given filename should already exist; this opens it.

Parameters:
filename - the B+ tree file name. Input parameter.
 o BTreeFile
 public BTreeFile(String filename,
                  int keytype,
                  int keysize,
                  int delete_fashion)
if index file exists, open it; else create it.

Parameters:
filename - file name. Input parameter.
keytype - the type of key. Input parameter.
keysize - the maximum size of a key. Input parameter.
delete_fashion - full delete or naive delete. Input parameter. It is either DeleteFashion.NAIVE_DELETE or DeleteFashion.FULL_DELETE.

Methods

 o close
 public void close()
Close the B+ tree file. Unpin header page.

 o destroyFile
 public void destroyFile()
Destroy entire B+ tree file.

 o insert
 public void insert(KeyClass key,
                    RID rid)
insert record with the given key and rid

Parameters:
key - the key of the record. Input parameter.
rid - the rid of the record. Input parameter.
Overrides:
insert in class IndexFile
 o Delete
 public boolean Delete(KeyClass key,
                       RID rid)
delete leaf entry given its pair. `rid' is IN the data entry; it is not the id of the data entry)

Parameters:
key - the key in pair . Input Parameter.
rid - the rid in pair . Input Parameter.
Returns:
true if deleted. false if no such record.
Throws: DeleteFashionException
neither full delete nor naive delete
Throws: LeafRedistributeException
redistribution error in leaf pages
Throws: RedistributeException
redistribution error in index pages
Throws: InsertRecException
error when insert in index page
Throws: KeyNotMatchException
key is neither integer key nor string key
Throws: UnpinPageException
error when unpin a page
Throws: IndexInsertRecException
error when insert in index page
Throws: FreePageException
error in BT page constructor
Throws: RecordNotFoundException
error delete a record in a BT page
Throws: PinPageException
error when pin a page
Throws: IndexFullDeleteException
fill delete error
Throws: LeafDeleteException
delete error in leaf page
Throws: IteratorException
iterator error
Throws: ConstructPageException
error in BT page constructor
Throws: DeleteRecException
error when delete in index page
Throws: IndexSearchException
error in search in index pages
Throws: IOException
error from the lower layer
Overrides:
Delete in class IndexFile
 o new_scan
 public BTFileScan new_scan(KeyClass lo_key,
                            KeyClass hi_key)
create a scan with given keys Cases: (1) lo_key = null, hi_key = null scan the whole index (2) lo_key = null, hi_key!= null range scan from min to the hi_key (3) lo_key!= null, hi_key = null range scan from the lo_key to max (4) lo_key!= null, hi_key!= null, lo_key = hi_key exact match ( might not unique) (5) lo_key!= null, hi_key!= null, lo_key < hi_key range scan from lo_key to hi_key

Parameters:
lo_key - the key where we begin scanning. Input parameter.
hi_key - the key where we stop scanning. Input parameter.

All Packages  Class Hierarchy  This Package  Previous  Next  Index