org.apache.derby.impl.store.raw.data
Class StoredRecordHeader

java.lang.Object
  extended byorg.apache.derby.impl.store.raw.data.StoredRecordHeader

public final class StoredRecordHeader
extends java.lang.Object

A class StoredPage uses to cache record headers by passing instances to BasePage, and to write stored versions of record headers. Format


        1 byte          - status
        compressed int  - record identifier

        compressed long - overflow page } only if hasOverflow() is true
        compressed int  - overflow id   }     "        "           "

        compressed int  - first field   } only if hasFirstField set - otherwise 0

        compressed int  - number of fields in this portion - only if hasOverflow()
                                                                is false OR hasFirstField is true - otherwise 0
        


Field Summary
protected  int firstField
          if (hasFirstField()) then this field is the number of the column in the orginal row which is now stored as the first field in this row.
protected  RecordHandle handle
          A record handle that can represent the record, may be null.
protected  int id
          Actual identifier of the record
MT - Mutable
protected  int numberFields
          number of fields in the row.
protected  int overflowId
          If (hasOverflow()) then this is the id of the row on page overflowPage where the next portion of the row can be found.
protected  long overflowPage
          If (hasOverflow()) then this is the page where where the next portion of the row can be found.
static int RECORD_DELETED
           
static int RECORD_HAS_FIRST_FIELD
           
static int RECORD_INITIAL
          Status bits for the record header: RECORD_INITIAL - used when record header is first initialized RECORD_DELETED - used to indicate the record has been deleted RECORD_OVERFLOW - used to indicate the record has been overflowed, it will point to the overflow page and ID RECORD_HAS_FIRST_FIELD - used to indicate that firstField is stored will be stored.
static int RECORD_OVERFLOW
           
static int RECORD_VALID_MASK
           
protected  int status
          Status of the record.
 
Constructor Summary
StoredRecordHeader()
          Constructors for This class:
StoredRecordHeader(byte[] data, int offset)
           
StoredRecordHeader(int id, int numberFields)
           
StoredRecordHeader(StoredRecordHeader loadTargetFrom)
           
 
Method Summary
 int getFirstField()
           
protected  RecordHandle getHandle(PageKey pageId, int current_slot)
          Get a record handle for the record.
 int getId()
          Get the record identifier
MT - thread safe
 int getNumberFields()
           
 int getOverflowId()
           
 long getOverflowPage()
           
protected  boolean hasFirstField()
           
 boolean hasOverflow()
           
 boolean isDeleted()
          Get the deleted state of the record.
private  void read(byte[] data, int offset)
           
 void read(java.io.ObjectInput in)
           
private  int readFirstField(byte[] data, int offset)
           
private  int readId(byte[] data, int offset)
           
private  void readNumberFields(byte[] data, int offset)
           
private  int readOverFlowId(byte[] data, int offset)
           
private  int readOverFlowPage(byte[] data, int offset)
           
 int setDeleted(boolean deleteTrue)
          Set the deleted state of the record.
 void setFirstField(int firstField)
           
 void setId(int id)
           
 void setNumberFields(int numberFields)
           
 void setOverflowDetails(RecordHandle overflowHandle)
           
 void setOverflowFields(StoredRecordHeader loadFromTarget)
           
 int size()
          return the size of the record header.
 java.lang.String toString()
           
 int write(java.io.OutputStream out)
          Public Methods implmenting read/write of Storable Interface:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RECORD_INITIAL

public static final int RECORD_INITIAL
Status bits for the record header: RECORD_INITIAL - used when record header is first initialized RECORD_DELETED - used to indicate the record has been deleted RECORD_OVERFLOW - used to indicate the record has been overflowed, it will point to the overflow page and ID RECORD_HAS_FIRST_FIELD - used to indicate that firstField is stored will be stored. When RECORD_OVERFLOW and RECORD_HAS_FIRST_FIELD both are set, part of record is on the page, the record header also stores the overflow point to the next part of the record. RECORD_VALID_MASK - A mask of valid bits that can be set currently, such that the following assert can be made: ASSERT((status & ~RECORD_VALID_MASK) == 0))

See Also:
Constant Field Values

RECORD_DELETED

public static final int RECORD_DELETED
See Also:
Constant Field Values

RECORD_OVERFLOW

public static final int RECORD_OVERFLOW
See Also:
Constant Field Values

RECORD_HAS_FIRST_FIELD

public static final int RECORD_HAS_FIRST_FIELD
See Also:
Constant Field Values

RECORD_VALID_MASK

public static final int RECORD_VALID_MASK
See Also:
Constant Field Values

id

protected int id
Actual identifier of the record
MT - Mutable


status

protected int status
Status of the record. See above for description of fields: RECORD_INITIAL RECORD_DELETED RECORD_OVERFLOW RECORD_HAS_FIRST_FIELD RECORD_VALID_MASK
MT - Mutable - single thread required.


numberFields

protected int numberFields
number of fields in the row.


handle

protected RecordHandle handle
A record handle that can represent the record, may be null.


overflowId

protected int overflowId
If (hasOverflow()) then this is the id of the row on page overflowPage where the next portion of the row can be found. In this case there are no "real" fields on this page. This situation comes about if a row has been updated such that the real first field no longer fits on the head page.


overflowPage

protected long overflowPage
If (hasOverflow()) then this is the page where where the next portion of the row can be found. In this case there are no "real" fields on this page.


firstField

protected int firstField
if (hasFirstField()) then this field is the number of the column in the orginal row which is now stored as the first field in this row. This row is 2nd through N'th portion of a long row. For example if a row has its first 3 fields on page 0 and its next 3 fields on page 1, then the record header of the row portion on page 1 will have hasFirstField() set to true, and the value would be 4, indicating that the 4th field of the row is stored as the 1st field of the partial row portion stored on page 1.

Constructor Detail

StoredRecordHeader

public StoredRecordHeader()
Constructors for This class:


StoredRecordHeader

public StoredRecordHeader(int id,
                          int numberFields)

StoredRecordHeader

public StoredRecordHeader(byte[] data,
                          int offset)

StoredRecordHeader

public StoredRecordHeader(StoredRecordHeader loadTargetFrom)
Method Detail

getHandle

protected RecordHandle getHandle(PageKey pageId,
                                 int current_slot)
Get a record handle for the record.


MT - single thread required


getId

public final int getId()
Get the record identifier
MT - thread safe


getNumberFields

public int getNumberFields()

getOverflowPage

public long getOverflowPage()

getOverflowId

public int getOverflowId()

getFirstField

public int getFirstField()

hasOverflow

public final boolean hasOverflow()

hasFirstField

protected final boolean hasFirstField()

isDeleted

public final boolean isDeleted()
Get the deleted state of the record.


MT - single thread required


size

public int size()
return the size of the record header.

Calculates the size of the record header, mostly used to allow a reader to skip over the record header and position on the 1st field of the record.

This low level routine is performance critical to processing lots of rows, so calls to CompressNumber have been hand inlined.

Returns:
The length of the record header.
Throws:
StandardException - Standard exception policy.

setDeleted

public int setDeleted(boolean deleteTrue)
Set the deleted state of the record.

return 1, if delete status from not deleted to deleted return -1, if delete status from deleted to not deleted return 0, if status unchanged.
MT - single thread required


setFirstField

public void setFirstField(int firstField)

setId

public final void setId(int id)

setOverflowDetails

public void setOverflowDetails(RecordHandle overflowHandle)

setOverflowFields

public void setOverflowFields(StoredRecordHeader loadFromTarget)

setNumberFields

public final void setNumberFields(int numberFields)

write

public int write(java.io.OutputStream out)
          throws java.io.IOException
Public Methods implmenting read/write of Storable Interface:

Throws:
java.io.IOException

read

public void read(java.io.ObjectInput in)
          throws java.io.IOException
Throws:
java.io.IOException

readId

private int readId(byte[] data,
                   int offset)

readOverFlowPage

private int readOverFlowPage(byte[] data,
                             int offset)

readOverFlowId

private int readOverFlowId(byte[] data,
                           int offset)

readFirstField

private int readFirstField(byte[] data,
                           int offset)

readNumberFields

private void readNumberFields(byte[] data,
                              int offset)

read

private void read(byte[] data,
                  int offset)

toString

public java.lang.String toString()

Built on Tue 2006-10-10 19:23:47+0200, from revision exported

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.