public class BPlusTree extends Object
Modifier and Type | Field and Description |
---|---|
protected PageAllocator |
allocator |
static String |
FILENAME_EXTENSION |
static String |
FILENAME_PREFIX |
protected DataBox |
keySchema |
Constructor and Description |
---|
BPlusTree(DataBox keySchema,
String fName)
This constructor is used for creating an empty BPlusTree.
|
BPlusTree(DataBox keySchema,
String fName,
String filePrefix) |
BPlusTree(String fName)
This constructor is used for loading a BPlusTree from a file.
|
BPlusTree(String fName,
String filePrefix) |
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(DataBox key)
Perform an equality search on the specified key.
|
void |
decrementNumNodes() |
boolean |
deleteKey(DataBox key,
RecordID rid)
Delete an entry with the matching key and RecordID.
|
int |
getNumNodes() |
int |
getNumPages()
Return the number of pages.
|
void |
incrementNumNodes() |
void |
insertKey(DataBox key,
RecordID rid)
Insert a (Key, RecordID) tuple.
|
Iterator<RecordID> |
lookupKey(DataBox key)
Perform an equality search on the specified key.
|
Iterator<RecordID> |
sortedScan()
Perform a sorted scan.
|
Iterator<RecordID> |
sortedScanFrom(DataBox keyStart)
Perform a range search beginning from a specified key.
|
protected void |
updateRoot(int pNum)
Update the root page.
|
public static final String FILENAME_PREFIX
public static final String FILENAME_EXTENSION
protected PageAllocator allocator
protected DataBox keySchema
public BPlusTree(DataBox keySchema, String fName)
keySchema
- the schema of the index keyfName
- the filename of where the index will be builtpublic BPlusTree(String fName)
fName
- the filename of a preexisting BPlusTreepublic void incrementNumNodes()
public void decrementNumNodes()
public int getNumNodes()
public Iterator<RecordID> sortedScan()
public Iterator<RecordID> sortedScanFrom(DataBox keyStart)
keyStart
- the key to start iterating frompublic Iterator<RecordID> lookupKey(DataBox key)
key
- the key to matchpublic void insertKey(DataBox key, RecordID rid)
key
- the key to insertrid
- the RecordID of the given keypublic boolean deleteKey(DataBox key, RecordID rid)
key
- the key to be deletedrid
- the RecordID of the key to be deletedpublic boolean containsKey(DataBox key)
key
- the key to lookuppublic int getNumPages()
protected void updateRoot(int pNum)
pNum
- the page number of the new root nodeCopyright © 2017. All rights reserved.