Skip to content

Commit

Permalink
Remove default implemention of PrimitiveValueDecoder::decode
Browse files Browse the repository at this point in the history
  • Loading branch information
Jefffrey committed Sep 28, 2024
1 parent 77ff433 commit 6f8c5d6
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions src/encoding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use snafu::ResultExt;

use crate::{
column::Column,
error::{InvalidColumnEncodingSnafu, IoSnafu, OutOfSpecSnafu, Result},
error::{InvalidColumnEncodingSnafu, IoSnafu, Result},
memory::EstimateMemory,
proto::column_encoding::Kind as ProtoColumnKind,
};
Expand Down Expand Up @@ -78,31 +78,7 @@ where
pub trait PrimitiveValueDecoder<V>: Iterator<Item = Result<V>> {
/// Decode out.len() values into out at a time, failing if it cannot fill
/// the buffer.
///
/// By default it relies on Iterator::next(), but hopefully this can be
/// refactored away when it is properly implemented for all the decoders.
fn decode(&mut self, out: &mut [V]) -> Result<()> {
// TODO: eventually remove this as each decoder implements for themselves
let mut len = 0;
for n in out.iter_mut() {
match self.next() {
Some(r) => {
*n = r?;
len += 1;
}
None => break,
};
}
if len != out.len() {
// TODO: more descriptive error
OutOfSpecSnafu {
msg: "Array length less than expected",
}
.fail()
} else {
Ok(())
}
}
fn decode(&mut self, out: &mut [V]) -> Result<()>;

/// Decode into `out` according to the `true` elements in `present`.
///
Expand Down

0 comments on commit 6f8c5d6

Please sign in to comment.