示例#1
0
        public override Traversal ToTraversal(IGremlinQueryEnvironment environment)
        {
            var keyProjectionTraversal        = _keyProjection.ToTraversal(environment);
            var maybeValueProjectionTraversal = _valueProjection?.ToTraversal(environment);

            return((keyProjectionTraversal.Count == 0 && (maybeValueProjectionTraversal?.Count).GetValueOrDefault() == 0)
                ? Traversal.Empty
                : new LocalStep(Traversal
                                .Create(
                                    4,
                                    (keyProjectionTraversal, maybeValueProjectionTraversal),
                                    static (steps, state) =>
            {
                var(keyProjectionTraversal, maybeValueProjectionTraversal) = state;

                steps[0] = UnfoldStep.Instance;
                steps[1] = GroupStep.Instance;

                steps[2] = new GroupStep.ByTraversalStep(Traversal
                                                         .Create(
                                                             keyProjectionTraversal.Count + 1,
                                                             keyProjectionTraversal,
                                                             static (steps, keyProjectionTraversal) =>
                {
                    steps[0] = new SelectColumnStep(Column.Keys);

                    keyProjectionTraversal.Steps
                    .AsSpan()
                    .CopyTo(steps[1..]);
                }));
示例#2
0
        public override Traversal ToTraversal(IGremlinQueryEnvironment environment)
        {
            var inner = _inner.ToTraversal(environment);

            if (inner.Count > 0)
            {
                return(new LocalStep(Traversal.Create(
                                         inner.Count + 2,
                                         inner,
                                         static (steps, inner) =>
                {
                    steps[0] = UnfoldStep.Instance;
                    steps[^ 1] = FoldStep.Instance;

                    inner
                    .Steps
                    .AsSpan()
                    .CopyTo(steps[1..]);