Skip to content
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
2 changes: 2 additions & 0 deletions columnar/examples/macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ use std::collections::BTreeMap;

use serde_columnar::columnar;

#[allow(dead_code)]
#[columnar(vec, map, ser, de)]
#[derive(Debug, Clone, PartialEq)]
struct A {
a: u64,
}

#[allow(dead_code)]
#[columnar(vec, map, ser, de)]
#[derive(Debug, Clone, PartialEq)]
struct B {
Expand Down
4 changes: 1 addition & 3 deletions columnar/src/column/bool_rle.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
strategy::{BoolRleDecoder, BoolRleEncoder},
ColumnAttr, ColumnarError, Strategy,
ColumnAttr, ColumnarError,
};

use super::ColumnTrait;
Expand All @@ -19,8 +19,6 @@ impl BoolRleColumn {
}

impl ColumnTrait for BoolRleColumn {
const STRATEGY: Strategy = Strategy::BoolRle;

fn attr(&self) -> ColumnAttr {
self.attr
}
Expand Down
4 changes: 1 addition & 3 deletions columnar/src/column/delta_of_delta.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
strategy::{DeltaOfDeltaDecoder, DeltaOfDeltaEncoder},
ColumnAttr, ColumnarError, Strategy,
ColumnAttr, ColumnarError,
};

use super::ColumnTrait;
Expand All @@ -22,8 +22,6 @@ impl<T> DeltaOfDeltaColumn<T> {
}

impl<T: DeltaOfDeltable> ColumnTrait for DeltaOfDeltaColumn<T> {
const STRATEGY: Strategy = Strategy::DeltaRle;

fn attr(&self) -> ColumnAttr {
self.attr
}
Expand Down
4 changes: 1 addition & 3 deletions columnar/src/column/delta_rle.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
strategy::{DeltaRleDecoder, DeltaRleEncoder},
ColumnAttr, ColumnarError, Strategy,
ColumnAttr, ColumnarError,
};

use super::{rle::Rleable, ColumnTrait};
Expand All @@ -26,8 +26,6 @@ impl<T> ColumnTrait for DeltaRleColumn<T>
where
T: DeltaRleable,
{
const STRATEGY: Strategy = Strategy::DeltaRle;

fn attr(&self) -> ColumnAttr {
self.attr
}
Expand Down
7 changes: 1 addition & 6 deletions columnar/src/column/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ pub mod rle;
pub mod serde_impl;

use crate::{columnar_internal::ColumnarEncoder, ColumnarDecoder, ColumnarError};
use crate::{
BoolRleColumn, DeltaOfDeltaColumn, DeltaRleColumn, DeltaRleable, RleColumn, Rleable, Strategy,
};
use crate::{BoolRleColumn, DeltaOfDeltaColumn, DeltaRleColumn, DeltaRleable, RleColumn, Rleable};
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
use std::ops::DerefMut;

pub trait ColumnTrait {
const STRATEGY: Strategy;
fn attr(&self) -> ColumnAttr;
fn encode(&self) -> Result<Vec<u8>, ColumnarError>;
fn decode(bytes: &[u8]) -> Result<Self, ColumnarError>
Expand Down Expand Up @@ -100,8 +97,6 @@ impl<T> ColumnTrait for GenericColumn<T>
where
T: Serialize + for<'de> Deserialize<'de>,
{
const STRATEGY: Strategy = Strategy::None;

fn attr(&self) -> ColumnAttr {
ColumnAttr::empty()
}
Expand Down
4 changes: 1 addition & 3 deletions columnar/src/column/rle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};

use crate::{
strategy::{AnyRleDecoder, AnyRleEncoder},
ColumnAttr, ColumnarError, Strategy,
ColumnAttr, ColumnarError,
};

use super::ColumnTrait;
Expand All @@ -27,8 +27,6 @@ impl<T> ColumnTrait for RleColumn<T>
where
T: Rleable,
{
const STRATEGY: Strategy = Strategy::Rle;

fn len(&self) -> usize {
self.data.len()
}
Expand Down
2 changes: 1 addition & 1 deletion columnar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ use serde::{Deserialize, Serialize};
mod strategy;
pub use strategy::{
AnyRleDecoder, AnyRleEncoder, BoolRleDecoder, BoolRleEncoder, DeltaOfDeltaDecoder,
DeltaOfDeltaEncoder, DeltaRleDecoder, DeltaRleEncoder, Strategy,
DeltaOfDeltaEncoder, DeltaRleDecoder, DeltaRleEncoder,
};
mod wrap;
pub use wrap::{ColumnarMap, ColumnarVec};
Expand Down
27 changes: 0 additions & 27 deletions columnar/src/strategy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,4 @@ pub use rle::{
DeltaOfDeltaEncoder, DeltaRleDecoder, DeltaRleEncoder,
};

use crate::ColumnarError;

/// The enum of Strategy includes `Rle`/`BoolRle`/`DeltaRle`
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum Strategy {
Rle = 1,
BoolRle,
DeltaRle,
DeltaOfDelta,
None,
}

impl TryFrom<u8> for Strategy {
type Error = ColumnarError;

fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
1 => Ok(Strategy::Rle),
2 => Ok(Strategy::BoolRle),
3 => Ok(Strategy::DeltaRle),
4 => Ok(Strategy::DeltaOfDelta),
_ => Err(ColumnarError::InvalidStrategy(value)),
}
}
}

pub const MAX_RLE_COUNT: usize = 1e9 as usize;
6 changes: 3 additions & 3 deletions columnar_derive/src/serde/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ impl<'a, P: WithGenericsBorrow> ToTokens for DeTypeGenerics<'a, P> {
pub fn split_with_de_lifetime<P: WithGenericsBorrow>(
params: &P,
) -> (
DeImplGenerics<P>,
DeTypeGenerics<P>,
syn::TypeGenerics,
DeImplGenerics<'_, P>,
DeTypeGenerics<'_, P>,
syn::TypeGenerics<'_>,
Option<&syn::WhereClause>,
) {
let de_impl_generics = DeImplGenerics(params);
Expand Down
Loading