Skip to content

Commit

Permalink
fix gremlin-test for mg (#489)
Browse files Browse the repository at this point in the history
* fix gremlin-test for mg
  • Loading branch information
tianliplus committed Jul 7, 2021
1 parent df2cc02 commit af373da
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl RangeManager {
if self.end - self.start < bulk {
return self.end - self.start;
} else if self.curr - self.end < bulk {
return bulk - self.curr + self.end;
return bulk - (self.curr - self.end);
} else {
return 0;
}
Expand Down
4 changes: 4 additions & 0 deletions interactive_engine/src/executor/store/src/db/api/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ impl GraphError {
pub fn add_backtrace(&mut self, function: String, code_info: String) {
self.backtrace.push((function, code_info));
}

pub fn get_error_code(&self) -> GraphErrorCode {
self.err_code
}
}

impl Debug for GraphError {
Expand Down
41 changes: 29 additions & 12 deletions interactive_engine/src/executor/store/src/db/graph/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::property::*;
use super::meta::*;
use super::bin::*;
use protobuf::Message;
use crate::db::api::GraphErrorCode::InvalidData;
use crate::db::api::GraphErrorCode::{InvalidData, TypeNotFound};
use crate::db::graph::table_manager::Table;

pub struct GraphStore {
Expand Down Expand Up @@ -381,23 +381,40 @@ impl GraphStore {
}

fn do_query_vertices<'a>(&'a self, si: SnapshotId, label: LabelId, condition: Option<Arc<Condition>>) -> GraphResult<Box<dyn VertexResultIter<V=VertexImpl> + 'a>> {
let res = self.vertex_manager.get_type(si, label).and_then(|type_info| {
SingleLabelVertexIter::create(si, type_info, self.storage.as_ref(), condition)
});
match res_unwrap!(res, do_query_vertices, si, label)? {
Some(iter) => Ok(Box::new(iter)),
None => Ok(Box::new(EmptyResultIter)),
let res = self.vertex_manager.get_type(si, label)
.and_then(|type_info| SingleLabelVertexIter::create(si, type_info, self.storage.as_ref(), condition));
match res_unwrap!(res, do_query_vertices, si, label) {
Ok(iter_option) => {
match iter_option {
Some(iter) => Ok(Box::new(iter)),
None => Ok(Box::new(EmptyResultIter)),
}
},
Err(e) => {
if let TypeNotFound = e.get_error_code() {
Ok(Box::new(EmptyResultIter))
} else {
Err(e)
}
},
}
}

fn do_query_edges<'a>(&'a self, si: SnapshotId, id: VertexId, label: Option<LabelId>, direction: EdgeDirection, condition: Option<Arc<Condition>>) -> GraphResult<Box<dyn EdgeResultIter<E=EdgeImpl> + 'a>> {
let storage = self.storage.as_ref();
if let Some(label) = label {
let res = self.edge_manager.get_edge(si, label).and_then(|info| {
SingleLabelEdgeIter::create(si, id, direction, info, storage, condition)
});
let iter = res_unwrap!(res, do_query_edges, si, id, label, direction)?;
Ok(Box::new(iter))
let res = self.edge_manager.get_edge(si, label)
.and_then(|info| SingleLabelEdgeIter::create(si, id, direction, info, storage, condition));
match res_unwrap!(res, do_query_edges, si, id, label, direction) {
Ok(iter) => Ok(Box::new(iter)),
Err(e) => {
if let TypeNotFound = e.get_error_code() {
Ok(Box::new(EmptyResultIter))
} else {
Err(e)
}
},
}
} else {
let info_iter = self.edge_manager.get_all_edges(si);
let res = MultiLabelsEdgeIter::create(si, id, direction, info_iter, storage, condition);
Expand Down

0 comments on commit af373da

Please sign in to comment.