jdbm.btree
Class BPage<K,V>

java.lang.Object
  extended by jdbm.btree.BPage<K,V>
All Implemented Interfaces:
Serializable, Serializer

public class BPage<K,V>
extends Object
implements Serializer

Page of a Btree.

The page contains a number of key-value pairs. Keys are ordered to allow dichotomic search.

If the page is a leaf page, the keys and values are user-defined and represent entries inserted by the user.

If the page is non-leaf, each key represents the greatest key in the underlying BPages and the values are recids pointing to the children BPages. The only exception is the rightmost BPage, which is considered to have an "infinite" key value, meaning that any insert will be to the left of this pseudo-key

Author:
Alex Boisvert
See Also:
Serialized Form

Field Summary
protected  long[] children
          Children pages (recids) associated with keys.
protected  int first
          Index of first used item at the page
protected  boolean isLeaf
          Flag indicating if this is a leaf BPage.
protected  K[] keys
          Keys of children nodes
protected  long next
          Next leaf BPage (only if this BPage is a leaf)
static AtomicInteger outstandingBrowsers
           
protected  long previous
          Previous leaf BPage (only if this BPage is a leaf)
protected  long recordId
          This BPage's record ID in the PageManager.
protected  V[] values
          Values associated with keys.
 
Constructor Summary
BPage()
          No-argument constructor used by serialization.
 
Method Summary
 BPage<K,V> deserialize(byte[] serialized)
          Deserialize the content of an object from a byte array.
 long getRecordId()
           
 byte[] serialize(Object obj)
          Serialize the content of an object into a byte array.
 void setRecordId(long recordId)
          Set the recordId
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

recordId

protected transient long recordId
This BPage's record ID in the PageManager.


isLeaf

protected boolean isLeaf
Flag indicating if this is a leaf BPage.


keys

protected K[] keys
Keys of children nodes


values

protected V[] values
Values associated with keys. (Only valid if leaf BPage)


children

protected long[] children
Children pages (recids) associated with keys. (Only valid if non-leaf BPage)


first

protected int first
Index of first used item at the page


previous

protected long previous
Previous leaf BPage (only if this BPage is a leaf)


next

protected long next
Next leaf BPage (only if this BPage is a leaf)


outstandingBrowsers

public static AtomicInteger outstandingBrowsers
Constructor Detail

BPage

public BPage()
No-argument constructor used by serialization.

Method Detail

getRecordId

public long getRecordId()
Returns:
The record ID

setRecordId

public void setRecordId(long recordId)
Set the recordId

Parameters:
recordId - The recordId

deserialize

public BPage<K,V> deserialize(byte[] serialized)
                       throws IOException
Deserialize the content of an object from a byte array.

Specified by:
deserialize in interface Serializer
Parameters:
serialized - Byte array representation of the object
Returns:
deserialized object
Throws:
IOException

serialize

public byte[] serialize(Object obj)
                 throws IOException
Serialize the content of an object into a byte array.

Specified by:
serialize in interface Serializer
Parameters:
obj - Object to serialize
Returns:
a byte array representing the object's state
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2003-2012 The Apache Software Foundation. All Rights Reserved.