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