KeyValue<Row> kv = new KeyValue<Row>();
kv.setKey(row.getKey());
if(!row.getColumns().isEmpty()) {
//Astyanax returns a row when there is none BUT we know if there are 0 columns there is really no row in the database
//then
Row r = rowProvider.get();
r.setKey(row.getKey());
CassandraSession.processColumns(row, r);
kv.setValue(r);
}
ByteArray b = new ByteArray(row.getKey());
map.put(b, kv);
cache.cacheRow(cf, row.getKey(), kv.getValue());
}
//UNFORTUNATELY, astyanax's result is NOT ORDERED by the keys we provided so, we need to iterate over the whole thing here
//into our own List :( :( .
List<KeyValue<Row>> finalRes = new ArrayList<KeyValue<Row>>();
Iterator<byte[]> keyIter = keysToLookup.iterator();
for(RowHolder<Row> r : results) {
if(r == null) {
byte[] key = keyIter.next();
ByteArray b = new ByteArray(key);
KeyValue<Row> kv = map.get(b);
finalRes.add(kv);
} else {
Row row = r.getValue();
KeyValue<Row> kv = new KeyValue<Row>();
kv.setKey(r.getKey());
kv.setValue(row);
finalRes.add(kv);
}