Search in sources :

Example 21 with LockResult

use of org.cojen.tupl.LockResult in project Tupl by cojen.

the class TransformedCursor method findLt.

@Override
public LockResult findLt(final byte[] tkey) throws IOException {
    final Cursor c = mSource;
    LockResult result;
    try {
        byte[] key = inverseTransformKey(tkey);
        if (key == null) {
            key = mTransformer.inverseTransformKeyLt(tkey);
            if (key == null) {
                reset();
                return LockResult.UNOWNED;
            }
            result = c.findLe(key);
        } else {
            result = c.findLt(key);
        }
    } catch (LockFailureException e) {
        throw transformCurrent(e);
    }
    result = transformCurrent(result);
    return result == null ? previous() : result;
}
Also used : LockResult(org.cojen.tupl.LockResult) Cursor(org.cojen.tupl.Cursor) LockFailureException(org.cojen.tupl.LockFailureException)

Example 22 with LockResult

use of org.cojen.tupl.LockResult in project Tupl by cojen.

the class TransformedCursor method findGt.

@Override
public LockResult findGt(final byte[] tkey) throws IOException {
    final Cursor c = mSource;
    LockResult result;
    try {
        byte[] key = inverseTransformKey(tkey);
        if (key == null) {
            key = mTransformer.inverseTransformKeyGt(tkey);
            if (key == null) {
                reset();
                return LockResult.UNOWNED;
            }
            result = c.findGe(key);
        } else {
            result = c.findGt(key);
        }
    } catch (LockFailureException e) {
        throw transformCurrent(e);
    }
    result = transformCurrent(result);
    return result == null ? next() : result;
}
Also used : LockResult(org.cojen.tupl.LockResult) Cursor(org.cojen.tupl.Cursor) LockFailureException(org.cojen.tupl.LockFailureException)

Example 23 with LockResult

use of org.cojen.tupl.LockResult in project Tupl by cojen.

the class TransformedCursor method last.

@Override
public LockResult last() throws IOException {
    LockResult result;
    try {
        result = mSource.last();
    } catch (LockFailureException e) {
        throw transformCurrent(e);
    }
    result = transformCurrent(result);
    return result == null ? previous() : result;
}
Also used : LockResult(org.cojen.tupl.LockResult) LockFailureException(org.cojen.tupl.LockFailureException)

Example 24 with LockResult

use of org.cojen.tupl.LockResult in project Tupl by cojen.

the class TransformedCursor method previousGt.

@Override
public LockResult previousGt(final byte[] limitTKey) throws IOException {
    final Cursor c = mSource;
    LockResult result;
    byte[] limitKey = inverseTransformKey(limitTKey);
    if (limitKey == null) {
        limitKey = mTransformer.inverseTransformKeyGt(limitTKey);
        if (limitKey == null) {
            reset();
            return LockResult.UNOWNED;
        }
        while (true) {
            try {
                result = c.previousGe(limitKey);
            } catch (LockFailureException e) {
                throw transformCurrent(e);
            }
            result = transformCurrent(result);
            if (result != null) {
                return result;
            }
        }
    } else {
        while (true) {
            try {
                result = c.previousGt(limitKey);
            } catch (LockFailureException e) {
                throw transformCurrent(e);
            }
            result = transformCurrent(result);
            if (result != null) {
                return result;
            }
        }
    }
}
Also used : LockResult(org.cojen.tupl.LockResult) Cursor(org.cojen.tupl.Cursor) LockFailureException(org.cojen.tupl.LockFailureException)

Example 25 with LockResult

use of org.cojen.tupl.LockResult in project Tupl by cojen.

the class TransformedCursor method next.

@Override
public LockResult next() throws IOException {
    final Cursor c = mSource;
    while (true) {
        LockResult result;
        try {
            result = c.next();
        } catch (LockFailureException e) {
            throw transformCurrent(e);
        }
        result = transformCurrent(result);
        if (result != null) {
            return result;
        }
    }
}
Also used : LockResult(org.cojen.tupl.LockResult) Cursor(org.cojen.tupl.Cursor) LockFailureException(org.cojen.tupl.LockFailureException)

Aggregations

LockResult (org.cojen.tupl.LockResult)68 Cursor (org.cojen.tupl.Cursor)28 BoundedView (org.cojen.tupl.views.BoundedView)14 LockFailureException (org.cojen.tupl.LockFailureException)13 Transaction (org.cojen.tupl.Transaction)8 UnpositionedCursorException (org.cojen.tupl.UnpositionedCursorException)5 LockMode (org.cojen.tupl.LockMode)4 IOException (java.io.IOException)1 SoftReference (java.lang.ref.SoftReference)1 Combiner (org.cojen.tupl.Combiner)1 RowPredicateLock (org.cojen.tupl.core.RowPredicateLock)1 LocalPool (org.cojen.tupl.util.LocalPool)1