Search in sources :

Example 6 with RowSliceQuery

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);
}
Also used : RowSliceQuery(com.netflix.astyanax.query.RowSliceQuery) TemporaryStorageException(com.thinkaurelius.titan.diskstorage.TemporaryStorageException) ByteBuffer(java.nio.ByteBuffer) StaticByteBuffer(com.thinkaurelius.titan.diskstorage.util.StaticByteBuffer) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException)

Aggregations

ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)6 RowSliceQuery (com.netflix.astyanax.query.RowSliceQuery)6 ByteBuffer (java.nio.ByteBuffer)6 Rows (com.netflix.astyanax.model.Rows)2 TemporaryStorageException (com.thinkaurelius.titan.diskstorage.TemporaryStorageException)2 Partitioner (com.thinkaurelius.titan.diskstorage.cassandra.AbstractCassandraStoreManager.Partitioner)2 StaticByteBuffer (com.thinkaurelius.titan.diskstorage.util.StaticByteBuffer)2 PermanentBackendException (org.janusgraph.diskstorage.PermanentBackendException)2 TemporaryBackendException (org.janusgraph.diskstorage.TemporaryBackendException)2 Column (com.netflix.astyanax.model.Column)1 ColumnList (com.netflix.astyanax.model.ColumnList)1 Row (com.netflix.astyanax.model.Row)1 RowQuery (com.netflix.astyanax.query.RowQuery)1 PermanentStorageException (com.thinkaurelius.titan.diskstorage.PermanentStorageException)1 TraversalInterruptedException (org.apache.tinkerpop.gremlin.process.traversal.util.TraversalInterruptedException)1 EntryList (org.janusgraph.diskstorage.EntryList)1 StaticBuffer (org.janusgraph.diskstorage.StaticBuffer)1 Partitioner (org.janusgraph.diskstorage.cassandra.AbstractCassandraStoreManager.Partitioner)1