Search in sources :

Example 36 with TemporaryStorageException

use of com.thinkaurelius.titan.diskstorage.TemporaryStorageException in project titan by thinkaurelius.

the class HBaseKeyColumnValueStore method getHelper.

private List<List<Entry>> getHelper(List<StaticBuffer> keys, Filter getFilter) throws StorageException {
    List<Get> requests = new ArrayList<Get>(keys.size());
    {
        for (StaticBuffer key : keys) {
            requests.add(new Get(key.as(StaticBuffer.ARRAY_FACTORY)).addFamily(columnFamilyBytes).setFilter(getFilter));
        }
    }
    List<List<Entry>> results = new ArrayList<List<Entry>>();
    try {
        HTableInterface table = null;
        Result[] r = null;
        try {
            table = pool.getTable(tableName);
            r = table.get(requests);
        } finally {
            IOUtils.closeQuietly(table);
        }
        if (r == null)
            return Collections.emptyList();
        for (Result result : r) {
            List<Entry> entries = new ArrayList<Entry>(result.size());
            Map<byte[], byte[]> fmap = result.getFamilyMap(columnFamilyBytes);
            if (null != fmap) {
                for (Map.Entry<byte[], byte[]> ent : fmap.entrySet()) {
                    entries.add(StaticBufferEntry.of(new StaticArrayBuffer(ent.getKey()), new StaticArrayBuffer(ent.getValue())));
                }
            }
            results.add(entries);
        }
        return results;
    } catch (IOException e) {
        throw new TemporaryStorageException(e);
    }
}
Also used : StaticArrayBuffer(com.thinkaurelius.titan.diskstorage.util.StaticArrayBuffer) IOException(java.io.IOException) TemporaryStorageException(com.thinkaurelius.titan.diskstorage.TemporaryStorageException) StaticBuffer(com.thinkaurelius.titan.diskstorage.StaticBuffer) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 37 with TemporaryStorageException

use of com.thinkaurelius.titan.diskstorage.TemporaryStorageException in project titan by thinkaurelius.

the class HBaseKeyColumnValueStore method containsKey.

@Override
public boolean containsKey(StaticBuffer key, StoreTransaction txh) throws StorageException {
    byte[] keyBytes = key.as(StaticBuffer.ARRAY_FACTORY);
    Get g = new Get(keyBytes).addFamily(columnFamilyBytes);
    try {
        HTableInterface table = null;
        try {
            table = pool.getTable(tableName);
            return table.exists(g);
        } finally {
            IOUtils.closeQuietly(table);
        }
    } catch (IOException e) {
        throw new TemporaryStorageException(e);
    }
}
Also used : TemporaryStorageException(com.thinkaurelius.titan.diskstorage.TemporaryStorageException) IOException(java.io.IOException)

Aggregations

TemporaryStorageException (com.thinkaurelius.titan.diskstorage.TemporaryStorageException)37 StorageException (com.thinkaurelius.titan.diskstorage.StorageException)11 PermanentStorageException (com.thinkaurelius.titan.diskstorage.PermanentStorageException)10 IOException (java.io.IOException)10 StaticBuffer (com.thinkaurelius.titan.diskstorage.StaticBuffer)9 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)6 Test (org.junit.Test)6 CTConnection (com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection)5 InvalidRequestException (org.apache.cassandra.thrift.InvalidRequestException)5 NotFoundException (org.apache.cassandra.thrift.NotFoundException)5 SchemaDisagreementException (org.apache.cassandra.thrift.SchemaDisagreementException)5 TException (org.apache.thrift.TException)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 ConsistentKeyLockStatus (com.thinkaurelius.titan.diskstorage.locking.consistentkey.ConsistentKeyLockStatus)4 ByteBuffer (java.nio.ByteBuffer)4 Cassandra (org.apache.cassandra.thrift.Cassandra)4 CfDef (org.apache.cassandra.thrift.CfDef)4 KsDef (org.apache.cassandra.thrift.KsDef)4 TitanException (com.thinkaurelius.titan.core.TitanException)3 Entry (com.thinkaurelius.titan.diskstorage.keycolumnvalue.Entry)3