Skip to content

Commit

Permalink
Merge pull request #42 from instaclustr/optimizer-optimization
Browse files Browse the repository at this point in the history
Resolving PR issues
  • Loading branch information
rukai authored Oct 11, 2023
2 parents 36007a1 + 4eb6a22 commit 4e93d60
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 21 deletions.
6 changes: 2 additions & 4 deletions brro-compressor/src/compressor/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ impl Constant {
/// Receives a data stream and generates a Constant
pub fn decompress(data: &[u8]) -> Self {
let config = BinConfig::get();
match bincode::decode_from_slice(data, config) {
Ok((constant, _)) => constant,
Err(e) => panic!("{e}"),
}
let (ct, _) = bincode::decode_from_slice(data, config).unwrap();
ct
}

/// This function transforms the structure into a Binary stream
Expand Down
6 changes: 2 additions & 4 deletions brro-compressor/src/compressor/fft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,8 @@ impl FFT {
/// Decompresses data
pub fn decompress(data: &[u8]) -> Self {
let config = BinConfig::get();
match bincode::decode_from_slice(data, config) {
Ok((fft, _)) => fft,
Err(e) => panic!("{e}")
}
let (fft, _) = bincode::decode_from_slice(data, config).unwrap();
fft
}

pub fn to_bytes(self) -> Vec<u8> {
Expand Down
2 changes: 1 addition & 1 deletion brro-compressor/src/compressor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Compressor {
Compressor::Noop => noop(data),
Compressor::FFT => fft(data, 8, 0.0, 10.0), // TODO: Remove the placeholders
Compressor::Constant => constant(data),
_ => noop(data),
_ => todo!(),
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions brro-compressor/src/compressor/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ impl Noop {
/// Receives a data stream and generates a Noop
pub fn decompress(data: &[u8]) -> Self {
let config = BinConfig::get();
match bincode::decode_from_slice(data, config) {
Ok((constant, _)) => constant,
Err(e) => panic!("{e}"),
}
let (noop, _) = bincode::decode_from_slice(data, config).unwrap();
noop
}

/// This function transforms the structure in a Binary stream to be appended to the frame
Expand Down
6 changes: 2 additions & 4 deletions brro-compressor/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ impl CompressedStream {
/// Gets a binary stream and generates a Compressed Stream
pub fn from_bytes(data: &[u8]) -> Self {
let config = BinConfig::get();
match bincode::decode_from_slice(data, config) {
Ok((compressed_stream, _)) => compressed_stream,
Err(e) => panic!("{e}")
}
let (compressed_stream, _) = bincode::decode_from_slice(data, config).unwrap();
compressed_stream
}
}

Expand Down
5 changes: 1 addition & 4 deletions brro-compressor/src/utils/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ pub struct Files {

/// Read a file by chunks and processes the chunks
pub fn process_by_chunk(file_path: &Path) -> Result<(), std::io::Error> {
let mut file = match std::fs::File::open(file_path) {
Ok(f) => f,
Err(e) => panic!("{}", e)
};
let mut file = std::fs::File::open(file_path)?;

let mut list_of_chunks = Vec::new();
// 64KB at a time, assuming 64Bit samples, ~1024 samples.
Expand Down

0 comments on commit 4e93d60

Please sign in to comment.