我的问题涉及Cassandra 0.8和Pelops。我发现Pelops使用相同的Thrift命令来读取一片列,就像一片计数器列一样。然后,它遍历检索到的Thrift ColumnOrSuperColumn对象的集合,声明该列(或counter_column)字段不为null。似乎很明显,对于混合列族,执行这些方法中的任何一个都会失败。
那么,Cassandra是否要求列族中的所有列都属于同一类型?
以下代码是Pelops的Selector类的片段。
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;
}
答案 0 :(得分:1)
那么,Cassandra是否需要全部 列族中的列是 属于同一类型?
是的,从某种意义上说,它确实要求CF包含所有计数器或所有非计数器。但是,