@Override public long approximateNumEntries() { return inner.approximateNumEntries(); }
@Override public long approximateNumEntries() { return inner.approximateNumEntries(); }
@Override public long approximateNumEntries() { return inner.approximateNumEntries(); }
@Override public long approximateNumEntries() { return inner.approximateNumEntries(); }
@Override public long approximateNumEntries() { validateStoreOpen(); lock.readLock().lock(); try { return underlying.approximateNumEntries(); } finally { lock.readLock().unlock(); } }
@Override public KeyValue<String, Review> punctuate(long currentTime) { if (minTimestampInStore + timeToKeepAReview < currentTime && reviewStore.approximateNumEntries() > 0) { log.info("let's expire data!"); // invalidate the min timestamp in store as we're going to re-compute it minTimestampInStore = System.currentTimeMillis(); KeyValueIterator<Long, Review> it = reviewStore.all(); List<Long> keysToRemove = new ArrayList<>(); while (it.hasNext()) { KeyValue<Long, Review> next = it.next(); Review review = next.value; Long courseId = review.getCourse().getId(); if (isReviewExpired(review, currentTime, timeToKeepAReview)) { Long reviewId = next.key; keysToRemove.add(reviewId); // we push an opposite review event to remove data from the average Review reverseReview = reverseReview(review); this.context.forward(courseId, reverseReview); } else { // update the min timestamp in store as we know the data is staying updateMinTimestamp(review); } } for (Long key : keysToRemove) { reviewStore.delete(key); } } // this is okay because we called this.context.forward() multiple times before return null; }