diff --git a/interactive_engine/executor/ir/runtime/src/process/operator/map/get_v.rs b/interactive_engine/executor/ir/runtime/src/process/operator/map/get_v.rs index d70ee3880da1..5a9dfc9eac6f 100644 --- a/interactive_engine/executor/ir/runtime/src/process/operator/map/get_v.rs +++ b/interactive_engine/executor/ir/runtime/src/process/operator/map/get_v.rs @@ -160,85 +160,83 @@ impl FilterMapFunction for AuxiliaOperator { // g.V().out().auxilia(as("a"))... where we give alias in auxilia, // then we set tag=None and alias="a" in auxilia - // 1. If only need to filter by labels, and the entry itself carries label information already, directly eval it without query the store - if !self.query_params.labels.is_empty() - && !self.query_params.is_queryable() - && entry.label().is_some() - { - if self + // 1. If to filter by labels, and the entry itself carries label information already, directly eval it without query the store + if !self.query_params.labels.is_empty() && entry.label().is_some() { + if !self .query_params .labels .contains(&entry.label().unwrap()) { - Ok(Some(input)) - } else { - Ok(None) + // pruning by labels + return Ok(None); + } else if !self.query_params.is_queryable() { + // if only filter by labels, directly return the results. + return Ok(Some(input)); } - } else { - // 2. Otherwise, filter after query store, e.g., the case of filter by columns. - match entry.get_type() { - EntryType::Vertex => { - let graph = get_graph().ok_or_else(|| FnExecError::NullGraphError)?; - let id = entry.id(); - if let Some(vertex) = graph - .get_vertex(&[id], &self.query_params)? - .next() - .map(|vertex| DynEntry::new(vertex)) - { - if let Some(alias) = self.alias { - // append without moving head - input - .get_columns_mut() - .insert(alias as usize, vertex.into()); - } else { - input.append(vertex, self.alias.clone()); - } + } + // 2. Otherwise, filter after query store, e.g., the case of filter by columns. + match entry.get_type() { + EntryType::Vertex => { + let graph = get_graph().ok_or_else(|| FnExecError::NullGraphError)?; + let id = entry.id(); + if let Some(vertex) = graph + .get_vertex(&[id], &self.query_params)? + .next() + .map(|vertex| DynEntry::new(vertex)) + { + if let Some(alias) = self.alias { + // append without moving head + input + .get_columns_mut() + .insert(alias as usize, vertex.into()); } else { - return Ok(None); + input.append(vertex, self.alias.clone()); } + } else { + return Ok(None); } - EntryType::Edge => { - // TODO: This is a little bit tricky. Modify this logic to query store with eid when supported. - // Currently, when getting properties from an edge, - // we assume that it has already been carried in the edge (when the first time queried the edge) - // since on most storages, query edges by eid is not supported yet. - if self.tag.eq(&self.alias) { - // do nothing as we assume properties is already carried + } + EntryType::Edge => { + // TODO: This is a little bit tricky. Modify this logic to query store with eid when supported. + // Currently, when getting properties from an edge, + // we assume that it has already been carried in the edge (when the first time queried the edge) + // since on most storages, query edges by eid is not supported yet. + if self.tag.eq(&self.alias) { + // do nothing as we assume properties is already carried + } else { + let entry = entry.clone(); + if let Some(alias) = self.alias { + // append without moving head + input + .get_columns_mut() + .insert(alias as usize, entry); } else { - let entry = entry.clone(); - if let Some(alias) = self.alias { - // append without moving head - input - .get_columns_mut() - .insert(alias as usize, entry); - } else { - input.append_arc_entry(entry, self.alias.clone()); - } + input.append_arc_entry(entry, self.alias.clone()); } } - EntryType::Path => { - // Auxilia for vertices in Path is for filtering. - let graph_path = entry - .as_graph_path() - .ok_or_else(|| FnExecError::Unreachable)?; - let path_end = graph_path.get_path_end(); - let graph = get_graph().ok_or_else(|| FnExecError::NullGraphError)?; - let id = path_end.id(); - if graph - .get_vertex(&[id], &self.query_params)? - .next() - .is_none() - { - return Ok(None); - } + } + EntryType::Path => { + // Auxilia for vertices in Path is for filtering. + let graph_path = entry + .as_graph_path() + .ok_or_else(|| FnExecError::Unreachable)?; + let path_end = graph_path.get_path_end(); + let graph = get_graph().ok_or_else(|| FnExecError::NullGraphError)?; + let id = path_end.id(); + if graph + .get_vertex(&[id], &self.query_params)? + .next() + .is_none() + { + return Ok(None); } - _ => Err(FnExecError::unexpected_data_error(&format!( + } + _ => Err(FnExecError::unexpected_data_error(&format!( "neither Vertex nor Edge entry is accessed in `Auxilia` operator, the entry is {:?}", entry )))?, - }; - Ok(Some(input)) - } + }; + Ok(Some(input)) } else { Ok(None) }