Top Description Fields Constructors Methods
org.apache.derby.impl.store.raw.data

public final Class StoredFieldHeader

extends Object
Class Inheritance
Imports
java.io.EOFException, .IOException, .ObjectInput, .OutputStream, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.io.ArrayInputStream, .CompressedNumber, .DataInputUtil, org.apache.derby.shared.common.sanity.SanityManager

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

Field Summary

Modifier and TypeField and Description
public static final int
protected static final int
private static final int
FIELD_INITIAL

Constants of the class

public static final int
private static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static final boolean
isExtensible(int status)

public static final boolean
isFixed(int status)

public static final boolean
isNonexistent(int status)

public static final boolean
isNull(int status)

Get the status of the field MT - single thread required

public static final boolean
isNullable(int status)

public static final boolean
isNullorNonExistent(int status)

public static final boolean
isOverflow(int status)

public static final boolean
isTagged(int status)

public static final int
readFieldDataLength(ObjectInput in, int status, int fieldDataSize)

read the field data length

public static final int
readFieldLengthAndSetStreamPosition(byte[] data, int offset, int status, int fieldDataSize, ArrayInputStream ais)

public static final int
readStatus(ObjectInput in)

read the field status

public static final int
readStatus(byte[] page, int offset)

public static final int

Returns:

The length of the field on the page, including it's header.
readTotalFieldLength
(byte[]
the array where the field is.
data
,
int
the offset in the array where the field begin, ie. the status byte is at data[offset].
offset
)

read the length of the field and hdr.

public static final int
setExtensible(int status, boolean isExtensible)

public static final int
setFixed(int status, boolean isFixed)

public static final int
setInitial()

Set accessors for setting bits in the status field.

public static final int
setNonexistent(int status)

public static final int
setNull(int status, boolean isNull)

public static final int
setOverflow(int status, boolean isOverflow)

public static final int
setTagged(int status, boolean isTagged)

public static final int
size(int status, int fieldDataLength, int fieldDataSize)

public static String
toDebugString(int status)

public static final int
write(OutputStream out, int status, int fieldDataLength, int fieldDataSize)

write out the field status and field data Length

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FIELD_EXTENSIBLEback to summary
public static final int FIELD_EXTENSIBLE
FIELD_FIXEDback to summary
protected static final int FIELD_FIXED
FIELD_INITIALback to summary
private static final int FIELD_INITIAL

Constants of the class

FIELD_NONEXISTENTback to summary
public static final int FIELD_NONEXISTENT
FIELD_NOT_NULLABLEback to summary
private static final int FIELD_NOT_NULLABLE
FIELD_NULLback to summary
public static final int FIELD_NULL
FIELD_OVERFLOWback to summary
public static final int FIELD_OVERFLOW
FIELD_TAGGEDback to summary
public static final int FIELD_TAGGED
STORED_FIELD_HEADER_STATUS_SIZEback to summary
public static final int STORED_FIELD_HEADER_STATUS_SIZE

Constructor Detail

StoredFieldHeaderback to summary
public StoredFieldHeader()

Method Detail

isExtensibleback to summary
public static final boolean isExtensible(int status)
isFixedback to summary
public static final boolean isFixed(int status)
isNonexistentback to summary
public static final boolean isNonexistent(int status)
isNullback to summary
public static final boolean isNull(int status)

Get the status of the field
MT - single thread required

isNullableback to summary
public static final boolean isNullable(int status)
isNullorNonExistentback to summary
public static final boolean isNullorNonExistent(int status)
isOverflowback to summary
public static final boolean isOverflow(int status)
isTaggedback to summary
public static final boolean isTagged(int status)
readFieldDataLengthback to summary
public static final int readFieldDataLength(ObjectInput in, int status, int fieldDataSize) throws IOException

read the field data length

Exceptions
IOException:
Thrown by potential I/O errors while reading field header.
readFieldLengthAndSetStreamPositionback to summary
public static final int readFieldLengthAndSetStreamPosition(byte[] data, int offset, int status, int fieldDataSize, ArrayInputStream ais) throws IOException
readStatusback to summary
public static final int readStatus(ObjectInput in) throws IOException

read the field status

Exceptions
IOException:
Thrown by potential I/O errors while reading field header.
readStatusback to summary
public static final int readStatus(byte[] page, int offset)
readTotalFieldLengthback to summary
public static final int readTotalFieldLength(byte[] data, int offset) throws IOException

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.

Parameters
data:byte[]

the array where the field is.

offset:int

the offset in the array where the field begin, ie. the status byte is at data[offset].

Returns:int

The length of the field on the page, including it's header.

Exceptions
IOException:
if an I/O error occurs
setExtensibleback to summary
public static final int setExtensible(int status, boolean isExtensible)
setFixedback to summary
public static final int setFixed(int status, boolean isFixed)
setInitialback to summary
public static final int setInitial()

Set accessors for setting bits in the status field.

setNonexistentback to summary
public static final int setNonexistent(int status)
setNullback to summary
public static final int setNull(int status, boolean isNull)
setOverflowback to summary
public static final int setOverflow(int status, boolean isOverflow)
setTaggedback to summary
public static final int setTagged(int status, boolean isTagged)
sizeback to summary
public static final int size(int status, int fieldDataLength, int fieldDataSize)
toDebugStringback to summary
public static String toDebugString(int status)
writeback to summary
public static final int write(OutputStream out, int status, int fieldDataLength, int fieldDataSize) throws IOException

write out the field status and field data Length

Exceptions
IOException:
Thrown by potential I/O errors while writing field header.