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

public Class StoredPage

extends CachedPage
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.store.raw.data.AllocPage
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .EOFException, .IOException, .InputStream, .ObjectInput, .OutputStream, java.util.Arrays, java.util.zip.CRC32, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.MessageId, .SQLState, org.apache.derby.iapi.services.io.ArrayInputStream, .ArrayOutputStream, .CompressedNumber, .DataInputUtil, .DynamicByteArrayOutputStream, .ErrorObjectInput, .FormatIdInputStream, .FormatIdOutputStream, .FormatIdUtil, .FormatableBitSet, .LimitObjectInput, .StoredFormatIds, .StreamStorable, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.store.access.Qualifier, .RowUtil, org.apache.derby.iapi.store.access.conglomerate.LogicalUndo, org.apache.derby.iapi.store.raw.ContainerHandle, .FetchDescriptor, .Page, .PageKey, .PageTimeStamp, .RawStoreFactory, .RecordHandle, org.apache.derby.iapi.store.raw.log.LogInstant, org.apache.derby.iapi.store.raw.xact.RawTransaction, org.apache.derby.iapi.types.DataValueDescriptor, org.apache.derby.iapi.util.ByteArray

StoredPage is a sub class of CachedPage that stores page data in a fixed size byte array and is designed to be written out to a file through a DataInput/DataOutput interface. A StoredPage can exist in its clean or dirty state without the FileContainer it was created from being in memory.

Page Format
The page is broken into five sections

  +----------+-------------+-------------------+-------------------+----------+
  | formatId | page header | records           | slot offset table | checksum |
  +----------+-------------+-------------------+-------------------+----------+
  

FormatId
The formatId is a 4 bytes array, it contains the format Id of this page.
Page Header
The page header is a fixed size, 56 bytes
  1 byte  boolean           is page an overflow page
  1 byte  byte              page status (a field maintained in base page)
  8 bytes long              pageVersion (a field maintained in base page)
  2 bytes unsigned short    number of slots in slot offset table
  4 bytes integer           next record identifier
  4 bytes integer           generation number of this page (Future Use)
  4 bytes integer           previous generation of this page (Future Use)
  8 bytes bipLocation       the location of the beforeimage page (Future Use)
  2 bytes unsigned short    number of deleted rows on page. (new release 2.0)
  2 bytes unsigned short    % of the page to keep free for updates
  2 bytes short             spare for future use
  4 bytes long              spare for future use (encryption uses to write 
                                                  random bytes here).
  8 bytes long              spare for future use
  8 bytes long              spare for future use

  
Note that spare space has been guaranteed to be writen with "0", so that future use of field should not either not use "0" as a valid data item or pick 0 as a valid default value so that on the fly upgrade can assume that 0 means field was never assigned.
Records The records section contains zero or more records, the format of each record follows. minimumRecordSize is the minimum user record size, excluding the space we use for the record header and field headers. When a record is inserted, it is stored in a space at least as large as the sum of the minimumRecordSize and total header size. For example, If minimumRecordSize is 10 bytes, the user record is 7 bytes, we used 5 bytes for record and field headers, this record will take (10 + 5) bytes of space, extra 3 bytes is put into reserve. If minimumRecordSize is 10 bytes, user record is 17 bytes, we used 5 bytes for record and field headers, this record will take (17 + 5) bytes of space, no reserve space here. minimumRecordSize is defined by user on per container basis. The default for minimumRecordSize is set to 1. This implementation always keeps occupied bytes at the low end of the record section. Thus removing (purging) a record moves all other records down, and their slots are also moved down. A page has no empty slot (an empty page has no slot)
Record and Field Format Record Header format is defined in the StoredRecordHeader class.
   
  
Fields 1 byte Boolean - is null, if true no more data follows. 4 bytes Integer - length of field that follows (excludes these four bytes). StoredPage will use the static method provided by StoredFieldHeader to read/write field status and field data length. Field Header format is defined in the StoredFieldHeader class.

Slot Offset Table
The slot offset table is a table of 6 or 12 bytes per record, depending on the pageSize being less or greater than 64K: 2 bytes (unsigned short) or 4 bytes (int) page offset for the record that is assigned to the slot, and 2 bytes (unsigned short) or 4 bytes (int) for the length of the record on this page. 2 bytes (unsigned short) or 4 bytes (int) for the length of the reserved number of bytes for this record on this page. First slot is slot 0. The slot table grows backwards. Slots are never left empty.
Checksum
8 bytes of a java.util.zip.CRC32 checksum of the entire's page contents without the 8 bytes representing the checksum.

Page Access The page data is accessed in this class by one of three methods.

  1. As a byte array using pageData (field in cachedPage). This is the fastest.
  2. As an ArrayInputStream (rawDataIn) and ArrayOutputStream (rawDataOut), this is used to set limits on any one reading the page logically.
  3. Logically through rawDataIn (ArrayInputStream) and logicalDataOut (FormatIdOutputStream), this provides the methods to write logical data (e.g. booleans and integers etc.) and the ObjectInput and ObjectOutput interfaces for DataValueDescriptor's. These logical streams are constructed using the array streams.
See Also
java.util.zip.CRC32, ArrayInputStream, ArrayOutputStream

Field Summary

Modifier and TypeField and Description
pack-priv ByteHolder
bh

In memory buffer used as scratch space for streaming columns.

private long
private CRC32
checksum

holder for the checksum.

protected static final int
CHECKSUM_SIZE

Size of the checksum stored on the page.

protected static final int
protected static final int
protected static final int
protected static final int
COLUMN_NONE

Constants used in call to logColumn.

private int
private int
public static final int
FORMAT_NUMBER

static final Fields of the class

protected int
private int
private boolean
headerOutOfDate

Is the header in the byte array out of date wrt the fields.

private boolean
isOverflowPage

The page header is a fixed size, 56 bytes, following are variables used to access the fields in the header:

1 byte boolean isOverflowPage is page an overflow page 1 byte byte pageStatus page status (field in base page) 8 bytes long pageVersion page version (field in base page) 2 bytes ushort slotsInUse number of slots in slot offset table 4 bytes integer nextId next record identifier 4 bytes integer generation generation number of this page(FUTURE USE) 4 bytes integer prevGeneration previous generation of page (FUTURE USE) 8 bytes long bipLocation the location of the BI page (FUTURE USE) 2 bytes ushort deletedRowCount number of deleted rows on page.(rel 2.0) 2 bytes long spare for future use 4 bytes long spare (encryption writes random bytes) 8 bytes long spare for future use 8 bytes long spare for future use Note that spare space has been guaranteed to be writen with "0", so that future use of field should not either not use "0" as a valid data item or pick 0 as a valid default value so that on the fly upgrade can assume that 0 means field was never assigned.

protected static final int
protected FormatIdOutputStream
private int
maxFieldSize

maxFieldSize is a worst case calculation for the size of a record on an empty page, with a single field, but still allow room for an overflow pointer if another field is to be added.

protected int
minimumRecordSize

Minimum space to reserve for record portion length of row.

private int
protected static final int
OVERFLOW_POINTER_SIZE

OVERFLOW_POINTER_SIZE - Number of bytes to reserve for overflow pointer The overflow pointer is the pointer that the takes the place of the last column of a row if the row can't fit on the page.

protected static final int
OVERFLOW_PTR_FIELD_SIZE

OVERFLOW_PTR_FIELD_SIZE - Number of bytes of an overflow field This is the length to reserve for either a column or row overflow pointer field.

private StoredRecordHeader
overflowRecordHeader

Scratch variable used when you need a overflowRecordHeader.

protected static final int
PAGE_HEADER_OFFSET

Start of page, formatId must fit in 4 bytes.

protected static final int
PAGE_HEADER_SIZE

Fixed size of the page header

protected static final int
PAGE_VERSION_OFFSET

offset of the page version number

private int
protected ArrayInputStream
rawDataIn

Input streams used to read/write bytes to/from the page byte array.

protected ArrayOutputStream
protected static final int
RECORD_SPACE_OFFSET

Start of the record storage area.

private int
private int
slotFieldSize

slot field and slot entry size.

private int
private int
slotTableOffsetToFirstEntry

Offset of the first entry in the slot table.

private int
slotTableOffsetToFirstRecordLengthField

Offset of the record length entry in the 1st slot table entry.

private int
slotTableOffsetToFirstReservedSpaceField

Offset of the reserved space length entry in the 1st slot table entry.

protected static final int
SMALL_SLOT_SIZE

SMALL_SLOT_SIZE are for pages smaller than 64K, LARGE_SLOT_SIZE is for pages bigger than 64K.

protected int
spareSpace

% of page to keep free for updates.

protected int
totalSpace

total usable space on a page.

private int
userRowSize

scratch variable used to keep track of the total user size for the row.

Inherited from org.apache.derby.impl.store.raw.data.CachedPage:
alreadyReadPagecontainerCachedataFactoryinitialRowCountisDirtyPAGE_FORMAT_ID_SIZEpageCachepageDatapreDirtyWRITE_NO_SYNCWRITE_SYNC

Constructor Summary

AccessConstructor and Description
public
StoredPage()

Simple no-arg constructor for StoredPage.

Method Summary

Modifier and TypeMethod and Description
private void
addSlotEntry(int
Position the new slot will take
slot
,
int
Offset of the record for the new slot
recordOffset
,
int
Length of the record stored in the new slot
recordPortionLength
,
int
Length of reserved space of record in slot
reservedSpace
)

Insert a new slot entry into the current slot array.

public boolean

Returns:

boolean indicating if a minimum sized row can be inserted.
allowInsert
()

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.allowInsert.

Is there enough space on the page to insert a minimum size row?

public int
appendOverflowFieldHeader(DynamicByteArrayOutputStream
The buffer that contains the partially logged row.
logBuffer
,
RecordHandle
the overflow (continuation) pointer to the beginning of the long column
overflowHandle
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.appendOverflowFieldHeader.

Append an overflow pointer to a partly logged row, to point to a long column that just been logged.

private int

Returns:

slot field size in bytes
calculateSlotFieldSize
(int
page size in bytes
pageSize
)

Calculate the slot field size from the page size.

private boolean

Returns:

true if space should be reclaimed from this row post commit.
checkRowReservedSpace
(int slot)

See if reserved space should be reclaimed for the input row.

private void
private void
clearAllSpace()

Initialize the freeSpace count and set the firstFreeByte on page

protected final void
clearSection(int
position of first byte to clear
offset
,
int
how many bytes to clear
length
)

Zero out a portion of the page.

protected void
compactRecord(RawTransaction t, int slot, int id)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.compactRecord.

Subclass implementation of compactRecord.

private void
compressPage(int
compress out space starting at startByte offset
startByte
,
int
compress out space ending at endByte offset
endByte
)

Compress out the space specified by startByte and endByte.

private void
createOutStreams()

Create the output streams.

protected void
createPage(PageKey
The key describing page (segment,container,page).
newIdentity
,
PageCreationArgs
information stored about the page, once in the container header and passed in through the object.
args
)

Implements abstract org.apache.derby.impl.store.raw.data.CachedPage.createPage.

Create a new StoredPage.

private void
createSpaceForUpdate(int slot, int offset, int oldLength, int newLength)

Create the space to update a portion of a record.

public PageTimeStamp

Returns:

page time stamp
currentTimeStamp
()

Implements org.apache.derby.iapi.store.raw.Page.currentTimeStamp.

Get a time stamp for this page

public void
doUpdateAtSlot(RawTransaction t, int slot, int id, Object[] row, FormatableBitSet validColumns)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.doUpdateAtSlot.

Perform an update.

public boolean

Returns:

true if the entire record at slot is on this page, i.e, no overflow row or long columns.
entireRecordOnPage
(int
Check record at this slot.
slot
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.entireRecordOnPage.

Is entire record on the page?

public boolean

Returns:

true if the same
equalTimeStamp
(PageTimeStamp
the page version gotton from this page via a currentTimeStamp or setTimeStamp call earlier
ts
)

Implements org.apache.derby.iapi.store.raw.Page.equalTimeStamp.

compare given PageVersion with pageVersion on page

protected void
expandPage(int
offset on page to begin the shift
startOffset
,
int
the number of bytes that must be freed.
requiredBytes
)

Free up required bytes by shifting rows "down" the page.

public int
fetchNumFieldsAtSlot(int
is the slot number
slot
)

Overrides org.apache.derby.impl.store.raw.data.BasePage.fetchNumFieldsAtSlot.

Implements org.apache.derby.iapi.store.raw.Page.fetchNumFieldsAtSlot.

Get the number of fields on the row at slot

protected int
getCurrentFreeSpace()

The current free space on the page.

private int
getFieldOffset(int slot, int fieldNumber)

Get the offset of the field header of the given field for the record in the given slot.

protected boolean
getIsOverflow(int slot)

private int
getMaxDataLength(int spaceAvailable, int overflowThreshold)

return the max datalength allowed with the space available

protected int

Returns:

the maximum free space on this page possible.
getMaxFreeSpace
()

The maximum free space on this page possible.

protected BasePage
private RecordHandle

Returns:

The next record handle in a long column chain.
getNextColumnPiece
(int
The slot of the current long column piece.
slot
)

Return the next recordHandle in a long column chain.

protected StoredPage
getOverflowPage(long pageNumber)

Get the overflow page for a record that has already overflowed.

public BasePage
getOverflowPageForInsert(int currentSlot, Object[] row, FormatableBitSet validColumns)

Get a overflow page that potentially can handle a new overflowed record.

public BasePage
getOverflowPageForInsert(int currentSlot, Object[] row, FormatableBitSet validColumns, int startColumn)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.getOverflowPageForInsert.

private StoredRecordHeader
getOverFlowRecordHeader()

get scratch space for over flow record header.

protected static int
getOverflowSlot(BasePage overflowPage, StoredRecordHeader recordHeader)

Get the overflow slot for a record that has already overflowed.

pack-priv String
public final int
getPageSize()

Get the full size of the page.

public int
getRecordLength(int slot)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.getRecordLength.

Get the stored length of a record.

private int

Returns:

The page offset of the record associated with the input slot.
getRecordOffset
(int
The array entry of the slot to find.
slot
)

Get the page offset of the record associated with the input slot.

protected int

Returns:

The length of the row on this page.
getRecordPortionLength
(int
the slot of the row to look up the length of.
slot
)

Return length of row on this page.

public int

Returns:

The reserved length of the row on this page.
getReservedCount
(int
the slot of the row to look up the length of.
slot
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.getReservedCount.

Return reserved length of row on this page.

private int

Returns:

The page offset of a given slot entry.
getSlotOffset
(int
The array entry of the slot to find.
slot
)

Get the page offset of a given slot entry.

protected int
public int

Returns:

The number of bytes used by the row at slot "slot".
getTotalSpace
(int
look at row at this slot.
slot
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.getTotalSpace.

Return the total number of bytes used, reserved, or wasted by the record at this slot.

public int
private void
handleIncompleteLogRow(int
slot of the current update.
slot
,
int
column to start at, handles start in middle of row
startColumn
,
FormatableBitSet
bit map indicating which columns are being updated.
columnList
,
DynamicByteArrayOutputStream
place to lot to.
out
)

Handle an update of a record portion that is incomplete.

protected void
initFromData(FileContainer
The container to read the page in from.
myContainer
,
PageKey
The key representing page being read in (segment, container, page number)
newIdentity
)

Implements abstract org.apache.derby.impl.store.raw.data.CachedPage.initFromData.

Initialize the page from values in the page buffer.

protected void
public void
initPage(LogInstant instant, byte status, int recordId, boolean overflow, boolean reuse)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.initPage.

Initialize the page.

private void
initSlotTable(PageKey
The identity of the page we are trying to initialize, since we are in the middle of trying to build the page existing info in the class is not set up yet (like getIdentity()).
newIdentity
)

Initialize the in-memory slot table.

private void
initSpace()

initialize the in memory variables associated with space maintenance.

public RecordHandle
insertAtSlot(int
The specified slot
slot
,
Object[]
The row version of the data
row
,
FormatableBitSet
a bit map of which columns in the row is valid. ValidColumns will not be changed by RawStore.
validColumns
,
LogicalUndo
if logical undo may be necessary, a function pointer to the access code where the logical undo logic resides. Null if logical undo is not necessary.
undo
,
byte
if INSERT_UNDO_WITH_PURGE set, then the undo of this insert will purge the row rather than mark it as deleted, which is the default bahavior for insertAtSlot and insert.
insertFlag
,
int overflowThreshold)

Overrides org.apache.derby.impl.store.raw.data.BasePage.insertAtSlot.

Implements org.apache.derby.iapi.store.raw.Page.insertAtSlot.

Override insertAtSlot to provide long row support.

protected int
internalDeletedRecordCount()

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.internalDeletedRecordCount.

get record count without checking for latch

private boolean

Returns:

true if page no longer points to the long column chain.
isColumnOrphaned
(StoredRecordHeader
record header which used to point at the long column
recordHeader
,
int
column id of the long column in head.
columnId
,
long
the page id where the long column used to be.
oldPageId
,
long
the record id where the long column used to be.
oldRecordId
)

See if there is a orphaned long colum chain or not.

private boolean
isLong(int fieldSize, int overflowThreshold)

return whether the field has exceeded the max threshold for this page it compares the fieldSize with the largest possible field for this page

public boolean
isOverflowPage()

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.isOverflowPage.

Return true if the page is an overflow page, false if not.

public void
public void
logColumn(int
slot of the current record
slot
,
int
field number of the column being updated
fieldId
,
Object
column version of the field.
column
,
DynamicByteArrayOutputStream
Where to write the logged form.
out
,
int overflowThreshold)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.logColumn.

Log a Storable to a stream.

private int

Returns:

The spaceAvailable after accounting for space for this column.
logColumn
(Object[]
array of column from which to read the column from.
row
,
int
The array position of column to be reading from row.
arrayPosition
,
DynamicByteArrayOutputStream
The stream to write the raw store page format of the the column to.
out
,
int
The number of bytes available on the page for this column, this may differ from current page as it may include bytes used by previous columns.
spaceAvailable
,
int
one of: COLUMN_NONE, COLUMN_FIRST, or COLUMN_LONG.
columnFlag
,
int overflowThreshold)

Log column from input row to the given output stream.

public void
logField(int
Slot number the record is stored in.
slot
,
int
Number of the field (starts at 0).
fieldNumber
,
OutputStream
Where to write the logged form.
out
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.logField.

Log a field to the ObjectOutput stream.

public int
logLongColumn(int
slot of the row with the column
slot
,
int
record id of the
recordId
,
Object
the object form of the column to log
column
,
DynamicByteArrayOutputStream
where to log to the column to.
out
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.logLongColumn.

Log a long column into a DataOuput.

private int
logOverflowField(DynamicByteArrayOutputStream out, int spaceAvailable, long overflowPage, int overflowId)

private int

Returns:

-1
logOverflowRecord
(int
slot of record to log.
slot
,
int
spaceAvaliable on page.
spaceAvailable
,
DynamicByteArrayOutputStream
stream to log the record to.
out
)

Create and write a long row header to the log stream.

public void
logRecord(int
Slot number the record is stored in.
slot
,
int
LOG_RECORD_*, the reason for logging the record.
flag
,
int
Record identifier of the record.
recordId
,
FormatableBitSet
which columns needs to be logged
validColumns
,
OutputStream
Where to write the logged form.
out
,
RecordHandle
the recordHandle of the head row piece, used for post commit cleanup for update.
headRowHandle
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.logRecord.

Log a record to the ObjectOutput stream.

private void
logRecordDataPortion(int slot, int flag, StoredRecordHeader recordHeader, FormatableBitSet validColumns, OutputStream out, RecordHandle headRowHandle)

public int

Returns:

the "realStartColumn" value, -1 if not a long row.
logRow
(int
the slot of the row being logged.
slot
,
boolean
this is logging an insert (not update/delete).
forInsert
,
int
record id of the row being logged.
recordId
,
Object[]
actual data of row in object form. If row is null then we are logging an overflow pointer.
row
,
FormatableBitSet
bit map describing valid columns in row.
validColumns
,
DynamicByteArrayOutputStream
stream to log to.
out
,
int
what column to start with (see above for detail)
startColumn
,
byte
flag indicating mode we are in, INSERT_DEFAULT - default insert INSERT_SPLIT - splitting a row/column across pages.
insertFlag
,
int
If -1 ignore variable, else part of row has already been logged, and should continue with this column.
realStartColumn
,
int
Use this as space on page if realStartColumn is not -1.
realSpaceOnPage
,
int
How much of the page to use before deciding to overflow a row.
overflowThreshold
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.logRow.

Log a row into the StoreOuput stream.

public int

Returns:

the number of rows processed.
moveRecordForCompressAtSlot
(int
slot of original row to move.
slot
,
Object[]
a row template to hold all columns of row.
row
,
RecordHandle[]
An array to be filled in by the call with the old handles of all rows moved.
old_handle
,
RecordHandle[]
An array to be filled in by the call with the new handles of all rows moved.
new_handle
)

Implements org.apache.derby.iapi.store.raw.Page.moveRecordForCompressAtSlot.

Move record to a page toward the beginning of the file.

private int
moveSavedDataToPage(DynamicByteArrayOutputStream savedData, int unusedSpace, int pageOffset)

public int

Returns:

The next id to assing to a row.
newRecordId
()

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.newRecordId.

Create a new record handle.

protected int

Returns:

the next id based on the input id.
newRecordId
(int
The id caller just used, return the next one.
recordId
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.newRecordId.

Create a new record id based on current one passed in.

This interface is used for the "copy" insert interface of raw store where multiple rows are inserted into a page in a single logged operation.

public int

Returns:

The next id to assing to a row.
newRecordIdAndBump
()

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.newRecordIdAndBump.

Create a new record handle, and bump the id.

Create a new record handle, and bump the id while holding the latch so that no other user can ever see this record id. This will lead to unused record id's in the case where an insert fails because there is not enough space on the page.

private static String

Returns:

The string with the hex dump in it.
pagedataToHexDump
(byte[]
array of bytes to dump.
data
)

Provide a hex dump of the data in the in memory version of the page.

private String
private void
purgeColumnChains(RawTransaction
The raw transaction doing the purging.
t
,
int
The slot of the row to purge.
slot
,
RecordHandle
The RecordHandle of the head row.
headRowHandle
)

purge long columns chains which eminate from this page.

private void
purgeOneColumnChain(long
The page where the long column chain starts.
overflowPageId
,
int
The record id where long column chain starts.
overflowRecordId
)

Purge the column chain that starts at overflowPageId, overflowRecordId

Purge just the column chain that starts at the input address.

protected void
purgeOverflowAtSlot(int
slot number of row to purge.
slot
,
RecordHandle
recordHandle of the head row piece.
headRowHandle
,
boolean
when true data is logged for purges otherwise just headers.
needDataLogged
)

Purge one row on an overflow page.

public void
purgeRecord(LogInstant instant, int
the slot to purge
slot
,
int
the id of the record that is to be purged
recordId
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.purgeRecord.

purgeRecord from page.

protected void
purgeRowPieces(RawTransaction
The raw transaction doing the purging.
t
,
int
The slot of the row to purge.
slot
,
RecordHandle
The RecordHandle of the head row.
headRowHandle
,
boolean
when true data is logged for purges otherwise just headers.
needDataLogged
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.purgeRowPieces.

Purge all the overflow columns and overflow rows of the record at slot.

private boolean

Returns:

true if the row qualifies.
qualifyRecordFromRow
(Object[]
The row being qualified.
row
,
Qualifier[][]
2 dimensional array representing conjunctive normal form of simple qualifiers.
qual_list
)

Process the qualifier list on the row, return true if it qualifies.

private final boolean

Returns:

Whether or not the row input qualifies.
qualifyRecordFromSlot
(Object[]
restore row into this object array.
row
,
int
offset in bytes from top of page to row
offset_to_row_data
,
FetchDescriptor
Description of fetch including which cols and qualifiers.
fetchDesc
,
StoredRecordHeader
The record header of the row, it was read in from stream and dataIn is positioned after it.
recordHeader
,
RecordHandle
The head row to use for locking, used to lock head row of overflow columns/rows.
recordToLock
)

Process the list of qualifiers on the row in the stream.

private final void
readOneColumnFromPage(Object[]
col is read into object in row[qual_colid].
row
,
int
the column id to read, colid N is row[N]
colid
,
int
offset in bytes from top of page to field
offset_to_field_data
,
StoredRecordHeader
record header of row to read column from.
recordHeader
,
RecordHandle
record handle to lock, used by overflow column code.
recordToLock
)

Read just one column from stream into row.

private void
readPageHeader()

Read the page header from the page array.

private final boolean
readRecordFromArray(Object[] row, int max_colid, int[] vCols, int[] mCols, ArrayInputStream dataIn, StoredRecordHeader recordHeader, RecordHandle recordToLock)

private final boolean

Returns:

The identifier to be used to open the conglomerate later.
readRecordFromStream
(Object[]
restore row into this object array.
row
,
int
The maximum numbered column id that will be requested by caller. It should be: min(row.length - 1, maximum bit set in vCols) It is used to stop the inner most loop from looking at more columns in the row.
max_colid
,
int[]
If not null, bit map indicates valid cols.
vCols
,
int[]
If not null, int array indicates columns already read in from the stream. A non-zero entry means the column has already been read in.
mCols
,
LimitObjectInput
restore row from this stream.
dataIn
,
StoredRecordHeader
The record header of the row, it was read in from stream and dataIn is positioned after it.
recordHeader
,
RecordHandle
The head row to use for locking, used to lock head row of overflow columns/rows.
recordToLock
)

restore a record from a stream.

public StoredRecordHeader

Returns:

The record header for the specific slot.
recordHeaderOnDemand
(int
return record header of this slot.
slot
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.recordHeaderOnDemand.

create the record header for the specific slot.

private String
recordToString(int slot)

protected void
releaseExclusive()

Overrides org.apache.derby.impl.store.raw.data.CachedPage.releaseExclusive.

Ensure that the page is released from the cache when it is unlatched.

pack-priv void
removeOrphanedColumnChain(ReclaimSpace
object describing the chain to remove.
work
,
ContainerHandle
open container handle to use to remove chain.
containerHdl
)

Remove a column chain that may have been orphaned by an update.

private void
removeSlotEntry(int
The slot to delete.
slot
)

Remove slot entry from slot array.

public void
reserveSpaceForSlot(LogInstant instant, int slot, int spaceToReserve)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.reserveSpaceForSlot.

reserveSpaceForSlot This method will reserve at least specified "spaceToReserve" bytes for the record in the slot.

private void
resetOutputStream()

Reset the logical output stream.

private StoredRecordHeader
restoreLongRecordFromSlot(Object[] row, FetchDescriptor fetchDesc, RecordHandle recordToLock, StoredRecordHeader parent_recordHeader)

public void
restorePortionLongColumn(OverflowInputStream
the stream to read the next portion of long col from
fetchStream
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.restorePortionLongColumn.

Restore a portion of a long column.

protected boolean

Returns:

false if a qualifier_list is provided and the row does not qualifier (no row read in that case), else true.
restoreRecordFromSlot
(int
the slot number
slot
,
Object[]
(out) filled in sparse row
row
,
FetchDescriptor
Information describing fetch, including what columns to fetch and qualifiers.
fetchDesc
,
RecordHandle
the record handle for the row at top level, and is used in OverflowInputStream to lock the row for Blobs/Clobs.
recordToLock
,
StoredRecordHeader recordHeader, boolean
The row on this page includes the head record handle. Will be false for the overflow portions of a "long" row, where columns of a row span multiple pages.
isHeadRow
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.restoreRecordFromSlot.

Read the record at the given slot into the given row.

public void
restoreRecordFromStream(LimitObjectInput
the limit input stream
in
,
Object[]
(IN/OUT) row that is to be restored (sparse representation)
row
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.restoreRecordFromStream.

Restore a storable row from a LimitInputStream.

public void
setDeleteStatus(LogInstant instant, int
the slot to delete or undelete
slot
,
boolean
set delete status to this value
delete
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.setDeleteStatus.

Set the deleted status

private void
setOutputStream(OutputStream out)

Tie the logical output stream to a passed in OutputStream.

public void
setPageStatus(LogInstant
the log instant of the log record
instant
,
byte
the page status
status
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.setPageStatus.

Set page status

private void
setRecordOffset(int
The array entry of the slot to set.
slot
,
int
the new offset to set.
recordOffset
)

Set the page offset of the record associated with the input slot.

public void
setReservedSpace(LogInstant instant, int slot, int value)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.setReservedSpace.

Set the row reserved space.

private void
setSlotEntry(int
the slot to initialize.
slot
,
int
the offset on the page to find the record.
recordOffset
,
int
the actual length of record+hdr on page.
recordPortionLength
,
int
the reserved length associated with record.
reservedSpace
)

Set up a new slot entry.

public void
setTimeStamp(PageTimeStamp ts)

Implements org.apache.derby.iapi.store.raw.Page.setTimeStamp.

Set given pageVersion to be the as what is on this page

private int

Returns:

the length of the data in the record after the replaced data.
shiftRemainingData
(int slot, int
Offset where the update starts, need not be on a field boundry.
offset
,
int
length of the data being replaced
oldLength
,
int
length of the data replacing the old data
newLength
)

Shift data within a record to account for an update.

private void
shrinkPage(int
offset on page to begin the shift
startOffset
,
int
the number of bytes that must be moved.
shrinkBytes
)

Shrink page.

public void
skipField(ObjectInput in)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.skipField.

Skip a field header and its data on the given stream.

public void
public boolean

Returns:

true if the sum of the lengths will fit on the page.
spaceForCopy
(int
number of rows to check for.
num_rows
,
int[]
array of lengths of the rows to insert.
spaceNeeded
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.spaceForCopy.

Does this page have enough space to insert the input rows?

protected boolean

Returns:

true if the record will fit on this page, after being given a new record id as the next id on this page.
spaceForCopy
(int
length of the row encoded with source_id record id.
spaceNeeded
,
int
record id of the row being moved.
source_id
)

Does this page have enough space to move the row to it.

public boolean

Returns:

true if we think the page will allow an insert, false otherwise.
spaceForInsert
()

Implements org.apache.derby.iapi.store.raw.Page.spaceForInsert.

Is there minimal space for insert?

public boolean

Returns:

bolean indicating if row can be inserted on this page.
spaceForInsert
(Object[]
The row to check for insert.
row
,
FormatableBitSet
bit map to interpret valid columns in row.
validColumns
,
int
The percentage of the page to use for the insert. 100 means use 100% of the page, 50 means use 50% of page (ie. make sure 2 rows fit per page).
overflowThreshold
)

Implements org.apache.derby.iapi.store.raw.Page.spaceForInsert.

Is row guaranteed to be inserted successfully on this page?

private boolean

Returns:

bolean indicating if row can be inserted on this page.
spaceForInsert
(Object[]
The row to check for insert.
row
,
FormatableBitSet
bit map to interpret valid columns in row.
validColumns
,
int spaceNeeded, int startColumn, int
The percentage of the page to use for the insert. 100 means use 100% of the page, 50 means use 50% of page (ie. make sure 2 rows fit per page).
overflowThreshold
)

Is row guaranteed to be inserted successfully on this page?

public void
storeField(LogInstant instant, int slot, int fieldNumber, ObjectInput in)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.storeField.

storeField

public void
storeRecord(LogInstant instant, int slot, boolean insert, ObjectInput in)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.storeRecord.

Store a record at the given slot.

private void
private void
public String
toString()

Overrides java.lang.Object.toString.

debugging, print this page

public String
public boolean

Returns:

true if page is relatively unfilled.
unfilled
()

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.unfilled.

Is this page unfilled?

protected void
updateChecksum()

Recalculate checksum and write it to the page array.

public RecordHandle
updateFieldAtSlot(int
is the slot number
slot
,
int
is the column id
fieldId
,
Object
has the new colum value to be stored in the record
newValue
,
LogicalUndo
if logical undo may be necessary, a function pointer to the access code where the logical undo logic resides. Null if logical undo is not necessary.
undo
)

Overrides org.apache.derby.impl.store.raw.data.BasePage.updateFieldAtSlot.

Implements org.apache.derby.iapi.store.raw.Page.updateFieldAtSlot.

Update field at specified slot

public void
updateFieldOverflowDetails(RecordHandle
handle of the record for long row
handle
,
RecordHandle
the overflow (continuation) pointer for the long row
overflowHandle
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.updateFieldOverflowDetails.

Update the overflow pointer for a long column MT - latched - page latch must be held

public void
updateOverflowDetails(RecordHandle
handle of the record for long row
handle
,
RecordHandle
the overflow (continuation) pointer for the long row
overflowHandle
)

Implements abstract org.apache.derby.impl.store.raw.data.BasePage.updateOverflowDetails.

Update a record handle to point to an overflowed record portion.

private void
updateOverflowDetails(StoredPage handlePage, RecordHandle handle, RecordHandle overflowHandle)

protected void
updateOverflowed(RawTransaction t, int
Slot of the original record on its original page
slot
,
Object[]
new version of the data
row
,
FormatableBitSet validColumns, StoredRecordHeader recordHeader)

Update an already overflowed record.

private void
updatePageHeader()

Update the page header in the page array.

private void
updatePageVersion()

Update the page version number in the byte array

private void
updateRecordPortionLength(int
the slot of the record to set.
slot
,
int
The amount the record length changed.
delta
,
int
The amount the reserved length changed.
reservedDelta
)

Update the length of data stored on this page for this record

Update both the record length "field" and the reserved space "field" of the slot table entry associated with "slot".

protected void
usePageBuffer(byte[]
The array of bytes to use as the page buffer.
pageBuffer
)

Implements abstract org.apache.derby.impl.store.raw.data.CachedPage.usePageBuffer.

use this passed in page buffer as this object's page data.

protected void
validateChecksum(PageKey
The key that describes the page.
id
)

Validate the check sum on the page.

protected void
writeFormatId(PageKey
The key of this page.
identity
)

Implements abstract org.apache.derby.impl.store.raw.data.CachedPage.writeFormatId.

Write out the format id of this page

protected void
writePage(PageKey
The key of this page.
identity
)

Implements abstract org.apache.derby.impl.store.raw.data.CachedPage.writePage.

Write information about page from variables into page byte array.

Inherited from org.apache.derby.impl.store.raw.data.CachedPage:
cleanclearIdentitycreateIdentitygetPageArrayisActuallyDirtyisDirtypreDirtysetContainerRowCountsetDirtysetFactorysetIdentitysetPageArray