use of com.bakdata.conquery.io.jackson.serializer.IdReferenceResolvingException in project conquery by bakdata.
the class CachedStore method fillCache.
@Override
public void fillCache() {
AtomicLong totalSize = new AtomicLong(0);
int count = count();
cache = new ConcurrentHashMap<KEY, VALUE>(count);
final ProgressBar bar;
Stopwatch timer = Stopwatch.createStarted();
if (count > 100) {
synchronized (PROGRESS_BAR) {
bar = PROGRESS_BAR;
bar.addMaxValue(count);
}
log.info("\tloading store {}", this);
} else {
bar = null;
}
store.forEach((key, value, size) -> {
try {
totalSize.addAndGet(size);
cache.put(key, value);
} catch (RuntimeException e) {
if (e.getCause() != null && e.getCause() instanceof IdReferenceResolvingException) {
log.warn("Probably failed to read id '{}' because it is not yet present, skipping", ((IdReferenceResolvingException) e.getCause()).getValue(), e);
} else {
throw e;
}
} finally {
if (bar != null) {
bar.addCurrentValue(1);
}
}
});
log.info("\tloaded store {}: {} entries, {} within {}", this, cache.values().size(), BinaryByteUnit.format(totalSize.get()), timer.stop());
}
Aggregations