Skip to content

Commit

Permalink
[query] Add insert query #387 (#388)
Browse files Browse the repository at this point in the history
fix clippy
  • Loading branch information
michaelvlach authored Dec 12, 2022
1 parent d3436e5 commit 3268541
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/agdb/db.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pub mod db_element;
pub mod db_error;
pub mod db_index;
pub mod db_key;
pub mod db_key_value;
pub mod db_value;

mod db_float;
Expand Down
6 changes: 6 additions & 0 deletions src/agdb/db/db_element.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use super::db_key_value::DbKeyValue;

pub struct DbElement {
pub index: u64,
pub values: Vec<DbKeyValue>,
}
7 changes: 7 additions & 0 deletions src/agdb/db/db_key_value.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use crate::DbKey;
use crate::DbValue;

pub struct DbKeyValue {
pub key: DbKey,
pub value: DbValue,
}
25 changes: 23 additions & 2 deletions src/agdb/query.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
mod insert_edges_query;
mod insert_nodes_query;
mod insert_values_query;
mod query_error;
mod query_ids;
mod query_result;
mod query_values;

use self::insert_edges_query::InsertEdgesQuery;
use self::insert_nodes_query::InsertNodeQuery;
use self::insert_values_query::InsertValuesQuery;
use self::query_values::QueryValues;
pub use query_error::QueryError;
pub use query_result::QueryResult;

#[derive(Default)]
pub struct Query {}
pub enum Query {
InsertEdges(InsertEdgesQuery),
InsertNodes(InsertNodeQuery),
InsertValues(InsertValuesQuery),
}

impl Default for Query {
fn default() -> Self {
Query::InsertNodes(InsertNodeQuery {
count: 0,
values: QueryValues::None,
})
}
}
9 changes: 9 additions & 0 deletions src/agdb/query/insert_edges_query.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use super::query_ids::QueryIds;
use super::query_values::QueryValues;

pub struct InsertEdgesQuery {
pub from: QueryIds,
pub to: QueryIds,
pub count: u64,
pub values: QueryValues,
}
6 changes: 6 additions & 0 deletions src/agdb/query/insert_nodes_query.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use super::query_values::QueryValues;

pub struct InsertNodeQuery {
pub count: u64,
pub values: QueryValues,
}
7 changes: 7 additions & 0 deletions src/agdb/query/insert_values_query.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use super::query_ids::QueryIds;
use super::query_values::QueryValues;

pub struct InsertValuesQuery {
pub ids: QueryIds,
pub values: QueryValues,
}
7 changes: 7 additions & 0 deletions src/agdb/query/query_ids.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use crate::Query;

#[allow(dead_code)]
pub enum QueryIds {
Ids(Vec<u64>),
Query(Box<Query>),
}
7 changes: 6 additions & 1 deletion src/agdb/query/query_result.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
use crate::db::db_element::DbElement;

#[derive(Default)]
pub struct QueryResult {}
pub struct QueryResult {
pub result: u64,
pub elements: Vec<DbElement>,
}
9 changes: 9 additions & 0 deletions src/agdb/query/query_values.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use crate::db::db_key_value::DbKeyValue;
use crate::Query;

#[allow(dead_code)]
pub enum QueryValues {
None,
Values(Vec<Vec<DbKeyValue>>),
Query(Box<Query>),
}

0 comments on commit 3268541

Please sign in to comment.