risingwave_storage/hummock/
test_utils.rs

1// Copyright 2025 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::cmp::min;
16use std::collections::HashMap;
17use std::sync::Arc;
18
19use bytes::Bytes;
20use foyer::{
21    Hint, HybridCache, HybridCacheBuilder, StorageKey as HybridKey, StorageValue as HybridValue,
22};
23use futures::TryFutureExt;
24use itertools::Itertools;
25use risingwave_common::catalog::TableId;
26use risingwave_common::config::EvictionConfig;
27use risingwave_common::hash::VirtualNode;
28use risingwave_common::util::epoch::test_epoch;
29use risingwave_common::util::row_serde::OrderedRowSerde;
30use risingwave_hummock_sdk::key::{FullKey, TableKey, TableKeyRange, UserKey};
31use risingwave_hummock_sdk::key_range::KeyRange;
32use risingwave_hummock_sdk::sstable_info::{SstableInfo, SstableInfoInner};
33use risingwave_hummock_sdk::{
34    EpochWithGap, HummockEpoch, HummockReadEpoch, HummockSstableObjectId,
35};
36
37use super::iterator::test_utils::iterator_test_table_key_of;
38use super::{
39    DEFAULT_RESTART_INTERVAL, HummockResult, InMemWriter, SstableMeta, SstableWriterOptions,
40};
41use crate::StateStore;
42use crate::compaction_catalog_manager::{
43    CompactionCatalogAgent, FilterKeyExtractorImpl, FullKeyFilterKeyExtractor,
44};
45use crate::error::StorageResult;
46use crate::hummock::shared_buffer::shared_buffer_batch::{
47    SharedBufferBatch, SharedBufferItem, SharedBufferValue,
48};
49use crate::hummock::value::HummockValue;
50use crate::hummock::{
51    BlockedXor16FilterBuilder, CachePolicy, FilterBuilder, LruCache, Sstable, SstableBuilder,
52    SstableBuilderOptions, SstableStoreRef, SstableWriter, TableHolder, Xor16FilterBuilder,
53};
54use crate::monitor::StoreLocalStatistic;
55use crate::opts::StorageOpts;
56use crate::storage_value::StorageValue;
57use crate::store::*;
58
59pub fn default_opts_for_test() -> StorageOpts {
60    StorageOpts {
61        sstable_size_mb: 4,
62        block_size_kb: 64,
63        bloom_false_positive: 0.1,
64        share_buffers_sync_parallelism: 2,
65        share_buffer_compaction_worker_threads_number: 1,
66        shared_buffer_capacity_mb: 64,
67        data_directory: "hummock_001".to_owned(),
68        write_conflict_detection_enabled: true,
69        block_cache_capacity_mb: 64,
70        meta_cache_capacity_mb: 64,
71        block_cache_eviction_config: EvictionConfig::for_test(),
72        disable_remote_compactor: false,
73        share_buffer_upload_concurrency: 1,
74        compactor_memory_limit_mb: 64,
75        sstable_id_remote_fetch_number: 1,
76        vector_file_block_size_kb: 8,
77        ..Default::default()
78    }
79}
80
81pub fn gen_dummy_batch(n: u64) -> Vec<SharedBufferItem> {
82    vec![(
83        TableKey(Bytes::from(iterator_test_table_key_of(n as usize))),
84        SharedBufferValue::Insert(Bytes::copy_from_slice(&b"value1"[..])),
85    )]
86}
87
88pub fn gen_dummy_batch_several_keys(n: usize) -> Vec<(TableKey<Bytes>, StorageValue)> {
89    let mut kvs = vec![];
90    let v = Bytes::from(b"value1".to_vec().repeat(100));
91    for idx in 0..n {
92        kvs.push((
93            TableKey(Bytes::from(iterator_test_table_key_of(idx))),
94            StorageValue::new_put(v.clone()),
95        ));
96    }
97    kvs
98}
99
100pub fn gen_dummy_sst_info(
101    id: u64,
102    batches: Vec<SharedBufferBatch>,
103    table_id: TableId,
104    epoch: HummockEpoch,
105) -> SstableInfo {
106    let mut min_table_key: Vec<u8> = batches[0].start_table_key().to_vec();
107    let mut max_table_key: Vec<u8> = batches[0].end_table_key().to_vec();
108    let mut file_size = 0;
109    for batch in batches.iter().skip(1) {
110        if min_table_key.as_slice() > *batch.start_table_key() {
111            min_table_key = batch.start_table_key().to_vec();
112        }
113        if max_table_key.as_slice() < *batch.end_table_key() {
114            max_table_key = batch.end_table_key().to_vec();
115        }
116        file_size += batch.size() as u64;
117    }
118    SstableInfoInner {
119        object_id: id.into(),
120        sst_id: id.into(),
121        key_range: KeyRange {
122            left: Bytes::from(FullKey::for_test(table_id, min_table_key, epoch).encode()),
123            right: Bytes::from(FullKey::for_test(table_id, max_table_key, epoch).encode()),
124            right_exclusive: false,
125        },
126        file_size,
127        table_ids: vec![table_id],
128        uncompressed_file_size: file_size,
129        min_epoch: epoch,
130        max_epoch: epoch,
131        sst_size: file_size,
132        ..Default::default()
133    }
134    .into()
135}
136
137/// Number of keys in table generated in `generate_table`.
138pub const TEST_KEYS_COUNT: usize = 10000;
139
140pub fn default_builder_opt_for_test() -> SstableBuilderOptions {
141    SstableBuilderOptions {
142        capacity: 256 * (1 << 20), // 256MB
143        block_capacity: 4096,      // 4KB
144        restart_interval: DEFAULT_RESTART_INTERVAL,
145        bloom_false_positive: 0.1,
146        ..Default::default()
147    }
148}
149
150pub fn default_writer_opt_for_test() -> SstableWriterOptions {
151    SstableWriterOptions {
152        capacity_hint: None,
153        tracker: None,
154        policy: CachePolicy::Disable,
155    }
156}
157
158pub fn mock_sst_writer(opt: &SstableBuilderOptions) -> InMemWriter {
159    InMemWriter::from(opt)
160}
161
162/// Generates sstable data and metadata from given `kv_iter`
163pub async fn gen_test_sstable_data(
164    opts: SstableBuilderOptions,
165    kv_iter: impl Iterator<Item = (FullKey<Vec<u8>>, HummockValue<Vec<u8>>)>,
166) -> (Bytes, SstableMeta) {
167    let table_id_to_vnode = HashMap::from_iter(vec![(
168        TableId::default().as_raw_id(),
169        VirtualNode::COUNT_FOR_TEST,
170    )]);
171    let table_id_to_watermark_serde = HashMap::from_iter(vec![(0, None)]);
172    let mut b = SstableBuilder::for_test(
173        0,
174        mock_sst_writer(&opts),
175        opts,
176        table_id_to_vnode,
177        table_id_to_watermark_serde,
178    );
179    for (key, value) in kv_iter {
180        b.add_for_test(key.to_ref(), value.as_slice())
181            .await
182            .unwrap();
183    }
184    let output = b.finish().await.unwrap();
185    output.writer_output
186}
187
188/// Write the data and meta to `sstable_store`.
189pub async fn put_sst(
190    sst_object_id: u64,
191    data: Bytes,
192    mut meta: SstableMeta,
193    sstable_store: SstableStoreRef,
194    mut options: SstableWriterOptions,
195    table_ids: Vec<u32>,
196) -> HummockResult<SstableInfo> {
197    options.policy = CachePolicy::NotFill;
198    let mut writer = sstable_store
199        .clone()
200        .create_sst_writer(sst_object_id, options);
201    for block_meta in &meta.block_metas {
202        let offset = block_meta.offset as usize;
203        let end_offset = offset + block_meta.len as usize;
204        writer
205            .write_block(&data[offset..end_offset], block_meta)
206            .await?;
207    }
208
209    // dummy
210    let bloom_filter = {
211        let mut filter_builder = BlockedXor16FilterBuilder::new(100);
212        for _ in &meta.block_metas {
213            filter_builder.switch_block(None);
214        }
215
216        filter_builder.finish(None)
217    };
218
219    meta.meta_offset = writer.data_len() as u64;
220    meta.bloom_filter = bloom_filter;
221    let sst = SstableInfoInner {
222        object_id: sst_object_id.into(),
223        sst_id: sst_object_id.into(),
224        key_range: KeyRange {
225            left: Bytes::from(meta.smallest_key.clone()),
226            right: Bytes::from(meta.largest_key.clone()),
227            right_exclusive: false,
228        },
229        file_size: meta.estimated_size as u64,
230        meta_offset: meta.meta_offset,
231        uncompressed_file_size: meta.estimated_size as u64,
232        table_ids: table_ids.into_iter().map(Into::into).collect(),
233        ..Default::default()
234    }
235    .into();
236    let writer_output = writer.finish(meta).await?;
237    writer_output.await.unwrap()?;
238    Ok(sst)
239}
240
241/// Generates a test table from the given `kv_iter` and put the kv value to `sstable_store`
242pub async fn gen_test_sstable_impl<B: AsRef<[u8]> + Clone + Default + Eq, F: FilterBuilder>(
243    opts: SstableBuilderOptions,
244    object_id: u64,
245    kv_iter: impl IntoIterator<Item = (FullKey<B>, HummockValue<B>)>,
246    sstable_store: SstableStoreRef,
247    policy: CachePolicy,
248    table_id_to_vnode: HashMap<u32, usize>,
249    table_id_to_watermark_serde: HashMap<u32, Option<(OrderedRowSerde, OrderedRowSerde, usize)>>,
250) -> SstableInfo {
251    let writer_opts = SstableWriterOptions {
252        capacity_hint: None,
253        tracker: None,
254        policy,
255    };
256    let writer = sstable_store
257        .clone()
258        .create_sst_writer(object_id, writer_opts);
259
260    let compaction_catalog_agent_ref = Arc::new(CompactionCatalogAgent::new(
261        FilterKeyExtractorImpl::FullKey(FullKeyFilterKeyExtractor),
262        table_id_to_vnode
263            .into_iter()
264            .map(|(table_id, v)| (table_id.into(), v))
265            .collect(),
266        table_id_to_watermark_serde
267            .into_iter()
268            .map(|(table_id, v)| (table_id.into(), v))
269            .collect(),
270    ));
271
272    let mut b = SstableBuilder::<_, F>::new(
273        object_id,
274        writer,
275        F::create(opts.bloom_false_positive, opts.capacity / 16),
276        opts,
277        compaction_catalog_agent_ref,
278        None,
279    );
280
281    let mut last_key = FullKey::<B>::default();
282    for (key, value) in kv_iter {
283        let is_new_user_key =
284            last_key.is_empty() || key.user_key.as_ref() != last_key.user_key.as_ref();
285        if is_new_user_key {
286            last_key = key.clone();
287        }
288
289        b.add(key.to_ref(), value.as_slice()).await.unwrap();
290    }
291    let output = b.finish().await.unwrap();
292    output.writer_output.await.unwrap().unwrap();
293    output.sst_info.sst_info
294}
295
296/// Generate a test table from the given `kv_iter` and put the kv value to `sstable_store`
297pub async fn gen_test_sstable<B: AsRef<[u8]> + Clone + Default + Eq>(
298    opts: SstableBuilderOptions,
299    object_id: u64,
300    kv_iter: impl Iterator<Item = (FullKey<B>, HummockValue<B>)>,
301    sstable_store: SstableStoreRef,
302) -> (TableHolder, SstableInfo) {
303    let table_id_to_vnode = HashMap::from_iter(vec![(
304        TableId::default().as_raw_id(),
305        VirtualNode::COUNT_FOR_TEST,
306    )]);
307
308    let table_id_to_watermark_serde =
309        HashMap::from_iter(vec![(TableId::default().as_raw_id(), None)]);
310
311    let sst_info = gen_test_sstable_impl::<_, Xor16FilterBuilder>(
312        opts,
313        object_id,
314        kv_iter,
315        sstable_store.clone(),
316        CachePolicy::NotFill,
317        table_id_to_vnode,
318        table_id_to_watermark_serde,
319    )
320    .await;
321
322    (
323        sstable_store
324            .sstable(&sst_info, &mut StoreLocalStatistic::default())
325            .await
326            .unwrap(),
327        sst_info,
328    )
329}
330
331pub async fn gen_test_sstable_with_table_ids<B: AsRef<[u8]> + Clone + Default + Eq>(
332    opts: SstableBuilderOptions,
333    object_id: u64,
334    kv_iter: impl Iterator<Item = (FullKey<B>, HummockValue<B>)>,
335    sstable_store: SstableStoreRef,
336    table_ids: Vec<u32>,
337) -> (TableHolder, SstableInfo) {
338    let table_id_to_vnode = table_ids
339        .iter()
340        .map(|table_id| (*table_id, VirtualNode::COUNT_FOR_TEST))
341        .collect();
342    let table_id_to_watermark_serde = table_ids.iter().map(|table_id| (*table_id, None)).collect();
343
344    let sst_info = gen_test_sstable_impl::<_, Xor16FilterBuilder>(
345        opts,
346        object_id,
347        kv_iter,
348        sstable_store.clone(),
349        CachePolicy::NotFill,
350        table_id_to_vnode,
351        table_id_to_watermark_serde,
352    )
353    .await;
354
355    (
356        sstable_store
357            .sstable(&sst_info, &mut StoreLocalStatistic::default())
358            .await
359            .unwrap(),
360        sst_info,
361    )
362}
363
364/// Generate a test table from the given `kv_iter` and put the kv value to `sstable_store`
365pub async fn gen_test_sstable_info<B: AsRef<[u8]> + Clone + Default + Eq>(
366    opts: SstableBuilderOptions,
367    object_id: u64,
368    kv_iter: impl IntoIterator<Item = (FullKey<B>, HummockValue<B>)>,
369    sstable_store: SstableStoreRef,
370) -> SstableInfo {
371    let table_id_to_vnode = HashMap::from_iter(vec![(
372        TableId::default().as_raw_id(),
373        VirtualNode::COUNT_FOR_TEST,
374    )]);
375
376    let table_id_to_watermark_serde =
377        HashMap::from_iter(vec![(TableId::default().as_raw_id(), None)]);
378
379    gen_test_sstable_impl::<_, BlockedXor16FilterBuilder>(
380        opts,
381        object_id,
382        kv_iter,
383        sstable_store,
384        CachePolicy::NotFill,
385        table_id_to_vnode,
386        table_id_to_watermark_serde,
387    )
388    .await
389}
390
391/// Generate a test table from the given `kv_iter` and put the kv value to `sstable_store`
392pub async fn gen_test_sstable_with_range_tombstone(
393    opts: SstableBuilderOptions,
394    object_id: u64,
395    kv_iter: impl Iterator<Item = (FullKey<Vec<u8>>, HummockValue<Vec<u8>>)>,
396    sstable_store: SstableStoreRef,
397) -> SstableInfo {
398    let table_id_to_vnode = HashMap::from_iter(vec![(
399        TableId::default().as_raw_id(),
400        VirtualNode::COUNT_FOR_TEST,
401    )]);
402
403    let table_id_to_watermark_serde =
404        HashMap::from_iter(vec![(TableId::default().as_raw_id(), None)]);
405
406    gen_test_sstable_impl::<_, Xor16FilterBuilder>(
407        opts,
408        object_id,
409        kv_iter,
410        sstable_store.clone(),
411        CachePolicy::Fill(Hint::Normal),
412        table_id_to_vnode,
413        table_id_to_watermark_serde,
414    )
415    .await
416}
417
418/// Generates a user key with table id 0 and the given `table_key`
419pub fn test_user_key(table_key: impl AsRef<[u8]>) -> UserKey<Vec<u8>> {
420    UserKey::for_test(TableId::default(), table_key.as_ref().to_vec())
421}
422
423/// Generates a user key with table id 0 and table key format of `key_test_{idx * 2}`
424pub fn test_user_key_of(idx: usize) -> UserKey<Vec<u8>> {
425    let mut table_key = VirtualNode::ZERO.to_be_bytes().to_vec();
426    table_key.extend_from_slice(format!("key_test_{:05}", idx * 2).as_bytes());
427    UserKey::for_test(TableId::default(), table_key)
428}
429
430/// Generates a full key with table id 0 and epoch 123. User key is created with `test_user_key_of`.
431pub fn test_key_of(idx: usize) -> FullKey<Vec<u8>> {
432    FullKey {
433        user_key: test_user_key_of(idx),
434        epoch_with_gap: EpochWithGap::new_from_epoch(test_epoch(1)),
435    }
436}
437
438/// The value of an index in the test table
439pub fn test_value_of(idx: usize) -> Vec<u8> {
440    "23332333"
441        .as_bytes()
442        .iter()
443        .cycle()
444        .cloned()
445        .take(idx % 100 + 1) // so that the table is not too big
446        .collect_vec()
447}
448
449/// Generates a test table used in almost all table-related tests. Developers may verify the
450/// correctness of their implementations by comparing the got value and the expected value
451/// generated by `test_key_of` and `test_value_of`.
452pub async fn gen_default_test_sstable(
453    opts: SstableBuilderOptions,
454    object_id: u64,
455    sstable_store: SstableStoreRef,
456) -> (TableHolder, SstableInfo) {
457    gen_test_sstable(
458        opts,
459        object_id,
460        (0..TEST_KEYS_COUNT).map(|i| (test_key_of(i), HummockValue::put(test_value_of(i)))),
461        sstable_store,
462    )
463    .await
464}
465
466pub async fn count_stream(mut i: impl StateStoreIter) -> usize {
467    let mut c: usize = 0;
468    while i.try_next().await.unwrap().is_some() {
469        c += 1
470    }
471    c
472}
473
474pub fn create_small_table_cache() -> Arc<LruCache<HummockSstableObjectId, Box<Sstable>>> {
475    Arc::new(LruCache::new(1, 4, 0))
476}
477
478pub async fn hybrid_cache_for_test<K, V>() -> HybridCache<K, V>
479where
480    K: HybridKey,
481    V: HybridValue,
482{
483    HybridCacheBuilder::new()
484        .memory(10)
485        .storage()
486        .build()
487        .await
488        .unwrap()
489}
490
491#[derive(Default, Clone)]
492pub struct StateStoreTestReadOptions {
493    pub table_id: TableId,
494    pub prefix_hint: Option<Bytes>,
495    pub prefetch_options: PrefetchOptions,
496    pub cache_policy: CachePolicy,
497    pub read_committed: bool,
498    pub retention_seconds: Option<u32>,
499    pub read_version_from_backup: bool,
500}
501
502impl StateStoreTestReadOptions {
503    fn get_read_epoch(&self, epoch: u64) -> HummockReadEpoch {
504        if self.read_version_from_backup {
505            HummockReadEpoch::Backup(epoch)
506        } else if self.read_committed {
507            HummockReadEpoch::Committed(epoch)
508        } else {
509            HummockReadEpoch::NoWait(epoch)
510        }
511    }
512}
513
514pub type ReadOptions = StateStoreTestReadOptions;
515
516impl From<StateStoreTestReadOptions> for crate::store::ReadOptions {
517    fn from(val: StateStoreTestReadOptions) -> crate::store::ReadOptions {
518        crate::store::ReadOptions {
519            prefix_hint: val.prefix_hint,
520            prefetch_options: val.prefetch_options,
521            cache_policy: val.cache_policy,
522            retention_seconds: val.retention_seconds,
523        }
524    }
525}
526
527pub trait StateStoreReadTestExt: StateStore {
528    /// Point gets a value from the state store.
529    /// The result is based on a snapshot corresponding to the given `epoch`.
530    /// Both full key and the value are returned.
531    fn get_keyed_row(
532        &self,
533        key: TableKey<Bytes>,
534        epoch: u64,
535        read_options: ReadOptions,
536    ) -> impl StorageFuture<'_, Option<StateStoreKeyedRow>>;
537
538    /// Point gets a value from the state store.
539    /// The result is based on a snapshot corresponding to the given `epoch`.
540    /// Only the value is returned.
541    fn get(
542        &self,
543        key: TableKey<Bytes>,
544        epoch: u64,
545        read_options: ReadOptions,
546    ) -> impl StorageFuture<'_, Option<Bytes>> {
547        self.get_keyed_row(key, epoch, read_options)
548            .map_ok(|v| v.map(|(_, v)| v))
549    }
550
551    /// Opens and returns an iterator for given `prefix_hint` and `full_key_range`
552    /// Internally, `prefix_hint` will be used to for checking `bloom_filter` and
553    /// `full_key_range` used for iter. (if the `prefix_hint` not None, it should be be included
554    /// in `key_range`) The returned iterator will iterate data based on a snapshot
555    /// corresponding to the given `epoch`.
556    fn iter(
557        &self,
558        key_range: TableKeyRange,
559        epoch: u64,
560        read_options: ReadOptions,
561    ) -> impl StorageFuture<'_, <<Self as StateStore>::ReadSnapshot as StateStoreRead>::Iter>;
562
563    fn rev_iter(
564        &self,
565        key_range: TableKeyRange,
566        epoch: u64,
567        read_options: ReadOptions,
568    ) -> impl StorageFuture<'_, <<Self as StateStore>::ReadSnapshot as StateStoreRead>::RevIter>;
569
570    fn scan(
571        &self,
572        key_range: TableKeyRange,
573        epoch: u64,
574        limit: Option<usize>,
575        read_options: ReadOptions,
576    ) -> impl StorageFuture<'_, Vec<StateStoreKeyedRow>>;
577}
578
579impl<S: StateStore> StateStoreReadTestExt for S {
580    async fn get_keyed_row(
581        &self,
582        key: TableKey<Bytes>,
583        epoch: u64,
584        read_options: ReadOptions,
585    ) -> StorageResult<Option<StateStoreKeyedRow>> {
586        let snapshot = self
587            .new_read_snapshot(
588                read_options.get_read_epoch(epoch),
589                NewReadSnapshotOptions {
590                    table_id: read_options.table_id,
591                },
592            )
593            .await?;
594        snapshot
595            .on_key_value(key, read_options.into(), |key, value| {
596                Ok((key.copy_into(), Bytes::copy_from_slice(value)))
597            })
598            .await
599    }
600
601    async fn iter(
602        &self,
603        key_range: TableKeyRange,
604        epoch: u64,
605        read_options: ReadOptions,
606    ) -> StorageResult<<<Self as StateStore>::ReadSnapshot as StateStoreRead>::Iter> {
607        let snapshot = self
608            .new_read_snapshot(
609                read_options.get_read_epoch(epoch),
610                NewReadSnapshotOptions {
611                    table_id: read_options.table_id,
612                },
613            )
614            .await?;
615        snapshot.iter(key_range, read_options.into()).await
616    }
617
618    async fn rev_iter(
619        &self,
620        key_range: TableKeyRange,
621        epoch: u64,
622        read_options: ReadOptions,
623    ) -> StorageResult<<<Self as StateStore>::ReadSnapshot as StateStoreRead>::RevIter> {
624        let snapshot = self
625            .new_read_snapshot(
626                read_options.get_read_epoch(epoch),
627                NewReadSnapshotOptions {
628                    table_id: read_options.table_id,
629                },
630            )
631            .await?;
632        snapshot.rev_iter(key_range, read_options.into()).await
633    }
634
635    async fn scan(
636        &self,
637        key_range: TableKeyRange,
638        epoch: u64,
639        limit: Option<usize>,
640        read_options: ReadOptions,
641    ) -> StorageResult<Vec<StateStoreKeyedRow>> {
642        const MAX_INITIAL_CAP: usize = 1024;
643        let limit = limit.unwrap_or(usize::MAX);
644        let mut ret = Vec::with_capacity(min(limit, MAX_INITIAL_CAP));
645        let mut iter = self.iter(key_range, epoch, read_options).await?;
646        while let Some((key, value)) = iter.try_next().await? {
647            ret.push((key.copy_into(), Bytes::copy_from_slice(value)))
648        }
649        Ok(ret)
650    }
651}
652
653pub trait StateStoreGetTestExt: StateStoreGet {
654    fn get(
655        &self,
656        key: TableKey<Bytes>,
657        read_options: ReadOptions,
658    ) -> impl StorageFuture<'_, Option<Bytes>>;
659}
660
661impl<S: StateStoreGet> StateStoreGetTestExt for S {
662    async fn get(
663        &self,
664        key: TableKey<Bytes>,
665        read_options: ReadOptions,
666    ) -> StorageResult<Option<Bytes>> {
667        self.on_key_value(key, read_options.into(), |_, value| {
668            Ok(Bytes::copy_from_slice(value))
669        })
670        .await
671    }
672}