This class represents a file that is organized as a number of pages. Page 0
contains a static file header, and pages 1 and 2 both contain the variable
file header (page 2 is a copy of page 1 and is only read if the checksum of
page 1 is invalid). The format of page 0 is:
Page 3 contains the first free list page.
Page 4 contains the meta table root page.
| Methods |
| static boolean |
checksumTest(byte[] d, int pageId, int pageSize)
Check if the stored checksum is correct
|
| static boolean |
checksumTest(byte[] d, int pageId, int pageSize)
Check if the stored checksum is correct
Parameters:
d - the data
pageId - the page id
pageSize - the page size
Returns:
true if it is correct
|
|
PageStore(Database database, String fileName, String accessMode, int cacheSizeDefault)
Create a new page store object.
|
|
PageStore(Database database, String fileName, String accessMode, int cacheSizeDefault)
Create a new page store object.
Parameters:
database - the database
fileName - the file name
accessMode - the access mode
cacheSizeDefault - the default cache size
|
| void |
addIndex(PageIndex index)
Add an index to the in-memory index map.
|
| void |
addIndex(PageIndex index)
Add an index to the in-memory index map.
Parameters:
index - the index
|
| void |
addMeta(PageIndex index, Session session)
Add the meta data of an index.
|
| void |
addMeta(PageIndex index, Session session)
Add the meta data of an index.
Parameters:
index - the index to add
session - the session
|
| void |
allocateIfIndexRoot(int logPos, int tableId, Row row)
Reserve the page if this is a index root page entry.
|
| void |
allocateIfIndexRoot(int logPos, int tableId, Row row)
Reserve the page if this is a index root page entry.
Parameters:
logPos - the redo log position
tableId - the table id
row - the row
|
| void |
allocatePage(int pageId)
Set the bit of an already allocated page.
|
| void |
allocatePage(int pageId)
Set the bit of an already allocated page.
Parameters:
pageId - the page to allocate
|
| int |
allocatePage()
Allocate a page.
|
| int |
allocatePage()
Allocate a page.
Returns:
the page id
|
| void |
allocatePages(IntArray list, int pagesToAllocate, BitField exclude, int after)
Allocate a number of pages.
|
| void |
allocatePages(IntArray list, int pagesToAllocate, BitField exclude, int after)
Allocate a number of pages.
Parameters:
list - the list where to add the allocated pages
pagesToAllocate - the number of pages to allocate
exclude - the exclude list
after - all allocated pages are higher than this page
|
| void |
checkpoint()
Flush all pending changes to disk, and switch the new transaction log.
|
| void |
checkpoint()
Flush all pending changes to disk, and switch the new transaction log.
|
| void |
close()
Close the file without further writing.
|
| void |
close()
Close the file without further writing.
|
| void |
commit(Session session)
Mark a committed transaction.
|
| void |
commit(Session session)
Mark a committed transaction.
Parameters:
session - the session
|
| void |
compact(int compactMode)
Shrink the file so there are no empty pages at the end.
|
| void |
compact(int compactMode)
Shrink the file so there are no empty pages at the end.
Parameters:
compactMode - 0 if no compacting should happen, otherwise
TransactionCommand.SHUTDOWN_COMPACT or TransactionCommand.SHUTDOWN_DEFRAG
|
| int |
copyDirect(int pageId, OutputStream out)
Copy the next page to the output stream.
|
| int |
copyDirect(int pageId, OutputStream out) throws IOException
Copy the next page to the output stream.
Parameters:
pageId - the page to copy
out - the output stream
Returns:
the new position, or -1 if there is no more data to copy
|
| Data |
createData()
Create a data object.
|
| Data |
createData()
Create a data object.
Returns:
the data page.
|
| void |
flushLog()
|
| void |
flushLog()
|
| void |
free(int pageId)
Add a page to the free list.
|
| void |
free(int pageId)
Add a page to the free list. The undo log entry must have been written.
Parameters:
pageId - the page id
|
| void |
free(int pageId, boolean undo)
Add a page to the free list.
|
| void |
free(int pageId, boolean undo)
Add a page to the free list.
Parameters:
pageId - the page id
undo - if the undo record must have been written
|
| void |
freeUnused(int pageId)
Add a page to the free list.
|
| void |
freeUnused(int pageId)
Add a page to the free list. The page is not used, therefore doesn't need
to be overwritten.
Parameters:
pageId - the page id
|
| Cache |
getCache()
|
| Cache |
getCache()
|
| long |
getChangeCount()
Get the current change count.
|
| long |
getChangeCount()
Get the current change count. The first value is 1
Returns:
the change count
|
| Database |
getDatabase()
|
| Database |
getDatabase()
|
| ArrayList |
getInDoubtTransactions()
Get the list of in-doubt transaction.
|
| ArrayList |
getInDoubtTransactions()
Get the list of in-doubt transaction.
Returns:
the list
|
| int |
getLogMode()
|
| int |
getLogMode()
|
| BitField |
getObjectIds()
|
| BitField |
getObjectIds()
|
| Page |
getPage(int pageId)
Read a page from the store.
|
| Page |
getPage(int pageId)
Read a page from the store.
Parameters:
pageId - the page id
Returns:
the page
|
| int |
getPageCount()
Get the number of pages (including free pages).
|
| int |
getPageCount()
Get the number of pages (including free pages).
Returns:
the page count
|
| int |
getPageSize()
Get the page size.
|
| int |
getPageSize()
Get the page size.
Returns:
the page size
|
| Session |
getPageStoreSession()
|
| Session |
getPageStoreSession()
|
| long |
getReadCount()
Get the file read count since the database was opened.
|
| long |
getReadCount()
Get the file read count since the database was opened.
Returns:
the read count
|
| int |
getRootPageId(int indexId)
Get the root page of an index.
|
| int |
getRootPageId(int indexId)
Get the root page of an index.
Parameters:
indexId - the index id
Returns:
the root page
|
| Trace |
getTrace()
|
| Trace |
getTrace()
|
| long |
getWriteCount()
Get the file write count since the database was opened.
|
| long |
getWriteCount()
Get the file write count since the database was opened.
Returns:
the write count
|
| long |
getWriteCountTotal()
Get the file write count since the database was created.
|
| long |
getWriteCountTotal()
Get the file write count since the database was created.
Returns:
the write count
|
| void |
incrementChangeCount()
Increment the change count.
|
| void |
incrementChangeCount()
Increment the change count. To be done after the operation has finished.
|
| boolean |
isNew()
Check whether this is a new database.
|
| boolean |
isNew()
Check whether this is a new database.
Returns:
true if it is
|
| boolean |
isRecoveryRunning()
Check whether the recovery process is currently running.
|
| boolean |
isRecoveryRunning()
Check whether the recovery process is currently running.
Returns:
true if it is
|
| void |
logAddOrRemoveRow(Session session, int tableId, Row row, boolean add)
A record is added to a table, or removed from a table.
|
| void |
logAddOrRemoveRow(Session session, int tableId, Row row, boolean add)
A record is added to a table, or removed from a table.
Parameters:
session - the session
tableId - the table id
row - the row to add
add - true if the row is added, false if it is removed
|
| void |
logTruncate(Session session, int tableId)
A table is truncated.
|
| void |
logTruncate(Session session, int tableId)
A table is truncated.
Parameters:
session - the session
tableId - the table id
|
| void |
logUndo(Page page, Data old)
Write an undo log entry if required.
|
| void |
logUndo(Page page, Data old)
Write an undo log entry if required.
Parameters:
page - the page
old - the old data (if known) or null
|
| void |
open()
Open the file and read the header.
|
| void |
open()
Open the file and read the header.
|
| void |
prepareCommit(Session session, String transaction)
Prepare a transaction.
|
| void |
prepareCommit(Session session, String transaction)
Prepare a transaction.
Parameters:
session - the session
transaction - the name of the transaction
|
| Data |
readPage(int pos)
Read a page.
|
| Data |
readPage(int pos)
Read a page.
Parameters:
pos - the page id
Returns:
the page
|
| void |
readPage(int pos, Data page)
Read a page.
|
| void |
readPage(int pos, Data page)
Read a page.
Parameters:
pos - the page id
page - the page
|
| void |
redo(int tableId, Row row, boolean add)
Redo a change in a table.
|
| void |
redo(int tableId, Row row, boolean add)
Redo a change in a table.
Parameters:
tableId - the object id of the table
row - the row
add - true if the record is added, false if deleted
|
| void |
redoDelete(int tableId, long key)
Redo a delete in a table.
|
| void |
redoDelete(int tableId, long key)
Redo a delete in a table.
Parameters:
tableId - the object id of the table
key - the key of the row to delete
|
| void |
redoTruncate(int tableId)
Redo a truncate.
|
| void |
redoTruncate(int tableId)
Redo a truncate.
Parameters:
tableId - the object id of the table
|
| void |
removeFromCache(int pageId)
Remove a page from the cache.
|
| void |
removeFromCache(int pageId)
Remove a page from the cache.
Parameters:
pageId - the page id
|
| void |
removeMeta(Index index, Session session)
Remove the meta data of an index.
|
| void |
removeMeta(Index index, Session session)
Remove the meta data of an index.
Parameters:
index - the index to remove
session - the session
|
| void |
setBackup(boolean start)
|
| void |
setBackup(boolean start)
|
| void |
setInDoubtTransactionState(int sessionId, int pageId, boolean commit)
Commit or rollback a prepared transaction after opening a database with
in-doubt transactions.
|
| void |
setInDoubtTransactionState(int sessionId, int pageId, boolean commit)
Commit or rollback a prepared transaction after opening a database with
in-doubt transactions.
Parameters:
sessionId - the session id
pageId - the page where the transaction was prepared
commit - if the transaction should be committed
|
| void |
setLockFile(boolean lockFile)
|
| void |
setLockFile(boolean lockFile)
|
| void |
setLogFirstPage(int logKey, int trunkPageId, int dataPageId)
Set the trunk page and data page id of the log.
|
| void |
setLogFirstPage(int logKey, int trunkPageId, int dataPageId)
Set the trunk page and data page id of the log.
Parameters:
logKey - the log key of the trunk page
trunkPageId - the trunk page id
dataPageId - the data page id
|
| void |
setLogMode(int logMode)
|
| void |
setLogMode(int logMode)
|
| void |
setMaxLogSize(long maxSize)
Set the maximum transaction log size in megabytes.
|
| void |
setMaxLogSize(long maxSize)
Set the maximum transaction log size in megabytes.
Parameters:
maxSize - the new maximum log size
|
| void |
setPageSize(int size)
Set the page size.
|
| void |
setPageSize(int size)
Set the page size. The size must be a power of two. This method must be
called before opening.
Parameters:
size - the page size
|
| HashMap |
statisticsEnd()
Stop collecting statistics.
|
| HashMap |
statisticsEnd()
Stop collecting statistics.
Returns:
the statistics
|
| void |
statisticsStart()
Start collecting statistics.
|
| void |
statisticsStart()
Start collecting statistics.
|
| void |
sync()
Flush the transaction log and sync the file.
|
| void |
sync()
Flush the transaction log and sync the file.
|
| void |
update(Page page)
Update a page.
|
| void |
update(Page page)
Update a page.
Parameters:
page - the page
|
| void |
writeBack(CacheObject obj)
|
| void |
writeBack(CacheObject obj)
|
| void |
writePage(int pageId, Data data)
Write a page.
|
| void |
writePage(int pageId, Data data)
Write a page.
Parameters:
pageId - the page id
data - the data
|