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_SIZE
SQLJET_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
ISqlJetPager
ISqlJetPager.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 ISqlJetPager
fileSystem
- 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)
SqlJetException
public java.io.File getDirectoryName()
ISqlJetPager
getDirectoryName
in interface ISqlJetPager
public java.io.File getFileName()
ISqlJetPager
getFileName
in interface ISqlJetPager
public ISqlJetFileSystem getFileSystem()
ISqlJetPager
getFileSystem
in interface ISqlJetPager
public ISqlJetFile getFile()
ISqlJetPager
getFile
in interface ISqlJetPager
public java.io.File getJournalName()
ISqlJetPager
getJournalName
in interface ISqlJetPager
public boolean isNoSync()
ISqlJetPager
isNoSync
in interface ISqlJetPager
public boolean isReadOnly()
ISqlJetPager
isReadOnly
in interface ISqlJetPager
public SqlJetPagerLockingMode getLockingMode()
ISqlJetPager
getLockingMode
in interface ISqlJetPager
public void setLockingMode(SqlJetPagerLockingMode lockingMode)
ISqlJetPager
setLockingMode
in interface ISqlJetPager
public SqlJetPagerJournalMode getJournalMode()
ISqlJetPager
getJournalMode
in interface ISqlJetPager
public void setJournalMode(SqlJetPagerJournalMode journalMode)
ISqlJetPager
setJournalMode
in interface ISqlJetPager
public long getJournalSizeLimit()
ISqlJetPager
getJournalSizeLimit
in interface ISqlJetPager
public void setJournalSizeLimit(long limit)
ISqlJetPager
setJournalSizeLimit
in interface ISqlJetPager
public SqlJetSafetyLevel getSafetyLevel()
ISqlJetPager
getSafetyLevel
in interface ISqlJetPager
public void setSafetyLevel(SqlJetSafetyLevel safetyLevel)
ISqlJetPager
setSafetyLevel
in interface ISqlJetPager
public ISqlJetMemoryPointer getTempSpace()
ISqlJetPager
getTempSpace
in interface ISqlJetPager
public void setBusyhandler(ISqlJetBusyHandler busyHandler)
ISqlJetPager
setBusyhandler
in interface ISqlJetPager
public void setReiniter(ISqlJetPageCallback reinitier)
ISqlJetPager
setReiniter
in interface ISqlJetPager
public int setPageSize(int pageSize) throws SqlJetException
ISqlJetPager
setPageSize
in interface ISqlJetPager
SqlJetException
public int getPageSize()
ISqlJetPager
getPageSize
in interface ISqlJetPager
public void setMaxPageCount(int maxPageCount) throws SqlJetException
ISqlJetPager
setMaxPageCount
in interface ISqlJetPager
SqlJetException
public int getMaxPageCount()
ISqlJetPager
getMaxPageCount
in interface ISqlJetPager
public void setCacheSize(int cacheSize)
ISqlJetPager
setCacheSize
in interface ISqlJetPager
public int getCacheSize()
getCacheSize
in interface ISqlJetPager
public void readFileHeader(int count, ISqlJetMemoryPointer buffer) throws SqlJetIOException
ISqlJetPager
readFileHeader
in interface ISqlJetPager
SqlJetIOException
public int getPageCount() throws SqlJetException
ISqlJetPager
getPageCount
in interface ISqlJetPager
SqlJetException
- if pager is in error state.public void close() throws SqlJetException
ISqlJetPager
close
in interface ISqlJetPager
SqlJetException
public ISqlJetPage acquirePage(int pageNumber, boolean read) throws SqlJetException
ISqlJetPager
ISqlJetPager.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 ISqlJetPager
pageNumber
- Page number to fetchread
- Do not bother reading content from disk if falseSqlJetException
public ISqlJetPage getPage(int pageNumber) throws SqlJetException
ISqlJetPager
getPage
in interface ISqlJetPager
pageNumber
- Page number to fetchSqlJetException
public ISqlJetPage lookupPage(int pageNumber) throws SqlJetException
ISqlJetPager
ISqlJetPager.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 ISqlJetPager
pageNumber
- Page number to lookupSqlJetException
public void truncateImage(int pagesNumber)
ISqlJetPager
truncateImage
in interface ISqlJetPager
public int imageSize()
ISqlJetPager
imageSize
in interface ISqlJetPager
public void begin(boolean exclusive) throws SqlJetException
ISqlJetPager
begin
in interface ISqlJetPager
SqlJetException
public void commitPhaseOne(java.lang.String master, boolean noSync) throws SqlJetException
ISqlJetPager
commitPhaseOne
in interface ISqlJetPager
SqlJetException
public void commitPhaseTwo() throws SqlJetException
ISqlJetPager
commitPhaseTwo
in interface ISqlJetPager
SqlJetException
public void rollback() throws SqlJetException
ISqlJetPager
rollback
in interface ISqlJetPager
SqlJetException
public void sync() throws SqlJetIOException
ISqlJetPager
sync
in interface ISqlJetPager
SqlJetIOException
public int getRefCount()
ISqlJetPager
getRefCount
in interface ISqlJetPager
public void pageCallback(ISqlJetPage page)
pageCallback
in interface ISqlJetPageCallback
public void openSavepoint(int nSavepoint) throws SqlJetException
openSavepoint
in interface ISqlJetPager
SqlJetException
public void savepoint(SqlJetSavepointOperation op, int iSavepoint) throws SqlJetException
savepoint
in interface ISqlJetPager
SqlJetException
Copyright © 2009-2010 TMate Software Ltd. All Rights Reserved.