@Override public <N> Mutator<K> addCounter(K key, String cf, HCounterColumn<N> c) { getPendingMutations().addCounterInsertion(key, Arrays.asList(cf), ((HCounterColumnImpl<N>) c).toThrift()); return this; }
@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()); }
@Override public <N> Mutator<K> addCounter(K key, String cf, HCounterColumn<N> c) { getPendingMutations().addCounterInsertion(key, Arrays.asList(cf), ((HCounterColumnImpl<N>) c).toThrift()); return this; }
@Override public <N> Mutator<K> addCounter(K key, String cf, HCounterColumn<N> c) { getPendingMutations().addCounterInsertion(key, Arrays.asList(cf), ((HCounterColumnImpl<N>) c).toThrift()); return this; }
@Test public void testIsEmpty() { assertTrue(batchMutate.isEmpty()); // Insert a column Column c1 = new Column(StringSerializer.get().toByteBuffer("c_name")); c1.setValue(StringSerializer.get().toByteBuffer("c_val")); c1.setTimestamp(System.currentTimeMillis()); batchMutate.addInsertion("key1", columnFamilies, c1); assertFalse(batchMutate.isEmpty()); // Insert a Counter. CounterColumn cc1 = new CounterColumn(StringSerializer.get().toByteBuffer("c_name"), 13); batchMutate.addCounterInsertion("key1", columnFamilies, cc1); assertFalse(batchMutate.isEmpty()); }