public class BTree
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
BTree()
Creates the root node of the BTree.
|
BTree(BTree T)
Loads the root node of the BTree.
|
Modifier and Type | Method and Description |
---|---|
Node |
allocateNode()
Creates space for a Node on disk, then returns the Node
|
void |
BTreeInsert(short k,
Exoplanet e)
Inserts a key and corresponding value into the BTree.
|
void |
BTreeInsertNonFull(Node x,
short k,
short v)
Inserts a key and corresponding value into the BTree when the node is non-full.
|
Exoplanet |
BTreeSearch(Node x,
short k)
Returns the value corresponding to a specific index.
|
Exoplanet |
BTreeSearch(short k)
Returns the value corresponding to a specific index.
|
void |
BTreeSplitChild(Node x,
short i)
Splits the nodes when they become full and readjusts the BTree afterwards.
|
void |
diskWrite(Node n)
Writes a given node to disk and updates the pointer to the root.
|
java.util.ArrayList<java.lang.Short> |
getKeys()
Returns all the keys from the persistant BTree.
|
java.util.ArrayList<java.lang.Short> |
getKeys(Node x)
Returns all the keys from the persistant BTree.
|
Node |
getNode(short pos)
Returns the node at the specified position.
|
Exoplanet |
getValue(short k)
Returns the value corresponding to a specific index.
|
java.util.ArrayList<Exoplanet> |
getValues()
Returns all the values from the persistant BTree.
|
java.util.ArrayList<Exoplanet> |
getValues(Node x)
Returns all the values from the persistant BTree.
|
void |
overwriteDegreeToFile()
Overwrites the current tree degree to file.
|
void |
overwriteNode(Node n)
Overwrites the node on disk.
|
void |
overwriteRootToFile()
Overwrites the current tree root to file.
|
short |
overwriteValue(Exoplanet e)
Returns the index corresponding to a specific value.
|
void |
readTreeDegree()
Reads the degree of the BTree from file and sets the order of the BTree.
|
void |
readTreeRoot()
Reads the root of the BTree from file and sets the root of the BTree.
|
void |
setOrder(int newOrder)
Sets the order of the the Btree.
|
public BTree() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
public BTree(BTree T) throws java.io.IOException, java.lang.ClassNotFoundException
T
- is an empty BTree.java.io.IOException
java.lang.ClassNotFoundException
public void setOrder(int newOrder)
newOrder
- is the new order of the BTree.public void readTreeDegree() throws java.io.IOException
java.io.IOException
- is used for the IO exceptions that might occurpublic void readTreeRoot() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic java.util.ArrayList<java.lang.Short> getKeys() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic java.util.ArrayList<java.lang.Short> getKeys(Node x) throws java.io.IOException, java.lang.ClassNotFoundException
x
- is a root node of a tree or subtree.java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic java.util.ArrayList<Exoplanet> getValues() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic java.util.ArrayList<Exoplanet> getValues(Node x) throws java.io.IOException, java.lang.ClassNotFoundException
x
- is a root node of a tree or subtree.java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic Node allocateNode() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic void overwriteNode(Node n) throws java.io.IOException
n
- is the specified index to find the node in the btreecacheNode filejava.io.IOException
- is used for the IO exceptions that might occurpublic short overwriteValue(Exoplanet e) throws java.io.IOException, java.lang.ClassNotFoundException
e
- is the Exoplanet to overwrite the current value found at its respective position on file.java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic void overwriteDegreeToFile() throws java.io.IOException
java.io.IOException
- is used for the IO exceptions that might occurpublic void overwriteRootToFile() throws java.io.IOException
java.io.IOException
- is used for the IO exceptions that might occurpublic Exoplanet getValue(short k) throws java.io.IOException, java.lang.ClassNotFoundException
k
- is the specified index to find the value in the btreecacheValue file.java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic void diskWrite(Node n) throws java.io.IOException, java.lang.ClassNotFoundException
n
- is the node that will be written to disk.java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic Node getNode(short pos) throws java.io.IOException, java.lang.ClassNotFoundException
pos
- is the specified index to find the node in the btreecacheNode file.java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic Exoplanet BTreeSearch(short k) throws java.io.IOException, java.lang.ClassNotFoundException
k
- is the specified key to find the value corresponding to it.java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic Exoplanet BTreeSearch(Node x, short k) throws java.io.IOException, java.lang.ClassNotFoundException
x
- is a root node of a tree or subtree.k
- is the specified key to find the value corresponding to it.java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic void BTreeSplitChild(Node x, short i) throws java.io.IOException, java.lang.ClassNotFoundException
x
- is the node being split and readjusted.i
- is the key value being stored in the node.java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic void BTreeInsert(short k, Exoplanet e) throws java.io.IOException, java.lang.ClassNotFoundException
k
- is the key value being stored in the node.e
- is the Exoplanet being stored in file.java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occurpublic void BTreeInsertNonFull(Node x, short k, short v) throws java.io.IOException, java.lang.ClassNotFoundException
x
- is a root node of a tree or subtree.k
- is the key value being stored in the node.v
- is the value index corresponding to the Exoplanet being stored in file.java.io.IOException
- is used for the IO exceptions that might occurjava.lang.ClassNotFoundException
- is used for the class not found exceptions that might occur