Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre RICCIARDI committed Jul 9, 2023
1 parent 8cbf88d commit e6e0d2e
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 5 deletions.
4 changes: 4 additions & 0 deletions lib/zawgl-core/src/graph_engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ impl GraphEngine {
pub fn sync(&mut self) {
self.repository.sync();
}

pub fn clear(&mut self) {
self.repository.clear();
}
}


Expand Down
7 changes: 7 additions & 0 deletions lib/zawgl-core/src/repository/graph_repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ impl GraphRepository {
self.properties_repository.sync();
self.labels_store.sync();
}
pub fn clear(&mut self) {
self.nodes_labels_index.clear();
self.relationships_store.clear();
self.nodes_store.clear();
self.properties_repository.clear();
self.labels_store.clear();
}
}

#[derive(Copy, Clone)]
Expand Down
3 changes: 3 additions & 0 deletions lib/zawgl-core/src/repository/index/b_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ impl BTreeIndex {
pub fn soft_sync(&mut self) {
self.node_store.soft_sync();
}
pub fn clear(&mut self) {
self.node_store.clear();
}
}

#[cfg(test)]
Expand Down
9 changes: 6 additions & 3 deletions lib/zawgl-core/src/repository/index/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,15 @@ impl BTreeNodeStore {

pub fn sync(&mut self) {
self.records_manager.lock().unwrap().sync();
self.pool.clear();
self.nodes_pool.clear();
self.clear();
}
pub fn soft_sync(&mut self) {
self.records_manager.lock().unwrap().sync();
}
pub fn clear(&mut self) {
self.pool.clear();
self.nodes_pool.clear();
}
}

struct BTreeNodePool {
Expand Down Expand Up @@ -634,7 +637,7 @@ impl BTreeNodePool {
self.nodes_map.get(id).and_then(|pos| self.nodes.get(*pos).map(|n| n.clone()))
}

fn clear(&mut self) {
pub fn clear(&mut self) {
self.nodes_map.clear();
self.nodes.clear();
}
Expand Down
5 changes: 5 additions & 0 deletions lib/zawgl-core/src/repository/properties_repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ impl PropertiesRespository {
pub fn sync(&mut self) {
self.prop_store.sync();
self.dyn_store.sync();

}
pub fn clear(&mut self) {
self.prop_store.clear();
self.dyn_store.clear();
}
}

Expand Down
3 changes: 3 additions & 0 deletions lib/zawgl-core/src/repository/records/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,9 @@ impl RecordsManager {
self.pager.sync();
}

pub fn clear(&mut self) {
self.pager.clear();
}
pub fn retrieve_all_records_ids(&mut self) -> RecordsManagerResult<Vec<u64>> {
let page_count = self.pager.get_header_page_ref().get_page_count();
let nb_records_per_page = self.page_map.nb_records_per_page;
Expand Down
4 changes: 4 additions & 0 deletions lib/zawgl-core/src/repository/store/dynamic_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ impl DynamicStore {
pub fn sync(&mut self) {
self.records_manager.sync();
}

pub fn clear(&mut self) {
self.records_manager.clear();
}
}

#[cfg(test)]
Expand Down
3 changes: 3 additions & 0 deletions lib/zawgl-core/src/repository/store/nodes_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ impl NodesStore {
pub fn retrieve_all_nodes_ids(&mut self) -> Option<Vec<u64>> {
self.records_manager.retrieve_all_records_ids().ok()
}
pub fn clear(&mut self) {
self.records_manager.clear();
}
}

#[cfg(test)]
Expand Down
4 changes: 4 additions & 0 deletions lib/zawgl-core/src/repository/store/properties_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,9 @@ impl PropertiesStore {
}
pub fn sync(&mut self) {
self.records_manager.sync();
self.clear();
}
pub fn clear(&mut self) {
self.records_manager.clear();
}
}
3 changes: 3 additions & 0 deletions lib/zawgl-core/src/repository/store/relationships_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ impl RelationshipsStore {
pub fn sync(&mut self) {
self.records_manager.sync();
}
pub fn clear(&mut self) {
self.records_manager.clear();
}
}


Expand Down
5 changes: 4 additions & 1 deletion lib/zawgl-front/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ pub fn handle_open_cypher_request(tx_handler: TxHandler, graph_request_handler:
Ok(mg) => {
build_response(request_id, mg, &r)
},
Err(e) => build_error(request_id, e),
Err(e) => {
graph_request_handler.lock().unwrap().cancel();
build_error(request_id, e)
},
}
},
Err(ce) => build_cypher_error(request_id, ce),
Expand Down
6 changes: 5 additions & 1 deletion lib/zawgl-front/src/tx_handler/request_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use zawgl_cypher_query_model::QueryStep;
use crate::planner::handle_query_steps;

use crate::tx_handler::tx_context::TxContext;
use super::{DatabaseError};
use super::DatabaseError;


pub type RequestHandler = Arc<Mutex<GraphRequestHandler>>;
Expand Down Expand Up @@ -78,6 +78,10 @@ impl <'a> GraphRequestHandler {
Ok(Vec::new())
}

pub fn cancel(&mut self) {
self.graph_engine.clear();
}

fn _commit_tx(&mut self, session_id: &str) {
let graph_engine = self.map_session_graph_engine.get_mut(session_id);
if let Some(ge) = graph_engine {
Expand Down

0 comments on commit e6e0d2e

Please sign in to comment.