src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
/**
     * AddColumn throws an exception if the column added does not sort after
     * the last column in the map.
     * The reasoning is that this implementation can get slower if too much
     * insertions are done in unsorted order and right now we only use it when
     * *all* insertion (with this method) are done in sorted order. The
     * assertion throwing is thus a protection against performance regression
     * without knowing about (we can revisit that decision later if we have
     * use cases where most insert are in sorted order but a few are not).
     */
AddColumn throws an exception if the column added does not sort after
the last column in the map.
The reasoning is that this implementation can get slower if too much
insertions are done in unsorted order and right now we only use it when
*all* insertion (with this method) are done in sorted order. The
assertion throwing is thus a protection against performance regression
without knowing about (we can revisit that decision later if we have
use cases where most insert are in sorted order but a few are not).
AddColumn throws an exception if the column added does not sort after the last column in the map . The reasoning is that this implementation can get slower if too much insertions are done in unsorted order and right now we only use it when * all * insertion ( with this method ) are done in sorted order . The assertion throwing is thus a protection against performance regression without knowing about ( we can revisit that decision later if we have use cases where most insert are in sorted order but a few are not ) .
public void addColumn(IColumn column, Allocator allocator)
    {
        if (columns.isEmpty())
        {
            columns.add(column);
            return;
        }
        int c = compare(columns.get(size() - 1).name(), column.name());
        assert c <= 0 : "Added column does not sort as the " + (reversed ? "first" : "last") + " column";
        if (c < 0)
        {
            columns.add(column);
        }
        else if (c == 0)
        {
            resolveAgainst(size() - 1, column, allocator);
        }
        else
        {
            int pos = binarySearch(column.name());
            if (pos >= 0)
                resolveAgainst(pos, column, allocator);
            else
                columns.add(-pos-1, column);
        }
    }
public void addColumn ( IColumn column , Allocator allocator ) { if ( columns . isEmpty ( ) ) { columns . add ( column ) ; return ; } int c = compare ( columns . get ( size ( ) - 1 ) . name ( ) , column . name ( ) ) ; assert c <= 0 : "Added column does not sort as the " + ( reversed ? "first" : "last" ) + " column" ; if ( c < 0 ) { columns . add ( column ) ; } else if ( c == 0 ) { resolveAgainst ( size ( ) - 1 , column , allocator ) ; } else { int pos = binarySearch ( column . name ( ) ) ; if ( pos >= 0 ) resolveAgainst ( pos , column , allocator ) ; else columns . add ( - pos - 1 , column ) ; } }
AddColumn throws an exception if the column added does not sort after
 the last column in the map.
AddColumn throws an exception if the column added does not sort after the last column in the map .
// Fast path if inserting at the tail // note that we want an assertion here (see addColumn javadoc), but we also want that if // assertion are disabled, addColumn works correctly with unsorted input // Insert as last // Resolve against last