|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jrdf.util.btree.BTree
public class BTree
Implementation of an on-disk B-Tree using the java.nio classes that are available in JDK 1.4 and newer. Documentation about B-Trees can be found on-line at the following URLs:
TODO: clean up code
| Constructor Summary | |
|---|---|
BTree(File newDataFile,
int newBlockSize,
int newValueSize)
Creates a new BTree that uses an instance of DefaultRecordComparator to compare values. |
|
BTree(File newDataFile,
int newBlockSize,
int newValueSize,
boolean newForceSync)
Creates a new BTree that uses an instance of DefaultRecordComparator to compare values. |
|
BTree(File newDataFile,
int newBlockSize,
int newValueSize,
RecordComparator newComparator)
Creates a new BTree that uses the supplied RecordComparator to compare the values that are or will be stored in the B-Tree. |
|
BTree(File newDataFile,
int newBlockSize,
int newValueSize,
RecordComparator newComparator,
boolean newForceSync)
Creates a new BTree that uses the supplied RecordComparator to compare the values that are or will be stored in the B-Tree. |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all values from the B-Tree. |
void |
close()
Closes any opened files and release any resources used by this B-Tree. |
byte[] |
get(byte[] key)
Gets the value that matches the specified key. |
File |
getFile()
Gets the file that this BTree operates on. |
long |
getValueCountEstimate()
Returns an estimate for the number of values stored in this BTree. |
byte[] |
insert(byte[] value)
Inserts the supplied value into the B-Tree. |
RecordIterator |
iterateAll()
Returns an iterator that iterates over all values in this B-Tree. |
RecordIterator |
iterateRange(byte[] minValue,
byte[] maxValue)
Returns an iterator that iterates over all values between minValue and maxValue, inclusive. |
RecordIterator |
iterateRangedValues(byte[] searchKey,
byte[] searchMask,
byte[] minValue,
byte[] maxValue)
Returns an iterator that iterates over all values between minValue and maxValue (inclusive) and returns the values that match the supplied searchKey after searchMask has been applied to the value. |
RecordIterator |
iterateValues(byte[] searchKey,
byte[] searchMask)
Returns an iterator that iterates over all values and returns the values that match the supplied searchKey after searchMask has been applied to the value. |
static void |
main(String[] args)
|
void |
print(PrintStream out)
|
byte[] |
remove(byte[] key)
Removes the value that matches the specified key from the B-Tree. |
static void |
runDebugTest(String[] args)
|
static void |
runPerformanceTest(String[] args)
|
void |
sync()
Writes any changes that are cached in memory to disk. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BTree(File newDataFile,
int newBlockSize,
int newValueSize)
throws IOException
newDataFile - The file for the B-Tree.newBlockSize - The size (in bytes) of a file block for a single node. Ideally, the
size specified is the size of a block in the used file system.newValueSize - The size (in bytes) of the fixed-length values that are or will be
stored in the B-Tree.
IOException - In case the initialization of the B-Tree file failed.DefaultRecordComparator
public BTree(File newDataFile,
int newBlockSize,
int newValueSize,
boolean newForceSync)
throws IOException
newDataFile - The file for the B-Tree.newBlockSize - The size (in bytes) of a file block for a single node. Ideally, the
size specified is the size of a block in the used file system.newValueSize - The size (in bytes) of the fixed-length values that are or will be
stored in the B-Tree.newForceSync - Flag indicating whether updates should be synced to disk forcefully
by calling FileChannel.force(boolean). This may have a
severe impact on write performance.
IOException - In case the initialization of the B-Tree file failed.DefaultRecordComparator
public BTree(File newDataFile,
int newBlockSize,
int newValueSize,
RecordComparator newComparator)
throws IOException
newDataFile - The file for the B-Tree.newBlockSize - The size (in bytes) of a file block for a single node. Ideally, the
size specified is the size of a block in the used file system.newValueSize - The size (in bytes) of the fixed-length values that are or will be
stored in the B-Tree.newComparator - The RecordComparator to use for determining whether one
value is smaller, larger or equal to another.
IOException - In case the initialization of the B-Tree file failed.
public BTree(File newDataFile,
int newBlockSize,
int newValueSize,
RecordComparator newComparator,
boolean newForceSync)
throws IOException
newDataFile - The file for the B-Tree.newBlockSize - The size (in bytes) of a file block for a single node. Ideally, the
size specified is the size of a block in the used file system.newValueSize - The size (in bytes) of the fixed-length values that are or will be
stored in the B-Tree.newComparator - The RecordComparator to use for determining whether one
value is smaller, larger or equal to another.newForceSync - Flag indicating whether updates should be synced to disk forcefully
by calling FileChannel.force(boolean). This may have a
severe impact on write performance.
IOException - In case the initialization of the B-Tree file failed.| Method Detail |
|---|
public File getFile()
public void close()
throws IOException
IOException
public void sync()
throws IOException
IOException
public byte[] get(byte[] key)
throws IOException
key - A value that is equal to the value that should be retrieved, at
least as far as the RecordComparator of this BTree is concerned.
IOExceptionpublic RecordIterator iterateAll()
public RecordIterator iterateRange(byte[] minValue,
byte[] maxValue)
public RecordIterator iterateValues(byte[] searchKey,
byte[] searchMask)
public RecordIterator iterateRangedValues(byte[] searchKey,
byte[] searchMask,
byte[] minValue,
byte[] maxValue)
public long getValueCountEstimate()
throws IOException
IOException
public byte[] insert(byte[] value)
throws IOException
value - The value to insert into the B-Tree.
IOException - If an I/O error occurred.
public byte[] remove(byte[] key)
throws IOException
key - A key that matches the value that should be removed from the
B-Tree.
IOException - If an I/O error occurred.
public void clear()
throws IOException
IOException - If an I/O error occurred.
public static void main(String[] args)
throws Exception
Exception
public static void runPerformanceTest(String[] args)
throws Exception
Exception
public static void runDebugTest(String[] args)
throws Exception
Exception
public void print(PrintStream out)
throws IOException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||