static byte[] appendZero(byte[] key) { return key == null ? null : ViewUtils.appendZero(key); } }
/** * Combined store and commit to the linked transaction. Although similar to storing and * committing explicitly, additional optimizations can be applied. In particular, no undo * log entry is required when committing the outermost transaction scope. This is the same * optimization used by null transactions (auto-commit). * * @param value value to store; pass null to delete * @throws IllegalStateException if position is undefined at invocation time * @throws ViewConstraintException if value is not permitted */ public default void commit(byte[] value) throws IOException { ViewUtils.commit(this, value); }
/** * Non-transactionally counts the number of entries within the given range. Implementations * of this method typically scan over the entries, and so it shouldn't be expected to run * in constant time. * * @param lowKey inclusive lowest key in the counted range; pass null for open range * @param highKey exclusive highest key in the counted range; pass null for open range */ public default long count(byte[] lowKey, byte[] highKey) throws IOException { return ViewUtils.count(this, false, lowKey, highKey); }
/** * Checks that leaf is defined and returns it. */ private CursorFrame leaf() { CursorFrame leaf = mLeaf; ViewUtils.positionCheck(leaf); return leaf; }
@Override public final String toString() { return ViewUtils.toString(this); }
@Override public LockResult skip(long amount, byte[] limitKey, boolean inclusive) throws IOException { return ViewUtils.skipWithLocks(this, amount, limitKey, inclusive); }
/** * Moves the Cursor to find the first available entry less than the given * key. * * <p>Ownership of the key instance transfers to the Cursor, and it must * not be modified after calling this method. * * @return {@link LockResult#UNOWNED UNOWNED}, {@link LockResult#ACQUIRED * ACQUIRED}, {@link LockResult#OWNED_SHARED OWNED_SHARED}, {@link * LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or {@link * LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} * @throws NullPointerException if key is null */ public default LockResult findLt(byte[] key) throws IOException { ViewUtils.findNoLock(this, key); return previous(); }
/** * Moves to the Cursor to the next available entry, but only when less than * or equal to the given limit key. Cursor key and value are set to null if * no applicable entry exists, and position will be undefined. * * @return {@link LockResult#UNOWNED UNOWNED}, {@link LockResult#ACQUIRED * ACQUIRED}, {@link LockResult#OWNED_SHARED OWNED_SHARED}, {@link * LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or {@link * LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} * @throws NullPointerException if limit key is null * @throws IllegalStateException if position is undefined at invocation time */ public default LockResult nextLe(byte[] limitKey) throws IOException { return ViewUtils.nextCmp(this, limitKey, 1); }
/** * Moves to the Cursor to the previous available entry, but only when * greater than the given limit key. Cursor key and value are set to null * if no applicable entry exists, and position will be undefined. * * @return {@link LockResult#UNOWNED UNOWNED}, {@link LockResult#ACQUIRED * ACQUIRED}, {@link LockResult#OWNED_SHARED OWNED_SHARED}, {@link * LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or {@link * LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} * @throws NullPointerException if limit key is null * @throws IllegalStateException if position is undefined at invocation time */ public default LockResult previousGt(byte[] limitKey) throws IOException { return ViewUtils.previousCmp(this, limitKey, 0); }
/** * Moves the Cursor by a relative amount of entries, stopping sooner if the limit key is * reached. Pass a positive amount to skip forward, and pass a negative amount to skip * backwards. If the limit key is reached, or if less than the given amount of entries are * available, the Cursor is reset. * * <p>Skipping by 1 is equivalent to calling {@link #nextLe nextLe}, {@link #nextLt nextLt} * or {@link #next next}, depending on which type of limit was provided. Likewise, skipping * by -1 is equivalent to calling {@link #previousGe previousGe}, {@link #previousGt * previousGt} or {@link #previous previous}. A skip of 0 merely checks and returns the * lock state for the current key. Lock acquisition only applies to the target entry * — no locks are acquired for entries in between. * * @param limitKey limit key; pass null for no limit * @param inclusive true if limit is inclusive, false for exclusive * @return {@link LockResult#UNOWNED UNOWNED}, {@link LockResult#ACQUIRED * ACQUIRED}, {@link LockResult#OWNED_SHARED OWNED_SHARED}, {@link * LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or {@link * LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} * @throws IllegalStateException if position is undefined at invocation time */ public default LockResult skip(long amount, byte[] limitKey, boolean inclusive) throws IOException { return ViewUtils.skip(this, amount, limitKey, inclusive); }
/** * Checks that mFrame is defined and returns it. * * @throws UnpositionedCursorException if unpositioned */ private _CursorFrame frame() { _CursorFrame frame = mFrame; ViewUtils.positionCheck(frame); return frame; }
@Override public final String toString() { return ViewUtils.toString(this); }
@Override public LockResult skip(long amount, byte[] limitKey, boolean inclusive) throws IOException { return ViewUtils.skipWithLocks(this, amount, limitKey, inclusive); }
/** * Moves the Cursor to find the first available entry greater than the * given key. * * <p>Ownership of the key instance transfers to the Cursor, and it must * not be modified after calling this method. * * @return {@link LockResult#UNOWNED UNOWNED}, {@link LockResult#ACQUIRED * ACQUIRED}, {@link LockResult#OWNED_SHARED OWNED_SHARED}, {@link * LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or {@link * LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} * @throws NullPointerException if key is null */ public default LockResult findGt(byte[] key) throws IOException { ViewUtils.findNoLock(this, key); return next(); }
/** * Moves to the Cursor to the next available entry, but only when less than * or equal to the given limit key. Cursor key and value are set to null if * no applicable entry exists, and position will be undefined. * * @return {@link LockResult#UNOWNED UNOWNED}, {@link LockResult#ACQUIRED * ACQUIRED}, {@link LockResult#OWNED_SHARED OWNED_SHARED}, {@link * LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or {@link * LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} * @throws NullPointerException if limit key is null * @throws IllegalStateException if position is undefined at invocation time */ public default LockResult nextLe(byte[] limitKey) throws IOException { return ViewUtils.nextCmp(this, limitKey, 1); }
/** * Moves to the Cursor to the previous available entry, but only when * greater than the given limit key. Cursor key and value are set to null * if no applicable entry exists, and position will be undefined. * * @return {@link LockResult#UNOWNED UNOWNED}, {@link LockResult#ACQUIRED * ACQUIRED}, {@link LockResult#OWNED_SHARED OWNED_SHARED}, {@link * LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or {@link * LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} * @throws NullPointerException if limit key is null * @throws UnpositionedCursorException if position is undefined at invocation time */ public default LockResult previousGt(byte[] limitKey) throws IOException { return ViewUtils.previousCmp(this, limitKey, 0); }
/** * Moves the Cursor by a relative amount of entries, stopping sooner if the limit key is * reached. Pass a positive amount to skip forward, and pass a negative amount to skip * backwards. If the limit key is reached, or if less than the given amount of entries are * available, the Cursor is reset. * * <p>Skipping by 1 is equivalent to calling {@link #nextLe nextLe}, {@link #nextLt nextLt} * or {@link #next next}, depending on which type of limit was provided. Likewise, skipping * by -1 is equivalent to calling {@link #previousGe previousGe}, {@link #previousGt * previousGt} or {@link #previous previous}. A skip of 0 merely checks and returns the * lock state for the current key. Lock acquisition only applies to the target entry * — no locks are acquired for entries in between. * * @param limitKey limit key; pass null for no limit * @param inclusive true if limit is inclusive, false for exclusive * @return {@link LockResult#UNOWNED UNOWNED}, {@link LockResult#ACQUIRED * ACQUIRED}, {@link LockResult#OWNED_SHARED OWNED_SHARED}, {@link * LockResult#OWNED_UPGRADABLE OWNED_UPGRADABLE}, or {@link * LockResult#OWNED_EXCLUSIVE OWNED_EXCLUSIVE} * @throws IllegalStateException if position is undefined at invocation time */ public default LockResult skip(long amount, byte[] limitKey, boolean inclusive) throws IOException { return ViewUtils.skip(this, amount, limitKey, inclusive); }
/** * Checks that leaf is defined and returns it. */ private _CursorFrame leaf() { _CursorFrame leaf = mLeaf; ViewUtils.positionCheck(leaf); return leaf; }
static byte[] appendZero(byte[] key) { return key == null ? null : ViewUtils.appendZero(key); } }
@Override public final String toString() { return ViewUtils.toString(this); }