private static long getCounterColumnSize(CounterColumn counterColumn) { if (counterColumn == null) { return getNullSize(); } return getByteArraySize(counterColumn.getName()) + getCounterValueSize(); }
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,
String thriftColumnName = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); String thriftColumnValue = new Long(column.getValue()).toString(); PropertyAccessorHelper.set(embeddedObject, superColumnFieldMap.get(thriftColumnName), thriftColumnValue);
@Override public ByteBuffer getRawName() { return ByteBuffer.wrap(column.getName()); }
@Override public ByteBuffer getRawName() { return ByteBuffer.wrap(column.getName()); }
public Object getFieldValue(_Fields field) { switch (field) { case NAME: return getName(); case VALUE: return Long.valueOf(getValue()); } throw new IllegalStateException(); }
public Object getFieldValue(_Fields field) { switch (field) { case NAME: return getName(); case VALUE: return Long.valueOf(getValue()); } throw new IllegalStateException(); }
private void constructMap() { if (lookup == null) { lookup = Maps.newHashMap(); for (org.apache.cassandra.thrift.CounterColumn column : columns) { lookup.put(colSer.fromBytes(column.getName()), column); } } } }
public Object getFieldValue(_Fields field) { switch (field) { case NAME: return getName(); case VALUE: return Long.valueOf(getValue()); } throw new IllegalStateException(); }
private void constructMap() { if (lookup == null) { lookup = Maps.newHashMap(); for (CounterColumn column : columns) { lookup.put(colSer.fromBytes(column.getName()), column); } } } }
@Override public Column<C> getColumnByIndex(int idx) { CounterColumn c = columns.get(idx); return new ThriftCounterColumnImpl<C>(colSer.fromBytes(c.getName()), c); }
@Override public Column<C> getColumnByIndex(int idx) { org.apache.cassandra.thrift.CounterColumn c = columns.get(idx); return new ThriftCounterColumnImpl<C>(colSer.fromBytes(c.getName()), c); }
@Override public Column<C> getColumnByName(C columnName) { constructMap(); CounterColumn c = lookup.get(columnName); if (c == null) { return null; } return new ThriftCounterColumnImpl<C>(colSer.fromBytes(c.getName()), c); }
@Override public Column<C> getColumnByName(C columnName) { constructMap(); org.apache.cassandra.thrift.CounterColumn c = lookup.get(columnName); if (c == null) { return null; } return new ThriftCounterColumnImpl<C>(colSer.fromBytes(c.getName()), c); }
private static long getCounterColumnSize(CounterColumn counterColumn) { if (counterColumn == null) { return getNullSize(); } return getByteArraySize(counterColumn.getName()) + getCounterValueSize(); }
@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; }
@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; }
private void constructMap() { if (lookup == null) { lookup = Maps.newHashMap(); for (ColumnOrSuperColumn column : columns) { if (column.isSetSuper_column()) { lookup.put(colSer.fromBytes(column.getSuper_column().getName()), column); } else if (column.isSetColumn()) { lookup.put(colSer.fromBytes(column.getColumn().getName()), column); } else if (column.isSetCounter_column()) { lookup.put(colSer.fromBytes(column.getCounter_column().getName()), column); } else if (column.isSetCounter_super_column()) { lookup.put(colSer.fromBytes(column.getCounter_super_column().getName()), column); } else { throw new UnsupportedOperationException("Unknown column type"); } } } }
@Override public Column<C> getColumnByIndex(int idx) { ColumnOrSuperColumn column = columns.get(idx); if (column == null) { // TODO: throw an exception return null; } else if (column.isSetColumn()) { return new ThriftColumnImpl<C>(this.colSer.fromBytes(column.getColumn().getName()), column.getColumn()); } else if (column.isSetCounter_column()) { return new ThriftCounterColumnImpl<C>(this.colSer.fromBytes(column.getCounter_column().getName()), column.getCounter_column()); } throw new UnsupportedOperationException("SuperColumn " + idx + " has no value"); }
@Override public Column<C> getColumnByIndex(int idx) { ColumnOrSuperColumn column = columns.get(idx); if (column == null) { // TODO: throw an exception return null; } else if (column.isSetColumn()) { return new ThriftColumnImpl<C>(this.colSer.fromBytes(column.getColumn().getName()), column.getColumn()); } else if (column.isSetCounter_column()) { return new ThriftCounterColumnImpl<C>(this.colSer.fromBytes(column.getCounter_column().getName()), column.getCounter_column()); } throw new UnsupportedOperationException("SuperColumn " + idx + " has no value"); }