|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.store.DiskFile
public class DiskFile
This class represents a file that is usually written to disk. The two main
files are .data.db and .index.db. For each such file, a number of
Storage
objects exists. The disk file is responsible for caching;
each object contains a Cache
object. Changes in the file are logged
in a LogSystem
object. Reading and writing to the file is delegated
to the FileStore
class.
There are 'blocks' of 128 bytes (DiskFile.BLOCK_SIZE). Each objects own one or more pages; each page size is 64 blocks (DiskFile.BLOCKS_PER_PAGE). That is 8 KB page size. However pages are not read or written as one unit; only individual objects (multiple blocks at a time) are read or written.
Currently there are no in-place updates. Each row occupies one or multiple blocks. Rows can occupy multiple pages. Rows are always contiguous (except LOBs, they are stored in their own files).
Field Summary | |
---|---|
static int |
BLOCK_PAGE_PAGE_SHIFT
The number of bits to shift to divide a position to get the page number. |
static int |
BLOCK_SIZE
The size of a block in bytes. |
static int |
BLOCKS_PER_PAGE
The size of a page in blocks. |
Constructor Summary | |
---|---|
DiskFile(Database database,
java.lang.String fileName,
java.lang.String mode,
boolean dataFile,
boolean logChanges,
int cacheSize)
Create a new disk file. |
Method Summary | |
---|---|
void |
addRedoLog(Storage storage,
int recordId,
int blockCount,
DataPage rec)
Add a redo-log entry to the redo buffer. |
void |
close()
Flush all pending changes and close the file. |
int |
copyDirect(int pos,
java.io.OutputStream out)
Copy a number of bytes at the specified location to the output stream. |
void |
delete()
Close the file and delete it. |
void |
flush()
Flush all pending changes to disk. |
void |
flushLog()
Flush the log file, so that entries can be removed from the cache. |
void |
flushRedoLog()
Write all buffered redo log data to the file. |
Cache |
getCache()
Get the cache. |
int |
getReadCount()
|
byte[] |
getSummary()
Get the 'storage allocation table' of this file. |
Trace |
getTrace()
Get the trace writer. |
int |
getWriteCount()
|
void |
init()
Read the 'storage allocation table' from the file if required. |
void |
initFromSummary(byte[] summary)
Initialize the the 'storage allocation table' of this file from a given byte array. |
boolean |
isDataFile()
Check if this is the data file. |
void |
setLogChanges(boolean logChanges)
Set whether changes should be written to the transaction log before they are applied in the file. |
void |
setPageOwner(int page,
int storageId)
Set the owner of a page. |
void |
sync()
Flush pending writes of the underlying file. |
java.lang.String |
toString()
|
void |
writeBack(CacheObject obj)
Write a record to the file immediately. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int BLOCK_PAGE_PAGE_SHIFT
public static final int BLOCKS_PER_PAGE
public static final int BLOCK_SIZE
Constructor Detail |
---|
public DiskFile(Database database, java.lang.String fileName, java.lang.String mode, boolean dataFile, boolean logChanges, int cacheSize) throws java.sql.SQLException
database
- the databasefileName
- the file namemode
- the file opening mode ("r", "rw", "rws", "rwd")dataFile
- if this is the data filelogChanges
- if changes should be loggedcacheSize
- the number of cache entries
java.sql.SQLException
Method Detail |
---|
public byte[] getSummary() throws java.sql.SQLException
java.sql.SQLException
public void initFromSummary(byte[] summary)
summary
- the storage allocation tablepublic void init() throws java.sql.SQLException
java.sql.SQLException
public void flush() throws java.sql.SQLException
java.sql.SQLException
public void close() throws java.sql.SQLException
java.sql.SQLException
public void setPageOwner(int page, int storageId) throws java.sql.SQLException
page
- the page idstorageId
- the storage id of this page
java.sql.SQLException
public void delete() throws java.sql.SQLException
java.sql.SQLException
public void writeBack(CacheObject obj) throws java.sql.SQLException
writeBack
in interface CacheWriter
obj
- the record to write
java.sql.SQLException
public int copyDirect(int pos, java.io.OutputStream out) throws java.sql.SQLException
pos
- the positionout
- the output stream
java.sql.SQLException
public Cache getCache()
public void sync()
public boolean isDataFile()
public void setLogChanges(boolean logChanges)
logChanges
- the new valuepublic void addRedoLog(Storage storage, int recordId, int blockCount, DataPage rec) throws java.sql.SQLException
storage
- the storagerecordId
- the record id of the entryblockCount
- the number of blocksrec
- the record
java.sql.SQLException
public void flushRedoLog() throws java.sql.SQLException
java.sql.SQLException
public int getWriteCount()
public int getReadCount()
public void flushLog() throws java.sql.SQLException
CacheWriter
flushLog
in interface CacheWriter
java.sql.SQLException
public java.lang.String toString()
toString
in class java.lang.Object
public Trace getTrace()
CacheWriter
getTrace
in interface CacheWriter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |