|
||||||||||
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. |
static boolean |
STORE_BTREE_ROWCOUNT
Store the rowcount in b-tree indexes. |
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. |
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 |
freePage(int pageId,
boolean logUndo,
Data old)
Add a page to the free list. |
Cache |
getCache()
|
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. |
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 write 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. |
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 |
trim()
Shrink the file so there are no empty pages at the end. |
void |
updateRecord(Record record,
boolean logUndo,
Data old)
Update a record. |
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
public static final boolean STORE_BTREE_ROWCOUNT
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 trim() throws java.sql.SQLException
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 CacheWriter
java.sql.SQLException
public Trace getTrace()
CacheWriter
getTrace
in interface CacheWriter
public void writeBack(CacheObject obj) throws java.sql.SQLException
CacheWriter
writeBack
in interface CacheWriter
obj
- the cache entry
java.sql.SQLException
public void updateRecord(Record record, boolean logUndo, Data old) throws java.sql.SQLException
record
- the recordlogUndo
- if an undo entry need to be loggedold
- the old data (if known)
java.sql.SQLException
public int allocatePage() throws java.sql.SQLException
java.sql.SQLException
public void freePage(int pageId, boolean logUndo, Data old) throws java.sql.SQLException
pageId
- the page idlogUndo
- if an undo entry need to be loggedold
- the old data (if known)
java.sql.SQLException
public 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.SQLException
public int getPageSize()
public int getPageCount()
public void writePage(int pageId, Data data) throws java.sql.SQLException
pageId
- the page iddata
- the data
java.sql.SQLException
public void removeRecord(int pageId)
pageId
- the page idpublic 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.SQLException
public int getSystemTableHeadPos()
public void addIndex(PageIndex index)
index
- the indexpublic 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.SQLException
public void setMaxLogSize(long maxSize)
maxSize
- the new maximum log file sizepublic 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.SQLException
public ObjectArray<InDoubtTransaction> getInDoubtTransactions()
public boolean isRecoveryRunning()
public static SearchRow[] newSearchRows(int entryCount)
entryCount
- the number of elements
public long getWriteCount()
public void logTruncate(Session session, int tableId) throws java.sql.SQLException
session
- the sessiontableId
- the table id
java.sql.SQLException
public 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |