Quadcap Embeddable Database

com.quadcap.sql.file.Cacheable Class Reference

Inheritance diagram for com.quadcap.sql.file.Cacheable:

Object com.quadcap.sql.file.Block List of all members.

Detailed Description

The construction of these objects needs to be managed by the cache object.

They are initialized using the

Author:
Stan Bailes

Definition at line 51 of file Cacheable.java.

Public Member Functions

void init (Object store, long key) throws IOException
 Initialization and (recycling).

Object getStore ()
 Return the cache to which this cacheable belongs.

boolean isReadOnly ()
 Am I read only?

void setReadOnly (boolean v)
 Set the 'read only' flag.

final boolean isDirty ()
 Read the dirty bit.

void setDirty (boolean d)
 Set the dirty bit.

final int getRefCount ()
 Read the reference count.

final void setRefCount (int x)
 Set the reference count.

final void incrRefCount ()
 Increment the reference count.

final void decrRefCount ()
 Decrement the reference count.

final void setDListItem (DListItem d)
 Set the LRU back pointer.

final DListItem getDListItem ()
 Get the LRU back pointer.

long getKey ()
 Get the cache item's key.

void setKey (long key)
 Set the cache item's key.

abstract Object getData ()
 Get the cache item's data.

abstract void setData (Object data)
 Set the cache item's data.

void flush () throws IOException
 Flush this item and clear the dirty bit.


Protected Attributes

long key
 The key used to locate this item in the underlying store, as well as in the cache itself.

Object store

Package Attributes

boolean dirty = false
 has object been modified while in the cache?

boolean readOnly = false
 Is this cache item read only?

int refCount = 0
 We reference-count the cache items to know when it's ok to flush older items to make room for new ones.

DListItem me
 Back pointer to my place in the LRU list.


Member Function Documentation

final void com.quadcap.sql.file.Cacheable.decrRefCount  ) 
 

Decrement the reference count.

Definition at line 136 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.refCount.

Referenced by com.quadcap.sql.file.SubPageManager.allocateNewBlock(), com.quadcap.sql.file.BlockFile.BlockFile(), com.quadcap.sql.index.Bnode.checkMagic(), com.quadcap.sql.file.SubPage.decrRefCount(), com.quadcap.sql.index.Bnode.delete(), com.quadcap.sql.index.Bnode.display(), com.quadcap.sql.file.BlockFile.dump(), com.quadcap.sql.file.BlockFile.ensureLastBlock(), com.quadcap.sql.index.Bnode.free(), com.quadcap.sql.file.SubPageManager.freePage(), com.quadcap.sql.file.BlockFile.freePage(), com.quadcap.sql.index.Bnode.get(), com.quadcap.sql.file.Cache.get(), com.quadcap.sql.file.BlockFile.getBytes(), com.quadcap.sql.file.BlockFile.getUserBlock(), com.quadcap.sql.index.Bnode.init(), com.quadcap.sql.index.Bnode.newLow(), com.quadcap.sql.file.SubPageManager.newPage(), com.quadcap.sql.file.BlockFile.newPage(), com.quadcap.sql.index.Bnode.propogateSplit(), com.quadcap.sql.file.Cache.put(), com.quadcap.sql.file.BlockFile.putBytes(), com.quadcap.sql.file.Log1.reallyCheckpoint(), com.quadcap.sql.file.Log1.restoreBlocks(), com.quadcap.sql.file.BlockFile.revert(), com.quadcap.sql.index.Bnode.set(), com.quadcap.sql.index.Bnode.setKey(), com.quadcap.sql.file.BlockFile.signature(), com.quadcap.sql.index.Bnode.size(), com.quadcap.sql.index.Bnode.split(), com.quadcap.sql.index.Bnode.splitHelp(), and com.quadcap.sql.file.BlockFile.updateBytes().

void com.quadcap.sql.file.Cacheable.flush  )  throws IOException
 

Flush this item and clear the dirty bit.

Reimplemented in com.quadcap.sql.file.Block.

Definition at line 171 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.dirty.

Referenced by com.quadcap.sql.file.Cache.flush(), and com.quadcap.sql.file.Cache.getCacheable().

abstract Object com.quadcap.sql.file.Cacheable.getData  )  [pure virtual]
 

Get the cache item's data.

Implemented in com.quadcap.sql.file.Block.

Referenced by com.quadcap.sql.file.Cache.get().

final DListItem com.quadcap.sql.file.Cacheable.getDListItem  ) 
 

Get the LRU back pointer.

Definition at line 146 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.me.

Referenced by com.quadcap.sql.file.Cache.getCacheable().

long com.quadcap.sql.file.Cacheable.getKey  ) 
 

Get the cache item's key.

Definition at line 151 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.key.

Referenced by com.quadcap.sql.file.Cache.getCacheable(), and com.quadcap.sql.file.Block.toString().

final int com.quadcap.sql.file.Cacheable.getRefCount  ) 
 

Read the reference count.

Definition at line 119 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.refCount.

Referenced by com.quadcap.sql.file.Cache.getCacheable().

Object com.quadcap.sql.file.Cacheable.getStore  ) 
 

Return the cache to which this cacheable belongs.

Definition at line 89 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.store.

final void com.quadcap.sql.file.Cacheable.incrRefCount  ) 
 

Increment the reference count.

Definition at line 129 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.refCount.

Referenced by com.quadcap.sql.file.Cache.getCacheable().

void com.quadcap.sql.file.Cacheable.init Object  store,
long  key
throws IOException
 

Initialization and (recycling).

Reimplemented in com.quadcap.sql.file.Block.

Definition at line 80 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.dirty, com.quadcap.sql.file.Cacheable.init(), com.quadcap.sql.file.Cacheable.key, and com.quadcap.sql.file.Cacheable.store.

Referenced by com.quadcap.sql.file.Cache.getCacheable(), and com.quadcap.sql.file.Cacheable.init().

final boolean com.quadcap.sql.file.Cacheable.isDirty  ) 
 

Read the dirty bit.

Definition at line 104 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.dirty.

Referenced by com.quadcap.sql.file.Cache.getCacheable().

boolean com.quadcap.sql.file.Cacheable.isReadOnly  ) 
 

Am I read only?

Definition at line 94 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.readOnly.

abstract void com.quadcap.sql.file.Cacheable.setData Object  data  )  [pure virtual]
 

Set the cache item's data.

Implemented in com.quadcap.sql.file.Block.

Referenced by com.quadcap.sql.file.Cache.put().

void com.quadcap.sql.file.Cacheable.setDirty boolean  d  ) 
 

Set the dirty bit.

Definition at line 109 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.dirty, com.quadcap.sql.file.Cacheable.readOnly, and com.quadcap.sql.file.Cacheable.setDirty().

Referenced by com.quadcap.sql.index.Bnode.moveKeys(), and com.quadcap.sql.file.Cacheable.setDirty().

final void com.quadcap.sql.file.Cacheable.setDListItem DListItem  d  ) 
 

Set the LRU back pointer.

Definition at line 141 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.me, and com.quadcap.sql.file.Cacheable.setDListItem().

Referenced by com.quadcap.sql.file.Cache.getCacheable(), and com.quadcap.sql.file.Cacheable.setDListItem().

void com.quadcap.sql.file.Cacheable.setKey long  key  ) 
 

Set the cache item's key.

Definition at line 156 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.setKey().

Referenced by com.quadcap.sql.file.Cacheable.setKey().

void com.quadcap.sql.file.Cacheable.setReadOnly boolean  v  ) 
 

Set the 'read only' flag.

Definition at line 99 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.setReadOnly().

Referenced by com.quadcap.sql.file.Cache.getCacheable(), and com.quadcap.sql.file.Cacheable.setReadOnly().

final void com.quadcap.sql.file.Cacheable.setRefCount int  x  ) 
 

Set the reference count.

Definition at line 124 of file Cacheable.java.

References com.quadcap.sql.file.Cacheable.refCount, and com.quadcap.sql.file.Cacheable.setRefCount().

Referenced by com.quadcap.sql.file.Cacheable.setRefCount().


Member Data Documentation

boolean com.quadcap.sql.file.Cacheable.dirty = false [package]
 

has object been modified while in the cache?

Definition at line 53 of file Cacheable.java.

Referenced by com.quadcap.sql.file.Cacheable.flush(), com.quadcap.sql.file.Cacheable.init(), com.quadcap.sql.file.Cacheable.isDirty(), and com.quadcap.sql.file.Cacheable.setDirty().

long com.quadcap.sql.file.Cacheable.key [protected]
 

The key used to locate this item in the underlying store, as well as in the cache itself.

Definition at line 73 of file Cacheable.java.

Referenced by com.quadcap.sql.file.Cacheable.getKey(), and com.quadcap.sql.file.Cacheable.init().

DListItem com.quadcap.sql.file.Cacheable.me [package]
 

Back pointer to my place in the LRU list.

Definition at line 67 of file Cacheable.java.

Referenced by com.quadcap.sql.file.Cacheable.getDListItem(), and com.quadcap.sql.file.Cacheable.setDListItem().

boolean com.quadcap.sql.file.Cacheable.readOnly = false [package]
 

Is this cache item read only?

Definition at line 56 of file Cacheable.java.

Referenced by com.quadcap.sql.file.Cacheable.isReadOnly(), and com.quadcap.sql.file.Cacheable.setDirty().

int com.quadcap.sql.file.Cacheable.refCount = 0 [package]
 

We reference-count the cache items to know when it's ok to flush older items to make room for new ones.

We should probably keep some statistics which keep track of the percentage of cache items currently "in-use"; i.e., with refCount > 0

Definition at line 64 of file Cacheable.java.

Referenced by com.quadcap.sql.file.Cacheable.decrRefCount(), com.quadcap.sql.file.Cacheable.getRefCount(), com.quadcap.sql.file.Cacheable.incrRefCount(), and com.quadcap.sql.file.Cacheable.setRefCount().

Object com.quadcap.sql.file.Cacheable.store [protected]
 

Definition at line 75 of file Cacheable.java.

Referenced by com.quadcap.sql.file.Cacheable.getStore(), and com.quadcap.sql.file.Cacheable.init().