Пример #1
0
            public object Serialize(IGremlinQueryBase query)
            {
                (_stepLabelNames ??= new Dictionary <StepLabel, string>()).Clear();

                return(_fragmentSerializer
                       .Serialize(query, query.AsAdmin().Environment));
            }
Пример #2
0
        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);
        }
Пример #3
0
            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);
 }
Пример #7
0
 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;