/** * Get a copy of the set of values for a given binary index * * @param name the name of the index * @return a copy of the values (or the empty set if index is not present) */ public Set<String> getBinIndex(String name) { Set<String> values = binIndexes.get(BinIndex.named(name)); if (values == null) { return new HashSet<String>(); } return new HashSet<String>(values); }
/** * Add a new {@link BinIndex} value to the set * * @param index the index name * @param value the value * @return this */ public RiakIndexes add(String index, String value) { final BinIndex key = BinIndex.named(index); final String lock = key.getFullname().intern(); // even though it is a concurrent hashmap, we need // fine grained access control for the // key's value set synchronized (lock) { Set<String> values = binIndexes.get(key); if (values == null) { values = new HashSet<String>(); } values.add(value); binIndexes.put(key, values); } return this; }