h2/src/main/org/h2/mvstore/db/TransactionStore.java
/**
     * Commit a transaction.
     *
     * @param t the transaction
     * @param maxLogId the last log id
     */
Commit a transaction.
@param t the transaction
@param maxLogId the last log id
Commit a transaction . @param t the transaction @param maxLogId the last log id
void commit(Transaction t, long maxLogId) {
        if (store.isClosed()) {
            return;
        }
        synchronized (undoLog) {
            t.setStatus(Transaction.STATUS_COMMITTING);
            for (long logId = 0; logId < maxLogId; logId++) {
                Long undoKey = getOperationId(t.getId(), logId);
                Object[] op = undoLog.get(undoKey);
                if (op == null) {
                    undoKey = undoLog.ceilingKey(undoKey);
                    if (undoKey == null || getTransactionId(undoKey) != t.getId()) {
                        break;
                    }
                    logId = getLogId(undoKey) - 1;
                    continue;
                }
                int mapId = (Integer) op[0];
                MVMap<Object, VersionedValue> map = openMap(mapId);
                if (map == null) {
                } else {
                    Object key = op[1];
                    VersionedValue value = map.get(key);
                    if (value == null) {
                    } else if (value.value == null) {
                        map.remove(key);
                    } else {
                        VersionedValue v2 = new VersionedValue();
                        v2.value = value.value;
                        map.put(key, v2);
                    }
                }
                undoLog.remove(undoKey);
            }
        }
        endTransaction(t);
    }
void commit ( Transaction t , long maxLogId ) { if ( store . isClosed ( ) ) { return ; } synchronized ( undoLog ) { t . setStatus ( Transaction . STATUS_COMMITTING ) ; for ( long logId = 0 ; logId < maxLogId ; logId ++ ) { Long undoKey = getOperationId ( t . getId ( ) , logId ) ; Object [ ] op = undoLog . get ( undoKey ) ; if ( op == null ) { undoKey = undoLog . ceilingKey ( undoKey ) ; if ( undoKey == null || getTransactionId ( undoKey ) != t . getId ( ) ) { break ; } logId = getLogId ( undoKey ) - 1 ; continue ; } int mapId = ( Integer ) op [ 0 ] ; MVMap < Object , VersionedValue > map = openMap ( mapId ) ; if ( map == null ) { } else { Object key = op [ 1 ] ; VersionedValue value = map . get ( key ) ; if ( value == null ) { } else if ( value . value == null ) { map . remove ( key ) ; } else { VersionedValue v2 = new VersionedValue ( ) ; v2 . value = value . value ; map . put ( key , v2 ) ; } } undoLog . remove ( undoKey ) ; } } endTransaction ( t ) ; }
Commit a transaction.
Commit a transaction .
// TODO could synchronize on blocks (100 at a time or so) // partially committed: load next // map was later removed // nothing to do // remove the value