mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-10-30 01:38:49 +01:00
Use the new Lru
This commit is contained in:
parent
759b9b1546
commit
86d5e6d9ff
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -3312,15 +3312,6 @@ version = "0.4.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
|
||||
|
||||
[[package]]
|
||||
name = "lru"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904"
|
||||
dependencies = [
|
||||
"hashbrown 0.14.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lzma-rs"
|
||||
version = "0.3.0"
|
||||
@ -3584,7 +3575,6 @@ dependencies = [
|
||||
"json-depth-checker",
|
||||
"levenshtein_automata",
|
||||
"liquid",
|
||||
"lru",
|
||||
"maplit",
|
||||
"md5",
|
||||
"meili-snap",
|
||||
|
21
Cargo.toml
21
Cargo.toml
@ -44,26 +44,5 @@ opt-level = 3
|
||||
[profile.dev.package.roaring]
|
||||
opt-level = 3
|
||||
|
||||
[profile.dev.package.lindera-ipadic-builder]
|
||||
opt-level = 3
|
||||
[profile.dev.package.encoding]
|
||||
opt-level = 3
|
||||
[profile.dev.package.yada]
|
||||
opt-level = 3
|
||||
|
||||
[profile.release.package.lindera-ipadic-builder]
|
||||
opt-level = 3
|
||||
[profile.release.package.encoding]
|
||||
opt-level = 3
|
||||
[profile.release.package.yada]
|
||||
opt-level = 3
|
||||
|
||||
[profile.bench.package.lindera-ipadic-builder]
|
||||
opt-level = 3
|
||||
[profile.bench.package.encoding]
|
||||
opt-level = 3
|
||||
[profile.bench.package.yada]
|
||||
opt-level = 3
|
||||
|
||||
[patch.crates-io]
|
||||
roaring = { git = "https://github.com/RoaringBitmap/roaring-rs", branch = "clone-iter-slice" }
|
||||
|
@ -40,7 +40,6 @@ heed = { version = "0.20.3", default-features = false, features = [
|
||||
indexmap = { version = "2.2.6", features = ["serde"] }
|
||||
json-depth-checker = { path = "../json-depth-checker" }
|
||||
levenshtein_automata = { version = "0.2.1", features = ["fst_automaton"] }
|
||||
lru = "0.12.3"
|
||||
memchr = "2.5.0"
|
||||
memmap2 = "0.9.4"
|
||||
obkv = { git = "https://github.com/kerollmops/obkv", branch = "unsized-kvreader" }
|
||||
|
@ -2,16 +2,16 @@ use std::mem;
|
||||
use std::num::NonZeroUsize;
|
||||
|
||||
use grenad::{MergeFunction, Sorter};
|
||||
use lru::LruCache;
|
||||
use roaring::RoaringBitmap;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use super::lru::Lru;
|
||||
use crate::update::del_add::{DelAdd, KvWriterDelAdd};
|
||||
use crate::CboRoaringBitmapCodec;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CboCachedSorter<MF> {
|
||||
cache: lru::LruCache<SmallVec<[u8; 20]>, DelAddRoaringBitmap>,
|
||||
cache: Lru<SmallVec<[u8; 20]>, DelAddRoaringBitmap>,
|
||||
sorter: Sorter<MF>,
|
||||
deladd_buffer: Vec<u8>,
|
||||
cbo_buffer: Vec<u8>,
|
||||
@ -22,7 +22,7 @@ pub struct CboCachedSorter<MF> {
|
||||
impl<MF> CboCachedSorter<MF> {
|
||||
pub fn new(cap: NonZeroUsize, sorter: Sorter<MF>) -> Self {
|
||||
CboCachedSorter {
|
||||
cache: lru::LruCache::new(cap),
|
||||
cache: Lru::new(cap),
|
||||
sorter,
|
||||
deladd_buffer: Vec::new(),
|
||||
cbo_buffer: Vec::new(),
|
||||
@ -171,7 +171,7 @@ impl<MF: MergeFunction> CboCachedSorter<MF> {
|
||||
}
|
||||
|
||||
pub fn into_sorter(mut self) -> grenad::Result<Sorter<MF>, MF::Error> {
|
||||
let default_arc = LruCache::new(NonZeroUsize::MIN);
|
||||
let default_arc = Lru::new(NonZeroUsize::MIN);
|
||||
for (key, deladd) in mem::replace(&mut self.cache, default_arc) {
|
||||
self.write_entry(key, deladd)?;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use std::num::NonZeroUsize;
|
||||
use hashbrown::hash_map::{DefaultHashBuilder, Entry};
|
||||
use hashbrown::HashMap;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Lru<K, V, S = DefaultHashBuilder> {
|
||||
lookup: HashMap<K, usize, S>,
|
||||
storage: FixedSizeList<LruNode<K, V>>,
|
||||
@ -104,17 +105,20 @@ impl<K, V> Iterator for IntoIter<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct LruNode<K, V> {
|
||||
key: K,
|
||||
value: V,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct FixedSizeListNode<T> {
|
||||
prev: usize,
|
||||
next: usize,
|
||||
data: T,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct FixedSizeList<T> {
|
||||
nodes: Box<[Option<FixedSizeListNode<T>>]>,
|
||||
// An un-ordered set of indices that are not in use in `nodes`.
|
@ -1,5 +1,6 @@
|
||||
mod cache;
|
||||
mod faceted;
|
||||
mod lru;
|
||||
mod searchable;
|
||||
|
||||
use std::fs::File;
|
||||
@ -9,12 +10,9 @@ use grenad::Merger;
|
||||
use rayon::iter::IntoParallelIterator;
|
||||
pub use searchable::*;
|
||||
|
||||
use crate::{
|
||||
update::{GrenadParameters, MergeDeladdCboRoaringBitmaps},
|
||||
GlobalFieldsIdsMap, Index, Result,
|
||||
};
|
||||
|
||||
use super::DocumentChange;
|
||||
use crate::update::{GrenadParameters, MergeDeladdCboRoaringBitmaps};
|
||||
use crate::{GlobalFieldsIdsMap, Index, Result};
|
||||
|
||||
pub trait DocidsExtractor {
|
||||
fn run_extraction(
|
||||
|
@ -10,7 +10,6 @@ mod document_change;
|
||||
mod extract;
|
||||
pub mod indexer;
|
||||
mod items_pool;
|
||||
mod lru;
|
||||
mod merger;
|
||||
mod top_level_map;
|
||||
mod word_fst_builder;
|
||||
|
Loading…
Reference in New Issue
Block a user