com.caucho.db.store
Class Block

java.lang.Object
  extended by com.caucho.db.store.Block
All Implemented Interfaces:
SyncCacheListener
Direct Known Subclasses:
ReadBlock, WriteBlock

public abstract class Block
extends java.lang.Object
implements SyncCacheListener

Represents a versioned row


Field Summary
protected static FreeList<byte[]> _freeBuffers
           
 
Method Summary
 boolean allocate()
          Allocates the block for a query.
 void commit()
          Handle any database writes necessary at commit time.
 void free()
          Frees a block from a query.
protected  void freeImpl()
          Frees any resources.
 long getBlockId()
          Returns the block's id.
abstract  byte[] getBuffer()
          Returns the block's buffer.
 Lock getLock()
           
 void invalidate()
          Marks the block's data as invalid.
 boolean isDirty()
          Returns true if the block needs writing
 boolean isFlushDirtyOnCommit()
          Returns true if the block should be flushed on a commit.
 boolean isFree()
          Return true if this is a free block.
 void read()
          Reads into the block.
 void setDirty(int min, int max)
          Marks the block's data as dirty
 void setFlushDirtyOnCommit(boolean isFlush)
          True if the block should be flushed on a commit.
 void syncRemoveEvent()
          Called when the block is removed from the cache.
 java.lang.String toString()
           
 void write()
          Forces a write of the data (should be private?)
protected  void writeImpl(int offset, int length)
          Write the dirty block.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_freeBuffers

protected static final FreeList<byte[]> _freeBuffers
Method Detail

isFlushDirtyOnCommit

public boolean isFlushDirtyOnCommit()
Returns true if the block should be flushed on a commit.


setFlushDirtyOnCommit

public void setFlushDirtyOnCommit(boolean isFlush)
True if the block should be flushed on a commit.


allocate

public boolean allocate()
Allocates the block for a query.


getBlockId

public long getBlockId()
Returns the block's id.


getLock

public Lock getLock()

getBuffer

public abstract byte[] getBuffer()
Returns the block's buffer.


read

public void read()
          throws java.io.IOException
Reads into the block.

Throws:
java.io.IOException

commit

public void commit()
            throws java.io.IOException
Handle any database writes necessary at commit time. If isFlushDirtyOnCommit() is true, this will write the data to the backing file.

Throws:
java.io.IOException

write

public void write()
           throws java.io.IOException
Forces a write of the data (should be private?)

Throws:
java.io.IOException

writeImpl

protected void writeImpl(int offset,
                         int length)
                  throws java.io.IOException
Write the dirty block.

Throws:
java.io.IOException

invalidate

public void invalidate()
Marks the block's data as invalid.


setDirty

public void setDirty(int min,
                     int max)
Marks the block's data as dirty


isDirty

public boolean isDirty()
Returns true if the block needs writing


isFree

public boolean isFree()
Return true if this is a free block.


free

public final void free()
Frees a block from a query.


syncRemoveEvent

public final void syncRemoveEvent()
Called when the block is removed from the cache.

Specified by:
syncRemoveEvent in interface SyncCacheListener

freeImpl

protected void freeImpl()
Frees any resources.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object