Java Doc for Bnode.java in  » Database-DBMS » Quadcap-Embeddable-Database » com » quadcap » sql » index » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » Quadcap Embeddable Database » com.quadcap.sql.index 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.quadcap.sql.index.Bnode

Bnode
public class Bnode (Code)
This class represents a node in the btree.

Things to think about:

  • Key Compression using dictionary? With a large enough node, say 4 or 8 k, you could perform a block compression
  • Key Endianness (X.500 keys are LSB, most others are MSB)
  • Large data stored in overflow areas (blockstream)
  • Thread-safeness
  • Improve block garbage collection (it appears that some deleted keys aren't properly counted as garbage!)

author:
   Stan Bailes


Field Summary
final static  intBNODE_MAGICF
    
final static  intBNODE_MAGICV
    
final static  intIS_LEAF
    
final public static  intREF_SIZE
     The number of octets in the representation of a reference to a byte offset in the data area of this block.
 longblockRef
    
final static  intfCount
     Number of key/data pairs in this node.
final static  intfDataBOS
     Bottom of data area -- grows downward.
final static  intfFlags
    
final static  intfGarbage
     Amount of space that could be reclaimed by repacking the node.
final static  intfIndices
     Start of key indices.
final static  intfParent
    
 BlockFilefile
    
final static  booleanparanoid
    
 Btreetree
    

Constructor Summary
public  Bnode(Btree tree, long blockRef)
     Construct a node from a buffer.

Method Summary
final static  longblockRef(Block b, int index)
    
final static  intbsearch(Block b, Comparator c, byte[] key, int klen, int lo, int hi)
     Perform a binary search of the keys in the specified block, searching for the given key.
final  intbsearch(Block b, byte[] key, int klen)
     Perform a binary search of the keys in the specified block, searching for the given key.
final static  intcapacity(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  voidcheckBlock(Block b)
    
final  voidcheckMagic()
    
final  intcheckSpace(Block b, int index, int klen, int dlen, boolean replace)
     Determine if there is room in the block for a new key/data pair.
Parameters:
  b - the block to operate on
Parameters:
  index - the index of the key that is being replaced,if replace is true.
Parameters:
  klen - the search key length
Parameters:
  dlen - the length of the data associated with the key
Parameters:
  replace - true if an existing key/data pair is tobe replaced by the new key, false otherwise.
final static  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 static  intdataAtPos(Block b, int index, int koff, byte[] data, int off, int len)
    
final public static  Stringdatabytes(byte[] b)
     Represent strings as having a length other than 4, while representing integers as only of length 4 bytes.
final  intdebugcheckSpace(Block b, int index, int klen, int dlen, boolean replace)
    
final public  booleandelete(byte[] key)
     Implement the delete operation.
final  booleandelete(Block b, byte[] key)
     Recursive implementation of delete(key).
final  booleandeleteKeyAtPos(Block b, int index, boolean skipNewLow)
     Delete the specified key.
final  voiddisplay(PrintStream os, boolean recursive)
     For debugging purposes, write a human readable version of this Bnode to the specified stream.
final  voiddisplay(PrintStream os, PrintStream er, boolean recursive)
    
final  voiddisplay(Block b, PrintStream os, boolean recursive)
    
final  voiddisplay(Block b, PrintStream os, PrintStream er, boolean recursive)
    
final static  intexistingKeyLength(Block b, int index)
     Compute the total length of an existing key data pair, including both key and data length fields.
final  voidforgetKeyAtPos(Block b, int index)
     This function is scary.
final public  voidfree()
     Free the resources associated with this block.
final  voidgc(Block b)
     Reclaim the data space occupied by deleted keys.
final public  byte[]get(byte[] key, int klen)
     Implement the get operation.
final  byte[]get(Block b, byte[] key, int klen)
     A helper function to perform a single-level of the recursive search.
final  BlockgetBlock(long blockNum)
    
final  BlockgetBlock()
    
final static  intgetBos(Block b)
     Return the value of the count field.
final static  intgetBytes(Block b, int pos, byte[] buf, int[] lenret)
    
final public static  intgetCount(Block b)
     Return the value of the bos field.
final public static  booleangetFlag(Block b, int mask)
     Return the boolean value of a specified flag.
final public static  intgetFlags(Block b)
     Return the value of the flags field.
final public static  intgetGarbage(Block b)
     Return the value of the garbage field.
final public static  booleangetKeyAndData(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.
Parameters:
  b - the block on which to operate.
Parameters:
  index - the index of the item for which the key is to be retrieved
Parameters:
  buf - the buffer into which the key bytes should be places
Parameters:
  off - the offset into the buffer
Parameters:
  len - the maximum number of bytes to write to the buffer the number of bytes returned, if sucessful.
final static  intgetKeyEnd(Block b, int keypos)
     Find the length of the specified key, as well as the byte offset to the start of the key.
Parameters:
  b - the B-node
Parameters:
  keypos - the buffer offset where the key/data pair starts.
final static  intgetKeyIndex(Block b, int index)
     Return the byte offset of the specified key/data pair.
final static  intgetKeyLen(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 static  intgetKeyLen(Block b, int keypos)
     Find the length of the specified key, as well as the byte offset to the start of the key.
Parameters:
  b - the B-node
Parameters:
  keypos - the buffer offset where the key/data pair starts.
final public static  longgetParent(Block b)
     Return the value of the parent field.
final  BlockgetSearchBlock(Block b, int bs)
    
final static  intindex(int pos)
    
final  voidinit(Block b, boolean isLeaf)
     Initialize an empty BNode.
final  voidinit(boolean f)
    
final static  intinsertKeyData(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 public static  booleanisLeaf(Block b)
     Return the value of the IS_LEAF flag.
final static  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 static  intkeyCompareAtPos(Comparator c, byte[] key, int klen, Block b, int index)
     Perform a key comparison with the specified key in the block.
final static  Stringkeybytes(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 static  Stringkeybytes(byte[] key, int off, int len)
    
final static  longlongDataAtPos(Block b, int index)
     Given a block and a key index, return the data for that index as a long.
final static  voidmoveKeys(Block b, int from, int to, int length)
     Helper function to move key indices around when adding or deleting keys.
final  booleannewLow(Block b, byte[] prevLow)
     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.
Parameters:
  b - the block containing the new lowest key
Parameters:
  prevLow - the key which was previously the lowest key.
final  voidpropogateSplit(Block[] ba)
     After the split operation, propagate information up the tree to the parent block about the newly created block and the new key distribution.
final public  booleanset(byte[] key, int klen, byte[] data, int doff, int dlen, boolean insOk, boolean updOk)
     Implement the set operation.
final  booleanset(Block b, byte[] key, int klen, byte[] data, int doff, int dlen, boolean insOk, boolean updOk)
     Recursive implementation of set(key, data).

Precondition: The caller must already have a write-lock on b.

final public static  voidsetBos(Block b, int bos)
     Set the value of the bos field.
final public static  voidsetCount(Block b, int count)
     Set the value of the count field.
final public static  voidsetFlag(Block b, int mask, boolean val)
     Set a specified boolean flag.
final public static  voidsetFlags(Block b, int flags)
     Set the value of the flags field.
final public static  voidsetGarbage(Block b, int g)
     Set the value of the garbage field.
final  BlocksetKey(Block b, int index, byte[] key, int klen, byte[] data, int doff, int dlen, boolean replace)
     Insert or replace a key in the specified block, which may or may not be a leaf block.
final  booleansetKeyAtPos(Block b, int index, byte[] key, int klen, byte[] data, int doff, int dlen, boolean replace)
     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 static  voidsetKeyIndex(Block b, int index, int val)
     Set the byte offset for the specified key/data pair.
final public static  voidsetLeaf(Block b, boolean v)
     Set the value of the IS_LEAF flag.
final public static  voidsetParent(Block b, long g)
     Set the value of the parent field.
public  intsize()
     Return the number of keys in this subtree.
public  intsize(Block b)
    
final  voidsplit(Block[] ba)
     Split this block, by creaing a new block and moving half of this block's keys into the new block.
final  voidsplitHelp(Block[] ba, long nbno)
    
final static  inttotalLength(int len)
     Compute the total number of bytes that will be required to store the byte array 'b' plus its length code.
final static  intwriteLenLen(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.

Field Detail
BNODE_MAGICF
final static int BNODE_MAGICF(Code)



BNODE_MAGICV
final static int BNODE_MAGICV(Code)



IS_LEAF
final static int IS_LEAF(Code)



REF_SIZE
final public static int REF_SIZE(Code)
The number of octets in the representation of a reference to a byte offset in the data area of this block. Currently, bnode blocks can't be larger than 65536 because of the two byte ref size.



blockRef
long blockRef(Code)



fCount
final static int fCount(Code)
Number of key/data pairs in this node.



fDataBOS
final static int fDataBOS(Code)
Bottom of data area -- grows downward.



fFlags
final static int fFlags(Code)
Flags



fGarbage
final static int fGarbage(Code)
Amount of space that could be reclaimed by repacking the node. When keys are deleted, we don't immediately remove the key/data pair in the data area. Instead, we remove the pointer the pair from the key index list, and record (here) the size of the key/data pair. Later, when the block becomes full, we reclaim this space by repacking the data area to eliminate the holes.



fIndices
final static int fIndices(Code)
Start of key indices.



fParent
final static int fParent(Code)



file
BlockFile file(Code)



paranoid
final static boolean paranoid(Code)



tree
Btree tree(Code)




Constructor Detail
Bnode
public Bnode(Btree tree, long blockRef)(Code)
Construct a node from a buffer.
Parameters:
  tree - the Btree containing this node
Parameters:
  blockRef - the block number in file of this node.




Method Detail
blockRef
final static long blockRef(Block b, int index) throws IOException(Code)
Return the data for a specified key as an integer



bsearch
final static int bsearch(Block b, Comparator c, byte[] key, int klen, int lo, int hi) throws IOException(Code)
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 0 - (index+1).
Parameters:
  b - the block to be searched.
Parameters:
  key - the search key
Parameters:
  lo - index of smallest element in search region
Parameters:
  hi - index of largest element in search region if found, the index of the matching key/data pair. If notfound, return the index where the data would be foundas an expression of the form:

0 - (index + 1)




bsearch
final int bsearch(Block b, byte[] key, int klen) throws IOException(Code)
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 0 - (index+1).
Parameters:
  b - the block to be searched.
Parameters:
  key - the search key if found, the index of the matching key/data pair. If notfound, return the index where the data would be foundas an expression of the form:

0 - (index + 1)




capacity
final static int capacity(Block b)(Code)
Return the number of available bytes in the buffer, not including space that could be made available by performing a garbage collection.



checkBlock
final void checkBlock(Block b) throws IOException(Code)



checkMagic
final void checkMagic() throws IOException(Code)



checkSpace
final int checkSpace(Block b, int index, int klen, int dlen, boolean replace)(Code)
Determine if there is room in the block for a new key/data pair.
Parameters:
  b - the block to operate on
Parameters:
  index - the index of the key that is being replaced,if replace is true.
Parameters:
  klen - the search key length
Parameters:
  dlen - the length of the data associated with the key
Parameters:
  replace - true if an existing key/data pair is tobe replaced by the new key, false otherwise. negative number if there is no room for the new data.

zero if there is room for the new data.

positive number if there would be room after a garbagecollection. Included in this calculation is the deletionof the key being replaced, if replace is true.




dataAtPos
final static byte[] dataAtPos(Block b, int index)(Code)
Given a block and a key index, return the data for that index as a new byte array.
Parameters:
  b - the block on which to operate.
Parameters:
  index - the index of the item for which the data is to be retrieved the data for the key at the specified position in the node.



dataAtPos
final static int dataAtPos(Block b, int index, int koff, byte[] data, int off, int len)(Code)



databytes
final public static String databytes(byte[] b)(Code)
Represent strings as having a length other than 4, while representing integers as only of length 4 bytes.
Parameters:
  b - the string of bytes to convert A string containing either a 4-byte integer conversion or astring 'keybytes' filter.



debugcheckSpace
final int debugcheckSpace(Block b, int index, int klen, int dlen, boolean replace)(Code)



delete
final public boolean delete(byte[] key) throws IOException(Code)
Implement the delete operation.
Parameters:
  key - the key



delete
final boolean delete(Block b, byte[] key) throws IOException(Code)
Recursive implementation of delete(key).
Parameters:
  b - the block to be searched
Parameters:
  key - the search key true if the key already existed before the delete,false otherwise.



deleteKeyAtPos
final boolean deleteKeyAtPos(Block b, int index, boolean skipNewLow) throws IOException(Code)
Delete the specified key. true if the block is now empty, has been freed, and weshould avoid touching it...



display
final void display(PrintStream os, boolean recursive) throws IOException(Code)
For debugging purposes, write a human readable version of this Bnode to the specified stream.



display
final void display(PrintStream os, PrintStream er, boolean recursive) throws IOException(Code)



display
final void display(Block b, PrintStream os, boolean recursive) throws IOException(Code)



display
final void display(Block b, PrintStream os, PrintStream er, boolean recursive) throws IOException(Code)



existingKeyLength
final static int existingKeyLength(Block b, int index)(Code)
Compute the total length of an existing key data pair, including both key and data length fields.
Parameters:
  b - the block on which to operate.
Parameters:
  index - the index of the item for which the data is to be retrieved the total number of data area bytes consumed by this item.



forgetKeyAtPos
final void forgetKeyAtPos(Block b, int index)(Code)
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 garbage field, but it doesn't actually delete the key. Be careful.



free
final public void free() throws IOException(Code)
Free the resources associated with this block. If the block is a non-leaf node, free the entire subtree.



gc
final void gc(Block b) throws IOException(Code)
Reclaim the data space occupied by deleted keys.



get
final public byte[] get(byte[] key, int klen) throws IOException(Code)
Implement the get operation.
Parameters:
  key - the search key if the get succeeds, the data is returned as a byte array;if the get fails, null is returned.



get
final byte[] get(Block b, byte[] key, int klen) throws IOException(Code)
A helper function to perform a single-level of the recursive search.
Parameters:
  b - the block to be searched.
Parameters:
  key - the search key if found, the data, else null



getBlock
final Block getBlock(long blockNum) throws IOException(Code)



getBlock
final Block getBlock() throws IOException(Code)



getBos
final static int getBos(Block b)(Code)
Return the value of the count field.



getBytes
final static int getBytes(Block b, int pos, byte[] buf, int[] lenret)(Code)



getCount
final public static int getCount(Block b)(Code)
Return the value of the bos field.



getFlag
final public static boolean getFlag(Block b, int mask)(Code)
Return the boolean value of a specified flag.



getFlags
final public static int getFlags(Block b)(Code)
Return the value of the flags field.



getGarbage
final public static int getGarbage(Block b)(Code)
Return the value of the garbage field.



getKeyAndData
final public static boolean getKeyAndData(Block b, int index, byte[] k, byte[] d, int[] lengths)(Code)
Given a block and a key index, return the key for that index as a new byte array.
Parameters:
  b - the block on which to operate.
Parameters:
  index - the index of the item for which the key is to be retrieved
Parameters:
  buf - the buffer into which the key bytes should be places
Parameters:
  off - the offset into the buffer
Parameters:
  len - the maximum number of bytes to write to the buffer the number of bytes returned, if sucessful. If the bufferisn't big enough, we return a negative number '0 - k', where'k' is the actual key length.



getKeyEnd
final static int getKeyEnd(Block b, int keypos)(Code)
Find the length of the specified key, as well as the byte offset to the start of the key.
Parameters:
  b - the B-node
Parameters:
  keypos - the buffer offset where the key/data pair starts. two 16-bit integers {start, len} encoded in a 32 bit int.



getKeyIndex
final static int getKeyIndex(Block b, int index)(Code)
Return the byte offset of the specified key/data pair.
Parameters:
  b - the Bnode containing the key
Parameters:
  index - the index of the specified key/data pair.



getKeyLen
final static int getKeyLen(Block b, int keypos, int[] keystart)(Code)
Find the length of the specified key, as well as the byte offset to the start of the key.
Parameters:
  b - the B-node
Parameters:
  keypos - the buffer offset where the key/data pair starts.
Parameters:
  keystart - an out parameter, used to return the bufferoffset where the actual key begins.



getKeyLen
final static int getKeyLen(Block b, int keypos)(Code)
Find the length of the specified key, as well as the byte offset to the start of the key.
Parameters:
  b - the B-node
Parameters:
  keypos - the buffer offset where the key/data pair starts. the key length



getParent
final public static long getParent(Block b)(Code)
Return the value of the parent field.



getSearchBlock
final Block getSearchBlock(Block b, int bs) throws IOException(Code)



index
final static int index(int pos)(Code)



init
final void init(Block b, boolean isLeaf) throws IOException(Code)
Initialize an empty BNode.

PRECONDITION:Hold lock on b.
Parameters:
  b - the block to be initialized.




init
final void init(boolean f) throws IOException(Code)



insertKeyData
final static int insertKeyData(Block b, byte[] key, int klen, byte[] data, int doff, int dlen)(Code)
Insert a key/data pair at the bottom of the data area and return its offset. This method does NOT check the capacity of the buffer -- it is assumed that the caller has already ensured that enough space is available.
Parameters:
  b - the block to operate on
Parameters:
  key - the search key
Parameters:
  data - the data associated with the key



isLeaf
final public static boolean isLeaf(Block b)(Code)
Return the value of the IS_LEAF flag.



keyAtPos
final static byte[] keyAtPos(Block b, int index)(Code)
Given a block and a key index, return the key for that index as a new byte array.
Parameters:
  b - the block on which to operate.
Parameters:
  index - the index of the item for which the key is to be retrieved



keyCompareAtPos
final static int keyCompareAtPos(Comparator c, byte[] key, int klen, Block b, int index) throws IOException(Code)
Perform a key comparison with the specified key in the block.
Parameters:
  c - the compare function
Parameters:
  key - the compare key
Parameters:
  b - the block to be compared
Parameters:
  index - the position of the key to be compared to the compare key the integer compare value (usu: -1, 0, 1)



keybytes
final static String keybytes(byte[] key)(Code)
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. If it contains any "non-printable" characters, it is instead formatted in hex/ascii dump form.
Parameters:
  b - the bytes form of the key a displayable representation of the key.



keybytes
final static String keybytes(byte[] key, int off, int len)(Code)



longDataAtPos
final static long longDataAtPos(Block b, int index)(Code)
Given a block and a key index, return the data for that index as a long.
Parameters:
  b - the block on which to operate.
Parameters:
  index - the index of the item for which the data is to be retrieved the data for the key at the specified position in the node.



moveKeys
final static void moveKeys(Block b, int from, int to, int length)(Code)
Helper function to move key indices around when adding or deleting keys.



newLow
final boolean newLow(Block b, byte[] prevLow) throws IOException(Code)
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.
Parameters:
  b - the block containing the new lowest key
Parameters:
  prevLow - the key which was previously the lowest key. true if block b is now empty, and has beenfreed and unlinked from the tree. Don't touch this blockany more!



propogateSplit
final void propogateSplit(Block[] ba) throws IOException(Code)
After the split operation, propagate information up the tree to the parent block about the newly created block and the new key distribution.
Parameters:
  ba - a two-element array, with ba[0] beingthe pre-split block, and ba[1] the new block



set
final public boolean set(byte[] key, int klen, byte[] data, int doff, int dlen, boolean insOk, boolean updOk) throws IOException(Code)
Implement the set operation.
Parameters:
  key - the key
Parameters:
  data - the data



set
final boolean set(Block b, byte[] key, int klen, byte[] data, int doff, int dlen, boolean insOk, boolean updOk) throws IOException(Code)
Recursive implementation of set(key, data).

Precondition: The caller must already have a write-lock on b.
Parameters:
  b - the block to be searched
Parameters:
  key - the search key
Parameters:
  data - the data associated with the key true if the key already existed before the set, false otherwise.




setBos
final public static void setBos(Block b, int bos)(Code)
Set the value of the bos field.



setCount
final public static void setCount(Block b, int count)(Code)
Set the value of the count field.



setFlag
final public static void setFlag(Block b, int mask, boolean val)(Code)
Set a specified boolean flag.



setFlags
final public static void setFlags(Block b, int flags)(Code)
Set the value of the flags field.



setGarbage
final public static void setGarbage(Block b, int g)(Code)
Set the value of the garbage field.



setKey
final Block setKey(Block b, int index, byte[] key, int klen, byte[] data, int doff, int dlen, boolean replace) throws IOException(Code)
Insert or replace a key in the specified block, which may or may not be a leaf block. Handle split operations: if a split is required, determine which post-split block this key should be added to. Also, if the new key happens to be key zero (i.e., the lowest valued key in this block), then adjust the parent's reference to this block accordingly. Although, maybe that can't happen?

PRECONDITION: Lock/ref on block b

POSTCONDITION: Lock/ref on block b the block into which the key was actually stored. Thiswill be different from b if a split wasnecessary.




setKeyAtPos
final boolean setKeyAtPos(Block b, int index, byte[] key, int klen, byte[] data, int doff, int dlen, boolean replace) throws IOException(Code)
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. If the incoming data won't fit, don't modify the block and return false.
Parameters:
  b - the block to be modified.
Parameters:
  index - the position in the key array
Parameters:
  key - the key
Parameters:
  data - the data true if the insert was performed successfully, falseif not because of, e.g., "wont fit".



setKeyIndex
final static void setKeyIndex(Block b, int index, int val)(Code)
Set the byte offset for the specified key/data pair.
Parameters:
  b - the Bnode containing the key
Parameters:
  index - the index of the specified key/data pair.
Parameters:
  val - the byte offset of the specified key/data pair.



setLeaf
final public static void setLeaf(Block b, boolean v)(Code)
Set the value of the IS_LEAF flag.



setParent
final public static void setParent(Block b, long g)(Code)
Set the value of the parent field.



size
public int size() throws IOException(Code)
Return the number of keys in this subtree. This implicitly only counts entries in the leaf nodes.



size
public int size(Block b) throws IOException(Code)



split
final void split(Block[] ba) throws IOException(Code)
Split this block, by creaing a new block and moving half of this block's keys into the new block. Then, add a new key to the parent block to reflect the new block, and adjust the parent's old reference to this block to reflect the new key distribution.

PRECONDITION: We have a ref/lock on ba[0]

POSTCONDITION: We have a ref on ba[1]
Parameters:
  ba - a two-element array, with ba[0] beingthe pre-split block, and ba[1] the new block




splitHelp
final void splitHelp(Block[] ba, long nbno) throws IOException(Code)
Split helper:

PRECONDITION: Ref/lock on both ba[0], ba[1]




totalLength
final static int totalLength(int len)(Code)
Compute the total number of bytes that will be required to store the byte array 'b' plus its length code.
Parameters:
  b - the byte array the length of the byte array plus the length of the lengthcode.



writeLenLen
final static int writeLenLen(Block b, int bos, int len)(Code)
Write a length code for the specified length, working backwards in the data area, and returning the new bottom of the data area.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.