use of org.apache.kafka.streams.state.KeyValueIterator in project kafka by apache.
the class SessionKeySchema method hasNextCondition.
@Override
public HasNextCondition hasNextCondition(final Bytes binaryKey, final long from, final long to) {
return new HasNextCondition() {
@Override
public boolean hasNext(final KeyValueIterator<Bytes, ?> iterator) {
if (iterator.hasNext()) {
final Bytes bytes = iterator.peekNextKey();
final Bytes keyBytes = Bytes.wrap(SessionKeySerde.extractKeyBytes(bytes.get()));
if (!keyBytes.equals(binaryKey)) {
return false;
}
final long start = SessionKeySerde.extractStart(bytes.get());
final long end = SessionKeySerde.extractEnd(bytes.get());
return end >= from && start <= to;
}
return false;
}
};
}
use of org.apache.kafka.streams.state.KeyValueIterator in project kafka by apache.
the class WindowKeySchema method hasNextCondition.
@Override
public HasNextCondition hasNextCondition(final Bytes binaryKey, final long from, final long to) {
return new HasNextCondition() {
@Override
public boolean hasNext(final KeyValueIterator<Bytes, ?> iterator) {
if (iterator.hasNext()) {
final Bytes bytes = iterator.peekNextKey();
final Bytes keyBytes = WindowStoreUtils.bytesKeyFromBinaryKey(bytes.get());
if (!keyBytes.equals(binaryKey)) {
return false;
}
final long time = WindowStoreUtils.timestampFromBinaryKey(bytes.get());
return time >= from && time <= to;
}
return false;
}
};
}
Aggregations