http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs new file mode 100644 index 0000000..4826113 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Remote/RemoteStrategy.cs @@ -0,0 +1,61 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Threading.Tasks; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Process.Remote +{ + /// <summary> + /// Reconstructs a <see cref="ITraversal" /> by submitting it to a remote server via an + /// <see cref="IRemoteConnection" /> instance. + /// </summary> + public class RemoteStrategy : ITraversalStrategy + { + private readonly IRemoteConnection _remoteConnection; + + /// <summary> + /// Initializes a new instance of the <see cref="RemoteStrategy" /> class. + /// </summary> + /// <param name="remoteConnection">The <see cref="IRemoteConnection" /> that should be used.</param> + public RemoteStrategy(IRemoteConnection remoteConnection) + { + _remoteConnection = remoteConnection; + } + + /// <inheritdoc /> + public void Apply(ITraversal traversal) + { + ApplyAsync(traversal).Wait(); + } + + /// <inheritdoc /> + public async Task ApplyAsync(ITraversal traversal) + { + if (traversal.Traversers != null) return; + var remoteTraversal = await _remoteConnection.SubmitAsync(traversal.Bytecode).ConfigureAwait(false); + traversal.SideEffects = remoteTraversal.SideEffects; + traversal.Traversers = remoteTraversal.Traversers; + } + } +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs new file mode 100644 index 0000000..13d1796 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Barrier.cs @@ -0,0 +1,30 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + public enum Barrier + { + normSack + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Binding.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Binding.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Binding.cs new file mode 100644 index 0000000..80c8269 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Binding.cs @@ -0,0 +1,80 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System; + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// Associates a variable with a value. + /// </summary> + public class Binding : IEquatable<Binding> + { + /// <summary> + /// Initializes a new instance of the <see cref="Binding" /> class. + /// </summary> + /// <param name="key">The key that identifies the <see cref="Binding" />.</param> + /// <param name="value">The value of the <see cref="Binding" />.</param> + public Binding(string key, object value) + { + Key = key; + Value = value; + } + + /// <summary> + /// Gets the key that identifies the <see cref="Binding" />. + /// </summary> + public string Key { get; } + + /// <summary> + /// Gets the value of the <see cref="Binding" />. + /// </summary> + public object Value { get; } + + /// <inheritdoc /> + public bool Equals(Binding other) + { + if (other == null) + return false; + return Key == other.Key && Value.Equals(other.Value); + } + + /// <inheritdoc /> + public override bool Equals(object other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + if (other.GetType() != GetType()) return false; + return Equals(other as Binding); + } + + /// <inheritdoc /> + public override int GetHashCode() + { + unchecked + { + return ((Key?.GetHashCode() ?? 0) * 397) ^ (Value?.GetHashCode() ?? 0); + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs new file mode 100644 index 0000000..985369e --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bindings.cs @@ -0,0 +1,42 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// Bindings are used to associate a variable with a value. + /// </summary> + public class Bindings + { + /// <summary> + /// Binds the variable to the specified value. + /// </summary> + /// <param name="variable">The variable to bind.</param> + /// <param name="value">The value to which the variable should be bound.</param> + /// <returns>The bound value.</returns> + public Binding Of(string variable, object value) + { + return new Binding(variable, value); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs new file mode 100644 index 0000000..b35e8db --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Bytecode.cs @@ -0,0 +1,85 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// A language agnostic representation of <see cref="ITraversal" /> mutations. + /// </summary> + /// <remarks> + /// Bytecode is simply a list of ordered instructions. + /// Bytecode can be serialized between environments and machines by way of a GraphSON representation. + /// Thus, Gremlin-CSharp can create bytecode in C# and ship it to Gremlin-Java for evaluation in Java. + /// </remarks> + public class Bytecode + { + /// <summary> + /// Initializes a new instance of the <see cref="Bytecode" /> class. + /// </summary> + public Bytecode() + { + } + + /// <summary> + /// Initializes a new instance of the <see cref="Bytecode" /> class. + /// </summary> + /// <param name="byteCode">Already existing <see cref="Bytecode" /> that should be cloned.</param> + public Bytecode(Bytecode byteCode) + { + SourceInstructions = new List<Instruction>(byteCode.SourceInstructions); + StepInstructions = new List<Instruction>(byteCode.StepInstructions); + } + + /// <summary> + /// Gets the traversal source instructions. + /// </summary> + public List<Instruction> SourceInstructions { get; } = new List<Instruction>(); + + /// <summary> + /// Gets the <see cref="ITraversal" /> instructions. + /// </summary> + public List<Instruction> StepInstructions { get; } = new List<Instruction>(); + + /// <summary> + /// Add a traversal source instruction to the bytecode. + /// </summary> + /// <param name="sourceName">The traversal source method name (e.g. withSack()).</param> + /// <param name="args">The traversal source method arguments.</param> + public void AddSource(string sourceName, params object[] args) + { + SourceInstructions.Add(new Instruction(sourceName, args)); + } + + /// <summary> + /// Adds a <see cref="ITraversal" /> instruction to the bytecode. + /// </summary> + /// <param name="stepName">The traversal method name (e.g. out()).</param> + /// <param name="args">The traversal method arguments.</param> + public void AddStep(string stepName, params object[] args) + { + StepInstructions.Add(new Instruction(stepName, args)); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs new file mode 100644 index 0000000..f2365c3 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Cardinality.cs @@ -0,0 +1,32 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + public enum Cardinality + { + list, + set, + single + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs new file mode 100644 index 0000000..ee591da --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Column.cs @@ -0,0 +1,31 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + public enum Column + { + keys, + values + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs new file mode 100644 index 0000000..86c636c --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/DefaultTraversal.cs @@ -0,0 +1,195 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// A traversal represents a directed walk over a graph. + /// </summary> + public abstract class DefaultTraversal : ITraversal + { + private IEnumerator<Traverser> _traverserEnumerator; + + /// <summary> + /// Gets the <see cref="Bytecode" /> representation of this traversal. + /// </summary> + public Bytecode Bytecode { get; protected set; } + + /// <summary> + /// Gets or sets the <see cref="ITraversalSideEffects" /> of this traversal. + /// </summary> + public ITraversalSideEffects SideEffects { get; set; } + + /// <summary> + /// Gets or sets the <see cref="Traverser" />'s of this traversal that hold the results of the traversal. + /// </summary> + public IEnumerable<Traverser> Traversers { get; set; } + + /// <summary> + /// Gets or sets the <see cref="ITraversalStrategy" /> strategies of this traversal. + /// </summary> + protected ICollection<ITraversalStrategy> TraversalStrategies { get; set; } = new List<ITraversalStrategy>(); + + private IEnumerator<Traverser> TraverserEnumerator + => _traverserEnumerator ?? (_traverserEnumerator = GetTraverserEnumerator()); + + /// <inheritdoc /> + public void Dispose() + { + Dispose(true); + } + + /// <inheritdoc /> + public bool MoveNext() + { + var currentTraverser = TraverserEnumerator.Current; + if (currentTraverser?.Bulk > 1) + { + currentTraverser.Bulk--; + return true; + } + return TraverserEnumerator.MoveNext(); + } + + /// <summary> + /// Reset is not supported. + /// </summary> + /// <exception cref="NotSupportedException">Thrown always as this operation is not supported.</exception> + public void Reset() + { + throw new NotSupportedException(); + } + + /// <inheritdoc /> + public object Current => TraverserEnumerator.Current?.Object; + + private IEnumerator<Traverser> GetTraverserEnumerator() + { + if (Traversers == null) + ApplyStrategies(); + return Traversers.GetEnumerator(); + } + + private void ApplyStrategies() + { + foreach (var strategy in TraversalStrategies) + strategy.Apply(this); + } + + private async Task ApplyStrategiesAsync() + { + foreach (var strategy in TraversalStrategies) + await strategy.ApplyAsync(this).ConfigureAwait(false); + } + + /// <summary> + /// Gets the next result from the traversal. + /// </summary> + /// <returns>The result.</returns> + public object Next() + { + MoveNext(); + return Current; + } + + /// <summary> + /// Gets the next n-number of results from the traversal. + /// </summary> + /// <param name="amount">The number of results to get.</param> + /// <returns>The n-results.</returns> + public IEnumerable<object> Next(int amount) + { + for (var i = 0; i < amount; i++) + yield return Next(); + } + + /// <summary> + /// Iterates all <see cref="Traverser" /> instances in the traversal. + /// </summary> + /// <returns>The fully drained traversal.</returns> + public ITraversal Iterate() + { + while (MoveNext()) + { + } + return this; + } + + /// <summary> + /// Gets the next <see cref="Traverser" />. + /// </summary> + /// <returns>The next <see cref="Traverser" />.</returns> + public Traverser NextTraverser() + { + TraverserEnumerator.MoveNext(); + return TraverserEnumerator.Current; + } + + /// <summary> + /// Puts all the results into a <see cref="List{T}" />. + /// </summary> + /// <returns>The results in a list.</returns> + public List<object> ToList() + { + var objs = new List<object>(); + while (MoveNext()) + objs.Add(Current); + return objs; + } + + /// <summary> + /// Puts all the results into a <see cref="HashSet{T}" />. + /// </summary> + /// <returns>The results in a set.</returns> + public HashSet<object> ToSet() + { + var objs = new HashSet<object>(); + while (MoveNext()) + objs.Add(Current); + return objs; + } + + /// <inheritdoc /> + protected virtual void Dispose(bool disposing) + { + if (disposing) + SideEffects?.Dispose(); + } + + /// <summary> + /// Starts a promise to execute a function on the current traversal that will be completed in the future. + /// </summary> + /// <typeparam name="TReturn">The return type of the <paramref name="callback" />.</typeparam> + /// <param name="callback">The function to execute on the current traversal.</param> + /// <returns>The result of the executed <paramref name="callback" />.</returns> + public async Task<TReturn> Promise<TReturn>(Func<ITraversal, TReturn> callback) + { + await ApplyStrategiesAsync().ConfigureAwait(false); + return callback(this); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs new file mode 100644 index 0000000..413e11f --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Direction.cs @@ -0,0 +1,32 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + public enum Direction + { + BOTH, + IN, + OUT + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs new file mode 100644 index 0000000..88e9261 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversal.cs @@ -0,0 +1,629 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; + +namespace Gremlin.Net.Process.Traversal +{ + public class GraphTraversal : DefaultTraversal + { + public GraphTraversal() + : this(new List<ITraversalStrategy>(), new Bytecode()) + { + } + + public GraphTraversal(ICollection<ITraversalStrategy> traversalStrategies, Bytecode bytecode) + { + TraversalStrategies = traversalStrategies; + Bytecode = bytecode; + } + + public GraphTraversal V(params object[] args) + { + Bytecode.AddStep("V", args); + return this; + } + + public GraphTraversal AddE(params object[] args) + { + Bytecode.AddStep("addE", args); + return this; + } + + public GraphTraversal AddInE(params object[] args) + { + Bytecode.AddStep("addInE", args); + return this; + } + + public GraphTraversal AddOutE(params object[] args) + { + Bytecode.AddStep("addOutE", args); + return this; + } + + public GraphTraversal AddV(params object[] args) + { + Bytecode.AddStep("addV", args); + return this; + } + + public GraphTraversal Aggregate(params object[] args) + { + Bytecode.AddStep("aggregate", args); + return this; + } + + public GraphTraversal And(params object[] args) + { + Bytecode.AddStep("and", args); + return this; + } + + public GraphTraversal As(params object[] args) + { + Bytecode.AddStep("as", args); + return this; + } + + public GraphTraversal Barrier(params object[] args) + { + Bytecode.AddStep("barrier", args); + return this; + } + + public GraphTraversal Both(params object[] args) + { + Bytecode.AddStep("both", args); + return this; + } + + public GraphTraversal BothE(params object[] args) + { + Bytecode.AddStep("bothE", args); + return this; + } + + public GraphTraversal BothV(params object[] args) + { + Bytecode.AddStep("bothV", args); + return this; + } + + public GraphTraversal Branch(params object[] args) + { + Bytecode.AddStep("branch", args); + return this; + } + + public GraphTraversal By(params object[] args) + { + Bytecode.AddStep("by", args); + return this; + } + + public GraphTraversal Cap(params object[] args) + { + Bytecode.AddStep("cap", args); + return this; + } + + public GraphTraversal Choose(params object[] args) + { + Bytecode.AddStep("choose", args); + return this; + } + + public GraphTraversal Coalesce(params object[] args) + { + Bytecode.AddStep("coalesce", args); + return this; + } + + public GraphTraversal Coin(params object[] args) + { + Bytecode.AddStep("coin", args); + return this; + } + + public GraphTraversal Constant(params object[] args) + { + Bytecode.AddStep("constant", args); + return this; + } + + public GraphTraversal Count(params object[] args) + { + Bytecode.AddStep("count", args); + return this; + } + + public GraphTraversal CyclicPath(params object[] args) + { + Bytecode.AddStep("cyclicPath", args); + return this; + } + + public GraphTraversal Dedup(params object[] args) + { + Bytecode.AddStep("dedup", args); + return this; + } + + public GraphTraversal Drop(params object[] args) + { + Bytecode.AddStep("drop", args); + return this; + } + + public GraphTraversal Emit(params object[] args) + { + Bytecode.AddStep("emit", args); + return this; + } + + public GraphTraversal Filter(params object[] args) + { + Bytecode.AddStep("filter", args); + return this; + } + + public GraphTraversal FlatMap(params object[] args) + { + Bytecode.AddStep("flatMap", args); + return this; + } + + public GraphTraversal Fold(params object[] args) + { + Bytecode.AddStep("fold", args); + return this; + } + + public GraphTraversal From(params object[] args) + { + Bytecode.AddStep("from", args); + return this; + } + + public GraphTraversal Group(params object[] args) + { + Bytecode.AddStep("group", args); + return this; + } + + public GraphTraversal GroupCount(params object[] args) + { + Bytecode.AddStep("groupCount", args); + return this; + } + + public GraphTraversal GroupV3d0(params object[] args) + { + Bytecode.AddStep("groupV3d0", args); + return this; + } + + public GraphTraversal Has(params object[] args) + { + Bytecode.AddStep("has", args); + return this; + } + + public GraphTraversal HasId(params object[] args) + { + Bytecode.AddStep("hasId", args); + return this; + } + + public GraphTraversal HasKey(params object[] args) + { + Bytecode.AddStep("hasKey", args); + return this; + } + + public GraphTraversal HasLabel(params object[] args) + { + Bytecode.AddStep("hasLabel", args); + return this; + } + + public GraphTraversal HasNot(params object[] args) + { + Bytecode.AddStep("hasNot", args); + return this; + } + + public GraphTraversal HasValue(params object[] args) + { + Bytecode.AddStep("hasValue", args); + return this; + } + + public GraphTraversal Id(params object[] args) + { + Bytecode.AddStep("id", args); + return this; + } + + public GraphTraversal Identity(params object[] args) + { + Bytecode.AddStep("identity", args); + return this; + } + + public GraphTraversal In(params object[] args) + { + Bytecode.AddStep("in", args); + return this; + } + + public GraphTraversal InE(params object[] args) + { + Bytecode.AddStep("inE", args); + return this; + } + + public GraphTraversal InV(params object[] args) + { + Bytecode.AddStep("inV", args); + return this; + } + + public GraphTraversal Inject(params object[] args) + { + Bytecode.AddStep("inject", args); + return this; + } + + public GraphTraversal Is(params object[] args) + { + Bytecode.AddStep("is", args); + return this; + } + + public GraphTraversal Key(params object[] args) + { + Bytecode.AddStep("key", args); + return this; + } + + public GraphTraversal Label(params object[] args) + { + Bytecode.AddStep("label", args); + return this; + } + + public GraphTraversal Limit(params object[] args) + { + Bytecode.AddStep("limit", args); + return this; + } + + public GraphTraversal Local(params object[] args) + { + Bytecode.AddStep("local", args); + return this; + } + + public GraphTraversal Loops(params object[] args) + { + Bytecode.AddStep("loops", args); + return this; + } + + public GraphTraversal Map(params object[] args) + { + Bytecode.AddStep("map", args); + return this; + } + + public GraphTraversal MapKeys(params object[] args) + { + Bytecode.AddStep("mapKeys", args); + return this; + } + + public GraphTraversal MapValues(params object[] args) + { + Bytecode.AddStep("mapValues", args); + return this; + } + + public GraphTraversal Match(params object[] args) + { + Bytecode.AddStep("match", args); + return this; + } + + public GraphTraversal Max(params object[] args) + { + Bytecode.AddStep("max", args); + return this; + } + + public GraphTraversal Mean(params object[] args) + { + Bytecode.AddStep("mean", args); + return this; + } + + public GraphTraversal Min(params object[] args) + { + Bytecode.AddStep("min", args); + return this; + } + + public GraphTraversal Not(params object[] args) + { + Bytecode.AddStep("not", args); + return this; + } + + public GraphTraversal Option(params object[] args) + { + Bytecode.AddStep("option", args); + return this; + } + + public GraphTraversal Optional(params object[] args) + { + Bytecode.AddStep("optional", args); + return this; + } + + public GraphTraversal Or(params object[] args) + { + Bytecode.AddStep("or", args); + return this; + } + + public GraphTraversal Order(params object[] args) + { + Bytecode.AddStep("order", args); + return this; + } + + public GraphTraversal OtherV(params object[] args) + { + Bytecode.AddStep("otherV", args); + return this; + } + + public GraphTraversal Out(params object[] args) + { + Bytecode.AddStep("out", args); + return this; + } + + public GraphTraversal OutE(params object[] args) + { + Bytecode.AddStep("outE", args); + return this; + } + + public GraphTraversal OutV(params object[] args) + { + Bytecode.AddStep("outV", args); + return this; + } + + public GraphTraversal PageRank(params object[] args) + { + Bytecode.AddStep("pageRank", args); + return this; + } + + public GraphTraversal Path(params object[] args) + { + Bytecode.AddStep("path", args); + return this; + } + + public GraphTraversal PeerPressure(params object[] args) + { + Bytecode.AddStep("peerPressure", args); + return this; + } + + public GraphTraversal Profile(params object[] args) + { + Bytecode.AddStep("profile", args); + return this; + } + + public GraphTraversal Program(params object[] args) + { + Bytecode.AddStep("program", args); + return this; + } + + public GraphTraversal Project(params object[] args) + { + Bytecode.AddStep("project", args); + return this; + } + + public GraphTraversal Properties(params object[] args) + { + Bytecode.AddStep("properties", args); + return this; + } + + public GraphTraversal Property(params object[] args) + { + Bytecode.AddStep("property", args); + return this; + } + + public GraphTraversal PropertyMap(params object[] args) + { + Bytecode.AddStep("propertyMap", args); + return this; + } + + public GraphTraversal Range(params object[] args) + { + Bytecode.AddStep("range", args); + return this; + } + + public GraphTraversal Repeat(params object[] args) + { + Bytecode.AddStep("repeat", args); + return this; + } + + public GraphTraversal Sack(params object[] args) + { + Bytecode.AddStep("sack", args); + return this; + } + + public GraphTraversal Sample(params object[] args) + { + Bytecode.AddStep("sample", args); + return this; + } + + public GraphTraversal Select(params object[] args) + { + Bytecode.AddStep("select", args); + return this; + } + + public GraphTraversal SideEffect(params object[] args) + { + Bytecode.AddStep("sideEffect", args); + return this; + } + + public GraphTraversal SimplePath(params object[] args) + { + Bytecode.AddStep("simplePath", args); + return this; + } + + public GraphTraversal Store(params object[] args) + { + Bytecode.AddStep("store", args); + return this; + } + + public GraphTraversal Subgraph(params object[] args) + { + Bytecode.AddStep("subgraph", args); + return this; + } + + public GraphTraversal Sum(params object[] args) + { + Bytecode.AddStep("sum", args); + return this; + } + + public GraphTraversal Tail(params object[] args) + { + Bytecode.AddStep("tail", args); + return this; + } + + public GraphTraversal TimeLimit(params object[] args) + { + Bytecode.AddStep("timeLimit", args); + return this; + } + + public GraphTraversal Times(params object[] args) + { + Bytecode.AddStep("times", args); + return this; + } + + public GraphTraversal To(params object[] args) + { + Bytecode.AddStep("to", args); + return this; + } + + public GraphTraversal ToE(params object[] args) + { + Bytecode.AddStep("toE", args); + return this; + } + + public GraphTraversal ToV(params object[] args) + { + Bytecode.AddStep("toV", args); + return this; + } + + public GraphTraversal Tree(params object[] args) + { + Bytecode.AddStep("tree", args); + return this; + } + + public GraphTraversal Unfold(params object[] args) + { + Bytecode.AddStep("unfold", args); + return this; + } + + public GraphTraversal Union(params object[] args) + { + Bytecode.AddStep("union", args); + return this; + } + + public GraphTraversal Until(params object[] args) + { + Bytecode.AddStep("until", args); + return this; + } + + public GraphTraversal Value(params object[] args) + { + Bytecode.AddStep("value", args); + return this; + } + + public GraphTraversal ValueMap(params object[] args) + { + Bytecode.AddStep("valueMap", args); + return this; + } + + public GraphTraversal Values(params object[] args) + { + Bytecode.AddStep("values", args); + return this; + } + + public GraphTraversal Where(params object[] args) + { + Bytecode.AddStep("where", args); + return this; + } + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs new file mode 100644 index 0000000..6382781 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/GraphTraversalSource.cs @@ -0,0 +1,142 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using Gremlin.Net.Process.Remote; +using Gremlin.Net.Process.Traversal.Strategy.Decoration; + +namespace Gremlin.Net.Process.Traversal +{ + public class GraphTraversalSource + { + public ICollection<ITraversalStrategy> TraversalStrategies { get; set; } + public Bytecode Bytecode { get; set; } + + public GraphTraversalSource() + : this(new List<ITraversalStrategy>(), new Bytecode()) + { + } + + public GraphTraversalSource(ICollection<ITraversalStrategy> traversalStrategies, Bytecode bytecode) + { + TraversalStrategies = traversalStrategies; + Bytecode = bytecode; + } + + public GraphTraversalSource WithBulk(params object[] args) + { + var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("withBulk", args); + return source; + } + + public GraphTraversalSource WithPath(params object[] args) + { + var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("withPath", args); + return source; + } + + public GraphTraversalSource WithSack(params object[] args) + { + var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("withSack", args); + return source; + } + + public GraphTraversalSource WithSideEffect(params object[] args) + { + var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("withSideEffect", args); + return source; + } + + public GraphTraversalSource WithStrategies(params object[] args) + { + var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("withStrategies", args); + return source; + } + + public GraphTraversalSource WithoutStrategies(params object[] args) + { + var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies), + new Bytecode(Bytecode)); + source.Bytecode.AddSource("withoutStrategies", args); + return source; + } + + public GraphTraversalSource WithBindings(object bindings) + { + return this; + } + + public GraphTraversalSource WithRemote(IRemoteConnection remoteConnection) + { + var source = new GraphTraversalSource(new List<ITraversalStrategy>(TraversalStrategies), + new Bytecode(Bytecode)); + source.TraversalStrategies.Add(new RemoteStrategy(remoteConnection)); + return source; + } + + public GraphTraversalSource WithComputer(string graphComputer = null, int? workers = null, string persist = null, + string result = null, ITraversal vertices = null, ITraversal edges = null, + Dictionary<string, dynamic> configuration = null) + { + return WithStrategies(new VertexProgramStrategy(graphComputer, workers, persist, result, vertices, edges, configuration)); + } + + public GraphTraversal E(params object[] args) + { + var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + traversal.Bytecode.AddStep("E", args); + return traversal; + } + + public GraphTraversal V(params object[] args) + { + var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + traversal.Bytecode.AddStep("V", args); + return traversal; + } + + public GraphTraversal AddV(params object[] args) + { + var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + traversal.Bytecode.AddStep("addV", args); + return traversal; + } + + public GraphTraversal Inject(params object[] args) + { + var traversal = new GraphTraversal(TraversalStrategies, new Bytecode(Bytecode)); + traversal.Bytecode.AddStep("inject", args); + return traversal; + } + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs new file mode 100644 index 0000000..cb472b7 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversal.cs @@ -0,0 +1,96 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// A traversal represents a directed walk over a graph. + /// </summary> + public interface ITraversal : IDisposable, IEnumerator + { + /// <summary> + /// Gets the <see cref="Bytecode" /> representation of this traversal. + /// </summary> + Bytecode Bytecode { get; } + + /// <summary> + /// Gets or sets the <see cref="ITraversalSideEffects" /> of this traversal. + /// </summary> + ITraversalSideEffects SideEffects { get; set; } + + /// <summary> + /// Gets or sets the <see cref="Traverser" />'s of this traversal that hold the results of the traversal. + /// </summary> + IEnumerable<Traverser> Traversers { get; set; } + + /// <summary> + /// Gets the next result from the traversal. + /// </summary> + /// <returns>The result.</returns> + object Next(); + + /// <summary> + /// Gets the next n-number of results from the traversal. + /// </summary> + /// <param name="amount">The number of results to get.</param> + /// <returns>The n-results.</returns> + IEnumerable<object> Next(int amount); + + /// <summary> + /// Iterates all <see cref="Traverser" /> instances in the traversal. + /// </summary> + /// <returns>The fully drained traversal.</returns> + ITraversal Iterate(); + + /// <summary> + /// Gets the next <see cref="Traverser" />. + /// </summary> + /// <returns>The next <see cref="Traverser" />.</returns> + Traverser NextTraverser(); + + /// <summary> + /// Puts all the results into a <see cref="List{T}" />. + /// </summary> + /// <returns>The results in a list.</returns> + List<object> ToList(); + + /// <summary> + /// Puts all the results into a <see cref="HashSet{T}" />. + /// </summary> + /// <returns>The results in a set.</returns> + HashSet<object> ToSet(); + + /// <summary> + /// Starts a promise to execute a function on the current traversal that will be completed in the future. + /// </summary> + /// <typeparam name="TReturn">The return type of the <paramref name="callback" />.</typeparam> + /// <param name="callback">The function to execute on the current traversal.</param> + /// <returns>The result of the executed <paramref name="callback" />.</returns> + Task<TReturn> Promise<TReturn>(Func<ITraversal, TReturn> callback); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs new file mode 100644 index 0000000..7e7b450 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalSideEffects.cs @@ -0,0 +1,52 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System; +using System.Collections.Generic; + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// A <see cref="ITraversal" /> can maintain global sideEffects. + /// </summary> + public interface ITraversalSideEffects : IDisposable + { + /// <summary> + /// Retrieves the keys of the side-effect that can be supplied to <see cref="Get(string)" />. + /// </summary> + /// <returns>The keys of the side-effect.</returns> + IReadOnlyCollection<string> Keys(); + + /// <summary> + /// Gets the side-effect associated with the provided key. + /// </summary> + /// <param name="key">The key to get the value for.</param> + /// <returns>The value associated with key.</returns> + object Get(string key); + + /// <summary> + /// Invalidates the side effect cache for traversal. + /// </summary> + void Close(); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs new file mode 100644 index 0000000..991a807 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ITraversalStrategy.cs @@ -0,0 +1,46 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Threading.Tasks; + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// A <see cref="ITraversalStrategy" /> defines a particular atomic operation for mutating a + /// <see cref="ITraversal" /> prior to its evaluation. + /// </summary> + public interface ITraversalStrategy + { + /// <summary> + /// Applies the strategy to the given <see cref="ITraversal" />. + /// </summary> + /// <param name="traversal">The <see cref="ITraversal" /> the strategy should be applied to.</param> + void Apply(ITraversal traversal); + + /// <summary> + /// Applies the strategy to the given <see cref="ITraversal" /> asynchronously. + /// </summary> + /// <param name="traversal">The <see cref="ITraversal" /> the strategy should be applied to.</param> + Task ApplyAsync(ITraversal traversal); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Instruction.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Instruction.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Instruction.cs new file mode 100644 index 0000000..195b7bf --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Instruction.cs @@ -0,0 +1,52 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + /// <summary> + /// Represents a <see cref="Bytecode" /> instruction by an operator name and its arguments. + /// </summary> + public class Instruction + { + /// <summary> + /// Initializes a new instance of the <see cref="Instruction" /> class. + /// </summary> + /// <param name="operatorName">The name of the operator.</param> + /// <param name="arguments">The arguments.</param> + public Instruction(string operatorName, params dynamic[] arguments) + { + OperatorName = operatorName; + Arguments = arguments; + } + + /// <summary> + /// Gets the name of the operator. + /// </summary> + public string OperatorName { get; } + + /// <summary> + /// Gets the arguments. + /// </summary> + public dynamic[] Arguments { get; } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs new file mode 100644 index 0000000..563f091 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Operator.cs @@ -0,0 +1,40 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + public enum Operator + { + addAll, + and, + assign, + div, + max, + min, + minus, + mult, + or, + sum, + sumLong + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs new file mode 100644 index 0000000..bbd0eab --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Order.cs @@ -0,0 +1,36 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + public enum Order + { + decr, + incr, + keyDecr, + keyIncr, + shuffle, + valueDecr, + valueIncr + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs new file mode 100644 index 0000000..0ecdccd --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/P.cs @@ -0,0 +1,107 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + + +namespace Gremlin.Net.Process.Traversal +{ + public class P + { + public static TraversalPredicate Between(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("between", value); + } + + public static TraversalPredicate Eq(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("eq", value); + } + + public static TraversalPredicate Gt(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("gt", value); + } + + public static TraversalPredicate Gte(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("gte", value); + } + + public static TraversalPredicate Inside(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("inside", value); + } + + public static TraversalPredicate Lt(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("lt", value); + } + + public static TraversalPredicate Lte(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("lte", value); + } + + public static TraversalPredicate Neq(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("neq", value); + } + + public static TraversalPredicate Not(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("not", value); + } + + public static TraversalPredicate Outside(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("outside", value); + } + + public static TraversalPredicate Test(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("test", value); + } + + public static TraversalPredicate Within(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("within", value); + } + + public static TraversalPredicate Without(params object[] args) + { + var value = args.Length == 1 ? args[0] : args; + return new TraversalPredicate("without", value); + } + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs new file mode 100644 index 0000000..f16aa20 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pick.cs @@ -0,0 +1,31 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + public enum Pick + { + any, + none + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs new file mode 100644 index 0000000..e0cf62e --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Pop.cs @@ -0,0 +1,32 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + public enum Pop + { + all, + first, + last + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs new file mode 100644 index 0000000..c4af316 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Scope.cs @@ -0,0 +1,31 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal +{ + public enum Scope + { + global, + local + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs new file mode 100644 index 0000000..8c9666c --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/AbstractTraversalStrategy.cs @@ -0,0 +1,86 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Gremlin.Net.Process.Traversal.Strategy +{ + /// <summary> + /// Provides a common base class for strategies that are only included in <see cref="Bytecode" /> + /// to be applied remotely. + /// </summary> + public abstract class AbstractTraversalStrategy : ITraversalStrategy, IEquatable<AbstractTraversalStrategy> + { + /// <summary> + /// Gets the name of the strategy. + /// </summary> + public string StrategyName => GetType().Name; + + /// <summary> + /// Gets the configuration of the strategy. + /// </summary> + public Dictionary<string, dynamic> Configuration { get; } = new Dictionary<string, dynamic>(); + + /// <inheritdoc /> + public bool Equals(AbstractTraversalStrategy other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return StrategyName == other.StrategyName; + } + + /// <inheritdoc /> + public virtual void Apply(ITraversal traversal) + { + } + + /// <inheritdoc /> + public virtual Task ApplyAsync(ITraversal traversal) + { + return Task.CompletedTask; + } + + /// <inheritdoc /> + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != GetType()) return false; + return Equals((AbstractTraversalStrategy) obj); + } + + /// <inheritdoc /> + public override int GetHashCode() + { + return StrategyName.GetHashCode(); + } + + /// <inheritdoc /> + public override string ToString() + { + return StrategyName; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/ConnectiveStrategy.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/ConnectiveStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/ConnectiveStrategy.cs new file mode 100644 index 0000000..2bca7c2 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/ConnectiveStrategy.cs @@ -0,0 +1,33 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal.Strategy.Decoration +{ + /// <summary> + /// ConnectiveStrategy rewrites the binary conjunction form of <c>a.and().b</c> into an AndStep of + /// <c>and(a, b)</c> (likewise for OrStep). + /// </summary> + public class ConnectiveStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/ElementIdStrategy.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/ElementIdStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/ElementIdStrategy.cs new file mode 100644 index 0000000..6079f58 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/ElementIdStrategy.cs @@ -0,0 +1,32 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal.Strategy.Decoration +{ + /// <summary> + /// Provides a degree of control over element identifier assignment as some graphs don't provide that feature. + /// </summary> + public class ElementIdStrategy : AbstractTraversalStrategy + { + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs new file mode 100644 index 0000000..98f949c --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/HaltedTraverserStrategy.cs @@ -0,0 +1,34 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal.Strategy.Decoration +{ + public class HaltedTraverserStrategy : AbstractTraversalStrategy + { + public HaltedTraverserStrategy(string haltedTraverserFactoryName = null) + { + if (haltedTraverserFactoryName != null) + Configuration["haltedTraverserFactory"] = haltedTraverserFactoryName; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/PartitionStrategy.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/PartitionStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/PartitionStrategy.cs new file mode 100644 index 0000000..f89037b --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/PartitionStrategy.cs @@ -0,0 +1,56 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; + +namespace Gremlin.Net.Process.Traversal.Strategy.Decoration +{ + /// <summary> + /// Partitions the vertices, edges and vertex properties of a graph into String named partitions. + /// </summary> + public class PartitionStrategy : AbstractTraversalStrategy + { + /// <summary> + /// Initializes a new instance of the <see cref="PartitionStrategy" /> class. + /// </summary> + /// <param name="partitionKey">Specifies the partition key name.</param> + /// <param name="writePartition"> + /// Specifies the name of the partition to write when adding vertices, edges and vertex + /// properties. + /// </param> + /// <param name="readPartitions">Specifies the partition of the graph to read from.</param> + /// <param name="includeMetaProperties">Set to true if vertex properties should get assigned to partitions.</param> + public PartitionStrategy(string partitionKey = null, string writePartition = null, + IEnumerable<string> readPartitions = null, bool? includeMetaProperties = null) + { + if (partitionKey != null) + Configuration["partitionKey"] = partitionKey; + if (writePartition != null) + Configuration["writePartition"] = writePartition; + if (readPartitions != null) + Configuration["readPartitions"] = readPartitions; + if (includeMetaProperties != null) + Configuration["includeMetaProperties"] = includeMetaProperties.Value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/SubgraphStrategy.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/SubgraphStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/SubgraphStrategy.cs new file mode 100644 index 0000000..2f0d23e --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/SubgraphStrategy.cs @@ -0,0 +1,48 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal.Strategy.Decoration +{ + /// <summary> + /// Provides a way to limit the view of a <see cref="ITraversal" />. + /// </summary> + public class SubgraphStrategy : AbstractTraversalStrategy + { + /// <summary> + /// Initializes a new instance of the <see cref="SubgraphStrategy" /> class. + /// </summary> + /// <param name="vertexCriterion">Constrains vertices for the <see cref="ITraversal" />.</param> + /// <param name="edgeCriterion">Constrains edges for the <see cref="ITraversal" />.</param> + /// <param name="vertexPropertyCriterion">Constrains vertex properties for the <see cref="ITraversal" />.</param> + public SubgraphStrategy(ITraversal vertexCriterion = null, ITraversal edgeCriterion = null, + ITraversal vertexPropertyCriterion = null) + { + if (vertexCriterion != null) + Configuration["vertices"] = vertexCriterion; + if (edgeCriterion != null) + Configuration["edges"] = edgeCriterion; + if (vertexPropertyCriterion != null) + Configuration["vertexProperties"] = vertexPropertyCriterion; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs new file mode 100644 index 0000000..1c5b5f2 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Decoration/VertexProgramStrategy.cs @@ -0,0 +1,50 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using System.Linq; + +namespace Gremlin.Net.Process.Traversal.Strategy.Decoration +{ + public class VertexProgramStrategy : AbstractTraversalStrategy + { + public VertexProgramStrategy(string graphComputer = null, int? workers = null, string persist = null, + string result = null, ITraversal vertices = null, ITraversal edges = null, + Dictionary<string, dynamic> configuration = null) + { + if (graphComputer != null) + Configuration["graphComputer"] = graphComputer; + if (workers != null) + Configuration["workers"] = workers; + if (persist != null) + Configuration["persist"] = persist; + if (result != null) + Configuration["result"] = result; + if (vertices != null) + Configuration["vertices"] = vertices; + if (edges != null) + Configuration["edges"] = edges; + configuration?.ToList().ForEach(x => Configuration[x.Key] = x.Value); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs new file mode 100644 index 0000000..11a9e2c --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Strategy/Finalization/MatchAlgorithmStrategy.cs @@ -0,0 +1,34 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +namespace Gremlin.Net.Process.Traversal.Strategy.Finalization +{ + public class MatchAlgorithmStrategy : AbstractTraversalStrategy + { + public MatchAlgorithmStrategy(string matchAlgorithm = null) + { + if (matchAlgorithm != null) + Configuration["matchAlgorithm"] = matchAlgorithm; + } + } +} \ No newline at end of file