-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
81 additions
and
98 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
use crate::buffer::PageId; | ||
use crate::catalog::{Column, DataType, Schema, SchemaRef}; | ||
use std::sync::Arc; | ||
|
||
// 数据页的大小(字节) | ||
pub const BUSTUBX_PAGE_SIZE: usize = 4096; | ||
pub const INVALID_PAGE_ID: PageId = std::u32::MAX; | ||
|
||
// table heap对应的缓冲池的大小(页) | ||
pub const TABLE_HEAP_BUFFER_POOL_SIZE: usize = 100; | ||
|
||
pub type TransactionId = u32; | ||
|
||
lazy_static::lazy_static! { | ||
pub static ref EMPTY_SCHEMA_REF: SchemaRef = Arc::new(Schema::empty()); | ||
|
||
pub static ref INSERT_OUTPUT_SCHEMA_REF: SchemaRef = Arc::new(Schema::new( | ||
vec![Column::new("insert_rows".to_string(), DataType::Int32)] | ||
)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
pub mod config; | ||
pub mod rid; | ||
mod scalar; | ||
pub mod table_ref; | ||
mod table_ref; | ||
pub mod util; | ||
|
||
pub use scalar::ScalarValue; | ||
pub use table_ref::TableReference; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
use comfy_table::Cell; | ||
|
||
use crate::{catalog::Schema, storage::Tuple}; | ||
use crate::storage::Tuple; | ||
|
||
pub fn pretty_format_tuples(tuples: &Vec<Tuple>) -> comfy_table::Table { | ||
let mut table = comfy_table::Table::new(); | ||
table.load_preset("||--+-++| ++++++"); | ||
|
||
pub fn print_tuples(tuples: &Vec<Tuple>, schema: &Schema) { | ||
if tuples.is_empty() { | ||
return; | ||
return table; | ||
} | ||
let mut headers = Vec::new(); | ||
for column in &schema.columns { | ||
headers.push(Cell::new(column.name.clone())); | ||
|
||
let schema = &tuples[0].schema; | ||
|
||
let mut header = Vec::new(); | ||
for column in schema.columns.iter() { | ||
header.push(Cell::new(column.name.clone())); | ||
} | ||
let mut table = comfy_table::Table::new(); | ||
table.set_header(headers); | ||
table.set_header(header); | ||
|
||
for tuple in tuples { | ||
let mut row = Vec::new(); | ||
tuple.all_values(schema).iter().for_each(|v| { | ||
row.push(Cell::new(format!("{v:?}"))); | ||
}); | ||
table.add_row(row); | ||
let mut cells = Vec::new(); | ||
for value in tuple.data.iter() { | ||
cells.push(Cell::new(format!("{value}"))); | ||
} | ||
table.add_row(cells); | ||
} | ||
|
||
println!("{}", table); | ||
table | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.