@Override public Void execute(Cassandra.Client cassandra) throws HectorException { try { cassandra.insert(key, columnParent, column, getThriftCl(OperationType.WRITE)); return null; } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public Void execute(Cassandra.Client cassandra) throws HectorException { try { cassandra.remove(key, columnPath, timestamp, getThriftCl(OperationType.WRITE)); return null; } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public Map<ByteBuffer, Integer> execute(Cassandra.Client cassandra) throws HectorException { try { return cassandra.multiget_count(keys, columnParent, slicePredicate, getThriftCl(OperationType.READ)); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public String execute(Cassandra.Client cassandra) throws HectorException { try { return cassandra.describe_version(); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public String execute(Cassandra.Client cassandra) throws HectorException { try { if ( log.isInfoEnabled() ) { log.info("in execute with client {}", cassandra); } return cassandra.describe_partitioner(); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public Map<String,List<String>> execute(Cassandra.Client cassandra) throws HectorException { try { return cassandra.describe_schema_versions(); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public Integer execute(Cassandra.Client cassandra) throws HectorException { try { return cassandra.get_count(key, columnParent, predicate, getThriftCl(OperationType.READ)); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public String execute(Cassandra.Client cassandra) throws HectorException { try { return cassandra.describe_cluster_name(); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public List<TokenRange> execute(Cassandra.Client cassandra) throws HectorException { try { return cassandra.describe_ring(keyspace); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public Void execute(Cassandra.Client cassandra) throws HectorException { try { cassandra.batch_mutate(mutationMap, getThriftCl(OperationType.WRITE)); } catch (Exception e) { throw xtrans.translate(e); } return null; } };
@Override public Void execute(Cassandra.Client cassandra) throws HectorException { try { cassandra.add(key, columnParent, counterColumn, getThriftCl(OperationType.WRITE)); return null; } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public Void execute(Cassandra.Client cassandra) throws HectorException { try { cassandra.remove_counter(key, columnPath, getThriftCl(OperationType.WRITE)); return null; } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public Void execute(Cassandra.Client cassandra) throws HectorException { try { cassandra.truncate(columnFamily); } catch (Exception e) { throw xtrans.translate(e); } return null; } };
@Override public Map<ByteBuffer, List<Column>> execute(Cassandra.Client cassandra) throws HectorException { try { Map<ByteBuffer, List<ColumnOrSuperColumn>> cfmap = cassandra.multiget_slice( keys, columnParent, predicate, getThriftCl(OperationType.READ)); Map<ByteBuffer, List<Column>> result = new HashMap<ByteBuffer, List<Column>>(); for (Map.Entry<ByteBuffer, List<ColumnOrSuperColumn>> entry : cfmap.entrySet()) { result.put(entry.getKey(), getColumnList(entry.getValue())); } return result; } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public CounterColumn execute(Cassandra.Client cassandra) throws HectorException { ColumnOrSuperColumn cosc; try { cosc = cassandra.get(key, columnPath, getThriftCl(OperationType.READ)); } catch (NotFoundException e) { setException(xtrans.translate(e)); return null; } catch (Exception e) { throw xtrans.translate(e); } return cosc.getCounter_column(); }
@Override public Column execute(Cassandra.Client cassandra) throws HectorException { ColumnOrSuperColumn cosc; try { cosc = cassandra.get(key, columnPath, getThriftCl(OperationType.READ)); } catch (NotFoundException e) { setException(xtrans.translate(e)); return null; } catch (Exception e) { throw xtrans.translate(e); } return cosc == null ? null : cosc.getColumn(); }
@Override public KeyspaceDefinition execute(Cassandra.Client cassandra) throws HectorException { try { return new ThriftKsDef(cassandra.describe_keyspace(keyspace)); } catch (org.apache.cassandra.thrift.NotFoundException nfe) { setException(xtrans.translate(nfe)); return null; } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public List<KeyspaceDefinition> execute(Cassandra.Client cassandra) throws HectorException { try { return ThriftKsDef.fromThriftList(cassandra.describe_keyspaces()); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public Map<ByteBuffer,List<ColumnOrSuperColumn>> execute(Cassandra.Client cassandra) throws HectorException { Map<ByteBuffer,List<ColumnOrSuperColumn>> cosc = new LinkedHashMap<ByteBuffer, List<ColumnOrSuperColumn>>(); try { ByteBuffer sKey = keySerializer.toByteBuffer(key); cosc.put(sKey, cassandra.get_slice(sKey, columnParent, workingSlicePredicate.toThrift(), ThriftConverter.consistencyLevel(consistencyLevelPolicy.get(operationType, columnFamily)))); } catch (Exception e) { throw exceptionsTranslator.translate(e); } return cosc; } });
@Override public Map<ByteBuffer,List<ColumnOrSuperColumn>> execute(Cassandra.Client cassandra) throws HectorException { try { List<K> keyList = new ArrayList<K>(); Iterators.addAll(keyList, keys.iterator()); return cassandra.multiget_slice(keySerializer.toBytesList(keyList), columnParent, (workingSlicePredicate == null ? activeSlicePredicate.setColumnNames(columnValueSerializers.keySet()).toThrift() : workingSlicePredicate.toThrift()), ThriftConverter.consistencyLevel(consistencyLevelPolicy.get(operationType, columnFamily))); } catch (Exception e) { throw exceptionsTranslator.translate(e); } } });