/** * Add a new {@link IntIndex} value to the set * * @param name name of the index * @param value the value * @return this */ public RiakIndexes add(String index, int value) { final IntIndex key = IntIndex.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<Integer> values = intIndexes.get(key); if (values == null) { values = new HashSet<Integer>(); } values.add(value); intIndexes.put(key, values); } return this; }
/** * Get a copy of the set of values for a given int 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<Integer> getIntIndex(String name) { Set<Integer> values = intIndexes.get(IntIndex.named(name)); if (values == null) { return new HashSet<Integer>(); } return new HashSet<Integer>(values); }