Search in sources :

Example 1 with Statement

use of org.apache.ignite.internal.metastorage.server.Statement in project ignite-3 by apache.

the class RocksDbKeyValueStorage method invoke.

@Override
public StatementResult invoke(If iif) {
    rwLock.writeLock().lock();
    try {
        If currIf = iif;
        byte maximumNumOfNestedBranch = 100;
        while (true) {
            if (maximumNumOfNestedBranch-- <= 0) {
                throw new IgniteInternalException("Too many nested (" + maximumNumOfNestedBranch + ") statements in multi-invoke command.");
            }
            Entry[] entries = getAll(Arrays.asList(currIf.cond().keys())).toArray(new Entry[] {});
            Statement branch = (currIf.cond().test(entries)) ? currIf.andThen() : currIf.orElse();
            if (branch.isTerminal()) {
                Update update = branch.update();
                applyOperations(update.operations());
                return update.result();
            } else {
                currIf = branch.iif();
            }
        }
    } catch (RocksDBException e) {
        throw new IgniteInternalException(e);
    } finally {
        rwLock.writeLock().unlock();
    }
}
Also used : RocksDBException(org.rocksdb.RocksDBException) Entry(org.apache.ignite.internal.metastorage.server.Entry) IgniteInternalException(org.apache.ignite.lang.IgniteInternalException) Statement(org.apache.ignite.internal.metastorage.server.Statement) Update(org.apache.ignite.internal.metastorage.server.Update) If(org.apache.ignite.internal.metastorage.server.If)

Aggregations

Entry (org.apache.ignite.internal.metastorage.server.Entry)1 If (org.apache.ignite.internal.metastorage.server.If)1 Statement (org.apache.ignite.internal.metastorage.server.Statement)1 Update (org.apache.ignite.internal.metastorage.server.Update)1 IgniteInternalException (org.apache.ignite.lang.IgniteInternalException)1 RocksDBException (org.rocksdb.RocksDBException)1