@Override public boolean step() throws IOException { Cursor c = mCursor; try { c.next(); return c.key() != null; } catch (UnpositionedCursorException e) { return false; } catch (Throwable e) { throw ViewUtils.fail(this, e); } }
@Override public boolean step(long amount) throws IOException { Cursor c = mCursor; if (amount > 0) { try { c.skip(amount); } catch (UnpositionedCursorException e) { return false; } catch (Throwable e) { throw ViewUtils.fail(this, e); } } else if (amount < 0) { throw new IllegalArgumentException(); } return c.key() != null; }
@Override public boolean update(byte[] value) throws IOException { try { mCursor.store(value); } catch (UnpositionedCursorException e) { return false; } catch (Throwable e) { throw ViewUtils.fail(this, e); } return step(); } }
/** * Steps over the requested amount of entries. * * @param amount amount of entries to step over * @return false if no more entries remain and scanner has been closed * @throws IllegalArgumentException if amount is negative */ default boolean step(long amount) throws IOException { if (amount > 0) while (true) { boolean result = step(); if (!result || --amount <= 0) { return result; } } if (amount == 0) { return key() != null; } throw ViewUtils.fail(this, new IllegalArgumentException()); }
@Override public boolean update(byte[] value) throws IOException { try { mCursor.store(value); } catch (UnpositionedCursorException e) { resetTxnMode(); return false; } catch (Throwable e) { throw ViewUtils.fail(this, e); } return step(); }
@Override public boolean step(long amount) throws IOException { if (amount < 0) { throw new IllegalArgumentException(); } tryStep: { Cursor c = mCursor; if (amount > 0) { try { c.skip(amount); } catch (UnpositionedCursorException e) { break tryStep; } catch (Throwable e) { throw ViewUtils.fail(this, e); } } if (c.key() != null) { return true; } } resetTxnMode(); return false; }
@Override public boolean step() throws IOException { tryStep: { Cursor c = mCursor; try { c.next(); } catch (UnpositionedCursorException e) { break tryStep; } catch (Throwable e) { throw ViewUtils.fail(this, e); } if (c.key() != null) { return true; } } resetTxnMode(); return false; }
@Override public boolean step() throws IOException { TreeCursor c = cursor(); try { doStep(c); if (c.key() != null) { return true; } mDatabase.quickDeleteTemporaryTree(c.mTree); return false; } catch (UnpositionedCursorException e) { return false; } catch (Throwable e) { throw ViewUtils.fail(this, e); } }
@Override public boolean step() throws IOException { _TreeCursor c = cursor(); try { doStep(c); if (c.key() != null) { return true; } mDatabase.quickDeleteTemporaryTree(c.mTree); return false; } catch (UnpositionedCursorException e) { return false; } catch (Throwable e) { throw ViewUtils.fail(this, e); } }
/** * Calls the given action for each remaining entry, and then closes the scanner. */ default void scanAll(EntryConsumer action) throws IOException { while (true) { byte[] key = key(); if (key == null) { return; } try { action.accept(key, value()); } catch (Throwable e) { throw ViewUtils.fail(this, e); } step(); } }
@Override public boolean update(byte[] value) throws IOException { Cursor c = mCursor; try { c.store(value); } catch (UnpositionedCursorException e) { close(); return false; } catch (Throwable e) { throw ViewUtils.fail(this, e); } postUpdate(); LockResult result; tryStep: { try { result = c.next(); } catch (UnpositionedCursorException e) { break tryStep; } catch (Throwable e) { throw ViewUtils.fail(this, e); } if (c.key() != null) { mLockResult = result; return true; } } mLockResult = null; finished(); return false; }
/** * Applies the given updating action for each remaining entry, and then closes the updater. */ default void updateAll(EntryFunction action) throws IOException { while (true) { byte[] key = key(); if (key == null) { return; } byte[] value; try { value = action.apply(key, value()); } catch (Throwable e) { throw ViewUtils.fail(this, e); } update(value); } }
break tryStep; } catch (Throwable e) { throw ViewUtils.fail(this, e);
@Override public boolean step() throws IOException { LockResult result = mLockResult; if (result == null) { return false; } Cursor c = mCursor; tryStep: { if (result.isAcquired()) { c.link().unlock(); } try { result = c.next(); } catch (UnpositionedCursorException e) { break tryStep; } catch (Throwable e) { throw ViewUtils.fail(this, e); } if (c.key() != null) { mLockResult = result; return true; } } mLockResult = null; finished(); return false; }