mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
Reduce the lru key size from 20 to 8 bytes
This commit is contained in:
parent
86d5e6d9ff
commit
52d7f3ed1c
@ -11,7 +11,7 @@ use crate::CboRoaringBitmapCodec;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct CboCachedSorter<MF> {
|
pub struct CboCachedSorter<MF> {
|
||||||
cache: Lru<SmallVec<[u8; 20]>, DelAddRoaringBitmap>,
|
cache: Lru<SmallVec<[u8; 8]>, DelAddRoaringBitmap>,
|
||||||
sorter: Sorter<MF>,
|
sorter: Sorter<MF>,
|
||||||
deladd_buffer: Vec<u8>,
|
deladd_buffer: Vec<u8>,
|
||||||
cbo_buffer: Vec<u8>,
|
cbo_buffer: Vec<u8>,
|
||||||
|
@ -59,10 +59,10 @@ impl<K: Clone + Eq + Hash, V, S: BuildHasher> Lru<K, V, S> {
|
|||||||
Entry::Vacant(vac) => {
|
Entry::Vacant(vac) => {
|
||||||
let key = vac.key().clone();
|
let key = vac.key().clone();
|
||||||
if self.storage.is_full() {
|
if self.storage.is_full() {
|
||||||
let idx = self.storage.back_idx();
|
|
||||||
// It's fine to unwrap here because:
|
// It's fine to unwrap here because:
|
||||||
// * the cache capacity is non zero
|
// * the cache capacity is non zero
|
||||||
// * the cache is full
|
// * the cache is full
|
||||||
|
let idx = self.storage.back_idx();
|
||||||
let node = self.storage.move_front(idx).unwrap();
|
let node = self.storage.move_front(idx).unwrap();
|
||||||
let LruNode { key, value } = mem::replace(node, LruNode { key, value });
|
let LruNode { key, value } = mem::replace(node, LruNode { key, value });
|
||||||
vac.insert(idx);
|
vac.insert(idx);
|
||||||
@ -128,8 +128,8 @@ struct FixedSizeList<T> {
|
|||||||
// to find a free place.
|
// to find a free place.
|
||||||
// TODO remove the free list as it is always growing:
|
// TODO remove the free list as it is always growing:
|
||||||
// we cannot remove entries from the map.
|
// we cannot remove entries from the map.
|
||||||
// Also, we probably do not need one of the front and back cursors.
|
|
||||||
free: Vec<usize>,
|
free: Vec<usize>,
|
||||||
|
// TODO Also, we probably do not need one of the front and back cursors.
|
||||||
front: usize,
|
front: usize,
|
||||||
back: usize,
|
back: usize,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user