diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 75c58fb3..22dfb671 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -10,6 +10,7 @@ use crate::serdes::ReferenceTables; use crate::storage::table_codec::TableCodec; use crate::types::index::{Index, IndexId, IndexMetaRef, IndexType}; use crate::types::tuple::{Tuple, TupleId}; +use crate::types::tuple_builder::TupleIdBuilder; use crate::types::value::DataValue; use crate::types::{ColumnId, LogicalType}; use crate::utils::lru::SharedLruCache; @@ -21,7 +22,6 @@ use std::ops::SubAssign; use std::sync::Arc; use std::{mem, slice}; use ulid::Generator; -use crate::types::tuple_builder::TupleIdBuilder; pub(crate) type StatisticsMetaCache = SharedLruCache<(TableName, IndexId), StatisticsMeta>; pub(crate) type TableCache = SharedLruCache; @@ -657,7 +657,11 @@ impl IndexImplParams<'_, T> { Ok(val) } - fn get_tuple_by_id(&self, id_builder: &mut TupleIdBuilder, tuple_id: &TupleId) -> Result, DatabaseError> { + fn get_tuple_by_id( + &self, + id_builder: &mut TupleIdBuilder, + tuple_id: &TupleId, + ) -> Result, DatabaseError> { let key = TableCodec::encode_tuple_key(self.table_name, tuple_id)?; Ok(self.tx.get(&key)?.map(|bytes| { @@ -1000,7 +1004,9 @@ impl Iter for IndexIter<'_, T> { continue; } Self::limit_sub(&mut self.limit); - let tuple = self.inner.index_lookup(&bytes, &mut self.id_builder, &self.params)?; + let tuple = self + .inner + .index_lookup(&bytes, &mut self.id_builder, &self.params)?; return Ok(Some(tuple)); } @@ -1063,7 +1069,10 @@ impl Iter for IndexIter<'_, T> { Range::Eq(mut val) => { val = self.params.try_cast(val)?; - match self.inner.eq_to_res(&val, &mut self.id_builder, &self.params)? { + match self + .inner + .eq_to_res(&val, &mut self.id_builder, &self.params)? + { IndexResult::Tuple(tuple) => { if Self::offset_move(&mut self.offset) { return self.next_tuple(); diff --git a/src/storage/rocksdb.rs b/src/storage/rocksdb.rs index 94dfe984..85648ae0 100644 --- a/src/storage/rocksdb.rs +++ b/src/storage/rocksdb.rs @@ -141,6 +141,7 @@ mod test { }; use crate::types::index::{IndexMeta, IndexType}; use crate::types::tuple::Tuple; + use crate::types::tuple_builder::TupleIdBuilder; use crate::types::value::DataValue; use crate::types::LogicalType; use crate::utils::lru::SharedLruCache; @@ -149,7 +150,6 @@ mod test { use std::hash::RandomState; use std::sync::Arc; use tempfile::TempDir; - use crate::types::tuple_builder::TupleIdBuilder; #[test] fn test_in_rocksdb_storage_works_with_data() -> Result<(), DatabaseError> { diff --git a/src/storage/table_codec.rs b/src/storage/table_codec.rs index b547fcb0..cbcb8199 100644 --- a/src/storage/table_codec.rs +++ b/src/storage/table_codec.rs @@ -5,13 +5,13 @@ use crate::serdes::{ReferenceSerialization, ReferenceTables}; use crate::storage::{TableCache, Transaction}; use crate::types::index::{Index, IndexId, IndexMeta, IndexType}; use crate::types::tuple::{Schema, Tuple, TupleId}; +use crate::types::tuple_builder::TupleIdBuilder; use crate::types::value::DataValue; use crate::types::LogicalType; use bytes::Bytes; use integer_encoding::FixedInt; use lazy_static::lazy_static; use std::io::{Cursor, Read, Seek, SeekFrom, Write}; -use crate::types::tuple_builder::TupleIdBuilder; const BOUND_MIN_TAG: u8 = 0; const BOUND_MAX_TAG: u8 = 1; @@ -499,6 +499,7 @@ mod tests { use crate::storage::Storage; use crate::types::index::{Index, IndexMeta, IndexType}; use crate::types::tuple::Tuple; + use crate::types::tuple_builder::TupleIdBuilder; use crate::types::value::DataValue; use crate::types::LogicalType; use bytes::Bytes; @@ -510,7 +511,6 @@ mod tests { use std::slice; use std::sync::Arc; use ulid::Ulid; - use crate::types::tuple_builder::TupleIdBuilder; fn build_table_codec() -> TableCatalog { let columns = vec![ @@ -548,7 +548,13 @@ mod tests { let mut id_builder = TupleIdBuilder::new(schema); debug_assert_eq!( - TableCodec::decode_tuple(&table_catalog.types(), &mut id_builder, &[0, 1], schema, &bytes), + TableCodec::decode_tuple( + &table_catalog.types(), + &mut id_builder, + &[0, 1], + schema, + &bytes + ), tuple ); diff --git a/src/types/tuple.rs b/src/types/tuple.rs index cb4ddd98..18da935c 100644 --- a/src/types/tuple.rs +++ b/src/types/tuple.rs @@ -1,12 +1,12 @@ use crate::catalog::ColumnRef; use crate::errors::DatabaseError; +use crate::types::tuple_builder::TupleIdBuilder; use crate::types::value::DataValue; use crate::types::LogicalType; use comfy_table::{Cell, Table}; use itertools::Itertools; use lazy_static::lazy_static; use std::sync::Arc; -use crate::types::tuple_builder::TupleIdBuilder; lazy_static! { pub static ref EMPTY_TUPLE: Tuple = { @@ -168,13 +168,13 @@ pub fn create_table(schema: &Schema, tuples: &[Tuple]) -> Table { mod tests { use crate::catalog::{ColumnCatalog, ColumnDesc, ColumnRef}; use crate::types::tuple::Tuple; + use crate::types::tuple_builder::TupleIdBuilder; use crate::types::value::{DataValue, Utf8Type}; use crate::types::LogicalType; use itertools::Itertools; use rust_decimal::Decimal; use sqlparser::ast::CharLengthUnits; use std::sync::Arc; - use crate::types::tuple_builder::TupleIdBuilder; #[test] fn test_tuple_serialize_to_and_deserialize_from() {