Source:
<code>public void save(Iterable<? extends T> items) { checkNotNull(items); Value value = new Value(); Text forwardCF = new Text(); Text forwardCQ = new Text(); Text invertedCF = new Text(); Text invertedCQ = new Text(); try { for (T item : items) { if (item.size() > 0) { List<Key> docKeys = new ArrayList<Key>(); List<Value> docValues = new ArrayList<Value>(); String id = buildId(item); String shardId = shardBuilder.buildShard(item); Mutation shardMutation = new Mutation(shardId); for (Tuple tuple : item.getTuples()) { String visibility = getVisibility(tuple.getMetadata(), ""); String aliasValue = typeRegistry.getAlias(tuple.getValue()) + ONE_BYTE + typeRegistry.encode(tuple.getValue()); ColumnVisibility columnVisibility = new ColumnVisibility(visibility); Map<String,Object> meta = tuple.getMetadata(); value.set(metadataSerDe.serialize(meta)); forwardCF.set(id); forwardCQ.set(tuple.getKey() + NULL_BYTE + aliasValue); invertedCF.set(PREFIX_FI + NULL_BYTE + tuple.getKey()); invertedCQ.set(aliasValue + NULL_BYTE + id); docKeys.add(new Key(new Text(shardId), forwardCF, forwardCQ, columnVisibility, 0)); docValues.add(new Value(value)); shardMutation.put(invertedCF, invertedCQ, columnVisibility, value); } Value row = encodeRow(docKeys, docValues); <START> shardMutation.put(new Text(id), new Text(), row); <END> shardWriter.addMutation(shardMutation); } } keyValueIndex.indexKeyValues(items); } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new RuntimeException(e); } }</code><technical_language>a visibility dangerous, a simple scan access data in table. A potential solution combine visibilities "|" operator. This leak information visibilities for data user however. Another option write rows for visibilities in row. this require some preprocessing evaluation however, Im complicated be</technical_language>

Target:
public void save(Iterable<? extends T> items) { checkNotNull(items); Value value = new Value(); Text forwardCF = new Text(); Text forwardCQ = new Text(); Text invertedCF = new Text(); Text invertedCQ = new Text(); try { for (T item : items) { if (item.size() > 0) { String id = buildId(item); String shardId = shardBuilder.buildShard(item); Multimap<ColumnVisibility,Map.Entry<Key,Value>> visToKeyCache = ArrayListMultimap.create(); Mutation shardMutation = new Mutation(shardId); for (Tuple tuple : item.getTuples()) { String visibility = getVisibility(tuple.getMetadata(), ""); String aliasValue = typeRegistry.getAlias(tuple.getValue()) + ONE_BYTE + typeRegistry.encode(tuple.getValue()); ColumnVisibility columnVisibility = new ColumnVisibility(visibility); Map<String,Object> meta = tuple.getMetadata(); value.set(metadataSerDe.serialize(meta)); forwardCF.set(id); forwardCQ.set(tuple.getKey() + NULL_BYTE + aliasValue); invertedCF.set(PREFIX_FI + NULL_BYTE + tuple.getKey()); invertedCQ.set(aliasValue + NULL_BYTE + id); Key key = new Key(new Text(shardId), forwardCF, forwardCQ, columnVisibility, 0); Value valuePart = new Value(value); visToKeyCache.put(columnVisibility, Maps.immutableEntry(key, valuePart)); shardMutation.put(invertedCF, invertedCQ, columnVisibility, value); } for(ColumnVisibility colVis : visToKeyCache.keySet()) { Value row = encodeRow(visToKeyCache.get(colVis)); shardMutation.put(new Text(id), new Text(), colVis, row); } shardWriter.addMutation(shardMutation); } } keyValueIndex.indexKeyValues(items); } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new RuntimeException(e); } }