Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.hsqldb
Class ReverseTextCache  view ReverseTextCache download ReverseTextCache.java

java.lang.Object
  extended byorg.hsqldb.Cache
      extended byorg.hsqldb.TextCache
          extended byorg.hsqldb.ReverseTextCache

class ReverseTextCache
extends TextCache

Cache class declaration

The cache class implements the handling of reversed text table caches.

Version:
1.7.0

Field Summary
protected  int iFreePos
           
protected  java.lang.String ignoredFirst
           
protected  boolean ignoreFirst
           
protected  TextDatabaseRowInput in
           
static java.lang.String NL
           
protected  boolean readOnly
           
protected  DatabaseFile rFile
           
protected  java.lang.String sName
           
 
Constructor Summary
(package private) ReverseTextCache(java.lang.String name, java.lang.String propPrefix, HsqlDatabaseProperties props)
          The cache constructor sets up the initial parameters of the cache object, setting the name used for the file, etc.
 
Method Summary
(package private)  void add(CachedRow r)
          Adds a Row to the Cache.
(package private)  void cleanUp()
          Cleans up this Cache object.
(package private)  void closeFile()
          Closes this object's database file without flushing pending writes.
(package private)  void flush()
          The flush method saves all cached data to the file, saves the free position and closes the file.
(package private)  void free(CachedRow r)
          Marks space in this object's cache file as free.
(package private)  int getFreePos()
          Getter for iFreePos member
(package private)  CachedRow getRow(int pos, Table t)
          Reads a Row object from this Cache that corresponds to the (pos) file offset in .data file.
protected  CachedRow makeRow(int pos, Table t)
          Constructs a new Row for the specified table, using row data read at the specified position (pos) in this object's database file.
(package private)  void open(boolean readonly)
          The open method creates or opens a database file.
(package private)  void purge()
           
protected  void remove(CachedRow r)
          Removes a Row from this Cache object.
(package private)  void reopen()
           
protected  void saveAll()
          Writes out all cached Rows.
protected  void saveRow(CachedRow r)
          Writes out the specified Row.
protected  void setStorageSize(CachedRow r)
          Calculates the number of bytes required to store a Row in this object's database file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NL

public static final java.lang.String NL

readOnly

protected boolean readOnly

in

protected TextDatabaseRowInput in

ignoreFirst

protected boolean ignoreFirst

ignoredFirst

protected java.lang.String ignoredFirst

sName

protected java.lang.String sName

iFreePos

protected int iFreePos

rFile

protected DatabaseFile rFile
Constructor Detail

ReverseTextCache

ReverseTextCache(java.lang.String name,
                 java.lang.String propPrefix,
                 HsqlDatabaseProperties props)
           throws java.sql.SQLException
The cache constructor sets up the initial parameters of the cache object, setting the name used for the file, etc.

Method Detail

open

void open(boolean readonly)
    throws java.sql.SQLException
The open method creates or opens a database file.

Overrides:
open in class TextCache

flush

void flush()
     throws java.sql.SQLException
The flush method saves all cached data to the file, saves the free position and closes the file.

Overrides:
flush in class TextCache

purge

void purge()
     throws java.sql.SQLException
Overrides:
purge in class TextCache

makeRow

protected CachedRow makeRow(int pos,
                            Table t)
                     throws java.sql.SQLException
Description copied from class: Cache
Constructs a new Row for the specified table, using row data read at the specified position (pos) in this object's database file.

Overrides:
makeRow in class TextCache

reopen

void reopen()
      throws java.sql.SQLException

free

void free(CachedRow r)
    throws java.sql.SQLException
Description copied from class: Cache
Marks space in this object's cache file as free.

Note: If there exists more than MAX_FREE_COUNT free positions, then they are probably all too small, so we start a new list.

todo: This is wrong when deleting lots of records

Overrides:
free in class Cache

setStorageSize

protected void setStorageSize(CachedRow r)
                       throws java.sql.SQLException
Description copied from class: Cache
Calculates the number of bytes required to store a Row in this object's database file.

Overrides:
setStorageSize in class Cache

saveRow

protected void saveRow(CachedRow r)
                throws java.io.IOException,
                       java.sql.SQLException
Description copied from class: Cache
Writes out the specified Row.

Overrides:
saveRow in class Cache

closeFile

void closeFile()
         throws java.sql.SQLException
Closes this object's database file without flushing pending writes.


add

void add(CachedRow r)
   throws java.sql.SQLException
Adds a Row to the Cache.

A Row is added by walking the list of CacheFree objects to see if there is available space to store it, reusing space if it exists. Otherwise , this object's cache file is grown to accomadate it.


getRow

CachedRow getRow(int pos,
                 Table t)
           throws java.sql.SQLException
Reads a Row object from this Cache that corresponds to the (pos) file offset in .data file.


cleanUp

void cleanUp()
       throws java.sql.SQLException
Cleans up this Cache object.

This method is called when this Cache object grows too large.

Cleanup is done by checking the iLastAccess member of this object's in-memory Rows and removing those that have been least recently accessed (classic LRU algoritm).


remove

protected void remove(CachedRow r)
               throws java.sql.SQLException
Removes a Row from this Cache object. Note: This method is called by the cleanUp method.


saveAll

protected void saveAll()
                throws java.sql.SQLException
Writes out all cached Rows.


getFreePos

int getFreePos()
Getter for iFreePos member