org.apache.cassandra.thrift.CounterColumn Java Examples
The following examples show how to use
org.apache.cassandra.thrift.CounterColumn.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ThriftCounterAdder.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public void run(final ThriftClient client) throws IOException { List<CounterColumn> columns = new ArrayList<>(); for (ByteBuffer name : select().select(settings.columns.names)) columns.add(new CounterColumn(name, counteradd.next())); List<Mutation> mutations = new ArrayList<>(columns.size()); for (CounterColumn c : columns) { ColumnOrSuperColumn cosc = new ColumnOrSuperColumn().setCounter_column(c); mutations.add(new Mutation().setColumn_or_supercolumn(cosc)); } Map<String, List<Mutation>> row = Collections.singletonMap(type.table, mutations); final ByteBuffer key = getKey(); final Map<ByteBuffer, Map<String, List<Mutation>>> record = Collections.singletonMap(key, row); timeWithRetry(new RunOp() { @Override public boolean run() throws Exception { client.batch_mutate(record, settings.command.consistencyLevel); return true; } @Override public int partitionCount() { return 1; } @Override public int rowCount() { return 1; } }); }
Example #2
Source File: ColumnFamilyWideRowRecordReader.java From Hive-Cassandra with Apache License 2.0 | 5 votes |
private IColumn unthriftifySuperCounter(CounterSuperColumn superColumn) { org.apache.cassandra.db.SuperColumn sc = new org.apache.cassandra.db.SuperColumn( superColumn.name, subComparator); for (CounterColumn column : superColumn.columns) { sc.addColumn(unthriftifyCounter(column)); } return sc; }
Example #3
Source File: ColumnFamilyWideRowRecordReader.java From Hive-Cassandra with Apache License 2.0 | 4 votes |
private IColumn unthriftifyCounter(CounterColumn column) { // CounterColumns read the nodeID from the System table, so need the StorageService running // and access // to cassandra.yaml. To avoid a Hadoop needing access to yaml return a regular Column. return new org.apache.cassandra.db.Column(column.name, ByteBufferUtil.bytes(column.value), 0); }