use of org.apache.kafka.streams.state.internals.MeteredWindowStore in project ksql by confluentinc.
the class WindowStoreCacheBypass method fetchRangeUncached.
/*
This method is used for range queries. It is invoked by the fetchRange method
*/
private static KeyValueIterator<Windowed<GenericKey>, ValueAndTimestamp<GenericRow>> fetchRangeUncached(final ReadOnlyWindowStore<GenericKey, ValueAndTimestamp<GenericRow>> windowStore, final GenericKey keyFrom, final GenericKey keyTo, final Instant lower, final Instant upper) {
if (!(windowStore instanceof MeteredWindowStore)) {
throw new IllegalStateException("Expecting a MeteredWindowStore");
}
final StateSerdes<GenericKey, ValueAndTimestamp<GenericRow>> serdes = getSerdes(windowStore);
final WindowStore<Bytes, byte[]> wrapped = getInnermostStore(windowStore);
final Bytes rawKeyFrom = Bytes.wrap(serdes.rawKey(keyFrom));
final Bytes rawKeyTo = Bytes.wrap(serdes.rawKey(keyTo));
final KeyValueIterator<Windowed<Bytes>, byte[]> fetch = wrapped.fetch(rawKeyFrom, rawKeyTo, lower, upper);
return new DeserializingKeyValueIterator(fetch, serdes);
}
use of org.apache.kafka.streams.state.internals.MeteredWindowStore in project ksql by confluentinc.
the class WindowStoreCacheBypass method fetchUncached.
/*
This method is used for single key lookups. It is invoked by the fetch method
*/
private static WindowStoreIterator<ValueAndTimestamp<GenericRow>> fetchUncached(final ReadOnlyWindowStore<GenericKey, ValueAndTimestamp<GenericRow>> windowStore, final GenericKey key, final Instant lower, final Instant upper) {
if (!(windowStore instanceof MeteredWindowStore)) {
throw new IllegalStateException("Expecting a MeteredWindowStore");
}
final StateSerdes<GenericKey, ValueAndTimestamp<GenericRow>> serdes = getSerdes(windowStore);
final WindowStore<Bytes, byte[]> wrapped = getInnermostStore(windowStore);
final Bytes rawKey = Bytes.wrap(serdes.rawKey(key));
final WindowStoreIterator<byte[]> fetch = wrapped.fetch(rawKey, lower, upper);
return new DeserializingIterator(fetch, serdes);
}
use of org.apache.kafka.streams.state.internals.MeteredWindowStore in project ksql by confluentinc.
the class WindowStoreCacheBypass method getInnermostStore.
@SuppressWarnings("unchecked")
private static WindowStore<Bytes, byte[]> getInnermostStore(final ReadOnlyWindowStore<GenericKey, ValueAndTimestamp<GenericRow>> windowStore) {
WindowStore<Bytes, byte[]> wrapped = ((MeteredWindowStore<GenericKey, ValueAndTimestamp<GenericRow>>) windowStore).wrapped();
// layer.
while (wrapped instanceof WrappedStateStore) {
final StateStore store = ((WrappedStateStore<?, ?, ?>) wrapped).wrapped();
// we just store there.
if (!(store instanceof WindowStore)) {
break;
}
wrapped = (WindowStore<Bytes, byte[]>) store;
}
// now we have the innermost layer of the store.
return wrapped;
}
Aggregations