Best way to delete a subcolumn of a supercolumn family

160 views Asked by At

I am trying to delete a sub-column of a super column family. I tried the following code but it won't work when the super column family has many super columns, it only returns partial super columns.

SuperCfResult<UUID, Long, UUID> superCfResult = sTemplate.querySuperColumns(key);
Collection<Long> supercolumns = superCfResult.getSuperColumns();

Another approach would be to build a SuperSliceQuery with the range that would return all the super columns, and then loop thru to find the one that has match and delete it. It works but it definitely overkill and has performance cost.

Is there a better solution for the purpose?

1

There are 1 answers

0
rs_atl On BEST ANSWER
Mutator mutator = HFactory.createMutator(keyspace, key_serializer);
mutator.addSubDelete(key, column_family, supercol, subcol, super_serializer, sub_serializer);
mutator.execute();