aliehsaeedii commented on code in PR #14596: URL: https://github.com/apache/kafka/pull/14596#discussion_r1370052232
########## streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredVersionedKeyValueStore.java: ########## @@ -148,13 +205,38 @@ protected <R> QueryResult<R> runRangeQuery(final Query<R> query, throw new UnsupportedOperationException("Versioned stores do not support RangeQuery queries at this time."); } + @SuppressWarnings("unchecked") @Override protected <R> QueryResult<R> runKeyQuery(final Query<R> query, - final PositionBound positionBound, - final QueryConfig config) { - // throw exception for now to reserve the ability to implement this in the future - // without clashing with users' custom implementations in the meantime - throw new UnsupportedOperationException("Versioned stores do not support KeyQuery queries at this time."); + final PositionBound positionBound, + final QueryConfig config) { + if (query instanceof VersionedKeyQuery) { + final QueryResult<R> result; + final VersionedKeyQuery<K, V> typedKeyQuery = (VersionedKeyQuery<K, V>) query; + VersionedKeyQuery<Bytes, byte[]> rawKeyQuery; + if (typedKeyQuery.asOfTimestamp().isPresent()) { + rawKeyQuery = VersionedKeyQuery.withKey(keyBytes(typedKeyQuery.key())); + rawKeyQuery = rawKeyQuery.asOf(typedKeyQuery.asOfTimestamp().get()); + } else { + rawKeyQuery = VersionedKeyQuery.withKey(keyBytes(typedKeyQuery.key())); + } + final QueryResult<VersionedRecord<byte[]>> rawResult = + wrapped().query(rawKeyQuery, positionBound, config); + if (rawResult.isSuccess()) { + final Function<byte[], ValueAndTimestamp<V>> deserializer = getDeserializeValue(plainValueSerdes); Review Comment: > Why is the type `ValueAndTimestamp`? Should it not be `VersionedRecord`? Thanks Matthias. Good point. I wanted to discuss it with you. I just did it to reuse the `ValueAndTimestampDeserializer` class. Moreover, inside `MeteredVersionedKeyValueStoreInternal` every other method uses `ValueAndTimestamp` as well. Btw, do you agree to implement a new class `VersionedRecordDeserializer`? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org