|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.h2.store.PageStore
public class PageStore
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:
| Field Summary | |
|---|---|
static int |
PAGE_SIZE_DEFAULT
The default page size. |
static int |
PAGE_SIZE_MAX
The biggest possible page size. |
static int |
PAGE_SIZE_MIN
The smallest possible page size. |
| Constructor Summary | |
|---|---|
PageStore(Database database,
java.lang.String fileName,
java.lang.String accessMode,
int cacheSizeDefault)
Create a new page store object. |
|
| Method Summary | |
|---|---|
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 re-open the log file. |
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(boolean fully)
Shrink the file so there are no empty pages at the end. |
int |
copyDirect(int pageId,
java.io.OutputStream out)
Copy the next page to the output stream. |
Data |
createData()
Create a data object. |
void |
flushLog()
Flush the log file, 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. |
ObjectArray<InDoubtTransaction> |
getInDoubtTransactions()
Get the list of in-doubt transaction. |
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. |
Record |
getRecord(int pos)
Get the record if it is stored in the file, or null if not. |
int |
getRootPageId(int indexId)
Get the root page of an index. |
int |
getSystemTableHeadPos()
Get the position of the system table head. |
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 |
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(Record record,
Data old)
Write an undo log entry if required. |
static SearchRow[] |
newSearchRows(int entryCount)
Create an array of SearchRow with the given size. |
void |
open()
Open the file and read the header. |
void |
prepareCommit(Session session,
java.lang.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 |
setMaxLogSize(long maxSize)
Set the maximum log file size in megabytes. |
void |
update(Page page)
Update a page. |
void |
writeBack(CacheObject obj)
Persist a record. |
void |
writePage(int pageId,
Data data)
Write a page. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int PAGE_SIZE_MIN
public static final int PAGE_SIZE_MAX
public static final int PAGE_SIZE_DEFAULT
| Constructor Detail |
|---|
public PageStore(Database database,
java.lang.String fileName,
java.lang.String accessMode,
int cacheSizeDefault)
throws java.sql.SQLException
database - the databasefileName - the file nameaccessMode - the access modecacheSizeDefault - the default cache size
java.sql.SQLException| Method Detail |
|---|
public int copyDirect(int pageId,
java.io.OutputStream out)
throws java.sql.SQLException
pageId - the page to copyout - the output stream
java.sql.SQLException
public void open()
throws java.sql.SQLException
java.sql.SQLException
public void checkpoint()
throws java.sql.SQLException
java.sql.SQLException
public void compact(boolean fully)
throws java.sql.SQLException
fully - if the database should be fully compressed
java.sql.SQLException
public Page getPage(int pageId)
throws java.sql.SQLException
pageId - the page id
java.sql.SQLException
public void close()
throws java.sql.SQLException
java.sql.SQLException
public void flushLog()
throws java.sql.SQLException
CacheWriter
flushLog in interface CacheWriterjava.sql.SQLExceptionpublic Trace getTrace()
CacheWriter
getTrace in interface CacheWriter
public void writeBack(CacheObject obj)
throws java.sql.SQLException
CacheWriter
writeBack in interface CacheWriterobj - the cache entry
java.sql.SQLException
public void logUndo(Record record,
Data old)
throws java.sql.SQLException
record - the pageold - the old data (if known) or null
java.sql.SQLException
public void update(Page page)
throws java.sql.SQLException
page - the page
java.sql.SQLException
public int allocatePage()
throws java.sql.SQLException
java.sql.SQLException
public void free(int pageId)
throws java.sql.SQLException
pageId - the page id
java.sql.SQLExceptionpublic Data createData()
public Record getRecord(int pos)
pos - the page id
public Data readPage(int pos)
throws java.sql.SQLException
pos - the page id
java.sql.SQLExceptionpublic int getPageSize()
public int getPageCount()
public void writePage(int pageId,
Data data)
throws java.sql.SQLException
pageId - the page iddata - the data
java.sql.SQLExceptionpublic void removeRecord(int pageId)
pageId - the page id
public void logAddOrRemoveRow(Session session,
int tableId,
Row row,
boolean add)
throws java.sql.SQLException
session - the sessiontableId - the table idrow - the row to addadd - true if the row is added, false if it is removed
java.sql.SQLException
public void commit(Session session)
throws java.sql.SQLException
session - the session
java.sql.SQLException
public void prepareCommit(Session session,
java.lang.String transaction)
throws java.sql.SQLException
session - the sessiontransaction - the name of the transaction
java.sql.SQLExceptionpublic int getSystemTableHeadPos()
public void addIndex(PageIndex index)
index - the index
public void addMeta(PageIndex index,
Session session)
throws java.sql.SQLException
index - the index to addsession - the session
java.sql.SQLException
public void removeMeta(Index index,
Session session)
throws java.sql.SQLException
index - the index to removesession - the session
java.sql.SQLExceptionpublic void setMaxLogSize(long maxSize)
maxSize - the new maximum log file size
public void setInDoubtTransactionState(int sessionId,
int pageId,
boolean commit)
throws java.sql.SQLException
sessionId - the session idpageId - the page where the transaction was preparedcommit - if the transaction should be committed
java.sql.SQLExceptionpublic ObjectArray<InDoubtTransaction> getInDoubtTransactions()
public boolean isRecoveryRunning()
public static SearchRow[] newSearchRows(int entryCount)
entryCount - the number of elements
public long getWriteCountTotal()
public long getWriteCount()
public long getReadCount()
public void logTruncate(Session session,
int tableId)
throws java.sql.SQLException
session - the sessiontableId - the table id
java.sql.SQLExceptionpublic int getRootPageId(int indexId)
indexId - the index id
public Cache getCache()
public static boolean checksumTest(byte[] d,
int pageId,
int pageSize)
d - the datapageId - the page idpageSize - the page size
public void incrementChangeCount()
public int getChangeCount()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||