mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
Reduce the lru key size from 8 to 12 bytes
This commit is contained in:
parent
5f53935c8a
commit
3d244451df
@ -9,7 +9,7 @@ use super::lru::Lru;
|
|||||||
use crate::update::del_add::{DelAdd, KvWriterDelAdd};
|
use crate::update::del_add::{DelAdd, KvWriterDelAdd};
|
||||||
use crate::CboRoaringBitmapCodec;
|
use crate::CboRoaringBitmapCodec;
|
||||||
|
|
||||||
const KEY_SIZE: usize = 8;
|
const KEY_SIZE: usize = 12;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct CboCachedSorter<MF> {
|
pub struct CboCachedSorter<MF> {
|
||||||
|
@ -121,8 +121,8 @@ struct FixedSizeListNode<T> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct FixedSizeList<T> {
|
struct FixedSizeList<T> {
|
||||||
nodes: Box<[Option<FixedSizeListNode<T>>]>,
|
nodes: Box<[Option<FixedSizeListNode<T>>]>,
|
||||||
/// The first `None` in the nodes.
|
/// Also corresponds to the first `None` in the nodes.
|
||||||
next_free: usize,
|
length: usize,
|
||||||
// TODO Also, we probably do not need one of the front and back cursors.
|
// TODO Also, we probably do not need one of the front and back cursors.
|
||||||
front: usize,
|
front: usize,
|
||||||
back: usize,
|
back: usize,
|
||||||
@ -132,7 +132,7 @@ impl<T> FixedSizeList<T> {
|
|||||||
fn new(capacity: usize) -> Self {
|
fn new(capacity: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
nodes: repeat_with(|| None).take(capacity).collect::<Vec<_>>().into_boxed_slice(),
|
nodes: repeat_with(|| None).take(capacity).collect::<Vec<_>>().into_boxed_slice(),
|
||||||
next_free: 0,
|
length: 0,
|
||||||
front: usize::MAX,
|
front: usize::MAX,
|
||||||
back: usize::MAX,
|
back: usize::MAX,
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ impl<T> FixedSizeList<T> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn len(&self) -> usize {
|
fn len(&self) -> usize {
|
||||||
self.next_free
|
self.length
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -168,8 +168,8 @@ impl<T> FixedSizeList<T> {
|
|||||||
if self.is_full() {
|
if self.is_full() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let current_free = self.next_free;
|
let current_free = self.length;
|
||||||
self.next_free += 1;
|
self.length += 1;
|
||||||
Some(current_free)
|
Some(current_free)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user