Create table partial implementation
This commit is contained in:
parent
f973df2ca2
commit
2dd0555174
5 changed files with 98 additions and 32 deletions
|
|
@ -36,10 +36,9 @@ pub const GARBAGE_COLLECTION_INTERMEDIATE_ROWS_FILE_NAME: &'static str = "rows_i
|
|||
|
||||
impl <T>Store<T> {
|
||||
// ===Creation===
|
||||
pub async fn new(table_folder: &str, number_of_columns: usize, primary_column: Column) -> Result<Self>
|
||||
pub async fn new(path_to_table: &Path, number_of_columns: usize, primary_column: Column) -> Result<Self>
|
||||
where T: Encode + Decode + Ord
|
||||
{
|
||||
let path_to_table = Path::new(table_folder);
|
||||
let path_to_rows = path_to_table.join(ROWS_FILE_NAME);
|
||||
DirBuilder::new()
|
||||
.create(path_to_table).await?;
|
||||
|
|
@ -48,7 +47,7 @@ impl <T>Store<T> {
|
|||
let mut indexed_columns = vec![false; number_of_columns];
|
||||
indexed_columns[primary_column as usize] = true;
|
||||
StoreHeader {
|
||||
table_folder: table_folder.to_string(),
|
||||
table_folder: path_to_table.to_path_buf(),
|
||||
number_of_columns,
|
||||
deleted_count: 0,
|
||||
total_count: 0,
|
||||
|
|
@ -225,7 +224,7 @@ mod tests {
|
|||
async fn test_create() {
|
||||
type Data = u32;
|
||||
|
||||
let table_path = "test_table_0";
|
||||
let table_path = Path::new("test_table_0");
|
||||
let number_of_columns = 5;
|
||||
let primary_column = 0;
|
||||
let store: Store<Data> = Store::new(table_path, number_of_columns, primary_column).await.unwrap();
|
||||
|
|
@ -240,7 +239,7 @@ mod tests {
|
|||
async fn test_insert() {
|
||||
type Data = u32;
|
||||
|
||||
let table_path = "test_table_1";
|
||||
let table_path = Path::new("test_table_1");
|
||||
let number_of_columns = 5;
|
||||
let primary_column = 0;
|
||||
let mut store: Store<Data> = Store::new(table_path, number_of_columns, primary_column).await.unwrap();
|
||||
|
|
@ -262,7 +261,7 @@ mod tests {
|
|||
async fn test_select_next() {
|
||||
type Data = u32;
|
||||
|
||||
let table_path = "test_table_2";
|
||||
let table_path = Path::new("test_table_2");
|
||||
let number_of_columns = 5;
|
||||
let primary_column = 0;
|
||||
let mut store: Store<Data> = Store::new(table_path, number_of_columns, primary_column).await.unwrap();
|
||||
|
|
@ -294,7 +293,7 @@ mod tests {
|
|||
async fn test_select_all() {
|
||||
type Data = u32;
|
||||
|
||||
let table_path = "test_table_3";
|
||||
let table_path = Path::new("test_table_3");
|
||||
let number_of_columns = 5;
|
||||
let primary_column = 0;
|
||||
let mut store: Store<Data> = Store::new(table_path, number_of_columns, primary_column).await.unwrap();
|
||||
|
|
@ -329,7 +328,7 @@ mod tests {
|
|||
async fn test_select_eq() {
|
||||
type Data = u32;
|
||||
|
||||
let table_path = "test_table_4";
|
||||
let table_path = Path::new("test_table_4");
|
||||
let number_of_columns = 5;
|
||||
let primary_column = 0;
|
||||
let mut store: Store<Data> = Store::new(table_path, number_of_columns, primary_column).await.unwrap();
|
||||
|
|
@ -369,7 +368,7 @@ mod tests {
|
|||
async fn test_select_eq_indexed() {
|
||||
type Data = u32;
|
||||
|
||||
let table_path = "test_table_5";
|
||||
let table_path = Path::new("test_table_5");
|
||||
let number_of_columns = 5;
|
||||
let primary_column = 0;
|
||||
let mut store: Store<Data> = Store::new(table_path, number_of_columns, primary_column).await.unwrap();
|
||||
|
|
@ -415,7 +414,7 @@ mod tests {
|
|||
async fn test_delete_entry() {
|
||||
type Data = u32;
|
||||
|
||||
let table_path = "test_table_6";
|
||||
let table_path = Path::new("test_table_6");
|
||||
let number_of_columns = 5;
|
||||
let primary_column = 0;
|
||||
let mut store: Store<Data> = Store::new(table_path, number_of_columns, primary_column).await.unwrap();
|
||||
|
|
@ -452,7 +451,7 @@ mod tests {
|
|||
async fn test_delete_where_eq() {
|
||||
type Data = u32;
|
||||
|
||||
let table_path = "test_table_7";
|
||||
let table_path = Path::new("test_table_7");
|
||||
let number_of_columns = 5;
|
||||
let primary_column = 0;
|
||||
let mut store: Store<Data> = Store::new(table_path, number_of_columns, primary_column).await.unwrap();
|
||||
|
|
@ -496,7 +495,7 @@ mod tests {
|
|||
async fn test_garbage_collection() {
|
||||
type Data = u32;
|
||||
|
||||
let table_path = "test_table_8";
|
||||
let table_path = Path::new("test_table_8");
|
||||
let number_of_columns = 5;
|
||||
let primary_column = 0;
|
||||
let mut store: Store<Data> = Store::new(table_path, number_of_columns, primary_column).await.unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue