use of com.netflix.astyanax.query.RowSliceQuery in project titan by thinkaurelius.
the class AstyanaxOrderedKeyColumnValueStore method getNamesSlice.
public Map<ByteBuffer, List<Entry>> getNamesSlice(List<StaticBuffer> keys, SliceQuery query, StoreTransaction txh) throws StorageException {
ByteBuffer[] requestKeys = new ByteBuffer[keys.size()];
{
for (int i = 0; i < keys.size(); i++) {
requestKeys[i] = keys.get(i).asByteBuffer();
}
}
/*
* RowQuery<K,C> should be parameterized as
* RowQuery<ByteBuffer,ByteBuffer>. However, this causes the following
* compilation error when attempting to call withColumnRange on a
* RowQuery<ByteBuffer,ByteBuffer> instance:
*
* java.lang.Error: Unresolved compilation problem: The method
* withColumnRange(ByteBuffer, ByteBuffer, boolean, int) is ambiguous
* for the type RowQuery<ByteBuffer,ByteBuffer>
*
* The compiler substitutes ByteBuffer=C for both startColumn and
* endColumn, compares it to its identical twin with that type
* hard-coded, and dies.
*
*/
RowSliceQuery rq = keyspace.prepareQuery(columnFamily).setConsistencyLevel(getTx(txh).getReadConsistencyLevel().getAstyanaxConsistency()).withRetryPolicy(retryPolicy.duplicate()).getKeySlice(requestKeys);
// Thank you, Astyanax, for making builder pattern useful :(
int limit = ((query.hasLimit()) ? query.getLimit() : Integer.MAX_VALUE - 1);
rq.withColumnRange(query.getSliceStart().asByteBuffer(), query.getSliceEnd().asByteBuffer(), false, limit + 1);
OperationResult<Rows<ByteBuffer, ByteBuffer>> r;
try {
r = (OperationResult<Rows<ByteBuffer, ByteBuffer>>) rq.execute();
} catch (ConnectionException e) {
throw new TemporaryStorageException(e);
}
return convertResult(r.getResult(), query.getSliceEnd().asByteBuffer(), limit);
}
Aggregations