Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
suxiaogang223 committed Jan 16, 2025
1 parent a1e954a commit 59e9857
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/encoding/integer/rle_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,21 @@ impl<N: NInt, S: EncodingSign> RleV1Encoder<N, S> {
///
/// 1. `RleV1EncoderState::Empty`:
/// - Transitions to the `Literal` state with the given value as the first element in the buffer.
/// 2. `RleV1EncoderState::Literal`:
/// - The value is added to the buffer. If the buffer length reaches `MAX_LITERAL_LENGTH`, the buffer is written out
/// and the state transitions to `Empty`.
/// - If the buffer length is at least `MIN_RUN_LENGTH` and the values in the buffer form a valid run (i.e., the deltas
/// between consecutive values are consistent and within the allowed range), the state transitions to `Run`.
/// - Otherwise, the state remains `Literal`.
/// 3. `RleV1EncoderState::Run`:
///
/// 2. `RleV1EncoderState::Run`:
/// - If the value continues the current run (i.e., it matches the expected value based on the run's delta and length),
/// the run length is incremented. If the run length reaches `MAX_RUN_LENGTH`, the run is written out and the state
/// transitions to `Empty`.
/// - If the value does not continue the current run, the existing run is written out and the state transitions to
/// `Literal` with the new value as the first element in the buffer.
///
/// 3. `RleV1EncoderState::Literal`:
/// - The value is added to the buffer. If the buffer length reaches `MAX_LITERAL_LENGTH`, the buffer is written out
/// and the state transitions to `Empty`.
/// - If the buffer length is at least `MIN_RUN_LENGTH` and the values in the buffer form a valid run (i.e., the deltas
/// between consecutive values are consistent and within the allowed range), the state transitions to `Run`.
/// - Otherwise, the state remains `Literal`.
///
fn process_value(&mut self, value: N) {
match &mut self.state {
RleV1EncodingState::Empty => {
Expand Down Expand Up @@ -271,12 +272,12 @@ impl<N: NInt, S: EncodingSign> RleV1Encoder<N, S> {
/// 1. `RleV1EncoderState::Empty`:
/// - No action is needed as there are no buffered values to write.
///
/// 2. `RleV1EncoderState::Run`:
/// - Writes out the current run of values.
///
/// 3. `RleV1EncoderState::Literal`:
/// - Writes out the buffered literal values.
///
/// 2. `RleV1EncoderState::Run`:
/// - Writes out the current run of values.
///
/// After calling this function, the encoder state will be reset to `Empty`.
fn flush(&mut self) {
let state = std::mem::take(&mut self.state);
Expand Down

0 comments on commit 59e9857

Please sign in to comment.