|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iglu.util.FileBTree
A B-Tree index file which contains both the index and the data which the index points to. Implements the B-Tree described in Cormen, except that a value pointer is attached to each entry in the tree. Whenever a new node or value is needed, the space is just allocated off the end of the file. It uses safe flags to indicate whether or not a node has been appropriatly written out.
keySize
bytes in the key
Nested Class Summary | |
class |
FileBTree.Entry
|
class |
FileBTree.Node
|
private class |
FileBTree.ValueIterator
|
Field Summary | |
static long |
B_ISLEAF
Bitmask for if a block is a leaf |
static long |
B_SAFE
Bitmask for a block's safety bit |
static long |
B_VALID
Bitmask for a block's validity bit |
static long |
F_SAFE
bitmask for the file's safety status bit |
protected java.io.RandomAccessFile |
file
pointer to the actual file |
protected java.lang.String |
filename
name of the file |
static long |
FIRSTNODE_LOC
Location of where the first node is stored |
static long |
FSTATUSFLAGS_LOC
Location of the status flag for the file |
static long |
I_VALID
Bitmask for if an entry is value |
protected int |
keySize
Number of bytes in a key |
static long |
KEYSIZE_LOC
Location of the number of keys per node |
protected java.util.HashMap |
nodes
A hash map of the nodes |
protected int |
nodeSize
Number of keys per node (2*t-1) |
static long |
NODESIZE_LOC
Location of the size of a node |
protected long |
numRecords
Number of records in this file |
static long |
NUMRECORDS_LOC
Location of the number of records |
protected long |
rootPointer
Pointer to the root node |
static long |
ROOTPTR_LOC
Location of the root pointer |
protected long |
statusBits
Status flags for this file |
protected int |
t
t parameter |
static long |
T_LOC
Location of the t parameter |
Constructor Summary | |
FileBTree(java.lang.String filename)
|
|
FileBTree(java.lang.String filename,
int t,
int keySize)
|
Method Summary | |
static java.io.Serializable |
bytesToObj(byte[] b)
|
void |
close()
|
static int |
compBytes(byte[] a,
byte[] b)
|
protected void |
createFile()
|
protected FileBTree.Node |
createNewNodeFromFile()
|
boolean |
delete(byte[] key)
|
protected boolean |
delete(byte[] key,
long nodePtr)
|
boolean |
delete(long key)
|
boolean |
delete(java.lang.Long key)
|
boolean |
delete(java.io.Serializable key)
|
boolean |
delete(java.lang.String key)
|
protected void |
finalize()
|
protected void |
flushNodes()
|
protected FileBTree.Node |
getNewNode()
|
protected FileBTree.Node |
getNode(long ptr)
|
long |
getNumRecords()
|
long |
getRootPointer()
|
protected byte[] |
getValue(long ptr)
|
void |
insert(byte[] key,
byte[] value)
|
void |
insert(byte[] key,
java.io.Serializable value)
|
void |
insert(long key,
byte[] value)
|
protected void |
insert(long nodePtr,
byte[] key,
byte[] value)
|
void |
insert(long key,
java.io.Serializable value)
|
void |
insert(java.io.Serializable key,
byte[] value)
|
void |
insert(java.io.Serializable key,
java.io.Serializable value)
|
void |
insert(java.lang.String key,
byte[] value)
|
void |
insert(java.lang.String key,
java.io.Serializable value)
|
protected void |
insertNonfull(FileBTree.Node x,
byte[] key,
byte[] value)
|
protected byte[] |
longToBytes(long l)
|
byte[] |
lookup(byte[] key)
|
protected byte[] |
lookup(byte[] key,
long nodePtr)
|
byte[] |
lookup(long key)
|
byte[] |
lookup(java.io.Serializable key)
|
byte[] |
lookup(java.lang.String key)
|
java.io.Serializable |
lookupObject(byte[] key)
|
java.io.Serializable |
lookupObject(long key)
|
java.io.Serializable |
lookupObject(java.io.Serializable key)
|
java.io.Serializable |
lookupObject(java.lang.String key)
|
static void |
main(java.lang.String[] argv)
|
static byte[] |
objectToBytes(java.io.Serializable o)
|
protected void |
openFile()
|
protected FileBTree.Node |
readNodeFromFile(long ptr)
|
protected byte[] |
readValueFromFile(long ptr)
|
byte[] |
sizeKey(byte[] key)
|
protected void |
splitChild(FileBTree.Node x,
int i,
FileBTree.Node y)
|
java.lang.String |
toString()
|
java.util.Iterator |
valueIterator()
|
protected void |
writeNodeStatusSafe(FileBTree.Node n)
|
protected void |
writeNodeToFile(FileBTree.Node n,
boolean safe)
|
protected long |
writeValue(byte[] value)
|
protected void |
writeValue(long ptr,
byte[] value)
|
protected void |
writeValueToFile(long ptr,
byte[] value)
|
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final long NODESIZE_LOC
public static final long KEYSIZE_LOC
public static final long FSTATUSFLAGS_LOC
public static final long T_LOC
public static final long ROOTPTR_LOC
public static final long NUMRECORDS_LOC
public static final long FIRSTNODE_LOC
public static final long F_SAFE
public static final long B_VALID
public static final long B_SAFE
public static final long B_ISLEAF
public static final long I_VALID
protected java.lang.String filename
protected java.io.RandomAccessFile file
protected int t
protected int nodeSize
protected int keySize
protected long statusBits
protected long numRecords
protected long rootPointer
protected java.util.HashMap nodes
Constructor Detail |
public FileBTree(java.lang.String filename, int t, int keySize)
public FileBTree(java.lang.String filename)
Method Detail |
public void close()
public java.util.Iterator valueIterator()
protected void flushNodes()
public java.lang.String toString()
toString
in class java.lang.Object
protected void createFile()
protected void openFile()
public long getRootPointer()
public long getNumRecords()
public byte[] lookup(byte[] key)
public byte[] lookup(long key)
public byte[] lookup(java.lang.String key)
public byte[] lookup(java.io.Serializable key)
public java.io.Serializable lookupObject(byte[] key)
public java.io.Serializable lookupObject(long key)
public java.io.Serializable lookupObject(java.lang.String key)
public java.io.Serializable lookupObject(java.io.Serializable key)
protected byte[] lookup(byte[] key, long nodePtr)
public boolean delete(java.lang.String key)
public boolean delete(java.lang.Long key)
public boolean delete(long key)
public boolean delete(byte[] key)
public boolean delete(java.io.Serializable key)
protected boolean delete(byte[] key, long nodePtr)
protected FileBTree.Node getNewNode()
protected FileBTree.Node createNewNodeFromFile()
protected void writeNodeToFile(FileBTree.Node n, boolean safe)
protected void writeNodeStatusSafe(FileBTree.Node n)
protected FileBTree.Node getNode(long ptr)
protected FileBTree.Node readNodeFromFile(long ptr)
protected byte[] getValue(long ptr)
protected byte[] readValueFromFile(long ptr)
protected long writeValue(byte[] value)
protected void writeValue(long ptr, byte[] value)
protected void writeValueToFile(long ptr, byte[] value)
protected void splitChild(FileBTree.Node x, int i, FileBTree.Node y)
public void insert(byte[] key, byte[] value)
public void insert(long key, byte[] value)
public void insert(java.lang.String key, byte[] value)
public void insert(java.io.Serializable key, byte[] value)
public void insert(byte[] key, java.io.Serializable value)
public void insert(long key, java.io.Serializable value)
public void insert(java.lang.String key, java.io.Serializable value)
public void insert(java.io.Serializable key, java.io.Serializable value)
protected void insert(long nodePtr, byte[] key, byte[] value)
protected void insertNonfull(FileBTree.Node x, byte[] key, byte[] value)
protected void finalize() throws java.io.IOException
finalize
in class java.lang.Object
java.io.IOException
public static int compBytes(byte[] a, byte[] b)
protected byte[] longToBytes(long l)
public static java.io.Serializable bytesToObj(byte[] b)
public byte[] sizeKey(byte[] key)
public static byte[] objectToBytes(java.io.Serializable o)
public static void main(java.lang.String[] argv)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |