diff --git a/.gitignore b/.gitignore index 6985cf1..d305449 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Cargo.toml b/Cargo.toml index 671a5da..1725410 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/rust-rocksdb b/rust-rocksdb new file mode 160000 index 0000000..dc9a000 --- /dev/null +++ b/rust-rocksdb @@ -0,0 +1 @@ +Subproject commit dc9a0002cc76b25ab56d322e7b7a84556f772db7 diff --git a/src/dto/mod.rs b/src/dto/mod.rs new file mode 100644 index 0000000..1e6a204 --- /dev/null +++ b/src/dto/mod.rs @@ -0,0 +1,3 @@ +pub mod namespace_data; +pub mod operator_statistics; +pub mod table_data; diff --git a/src/dto/namespace_data.rs b/src/dto/namespace_data.rs new file mode 100644 index 0000000..7066446 --- /dev/null +++ b/src/dto/namespace_data.rs @@ -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, +} diff --git a/src/dto/operator_statistics.rs b/src/dto/operator_statistics.rs new file mode 100644 index 0000000..0bb293e --- /dev/null +++ b/src/dto/operator_statistics.rs @@ -0,0 +1,7 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Serialize, Deserialize)] +pub struct OperatorStatistics { + pub operator_string: String, + pub cardinality_prev_result: u64, +} diff --git a/src/dto/table_data.rs b/src/dto/table_data.rs new file mode 100644 index 0000000..63857a2 --- /dev/null +++ b/src/dto/table_data.rs @@ -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, + pub columns: Vec>, + pub aggregates: Value, + pub value_range: (i32, i32), + pub is_strong_key: bool, + pub is_weak_key: bool, + pub primary_key_col_name: String, +} diff --git a/src/main.rs b/src/main.rs index e7a11a9..5858400 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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); }