use of com.sleepycat.je.SecondaryDatabase in project parliament by SemWebCentral.
the class PersistentTemporalIndex method countRecords.
private long countRecords(long time, boolean starts) {
@SuppressWarnings("resource") SecondaryDatabase sdb = (starts) ? getStartsDatabase() : getEndsDatabase();
DatabaseEntry key = new DatabaseEntry(PersistentTemporalIndex.getBytesForLong(time));
DatabaseEntry data = new DatabaseEntry();
try (SecondaryCursor cursor = sdb.openCursor(null, CursorConfig.READ_UNCOMMITTED)) {
OperationStatus status = cursor.getSearchKeyRange(key, data, LockMode.READ_UNCOMMITTED);
if (OperationStatus.SUCCESS.equals(status)) {
int count = 1;
long start = System.currentTimeMillis();
while (OperationStatus.SUCCESS.equals(cursor.getNext(key, data, LockMode.READ_UNCOMMITTED))) {
count++;
}
long length = System.currentTimeMillis() - start;
LOG.debug("Search took: " + length);
return count;
}
}
return Long.MAX_VALUE;
}
Aggregations