use of de.invesdwin.util.time.Instant in project invesdwin-context-persistence by subes.
the class TestStockData method assertIteration.
private void assertIteration(final int countFDates, final FDate fromFDate, final FDate toFDate) {
TableIterator<RangeTableRow<String, FDate, Integer>> range = table.range(MSFT, fromFDate, toFDate);
int iteratedBars = 0;
int prevValue = 0;
FDate left1000FDate = null;
FDate left900FDate = null;
final Instant start = new Instant();
while (range.hasNext()) {
final RangeTableRow<String, FDate, Integer> next = range.next();
final Integer value = next.getValue();
// System.out.println(value);
iteratedBars++;
Assertions.checkTrue(prevValue < value);
prevValue = value;
if (iteratedBars == countFDates - 999) {
left1000FDate = next.getRangeKey();
}
if (iteratedBars == countFDates - 900) {
left900FDate = next.getRangeKey();
}
}
System.out.println("took: " + start);
Assertions.checkEquals(countFDates, iteratedBars);
Assertions.checkEquals(1, table.getLatest(MSFT, fromFDate).getValue());
Assertions.checkEquals(countFDates, table.getLatest(MSFT, toFDate).getValue());
// System.out.println(left1000FDate +" -> "+left900FDate);
range = table.range(MSFT, left1000FDate, left900FDate);
int curLeftIt = 0;
RangeTableRow<String, FDate, Integer> prev = null;
while (range.hasNext()) {
final RangeTableRow<String, FDate, Integer> next = range.next();
curLeftIt++;
Assertions.checkEquals(countFDates - 1000 + curLeftIt, next.getValue());
if (prev != null) {
final Integer nextFromPrevPlus = table.getNext(MSFT, new FDate(prev.getRangeKey().millisValue() + 1)).getValue();
Assertions.checkEquals(next.getValue(), nextFromPrevPlus);
final Integer prevFromNextMinus = table.getPrev(MSFT, new FDate(next.getRangeKey().millisValue() - 1)).getValue();
Assertions.checkEquals(prev.getValue(), prevFromNextMinus);
}
final Integer nextFromNextIsSame = table.getNext(MSFT, new FDate(next.getRangeKey().millisValue())).getValue();
Assertions.checkEquals(next.getValue(), nextFromNextIsSame);
final Integer prevFromNextIsSame = table.getPrev(MSFT, new FDate(next.getRangeKey().millisValue())).getValue();
Assertions.checkEquals(next.getValue(), prevFromNextIsSame);
prev = next;
}
Assertions.checkEquals(100, curLeftIt);
}
use of de.invesdwin.util.time.Instant in project invesdwin-context-persistence by subes.
the class PersistentEzdbPerformanceTest method readGet.
private void readGet(final APersistentMap<FDate, FDate> table) throws InterruptedException {
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
final List<FDate> values = Lists.toList(newValues());
final Instant readsStart = new Instant();
for (int reads = 1; reads <= READS; reads++) {
FDate prevValue = null;
for (int i = 0; i < values.size(); i++) {
try {
final FDate value = table.get(values.get(i));
if (prevValue != null) {
Assertions.checkTrue(prevValue.isBefore(value));
}
prevValue = value;
} catch (final NoSuchElementException e) {
break;
}
}
if (loopCheck.check()) {
printProgress("Gets", readsStart, VALUES * reads, VALUES * READS);
}
}
printProgress("GetsFinished", readsStart, VALUES * READS, VALUES * READS);
}
use of de.invesdwin.util.time.Instant in project invesdwin-context-persistence by subes.
the class BasicRecordFilePerformanceTest method readIterator.
private void readIterator(final File file) throws IOException, InterruptedException {
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck();
final Instant readsStart = new Instant();
for (int reads = 1; reads <= READS; reads++) {
FDate prevValue = null;
int count = 0;
try (BasicRecordFile<TimedDecimal> reader = new BasicRecordFile<>(file, IndeedSerializer.valueOf(TimedDecimalSerde.GET))) {
final RecordFile.Reader<TimedDecimal> iterator = reader.reader();
while (iterator.next()) {
final FDate value = iterator.get().getTime();
if (prevValue != null) {
Assertions.checkTrue(prevValue.isBefore(value));
}
prevValue = value;
count++;
}
Assertions.checkEquals(count, VALUES);
if (loopCheck.check()) {
printProgress("Reads", readsStart, VALUES * reads, VALUES * READS);
}
}
}
printProgress("ReadsFinished", readsStart, VALUES * READS, VALUES * READS);
}
use of de.invesdwin.util.time.Instant in project invesdwin-context-persistence by subes.
the class LsmTreePerformanceTest method readIterator.
private void readIterator(final Store<FDate, FDate> table) throws InterruptedException, IOException {
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
final Instant readsStart = new Instant();
for (int reads = 1; reads <= READS; reads++) {
FDate prevValue = null;
final Iterator<Store.Entry<FDate, FDate>> range = table.iterator();
int count = 0;
while (true) {
try {
final FDate value = range.next().getValue();
if (prevValue != null) {
Assertions.checkTrue(prevValue.isBefore(value));
}
prevValue = value;
count++;
} catch (final NoSuchElementException e) {
break;
}
}
Assertions.checkEquals(count, VALUES);
if (loopCheck.check()) {
printProgress("Reads", readsStart, VALUES * reads, VALUES * READS);
}
}
printProgress("ReadsFinished", readsStart, VALUES * READS, VALUES * READS);
}
use of de.invesdwin.util.time.Instant in project invesdwin-context-persistence by subes.
the class LsmTreePerformanceTest method readGetLatest.
private void readGetLatest(final Store<FDate, FDate> table) throws InterruptedException, IOException {
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
final List<FDate> values = Lists.toList(newValues());
final Instant readsStart = new Instant();
for (int reads = 1; reads <= READS; reads++) {
FDate prevValue = null;
for (int i = 0; i < values.size(); i++) {
try {
final Store.Entry<FDate, FDate> entry = table.floor(values.get(i));
final FDate value = entry.getValue();
if (prevValue != null) {
Assertions.checkTrue(prevValue.isBefore(value));
}
prevValue = value;
} catch (final NoSuchElementException e) {
break;
}
}
if (loopCheck.check()) {
printProgress("GetLatests", readsStart, VALUES * reads, VALUES * READS);
}
}
printProgress("GetLatestsFinished", readsStart, VALUES * READS, VALUES * READS);
}
Aggregations