@Override public void batchMutate(BatchMutation batchMutate) throws HectorException { batchMutate(batchMutate.getMutationMap()); }
@Override public void batchMutate(BatchMutation batchMutate) throws HectorException { batchMutate(batchMutate.getMutationMap()); }
@Override public Void execute(Cassandra.Client cassandra) throws Exception { cassandra.batch_mutate(mutations.getMutationMap(), ThriftConverter.consistencyLevel(consistencyLevelPolicy.get(operationType))); return null; } }));
@Test public void testAddInsertionWithHint() { BatchMutation<String> batchMutate = new BatchMutation<String>(StringSerializer.get(), new BatchSizeHint(1, 50)); Column column = new Column(StringSerializer.get().toByteBuffer("c_name")); column.setValue(StringSerializer.get().toByteBuffer("c_val")); column.setTimestamp(System.currentTimeMillis()); batchMutate.addInsertion("key1", columnFamilies, column); Map<ByteBuffer, Map<String, List<Mutation>>> mutMap = batchMutate.getMutationMap(); assertEquals(1, mutMap.size()); assertEquals(ByteBuffer.wrap("key1".getBytes()), mutMap.keySet().iterator().next()); Map<String, List<Mutation>> cfMutMap = mutMap.values().iterator().next(); assertEquals(1, cfMutMap.size()); List<Mutation> cfMutList = cfMutMap.values().iterator().next(); assertTrue(cfMutList instanceof ArrayList); }
@Test public void testAddCounterInsertion() { // Insert a Counter. CounterColumn cc1 = new CounterColumn(StringSerializer.get().toByteBuffer("c_name"), 222); batchMutate.addCounterInsertion("key1", columnFamilies, cc1); // assert there is one outter map row with 'key' as the key Map<ByteBuffer, Map<String, List<Mutation>>> mutationMap = batchMutate.getMutationMap(); assertEquals(1, mutationMap.get(StringSerializer.get().toByteBuffer("key1")).size()); // add again with a different counter and verify there is one key and two mutations underneath // for "standard1" CounterColumn cc2 = new CounterColumn(StringSerializer.get().toByteBuffer("c_name2"), 44); batchMutate.addCounterInsertion("key1", columnFamilies, cc2); assertEquals(2, mutationMap.get(StringSerializer.get().toByteBuffer("key1")).get("Standard1").size()); }
@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 testAddSuperCounterInsertion() { // Create 1 super counter. CounterSuperColumn csc1 = new CounterSuperColumn(StringSerializer.get().toByteBuffer("c_name"), Arrays.asList(new CounterColumn(StringSerializer.get().toByteBuffer("c_name"), 123))); batchMutate.addSuperCounterInsertion("key1", columnFamilies, csc1); // assert there is one outter map row with 'key' as the key assertEquals(1, batchMutate.getMutationMap().get(StringSerializer.get().toByteBuffer("key1")).size()); // add again with a different column and verify there is one key and two mutations underneath // for "standard1" CounterSuperColumn csc2 = new CounterSuperColumn(StringSerializer.get().toByteBuffer("c_name2"), Arrays.asList(new CounterColumn(StringSerializer.get().toByteBuffer("c_name"), 456))); batchMutate.addSuperCounterInsertion("key1", columnFamilies, csc2); 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()); }
@Test public void testAddSuperInsertion() { Column column = new Column(StringSerializer.get().toByteBuffer("c_name")); column.setValue(StringSerializer.get().toByteBuffer("c_val")); column.setTimestamp(System.currentTimeMillis()); SuperColumn sc = new SuperColumn(StringSerializer.get().toByteBuffer("c_name"), Arrays.asList(column)); batchMutate.addSuperInsertion("key1", columnFamilies, sc); // assert there is one outter map row with 'key' as the key assertEquals(1, batchMutate.getMutationMap().get(StringSerializer.get().toByteBuffer("key1")).size()); // add again with a different column and verify there is one key and two mutations underneath // for "standard1" column = new Column(StringSerializer.get().toByteBuffer("c_name")); column.setValue(StringSerializer.get().toByteBuffer("c_val")); column.setTimestamp(System.currentTimeMillis()); SuperColumn sc2 = new SuperColumn(StringSerializer.get().toByteBuffer("c_name2"), Arrays.asList(column)); batchMutate.addSuperInsertion("key1", columnFamilies, sc2); assertEquals(2, batchMutate.getMutationMap().get(StringSerializer.get().toByteBuffer("key1")).get("Standard1").size()); }
@Test public void testAddInsertion() { Column column = new Column(StringSerializer.get().toByteBuffer("c_name")); column.setValue(StringSerializer.get().toByteBuffer("c_val")); column.setTimestamp(System.currentTimeMillis()); batchMutate.addInsertion("key1", columnFamilies, column); // assert there is one outter map row with 'key' as the key Map<ByteBuffer, Map<String, List<Mutation>>> mutationMap = batchMutate.getMutationMap(); assertEquals(1, mutationMap.get(StringSerializer.get().toByteBuffer("key1")).size()); // add again with a different column and verify there is one key and two mutations underneath // for "standard1" Column column2 = new Column(StringSerializer.get().toByteBuffer("c_name2")); column2.setValue(StringSerializer.get().toByteBuffer("c_val2")); column2.setTimestamp(System.currentTimeMillis()); batchMutate.addInsertion("key1",columnFamilies, column2); assertEquals(2, mutationMap.get(StringSerializer.get().toByteBuffer("key1")).get("Standard1").size()); }
@Override public void batchMutate(BatchMutation batchMutate) throws HectorException { batchMutate(batchMutate.getMutationMap()); }
@Override public void batchMutate(BatchMutation batchMutate) throws HectorException { batchMutate(batchMutate.getMutationMap()); }
@Override public void batchMutate(BatchMutation batchMutate) throws HectorException { batchMutate(batchMutate.getMutationMap()); }
@Override public void batchMutate(BatchMutation batchMutate) throws HectorException { batchMutate(batchMutate.getMutationMap()); }
@Override public Void execute(Cassandra.Client cassandra) throws Exception { cassandra.batch_mutate(mutations.getMutationMap(), ThriftConverter.consistencyLevel(consistencyLevelPolicy.get(operationType))); return null; } }));
@Override public Void execute(Cassandra.Client cassandra) throws Exception { cassandra.batch_mutate(mutations.getMutationMap(), ThriftConverter.consistencyLevel(consistencyLevelPolicy.get(operationType))); return null; } }));