pub use thrift::protocol::TCompactOutputProtocol;
use thrift::protocol::{TInputProtocol, TOutputProtocol};
pub trait TSerializable: Sized {
fn read_from_in_protocol<T: TInputProtocol>(i_prot: &mut T) -> thrift::Result<Self>;
fn write_to_out_protocol<T: TOutputProtocol>(&self, o_prot: &mut T) -> thrift::Result<()>;
}
#[cfg(test)]
mod tests {
use crate::{
basic::Type,
file::page_index::{column_index::ColumnIndexMetaData, index_reader::decode_column_index},
};
#[test]
pub fn read_boolean_list_field_type() {
let bytes = vec![
0x19, 0x21, 2, 1, 0x19, 0x28, 1, 0, 0, 0x19, 0x28, 1, 1, 0, 0x15, 0, 0,
];
let index = decode_column_index(&bytes, Type::BOOLEAN).unwrap();
let index = match index {
ColumnIndexMetaData::BOOLEAN(index) => index,
_ => panic!("expected boolean column index"),
};
assert!(!index.is_null_page(0));
assert!(index.is_null_page(1));
assert!(!index.min_value(0).unwrap()); assert!(index.max_value(0).unwrap()); assert!(index.min_value(1).is_none());
assert!(index.max_value(1).is_none());
}
#[test]
pub fn read_boolean_list_alternative_encoding() {
let bytes = vec![
0x19, 0x22, 0, 1, 0x19, 0x28, 1, 0, 0, 0x19, 0x28, 1, 1, 0, 0x15, 0, 0,
];
let index = decode_column_index(&bytes, Type::BOOLEAN).unwrap();
let index = match index {
ColumnIndexMetaData::BOOLEAN(index) => index,
_ => panic!("expected boolean column index"),
};
assert!(!index.is_null_page(0));
assert!(index.is_null_page(1));
assert!(!index.min_value(0).unwrap()); assert!(index.max_value(0).unwrap()); assert!(index.min_value(1).is_none());
assert!(index.max_value(1).is_none());
}
}