d.setPredicate(sp); d.setTimestamp(commitTime.getDeletionTime(times)); org.apache.cassandra.thrift.Mutation m = new org.apache.cassandra.thrift.Mutation(); m.setDeletion(d); thriftMutation.add(m); org.apache.cassandra.thrift.Mutation m = new org.apache.cassandra.thrift.Mutation(); m.setColumn_or_supercolumn(cosc); thriftMutation.add(m);
/** * Add a deletion request to the batch mutation. */ public BatchMutation<K> addDeletion(K key, List<String> columnFamilies, Deletion deletion) { Mutation mutation = new Mutation(); mutation.setDeletion(deletion); addMutation(key, columnFamilies, mutation); return this; }
/** * Add a SuperColumnCounter insertion (or update) */ public BatchMutation<K> addSuperCounterInsertion(K key, List<String> columnFamilies, CounterSuperColumn counterSuperColumn) { Mutation mutation = new Mutation(); mutation.setColumn_or_supercolumn(new ColumnOrSuperColumn().setCounter_super_column(counterSuperColumn)); addMutation(key, columnFamilies, mutation); return this; }
/** * Add a ColumnCounter insertion (or update) */ public BatchMutation<K> addCounterInsertion(K key, List<String> columnFamilies, CounterColumn counterColumn) { Mutation mutation = new Mutation(); mutation.setColumn_or_supercolumn(new ColumnOrSuperColumn().setCounter_column(counterColumn)); addMutation(key, columnFamilies, mutation); return this; }
/** * Add a SuperColumn insertion (or update) to the batch mutation request. */ public BatchMutation<K> addSuperInsertion(K key, List<String> columnFamilies, SuperColumn superColumn) { Mutation mutation = new Mutation(); mutation.setColumn_or_supercolumn(new ColumnOrSuperColumn().setSuper_column(superColumn)); addMutation(key, columnFamilies, mutation); return this; }
/** * Add an Column insertion (or update) to the batch mutation request. */ public BatchMutation<K> addInsertion(K key, List<String> columnFamilies, Column column) { Mutation mutation = new Mutation(); mutation.setColumn_or_supercolumn(new ColumnOrSuperColumn().setColumn(column)); addMutation(key, columnFamilies, mutation); return this; }
@Test public void getSizeForBatchMutate() { Map<ByteBuffer, Map<String, List<Mutation>>> batchMutateMap = ImmutableMap.of( TEST_NAME_BYTES, ImmutableMap.of( TEST_NAME, ImmutableList.of(new Mutation().setColumn_or_supercolumn(EMPTY_COLUMN_OR_SUPERCOLUMN)))); long expectedSize = TEST_NAME_BYTES_SIZE + TEST_NAME_SIZE + NULL_SIZE + EMPTY_COLUMN_OR_SUPERCOLUMN_SIZE; assertThat(ThriftObjectSizeUtils.getApproximateSizeOfMutationMap(batchMutateMap)).isEqualTo(expectedSize); }
@Test public void getSizeForEmptyMutation() { assertThat(ThriftObjectSizeUtils.getMutationSize(new Mutation())).isEqualTo(NULL_SIZE * 2); }
del.setPredicate(pred); del.setTimestamp(deleteTimestampGetter.applyAsLong(ts)); Mutation mutation = new Mutation(); mutation.setDeletion(del);
@Test public void getSizeOfMutationPerTableOnBatchMutate() { Map<ByteBuffer, Map<String, List<Mutation>>> batchMutateMap = ImmutableMap.of( TEST_NAME_BYTES, ImmutableMap.of( TEST_NAME, ImmutableList.of(new Mutation().setColumn_or_supercolumn(EMPTY_COLUMN_OR_SUPERCOLUMN)))); long expectedSize = EMPTY_COLUMN_OR_SUPERCOLUMN_SIZE + NULL_SIZE + TEST_NAME_BYTES_SIZE; assertThat(ThriftObjectSizeUtils.getSizeOfMutationPerTable(batchMutateMap)) .isEqualTo(ImmutableMap.of(TEST_NAME, expectedSize)); }
@Test public void getSizeForMutationWithColumnOrSuperColumn() { assertThat(ThriftObjectSizeUtils.getMutationSize(new Mutation() .setColumn_or_supercolumn(EMPTY_COLUMN_OR_SUPERCOLUMN))) .isEqualTo(NULL_SIZE + EMPTY_COLUMN_OR_SUPERCOLUMN_SIZE); }
public static Mutation rangeTombstoneForColumn( byte[] columnName, long maxAtlasTimestampExclusive, long timestampForRangeTombstone) { Deletion deletion = new Deletion() .setTimestamp(timestampForRangeTombstone) .setPredicate(SlicePredicates.rangeTombstoneForColumn(columnName, maxAtlasTimestampExclusive)); return new Mutation().setDeletion(deletion); }
public static Mutation rangeTombstoneIncludingSentinelForColumn( byte[] columnName, long maxAtlasTimestampExclusive, long timestampForRangeTombstone) { Deletion deletion = new Deletion() .setTimestamp(timestampForRangeTombstone) .setPredicate(SlicePredicates .rangeTombstoneIncludingSentinelForColumn(columnName, maxAtlasTimestampExclusive)); return new Mutation().setDeletion(deletion); }
@Test public void getSizeForMutationWithDeletionContainingSuperColumn() { long nonEmptyDeletionSize = Long.BYTES + TEST_NAME.getBytes().length + NULL_SIZE; assertThat(ThriftObjectSizeUtils.getMutationSize(new Mutation() .setDeletion(new Deletion().setSuper_column(TEST_NAME.getBytes())))) .isEqualTo(NULL_SIZE + nonEmptyDeletionSize); }
@Test public void getSizeForMutationWithEmptyDeletion() { long emptyDeletionSize = Long.BYTES + 2 * NULL_SIZE; assertThat(ThriftObjectSizeUtils.getMutationSize(new Mutation() .setDeletion(new Deletion()))) .isEqualTo(NULL_SIZE + emptyDeletionSize); }
@Test public void getSizeForMutationWithDeletionContainingNonEmptySlicePredicate() { long deletionSize = (Long.BYTES) + NULL_SIZE + (TEST_NAME.getBytes().length + NULL_SIZE); assertThat(ThriftObjectSizeUtils .getMutationSize(new Mutation() .setDeletion(new Deletion() .setPredicate(new SlicePredicate() .setColumn_names(ImmutableList.of(ByteBuffer.wrap(TEST_NAME.getBytes()))))))) .isEqualTo(NULL_SIZE + deletionSize); }
@Test public void getSizeForMutationWithColumnOrSuperColumnAndDeletion() { long emptyDeletionSize = Long.BYTES + 2 * NULL_SIZE; assertThat(ThriftObjectSizeUtils.getMutationSize(new Mutation() .setColumn_or_supercolumn(EMPTY_COLUMN_OR_SUPERCOLUMN) .setDeletion(new Deletion()))) .isEqualTo(EMPTY_COLUMN_OR_SUPERCOLUMN_SIZE + emptyDeletionSize); }
Mutation mutation = new Mutation(); mutation.setColumn_or_supercolumn(colOrSup);
private MutationMap convertToMutations(List<TableCellAndValue> batch, long timestamp) { MutationMap mutationMap = new MutationMap(); for (TableCellAndValue tableCellAndValue : batch) { Cell cell = tableCellAndValue.cell; Column col = CassandraKeyValueServices.createColumn( cell, Value.create(tableCellAndValue.value, timestamp)); ColumnOrSuperColumn colOrSup = new ColumnOrSuperColumn(); colOrSup.setColumn(col); Mutation mutation = new Mutation(); mutation.setColumn_or_supercolumn(colOrSup); mutationMap.addMutationForCell(cell, tableCellAndValue.tableRef, mutation); } return mutationMap; }
@Test public void getSizeForMutationWithDeletionContainingEmptySlicePredicate() { long deletionSize = Long.BYTES + NULL_SIZE + NULL_SIZE * 2; assertThat(ThriftObjectSizeUtils.getMutationSize(new Mutation() .setDeletion(new Deletion().setPredicate(new SlicePredicate())))) .isEqualTo(NULL_SIZE + deletionSize); }