2025-01-19 19:24:12 -05:00
|
|
|
// Copyright (c) 2022-2025 Alex Chi Z
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
2022-12-24 10:11:06 -05:00
|
|
|
#![allow(unused_variables)] // TODO(you): remove this lint after implementing this mod
|
|
|
|
|
#![allow(dead_code)] // TODO(you): remove this lint after implementing this mod
|
|
|
|
|
|
|
|
|
|
use anyhow::Result;
|
|
|
|
|
|
2022-12-24 18:25:41 -05:00
|
|
|
use super::StorageIterator;
|
2022-12-24 10:11:06 -05:00
|
|
|
|
|
|
|
|
/// Merges two iterators of different types into one. If the two iterators have the same key, only
|
|
|
|
|
/// produce the key once and prefer the entry from A.
|
|
|
|
|
pub struct TwoMergeIterator<A: StorageIterator, B: StorageIterator> {
|
|
|
|
|
a: A,
|
|
|
|
|
b: B,
|
|
|
|
|
// Add fields as need
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:59:08 +08:00
|
|
|
impl<
|
2025-03-09 16:11:52 -04:00
|
|
|
A: 'static + StorageIterator,
|
|
|
|
|
B: 'static + for<'a> StorageIterator<KeyType<'a> = A::KeyType<'a>>,
|
|
|
|
|
> TwoMergeIterator<A, B>
|
2024-01-25 10:59:08 +08:00
|
|
|
{
|
2022-12-24 10:11:06 -05:00
|
|
|
pub fn create(a: A, b: B) -> Result<Self> {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:59:08 +08:00
|
|
|
impl<
|
2025-03-09 16:11:52 -04:00
|
|
|
A: 'static + StorageIterator,
|
|
|
|
|
B: 'static + for<'a> StorageIterator<KeyType<'a> = A::KeyType<'a>>,
|
|
|
|
|
> StorageIterator for TwoMergeIterator<A, B>
|
2024-01-25 10:59:08 +08:00
|
|
|
{
|
2024-01-28 15:17:53 +08:00
|
|
|
type KeyType<'a> = A::KeyType<'a>;
|
2024-01-25 10:59:08 +08:00
|
|
|
|
2024-01-28 15:17:53 +08:00
|
|
|
fn key(&self) -> Self::KeyType<'_> {
|
2022-12-24 10:11:06 -05:00
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn value(&self) -> &[u8] {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn is_valid(&self) -> bool {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn next(&mut self) -> Result<()> {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
}
|