Push mtzqmmrlmzzx #34
@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
use memmap2::MmapMut;
|
||||
|
||||
use crate::format::{HEADER_SIZE, finalize_pciv, parse_overflow_entry};
|
||||
use crate::format::{byte_count_nonzero, byte_sum, HEADER_SIZE, finalize_pciv, parse_overflow_entry};
|
||||
use crate::reader::PersistentCompactIntVec;
|
||||
|
||||
pub struct PersistentCompactIntVecBuilder {
|
||||
@@ -148,6 +148,12 @@ impl IntSlice for PersistentCompactIntVecBuilder {
|
||||
fn overflow_entries(&self) -> impl Iterator<Item = (usize, u32)> + '_ {
|
||||
self.overflow.iter().map(|(&k, &v)| (k, v))
|
||||
}
|
||||
fn sum(&self) -> u64 {
|
||||
byte_sum(&self.mmap[HEADER_SIZE..HEADER_SIZE + self.n], self.overflow.values().copied())
|
||||
}
|
||||
fn count_nonzero(&self) -> u64 {
|
||||
byte_count_nonzero(&self.mmap[HEADER_SIZE..HEADER_SIZE + self.n])
|
||||
}
|
||||
}
|
||||
|
||||
impl IntSliceMut for PersistentCompactIntVecBuilder {
|
||||
|
||||
@@ -80,6 +80,7 @@ impl IntSlice for MemoryIntVec {
|
||||
fn overflow_entries(&self) -> impl Iterator<Item = (usize, u32)> + '_ {
|
||||
self.overflow.iter().map(|(&k, &v)| (k, v))
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = u32> + '_ { self.iter() }
|
||||
fn sum(&self) -> u64 { self.sum() }
|
||||
fn count_nonzero(&self) -> u64 { self.count_nonzero() }
|
||||
}
|
||||
|
||||
@@ -363,6 +363,9 @@ impl IntSlice for PersistentCompactIntVec {
|
||||
fn overflow_entries(&self) -> impl Iterator<Item = (usize, u32)> + '_ {
|
||||
(0..self.n_overflow).map(|i| (self.data_slot(i), self.data_value(i)))
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = u32> + '_ { self.iter() }
|
||||
fn sum(&self) -> u64 { self.sum() }
|
||||
fn count_nonzero(&self) -> u64 { self.count_nonzero() }
|
||||
}
|
||||
|
||||
impl<'a> IntoIterator for &'a PersistentCompactIntVec {
|
||||
|
||||
Reference in New Issue
Block a user