index/inverted_index/search/fst_apply.rs
1// Copyright 2023 Greptime Team
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
15mod intersection_apply;
16mod keys_apply;
17
18pub use intersection_apply::IntersectionFstApplier;
19pub use keys_apply::KeysFstApplier;
20
21use crate::inverted_index::FstMap;
22
23/// A trait for objects that can process a finite state transducer (FstMap) and return
24/// associated values.
25#[mockall::automock]
26pub trait FstApplier: Send + Sync {
27 /// Retrieves values from an FstMap.
28 ///
29 /// * `fst`: A reference to the FstMap from which the values will be fetched.
30 ///
31 /// Returns a `Vec<u64>`, with each u64 being a value from the FstMap.
32 fn apply(&self, fst: &FstMap) -> Vec<u64>;
33
34 /// Returns the memory usage of the applier.
35 fn memory_usage(&self) -> usize;
36}