use of de.invesdwin.context.persistence.timeseriesdb.ATimeSeriesDB in project invesdwin-context-persistence by subes.
the class TimeseriesDBPerformanceTest method testTimeSeriesDbPerformance.
@Test
public void testTimeSeriesDbPerformance() throws IncompleteUpdateFoundException, InterruptedException {
final ATimeSeriesDB<String, FDate> table = new ATimeSeriesDB<String, FDate>("testTimeSeriesDbPerformance") {
@Override
protected File getBaseDirectory() {
return ContextProperties.TEMP_DIRECTORY;
}
@Override
protected ISerde<FDate> newValueSerde() {
return FDateSerde.GET;
}
@Override
protected Integer newValueFixedLength() {
return FDateSerde.FIXED_LENGTH;
}
@Override
protected String innerHashKeyToString(final String key) {
return "testTimeSeriesDbPerformance_" + key;
}
@Override
protected FDate extractEndTime(final FDate value) {
return value;
}
};
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
final Instant writesStart = new Instant();
final ATimeSeriesUpdater<String, FDate> updater = new ATimeSeriesUpdater<String, FDate>(HASH_KEY, table) {
@Override
protected ICloseableIterable<FDate> getSource(final FDate updateFrom) {
return newValues();
}
@Override
protected void onUpdateFinished(final Instant updateStart) {
printProgress("WritesFinished", writesStart, VALUES, VALUES);
}
@Override
protected void onUpdateStart() {
}
@Override
protected FDate extractEndTime(final FDate element) {
return element;
}
@Override
protected void onFlush(final int flushIndex, final ATimeSeriesUpdater<String, FDate>.UpdateProgress updateProgress) {
try {
if (loopCheck.check()) {
printProgress("Writes", writesStart, updateProgress.getValueCount() * flushIndex, VALUES);
}
} catch (final InterruptedException e) {
throw new RuntimeException(e);
}
}
@Override
public Percent getProgress() {
return null;
}
};
Assertions.checkTrue(updater.update());
readIterator(table, "Cold", 1);
readIterator(table, "Warm", READS);
readGetLatest(table, "Cold", 1);
readGetLatest(table, "Warm", READS);
}
Aggregations