@SuppressWarnings("unchecked")
        private <R> QueryResult<R> runVersionedKeyQuery(final Query<R> query,
                                                          final PositionBound positionBound,
                                                          final QueryConfig config) {
            final QueryResult<R> result;
            final VersionedKeyQuery<K, V> typedKeyQuery = (VersionedKeyQuery<K, V>) query;
            VersionedKeyQuery<Bytes, byte[]> rawKeyQuery = VersionedKeyQuery.withKey(keyBytes(typedKeyQuery.key()));
            if (typedKeyQuery.asOfTimestamp().isPresent()) {
                rawKeyQuery = rawKeyQuery.asOf(typedKeyQuery.asOfTimestamp().get());
            }
            final QueryResult<VersionedRecord<byte[]>> rawResult =
                wrapped().query(rawKeyQuery, positionBound, config);
            if (rawResult.isSuccess() && rawResult.getResult() != null) {
                final VersionedRecord<V> versionedRecord = StoreQueryUtils.deserializeVersionedRecord(plainValueSerdes, rawResult.getResult());
                final QueryResult<VersionedRecord<V>> typedQueryResult =
                    InternalQueryResultUtil.copyAndSubstituteDeserializedResult(rawResult, versionedRecord);
                result = (QueryResult<R>) typedQueryResult;
            } else {
                // the generic type doesn't matter, since failed queries have no result set.
                result = (QueryResult<R>) rawResult;
            }
            return result;
        }
Conceptually, {@link MeteredVersionedKeyValueStore} should {@code extend}
{@link MeteredKeyValueStore}, but due to type conflicts, we cannot do this. (Specifically,
the first needs to be {@link VersionedKeyValueStore} while the second is {@link KeyValueStore}
and the two interfaces conflict.) Thus, we use an internal <it>instance</it> of
{@code MeteredKeyValueStore} to mimic inheritance instead.
<p>
It's not ideal because it requires an extra step to translate between the APIs of
{@link VersionedKeyValueStore} in {@link MeteredVersionedKeyValueStore} and
the APIs of {@link TimestampedKeyValueStore} in {@link MeteredVersionedKeyValueStoreInternal}.
This extra step is all that the methods of {@code MeteredVersionedKeyValueStoreInternal} do.
<p>
Note that the addition of {@link #get(Object, long)} and {@link #delete(Object, long)} in
this class are to match the interface of {@link VersionedKeyValueStore}.
streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredVersionedKeyValueStore.java