Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Add data models (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimranMakhija7 authored Feb 28, 2024
1 parent 7f26037 commit 6964323
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# will have compiled files and executables
debug/
target/
rocksdb/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
1 change: 1 addition & 0 deletions rust-rocksdb
Submodule rust-rocksdb added at dc9a00
3 changes: 3 additions & 0 deletions src/dto/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod namespace_data;
pub mod operator_statistics;
pub mod table_data;
8 changes: 8 additions & 0 deletions src/dto/namespace_data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use serde::{Deserialize, Serialize};
use serde_json::Value;

#[derive(Debug, Serialize, Deserialize)]
pub struct NamespaceData {
pub name: String,
pub properties: Value,
}
7 changes: 7 additions & 0 deletions src/dto/operator_statistics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
pub struct OperatorStatistics {
pub operator_string: String,
pub cardinality_prev_result: u64,
}
17 changes: 17 additions & 0 deletions src/dto/table_data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use serde::{Deserialize, Serialize};
use serde_json::Value;

#[derive(Debug, Serialize, Deserialize)]
pub struct TableData {
pub name: String,
pub num_columns: u64,
pub read_properties: Value,
pub write_properties: Value,
pub file_urls: Vec<String>,
pub columns: Vec<Vec<String>>,
pub aggregates: Value,
pub value_range: (i32, i32),
pub is_strong_key: bool,
pub is_weak_key: bool,
pub primary_key_col_name: String,
}
36 changes: 35 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
mod dto;

use dto::namespace_data::NamespaceData;
use dto::operator_statistics::OperatorStatistics;
use dto::table_data::TableData;

fn main() {
println!("Hello, world!");
// Create instances of the structs
let namespace = NamespaceData {
name: "MyNamespace".to_string(),
properties: serde_json::json!({"key": "value"}),
};

let table = TableData {
name: "MyTable".to_string(),
num_columns: 5,
read_properties: serde_json::json!({"key": "value"}),
write_properties: serde_json::json!({"key": "value"}),
file_urls: vec!["url1".to_string(), "url2".to_string()],
columns: vec![vec!["column1".to_string(), "column2".to_string()]],
aggregates: serde_json::json!({"key": "value"}),
value_range: (1, 100),
is_strong_key: true,
is_weak_key: false,
primary_key_col_name: "id".to_string(),
};

let operator_stats = OperatorStatistics {
operator_string: "MyOperator".to_string(),
cardinality_prev_result: 10,
};

// Use the structs as required
println!("Namespace: {:?}", namespace);
println!("Table: {:?}", table);
println!("Operator Stats: {:?}", operator_stats);
}

0 comments on commit 6964323

Please sign in to comment.