Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoder can take byte buffer instead of mmap + offset #261

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion rs/compression/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ anyhow.workspace = true
bitvec = "1"
env_logger.workspace = true
log.workspace = true
memmap2.workspace = true
tempdir.workspace = true
utils.workspace = true
3 changes: 1 addition & 2 deletions rs/compression/src/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::fs::File;
use std::io::BufWriter;

use anyhow::Result;
use memmap2::Mmap;

pub trait IntSeqEncoder {
/// Creates an encoder
Expand All @@ -23,7 +22,7 @@ pub trait IntSeqEncoder {

pub trait IntSeqDecoderIterator: Iterator {
/// Creates a decoder
fn new_decoder(mmap: &Mmap, offset: usize, size: usize) -> Self
fn new_decoder(encoded_data: &[u8]) -> Self
where
Self: Sized;

Expand Down
9 changes: 3 additions & 6 deletions rs/compression/src/noc/noc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use std::fs::File;
use std::io::{BufWriter, Write};

use anyhow::Result;
use memmap2::Mmap;
use utils::io::wrap_write;
use utils::mem::{get_ith_val_from_raw_ptr, transmute_u8_to_slice};
use utils::mem::get_ith_val_from_raw_ptr;

use crate::compression::{IntSeqDecoderIterator, IntSeqEncoder};

Expand Down Expand Up @@ -56,11 +55,9 @@ pub struct PlainDecoderIterator {
}

impl IntSeqDecoderIterator for PlainDecoderIterator {
fn new_decoder(mmap: &Mmap, offset: usize, size: usize) -> Self {
let slice = &mmap[offset..offset + size * size_of::<u64>()];
let encoded_data = transmute_u8_to_slice::<u64>(slice);
fn new_decoder(encoded_data: &[u8]) -> Self {
Self {
size,
size: encoded_data.len(),
cur_index: 0,
encoded_data_ptr: encoded_data.as_ptr() as *const u64,
}
Expand Down
Loading