Deletion d = new Deletion(); SlicePredicate sp = new SlicePredicate(); sp.addToColumn_names(buf.as(StaticBuffer.BB_FACTORY));
@Override public <N> Mutator<K> addCounterDeletion(K key, String cf) { getPendingMutations().addDeletion(key, Arrays.asList(cf), new Deletion()); return this; }
@Override public <N> Mutator<K> addCounterDeletion(K key, String cf, N counterColumnName, Serializer<N> nameSerializer) { Deletion d; if ( counterColumnName != null ) { SlicePredicate sp = new SlicePredicate(); sp.addToColumn_names(nameSerializer.toByteBuffer(counterColumnName)); d = new Deletion().setPredicate(sp); } else { d = new Deletion(); } getPendingMutations().addDeletion(key, Arrays.asList(cf), d); return this; }
/** * {@inheritDoc} */ @Override public <N> Mutator<K> addDeletion(K key, String cf, N columnName, Serializer<N> nameSerializer, long clock) { Deletion d; if ( columnName != null ) { SlicePredicate sp = new SlicePredicate(); sp.addToColumn_names(nameSerializer.toByteBuffer(columnName)); d = new Deletion().setTimestamp(clock).setPredicate(sp); } else { d = new Deletion().setTimestamp(clock); } getPendingMutations().addDeletion(key, Arrays.asList(cf), d); return this; }
@Override public <SN> Mutator<K> addSuperDelete(K key, String cf, SN sColumnName, Serializer<SN> sNameSerializer) { Deletion d = new Deletion().setTimestamp(keyspace.createClock()); d.setSuper_column(sNameSerializer.toByteBuffer(sColumnName)); getPendingMutations().addDeletion(key, Arrays.asList(cf), d); return this; }
SlicePredicate pred = new SlicePredicate(); pred.setColumn_names(Collections.singletonList(colName)); Deletion del = new Deletion(); del.setPredicate(pred); del.setTimestamp(deleteTimestampGetter.applyAsLong(ts));
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); }
@Override public <SN, N> Mutator<K> addSubDelete(K key, String cf, SN sColumnName, N columnName, Serializer<SN> sNameSerializer, Serializer<N> nameSerializer, long clock) { Deletion d = new Deletion().setTimestamp(clock); SlicePredicate predicate = new SlicePredicate(); predicate.addToColumn_names(nameSerializer.toByteBuffer(columnName)); d.setPredicate(predicate); d.setSuper_column(sNameSerializer.toByteBuffer(sColumnName)); getPendingMutations().addDeletion(key, Arrays.asList(cf), d); return this; }
/** * {@inheritDoc} */ @Override public <N> Mutator<K> addDeletion(K key, String cf, N columnNameStart, N columnNameFinish, Serializer<N> nameSerializer, long clock) { SlicePredicate sp = new SlicePredicate(); sp.setSlice_range(new SliceRange(nameSerializer.toByteBuffer(columnNameStart), nameSerializer.toByteBuffer(columnNameFinish), false, Integer.MAX_VALUE)); Deletion d = new Deletion().setTimestamp(clock).setPredicate(sp); getPendingMutations().addDeletion(key, Arrays.asList(cf), d); return this; }
@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); }
@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); }
@Override public <SN, N> Mutator<K> addCounterSubDeletion(K key, String cf, HCounterSuperColumn<SN, N> sc) { Deletion d = new Deletion(); if ( sc.getColumns() != null ) { SlicePredicate pred = new SlicePredicate(); for (HCounterColumn<N> col : sc.getColumns()) { pred.addToColumn_names(col.getNameSerializer().toByteBuffer(col.getName())); } d.setPredicate(pred); } d.setSuper_column(sc.getNameByteBuffer()); getPendingMutations().addDeletion(key, Arrays.asList(cf), d); return this; }
public <SN,N,V> Mutator<K> addSubDelete(K key, String cf, HSuperColumn<SN,N,V> sc, long clock) { Deletion d = new Deletion().setTimestamp(clock); if ( sc.getColumns() != null ) { SlicePredicate pred = new SlicePredicate(); for (HColumn<N, V> col : sc.getColumns()) { pred.addToColumn_names(col.getNameSerializer().toByteBuffer(col.getName())); } d.setPredicate(pred); } d.setSuper_column(sc.getNameByteBuffer()); getPendingMutations().addDeletion(key, Arrays.asList(cf), d); return this; }
@Test public void testAddDeletion() { Deletion deletion = new Deletion().setTimestamp(System.currentTimeMillis()); SlicePredicate slicePredicate = new SlicePredicate(); slicePredicate.addToColumn_names(StringSerializer.get().toByteBuffer("c_name")); deletion.setPredicate(slicePredicate); batchMutate.addDeletion("key1", columnFamilies, deletion); assertEquals(1,batchMutate.getMutationMap().get(StringSerializer.get().toByteBuffer("key1")).size()); deletion = new Deletion().setTimestamp(System.currentTimeMillis()); slicePredicate = new SlicePredicate(); slicePredicate.addToColumn_names(StringSerializer.get().toByteBuffer("c_name2")); deletion.setPredicate(slicePredicate); batchMutate.addDeletion("key1", columnFamilies, deletion); assertEquals(2,batchMutate.getMutationMap().get(StringSerializer.get().toByteBuffer("key1")).get("Standard1").size()); }
@Test public void testAddCounterDeletion() { Deletion counterDeletion = new Deletion(); SlicePredicate slicePredicate = new SlicePredicate(); slicePredicate.addToColumn_names(StringSerializer.get().toByteBuffer("c_name")); counterDeletion.setPredicate(slicePredicate); batchMutate.addDeletion("key1", columnFamilies, counterDeletion); assertEquals(1, batchMutate.getMutationMap().get(StringSerializer.get().toByteBuffer("key1")).size()); counterDeletion = new Deletion(); slicePredicate = new SlicePredicate(); slicePredicate.addToColumn_names(StringSerializer.get().toByteBuffer("c_name2")); counterDeletion.setPredicate(slicePredicate); batchMutate.addDeletion("key1", columnFamilies, counterDeletion); assertEquals(2,batchMutate.getMutationMap().get(StringSerializer.get().toByteBuffer("key1")).get("Standard1").size()); }
slicePredicate.addToColumn_names(StringSerializer.get().toByteBuffer("deleteThroughInserBatch_col")); Deletion deletion = new Deletion().setTimestamp(connectionManager.createClock()); deletion.setPredicate(slicePredicate);