private void assertFurtherValuesSorting(final FDate key) { final FDate firstKey = extractKey(key, furtherValues.getHead()); if (firstKey.compareTo(key) <= -1) { /* * readAllValuesAscendingFrom loads all data, thus we set the min key very deep so that later queries are * skipped if they are before minKey */ minKey = minKey(); } if (minKeyInDB == null || firstKey.compareTo(minKey) <= -1) { minKeyInDB = firstKey; } minKeyInDBFromLoadFurtherValues = FDates.min(minKeyInDBFromLoadFurtherValues, firstKey); final FDate lastKey = extractKey(key, furtherValues.getTail()); if (maxKeyInDB == null || lastKey.compareTo(maxKeyInDB) <= -1) { maxKeyInDB = FDates.max(maxKeyInDB, lastKey); } maxKeyInDBFromLoadFurtherValues = FDates.max(maxKeyInDBFromLoadFurtherValues, lastKey); if (furtherValues.size() > 1) { Assertions.checkState( firstKey.compareTo(lastKey) <= 0, "Not ascending sorted! At firstKey [%s] and lastKey [%s]", firstKey, lastKey); } }
private boolean eventuallyLoadFurtherValues( final String source, final FDate key, final FDate adjustedKey, final boolean newMinKey, final boolean forced) { if (forced || shouldLoadFurtherValues(key, newMinKey)) { final FDate keyForReadAllValues; if (newMinKey && minKeyInDBFromLoadFurtherValues != null && key.isBefore(minKeyInDBFromLoadFurtherValues)) { // performance optimization for first load keyForReadAllValues = FDates.min(minKeyInDB, FDates.max(minKeyInDB, adjustedKey)); } else { keyForReadAllValues = FDates.max(minKeyInDB, adjustedKey); } furtherValues.clear(); lastValuesFromFurtherValues.clear(); furtherValues.addAll(readAllValuesAscendingFrom(keyForReadAllValues)); if (!furtherValues.isEmpty()) { assertFurtherValuesSorting(key); } return true; } return false; }