|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.store.Storage
public class Storage
This class represents an persistent container that stores data of a table or
an index. An object contains a list of records, see Record
. For each
storage there is a RecordReader
object that knows how to convert
records into a byte array and vice versa. The data is stored in a
DiskFile
. A storage occupies a number of pages in a file.
File format:
int block size int storage id record data byte checksum [bytes * fillerLength]
Field Summary | |
---|---|
static int |
ALLOCATE_POS
This value is used to indicate that the position is not yet known, and space needs to be allocated. |
Constructor Summary | |
---|---|
Storage(Database database,
DiskFile file,
RecordReader reader,
int id)
Create a new storage object for this file. |
Method Summary | |
---|---|
void |
addRecord(Session session,
Record record,
int pos)
Add or update a record in the file. |
void |
flushRecord(Record rec)
Write this record now. |
DiskFile |
getDiskFile()
|
int |
getId()
Get the unique storage id. |
int |
getNext(Record record)
Gets the position of the next record. |
Record |
getRecord(Session session,
int pos)
Read a record from the file or cache. |
int |
getRecordCount()
Get the number of records in this storage. |
Record |
getRecordIfStored(Session session,
int pos)
Read a record if it is stored at that location. |
int |
getRecordOverhead()
Get the overhead to store a record (header data) in number of bytes. |
RecordReader |
getRecordReader()
Get the record parser for this storage. |
void |
removeRecord(Session session,
int pos)
Remove a record. |
void |
setReader(RecordReader reader)
Set the record parser for this storage. |
void |
setRecordCount(int recordCount)
Update the record count. |
void |
truncate(Session session)
Delete all records from this storage. |
void |
updateRecord(Session session,
Record record)
Update an existing record. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ALLOCATE_POS
Constructor Detail |
---|
public Storage(Database database, DiskFile file, RecordReader reader, int id)
database
- the databasefile
- the filereader
- the reader that can parse recordsid
- the storage idMethod Detail |
---|
public RecordReader getRecordReader()
public Record getRecord(Session session, int pos) throws java.sql.SQLException
session
- the sessionpos
- the position of the record
java.sql.SQLException
public Record getRecordIfStored(Session session, int pos) throws java.sql.SQLException
session
- the sessionpos
- the position where it is stored
java.sql.SQLException
public int getNext(Record record)
record
- the last record (null to get the first record)
public void updateRecord(Session session, Record record) throws java.sql.SQLException
session
- the sessionrecord
- the record
java.sql.SQLException
public void addRecord(Session session, Record record, int pos) throws java.sql.SQLException
session
- the sessionrecord
- the recordpos
- the position (use ALLOCATE_POS to add a new record)
java.sql.SQLException
public void removeRecord(Session session, int pos) throws java.sql.SQLException
session
- the sessionpos
- where the record is stored
java.sql.SQLException
public int getId()
public int getRecordCount()
public void truncate(Session session) throws java.sql.SQLException
session
- the session
java.sql.SQLException
public void setReader(RecordReader reader)
reader
- the record parserpublic void flushRecord(Record rec) throws java.sql.SQLException
rec
- the record to write
java.sql.SQLException
public int getRecordOverhead()
public DiskFile getDiskFile()
public void setRecordCount(int recordCount)
recordCount
- the new record count
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |