| java.lang.Object org.apache.derby.impl.store.raw.data.StoredFieldHeader
StoredFieldHeader | final public class StoredFieldHeader (Code) | | A class to provide static methods to manipulate fields in the field header.
A class StoredPage uses to read/write field status and field data length.
No attributes exist in this class, this class provides a set of static
methods for writing field status and field data length, and for reading
field status and field data length.
Stored Field Header Format
The field header is broken into two sections.
Only the Status byte is required to be there.
Field header format:
+--------+-------------------+
| status | |
+--------+-------------------+
Overflow page and overflow id are stored as field data.
If the overflow bit in status is set, the field data is the overflow
information. When the overflow bit is not set in status, then,
fieldData is the actually user data for the field.
That means, field header consists only field status, and field data length.
A non-overflow field:
+--------+-------------------+-------------+
| status | | |
+--------+-------------------+-------------+
An overflow field:
+--------+-------------------+-----------------+--------------+
| status | | | |
+--------+-------------------+-----------------+--------------+
status
The status is 1 byte, it indicates the state of the field.
A FieldHeader can be in the following states:
NULL - if the field is NULL, no field data length is stored
OVERFLOW - indicates the field has been overflowed to another page.
overflow page and overflow ID is stored at the end of the
user data. field data length must be a number greater or
equal to 0, indicating the length of the field that is stored
on the current page.
The format looks like this:
+--------+-----------------+---------------+------------+
|||||
+--------+-----------------+---------------+------------+
overflowPage will be written as compressed long,
overflowId will be written as compressed Int
NONEXISTENT - the field no longer exists,
e.g. column has been dropped during an alter table
EXTENSIBLE - the field is of user defined data type.
The field may be tagged.
TAGGED - the field is TAGGED if and only if it is EXTENSIBLE.
FIXED - the field is FIXED if and only if it is used in the log
records for version 1.2 and higher.
fieldDataLength
The fieldDataLength is only set if the field is not NULL. It is the length
of the field that is stored on the current page.
The fieldDataLength is a variable length CompressedInt.
overflowPage and overflowID
The overflowPage is a variable length CompressedLong, overflowID is a
variable Length CompressedInt.
They are only stored when the field state is OVERFLOW.
And they are not stored in the field header.
Instead, they are stored at the end of the field data.
The reason we do that is to save a copy if the field has to overflow.
MT - Mutable - Immutable identity - Thread Aware
|
Method Summary | |
final public static boolean | isExtensible(int status) | final public static boolean | isFixed(int status) | final public static boolean | isNonexistent(int status) | final public static boolean | isNull(int status) | final public static boolean | isNullable(int status) | final public static boolean | isNullorNonExistent(int status) | final public static boolean | isOverflow(int status) | final public static boolean | isTagged(int status) | final public static int | readFieldDataLength(ObjectInput in, int status, int fieldDataSize) | final public static int | readFieldLengthAndSetStreamPosition(byte[] data, int offset, int status, int fieldDataSize, ArrayInputStream ais) | final public static int | readStatus(ObjectInput in) | final public static int | readStatus(byte[] page, int offset) | final public static int | readTotalFieldLength(byte[] data, int offset) read the length of the field and hdr.
Optimized routine used to skip a field on a page. | final public static int | setExtensible(int status, boolean isExtensible) | final public static int | setFixed(int status, boolean isFixed) | final public static int | setInitial() Set accessors for setting bits in the status field. | final public static int | setNonexistent(int status) | final public static int | setNull(int status, boolean isNull) | final public static int | setOverflow(int status, boolean isOverflow) | final public static int | setTagged(int status, boolean isTagged) | final public static int | size(int status, int fieldDataLength, int fieldDataSize) | public static String | toDebugString(int status) | final public static int | write(OutputStream out, int status, int fieldDataLength, int fieldDataSize) |
FIELD_EXTENSIBLE | final public static int FIELD_EXTENSIBLE(Code) | | |
FIELD_FIXED | final protected static int FIELD_FIXED(Code) | | |
FIELD_NONEXISTENT | final public static int FIELD_NONEXISTENT(Code) | | |
FIELD_NULL | final public static int FIELD_NULL(Code) | | |
FIELD_OVERFLOW | final public static int FIELD_OVERFLOW(Code) | | |
FIELD_TAGGED | final public static int FIELD_TAGGED(Code) | | |
STORED_FIELD_HEADER_STATUS_SIZE | final public static int STORED_FIELD_HEADER_STATUS_SIZE(Code) | | |
isExtensible | final public static boolean isExtensible(int status)(Code) | | |
isFixed | final public static boolean isFixed(int status)(Code) | | |
isNonexistent | final public static boolean isNonexistent(int status)(Code) | | |
isNull | final public static boolean isNull(int status)(Code) | | Get the status of the field
MT - single thread required
|
isNullable | final public static boolean isNullable(int status)(Code) | | |
isNullorNonExistent | final public static boolean isNullorNonExistent(int status)(Code) | | |
isOverflow | final public static boolean isOverflow(int status)(Code) | | |
isTagged | final public static boolean isTagged(int status)(Code) | | |
readFieldDataLength | final public static int readFieldDataLength(ObjectInput in, int status, int fieldDataSize) throws IOException(Code) | | read the field data length
exception: IOException - Thrown by potential I/O errors while reading field header. |
readFieldLengthAndSetStreamPosition | final public static int readFieldLengthAndSetStreamPosition(byte[] data, int offset, int status, int fieldDataSize, ArrayInputStream ais) throws IOException(Code) | | |
readStatus | final public static int readStatus(byte[] page, int offset)(Code) | | |
readTotalFieldLength | final public static int readTotalFieldLength(byte[] data, int offset) throws IOException(Code) | | read the length of the field and hdr.
Optimized routine used to skip a field on a page. It returns the
total length of the field including the header portion. It operates
directly on the array and does no checking of it's own for limits on
the array length, so an array out of bounds exception may be thrown -
the routine is meant to be used to read a field from a page so this
should not happen.
The length of the field on the page, including it's header. Parameters: data - the array where the field is. Parameters: offset - the offset in the array where the field begin, ie. the status byte is at data[offset]. exception: StandardException - Standard exception policy. |
setExtensible | final public static int setExtensible(int status, boolean isExtensible)(Code) | | |
setFixed | final public static int setFixed(int status, boolean isFixed)(Code) | | |
setInitial | final public static int setInitial()(Code) | | Set accessors for setting bits in the status field.
|
setNonexistent | final public static int setNonexistent(int status)(Code) | | |
setNull | final public static int setNull(int status, boolean isNull)(Code) | | |
setOverflow | final public static int setOverflow(int status, boolean isOverflow)(Code) | | |
setTagged | final public static int setTagged(int status, boolean isTagged)(Code) | | |
size | final public static int size(int status, int fieldDataLength, int fieldDataSize)(Code) | | |
toDebugString | public static String toDebugString(int status)(Code) | | |
write | final public static int write(OutputStream out, int status, int fieldDataLength, int fieldDataSize) throws IOException(Code) | | write out the field status and field data Length
exception: IOException - Thrown by potential I/O errors while writing field header. |
|
|