@Override public KeyValueIterator<K, V> all() { return this.inner.all(); } }
@Override public KeyValueIterator<Bytes, byte[]> all() { return inner.all(); } }
@Override public KeyValueIterator<K, V> all() { return this.inner.all(); }
@Override public KeyValueIterator<K, V> all() { return new MeteredKeyValueIterator(this.inner.all(), this.allTime); }
private void printStateStoreAll() { final KeyValueIterator<String, VisibilityBindingSet> rangeIt = store.all(); printStateStoreKeyValueIterator(rangeIt); }
/** Saves the `lastAvgs` map to the state store. * * {@inheritDoc} */ @Override public void punctuate(long timestamp) { // Print the contents of the state store. state.all().forEachRemaining( kv -> System.out.println(System.currentTimeMillis() + " PUNCTUATE: " + kv.key + ", " + kv.value)); // Foward the new average. state.all().forEachRemaining( kv -> context.forward(kv.key, kv.value, "FAST-sink")); } // Close punctuate.
/** Forwards the values in the state store downstream. * * {@inheritDoc} */ @Override public void punctuate(long timestamp) { state.all().forEachRemaining( kv -> context.forward(kv.key, kv.value, type + "-sink")); } // Close punctuate.
/** Initializes the state store with the name "FAST-store", where * `type` is the type specified in the constructor. * * {@inheritDoc} */ @Override @SuppressWarnings("unchecked") public void init(ProcessorContext context) { this.context = context; // Schedules the `punctuate` method for every second. this.context.schedule(1000L); state = (KeyValueStore) context.getStateStore("FAST-store"); // Print the contents of the state store. state.all().forEachRemaining( kv -> System.out.println(System.currentTimeMillis() + " INIT: " + kv.key + ", " + kv.value)); } // Close init.
@Override public void punctuate(long streamTime) { KeyValueIterator<String, StockTransactionSummary> it = summaryStore.all(); long currentTime = System.currentTimeMillis(); while (it.hasNext()) { StockTransactionSummary summary = it.next().value; if (summary.updatedWithinLastMillis(currentTime, 11000)) { this.context.forward(summary.tickerSymbol, summary); } } }
@Override public boolean hasNext() { boolean hasNext = false; while ((currentIterator == null || !(hasNext = hasNextConditionHasNext()) || !currentSegment.isOpen()) && segments.hasNext()) { close(); currentSegment = segments.next(); try { if (from == null || to == null) { currentIterator = currentSegment.all(); } else { currentIterator = currentSegment.range(from, to); } } catch (final InvalidStateStoreException e) { // segment may have been closed so we ignore it. } } return currentIterator != null && hasNext; }
@Override public void punctuate(long timestamp) { try (KeyValueIterator<String, Integer> iterator = this.kvStore.all()) { iterator.forEachRemaining(entry -> { context.forward(entry.key, entry.value); this.kvStore.delete(entry.key); }); } context.commit(); }
@Override public KeyValueIterator<Bytes, byte[]> all() { validateStoreOpen(); final KeyValueIterator<Bytes, byte[]> storeIterator = new DelegatingPeekingKeyValueIterator<>(this.name(), underlying.all()); final ThreadCache.MemoryLRUCacheBytesIterator cacheIterator = cache.all(cacheName); return new MergedSortedCacheKeyValueBytesStoreIterator(cacheIterator, storeIterator); }
@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; }