public class PageStore extends Object implements CacheWriter
| Modifier and Type | Field and Description |
|---|---|
static int |
LOG_MODE_OFF
This log mode means the transaction log is not used.
|
static int |
LOG_MODE_SYNC
This log mode means the transaction log is used and FileDescriptor.sync()
is called for each checkpoint.
|
static int |
PAGE_SIZE_MAX
The biggest possible page size.
|
static int |
PAGE_SIZE_MIN
The smallest possible page size.
|
| Constructor and Description |
|---|
PageStore(Database database,
String fileName,
String accessMode,
int cacheSizeDefault)
Create a new page store object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addIndex(PageIndex index)
Add an index to the in-memory index map.
|
void |
addMeta(PageIndex index,
Session session)
Add the meta data of an index.
|
int |
allocatePage()
Allocate a page.
|
void |
checkpoint()
Flush all pending changes to disk, and switch the new transaction log.
|
static boolean |
checksumTest(byte[] d,
int pageId,
int pageSize)
Check if the stored checksum is correct
|
void |
close()
Close the file without further writing.
|
void |
commit(Session session)
Mark a committed transaction.
|
void |
compact(int compactMode)
Shrink the file so there are no empty pages at the end.
|
int |
copyDirect(int pageId,
OutputStream out)
Copy the next page to the output stream.
|
Data |
createData()
Create a data object.
|
void |
flushLog()
Flush the transaction log, so that entries can be removed from the cache.
|
void |
free(int pageId)
Add a page to the free list.
|
Cache |
getCache() |
int |
getChangeCount()
Get the current change count.
|
ArrayList<InDoubtTransaction> |
getInDoubtTransactions()
Get the list of in-doubt transaction.
|
int |
getLogMode() |
BitField |
getObjectIds() |
Page |
getPage(int pageId)
Read a page from the store.
|
int |
getPageCount()
Get the number of pages (including free pages).
|
int |
getPageSize()
Get the page size.
|
long |
getReadCount()
Get the file read count since the database was opened.
|
int |
getRootPageId(int indexId)
Get the root page of an index.
|
Session |
getSystemSession() |
Trace |
getTrace()
Get the trace writer.
|
long |
getWriteCount()
Get the file write count since the database was opened.
|
long |
getWriteCountTotal()
Get the file write count since the database was created.
|
void |
incrementChangeCount()
Increment the change count.
|
boolean |
isNew()
Check whether this is a new database.
|
boolean |
isRecoveryRunning()
Check whether the recovery process is currently running.
|
void |
logAddOrRemoveRow(Session session,
int tableId,
Row row,
boolean add)
A record is added to a table, or removed from a table.
|
void |
logTruncate(Session session,
int tableId)
A table is truncated.
|
void |
logUndo(Page page,
Data old)
Write an undo log entry if required.
|
void |
open()
Open the file and read the header.
|
void |
prepareCommit(Session session,
String transaction)
Prepare a transaction.
|
Data |
readPage(int pos)
Read a page.
|
void |
removeMeta(Index index,
Session session)
Remove the meta data of an index.
|
void |
removeRecord(int pageId)
Remove a page from the cache.
|
void |
setInDoubtTransactionState(int sessionId,
int pageId,
boolean commit)
Commit or rollback a prepared transaction after opening a database with
in-doubt transactions.
|
void |
setLockFile(boolean lockFile) |
void |
setLogMode(int logMode) |
void |
setMaxLogSize(long maxSize)
Set the maximum transaction log size in megabytes.
|
void |
setPageSize(int size)
Set the page size.
|
HashMap<String,Integer> |
statisticsEnd()
Stop collecting statistics.
|
void |
statisticsStart()
Start collecting statistics.
|
void |
sync()
Flush the transaction log and sync the file.
|
void |
update(Page page)
Update a page.
|
void |
writeBack(CacheObject obj)
Persist a record.
|
void |
writePage(int pageId,
Data data)
Write a page.
|
public static final int PAGE_SIZE_MIN
public static final int PAGE_SIZE_MAX
public static final int LOG_MODE_OFF
public static final int LOG_MODE_SYNC
public void statisticsStart()
public HashMap<String,Integer> statisticsEnd()
public int copyDirect(int pageId,
OutputStream out)
throws IOException
pageId - the page to copyout - the output streamIOExceptionpublic void open()
public void checkpoint()
public void compact(int compactMode)
compactMode - 0 if no compacting should happen, otherwise
TransactionCommand.SHUTDOWN_COMPACT or TransactionCommand.SHUTDOWN_DEFRAGpublic Page getPage(int pageId)
pageId - the page idpublic void setPageSize(int size)
size - the page sizepublic void close()
public void flushLog()
CacheWriterflushLog in interface CacheWriterpublic void sync()
public Trace getTrace()
CacheWritergetTrace in interface CacheWriterpublic void writeBack(CacheObject obj)
CacheWriterwriteBack in interface CacheWriterobj - the cache entrypublic void logUndo(Page page, Data old)
page - the pageold - the old data (if known) or nullpublic void update(Page page)
page - the pagepublic int allocatePage()
public void free(int pageId)
pageId - the page idpublic Data createData()
public Data readPage(int pos)
pos - the page idpublic int getPageSize()
public int getPageCount()
public void writePage(int pageId,
Data data)
pageId - the page iddata - the datapublic void removeRecord(int pageId)
pageId - the page idpublic void logAddOrRemoveRow(Session session, int tableId, Row row, boolean add)
session - the sessiontableId - the table idrow - the row to addadd - true if the row is added, false if it is removedpublic void commit(Session session)
session - the sessionpublic void prepareCommit(Session session, String transaction)
session - the sessiontransaction - the name of the transactionpublic boolean isNew()
public void addIndex(PageIndex index)
index - the indexpublic void addMeta(PageIndex index, Session session)
index - the index to addsession - the sessionpublic void removeMeta(Index index, Session session)
index - the index to removesession - the sessionpublic void setMaxLogSize(long maxSize)
maxSize - the new maximum log sizepublic void setInDoubtTransactionState(int sessionId,
int pageId,
boolean commit)
sessionId - the session idpageId - the page where the transaction was preparedcommit - if the transaction should be committedpublic ArrayList<InDoubtTransaction> getInDoubtTransactions()
public boolean isRecoveryRunning()
public long getWriteCountTotal()
public long getWriteCount()
public long getReadCount()
public void logTruncate(Session session, int tableId)
session - the sessiontableId - the table idpublic int getRootPageId(int indexId)
indexId - the index idpublic Cache getCache()
public static boolean checksumTest(byte[] d,
int pageId,
int pageSize)
d - the datapageId - the page idpageSize - the page sizepublic void incrementChangeCount()
public int getChangeCount()
public void setLogMode(int logMode)
public int getLogMode()
public void setLockFile(boolean lockFile)
public BitField getObjectIds()
public Session getSystemSession()
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.