HashIndex extends AbstractMapBasedAttributeIndex<A, O, ConcurrentMap<A, StoredResultSet<O>>> implements KeyStatisticsAttributeIndex<A, O>, OnHeapTypeIndex { public static <A, O> HashIndex<A, O> onSemiUniqueAttribute(Attribute<O, A> attribute) { return onAttribute(new DefaultIndexMapFactory<A, O>(), new CompactValueSetFactory<O>(), attribute); } protected  HashIndex(Factory<ConcurrentMap<A, StoredResultSet<O>>> indexMapFactory, Factory<StoredResultSet<O>> valueSetFactory, Attribute<O, A> attribute); @Override boolean isMutable(); @Override Index<O> getEffectiveIndex(); @Override ResultSet<O> retrieve(final Query<O> query, final QueryOptions queryOptions); @Override Integer getCountForKey(A key, QueryOptions queryOptions); @Override CloseableIterable<A> getDistinctKeys(QueryOptions queryOptions); @Override Integer getCountOfDistinctKeys(QueryOptions queryOptions); @Override CloseableIterable<KeyStatistics<A>> getStatisticsForDistinctKeys(QueryOptions queryOptions); @Override CloseableIterable<KeyValue<A, O>> getKeysAndValues(QueryOptions queryOptions); static HashIndex<A, O> onAttribute(Attribute<O, A> attribute); static HashIndex<A, O> onSemiUniqueAttribute(Attribute<O, A> attribute); static HashIndex<A, O> onAttribute(Factory<ConcurrentMap<A, StoredResultSet<O>>> indexMapFactory, Factory<StoredResultSet<O>> valueSetFactory, Attribute<O, A> attribute); static HashIndex<A, O> withQuantizerOnAttribute(final Quantizer<A> quantizer, Attribute<O, A> attribute); static HashIndex<A, O> withQuantizerOnAttribute(Factory<ConcurrentMap<A, StoredResultSet<O>>> indexMapFactory, Factory<StoredResultSet<O>> valueSetFactory, final Quantizer<A> quantizer, Attribute<O, A> attribute);  }
@Test public void testOnSemiUniqueAttribute() throws Exception{ HashIndex<Integer, Car> hashIndex = HashIndex.onSemiUniqueAttribute(Car.CAR_ID); Field valueSetFactoryField = AbstractMapBasedAttributeIndex.class.getDeclaredField("valueSetFactory"); valueSetFactoryField.setAccessible(true); Assert.assertTrue("HashIndex should be configured with CompactValueSetFactory", valueSetFactoryField.get(hashIndex) instanceof HashIndex.CompactValueSetFactory); }