Class RecordId
- java.lang.Object
-
- org.apache.derby.impl.store.raw.data.RecordId
-
- All Implemented Interfaces:
Lockable
,RecordHandle
public final class RecordId extends java.lang.Object implements RecordHandle
Implementation of RecordHandle.
MT - Mutable - Immutable identity : Thread Aware -
The methods of RecordHandle only access the identity of the object and so the object appears immutable to them, as required.
The methods of Lockable are single thread required.
-
-
Field Summary
Fields Modifier and Type Field Description private PageKey
pageId
Page the record lives in.private int
recordId
The actual record id.private int
slotNumberHint
Last slot number this record id was at.-
Fields inherited from interface org.apache.derby.iapi.store.raw.RecordHandle
DEALLOCATE_PROTECTION_HANDLE, FIRST_RECORD_ID, INVALID_RECORD_HANDLE, PREVIOUS_KEY_HANDLE, RESERVED1_RECORD_HANDLE, RESERVED4_RECORD_HANDLE, RESERVED5_RECORD_HANDLE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object ref)
Implement value equality.ContainerKey
getContainerId()
Return the identity of my container.int
getId()
Get my record id.java.lang.Object
getPageId()
Return the identity of my Page.long
getPageNumber()
Get my page number.int
getSlotNumberHint()
What slot number might the record be at?int
hashCode()
Return a hashcode based on value.boolean
lockAttributes(int flag, java.util.Hashtable<java.lang.String,java.lang.Object> attributes)
This lockable wants to participate in the Virtual Lock table.boolean
lockerAlwaysCompatible()
Is a caller that holds a lock compatible with themselves?void
lockEvent(Latch lockInfo)
Lock me.boolean
requestCompatible(java.lang.Object requestedQualifier, java.lang.Object grantedQualifier)
Determine if this request can be granted.java.lang.String
toString()
void
unlockEvent(Latch lockInfo)
Unlock me.
-
-
-
Field Detail
-
pageId
private final PageKey pageId
Page the record lives in. MT - Immutable
-
recordId
private final int recordId
The actual record id. MT - Immutable
-
slotNumberHint
private transient int slotNumberHint
Last slot number this record id was at.
-
-
Constructor Detail
-
RecordId
public RecordId(ContainerKey container, long pageNumber, int recordId)
-
RecordId
public RecordId(PageKey pageId, int recordId)
-
RecordId
public RecordId(PageKey pageId, int recordId, int current_slot)
-
-
Method Detail
-
getId
public int getId()
Get my record id.
MT - thread safe- Specified by:
getId
in interfaceRecordHandle
- See Also:
RecordHandle.getId()
-
getPageNumber
public long getPageNumber()
Get my page number.
MT - thread safe- Specified by:
getPageNumber
in interfaceRecordHandle
- See Also:
RecordHandle.getPageNumber()
-
getPageId
public java.lang.Object getPageId()
Description copied from interface:RecordHandle
Return the identity of my Page.- Specified by:
getPageId
in interfaceRecordHandle
-
getContainerId
public ContainerKey getContainerId()
Description copied from interface:RecordHandle
Return the identity of my container.- Specified by:
getContainerId
in interfaceRecordHandle
-
getSlotNumberHint
public int getSlotNumberHint()
What slot number might the record be at?The raw store guarantees that the record handle of a record will not change, but its slot number may. When a RecordId is constructed the caller could have provided a slot number, if so return that slot number hint here. If a hint was not provided then the default Page.FIRST_SLOT_NUMBER will be returned.
- Specified by:
getSlotNumberHint
in interfaceRecordHandle
- Returns:
- The slot number the record handle may be at.
-
lockEvent
public void lockEvent(Latch lockInfo)
Lock me.
MT - Single thread required (methods of Lockable)- Specified by:
lockEvent
in interfaceLockable
- See Also:
Lockable.lockEvent(org.apache.derby.iapi.services.locks.Latch)
-
requestCompatible
public boolean requestCompatible(java.lang.Object requestedQualifier, java.lang.Object grantedQualifier)
Determine if this request can be granted.Implements the grant/wait lock logic for row locks. See the table in RowLock for more information.
MT - Single thread required (methods of Lockable)- Specified by:
requestCompatible
in interfaceLockable
- See Also:
Lockable.requestCompatible(java.lang.Object, java.lang.Object)
-
lockerAlwaysCompatible
public boolean lockerAlwaysCompatible()
Is a caller that holds a lock compatible with themselves?Row locks held in the same transaction are always compatible with themselves.
MT - Single thread required (methods of Lockable)- Specified by:
lockerAlwaysCompatible
in interfaceLockable
- See Also:
Lockable.lockerAlwaysCompatible()
-
unlockEvent
public void unlockEvent(Latch lockInfo)
Unlock me.
MT - Single thread required (methods of Lockable)- Specified by:
unlockEvent
in interfaceLockable
- See Also:
Lockable.unlockEvent(org.apache.derby.iapi.services.locks.Latch)
-
equals
public boolean equals(java.lang.Object ref)
Implement value equality.
MT - Thread safe- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Return a hashcode based on value.
MT - thread safe- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
lockAttributes
public boolean lockAttributes(int flag, java.util.Hashtable<java.lang.String,java.lang.Object> attributes)
This lockable wants to participate in the Virtual Lock table.- Specified by:
lockAttributes
in interfaceLockable
- Parameters:
flag
- use the bits in this int to decide if the user is interested in this kind of lockable object. The bits are defined in VirtualLockTable. For instance, the user may only ask for TABLE_AND_ROWLOCK and if this is not a table or row lock, then don't participate.attributes
- if this decides to participate, put all relevant attributes into the Hashtable. The complete list of interesting attributes is listed in VirtualLockTable. The following attributes must be present for all participating lockables: VirtualLockTable.LOCKNAME, VirtualLockTable.LOCKTYPE, either VirtualLockTable.CONTAINERID or VirtualLockTable.CONGLOMID,MT - this routine must be MP safe, caller will not be single threading the lock manager.
- Returns:
- true if this object has diagnostic information to add to the virtual lock table. If this object either does not want to participate in the diagnostic virtual lock table or none of the attributes requested are attributes of this lock, returns false.
- See Also:
VirtualLockTable
-
-