org.h2.store
Class Record

java.lang.Object
  extended by org.h2.util.CacheObject
      extended by org.h2.store.Record
Direct Known Subclasses:
BtreeHead, BtreePage, Page, Row

public abstract class Record
extends CacheObject

A record represents a persisted row in a table, or a index page. When a record is persisted to disk, it is first written into a DataPage buffer.


Field Summary
 
Fields inherited from class org.h2.util.CacheObject
blockCount, cacheQueue, chained, next, previous
 
Constructor Summary
Record()
           
 
Method Summary
 boolean canRemove()
          Check if the object can be removed from the cache.
 void commit()
          This record has been committed.
abstract  int getByteCount(DataPage dummy)
          Get the number of bytes required for the data if the given data page would be used.
 int getSessionId()
           
 int getStorageId()
           
 boolean isDeleted()
           
 boolean isEmpty()
          Check if this record is empty.
 boolean isLogWritten()
          Check if this record has been written to the log file.
 void prepareWrite()
          This method is called just before the page is written.
 void setDeleted(boolean deleted)
           
 void setLastLog(int log, int pos)
          Set the last log file and position where this record needs to be written.
 void setLogWritten(int log, int pos)
          Set the last log file and position where this record was written.
 void setSessionId(int sessionId)
           
 void setStorageId(int storageId)
           
abstract  void write(DataPage buff)
          Write the record to the data page.
 
Methods inherited from class org.h2.util.CacheObject
getBlockCount, getMemorySize, getPos, isChanged, isPinned, setBlockCount, setChanged, setPos, sort
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Record

public Record()
Method Detail

getByteCount

public abstract int getByteCount(DataPage dummy)
                          throws java.sql.SQLException
Get the number of bytes required for the data if the given data page would be used.

Parameters:
dummy - the template data page
Returns:
the number of bytes
Throws:
java.sql.SQLException

write

public abstract void write(DataPage buff)
                    throws java.sql.SQLException
Write the record to the data page.

Parameters:
buff - the data page
Throws:
java.sql.SQLException

prepareWrite

public void prepareWrite()
                  throws java.sql.SQLException
This method is called just before the page is written. If a read operation is required before writing, this needs to be done here. Because the data page buffer is shared for read and write operations. The method may read data and change the file pointer.

Throws:
java.sql.SQLException

isEmpty

public boolean isEmpty()
Check if this record is empty.

Returns:
false

setDeleted

public void setDeleted(boolean deleted)

setSessionId

public void setSessionId(int sessionId)

getSessionId

public int getSessionId()

commit

public void commit()
This record has been committed. The session id is reset.


isDeleted

public boolean isDeleted()

setStorageId

public void setStorageId(int storageId)

getStorageId

public int getStorageId()

setLastLog

public void setLastLog(int log,
                       int pos)
Set the last log file and position where this record needs to be written.

Parameters:
log - the log file id
pos - the position in the log file

setLogWritten

public void setLogWritten(int log,
                          int pos)
Set the last log file and position where this record was written.

Parameters:
log - the log file id
pos - the position in the log file

canRemove

public boolean canRemove()
Description copied from class: CacheObject
Check if the object can be removed from the cache. For example pinned objects can not be removed.

Specified by:
canRemove in class CacheObject
Returns:
true if it can be removed

isLogWritten

public boolean isLogWritten()
Check if this record has been written to the log file.

Returns:
true if it is