public class SqlJetPager extends java.lang.Object implements ISqlJetPager, ISqlJetLimits, ISqlJetPageCallback
aJournalMagic, JOURNAL, MEMORY_DB, PAGER_MAX_PGNO, SQLJET_DEFAULT_JOURNAL_SIZE_LIMIT, SQLJET_MIN_SECTOR_SIZESQLJET_DEFAULT_CACHE_SIZE, SQLJET_DEFAULT_PAGE_SIZE, SQLJET_DEFAULT_TEMP_CACHE_SIZE, SQLJET_MAX_ATTACHED, SQLJET_MAX_COLUMN, SQLJET_MAX_COMPOUND_SELECT, SQLJET_MAX_DEFAULT_PAGE_SIZE, SQLJET_MAX_EXPR_DEPTH, SQLJET_MAX_FILE_FORMAT, SQLJET_MAX_FUNCTION_ARG, SQLJET_MAX_LENGTH, SQLJET_MAX_LIKE_PATTERN_LENGTH, SQLJET_MAX_PAGE_COUNT, SQLJET_MAX_PAGE_SIZE, SQLJET_MAX_SQL_LENGTH, SQLJET_MAX_VARIABLE_NUMBER, SQLJET_MAX_VDBE_OP, SQLJET_MIN_FILE_FORMAT, SQLJET_MIN_PAGE_SIZE| Constructor and Description |
|---|
SqlJetPager() |
| Modifier and Type | Method and Description |
|---|---|
ISqlJetPage |
acquirePage(int pageNumber,
boolean read)
Acquire a page.
|
void |
begin(boolean exclusive)
Acquire a write-lock on the database.
|
void |
close()
Shutdown the page cache.
|
void |
commitPhaseOne(java.lang.String master,
boolean noSync)
Sync the database file for the pager pPager.
|
void |
commitPhaseTwo()
Commit all changes to the database and release the write lock.
|
int |
getCacheSize() |
java.io.File |
getDirectoryName()
Return the directory of the database file.
|
ISqlJetFile |
getFile()
Return the file handle for the database file associated with the pager.
|
java.io.File |
getFileName()
Return the path of the database file.
|
ISqlJetFileSystem |
getFileSystem()
Return the file system for the pager.
|
SqlJetPagerJournalMode |
getJournalMode()
Get the journal-mode for this pager.
|
java.io.File |
getJournalName()
Return the path of the journal file.
|
long |
getJournalSizeLimit()
Get the size-limit used for persistent journal files.
|
SqlJetPagerLockingMode |
getLockingMode()
Get the locking-mode for this pager.
|
int |
getMaxPageCount()
Return the current maximum page count.
|
ISqlJetPage |
getPage(int pageNumber)
Just call acquire( pageNumber, true);
|
int |
getPageCount()
Return the total number of pages in the disk file associated with pager.
|
int |
getPageSize()
Get the page size.
|
int |
getRefCount()
Return the number of references to the pager.
|
SqlJetSafetyLevel |
getSafetyLevel()
Get safety level
|
ISqlJetMemoryPointer |
getTempSpace()
Return a pointer to the "temporary page" buffer held internally by the
pager.
|
int |
imageSize()
Return the current size of the database file image in pages.
|
boolean |
isNoSync()
Return true if fsync() calls are disabled for this pager.
|
boolean |
isReadOnly()
Return TRUE if the database file is opened read-only.
|
ISqlJetPage |
lookupPage(int pageNumber)
Acquire a page if it is already in the in-memory cache.
|
void |
open(ISqlJetFileSystem fileSystem,
java.io.File fileName,
java.util.Set<SqlJetPagerFlags> flags,
SqlJetFileType type,
java.util.Set<SqlJetFileOpenPermission> permissions)
Open a new page cache.
|
void |
openSavepoint(int nSavepoint)
Ensure that there are at least nSavepoint savepoints open.
|
void |
pageCallback(ISqlJetPage page) |
void |
readFileHeader(int count,
ISqlJetMemoryPointer buffer)
Read the first N bytes from the beginning of the file into memory that
buffer points to.
|
void |
rollback()
Rollback all changes.
|
void |
savepoint(SqlJetSavepointOperation op,
int iSavepoint)
Parameter op is always either SAVEPOINT_ROLLBACK or SAVEPOINT_RELEASE.
|
void |
setBusyhandler(ISqlJetBusyHandler busyHandler)
Set the busy handler function.
|
void |
setCacheSize(int cacheSize)
Change the maximum number of in-memory pages that are allowed.
|
void |
setJournalMode(SqlJetPagerJournalMode journalMode)
Set the journal-mode for this pager.
|
void |
setJournalSizeLimit(long limit)
Set the size-limit used for persistent journal files.
|
void |
setLockingMode(SqlJetPagerLockingMode lockingMode)
Set the locking-mode for this pager.
|
void |
setMaxPageCount(int maxPageCount)
Attempt to set the maximum database page count if mxPage is positive.
|
int |
setPageSize(int pageSize)
Set the page size to pageSize.
|
void |
setReiniter(ISqlJetPageCallback reinitier)
Set the reinitializer for this pager.
|
void |
setSafetyLevel(SqlJetSafetyLevel safetyLevel)
Set safety level
|
void |
sync()
Sync the pager file to disk.
|
void |
truncateImage(int pagesNumber)
Truncate the in-memory database file image to nPage pages.
|
public void open(ISqlJetFileSystem fileSystem, java.io.File fileName, java.util.Set<SqlJetPagerFlags> flags, SqlJetFileType type, java.util.Set<SqlJetFileOpenPermission> permissions) throws SqlJetException
ISqlJetPagerISqlJetPager.getPage(int) and is only held open until the last
page is released using #unref(ISqlJetPage).
If fileName is null then a randomly-named temporary file is created and
used as the file to be cached. The file will be deleted automatically
when it is closed.
If fileName is ISqlJetPager.MEMORY_DB then all information is held in cache.
It is never written to disk. This can be used to implement an in-memory
database.open in interface ISqlJetPagerfileSystem - The file system to usefileName - Name of the database file to openflags - flags controlling this filetype - file type passed through to
ISqlJetFileSystem.open(java.io.File, SqlJetFileType, Set)permissions - permissions passed through to
ISqlJetFileSystem.open(java.io.File, SqlJetFileType, Set)SqlJetExceptionpublic java.io.File getDirectoryName()
ISqlJetPagergetDirectoryName in interface ISqlJetPagerpublic java.io.File getFileName()
ISqlJetPagergetFileName in interface ISqlJetPagerpublic ISqlJetFileSystem getFileSystem()
ISqlJetPagergetFileSystem in interface ISqlJetPagerpublic ISqlJetFile getFile()
ISqlJetPagergetFile in interface ISqlJetPagerpublic java.io.File getJournalName()
ISqlJetPagergetJournalName in interface ISqlJetPagerpublic boolean isNoSync()
ISqlJetPagerisNoSync in interface ISqlJetPagerpublic boolean isReadOnly()
ISqlJetPagerisReadOnly in interface ISqlJetPagerpublic SqlJetPagerLockingMode getLockingMode()
ISqlJetPagergetLockingMode in interface ISqlJetPagerpublic void setLockingMode(SqlJetPagerLockingMode lockingMode)
ISqlJetPagersetLockingMode in interface ISqlJetPagerpublic SqlJetPagerJournalMode getJournalMode()
ISqlJetPagergetJournalMode in interface ISqlJetPagerpublic void setJournalMode(SqlJetPagerJournalMode journalMode)
ISqlJetPagersetJournalMode in interface ISqlJetPagerpublic long getJournalSizeLimit()
ISqlJetPagergetJournalSizeLimit in interface ISqlJetPagerpublic void setJournalSizeLimit(long limit)
ISqlJetPagersetJournalSizeLimit in interface ISqlJetPagerpublic SqlJetSafetyLevel getSafetyLevel()
ISqlJetPagergetSafetyLevel in interface ISqlJetPagerpublic void setSafetyLevel(SqlJetSafetyLevel safetyLevel)
ISqlJetPagersetSafetyLevel in interface ISqlJetPagerpublic ISqlJetMemoryPointer getTempSpace()
ISqlJetPagergetTempSpace in interface ISqlJetPagerpublic void setBusyhandler(ISqlJetBusyHandler busyHandler)
ISqlJetPagersetBusyhandler in interface ISqlJetPagerpublic void setReiniter(ISqlJetPageCallback reinitier)
ISqlJetPagersetReiniter in interface ISqlJetPagerpublic int setPageSize(int pageSize)
throws SqlJetException
ISqlJetPagersetPageSize in interface ISqlJetPagerSqlJetExceptionpublic int getPageSize()
ISqlJetPagergetPageSize in interface ISqlJetPagerpublic void setMaxPageCount(int maxPageCount)
throws SqlJetException
ISqlJetPagersetMaxPageCount in interface ISqlJetPagerSqlJetExceptionpublic int getMaxPageCount()
ISqlJetPagergetMaxPageCount in interface ISqlJetPagerpublic void setCacheSize(int cacheSize)
ISqlJetPagersetCacheSize in interface ISqlJetPagerpublic int getCacheSize()
getCacheSize in interface ISqlJetPagerpublic void readFileHeader(int count,
ISqlJetMemoryPointer buffer)
throws SqlJetIOException
ISqlJetPagerreadFileHeader in interface ISqlJetPagerSqlJetIOExceptionpublic int getPageCount()
throws SqlJetException
ISqlJetPagergetPageCount in interface ISqlJetPagerSqlJetException - if pager is in error state.public void close()
throws SqlJetException
ISqlJetPagerclose in interface ISqlJetPagerSqlJetExceptionpublic ISqlJetPage acquirePage(int pageNumber, boolean read) throws SqlJetException
ISqlJetPagerISqlJetPager.lookupPage(int). Both this routine and
ISqlJetPager.lookupPage(int) attempt to find a page in the in-memory cache
first. If the page is not already in memory, this routine goes to disk to
read it in whereas ISqlJetPager.lookupPage(int) just returns 0. This routine
acquires a read-lock the first time it has to go to disk, and could also
playback an old journal if necessary. Since ISqlJetPager.lookupPage(int)
never goes to disk, it never has to deal with locks or journal files.
If noContent is false, the page contents are actually read from disk. If
noContent is true, it means that we do not care about the contents of the
page at this time, so do not do a disk read. Just fill in the page
content with zeros. But mark the fact that we have not read the content
by setting the PgHdr.needRead flag. Later on, if sqlite3PagerWrite() is
called on this page or if this routine is called again with noContent==0,
that means that the content is needed and the disk read should occur at
that point.acquirePage in interface ISqlJetPagerpageNumber - Page number to fetchread - Do not bother reading content from disk if falseSqlJetExceptionpublic ISqlJetPage getPage(int pageNumber) throws SqlJetException
ISqlJetPagergetPage in interface ISqlJetPagerpageNumber - Page number to fetchSqlJetExceptionpublic ISqlJetPage lookupPage(int pageNumber) throws SqlJetException
ISqlJetPagerISqlJetPager.getPage(int). The difference between this routine and
ISqlJetPager.getPage(int) is that ISqlJetPager.getPage(int) will go to the disk
and read in the page if the page is not already in cache. This routine
returns null if the page is not in cache or if a disk I/O error has ever
happened.lookupPage in interface ISqlJetPagerpageNumber - Page number to lookupSqlJetExceptionpublic void truncateImage(int pagesNumber)
ISqlJetPagertruncateImage in interface ISqlJetPagerpublic int imageSize()
ISqlJetPagerimageSize in interface ISqlJetPagerpublic void begin(boolean exclusive)
throws SqlJetException
ISqlJetPagerbegin in interface ISqlJetPagerSqlJetExceptionpublic void commitPhaseOne(java.lang.String master,
boolean noSync)
throws SqlJetException
ISqlJetPagercommitPhaseOne in interface ISqlJetPagerSqlJetExceptionpublic void commitPhaseTwo()
throws SqlJetException
ISqlJetPagercommitPhaseTwo in interface ISqlJetPagerSqlJetExceptionpublic void rollback()
throws SqlJetException
ISqlJetPagerrollback in interface ISqlJetPagerSqlJetExceptionpublic void sync()
throws SqlJetIOException
ISqlJetPagersync in interface ISqlJetPagerSqlJetIOExceptionpublic int getRefCount()
ISqlJetPagergetRefCount in interface ISqlJetPagerpublic void pageCallback(ISqlJetPage page)
pageCallback in interface ISqlJetPageCallbackpublic void openSavepoint(int nSavepoint)
throws SqlJetException
openSavepoint in interface ISqlJetPagerSqlJetExceptionpublic void savepoint(SqlJetSavepointOperation op, int iSavepoint) throws SqlJetException
savepoint in interface ISqlJetPagerSqlJetExceptionCopyright © 2009-2010 TMate Software Ltd. All Rights Reserved.