final NamedCache cache = CacheFactory.getCache("objects");
// final Map map = cache;
// final Map map = new ContinuousQueryCache(cache, new ClassFilter(DomainObject.class), true);
// final Map map = new ConcurrentHashMap();
// final Map map = new HashMap();
final Map map = new ConcurrentSkipListMap();
// final Map map = Collections.synchronizedMap(new HashMap());
final ObjectGenerator<?, ?> generator = new SimpleDomainObjGenerator();
// cache.addIndex(new ReflectionExtractor("getA0"), false, null);
// cache.addIndex(new ReflectionExtractor("getAs"), false, null);
// long objectCount = 1000000;
long objectCount = 100000;
long rangeStart = 0;
long rangeFinish = objectCount;
println("Loading " + objectCount + " objects ...");
for(long i = rangeStart; i < rangeFinish; i += 100) {
if (i % 100000 == 0) {
println("Done " + (i - rangeStart));
}
long j = Math.min(rangeFinish, i + 100);
map.putAll(generator.generate(i, j));
}
println("Loaded " + cache.size() + " objects");
System.gc();
println("Mem. usage " + ManagementFactory.getMemoryMXBean().getHeapMemoryUsage());
// checkAccess(cache, new EqualsFilter("getA0", new DomainObjAttrib("?")));
// checkAccess(cache, new EqualsFilter("getAs", Collections.EMPTY_LIST));
// checkAccess(cache, new ContainsAnyFilter("getAs", Collections.singleton(new DomainObjAttrib("?"))));
// ContinuousQueryCache view = new ContinuousQueryCache(cache, new EqualsFilter("getHashSegment", 0));
// System.out.println("View size " + view.size());
// view.addIndex(new ReflectionExtractor("getA0"), false, null);
// checkAccess(view, new EqualsFilter("getA0", new DomainObjAttrib("?")));
// checkAccess(view, new EqualsFilter("getA1", new DomainObjAttrib("?")));
if (map instanceof NearCache) {
println("Warming up near cache");
for(long i = rangeFinish-1; i >= rangeStart; --i) {
map.get(new DomainObjKey(i));
}
}
println("Starting access threads");