public object Serialize(IGremlinQueryBase query) { (_stepLabelNames ??= new Dictionary <StepLabel, string>()).Clear(); return(_fragmentSerializer .Serialize(query, query.AsAdmin().Environment)); }
public IGremlinQueryBase Apply(IGremlinQueryBase query) { var environment = query.AsAdmin().Environment; var anonymous = GremlinQuery.Anonymous(environment); var vertexCriterionTraversal = _vertexCriterion(anonymous.AsAdmin().ChangeQueryType <IVertexGremlinQuery <object> >()); var edgeCriterionTraversal = _edgeCriterion(anonymous.AsAdmin().ChangeQueryType <IEdgeGremlinQuery <object> >()); if (vertexCriterionTraversal.AsAdmin().Steps.Count > 0 || edgeCriterionTraversal.AsAdmin().Steps.Count > 0) { var strategy = GremlinQuery.Create <object>(environment) .AddStep(BuildStep.Instance); if (vertexCriterionTraversal.AsAdmin().Steps.Count > 0) { strategy = strategy.AddStep(new VerticesStep(vertexCriterionTraversal)); } if (edgeCriterionTraversal.AsAdmin().Steps.Count > 0) { strategy = strategy.AddStep(new EdgesStep(edgeCriterionTraversal)); } return(query .AddStep(new WithStrategiesStep(strategy.AddStep(CreateStep.Instance)))); } return(query); }
public IAsyncEnumerable <TElement> Execute <TElement>(IGremlinQueryBase <TElement> query) { var serialized = Serializer .Serialize(query); if (serialized == null) { return(AsyncEnumerableEx.Throw <TElement>(new Exception("Can't serialize query."))); } return(Executor .Execute(serialized) .SelectMany(executionResult => Deserializer .Deserialize <TElement>(executionResult, query.AsAdmin().Environment))); }
internal static Traversal ToTraversal(this IGremlinQueryBase query) { return(query.AsAdmin().ToTraversal()); }
internal static bool IsIdentity(this IGremlinQueryBase query) { return(query.AsAdmin().Steps.IsEmpty); }
internal static bool IsNone(this IGremlinQueryBase query) { return(query.AsAdmin().Steps.PeekOrDefault() is NoneStep); }
internal static IGremlinQueryBase AddStep(this IGremlinQueryBase query, Step step) { return(query.AsAdmin().InsertStep(query.AsAdmin().Steps.Count, step)); }
internal static Traversal ToTraversal(this IGremlinQueryBase query) => query .AsAdmin().Steps;