Skip to content

Commit

Permalink
chore: codefmt
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Nov 10, 2024
1 parent ee53f4d commit e177776
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
17 changes: 13 additions & 4 deletions src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<TableName, TableCatalog>;
Expand Down Expand Up @@ -657,7 +657,11 @@ impl<T: Transaction> IndexImplParams<'_, T> {
Ok(val)
}

fn get_tuple_by_id(&self, id_builder: &mut TupleIdBuilder, tuple_id: &TupleId) -> Result<Option<Tuple>, DatabaseError> {
fn get_tuple_by_id(
&self,
id_builder: &mut TupleIdBuilder,
tuple_id: &TupleId,
) -> Result<Option<Tuple>, DatabaseError> {
let key = TableCodec::encode_tuple_key(self.table_name, tuple_id)?;

Ok(self.tx.get(&key)?.map(|bytes| {
Expand Down Expand Up @@ -1000,7 +1004,9 @@ impl<T: Transaction> 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));
}
Expand Down Expand Up @@ -1063,7 +1069,10 @@ impl<T: Transaction> 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();
Expand Down
2 changes: 1 addition & 1 deletion src/storage/rocksdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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> {
Expand Down
12 changes: 9 additions & 3 deletions src/storage/table_codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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![
Expand Down Expand Up @@ -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
);

Expand Down
4 changes: 2 additions & 2 deletions src/types/tuple.rs
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit e177776

Please sign in to comment.