Skip to content

Commit

Permalink
chore: codefmt
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Oct 7, 2024
1 parent 5e00745 commit a35cd67
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
8 changes: 8 additions & 0 deletions src/serdes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ impl ReferenceTables {
ReferenceTables { tables: vec![] }
}

pub fn is_empty(&self) -> bool {
self.tables.is_empty()
}

pub fn len(&self) -> usize {
self.tables.len()
}

pub fn get(&self, i: usize) -> &TableName {
&self.tables[i]
}
Expand Down
1 change: 1 addition & 0 deletions src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ pub trait Transaction: Sized {
let (key, value) = TableCodec::encode_column(column, &mut reference_tables)?;
self.set(key, value)?;
}
debug_assert_eq!(reference_tables.len(), 1);
table_cache.put(table_name.to_string(), table_catalog);

Ok(table_name)
Expand Down
14 changes: 1 addition & 13 deletions src/storage/table_codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,27 +385,22 @@ impl TableCodec {
#[cfg(test)]
mod tests {
use crate::catalog::{ColumnCatalog, ColumnDesc, ColumnRelation, TableCatalog, TableMeta};
use crate::db::test::build_table;
use crate::errors::DatabaseError;
use crate::serdes::ReferenceTables;
use crate::storage::rocksdb::{RocksStorage, RocksTransaction};
use crate::storage::rocksdb::RocksTransaction;
use crate::storage::table_codec::TableCodec;
use crate::storage::Storage;
use crate::types::index::{Index, IndexMeta, IndexType};
use crate::types::tuple::Tuple;
use crate::types::value::DataValue;
use crate::types::LogicalType;
use crate::utils::lru::ShardingLruCache;
use bytes::Bytes;
use itertools::Itertools;
use rust_decimal::Decimal;
use std::collections::BTreeSet;
use std::hash::RandomState;
use std::io::Cursor;
use std::ops::Bound;
use std::slice;
use std::sync::Arc;
use tempfile::TempDir;

fn build_table_codec() -> TableCatalog {
let columns = vec![
Expand Down Expand Up @@ -506,13 +501,6 @@ mod tests {

#[test]
fn test_table_codec_column() -> Result<(), DatabaseError> {
let temp_dir = TempDir::new().expect("unable to create temporary working directory");
let storage = RocksStorage::new(temp_dir.path())?;
let mut transaction = storage.transaction()?;
let table_cache = Arc::new(ShardingLruCache::new(4, 1, RandomState::new())?);

build_table(&table_cache, &mut transaction)?;

let mut col: ColumnCatalog = ColumnCatalog::new(
"c2".to_string(),
false,
Expand Down

0 comments on commit a35cd67

Please sign in to comment.