ColumnFamilyRowCopy { public void copy() throws HectorException { if (this.cf == null) { throw new HectorException("Unable to clone row with null column family"); } if (this.rowKey == null) { throw new HectorException("Unable to clone row with null row key"); } if (this.destinationKey == null) { throw new HectorException("Unable to clone row with null clone key"); } ColumnFamilyTemplate<K, ByteBuffer> template = new ThriftColumnFamilyTemplate<K, ByteBuffer>(this.keyspace, this.cf, this.keySerializer, this.bs); Mutator<K> mutator = HFactory.createMutator(this.keyspace, this.keySerializer, new BatchSizeHint(1, this.mutateInterval)); ColumnFamilyUpdater<K, ByteBuffer> updater = template.createUpdater(this.destinationKey, mutator); SliceQuery<K, ByteBuffer, ByteBuffer> query = HFactory.createSliceQuery(this.keyspace, this.keySerializer, this.bs, this.bs). setColumnFamily(this.cf). setKey(this.rowKey); ColumnSliceIterator<K, ByteBuffer, ByteBuffer> iterator = new ColumnSliceIterator<K, ByteBuffer, ByteBuffer>(query, this.bs.fromBytes(new byte[0]), this.bs.fromBytes(new byte[0]), false); while (iterator.hasNext()) { HColumn<ByteBuffer, ByteBuffer> column = iterator.next(); updater.setValue(column.getName(), column.getValue(), this.bs); } template.update(updater); } ColumnFamilyRowCopy(Keyspace keyspace, Serializer<K> keySerializer); ColumnFamilyRowCopy setColumnFamily(String cf); ColumnFamilyRowCopy setRowKey(K rowKey); ColumnFamilyRowCopy setDestinationKey(K destinationKey); ColumnFamilyRowCopy setMutateInterval(int interval); void copy();  }
@Test public void testCopy() { new ColumnFamilyRowCopy<String, UUID>(keyspace, ss).setColumnFamily(CF). setRowKey(SOURCE_KEY). setDestinationKey(DESTINATION_KEY). setMutateInterval(150).copy(); SliceQuery<String, ByteBuffer, String> query = HFactory.createSliceQuery(keyspace, ss, bs, ss). setKey(DESTINATION_KEY).setColumnFamily(CF); ColumnSliceIterator<String, ByteBuffer, String> it = new ColumnSliceIterator<String, ByteBuffer, String>(query, bs. fromBytes(new byte[0]), bs.fromBytes(new byte[0]), false, 100); int total = 0; while (it.hasNext()) { it.next(); total++; } assertEquals(columns, total); }