Skip to content

Commit

Permalink
Move integer RLE files into new encoding/integer mod
Browse files Browse the repository at this point in the history
  • Loading branch information
Jefffrey committed Sep 29, 2024
1 parent 842acf9 commit a4a8779
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 23 deletions.
21 changes: 21 additions & 0 deletions src/encoding/integer/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

//! Run length encoding & decoding for integers

pub mod rle_v1;
pub mod rle_v2;
11 changes: 6 additions & 5 deletions src/encoding/rle_v1.rs → src/encoding/integer/rle_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ use std::{io::Read, marker::PhantomData};

use snafu::OptionExt;

use crate::error::{OutOfSpecSnafu, Result};

use super::{
util::{read_u8, read_varint_zigzagged, try_read_u8},
EncodingSign, NInt, PrimitiveValueDecoder,
use crate::{
encoding::{
util::{read_u8, read_varint_zigzagged, try_read_u8},
EncodingSign, NInt, PrimitiveValueDecoder,
},
error::{OutOfSpecSnafu, Result},
};

const MAX_RUN_LENGTH: usize = 130;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use snafu::OptionExt;

use crate::{
encoding::{
rle_v2::{EncodingType, MAX_RUN_LENGTH},
integer::rle_v2::{EncodingType, MAX_RUN_LENGTH},
util::{
extract_run_length_from_header, read_ints, read_u8, read_varint_zigzagged,
rle_v2_decode_bit_width, rle_v2_encode_bit_width, write_aligned_packed_ints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use bytes::{BufMut, BytesMut};

use crate::{
encoding::{
rle_v2::{EncodingType, MAX_RUN_LENGTH},
integer::rle_v2::{EncodingType, MAX_RUN_LENGTH},
util::{
extract_run_length_from_header, read_ints, read_u8, rle_v2_decode_bit_width,
rle_v2_encode_bit_width, write_aligned_packed_ints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ use std::{io::Read, marker::PhantomData};
use bytes::BytesMut;

use crate::{
encoding::{
util::{calculate_percentile_bits, try_read_u8},
EncodingSign, NInt, PrimitiveValueDecoder, PrimitiveValueEncoder, VarintSerde,
},
error::{OutOfSpecSnafu, Result},
memory::EstimateMemory,
};
Expand All @@ -31,11 +35,6 @@ use self::{
short_repeat::{read_short_repeat_values, write_short_repeat},
};

use super::{
util::{calculate_percentile_bits, try_read_u8},
EncodingSign, NInt, PrimitiveValueDecoder, PrimitiveValueEncoder, VarintSerde,
};

pub mod delta;
pub mod direct;
pub mod patched_base;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::io::Read;
use bytes::{BufMut, BytesMut};

use crate::{
encoding::{rle_v2::EncodingType, EncodingSign},
encoding::{integer::rle_v2::EncodingType, EncodingSign},
error::{OutOfSpecSnafu, Result},
};

Expand Down
13 changes: 4 additions & 9 deletions src/encoding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use std::{

use arrow::buffer::NullBuffer;
use bytes::Bytes;
use integer::{rle_v1::RleReaderV1, rle_v2::RleReaderV2};
use num::{traits::CheckedShl, PrimInt, Signed};
use snafu::ResultExt;

Expand All @@ -36,21 +37,15 @@ use crate::{
proto::column_encoding::Kind as ProtoColumnKind,
};

use self::{
rle_v1::RleReaderV1,
rle_v2::RleReaderV2,
util::{
get_closest_aligned_bit_width, signed_msb_decode, signed_zigzag_decode,
signed_zigzag_encode,
},
use self::util::{
get_closest_aligned_bit_width, signed_msb_decode, signed_zigzag_decode, signed_zigzag_encode,
};

pub mod boolean;
pub mod byte;
pub mod decimal;
pub mod float;
pub mod rle_v1;
pub mod rle_v2;
pub mod integer;
pub mod timestamp;
mod util;

Expand Down
3 changes: 2 additions & 1 deletion src/writer/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ use bytes::{BufMut, BytesMut};
use crate::{
encoding::{
boolean::BooleanEncoder, byte::ByteRleEncoder, float::FloatValueEncoder,
rle_v2::RleWriterV2, NInt, PrimitiveValueEncoder, SignedEncoding, UnsignedEncoding,
integer::rle_v2::RleWriterV2, NInt, PrimitiveValueEncoder, SignedEncoding,
UnsignedEncoding,
},
error::Result,
memory::EstimateMemory,
Expand Down

0 comments on commit a4a8779

Please sign in to comment.