LocalDuplicateIndex extends LocalMapIndex<UniqueKey<T>, T> { @Override public void remove( String nodeKey, String propertyName, T value ) { for (UniqueKey<T> key : Fun.filter(valuesByKey, nodeKey)) { if (key.actualKey.equals(value)) { logger.trace("Removing node '{0}' from '{1}' index with value '{2}'", nodeKey, name, key.actualKey); keysByValue.remove(key); } } } protected  LocalDuplicateIndex( String name,
                                   String workspaceName,
                                   DB db,
                                   Converter<T> converter,
                                   Serializer<T> valueSerializer,
                                   Comparator<T> comparator ); @Override void add( String nodeKey,
                     String propertyName, 
                     T value ); @Override void remove( String nodeKey,
                        String propertyName, 
                        T value ); @Override void remove( String nodeKey );  }
@Test public void shouldAllowRemovingAllValuesForKey() { LocalDuplicateIndex<Long> index = duplicateValueIndex(Long.class); loadLongIndexWithNoDuplicates(index, 10); assertThat(index.estimateTotalCount(), is(10L)); assertThat(index.estimateTotalCount(), is(10L)); assertMatch(index, Operator.EQUAL_TO, 20L, key(2)); index.remove(key(2)); assertNoMatch(index, Operator.EQUAL_TO, 20L); assertThat(index.estimateTotalCount(), is(9L)); assertNoMatch(index, Operator.EQUAL_TO, 200L); index.remove(key(20)); assertNoMatch(index, Operator.EQUAL_TO, 200L); assertThat(index.estimateTotalCount(), is(9L)); index.remove(key(3), null, 30L); assertNoMatch(index, Operator.EQUAL_TO, 30L); assertThat(index.estimateTotalCount(), is(8L)); index.remove(key(3), null, 3000L); assertNoMatch(index, Operator.EQUAL_TO, 30L); assertThat(index.estimateTotalCount(), is(8L)); }