A Page represents exclusive access to a data page within a container. Exclusive access is released by calling the unlatch() method, once that occurs the caller must no longer use the Page reference.
Several of the methods in Page take a RecordHandle as an argument. RecordHandles are obtained from a Page, while holding exclusive access of Page or a from a previous exclusive access of a Page representing the same data page. All RecordHandle's used as arguments to methods (with the exception of recordExists()) must be valid for the current state of the page. If they are not valid then the method will throw an exception. A caller can ensure that a record handle is valid by:
Several of the methods in Page take a slot number as an argument. A slot
always correspond to a record, which may be deleted or undeleted.
MT - Latched - In general every method requires the page to be latched.
Latching
All page methods which are not valid for a latched page throw an exception if the page is not latched. [@exception clauses on all the methods should be updated to reflect this].
Aux Objects
The page cache will manage a client object along with the page as long
as it remains in cache. This object is called the "aux object". The
aux object is associated with the page with setAuxObject(), and can be
retreived later with getAuxObject(). The aux object will remain valid
as long as the page is latched, but callers cannot assume that an aux
object will ever stick around once the page is unlatched. However, the
page manager promises to call pageBeingEvicted() once before clearing
the aux reference from the page.
Object, ContainerHandle, RecordHandle, AuxObject
| Modifier and Type | Field and Description |
|---|---|
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final int | FIRST_SLOT_NUMBER
The slot number of the first slot. |
| public static final byte | |
| public static final byte | |
| public static final byte | |
| public static final byte | INSERT_INITIAL
Values for insertFlag. |
| public static final byte | |
| public static final byte | |
| public static final int | INVALID_SLOT_NUMBER
A slot number guaranteed to be invalid. |
| Modifier and Type | Method and Description |
|---|---|
| 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)move rows from one page to another, purging in the process. |
| public PageTimeStamp | currentTimeStamp()
Return a time stamp that can be used to identify the page of this specific instance. |
| public RecordHandle | Returns: a Handle to the deleted/undeleted record.is 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 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)Mark the record at slot as deleted or undeleted according to delete flag. |
| public boolean | Returns: true if timestamp is the samethe time stamp gotten from an earlier call to this page's
getTimeStamp ts)See if timeStamp for this page is the same as the current instance of the page. |
| public RecordHandle | Returns: the Handle to the record that is lockedis the slot number slot, int is the column id fieldId, Object is to be filled in with information from the record. column)Fetch a single field from a deleted or non-deleted record. |
| public RecordHandle | Returns: A handle to the record.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)Fetch a record located in the passed in slot. |
| public int | Returns: the number of fields in the recordrecord handle to deleted or non-deleted record handle)Fetch the number of fields in a record. |
| public int | Returns: the number of fields in the recordis the slot number slot)Fetch the number of fields in a record. |
| public AuxObject | |
| public RecordHandle | |
| public int | Returns: 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.record handle to find the next higher id. handle)Find slot for record with an id greater than the passed in identifier. |
| public PageKey | |
| public long | |
| public long | |
| public RecordHandle | Returns: A valid record handle or null if the record no longer exists.previously stored recordId. recordId)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 RecordHandle | Returns: the record handle.the slot number slot)Get the record handle of row at slot. |
| public int | |
| public RecordHandle | Returns: A RecordHandle representing the new record.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)Insert a record anywhere on the page. |
| public RecordHandle | Returns: A RecordHandle representing the new record, or null if the row will not fit on a non-empty page.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)Insert a record at the specified slot. |
| public boolean | |
| public boolean | |
| public boolean | Returns: true if a scan that was positioned on the page at page
version version needs to reposition; false otherwisethe version number of the page when the scan positioned
on it (after which version the page should not have changed in a way
that requires repositioning) version)Check if this page has been changed in such a way that scans that are positioned on it will have to reposition. |
| public RecordHandle | Returns: The created record handle.the special recordId recordHandleConstant)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 int | Returns: the number of rows processed.Slot of row to move. slot, Object[] A template to read the current row into as part
of moving it. 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)Move record to a page toward the beginning of the file. |
| public int | |
| 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)Purge the row(s) from page. |
| public int | |
| public boolean | Returns: boolean indicating if the record still exists on the page.handle of the record to look for. handle, boolean if true, then routine will return true even if the
row is marked deleted. ignoreDelete)does the record still exist on the page? |
| public void | |
| public void | setRepositionNeeded()
Set a hint in the page object to indicate that scans positioned on it need to reposition. |
| public void | |
| 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)Is this page/deleted row a candidate for immediate reclaim space. |
| public boolean | Returns: true if it is likely an insert will fit on the page.Is it likely that an insert will fit on this page? |
| public boolean | Returns: true if insert of this row will fit on this page.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)will insert of this row fit on this page? |
| public void | unlatch()
Unlatch me, the page is exclusivly latched by its current user until this method call is made. |
| public RecordHandle | Returns: a Handle to the updated record.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)Update the complete record identified by the slot. |
| public RecordHandle | Returns: a Handle to the updated record.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)Update a field within the record, replacing its current value with the stored representation of newValue. |
| DIAG_BYTES_FREE | back to summary |
|---|---|
| public static final String DIAG_BYTES_FREE | |
| DIAG_BYTES_RESERVED | back to summary |
|---|---|
| public static final String DIAG_BYTES_RESERVED | |
| DIAG_MAXROWSIZE | back to summary |
|---|---|
| public static final String DIAG_MAXROWSIZE | |
| DIAG_MINIMUM_REC_SIZE | back to summary |
|---|---|
| public static final String DIAG_MINIMUM_REC_SIZE | |
| DIAG_MINROWSIZE | back to summary |
|---|---|
| public static final String DIAG_MINROWSIZE | |
| DIAG_NUMOVERFLOWED | back to summary |
|---|---|
| public static final String DIAG_NUMOVERFLOWED | |
| DIAG_PAGE_SIZE | back to summary |
|---|---|
| public static final String DIAG_PAGE_SIZE | |
| DIAG_PAGEOVERHEAD | back to summary |
|---|---|
| public static final String DIAG_PAGEOVERHEAD | |
| DIAG_RESERVED_SPACE | back to summary |
|---|---|
| public static final String DIAG_RESERVED_SPACE | |
| DIAG_ROWSIZE | back to summary |
|---|---|
| public static final String DIAG_ROWSIZE | |
| DIAG_SLOTTABLE_SIZE | back to summary |
|---|---|
| public static final String DIAG_SLOTTABLE_SIZE | |
| FIRST_SLOT_NUMBER | back to summary |
|---|---|
| public static final int FIRST_SLOT_NUMBER The slot number of the first slot. This is guaranteed to be zero. | |
| INSERT_CONDITIONAL | back to summary |
|---|---|
| public static final byte INSERT_CONDITIONAL | |
| INSERT_DEFAULT | back to summary |
|---|---|
| public static final byte INSERT_DEFAULT | |
| INSERT_FOR_SPLIT | back to summary |
|---|---|
| public static final byte INSERT_FOR_SPLIT | |
| INSERT_INITIAL | back to summary |
|---|---|
| public static final byte INSERT_INITIAL Values for insertFlag. INSERT_INITIAL - flag initializer INSERT_DEFAULT - default insert behavior, if the record does not fit on the page where the insert operation is called, an error will be returned, instead of overflowing the record. INSERT_UNDO_WITH_PURGE - if this is set, then the undo of this insert will purge the row rather than mark it as deleted, which is the default behaviro for insertAtSlot and insert. INSERT_CONDITIONAL - if this flag is set, then, the overflow is conditional. The record will be overflowed only if it exceeds the threshold specified by the properties, or the parameter. INSERT_OVERFLOW - if this flag is set, then the insert operation will overflow the record if it does not fit on the page. INSERT_FOR_SPLIT - a record is being updated that causes new portions to be inserted *and* the last new portion needs to point to an existing portion. Rules for the insert flags: 1. If INSERT_DEFAULT is set, INSERT_CONDITIONAL and INSERT_OVERFLOW will be ignored 2. INSERT_UNDO_WITH_PURGE can be set with any of the other 3 flags. 3. If INSERT_OVERFLOW is not set, INSERT_CONDITIONAL will be ignored. But, it is not necessary to set INSERT_CONDITIONAL when setting INSERT_OVERFLOW. 4. If INSERT_DEFAULT, INSERT_OVERFLOW both are not set, then, default insert action will be taken, i.e. no overflow will be allowed. | |
| INSERT_OVERFLOW | back to summary |
|---|---|
| public static final byte INSERT_OVERFLOW | |
| INSERT_UNDO_WITH_PURGE | back to summary |
|---|---|
| public static final byte INSERT_UNDO_WITH_PURGE | |
| INVALID_SLOT_NUMBER | back to summary |
|---|---|
| public static final int INVALID_SLOT_NUMBER A slot number guaranteed to be invalid. | |
| copyAndPurge | back to summary |
|---|---|
| public void copyAndPurge(Page destPage, int src_slot, int num_rows, int dest_slot) throws StandardException move rows from one page to another, purging in the process.
Move from this page slot[src_slot] to slot[src_slot+num_rows-1] to
destPage slot[dest_slot] to slot[dest_slot + num_rows - 1], in that
order. Both this page and destPage must be latched and from the same
container with the same page and record format.
Resolve reserve space now not copied over because in btree, a
row never shrinks. When this routine is called by heap or by some page
which will have shrunken row, then we need to add that
Locking Policy Calls the lockRecordForWrite() method of the LockingPolicy object passed to the openContainer() call before the rows are copied over and bore the records are purged. I.e, for num_rows moved, there will be 2*num_rows calls to lockRecordForWrite.
Use with caution
| |
| currentTimeStamp | back to summary |
|---|---|
| public PageTimeStamp currentTimeStamp() Return a time stamp that can be used to identify the page of this specific instance. For pages that don't support timestamp, returns null. | |
| deleteAtSlot | back to summary |
|---|---|
| public RecordHandle deleteAtSlot(int slot, boolean delete, LogicalUndo undo) throws StandardException Mark the record at slot as deleted or undeleted according to delete flag.
Locking Policy
Calls the lockRecordForWrite() method of the LockingPolicy object passed
to the openContainer() call before the record is deleted. If record
already deleted, and an attempt is made to delete it, an exception is
thrown. If record not deleted, and an attempt is made to undelete it,
an exception is thrown.
| |
| equalTimeStamp | back to summary |
|---|---|
| public boolean equalTimeStamp(PageTimeStamp ts) throws StandardException See if timeStamp for this page is the same as the current instance of the page. Null timeStamp never equals the instance of the page.
| |
| fetchFieldFromSlot | back to summary |
|---|---|
| public RecordHandle fetchFieldFromSlot(int slot, int fieldId, Object column) throws StandardException Fetch a single field from a deleted or non-deleted record.
Fills in the passed in Object column with the field
identified by fieldid if column is not null, otherwise the record
is locked but not fetched.
Locking Policy
| |
| fetchFromSlot | back to summary |
|---|---|
| public RecordHandle fetchFromSlot(RecordHandle rh, int slot, Object[] row, FetchDescriptor fetchDesc, boolean ignoreDelete) throws StandardException Fetch a record located in the passed in slot.
Fetch a record located in the passed in slot and fill-in the passed in
StorebleRow and the Object columns contained within. If row
is null then the record is locked but is not fetched.
| |
| fetchNumFields | back to summary |
|---|---|
| public int fetchNumFields(RecordHandle handle) throws StandardException Fetch the number of fields in a record. Locking Policy
No locks are obtained.
| |
| fetchNumFieldsAtSlot | back to summary |
|---|---|
| public int fetchNumFieldsAtSlot(int slot) throws StandardException Fetch the number of fields in a record.
Locking Policy
No locks are obtained.
| |
| getAuxObject | back to summary |
|---|---|
| public AuxObject getAuxObject() Retrieve this page's aux object, returning null if there isn't one. The reference returned
must only be used while the page is latched, once unlatch is called the reference to the
aux object must be discarded.
| |
| getInvalidRecordHandle | back to summary |
|---|---|
| public RecordHandle getInvalidRecordHandle() Return an invalid record handle.
| |
| getNextSlotNumber | back to summary |
|---|---|
| public int getNextSlotNumber(RecordHandle handle) throws StandardException Find slot for record with an id greater than the passed in identifier.
Find the slot for the first record on the page with an id greater than
the passed in identifier.
| |
| getPageKey | back to summary |
|---|---|
| public PageKey getPageKey() Return the page key of this page.
| |
| getPageNumber | back to summary |
|---|---|
| public long getPageNumber() Return the page number of this page. Page numbers are unique within a container and start at ContainerHandle.FIRST_PAGE_NUMBER and increment by 1 regardless of the page size.
| |
| getPageVersion | back to summary |
|---|---|
| public long getPageVersion() Get the current version number of the page.
| |
| getRecordHandle | back to summary |
|---|---|
| public RecordHandle getRecordHandle(int recordId) 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.
| |
| getRecordHandleAtSlot | back to summary |
|---|---|
| public RecordHandle getRecordHandleAtSlot(int slot) throws StandardException Get the record handle of row at slot.
Get the record handle of a record on a latched page using its slot
number.
| |
| getSlotNumber | back to summary |
|---|---|
| public int getSlotNumber(RecordHandle handle) throws StandardException Get the slot number. Get the slot number of a record on a latched page using its record handle. Note The slot number is only good for as long as the page is latched.
| |
| insert | back to summary |
|---|---|
| public RecordHandle insert(Object[] row, FormatableBitSet validColumns, byte insertFlag, int overflowThreshold) throws StandardException Insert a record anywhere on the page.
Locking Policy
| |
| insertAtSlot | back to summary |
|---|---|
| public RecordHandle insertAtSlot(int slot, Object[] row, FormatableBitSet validColumns, LogicalUndo undo, byte insertFlag, int overflowThreshold) throws StandardException Insert a record at the specified slot.
All records that occupy FIRST_SLOT_NUMBER to (slot - 1) are not moved.
Space Policy
Locking Policy
| |
| isDeletedAtSlot | back to summary |
|---|---|
| public boolean isDeletedAtSlot(int slot) throws StandardException Test if a record is deleted.
Locking Policy
| |
| isLatched | back to summary |
|---|---|
| public boolean isLatched() | |
| isRepositionNeeded | back to summary |
|---|---|
| public boolean isRepositionNeeded(long version) Check if this page has been changed in such a way that scans that are positioned on it will have to reposition. Only called on B-tree pages.
| |
| makeRecordHandle | back to summary |
|---|---|
| public RecordHandle makeRecordHandle(int recordHandleConstant) throws StandardException 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. Used for special cases like creating a key specific to the page, but not specific to a row on the page. See RecordHandle interface for a list of "special record handles."
| |
| moveRecordForCompressAtSlot | back to summary |
|---|---|
| public int moveRecordForCompressAtSlot(int slot, Object[] row, RecordHandle[] old_handle, RecordHandle[] new_handle) throws StandardException Move record to a page toward the beginning of the file. As part of compressing the table records need to be moved from the end of the file toward the beginning of the file. Only the contiguous set of free pages at the very end of the file can be given back to the OS. This call is used to purge the row from the current page, insert it into a previous page, and return the new row location Mark the record identified by position as deleted. The record may be undeleted sometime later using undelete() by any transaction that sees the record. The interface is optimized to work on a number of rows at a time, optimally processing all rows on the page at once. The call will process either all rows on the page, or the number of slots in the input arrays - whichever is smaller. Locking Policy
MUST be called with table locked, not locks are requested. Because
it is called with table locks the call will go ahead and purge any
row which is marked deleted. It will also use purge rather than
delete to remove the old row after it moves it to a new page. This
is ok since the table lock insures that no other transaction will
use space on the table before this transaction commits.
| |
| nonDeletedRecordCount | back to summary |
|---|---|
| public int nonDeletedRecordCount() throws StandardException Return the number of records on this page that are not marked as deleted.
| |
| purgeAtSlot | back to summary |
|---|---|
| public void purgeAtSlot(int slot, int numpurges, boolean needDataLogged) throws StandardException Purge the row(s) from page. Purge the row(s) from page, get rid of the row(s) and slot(s) - USE WITH CAUTION, please see entire description of this operation before attempting to use this. Starting from the specified slot, n rows will be purged. That is, rows that occupies from slot to slot+n-1 will be purged from the page. Locking Policy Calls the lockRecordForWrite() method of the LockingPolicy object passed to the openContainer() call before the records are purged.
NOTE : CAVEAT Note
| |
| recordCount | back to summary |
|---|---|
| public int recordCount() throws StandardException Return the number of records on the page. The returned count includes rows that are deleted,
i.e. it is the same as the number of slots on the page.
| |
| recordExists | back to summary |
|---|---|
| public boolean recordExists(RecordHandle handle, boolean ignoreDelete) throws StandardException does the record still exist on the page?
If "ignoreDelete" is true and the record handle represents a record on
the page (either marked deleted or not) return true. If "ignoreDelete"
is false return true if the record handle represents a record on the
page and the record is not marked as deleted. Return false otherwise.
| |
| setAuxObject | back to summary |
|---|---|
| public void setAuxObject(AuxObject aux) Set the aux object for this page.
To clear the auxObject in the page, pass in a null AuxObject.
If the AuxObject has already been set, this method will
call auxObjectInvalidated() on the old aux objkect and replace it with aux.
| |
| setRepositionNeeded | back to summary |
|---|---|
| public void setRepositionNeeded() Set a hint in the page object to indicate that scans positioned on it need to reposition. Only called on B-tree pages. | |
| setTimeStamp | back to summary |
|---|---|
| public void setTimeStamp(PageTimeStamp ts) throws StandardException Set the time stamp to what is on page at this instance. No op if this page does not support time stamp.
| |
| shouldReclaimSpace | back to summary |
|---|---|
| public boolean shouldReclaimSpace(int num_non_deleted_rows, int slot_just_deleted) throws StandardException Is this page/deleted row a candidate for immediate reclaim space. Used by access methods after executing a delete on "slot_just_deleted" to ask whether a post commit should be queued to try to reclaim space after the delete commits. Will return true if the number of non-deleted rows on the page is <= "num_non_deleted_rows". For instance 0 means schedule reclaim only if all rows are deleted, 1 if all rows but one are deleted. Will return true if the row just deleted is either a long row or long column. In this case doing a reclaim space on the single row may reclaim multiple pages of free space, so better to do it now rather than wait for all rows on page to be deleted. This case is to address the worst case scenario of all rows with long columns, but very short rows otherwise. In this case there could be 1000's of rows on the main page with many gigabytes of data on overflow pages in deleted space that would not be reclaimed until all rows on the page were deleted.
| |
| spaceForInsert | back to summary |
|---|---|
| public boolean spaceForInsert() throws StandardException Is it likely that an insert will fit on this page?
Return true if there is a good chance an insert will fit on this page,
false otherwise. If this returns true then an insert may still fail by
throwing an exception or by returning null, see insertAtSlot for details.
It is very probable that this call is much faster than the version that
takes a row. In situations where it is expected that the
majority of times a row will fit on a page this method should be used
and the null return handled from insert/insertAtSlot.
| |
| spaceForInsert | back to summary |
|---|---|
| public boolean spaceForInsert(Object[] row, FormatableBitSet validColumns, int overflowThreshold) throws StandardException will insert of this row fit on this page? Return true if this record is guaranteed to be inserted successfully using insert() or insertAtSlot(). This guarantee is only valid if the following conditions are fulfilled before an insert is called with t his row.
MT - latched
| |
| unlatch | back to summary |
|---|---|
| public void unlatch() Unlatch me, the page is exclusivly latched by its current user until
this method call is made.
ref.unlatch(); ref = null; The page will be released automatically at the close of the container if this method is not called explictly. MT - latched | |
| updateAtSlot | back to summary |
|---|---|
| public RecordHandle updateAtSlot(int slot, Object[] row, FormatableBitSet validColumns) throws StandardException Update the complete record identified by the slot. Locking Policy
Calls the lockRecordForWrite() method of the LockingPolicy object
passed to the openContainer() call before the record is undeleted.
If record already deleted, an exception is thrown.
| |
| updateFieldAtSlot | back to summary |
|---|---|
| public RecordHandle updateFieldAtSlot(int slot, int fieldId, Object newValue, LogicalUndo undo) throws StandardException Update a field within the record, replacing its current value with the stored representation of newValue. Record is identified by slot. If the field does not exist then it is added to the record, but only if (fieldId - 1) exists Resolve right now it throws an exception if fieldId is not already on the record, not add the next one as advertised. Locking Policy
Calls the lockRecordForWrite() method of the LockingPolicy object
passed to the openContainer() call before the record is updated.
| |