public static <N> CounterColumn createCounterColumn(N name, long value, Serializer<N> ns) { CounterColumn cc = new CounterColumn(); cc.setName(ns.toByteBuffer(name)); cc.setValue(value); return cc; }
throws InstantiationException, IllegalAccessException String thriftColumnName = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); String thriftColumnValue = new Long(column.getValue()).toString(); populateViaThrift(m, entity, entityType, relationNames, relations, thriftColumnName, thriftColumnValue, isCql3Enabled);
@Override public ByteBuffer getNameBytes() { return counterColumn.isSetName() ? counterColumn.name.duplicate() : null; }
@Override public ColumnListMutation<C> incrementCounterColumn(C columnName, long amount) { Preconditions.checkNotNull(columnName, "Column name cannot be null"); // 1. Set up the column with all the data CounterColumn column = new CounterColumn(); column.setName(columnSerializer.toByteBuffer(columnName)); if (column.getName().length == 0) { throw new RuntimeException("Column name cannot be empty"); } column.setValue(amount); // 2. Create a mutation and append to the mutation list. Mutation mutation = new Mutation(); mutation.setColumn_or_supercolumn(new ColumnOrSuperColumn().setCounter_column(column)); mutationList.add(mutation); return this; }
public HCounterColumnImpl(Serializer<N> nameSerializer) { notNull(nameSerializer, "nameSerializer is null"); this.nameSerializer = nameSerializer; this.counterColumn = new CounterColumn(); }
@Override public HCounterColumn<N> setName(N name) { notNull(name, "name is null"); this.counterColumn.setName(nameSerializer.toByteBuffer(name)); return this; }
private static long getCounterColumnSize(CounterColumn counterColumn) { if (counterColumn == null) { return getNullSize(); } return getByteArraySize(counterColumn.getName()) + getCounterValueSize(); }
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.name = iprot.readBinary(); struct.setNameIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.value = iprot.readI64(); struct.setValueIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); if (!struct.isSetValue()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'value' was not found in serialized data! Struct: " + toString()); struct.validate();
/** * Clear value, timestamp and ttl (the latter two set to '0') leaving only the column name */ @Override public HCounterColumn<N> clear() { counterColumn.value = 0; // TODO (patricioe) Is this ok? //counterColumn.ttl = 0; TODO (patricioe) pending on trunk //counterColumn.setTtlIsSet(false); counterColumn.setValueIsSet(false); return this; }
@Override public HCounterColumn<N> setValue(Long value) { notNull(value, "value is null"); this.counterColumn.setValue(value); return this; }
@Override public long getLongValue() { return this.column.getValue(); }
public void validate() throws org.apache.thrift.TException { // check for required fields if (name == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'name' was not present! Struct: " + toString()); } // alas, we cannot check 'value' because it's a primitive and you chose the non-beans generator. // check for sub-struct validity }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, CounterColumn struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.name = iprot.readBinary(); struct.setNameIsSet(true); struct.value = iprot.readI64(); struct.setValueIsSet(true); } }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case NAME: return isSetName(); case VALUE: return isSetValue(); } throw new IllegalStateException(); }
@Override public ColumnListMutation<C> incrementCounterColumn(C columnName, long amount) { Preconditions.checkNotNull(columnName, "Column name cannot be null"); // 1. Set up the column with all the data CounterColumn column = new CounterColumn(); column.setName(columnSerializer.toByteBuffer(columnName)); if (column.getName().length == 0) { throw new RuntimeException("Column name cannot be empty"); } column.setValue(amount); // 2. Create a mutation and append to the mutation list. Mutation mutation = new Mutation(); mutation.setColumn_or_supercolumn(new ColumnOrSuperColumn().setCounter_column(column)); mutationList.add(mutation); return this; }
public HCounterColumnImpl(N name, Long value, Serializer<N> nameSerializer) { this(nameSerializer); notNull(name, "name is null"); notNull(value, "value is null"); this.counterColumn = new CounterColumn(nameSerializer.toByteBuffer(name), value); }
public CounterColumn setName(byte[] name) { setName(name == null ? (ByteBuffer)null : ByteBuffer.wrap(name)); return this; }
@Override public ByteBuffer getRawName() { return ByteBuffer.wrap(column.getName()); }
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.name = iprot.readBinary(); struct.setNameIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.value = iprot.readI64(); struct.setValueIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); if (!struct.isSetValue()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'value' was not found in serialized data! Struct: " + toString()); struct.validate();
public CounterColumn setValue(long value) { this.value = value; setValueIsSet(true); return this; }