Hi Dileep,
HashIndex is backed by a ConcurrentHashMap, and NavigableIndex is backed by a ConcurrentSkipListMap. The concurrency characteristics of those indexes is based on the concurrency of the backing maps.
If you are seeing contention on high write concurrency, you can tune the indexes to configure the concurrencyLevel on those backing maps. Especially HashIndex. By default this is 16, but you might need a higher value.
Concurrency parameters can be tuned by supplying factories to the static factory method in HashIndex (and other indexes). Then the index will ask your factories to create the backing map and Sets hold objects, whenever it needs to.
If you don't supply any custom factories, then these factories are used by default (from HashIndex):
/**
* Creates an index map using default settings.
*/
public static class DefaultIndexMapFactory<A, O> implements Factory<ConcurrentMap<A, StoredResultSet<O>>> {
@Override
public ConcurrentMap<A, StoredResultSet<O>> create() {
return new ConcurrentHashMap<A, StoredResultSet<O>>();
}
}
/**
* Creates a value set using default settings.
*/
public static class DefaultValueSetFactory<O> implements Factory<StoredResultSet<O>> {
@Override
public StoredResultSet<O> create() {
return new StoredSetBasedResultSet<O>(Collections.<O>newSetFromMap(new ConcurrentHashMap<O, Boolean>()));
}
}
So the solution is to define your own factories which use
this constructor of ConcurrentHashMap to set concurrencyLevel greater than 16.
This should improve performance with high write concurrency.
HTH,
Niall