org.xerial.db.heap
Class HeapPage

java.lang.Object
  extended by org.xerial.db.heap.HeapPage
All Implemented Interfaces:
Iterable<Tuple>

public class HeapPage
extends Object
implements Iterable<Tuple>

Heap pages support sequential data appends to the database. Page Layout:

 ----------------------
 |CommonPageHeader 
 |numEntries       
 |entrySizeTotal
 | (entries: ([entry size:VariableLengthInteger, entry data ...]) )
 |  ....
 | 
 |
 | [ pointers to entries (in sorted order) ]
 ----------------------
 

Author:
leo

Constructor Summary
HeapPage(int bufferSize)
           
 
Method Summary
 void append(Tuple tuple)
          Appends the tuple to this heap page
 int getHeaderSize()
           
 Iterator<Tuple> iterator()
           
 void loadFrom(Buffer pageBuffer, TupleFactory tupleFactory)
          Loads the heap contents from the buffer
 void saveTo(Buffer pageBuffer)
          Marshaling the heap contents, and write them to the page buffer
 void sortTuples(TupleComparator comparator)
          Sort the tuple in this heap page according to the given comparator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeapPage

public HeapPage(int bufferSize)
Method Detail

getHeaderSize

public int getHeaderSize()

append

public void append(Tuple tuple)
            throws DBException
Appends the tuple to this heap page

Parameters:
tuple -
Throws:
DBException - when the page has no sufficient space for this tuple

sortTuples

public void sortTuples(TupleComparator comparator)
Sort the tuple in this heap page according to the given comparator

Parameters:
comparator - TupleComparator defines total order of the tuples

loadFrom

public void loadFrom(Buffer pageBuffer,
                     TupleFactory tupleFactory)
              throws DBException
Loads the heap contents from the buffer

Parameters:
pageBuffer - the buffer
tupleFactory - factory that creates tuples from raw byte arrays
Throws:
DBException - when page type is not heap

saveTo

public void saveTo(Buffer pageBuffer)
Marshaling the heap contents, and write them to the page buffer

Parameters:
pageBuffer -

iterator

public Iterator<Tuple> iterator()
Specified by:
iterator in interface Iterable<Tuple>


Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.1 Japan License.