src/java/org/apache/cassandra/thrift/ThriftConverter.java
//Assumes the lock on currentlyVisibleColumn is already held, so we can update it's previousVersions
Assumes the lock on currentlyVisibleColumn is already held, so we can update it's previousVersions
Assumes the lock on currentlyVisibleColumn is already held so we can update it ' s previousVersions
private static void applyCheckTransactionUpdate(org.apache.cassandra.db.Column currentlyVisibleColumn, long transactionId, CommitOrNotYetTime checkResult)
    {
        long newEarliestValidTime = checkResult.commitTime != null ? checkResult.commitTime : checkResult.notYetCommittedTime;
        NavigableSet<IColumn> allVersions = currentlyVisibleColumn.previousVersions();
        allVersions.add(currentlyVisibleColumn);
        PendingTransactionColumn updatedColumn = null;
        Long minPendingTransactionTime = Long.MAX_VALUE;
        for (IColumn column : allVersions.descendingSet()) {
            if (column instanceof PendingTransactionColumn) {
                if (((PendingTransactionColumn) column).getTransactionId() == transactionId) {
                    updatedColumn = (PendingTransactionColumn) column;
                    if (checkResult.commitTime == null) {
                        minPendingTransactionTime = Math.min(checkResult.notYetCommittedTime, minPendingTransactionTime);
                    }
                } else {
                    minPendingTransactionTime = Math.min(column.earliestValidTime(), minPendingTransactionTime);
                }
            }
        }
        assert updatedColumn != null : "This is actually fine, but don't expect this initially";
        if (updatedColumn != null && newEarliestValidTime > updatedColumn.earliestValidTime()) {
            boolean removed = allVersions.remove(updatedColumn);
            assert removed == true;
            updatedColumn.setEarliestValidTime(newEarliestValidTime);
            allVersions.add(updatedColumn);
            Long previousEVT = null;
            for (IColumn column : allVersions) {
                if (minPendingTransactionTime == Long.MAX_VALUE) {
                    column.setLatestValidTime(previousEVT);
                } else if (minPendingTransactionTime <= column.earliestValidTime()) {
                    column.setLatestValidTime(column.earliestValidTime());
                } else {
                    assert minPendingTransactionTime > column.earliestValidTime();
                    column.setLatestValidTime(Math.min(minPendingTransactionTime, previousEVT));
                }
                previousEVT = column.earliestValidTime();
            }
        }
        allVersions.remove(currentlyVisibleColumn);
    }
private static void applyCheckTransactionUpdate ( org . apache . cassandra . db . Column currentlyVisibleColumn , long transactionId , CommitOrNotYetTime checkResult ) { long newEarliestValidTime = checkResult . commitTime != null ? checkResult . commitTime : checkResult . notYetCommittedTime ; NavigableSet < IColumn > allVersions = currentlyVisibleColumn . previousVersions ( ) ; allVersions . add ( currentlyVisibleColumn ) ; PendingTransactionColumn updatedColumn = null ; Long minPendingTransactionTime = Long . MAX_VALUE ; for ( IColumn column : allVersions . descendingSet ( ) ) { if ( column instanceof PendingTransactionColumn ) { if ( ( ( PendingTransactionColumn ) column ) . getTransactionId ( ) == transactionId ) { updatedColumn = ( PendingTransactionColumn ) column ; if ( checkResult . commitTime == null ) { minPendingTransactionTime = Math . min ( checkResult . notYetCommittedTime , minPendingTransactionTime ) ; } } else { minPendingTransactionTime = Math . min ( column . earliestValidTime ( ) , minPendingTransactionTime ) ; } } } assert updatedColumn != null : "This is actually fine, but don't expect this initially" ; if ( updatedColumn != null && newEarliestValidTime > updatedColumn . earliestValidTime ( ) ) { boolean removed = allVersions . remove ( updatedColumn ) ; assert removed == true ; updatedColumn . setEarliestValidTime ( newEarliestValidTime ) ; allVersions . add ( updatedColumn ) ; Long previousEVT = null ; for ( IColumn column : allVersions ) { if ( minPendingTransactionTime == Long . MAX_VALUE ) { column . setLatestValidTime ( previousEVT ) ; } else if ( minPendingTransactionTime <= column . earliestValidTime ( ) ) { column . setLatestValidTime ( column . earliestValidTime ( ) ) ; } else { assert minPendingTransactionTime > column . earliestValidTime ( ) ; column . setLatestValidTime ( Math . min ( minPendingTransactionTime , previousEVT ) ) ; } previousEVT = column . earliestValidTime ( ) ; } } allVersions . remove ( currentlyVisibleColumn ) ; }
Assumes the lock on currentlyVisibleColumn is already held, so we can update it's previousVersions
Assumes the lock on currentlyVisibleColumn is already held so we can update it ' s previousVersions
//To simplify this code I'll temporarily add the current versions to previousVersions to get all versions //but it must be removed before the function returns //first pass, find the update PTC and determine the minimumPendingTransactionTIme //TODO just return if updatedColumn is null //only do the update if we're actually moving the evt forward //remove the updatedColumn and reinsert it with its new EVT //second pass, update all LVTs //remove the visible version from previousVersion before returning