diff --git a/bustubx/src/catalog/schema.rs b/bustubx/src/catalog/schema.rs index 459251e..7a1af92 100644 --- a/bustubx/src/catalog/schema.rs +++ b/bustubx/src/catalog/schema.rs @@ -1,4 +1,5 @@ use super::column::{Column, ColumnRef}; +use crate::error::BustubxResult; use std::sync::Arc; pub type SchemaRef = Arc; @@ -27,12 +28,13 @@ impl Schema { Self { columns: vec![] } } - pub fn from_schemas(schemas: Vec) -> Self { + pub fn try_merge(schemas: impl IntoIterator) -> BustubxResult { + // TODO check column conflict let mut columns = Vec::new(); for schema in schemas { columns.extend(schema.columns); } - Self { columns } + Ok(Self { columns }) } pub fn copy_schema(from: SchemaRef, key_attrs: &[u32]) -> Self { diff --git a/bustubx/src/planner/expr/mod.rs b/bustubx/src/planner/expr/mod.rs index a9c5693..8401e1a 100644 --- a/bustubx/src/planner/expr/mod.rs +++ b/bustubx/src/planner/expr/mod.rs @@ -37,7 +37,7 @@ impl Expr { (left_tuple.clone(), left_schema.clone()), (right_tuple.clone(), right_schema.clone()), ]); - let schema = Schema::from_schemas(vec![left_schema.clone(), right_schema.clone()]); + let schema = Schema::try_merge(vec![left_schema.clone(), right_schema.clone()]).unwrap(); self.evaluate(Some(&tuple), Some(&schema)) } } diff --git a/bustubx/src/planner/physical_plan/nested_loop_join.rs b/bustubx/src/planner/physical_plan/nested_loop_join.rs index 191a2dd..2dff3ef 100644 --- a/bustubx/src/planner/physical_plan/nested_loop_join.rs +++ b/bustubx/src/planner/physical_plan/nested_loop_join.rs @@ -35,10 +35,11 @@ impl PhysicalNestedLoopJoin { } } pub fn output_schema(&self) -> Schema { - Schema::from_schemas(vec![ + Schema::try_merge(vec![ self.left_input.output_schema(), self.right_input.output_schema(), ]) + .unwrap() } } impl VolcanoExecutor for PhysicalNestedLoopJoin { diff --git a/bustubx/src/storage/index.rs b/bustubx/src/storage/index.rs index b52b525..2029aa7 100644 --- a/bustubx/src/storage/index.rs +++ b/bustubx/src/storage/index.rs @@ -98,7 +98,7 @@ impl BPlusTreeIndex { .fetch_page_mut(leaf_page_id) .expect("Leaf page can not be fetched"); let mut leaf_page = - BPlusTreeLeafPage::from_bytes(&page.data, &self.index_metadata.key_schema); + BPlusTreeLeafPage::from_bytes(&page.data, self.index_metadata.key_schema.clone()); leaf_page.insert(key.clone(), rid, &self.index_metadata.key_schema); let mut curr_page = BPlusTreePage::Leaf(leaf_page); @@ -120,7 +120,7 @@ impl BPlusTreeIndex { .fetch_page_mut(page_id) .expect("Page can not be fetched"); let mut tree_page = - BPlusTreePage::from_bytes(&page.data, &self.index_metadata.key_schema); + BPlusTreePage::from_bytes(&page.data, self.index_metadata.key_schema.clone()); self.buffer_pool_manager.unpin_page(page_id, false); tree_page.insert_internalkv(internalkv, &self.index_metadata.key_schema); @@ -133,8 +133,10 @@ impl BPlusTreeIndex { .new_page() .expect("can not new root page"); let new_root_page_id = new_root_page.page_id; - let mut new_internal_page = - BPlusTreeInternalPage::new(self.internal_max_size as u32); + let mut new_internal_page = BPlusTreeInternalPage::new( + self.index_metadata.key_schema.clone(), + self.internal_max_size, + ); // internal page第一个kv对的key为空 new_internal_page.insert( @@ -176,7 +178,7 @@ impl BPlusTreeIndex { .fetch_page_mut(leaf_page_id) .expect("Leaf page can not be fetched"); let mut leaf_page = - BPlusTreeLeafPage::from_bytes(&page.data, &self.index_metadata.key_schema); + BPlusTreeLeafPage::from_bytes(&page.data, self.index_metadata.key_schema.clone()); leaf_page.delete(key, &self.index_metadata.key_schema); let mut curr_page = BPlusTreePage::Leaf(leaf_page); @@ -196,7 +198,7 @@ impl BPlusTreeIndex { .expect("Left sibling page can not be fetched"); let mut left_sibling_tree_page = BPlusTreePage::from_bytes( &left_sibling_page.data, - &self.index_metadata.key_schema, + self.index_metadata.key_schema.clone(), ); if left_sibling_tree_page.can_borrow() { // 从左兄弟借一个,返回父节点需要更新的key @@ -258,7 +260,7 @@ impl BPlusTreeIndex { .expect("Parent page can not be fetched"); let mut parent_internal_page = BPlusTreeInternalPage::from_bytes( &parent_page.data, - &self.index_metadata.key_schema, + self.index_metadata.key_schema.clone(), ); parent_internal_page.replace_key( &old_internal_key, @@ -282,7 +284,7 @@ impl BPlusTreeIndex { .expect("Right sibling page can not be fetched"); let mut right_sibling_tree_page = BPlusTreePage::from_bytes( &right_sibling_page.data, - &self.index_metadata.key_schema, + self.index_metadata.key_schema.clone(), ); if right_sibling_tree_page.can_borrow() { // 从右兄弟借一个,返回父节点需要更新的key @@ -331,7 +333,7 @@ impl BPlusTreeIndex { .expect("Parent page can not be fetched"); let mut parent_internal_page = BPlusTreeInternalPage::from_bytes( &parent_page.data, - &self.index_metadata.key_schema, + self.index_metadata.key_schema.clone(), ); parent_internal_page.replace_key( &old_internal_key, @@ -355,7 +357,7 @@ impl BPlusTreeIndex { .expect("Left sibling page can not be fetched"); let mut left_sibling_tree_page = BPlusTreePage::from_bytes( &left_sibling_page.data, - &self.index_metadata.key_schema, + self.index_metadata.key_schema.clone(), ); // 将当前页向左兄弟合入 match left_sibling_tree_page { @@ -404,7 +406,7 @@ impl BPlusTreeIndex { .expect("Parent page can not be fetched"); let mut parent_internal_page = BPlusTreeInternalPage::from_bytes( &parent_page.data, - &self.index_metadata.key_schema, + self.index_metadata.key_schema.clone(), ); parent_internal_page.delete_page_id(deleted_page_id); // 根节点只有一个子节点(叶子)时,则叶子节点成为新的根节点 @@ -431,7 +433,7 @@ impl BPlusTreeIndex { .expect("Right sibling page can not be fetched"); let mut right_sibling_tree_page = BPlusTreePage::from_bytes( &right_sibling_page.data, - &self.index_metadata.key_schema, + self.index_metadata.key_schema.clone(), ); // 将右兄弟合入当前页 match right_sibling_tree_page { @@ -476,7 +478,7 @@ impl BPlusTreeIndex { .expect("Parent page can not be fetched"); let mut parent_internal_page = BPlusTreeInternalPage::from_bytes( &parent_page.data, - &self.index_metadata.key_schema, + self.index_metadata.key_schema.clone(), ); parent_internal_page.delete_page_id(deleted_page_id); // 根节点只有一个子节点(叶子)时,则叶子节点成为新的根节点 @@ -513,7 +515,8 @@ impl BPlusTreeIndex { .expect("failed to start new tree"); let new_page_id = new_page.page_id; - let mut leaf_page = BPlusTreeLeafPage::new(self.leaf_max_size as u32); + let mut leaf_page = + BPlusTreeLeafPage::new(self.index_metadata.key_schema.clone(), self.leaf_max_size); leaf_page.insert(key.clone(), rid, &self.index_metadata.key_schema); new_page.data = leaf_page.to_bytes(); @@ -542,7 +545,7 @@ impl BPlusTreeIndex { .fetch_page_mut(leaf_page_id) .expect("Leaf page can not be fetched"); let leaf_page = - BPlusTreeLeafPage::from_bytes(&leaf_page.data, &self.index_metadata.key_schema); + BPlusTreeLeafPage::from_bytes(&leaf_page.data, self.index_metadata.key_schema.clone()); let result = leaf_page.look_up(key, &self.index_metadata.key_schema); self.buffer_pool_manager.unpin_page(leaf_page_id, false); return result; @@ -558,7 +561,7 @@ impl BPlusTreeIndex { .expect("Root page can not be fetched"); let mut curr_page_id = curr_page.page_id; let mut curr_page = - BPlusTreePage::from_bytes(&curr_page.data, &self.index_metadata.key_schema); + BPlusTreePage::from_bytes(&curr_page.data, self.index_metadata.key_schema.clone()); // 找到leaf page loop { @@ -573,8 +576,10 @@ impl BPlusTreeIndex { .buffer_pool_manager .fetch_page(next_page_id) .expect("Next page can not be fetched"); - let next_page = - BPlusTreePage::from_bytes(&next_page.data, &self.index_metadata.key_schema); + let next_page = BPlusTreePage::from_bytes( + &next_page.data, + self.index_metadata.key_schema.clone(), + ); curr_page_id = next_page_id; curr_page = next_page; } @@ -597,7 +602,10 @@ impl BPlusTreeIndex { let new_page_id = new_page.page_id; // 拆分kv对 - let mut new_leaf_page = BPlusTreeLeafPage::new(self.leaf_max_size as u32); + let mut new_leaf_page = BPlusTreeLeafPage::new( + self.index_metadata.key_schema.clone(), + self.leaf_max_size, + ); new_leaf_page.batch_insert( leaf_page.split_off(leaf_page.current_size as usize / 2), &self.index_metadata.key_schema, @@ -620,8 +628,10 @@ impl BPlusTreeIndex { let new_page_id = new_page.page_id; // 拆分kv对 - let mut new_internal_page = - BPlusTreeInternalPage::new(self.internal_max_size as u32); + let mut new_internal_page = BPlusTreeInternalPage::new( + self.index_metadata.key_schema.clone(), + self.internal_max_size as u32, + ); new_internal_page.batch_insert( internal_page.split_off(internal_page.current_size as usize / 2), &self.index_metadata.key_schema, @@ -649,8 +659,10 @@ impl BPlusTreeIndex { .buffer_pool_manager .fetch_page(parent_page_id) .expect("Parent page can not be fetched"); - let parent_page = - BPlusTreeInternalPage::from_bytes(&parent_page.data, &self.index_metadata.key_schema); + let parent_page = BPlusTreeInternalPage::from_bytes( + &parent_page.data, + self.index_metadata.key_schema.clone(), + ); self.buffer_pool_manager.unpin_page(parent_page_id, false); return parent_page.sibling_page_ids(child_page_id); } @@ -666,7 +678,7 @@ impl BPlusTreeIndex { .fetch_page(page_id) .expect("Page can not be fetched"); let mut curr_page = - BPlusTreePage::from_bytes(&curr_page.data, &self.index_metadata.key_schema); + BPlusTreePage::from_bytes(&curr_page.data, self.index_metadata.key_schema.clone()); self.buffer_pool_manager.unpin_page(page_id, false); loop { match curr_page { @@ -676,8 +688,10 @@ impl BPlusTreeIndex { .buffer_pool_manager .fetch_page(page_id) .expect("Page can not be fetched"); - curr_page = - BPlusTreePage::from_bytes(&page.data, &self.index_metadata.key_schema); + curr_page = BPlusTreePage::from_bytes( + &page.data, + self.index_metadata.key_schema.clone(), + ); self.buffer_pool_manager.unpin_page(page_id, false); } BPlusTreePage::Leaf(leaf_page) => { @@ -694,7 +708,7 @@ impl BPlusTreeIndex { .fetch_page(page_id) .expect("Page can not be fetched"); let mut curr_page = - BPlusTreePage::from_bytes(&curr_page.data, &self.index_metadata.key_schema); + BPlusTreePage::from_bytes(&curr_page.data, self.index_metadata.key_schema.clone()); self.buffer_pool_manager.unpin_page(page_id, false); loop { match curr_page { @@ -704,8 +718,10 @@ impl BPlusTreeIndex { .buffer_pool_manager .fetch_page(page_id) .expect("Page can not be fetched"); - curr_page = - BPlusTreePage::from_bytes(&page.data, &self.index_metadata.key_schema); + curr_page = BPlusTreePage::from_bytes( + &page.data, + self.index_metadata.key_schema.clone(), + ); self.buffer_pool_manager.unpin_page(page_id, false); } BPlusTreePage::Leaf(leaf_page) => { @@ -738,7 +754,7 @@ impl BPlusTreeIndex { .fetch_page(page_id) .expect("Page can not be fetched"); let curr_page = - BPlusTreePage::from_bytes(&page.data, &self.index_metadata.key_schema); + BPlusTreePage::from_bytes(&page.data, self.index_metadata.key_schema.clone()); self.buffer_pool_manager.unpin_page(page_id, false); match curr_page { BPlusTreePage::Internal(internal_page) => { diff --git a/bustubx/src/storage/index_page.rs b/bustubx/src/storage/index_page.rs index 3d7655a..f8fd080 100644 --- a/bustubx/src/storage/index_page.rs +++ b/bustubx/src/storage/index_page.rs @@ -1,6 +1,7 @@ use std::mem::size_of; use super::{page::PageId, Tuple}; +use crate::catalog::SchemaRef; use crate::{ catalog::Schema, common::{ @@ -20,14 +21,14 @@ pub enum BPlusTreePage { Leaf(BPlusTreeLeafPage), } impl BPlusTreePage { - pub fn from_bytes(raw: &[u8; BUSTUBX_PAGE_SIZE], key_schema: &Schema) -> Self { + pub fn from_bytes(raw: &[u8; BUSTUBX_PAGE_SIZE], key_schema: SchemaRef) -> Self { let page_type = BPlusTreePageType::from_bytes(&raw[0..4].try_into().unwrap()); return match page_type { BPlusTreePageType::InternalPage => { - Self::Internal(BPlusTreeInternalPage::from_bytes(raw, key_schema)) + Self::Internal(BPlusTreeInternalPage::from_bytes(raw, key_schema.clone())) } BPlusTreePageType::LeafPage => { - Self::Leaf(BPlusTreeLeafPage::from_bytes(raw, key_schema)) + Self::Leaf(BPlusTreeLeafPage::from_bytes(raw, key_schema.clone())) } BPlusTreePageType::InvalidPage => panic!("Invalid b+ tree page type"), }; @@ -113,6 +114,7 @@ pub type LeafKV = (Tuple, Rid); */ #[derive(Debug, Clone)] pub struct BPlusTreeInternalPage { + pub schema: SchemaRef, pub page_type: BPlusTreePageType, pub current_size: u32, // 能存放的最大kv数 @@ -121,8 +123,9 @@ pub struct BPlusTreeInternalPage { pub array: Vec, } impl BPlusTreeInternalPage { - pub fn new(max_size: u32) -> Self { + pub fn new(schema: SchemaRef, max_size: u32) -> Self { Self { + schema, page_type: BPlusTreePageType::InternalPage, current_size: 0, max_size, @@ -323,7 +326,7 @@ impl BPlusTreeInternalPage { } } - pub fn from_bytes(raw: &[u8; BUSTUBX_PAGE_SIZE], key_schema: &Schema) -> Self { + pub fn from_bytes(raw: &[u8; BUSTUBX_PAGE_SIZE], key_schema: SchemaRef) -> Self { let page_type = BPlusTreePageType::from_bytes(&raw[0..4].try_into().unwrap()); let current_size = u32::from_be_bytes(raw[4..8].try_into().unwrap()); let max_size = u32::from_be_bytes(raw[8..12].try_into().unwrap()); @@ -339,6 +342,7 @@ impl BPlusTreeInternalPage { array.push((key, page_id)); } Self { + schema: key_schema, page_type, current_size, max_size, @@ -406,6 +410,7 @@ impl BPlusTreeInternalPage { */ #[derive(Debug, Clone)] pub struct BPlusTreeLeafPage { + pub schema: SchemaRef, pub page_type: BPlusTreePageType, pub current_size: u32, // 能存放的最大kv数 @@ -414,8 +419,9 @@ pub struct BPlusTreeLeafPage { pub array: Vec, } impl BPlusTreeLeafPage { - pub fn new(max_size: u32) -> Self { + pub fn new(schema: SchemaRef, max_size: u32) -> Self { Self { + schema, page_type: BPlusTreePageType::LeafPage, current_size: 0, max_size, @@ -423,7 +429,7 @@ impl BPlusTreeLeafPage { array: Vec::with_capacity(max_size as usize), } } - pub fn from_bytes(raw: &[u8; BUSTUBX_PAGE_SIZE], key_schema: &Schema) -> Self { + pub fn from_bytes(raw: &[u8; BUSTUBX_PAGE_SIZE], key_schema: SchemaRef) -> Self { let page_type = BPlusTreePageType::from_bytes(&raw[0..4].try_into().unwrap()); let current_size = u32::from_be_bytes(raw[4..8].try_into().unwrap()); let max_size = u32::from_be_bytes(raw[8..12].try_into().unwrap()); @@ -440,6 +446,7 @@ impl BPlusTreeLeafPage { array.push((key, rid)); } Self { + schema: key_schema, page_type, current_size, max_size, @@ -589,14 +596,15 @@ mod tests { Tuple, }, }; + use std::sync::Arc; #[test] pub fn test_internal_page_from_to_bytes() { - let key_schema = Schema::new(vec![ + let key_schema = Arc::new(Schema::new(vec![ Column::new("a".to_string(), DataType::Int8), Column::new("a".to_string(), DataType::Int16), - ]); - let mut ori_page = BPlusTreeInternalPage::new(5); + ])); + let mut ori_page = BPlusTreeInternalPage::new(key_schema.clone(), 5); ori_page.insert(Tuple::empty(3), 0, &key_schema); ori_page.insert(Tuple::new(vec![1, 1, 1]), 1, &key_schema); ori_page.insert(Tuple::new(vec![2, 2, 2]), 2, &key_schema); @@ -604,7 +612,7 @@ mod tests { let bytes = ori_page.to_bytes(); - let new_page = BPlusTreeInternalPage::from_bytes(&bytes, &key_schema); + let new_page = BPlusTreeInternalPage::from_bytes(&bytes, key_schema.clone()); assert_eq!(new_page.page_type, BPlusTreePageType::InternalPage); assert_eq!(new_page.current_size, 3); assert_eq!(new_page.max_size, 5); @@ -618,18 +626,18 @@ mod tests { #[test] pub fn test_leaf_page_from_to_bytes() { - let key_schema = Schema::new(vec![ + let key_schema = Arc::new(Schema::new(vec![ Column::new("a".to_string(), DataType::Int8), Column::new("a".to_string(), DataType::Int16), - ]); - let mut ori_page = BPlusTreeLeafPage::new(5); + ])); + let mut ori_page = BPlusTreeLeafPage::new(key_schema.clone(), 5); ori_page.insert(Tuple::new(vec![1, 1, 1]), Rid::new(1, 1), &key_schema); ori_page.insert(Tuple::new(vec![2, 2, 2]), Rid::new(2, 2), &key_schema); assert_eq!(ori_page.current_size, 2); let bytes = ori_page.to_bytes(); - let new_page = BPlusTreeLeafPage::from_bytes(&bytes, &key_schema); + let new_page = BPlusTreeLeafPage::from_bytes(&bytes, key_schema.clone()); assert_eq!(new_page.page_type, BPlusTreePageType::LeafPage); assert_eq!(new_page.current_size, 2); assert_eq!(new_page.max_size, 5); @@ -641,11 +649,11 @@ mod tests { #[test] pub fn test_internal_page_insert() { - let key_schema = Schema::new(vec![ + let key_schema = Arc::new(Schema::new(vec![ Column::new("a".to_string(), DataType::Int8), Column::new("b".to_string(), DataType::Int16), - ]); - let mut internal_page = BPlusTreeInternalPage::new(3); + ])); + let mut internal_page = BPlusTreeInternalPage::new(key_schema.clone(), 3); internal_page.insert(Tuple::empty(key_schema.fixed_len()), 0, &key_schema); internal_page.insert(Tuple::new(vec![2, 2, 2]), 2, &key_schema); internal_page.insert(Tuple::new(vec![1, 1, 1]), 1, &key_schema); @@ -660,11 +668,11 @@ mod tests { #[test] pub fn test_leaf_page_insert() { - let key_schema = Schema::new(vec![ + let key_schema = Arc::new(Schema::new(vec![ Column::new("a".to_string(), DataType::Int8), Column::new("b".to_string(), DataType::Int16), - ]); - let mut leaf_page = BPlusTreeLeafPage::new(3); + ])); + let mut leaf_page = BPlusTreeLeafPage::new(key_schema.clone(), 3); leaf_page.insert(Tuple::new(vec![2, 2, 2]), Rid::new(2, 2), &key_schema); leaf_page.insert(Tuple::new(vec![1, 1, 1]), Rid::new(1, 1), &key_schema); leaf_page.insert(Tuple::new(vec![3, 3, 3]), Rid::new(3, 3), &key_schema); @@ -679,11 +687,11 @@ mod tests { #[test] pub fn test_internal_page_look_up() { - let key_schema = Schema::new(vec![ + let key_schema = Arc::new(Schema::new(vec![ Column::new("a".to_string(), DataType::Int8), Column::new("b".to_string(), DataType::Int16), - ]); - let mut internal_page = BPlusTreeInternalPage::new(5); + ])); + let mut internal_page = BPlusTreeInternalPage::new(key_schema.clone(), 5); internal_page.insert(Tuple::empty(key_schema.fixed_len()), 0, &key_schema); internal_page.insert(Tuple::new(vec![2, 2, 2]), 2, &key_schema); internal_page.insert(Tuple::new(vec![1, 1, 1]), 1, &key_schema); @@ -703,7 +711,7 @@ mod tests { 4 ); - let mut internal_page = BPlusTreeInternalPage::new(2); + let mut internal_page = BPlusTreeInternalPage::new(key_schema.clone(), 2); internal_page.insert(Tuple::empty(key_schema.fixed_len()), 0, &key_schema); internal_page.insert(Tuple::new(vec![1, 1, 1]), 1, &key_schema); @@ -723,11 +731,11 @@ mod tests { #[test] pub fn test_leaf_page_look_up() { - let key_schema = Schema::new(vec![ + let key_schema = Arc::new(Schema::new(vec![ Column::new("a".to_string(), DataType::Int8), Column::new("b".to_string(), DataType::Int16), - ]); - let mut leaf_page = BPlusTreeLeafPage::new(5); + ])); + let mut leaf_page = BPlusTreeLeafPage::new(key_schema.clone(), 5); leaf_page.insert(Tuple::new(vec![2, 2, 2]), Rid::new(2, 2), &key_schema); leaf_page.insert(Tuple::new(vec![1, 1, 1]), Rid::new(1, 1), &key_schema); leaf_page.insert(Tuple::new(vec![3, 3, 3]), Rid::new(3, 3), &key_schema); @@ -750,7 +758,7 @@ mod tests { None ); - let mut leaf_page = BPlusTreeLeafPage::new(2); + let mut leaf_page = BPlusTreeLeafPage::new(key_schema.clone(), 2); leaf_page.insert(Tuple::new(vec![2, 2, 2]), Rid::new(2, 2), &key_schema); leaf_page.insert(Tuple::new(vec![1, 1, 1]), Rid::new(1, 1), &key_schema); assert_eq!( @@ -773,11 +781,11 @@ mod tests { #[test] pub fn test_internal_page_delete() { - let key_schema = Schema::new(vec![ + let key_schema = Arc::new(Schema::new(vec![ Column::new("a".to_string(), DataType::Int8), Column::new("b".to_string(), DataType::Int16), - ]); - let mut internal_page = BPlusTreeInternalPage::new(5); + ])); + let mut internal_page = BPlusTreeInternalPage::new(key_schema.clone(), 5); internal_page.insert(Tuple::empty(key_schema.fixed_len()), 0, &key_schema); internal_page.insert(Tuple::new(vec![2, 2, 2]), 2, &key_schema); internal_page.insert(Tuple::new(vec![1, 1, 1]), 1, &key_schema); @@ -806,11 +814,11 @@ mod tests { #[test] pub fn test_leaf_page_delete() { - let key_schema = Schema::new(vec![ + let key_schema = Arc::new(Schema::new(vec![ Column::new("a".to_string(), DataType::Int8), Column::new("b".to_string(), DataType::Int16), - ]); - let mut leaf_page = BPlusTreeLeafPage::new(5); + ])); + let mut leaf_page = BPlusTreeLeafPage::new(key_schema.clone(), 5); leaf_page.insert(Tuple::new(vec![2, 2, 2]), Rid::new(2, 2), &key_schema); leaf_page.insert(Tuple::new(vec![1, 1, 1]), Rid::new(1, 1), &key_schema); leaf_page.insert(Tuple::new(vec![3, 3, 3]), Rid::new(3, 3), &key_schema); diff --git a/bustubx/src/storage/tuple.rs b/bustubx/src/storage/tuple.rs index b6cec4e..b8bd151 100644 --- a/bustubx/src/storage/tuple.rs +++ b/bustubx/src/storage/tuple.rs @@ -1,4 +1,4 @@ -use crate::catalog::ColumnRef; +use crate::catalog::{ColumnRef, SchemaRef}; use crate::{catalog::Schema, common::config::TransactionId, common::ScalarValue}; #[derive(Debug, Clone, Copy, PartialEq, Eq)]