A page contains a set of records, which can be accessed by "slot", which defines the order of the records on the page, or by "id" which defines the identity of the records on the page. Clients access records by both slot and id, depending on their needs.
BasePage implements Observer to watch the ContainerHandle which notifies
its Observers when it is closing.
MT - mutable
| Modifier and Type | Field and Description |
|---|---|
| private AuxObject | auxObj
auxiliary object MT - mutable - content dynamic : single thread required. |
| private StoredRecordHeader[] | headers
In-memory slot table, array of StoredRecordHeaders. |
| protected PageKey | identity
this page's identity MT - immutable - content dynamic : single thread required |
| protected boolean | |
| public static final int | |
| public static final int | INIT_PAGE_REUSE
Init page flag. |
| public static final int | |
| public static final byte | |
| private static final RecordHandle | |
| private LogInstant | lastLog
Instant of last log record that updated this page. |
| public static final int | LOG_RECORD_DEFAULT
Log Record flag. |
| public static final int | |
| public static final int | |
| private int | nestedLatch
Count of times a latch is held nested during an abort |
| protected BaseContainerHandle | owner
Page owner during exclusive access. |
| private byte | pageStatus
Status of the page |
| private long | pageVersion
Version of the page. |
| protected boolean | preLatch
Used to determine latch state of a page. |
| private int | |
| private long | repositionNeededAfterVersion
The oldest version where we know that any record id that was on the page at that version, must still be on the page. |
| public static final byte | VALID_PAGE
Values for pageStatus flag page goes thru the following transition: VALID_PAGE <-> deallocated page -> free page <-> VALID_PAGE deallocated and free page are both INVALID_PAGE as far as BasePage is concerned. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public abstract boolean | |
| public abstract 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)Append an overflow pointer to a partly logged row, to point to a long column that just been logged. |
| protected final long | |
| protected final void | |
| private final void | |
| protected void | |
| public void | |
| protected final void | |
| public void | compactRecord(RecordHandle
Handle to deleted or non-deleted record handle)Try to compact this record. |
| protected abstract void | |
| public void | copyAndPurge(Page
the page to copy to destPage, int start copying from this slot src_slot, int copy and purge this many rows from this page num_rows, int copying into this slot of destPage dest_slot)Implements org. move rows from one page to another, purging in the process. |
| private void | |
| public void | |
| public RecordHandle | deleteAtSlot(int
the slot number slot, boolean true if this record is to be deleted, false if this
deleted record is to be marked undeleted delete, LogicalUndo logical undo logic if necessary undo)Implements org. Mark the record at slot as deleted or undeleted according to delete flag. |
| public abstract void | |
| public abstract boolean | entireRecordOnPage(int slot)
Returns true if the entire record of that slot fits inside of this page. |
| public final RecordHandle | fetchFieldFromSlot(int
is the slot number slot, int is the column id fieldId, Object is to be filled in with information from the record. column)Implements org. Fetch a single field from a deleted or non-deleted record. |
| public RecordHandle | fetchFromSlot(RecordHandle
the record handle of the row. If non-null it must
refer to the same record as the slot. rh, int the slot number slot, Object[] Row to be filled in with information from record. row, FetchDescriptor A structure to efficiently carry a set of parameters
needed to describe the fetch, these include:
validColumns - A bit map of which columns in the
row to be fetched. ValidColumns will not be
changed by RawStore.
qualifier_list -
A list of Qualifiers to apply to the row to see if
the row should be returned.
An array of qualifiers which restrict whether or not
the row should be returned by the fetch. Rows for
which any one of the qualifiers returns false are
not returned by the fetch. If null, no qualification
is done and the requested columns of the rows are
returned. Qualifiers can only reference columns
which are included in the scanColumnList. The
column id that a qualifier returns is the column id
the table, not the column id in the partial row
being returned.
qualifier_scratch_space -
An array of int's that matches the size of the
row[] array. Used to process qualifiers, if no
qualifiers are input then array need not be
input. Passed in rather than allocated so that
space can be allocated a single time in a scan.
If not passed in then raw store will allocate and
deallocate per call. fetchDesc, boolean if true, return row regardless of whether it is
deleted or not. If false, only return non-deleted
row. ignoreDelete)Implements org. Fetch a record located in the passed in slot. |
| public final int | fetchNumFields(RecordHandle
record handle to deleted or non-deleted record handle)Implements org. Fetch the number of fields in a record. |
| public int | fetchNumFieldsAtSlot(int
is the slot number slot)Implements org. Fetch the number of fields in a record. |
| protected void | |
| private int | findNextRecordById(int
record id of the first record on the page with a
record id higher than the one passed in. If no
such record exists, -1 is returned. recordId)Find the slot for the first record on the page with an id greater than the passed in identifier. |
| public int | findRecordById(int
record id of the record to search for. recordId, int "hint" about which slot the record might be in. slotHint)Find the slot for the record with the passed in identifier. |
| public AuxObject | |
| public final StoredRecordHeader | |
| public Object | |
| public final RecordHandle | getInvalidRecordHandle()
Implements org. Return an invalid record handle. |
| public final LogInstant | |
| protected abstract BasePage | |
| public final int | getNextSlotNumber(RecordHandle
record handle to find the next higher id. handle)Implements org. Find slot for record with an id greater than the passed in identifier. |
| public abstract BasePage | |
| protected abstract byte[] | |
| public final PageKey | |
| public final PageKey | getPageKey()
Implements org. Return the page key of this page. |
| public final long | getPageNumber()
Implements org. Return the page number of this page. |
| public byte | |
| public final long | getPageVersion()
Implements org. Return the current page version. |
| public final RecordHandle | getRecordHandle(int
previously stored recordId. recordId)Implements org. Get a record handle from a previously stored record id. Get a record handle from a previously stored record identifier that was obtained from a RecordHandle. |
| public final RecordHandle | getRecordHandleAtSlot(int
the slot number slot)Implements org. Get the record handle of row at slot. |
| public abstract int | |
| public abstract int | |
| public final int | getSlotNumber(RecordHandle
the record handle handle)Implements org. Get the slot number. |
| public abstract int | getTotalSpace(int slot)
Return the total number of bytes used, reserved, or wasted by the record at this slot. |
| protected void | |
| protected void | |
| public void | initPage(int initFlag, long pageOffset)
Mark this page as being allocated and initialize it to a pristine page |
| public abstract void | initPage(LogInstant instant, byte status, int recordId, boolean overflow, boolean reuse)
initialize a page for the first time or for reuse All subtypes are expected to overwrite this method if it has something to clean up |
| public final RecordHandle | insert(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, byte see values for insertFlag below. insertFlag, int overflowThreshold)Implements org. Insert a record anywhere on the page. |
| public RecordHandle | insertAllowOverflow(int slot, Object[] row, FormatableBitSet validColumns, int startColumn, byte insertFlag, int overflowThreshold, RecordHandle nextPortionHandle)
Insert a row allowing overflow. |
| 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)Implements org. Insert a record at the specified slot. |
| protected RecordHandle | Returns: The recordHandle of the first piece of the long column chain.The parent page with row piece containing column
that will eventually point to this long column
chain. mainChainPage, LongColumnException The LongColumnException thrown when we recognized
that the column being inserted was "long", this
structure is used to cache the info that we have
read so far about column. In the case of an insert
of the stream it will have a copy of just the first
page of the stream that has already been read once. lce, byte flags for insert operation. insertFlag)Routine to insert a long column. |
| protected RecordHandle | insertNoOverflow(int slot, Object[] row, FormatableBitSet validColumns, LogicalUndo undo, byte insertFlag, int overflowThreshold)
|
| protected abstract int | |
| protected int | |
| public boolean | isDeletedAtSlot(int
slot of record to be tested. slot)Implements org. Test if a record is deleted. |
| protected final boolean | |
| public final synchronized boolean | Returns: true if the page is latched, false
otherwiseImplements org. Check whether the page is latched. |
| public abstract boolean | |
| public boolean | Returns: true if a repositioning is needed because the row
on the current position may have been removed from this page after
the specified version; false otherwisethe last version on which the B-tree scan had a valid
position on this page version)Implements org. Check if a B-tree scan positioned on this page needs to reposition. |
| public abstract 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)Log a to be stored column. |
| public abstract 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)Log a currently stored field. |
| public abstract int | logLongColumn(int
slot of the current record slot, int the id of the long column record recordId, Object column version of the field. column, DynamicByteArrayOutputStream Where to write the logged form. out)Log a to be stored long column. |
| public abstract 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)Log a currently stored record to the output stream. |
| public abstract int | logRow(int
Slot number the record will be stored in. slot, boolean True if the row is being logged for an insert,
false for an update. forInsert, int Record identifier of the record. recordId, Object[] The row version of the record. row, FormatableBitSet FormatableBitSet of which columns in row are valid,
null indicates all are valid validColumns, DynamicByteArrayOutputStream Where to write the logged form. out, int The first column that is being logged in this row.
This is used when logging portion of long rows. startColumn, byte To indicate whether the insert would allow overflow. insertFlag, int This is used when a long column is detected.
Portion of the row may already be logged and stored
in the 'out' buffer. After we log the long column,
the saved buffer was passed here, and we need to
continue to log the row. realStartColumn is the starting
column for the continuation of the logRow operation.
Pass in (-1) if realStartColumn is not significant. realStartColumn, int Being used in conjunction with realStartColumn,
to indicate the real free space left on the page. realSpaceOnPage, int overflowThreshold)Log the row that will be stored at the given slot to the given OutputStream. |
| public static final RecordHandle | |
| public final RecordHandle | makeRecordHandle(int
the special recordId recordHandleConstant)Implements org. Return a record handle for the given constant record id. Return a record handle that doesn't represent a record but rather has a special meaning. |
| public abstract int | |
| protected abstract int | |
| public abstract int | |
| public int | nonDeletedRecordCount()
Implements org. Return the number of records on this page that are not marked as deleted. |
| public abstract void | |
| private void | preLatch(BaseContainerHandle
handle to the container requesting ownership requester)Move page state from UNLATCHED to PRELATCH. |
| public void | purgeAtSlot(int
the starting slot number slot, int number of slots to purge. If <= 0,
just returns as a no-op. numpurges, boolean if set to true data is logged for purges else
only headers. needDataLogged)Implements org. Purge one or more rows on a non-overflow page. |
| public abstract void | purgeRecord(LogInstant instant, int
the slot to purge slot, int the id of the record that is to be purged recordId)Purge a record from the page. |
| protected abstract void | purgeRowPieces(RawTransaction t, int slot, RecordHandle headRowHandle, boolean needDataLogged)
Purge all the overflow columns and overflow rows of the record at slot. |
| public final int | recordCount()
Implements org. Return the number of records on the page. |
| public final boolean | recordExists(RecordHandle
handle of the record to look for. handle, boolean if true, then routine will return true even if the
row is marked deleted. ignoreDelete)Implements org. does the record still exist on the page? |
| public abstract StoredRecordHeader | |
| protected synchronized void | |
| protected void | |
| public abstract void | reserveSpaceForSlot(LogInstant instant, int slot, int spaceToReserve)
Reserve the required number of bytes for the record in the specified slot. |
| protected abstract void | restorePortionLongColumn(OverflowInputStream fetchStream)
Read portion of a log record at the given slot into the given byteHolder. |
| protected abstract boolean | Returns: false if a qualifier_list is provided and the row does not qualifier (no row read in that case), else true.the slot number slot, Object[] (out) filled in sparse row row, FetchDescriptor A set of information about the fetch: what
columns to fetch, any qualifiers, ... fetchDesc, RecordHandle the record handle for the row at top level,
and is used in OverflowInputStream to lock the
row for Blobs/Clobs. rh, StoredRecordHeader recordHeader, boolean Is the head row portion of the row, false if
a long row and the 2-N'th portion of the long
row. isHeadRow)Read the record at the given slot into the given row. |
| public abstract void | restoreRecordFromStream(LimitObjectInput in, Object[] row)
Restore a storable row from a InputStream that was used to store the row after a logRecord call. |
| public void | setAuxObject(AuxObject obj)
Implements org. Set the aux object. |
| public abstract void | setContainerRowCount(long count)
Set the number of rows in the container - the page uses this to decide whether it needs to aggressive set the container's row count when it changes. |
| public int | |
| public abstract void | setDeleteStatus(LogInstant instant, int
the slot to delete or undelete slot, boolean set delete status to this value delete)Set the delete status of a record from the page. |
| pack-priv void | |
| pack-priv boolean | setExclusiveNoWait(BaseContainerHandle requester)
Get an exclusive latch on the page, but only if I don't have to wait. |
| protected final void | setHeaderAtSlot(int slot, StoredRecordHeader rh)
Must be called by any non-abstract sub-class to initialise the slot table. |
| protected void | |
| public abstract void | setPageStatus(LogInstant
the log instant of the log record instant, byte the page status status)Set the page status underneath a log record MT - latched - page latch must be held |
| public final void | |
| public void | setRepositionNeeded()
Implements org. Set a hint in this page to make B-tree scans positioned on it reposition before they continue. |
| public abstract void | setReservedSpace(LogInstant instant, int slot, int value)
Set the reserved space for this row to value. |
| protected StoredRecordHeader | shiftUp(int low)
Shift all records in the in-memory slot table up one slot, starting at and including the record in slot 'low' A new slot is added to accomdate the move. |
| public boolean | Returns: true if a reclaim space should be scheduled post commit on this page, false otherwise.threshold number of non-deleted rows to
schedule reclaim space. num_non_deleted_rows, int row on page to check for long row/long column slot_just_deleted)Implements org. Is this page/deleted row a candidate for immediate reclaim space. |
| public abstract void | |
| public abstract void | |
| protected String | |
| public abstract boolean | spaceForCopy(int num_rows, int[] spaceNeeded)
Is there space for copying this many rows which takes this many bytes on the page MT - latched, page is latched when this methods is called. |
| public abstract void | storeField(LogInstant instant, int slot, int fieldId, ObjectInput in)
Read a previously stored field written by logField or logColumn and store it on the data page at thge given slot with the given record identifier and field number. |
| public abstract void | storeRecord(LogInstant instant, int slot, boolean forInsert, ObjectInput in)
Read a previously stored record written by logRecord or logRow and store it on the data page at the given slot with the given record identifier. |
| public abstract boolean | unfilled()
Returns true if an insert is allowed in the page and the page is relatively unfilled - let specific implementation decide what relatively unfilled means |
| public void | |
| public void | update(DerbyObservable
The object which is being observed obj, Object Extra information being passed to the callback arg)Implements org. This object is set to observe the BaseContainerHandle it was obtained by, that handle will notify its observers when it is being closed. |
| public final RecordHandle | updateAtSlot(int
is the slot number slot, Object[] row, FormatableBitSet a bit map of which columns in the row is valid.
ValidColumns will not be changed by RawStore. validColumns)Implements org. Update the complete record identified by the slot. |
| 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)Implements org. Update a field within the record, replacing its current value with the stored representation of newValue. |
| public abstract void | updateFieldOverflowDetails(RecordHandle
handle of the record for long row handle, RecordHandle the overflow (continuation) pointer for the long row overflowHandle)Update the overflow pointer for a long column MT - latched - page latch must be held |
| protected final void | |
| public abstract void | updateOverflowDetails(RecordHandle
handle of the record for long row handle, RecordHandle the overflow (continuation) pointer for the long row overflowHandle)Update the overflow pointer for a long row MT - latched - page latch must be held |