org.tmatesoft.sqljet.core.internal.pager
Class SqlJetPage

java.lang.Object
  extended by org.tmatesoft.sqljet.core.internal.pager.SqlJetPage
All Implemented Interfaces:
ISqlJetPage

public class SqlJetPage
extends java.lang.Object
implements ISqlJetPage


Field Summary
static SqlJetMemoryBufferType BUFFER_TYPE
           
 
Constructor Summary
SqlJetPage()
           
 
Method Summary
 void dontRollback()
          A call to this routine tells the pager that if a rollback occurs, it is not necessary to restore the data on the given page.
 void dontWrite()
          A call to this routine tells the pager that it is not necessary to write the information on page pPg back to the disk, even though that page might be marked as dirty.
 ISqlJetMemoryPointer getData()
          Return a pointer to the data for the specified page.
 ISqlJetPage getDirty()
           
 java.lang.Object getExtra()
           
 java.util.Set<SqlJetPageFlags> getFlags()
           
 long getHash()
          Hash of page content
 ISqlJetPage getNext()
           
 int getPageNumber()
           
 ISqlJetPager getPager()
           
 ISqlJetPage getPrev()
           
 int getRefCount()
           
 boolean isWriteable()
          Return TRUE if the page given in the argument was previously passed to sqlite3PagerWrite().
 void move(int pageNumber, boolean isCommit)
          Move the page to location pageNumber in the file.
 void ref()
          Increment the reference count for a page.
 void setExtra(java.lang.Object extra)
           
 void setFlags(java.util.Set<SqlJetPageFlags> flags)
           
 void setHash(long hash)
           
 void setPageNumber(int pageNumber)
           
 void setPager(ISqlJetPager pager)
           
 void unref()
          Release a page.
 void write()
          This function is used to mark a data-page as writable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_TYPE

public static final SqlJetMemoryBufferType BUFFER_TYPE
Constructor Detail

SqlJetPage

public SqlJetPage()
Method Detail

dontRollback

public void dontRollback()
Description copied from interface: ISqlJetPage
A call to this routine tells the pager that if a rollback occurs, it is not necessary to restore the data on the given page. This means that the pager does not have to record the given page in the rollback journal. If we have not yet actually read the content of this page (if the PgHdr.needRead flag is set) then this routine acts as a promise that we will never need to read the page content in the future. so the needRead flag can be cleared at this point.

Specified by:
dontRollback in interface ISqlJetPage

dontWrite

public void dontWrite()
Description copied from interface: ISqlJetPage
A call to this routine tells the pager that it is not necessary to write the information on page pPg back to the disk, even though that page might be marked as dirty. This happens, for example, when the page has been added as a leaf of the freelist and so its content no longer matters. The overlying software layer calls this routine when all of the data on the given page is unused. The pager marks the page as clean so that it does not get written to disk. Tests show that this optimization, together with the sqlite3PagerDontRollback() below, more than double the speed of large INSERT operations and quadruple the speed of large DELETEs. When this routine is called, set the bit corresponding to pDbPage in the Pager.pAlwaysRollback bitvec. Subsequent calls to sqlite3PagerDontRollback() for the same page will thereafter be ignored. This is necessary to avoid a problem where a page with data is added to the freelist during one part of a transaction then removed from the freelist during a later part of the same transaction and reused for some other purpose. When it is first added to the freelist, this routine is called. When reused, the sqlite3PagerDontRollback() routine is called. But because the page contains critical data, we still need to be sure it gets rolled back in spite of the sqlite3PagerDontRollback() call.

Specified by:
dontWrite in interface ISqlJetPage

getData

public ISqlJetMemoryPointer getData()
Description copied from interface: ISqlJetPage
Return a pointer to the data for the specified page.

Specified by:
getData in interface ISqlJetPage

getExtra

public java.lang.Object getExtra()
Specified by:
getExtra in interface ISqlJetPage

setExtra

public void setExtra(java.lang.Object extra)
Specified by:
setExtra in interface ISqlJetPage

move

public void move(int pageNumber,
                 boolean isCommit)
          throws SqlJetException
Description copied from interface: ISqlJetPage
Move the page to location pageNumber in the file. There must be no references to the page previously located at pageNumber (which we call pPgOld) though that page is allowed to be in cache. If the page previously located at pgno is not already in the rollback journal, it is not put there by by this routine. References to the page remain valid. Updating any meta-data associated with page (i.e. data stored in the nExtra bytes allocated along with the page) is the responsibility of the caller. A transaction must be active when this routine is called. It used to be required that a statement transaction was not active, but this restriction has been removed (CREATE INDEX needs to move a page when a statement transaction is active). If the second argument, isCommit, is true, then this page is being moved as part of a database reorganization just before the transaction is being committed. In this case, it is guaranteed that the database page refers to will not be written to again within this transaction.

Specified by:
move in interface ISqlJetPage
Throws:
SqlJetException

ref

public void ref()
Description copied from interface: ISqlJetPage
Increment the reference count for a page.

Specified by:
ref in interface ISqlJetPage

unref

public void unref()
           throws SqlJetException
Description copied from interface: ISqlJetPage
Release a page. If the number of references to the page drop to zero, then the page is added to the LRU list. When all references to all pages are released, a rollback occurs and the lock on the database is removed.

Specified by:
unref in interface ISqlJetPage
Throws:
SqlJetException

write

public void write()
           throws SqlJetException
Description copied from interface: ISqlJetPage
This function is used to mark a data-page as writable. It uses pager_write() to open a journal file (if it is not already open) and write the page *pData to the journal. The difference between this function and pager_write() is that this function also deals with the special case where 2 or more pages fit on a single disk sector. In this case all co-resident pages must have been written to the journal file before returning.

Specified by:
write in interface ISqlJetPage
Throws:
SqlJetException

getFlags

public java.util.Set<SqlJetPageFlags> getFlags()
Specified by:
getFlags in interface ISqlJetPage

getHash

public long getHash()
Description copied from interface: ISqlJetPage
Hash of page content

Specified by:
getHash in interface ISqlJetPage
Returns:

getPager

public ISqlJetPager getPager()
Specified by:
getPager in interface ISqlJetPage

setFlags

public void setFlags(java.util.Set<SqlJetPageFlags> flags)
Specified by:
setFlags in interface ISqlJetPage

setHash

public void setHash(long hash)
Specified by:
setHash in interface ISqlJetPage

setPager

public void setPager(ISqlJetPager pager)
Specified by:
setPager in interface ISqlJetPage

getPageNumber

public int getPageNumber()
Specified by:
getPageNumber in interface ISqlJetPage

setPageNumber

public void setPageNumber(int pageNumber)
Specified by:
setPageNumber in interface ISqlJetPage

getNext

public ISqlJetPage getNext()
Specified by:
getNext in interface ISqlJetPage

getPrev

public ISqlJetPage getPrev()
Specified by:
getPrev in interface ISqlJetPage

getRefCount

public int getRefCount()
Specified by:
getRefCount in interface ISqlJetPage

isWriteable

public boolean isWriteable()
Description copied from interface: ISqlJetPage
Return TRUE if the page given in the argument was previously passed to sqlite3PagerWrite(). In other words, return TRUE if it is ok to change the content of the page.

Specified by:
isWriteable in interface ISqlJetPage
Returns:

getDirty

public ISqlJetPage getDirty()
Specified by:
getDirty in interface ISqlJetPage
Returns: