com.caucho.db.block
Class Block

java.lang.Object
  extended by com.caucho.db.block.Block
All Implemented Interfaces:
SyncCacheListener

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

Represents a versioned row


Method Summary
 boolean allocate()
          Allocates the block for a query.
 void commit()
          Handle any database writes necessary at commit time.
 void deallocate()
           
 void free()
          Frees a block from a query.
 long getBlockId()
          Returns the block's id.
 byte[] getBuffer()
          Returns the block's buffer.
 java.util.concurrent.locks.Lock getReadLock()
           
 BlockStore getStore()
          Returns the block's table.
 int getUseCount()
           
 java.util.concurrent.locks.Lock getWriteLock()
           
 boolean isDestroyed()
           
 boolean isDirty()
          Returns true if the block needs writing
 boolean isFlushDirtyOnCommit()
          Returns true if the block should be flushed on a commit.
 boolean isIndex()
           
 boolean isValid()
           
 void read()
          Reads into the block.
 void saveAllocation()
           
 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.
 boolean startLruRemove()
          Called by the LRU cache before removing to see if the item can actually be removed.
 void syncLruRemoveEvent()
          Called when the block is removed from the cache.
 void syncRemoveEvent()
          Called when the block is removed deliberately from the cache.
 java.lang.String toString()
           
 void validateIsIndex()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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.


isIndex

public boolean isIndex()

validateIsIndex

public void validateIsIndex()

getStore

public BlockStore getStore()
Returns the block's table.


getBlockId

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


getReadLock

public final java.util.concurrent.locks.Lock getReadLock()

getWriteLock

public final java.util.concurrent.locks.Lock getWriteLock()

isValid

public final boolean isValid()

isDirty

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


allocate

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


read

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

Throws:
java.io.IOException

getBuffer

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


setDirty

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


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

getUseCount

public int getUseCount()

deallocate

public void deallocate()
                throws java.io.IOException
Throws:
java.io.IOException

saveAllocation

public void saveAllocation()
                    throws java.io.IOException
Throws:
java.io.IOException

free

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


startLruRemove

public boolean startLruRemove()
Called by the LRU cache before removing to see if the item can actually be removed.

Specified by:
startLruRemove in interface SyncCacheListener

syncLruRemoveEvent

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

Specified by:
syncLruRemoveEvent in interface SyncCacheListener

syncRemoveEvent

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

Specified by:
syncRemoveEvent in interface SyncCacheListener

isDestroyed

public boolean isDestroyed()

toString

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