use of com.googlecode.cqengine.ConcurrentIndexedCollection in project invesdwin-context-persistence by subes.
the class CqenginePerformanceTest method testCqenginePerformance.
@Test
public void testCqenginePerformance() throws InterruptedException, IOException {
final File folder = new File(ContextProperties.getCacheDirectory(), CqenginePerformanceTest.class.getSimpleName());
final File file = new File(folder, "table.db");
Files.deleteNative(folder);
Files.forceMkdir(folder);
final DiskPersistence<Content, Long> persistence = DiskPersistence.onPrimaryKeyInFile(Content.KEY, file);
// final OffHeapPersistence<Content, Long> persistence = OffHeapPersistence.onPrimaryKey(Content.KEY);
// final OnHeapPersistence<Content, Long> persistence = OnHeapPersistence.onPrimaryKey(Content.KEY);
final IndexedCollection<Content> table = new ConcurrentIndexedCollection<Content>(persistence);
final NavigableIndex<Long, Content> navigableIndex = NavigableIndex.onAttribute(Content.KEY);
// NavigableIndex<Long, Content> navigableIndex = NavigableIndex.withQuantizerOnAttribute(LongQuantizer.withCompressionFactor(5), KeyValue.KEY);
table.addIndex(navigableIndex);
table.addIndex(UniqueIndex.onAttribute(Content.KEY));
final Instant writesStart = new Instant();
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck();
int i = 0;
final List<Content> flushable = new ArrayList<>();
for (final FDate date : newValues()) {
flushable.add(new Content(date.millisValue(), date));
i++;
if (i % FLUSH_INTERVAL == 0) {
table.addAll(flushable);
flushable.clear();
if (loopCheck.check()) {
printProgress("Writes", writesStart, i, VALUES);
}
}
}
if (!flushable.isEmpty()) {
table.addAll(flushable);
}
persistence.compact();
printProgress("WritesFinished", writesStart, VALUES, VALUES);
readIterator(table);
readOrdered(table);
readOrderedIndex(navigableIndex);
readGet(table);
readGetLatest(table);
readGetLatestIndex(navigableIndex);
table.clear();
}
Aggregations