My question is about Cassandra 0.8 and Pelops. I found that Pelops uses the same Thrift command to read slice columns as it does to slice counter columns. It then iterates over the extracted set of Thrift objects ColumnOrSuperColumn, asserting that the column field (or counter_column) is not null. It seems obvious that for a mixed column family, any of these methods will fail.
So, does Cassandra require all columns in a column family to be of the same type?
The following code is a fragment of the Selector class from Pelops.
private List<Column> getColumnsFromRow(final ColumnParent colParent, final Bytes rowKey, final SlicePredicate colPredicate, final ConsistencyLevel cLevel) throws PelopsException { IOperation<List<Column>> operation = new IOperation<List<Column>>() { @Override public List<Column> execute(IPooledConnection conn) throws Exception { List<ColumnOrSuperColumn> apiResult = conn.getAPI().get_slice(safeGetRowKey(rowKey), colParent, colPredicate, cLevel); return toColumnList(apiResult); } }; return tryOperation(operation); } private List<CounterColumn> getCounterColumnsFromRow(final ColumnParent colParent, final Bytes rowKey, final SlicePredicate colPredicate, final ConsistencyLevel cLevel) throws PelopsException { IOperation<List<CounterColumn>> operation = new IOperation<List<CounterColumn>>() { @Override public List<CounterColumn> execute(IPooledConnection conn) throws Exception { List<ColumnOrSuperColumn> apiResult = conn.getAPI().get_slice(safeGetRowKey(rowKey), colParent, colPredicate, cLevel); return toCounterColumnList(apiResult); } }; return tryOperation(operation); } private static List<Column> toColumnList(List<ColumnOrSuperColumn> coscList) { List<Column> columns = new ArrayList<Column>(coscList.size()); for (ColumnOrSuperColumn cosc : coscList) { assert cosc.column != null : "The column should not be null"; columns.add(cosc.column); } return columns; } private static List<CounterColumn> toCounterColumnList(List<ColumnOrSuperColumn> coscList) { List<CounterColumn> columns = new ArrayList<CounterColumn>(coscList.size()); for (ColumnOrSuperColumn cosc : coscList) { assert cosc.counter_column != null : "The column should not be null"; columns.add(cosc.counter_column); } return columns; }
source share