Reduce the lru key size from 8 to 12 bytes

This commit is contained in:
Clément Renault 2024-09-25 16:14:13 +02:00
parent 5f53935c8a
commit 3d244451df
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F
2 changed files with 7 additions and 7 deletions

View File

@ -9,7 +9,7 @@ use super::lru::Lru;
use crate::update::del_add::{DelAdd, KvWriterDelAdd};
use crate::CboRoaringBitmapCodec;
const KEY_SIZE: usize = 8;
const KEY_SIZE: usize = 12;
#[derive(Debug)]
pub struct CboCachedSorter<MF> {

View File

@ -121,8 +121,8 @@ struct FixedSizeListNode<T> {
#[derive(Debug)]
struct FixedSizeList<T> {
nodes: Box<[Option<FixedSizeListNode<T>>]>,
/// The first `None` in the nodes.
next_free: usize,
/// Also corresponds to the first `None` in the nodes.
length: usize,
// TODO Also, we probably do not need one of the front and back cursors.
front: usize,
back: usize,
@ -132,7 +132,7 @@ impl<T> FixedSizeList<T> {
fn new(capacity: usize) -> Self {
Self {
nodes: repeat_with(|| None).take(capacity).collect::<Vec<_>>().into_boxed_slice(),
next_free: 0,
length: 0,
front: usize::MAX,
back: usize::MAX,
}
@ -145,7 +145,7 @@ impl<T> FixedSizeList<T> {
#[inline]
fn len(&self) -> usize {
self.next_free
self.length
}
#[inline]
@ -168,8 +168,8 @@ impl<T> FixedSizeList<T> {
if self.is_full() {
None
} else {
let current_free = self.next_free;
self.next_free += 1;
let current_free = self.length;
self.length += 1;
Some(current_free)
}
}