@Override public Windowed<K> peekNextKey() { return windowedKey(iter.peekNextKey()); } }
@Override public Bytes peekNextKey() { if (!hasNext()) { throw new NoSuchElementException(); } return currentIterator.peekNextKey(); }
@Override public Windowed<Bytes> peekNextKey() { final Bytes key = bytesIterator.peekNextKey(); return SessionKeySchema.from(key); }
@Override public Long peekNextKey() { return WindowKeySchema.extractStoreTimestamp(bytesIterator.peekNextKey().get()); }
@Override public Windowed<K> peekNextKey() { final Bytes bytes = bytesIterator.peekNextKey(); return SessionKeySchema.from(bytes.get(), serdes.keyDeserializer(), serdes.topic()); }
@Override public Windowed<K> peekNextKey() { final byte[] nextKey = bytesIterator.peekNextKey().get(); final long timestamp = WindowKeySchema.extractStoreTimestamp(nextKey); final K key = WindowKeySchema.extractStoreKey(nextKey, serdes); return new Windowed<>(key, WindowKeySchema.timeWindowForSize(timestamp, windowSize)); }
@Override public KeyValue<K, V> next() { if (!hasNext()) { throw new NoSuchElementException(); } final Bytes nextCacheKey = cacheIterator.hasNext() ? cacheIterator.peekNextKey() : null; final KS nextStoreKey = storeIterator.hasNext() ? storeIterator.peekNextKey() : null; if (nextCacheKey == null) { return nextStoreValue(nextStoreKey); } if (nextStoreKey == null) { return nextCacheValue(nextCacheKey); } final int comparison = compare(nextCacheKey, nextStoreKey); if (comparison > 0) { return nextStoreValue(nextStoreKey); } else if (comparison < 0) { return nextCacheValue(nextCacheKey); } else { // skip the same keyed element storeIterator.next(); return nextCacheValue(nextCacheKey); } }
@Override public boolean hasNext() { // skip over items deleted from cache, and corresponding store items if they have the same key while (cacheIterator.hasNext() && isDeletedCacheEntry(cacheIterator.peekNext())) { if (storeIterator.hasNext()) { final KS nextStoreKey = storeIterator.peekNextKey(); // advance the store iterator if the key is the same as the deleted cache key if (compare(cacheIterator.peekNextKey(), nextStoreKey) == 0) { storeIterator.next(); } } cacheIterator.next(); } return cacheIterator.hasNext() || storeIterator.hasNext(); }
@Override public boolean hasNext(final KeyValueIterator<Bytes, ?> iterator) { while (iterator.hasNext()) { final Bytes bytes = iterator.peekNextKey(); final Bytes keyBytes = Bytes.wrap(WindowKeySchema.extractStoreKeyBytes(bytes.get())); final long time = WindowKeySchema.extractStoreTimestamp(bytes.get()); if ((binaryKeyFrom == null || keyBytes.compareTo(binaryKeyFrom) >= 0) && (binaryKeyTo == null || keyBytes.compareTo(binaryKeyTo) <= 0) && time >= from && time <= to) { return true; } iterator.next(); } return false; } };
@Override public K peekNextKey() { if (!hasNext()) { throw new NoSuchElementException(); } final Bytes nextCacheKey = cacheIterator.hasNext() ? cacheIterator.peekNextKey() : null; final KS nextStoreKey = storeIterator.hasNext() ? storeIterator.peekNextKey() : null; if (nextCacheKey == null) { return deserializeStoreKey(nextStoreKey); } if (nextStoreKey == null) { return deserializeCacheKey(nextCacheKey); } final int comparison = compare(nextCacheKey, nextStoreKey); if (comparison > 0) { return deserializeStoreKey(nextStoreKey); } else if (comparison < 0) { return deserializeCacheKey(nextCacheKey); } else { // skip the same keyed element storeIterator.next(); return deserializeCacheKey(nextCacheKey); } }
@Override public boolean hasNext(final KeyValueIterator<Bytes, ?> iterator) { while (iterator.hasNext()) { final Bytes bytes = iterator.peekNextKey(); final Windowed<Bytes> windowedKey = SessionKeySchema.from(bytes); if ((binaryKeyFrom == null || windowedKey.key().compareTo(binaryKeyFrom) >= 0) && (binaryKeyTo == null || windowedKey.key().compareTo(binaryKeyTo) <= 0) && windowedKey.window().end() >= from && windowedKey.window().start() <= to) { return true; } iterator.next(); } return false; } };