use of org.apache.gora.cassandra.query.CassandraRow in project gora by apache.
the class CassandraStore method addSubColumns.
/**
* When we add subcolumns, Gora keys are mapped to Cassandra partition keys only.
* This is because we follow the Cassandra logic where column family data is
* partitioned across nodes based on row Key.
*/
private void addSubColumns(String family, CassandraQuery<K, T> cassandraQuery, CassandraResultSet<K> cassandraResultSet) {
// select family columns that are included in the query
List<Row<K, ByteBuffer, ByteBuffer>> rows = this.cassandraClient.execute(cassandraQuery, family);
for (Row<K, ByteBuffer, ByteBuffer> row : rows) {
K key = row.getKey();
// find associated row in the resultset
CassandraRow<K> cassandraRow = cassandraResultSet.getRow(key);
if (cassandraRow == null) {
cassandraRow = new CassandraRow<>();
cassandraResultSet.putRow(key, cassandraRow);
cassandraRow.setKey(key);
}
ColumnSlice<ByteBuffer, ByteBuffer> columnSlice = row.getColumnSlice();
for (HColumn<ByteBuffer, ByteBuffer> hColumn : columnSlice.getColumns()) {
CassandraSubColumn cassandraSubColumn = new CassandraSubColumn();
cassandraSubColumn.setValue(hColumn);
cassandraSubColumn.setFamily(family);
cassandraRow.add(cassandraSubColumn);
}
}
}
Aggregations