Top Description Fields Constructors Methods
org.h2.mvstore

public final Class RootReference<K, V>

extends Object
Class Inheritance

Class RootReference is an immutable structure to represent state of the MVMap as a whole (not related to a particular B-Tree node). Single structure would allow for non-blocking atomic state change. The most important part of it is a reference to the root node.
Author
Andrei Tokar

Field Summary

Modifier and TypeField and Description
private final byte
appendCounter

Size of the occupied part of the append buffer.

private final byte
holdCount

Counter of reentrant locks.

private final long
ownerId

Lock owner thread id.

pack-priv volatile RootReference<K, V>
previous

Reference to the previous root in the chain.

public final Page<K, V>
root

The root page.

pack-priv final long
updateAttemptCounter

Counter for attempted root updates.

pack-priv final long
updateCounter

Counter for successful root updates.

public final long
version

The version used for writing.

Constructor Summary

AccessConstructor and Description
pack-priv
RootReference(Page<K, V> root, long version)

private
RootReference(RootReference<K, V> r, Page<K, V> root, long updateAttemptCounter)

private
RootReference(RootReference<K, V> r, int attempt)

private
RootReference(RootReference<K, V> r, Page<K, V> root, boolean keepLocked, int appendCounter)

private
RootReference(RootReference<K, V> r, long version, int attempt)

Method Summary

Modifier and TypeMethod and Description
private boolean
pack-priv int
public long
pack-priv long
pack-priv boolean

Returns:

true if this root has unsaved changes
hasChangesSince
(long
to check against
version
,
boolean
whether map is backed by persistent storage
persistent
)

Does the root have changes since the specified version?

private boolean
pack-priv boolean
public boolean
public boolean

Returns:

true if yes
needFlush
()

Whether flushing is needed.

pack-priv void
removeUnusedOldVersions(long
the oldest version that needs to be retained
oldestVersionToKeep
)

Removed old versions that are not longer used.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

pack-priv RootReference<K, V>

Returns:

the new, locked, root reference, or null if not successful
tryLock
(int
the number of attempts so far
attemptCounter
)

Try to lock.

pack-priv RootReference<K, V>

Returns:

the new, unlocked and updated, root reference, or null if not successful
tryUnlockAndUpdateVersion
(long
the version
version
,
int
the number of attempts so far
attempt
)

Try to unlock, and if successful update the version

private RootReference<K, V>
tryUpdate(RootReference<K, V> updatedRootReference)

pack-priv RootReference<K, V>

Returns:

the new root reference, or null if not successful
updatePageAndLockedStatus
(Page<K, V>
the page
page
,
boolean
whether to keep it locked
keepLocked
,
int
number of items in append buffer
appendCounter
)

Update the page, possibly keeping it locked.

pack-priv RootReference<K, V>

Returns:

the new, unlocked, root reference, or null if not successful
updateRootPage
(Page<K, V>
the new root page
newRootPage
,
long
the number of attempts so far
attemptCounter
)

Try to unlock.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

appendCounterback to summary
private final byte appendCounter

Size of the occupied part of the append buffer.

holdCountback to summary
private final byte holdCount

Counter of reentrant locks.

ownerIdback to summary
private final long ownerId

Lock owner thread id.

previousback to summary
pack-priv volatile RootReference<K, V> previous

Reference to the previous root in the chain. That is the last root of the previous version, which had any data changes. Versions without any data changes are dropped from the chain, as it built.

rootback to summary
public final Page<K, V> root

The root page.

updateAttemptCounterback to summary
pack-priv final long updateAttemptCounter

Counter for attempted root updates.

updateCounterback to summary
pack-priv final long updateCounter

Counter for successful root updates.

versionback to summary
public final long version

The version used for writing.

Constructor Detail

RootReferenceback to summary
pack-priv RootReference(Page<K, V> root, long version)
RootReferenceback to summary
private RootReference(RootReference<K, V> r, Page<K, V> root, long updateAttemptCounter)
RootReferenceback to summary
private RootReference(RootReference<K, V> r, int attempt)
RootReferenceback to summary
private RootReference(RootReference<K, V> r, Page<K, V> root, boolean keepLocked, int appendCounter)
RootReferenceback to summary
private RootReference(RootReference<K, V> r, long version, int attempt)

Method Detail

canUpdateback to summary
private boolean canUpdate()
getAppendCounterback to summary
pack-priv int getAppendCounter()
getTotalCountback to summary
public long getTotalCount()
getVersionback to summary
pack-priv long getVersion()
hasChangesSinceback to summary
pack-priv boolean hasChangesSince(long version, boolean persistent)

Does the root have changes since the specified version?

Parameters
version:long

to check against

persistent:boolean

whether map is backed by persistent storage

Returns:boolean

true if this root has unsaved changes

isFreeback to summary
private boolean isFree()
isLockedback to summary
pack-priv boolean isLocked()
isLockedByCurrentThreadback to summary
public boolean isLockedByCurrentThread()
needFlushback to summary
public boolean needFlush()

Whether flushing is needed.

Returns:boolean

true if yes

removeUnusedOldVersionsback to summary
pack-priv void removeUnusedOldVersions(long oldestVersionToKeep)

Removed old versions that are not longer used.

Parameters
oldestVersionToKeep:long

the oldest version that needs to be retained

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
tryLockback to summary
pack-priv RootReference<K, V> tryLock(int attemptCounter)

Try to lock.

Parameters
attemptCounter:int

the number of attempts so far

Returns:RootReference<K, V>

the new, locked, root reference, or null if not successful

tryUnlockAndUpdateVersionback to summary
pack-priv RootReference<K, V> tryUnlockAndUpdateVersion(long version, int attempt)

Try to unlock, and if successful update the version

Parameters
version:long

the version

attempt:int

the number of attempts so far

Returns:RootReference<K, V>

the new, unlocked and updated, root reference, or null if not successful

tryUpdateback to summary
private RootReference<K, V> tryUpdate(RootReference<K, V> updatedRootReference)
updatePageAndLockedStatusback to summary
pack-priv RootReference<K, V> updatePageAndLockedStatus(Page<K, V> page, boolean keepLocked, int appendCounter)

Update the page, possibly keeping it locked.

Parameters
page:Page<K, V>

the page

keepLocked:boolean

whether to keep it locked

appendCounter:int

number of items in append buffer

Returns:RootReference<K, V>

the new root reference, or null if not successful

updateRootPageback to summary
pack-priv RootReference<K, V> updateRootPage(Page<K, V> newRootPage, long attemptCounter)

Try to unlock.

Parameters
newRootPage:Page<K, V>

the new root page

attemptCounter:long

the number of attempts so far

Returns:RootReference<K, V>

the new, unlocked, root reference, or null if not successful