![]() |
Quadcap Embeddable Database |
Things to think about:
Definition at line 80 of file Bnode.java.
Public Member Functions | |
| Bnode (Btree tree, long blockRef) | |
| Construct a node from a buffer. | |
| int | size () throws IOException |
| Return the number of keys in this subtree. | |
| int | size (Block b) throws IOException |
| final byte[] | get (byte[] key, int klen) throws IOException |
| Implement the get operation. | |
| final boolean | set (byte[] key, int klen, byte[] data, int doff, int dlen, boolean insOk, boolean updOk) throws IOException |
| Implement the set operation. | |
| final boolean | delete (byte[] key) throws IOException |
| Implement the delete operation. | |
| final void | free () throws IOException |
| Free the resources associated with this block. | |
Static Public Member Functions | |
| final boolean | getKeyAndData (Block b, int index, byte[] k, byte[] d, int[] lengths) |
| Given a block and a key index, return the key for that index as a new byte array. | |
| final void | setBos (Block b, int bos) |
| Set the value of the bos field. | |
| final int | getCount (Block b) |
| Return the value of the bos field. | |
| final void | setCount (Block b, int count) |
| Set the value of the count field. | |
| final int | getFlags (Block b) |
| Return the value of the flags field. | |
| final void | setFlags (Block b, int flags) |
| Set the value of the flags field. | |
| final boolean | getFlag (Block b, int mask) |
| Return the boolean value of a specified flag. | |
| final void | setFlag (Block b, int mask, boolean val) |
| Set a specified boolean flag. | |
| final boolean | isLeaf (Block b) |
| Return the value of the IS_LEAF flag. | |
| final void | setLeaf (Block b, boolean v) |
| Set the value of the IS_LEAF flag. | |
| final int | getGarbage (Block b) |
| Return the value of the garbage field. | |
| final void | setGarbage (Block b, int g) |
| Set the value of the garbage field. | |
| final long | getParent (Block b) |
| Return the value of the parent field. | |
| final void | setParent (Block b, long g) |
| Set the value of the parent field. | |
| final String | databytes (byte[] b) |
| Represent strings as having a length other than 4, while representing integers as only of length 4 bytes. | |
Static Public Attributes | |
| final int | REF_SIZE = 2 |
| The number of octets in the representation of a reference to a byte offset in the data area of this block. | |
Package Functions | |
| final byte[] | get (Block b, byte[] key, int klen) throws IOException |
| A helper function to perform a single-level of the recursive search. | |
| final Block | getSearchBlock (Block b, int bs) throws IOException |
| final void | init (Block b, boolean isLeaf) throws IOException |
| Initialize an empty BNode. | |
| final void | init (boolean f) throws IOException |
| final void | checkMagic () throws IOException |
| final int | bsearch (Block b, byte[] key, int klen) throws IOException |
| Perform a binary search of the keys in the specified block, searching for the given key. | |
| final boolean | set (Block b, byte[] key, int klen, byte[] data, int doff, int dlen, boolean insOk, boolean updOk) throws IOException |
Recursive implementation of set(key, data). | |
| final boolean | delete (Block b, byte[] key) throws IOException |
Recursive implementation of delete(key). | |
| final void | checkBlock (Block b) throws IOException |
| final Block | setKey (Block b, int index, byte[] key, int klen, byte[] data, int doff, int dlen, boolean replace) throws IOException |
| Insert or replace a key in the specified block, which may or may not be a leaf block. | |
| final void | split (Block[] ba) throws IOException |
| Split this block, by creaing a new block and moving half of this block's keys into the new block. | |
| final void | splitHelp (Block[] ba, long nbno) throws IOException |
| Split helper:. | |
| final void | propogateSplit (Block[] ba) throws IOException |
| After the split operation, propagate information up the tree to the parent block about the newly created block and the new key distribution. | |
| final void | gc (Block b) throws IOException |
| Reclaim the data space occupied by deleted keys. | |
| final boolean | newLow (Block b, byte[] prevLow) throws IOException |
| When an operation results in a change in the smallest key in a block, it is necessary to inform the parent block of the change, since the parent block key for this block is required to be the key of the smallest item in this block. | |
| final int | checkSpace (Block b, int index, int klen, int dlen, boolean replace) |
| Determine if there is room in the block for a new key/data pair. | |
| final int | debugcheckSpace (Block b, int index, int klen, int dlen, boolean replace) |
| final void | forgetKeyAtPos (Block b, int index) |
| This function is scary. | |
| final boolean | deleteKeyAtPos (Block b, int index, boolean skipNewLow) throws IOException |
| Delete the specified key. | |
| final boolean | setKeyAtPos (Block b, int index, byte[] key, int klen, byte[] data, int doff, int dlen, boolean replace) throws IOException |
| Given a block and a key position, insert a new key/data pair immediately at the specified position, returning true if the key/data fit in the block. | |
| final Block | getBlock (long blockNum) throws IOException |
| final Block | getBlock () throws IOException |
| final void | display (PrintStream os, boolean recursive) throws IOException |
For debugging purposes, write a human readable version of this Bnode to the specified stream. | |
| final void | display (PrintStream os, PrintStream er, boolean recursive) throws IOException |
| final void | display (Block b, PrintStream os, boolean recursive) throws IOException |
| final void | display (Block b, PrintStream os, PrintStream er, boolean recursive) throws IOException |
Static Package Functions | |
| final int | bsearch (Block b, Comparator c, byte[] key, int klen, int lo, int hi) throws IOException |
| Perform a binary search of the keys in the specified block, searching for the given key. | |
| final long | blockRef (Block b, int index) throws IOException |
| Return the data for a specified key as an integer. | |
| final byte[] | dataAtPos (Block b, int index) |
| Given a block and a key index, return the data for that index as a new byte array. | |
| final int | dataAtPos (Block b, int index, int koff, byte[] data, int off, int len) |
| final long | longDataAtPos (Block b, int index) |
| Given a block and a key index, return the data for that index as a long. | |
| final int | existingKeyLength (Block b, int index) |
| Compute the total length of an existing key data pair, including both key and data length fields. | |
| final byte[] | keyAtPos (Block b, int index) |
| Given a block and a key index, return the key for that index as a new byte array. | |
| final int | getBytes (Block b, int pos, byte[] buf, int[] lenret) |
| final int | keyCompareAtPos (Comparator c, byte[] key, int klen, Block b, int index) throws IOException |
| Perform a key comparison with the specified key in the block. | |
| final int | getKeyLen (Block b, int keypos, int[] keystart) |
| Find the length of the specified key, as well as the byte offset to the start of the key. | |
| final int | getKeyLen (Block b, int keypos) |
| Find the length of the specified key, as well as the byte offset to the start of the key. | |
| final int | getKeyEnd (Block b, int keypos) |
| Find the length of the specified key, as well as the byte offset to the start of the key. | |
| final int | totalLength (int len) |
| Compute the total number of bytes that will be required to store the byte array 'b' plus its length code. | |
| final int | insertKeyData (Block b, byte[] key, int klen, byte[] data, int doff, int dlen) |
| Insert a key/data pair at the bottom of the data area and return its offset. | |
| final void | moveKeys (Block b, int from, int to, int length) |
| Helper function to move key indices around when adding or deleting keys. | |
| final int | writeLenLen (Block b, int bos, int len) |
| Write a length code for the specified length, working backwards in the data area, and returning the new bottom of the data area. | |
| final int | capacity (Block b) |
| Return the number of available bytes in the buffer, not including space that could be made available by performing a garbage collection. | |
| final int | getKeyIndex (Block b, int index) |
| Return the byte offset of the specified key/data pair. | |
| final void | setKeyIndex (Block b, int index, int val) |
| Set the byte offset for the specified key/data pair. | |
| final int | index (int pos) |
| final int | getBos (Block b) |
| Return the value of the count field. | |
| final String | keybytes (byte[] key) |
| Since this is used for displaying the key, we attempt to return the string itself, as long as it is composed only of printable characters. | |
| final String | keybytes (byte[] key, int off, int len) |
Package Attributes | |
| Btree | tree |
| BlockFile | file |
| long | blockRef |
Static Package Attributes | |
| final boolean | paranoid = false |
| final int | fCount = 0 |
| Number of key/data pairs in this node. | |
| final int | fDataBOS = 4 |
| Bottom of data area -- grows downward. | |
| final int | fFlags = 8 |
| Flags. | |
| final int | IS_LEAF = 0x0001 |
| final int | BNODE_MAGICF = 0xff00 |
| final int | BNODE_MAGICV = 0xbd00 |
| final int | fGarbage = 12 |
| Amount of space that could be reclaimed by repacking the node. | |
| final int | fParent = 16 |
| final int | fIndices = 24 |
| Start of key indices. | |
Private Member Functions | |
| final void | free (long blockNum) throws IOException |
| Free the resources associated with the specified block. | |
|
||||||||||||
|
Construct a node from a buffer.
Definition at line 130 of file Bnode.java. References com.quadcap.sql.index.Btree.file. |
|
||||||||||||
|
Return the data for a specified key as an integer.
Definition at line 428 of file Bnode.java. References com.quadcap.sql.index.Bnode.blockRef, com.quadcap.sql.index.Bnode.index(), and com.quadcap.sql.index.Bnode.longDataAtPos(). |
|
||||||||||||||||
|
Perform a binary search of the keys in the specified block, searching for the given key.
If the key is found in the block, return the index of the matching key. If the key isn't found, return < 0, and for the key index which is the smallest existing key greater than the given key, return
Definition at line 421 of file Bnode.java. References com.quadcap.sql.index.Btree.compare, com.quadcap.sql.index.Bnode.getCount(), and com.quadcap.sql.index.Bnode.tree. |
|
||||||||||||||||||||||||||||
|
Perform a binary search of the keys in the specified block, searching for the given key.
If the key is found in the block, return the index of the matching key. If the key isn't found, return < 0, and for the key index which is the smallest existing key greater than the given key, return
Definition at line 393 of file Bnode.java. References com.quadcap.sql.index.Bnode.bsearch(), and com.quadcap.sql.index.Bnode.keyCompareAtPos(). Referenced by com.quadcap.sql.index.Bnode.bsearch(), and com.quadcap.sql.index.Bnode.get(). |
|
|
Return the number of available bytes in the buffer, not including space that could be made available by performing a garbage collection.
Definition at line 1393 of file Bnode.java. References com.quadcap.sql.index.Bnode.capacity(), com.quadcap.sql.index.Bnode.fIndices, com.quadcap.sql.index.Bnode.getBos(), com.quadcap.sql.index.Bnode.getCount(), and com.quadcap.sql.index.Bnode.REF_SIZE. Referenced by com.quadcap.sql.index.Bnode.capacity(), com.quadcap.sql.index.Bnode.checkSpace(), com.quadcap.sql.index.Bnode.debugcheckSpace(), com.quadcap.sql.index.Bnode.gc(), and com.quadcap.sql.index.Bnode.splitHelp(). |
|
|
|
Definition at line 327 of file Bnode.java. References com.quadcap.sql.index.Bnode.BNODE_MAGICF, com.quadcap.sql.index.Bnode.BNODE_MAGICV, com.quadcap.sql.file.Cacheable.decrRefCount(), com.quadcap.sql.index.Bnode.getBlock(), com.quadcap.sql.index.Bnode.getFlags(), and com.quadcap.sql.file.Block.getPageNum(). Referenced by com.quadcap.sql.index.Btree.Btree(). |
|
||||||||||||||||||||||||
|
Determine if there is room in the block for a new key/data pair.
positive number if there would be room after a garbage collection. Included in this calculation is the deletion of the key being replaced, if Definition at line 1248 of file Bnode.java. References com.quadcap.sql.index.Bnode.capacity(), com.quadcap.sql.index.Bnode.checkSpace(), com.quadcap.sql.index.Bnode.getGarbage(), and com.quadcap.sql.index.Bnode.REF_SIZE. Referenced by com.quadcap.sql.index.Bnode.checkSpace(). |
|
||||||||||||||||||||||||||||
|
Definition at line 595 of file Bnode.java. References com.quadcap.sql.index.Bnode.getKeyIndex(), com.quadcap.sql.index.Bnode.getKeyLen(), and com.quadcap.sql.file.Block.read(). |
|
||||||||||||
|
Given a block and a key index, return the data for that index as a new byte array.
Definition at line 580 of file Bnode.java. References com.quadcap.sql.index.Bnode.dataAtPos(), com.quadcap.sql.index.Bnode.getKeyIndex(), com.quadcap.sql.index.Bnode.getKeyLen(), and com.quadcap.sql.file.Block.read(). Referenced by com.quadcap.sql.index.Bnode.dataAtPos(), and com.quadcap.sql.index.Bnode.get(). |
|
|
Represent strings as having a length other than 4, while representing integers as only of length 4 bytes.
Definition at line 1568 of file Bnode.java. References com.quadcap.sql.index.Bnode.databytes(). Referenced by com.quadcap.sql.index.Bnode.databytes(). |
|
||||||||||||||||||||||||
|
Definition at line 1262 of file Bnode.java. References com.quadcap.sql.index.Bnode.capacity(), com.quadcap.sql.index.Bnode.debugcheckSpace(), com.quadcap.sql.index.Bnode.getGarbage(), and com.quadcap.sql.index.Bnode.REF_SIZE. Referenced by com.quadcap.sql.index.Bnode.debugcheckSpace(), and com.quadcap.sql.index.Bnode.set(). |
|
||||||||||||
|
Recursive implementation of
Definition at line 504 of file Bnode.java. References com.quadcap.sql.index.Bnode.checkBlock(), com.quadcap.sql.file.Cacheable.decrRefCount(), com.quadcap.sql.index.Bnode.deleteKeyAtPos(), com.quadcap.sql.index.Bnode.getBlock(), com.quadcap.sql.index.Bnode.index(), com.quadcap.sql.index.Bnode.isLeaf(), and com.quadcap.sql.index.Bnode.paranoid. |
|
|
Implement the delete operation.
Definition at line 236 of file Bnode.java. References com.quadcap.sql.file.Cacheable.decrRefCount(), and com.quadcap.sql.index.Bnode.getBlock(). Referenced by com.quadcap.sql.index.Btree.deleteObs(). |
|
||||||||||||||||
|
Delete the specified key.
Definition at line 1299 of file Bnode.java. References com.quadcap.sql.index.Bnode.deleteKeyAtPos(), com.quadcap.sql.index.Bnode.getCount(), com.quadcap.sql.index.Bnode.getParent(), com.quadcap.sql.index.Bnode.index(), com.quadcap.sql.index.Bnode.setCount(), and com.quadcap.sql.index.Bnode.setLeaf(). Referenced by com.quadcap.sql.index.BtreeCursor.delete(), com.quadcap.sql.index.Bnode.delete(), com.quadcap.sql.index.Bnode.deleteKeyAtPos(), com.quadcap.sql.index.Bnode.newLow(), and com.quadcap.sql.index.Bnode.setKey(). |
|
||||||||||||||||||||
|
||||||||||||||||
|
Definition at line 1526 of file Bnode.java. |
|
||||||||||||||||
|
Definition at line 1515 of file Bnode.java. References com.quadcap.sql.file.Cacheable.decrRefCount(), and com.quadcap.sql.index.Bnode.getBlock(). |
|
||||||||||||
|
For debugging purposes, write a human readable version of this
Definition at line 1511 of file Bnode.java. References com.quadcap.sql.index.Bnode.display(). Referenced by com.quadcap.sql.index.Bnode.checkBlock(), com.quadcap.sql.index.Bnode.display(), com.quadcap.sql.index.Bnode.free(), com.quadcap.sql.index.Bnode.newLow(), com.quadcap.sql.index.Bnode.set(), com.quadcap.sql.index.Bnode.setKey(), com.quadcap.sql.index.Bnode.setKeyAtPos(), and com.quadcap.sql.index.Bnode.splitHelp(). |
|
||||||||||||
|
Compute the total length of an existing key data pair, including both key and data length fields.
Definition at line 634 of file Bnode.java. References com.quadcap.sql.index.Bnode.existingKeyLength(), com.quadcap.sql.index.Bnode.getKeyIndex(), and com.quadcap.sql.index.Bnode.getKeyLen(). Referenced by com.quadcap.sql.index.Bnode.checkBlock(), and com.quadcap.sql.index.Bnode.existingKeyLength(). |
|
||||||||||||
|
This function is scary.
It accounts for the fact that we're about to delete a key, by including the size of the key/data in the node's Definition at line 1289 of file Bnode.java. References com.quadcap.sql.index.Bnode.forgetKeyAtPos(), com.quadcap.sql.index.Bnode.getGarbage(), and com.quadcap.sql.index.Bnode.setGarbage(). Referenced by com.quadcap.sql.index.Bnode.forgetKeyAtPos(), and com.quadcap.sql.index.Bnode.splitHelp(). |
|
|
Free the resources associated with the specified block. If the block is a non-leaf node, free the entire subtree. Definition at line 351 of file Bnode.java. References com.quadcap.sql.index.Bnode.blockRef, com.quadcap.sql.file.Cacheable.decrRefCount(), com.quadcap.sql.index.Bnode.display(), com.quadcap.sql.index.Bnode.file, com.quadcap.sql.index.Bnode.free(), com.quadcap.sql.index.Bnode.getBlock(), com.quadcap.sql.index.Bnode.getCount(), com.quadcap.sql.file.Block.getPageNum(), and com.quadcap.sql.index.Bnode.isLeaf(). |
|
|
Free the resources associated with this block. If the block is a non-leaf node, free the entire subtree. Definition at line 343 of file Bnode.java. References com.quadcap.sql.index.Bnode.blockRef. Referenced by com.quadcap.sql.index.Btree.free(), and com.quadcap.sql.index.Bnode.free(). |
|
|
Reclaim the data space occupied by deleted keys.
Definition at line 1120 of file Bnode.java. References com.quadcap.sql.index.Bnode.capacity(), com.quadcap.sql.index.Bnode.file, com.quadcap.sql.index.Bnode.gc(), com.quadcap.sql.index.Bnode.getCount(), com.quadcap.sql.index.Bnode.getGarbage(), com.quadcap.sql.index.Bnode.paranoid, com.quadcap.sql.index.Bnode.setBos(), com.quadcap.sql.index.Bnode.setGarbage(), and com.quadcap.sql.index.Bnode.setKeyIndex(). Referenced by com.quadcap.sql.index.Bnode.gc(), and com.quadcap.sql.index.Bnode.splitHelp(). |
|
||||||||||||||||
|
A helper function to perform a single-level of the recursive search.
Definition at line 251 of file Bnode.java. References com.quadcap.sql.index.Bnode.bsearch(), com.quadcap.sql.index.Bnode.checkBlock(), com.quadcap.sql.index.Bnode.dataAtPos(), com.quadcap.sql.file.Cacheable.decrRefCount(), com.quadcap.sql.index.Bnode.getSearchBlock(), com.quadcap.sql.index.Bnode.isLeaf(), and com.quadcap.sql.index.Bnode.paranoid. |
|
||||||||||||
|
Implement the get operation.
Definition at line 179 of file Bnode.java. References com.quadcap.sql.index.Bnode.blockRef, com.quadcap.sql.file.Cacheable.decrRefCount(), com.quadcap.sql.index.Bnode.get(), and com.quadcap.sql.index.Bnode.getBlock(). Referenced by com.quadcap.sql.index.Bnode.get(). |
|
|
|
|
Return the value of the count field.
Definition at line 1432 of file Bnode.java. References com.quadcap.sql.index.Bnode.fDataBOS, com.quadcap.sql.index.Bnode.getBos(), and com.quadcap.sql.file.Block.readInt(). Referenced by com.quadcap.sql.index.Bnode.capacity(), com.quadcap.sql.index.Bnode.checkBlock(), com.quadcap.sql.index.Bnode.getBos(), and com.quadcap.sql.index.Bnode.insertKeyData(). |
|
||||||||||||||||||||
|
Definition at line 666 of file Bnode.java. References com.quadcap.sql.index.Bnode.getBytes(), com.quadcap.sql.file.Block.read(), and com.quadcap.sql.file.Block.readByte(). Referenced by com.quadcap.sql.index.Bnode.getBytes(). |
|
|
||||||||||||
|
Return the boolean value of a specified flag.
Definition at line 1462 of file Bnode.java. References com.quadcap.sql.index.Bnode.getFlag(). Referenced by com.quadcap.sql.index.Bnode.getFlag(). |
|
|
Return the value of the flags field.
Definition at line 1452 of file Bnode.java. References com.quadcap.sql.index.Bnode.fFlags, com.quadcap.sql.index.Bnode.getFlags(), and com.quadcap.sql.file.Block.readInt(). Referenced by com.quadcap.sql.index.Bnode.checkMagic(), and com.quadcap.sql.index.Bnode.getFlags(). |
|
|
Return the value of the garbage field.
Definition at line 1485 of file Bnode.java. References com.quadcap.sql.index.Bnode.fGarbage, com.quadcap.sql.index.Bnode.getGarbage(), and com.quadcap.sql.file.Block.readInt(). Referenced by com.quadcap.sql.index.Bnode.checkBlock(), com.quadcap.sql.index.Bnode.checkSpace(), com.quadcap.sql.index.Bnode.debugcheckSpace(), com.quadcap.sql.index.Bnode.forgetKeyAtPos(), com.quadcap.sql.index.Bnode.gc(), com.quadcap.sql.index.Bnode.getGarbage(), and com.quadcap.sql.index.Bnode.splitHelp(). |
|
||||||||||||||||||||||||
|
Given a block and a key index, return the key for that index as a new byte array.
Definition at line 695 of file Bnode.java. References com.quadcap.sql.index.Bnode.getKeyAndData(), and com.quadcap.sql.index.Bnode.getKeyIndex(). Referenced by com.quadcap.sql.index.Bnode.getKeyAndData(). |
|
||||||||||||
|
Find the length of the specified key, as well as the byte offset to the start of the key.
Definition at line 779 of file Bnode.java. References com.quadcap.sql.index.Bnode.getKeyEnd(), and com.quadcap.sql.file.Block.readByte(). Referenced by com.quadcap.sql.index.Bnode.getKeyEnd(), and com.quadcap.sql.index.Bnode.longDataAtPos(). |
|
||||||||||||
|
Return the byte offset of the specified key/data pair.
Definition at line 1412 of file Bnode.java. References com.quadcap.sql.index.Bnode.getKeyIndex(), and com.quadcap.sql.file.Block.readShort(). Referenced by com.quadcap.sql.index.Bnode.dataAtPos(), com.quadcap.sql.index.Bnode.existingKeyLength(), com.quadcap.sql.index.Bnode.getKeyAndData(), com.quadcap.sql.index.Bnode.getKeyIndex(), com.quadcap.sql.index.Bnode.keyAtPos(), com.quadcap.sql.index.Bnode.keyCompareAtPos(), and com.quadcap.sql.index.Bnode.longDataAtPos(). |
|
||||||||||||
|
Find the length of the specified key, as well as the byte offset to the start of the key.
Definition at line 759 of file Bnode.java. References com.quadcap.sql.file.Block.readByte(). |
|
||||||||||||||||
|
Find the length of the specified key, as well as the byte offset to the start of the key.
Definition at line 738 of file Bnode.java. References com.quadcap.sql.index.Bnode.getKeyLen(), and com.quadcap.sql.file.Block.readByte(). Referenced by com.quadcap.sql.index.Bnode.dataAtPos(), < |