You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2018/08/31 18:24:07 UTC
[1/3] tinkerpop git commit: Added better support for Gremlin language
tokens in python CTR
Repository: tinkerpop
Updated Branches:
refs/heads/master 793ed6d6d -> fcabd01c4
Added better support for Gremlin language tokens in python CTR
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/c0a35e25
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/c0a35e25
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/c0a35e25
Branch: refs/heads/master
Commit: c0a35e25b7cb87cac9786a2c30d94cf560311338
Parents: 793ed6d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Aug 31 13:33:14 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Aug 31 13:34:01 2018 -0400
----------------------------------------------------------------------
gremlin-python/glv/TraversalSource.template | 12 ++---
gremlin-python/glv/generate.groovy | 16 ++++--
.../jython/gremlin_python/process/traversal.py | 54 +++++++++++++++++++-
3 files changed, 72 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c0a35e25/gremlin-python/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-python/glv/TraversalSource.template b/gremlin-python/glv/TraversalSource.template
index 3ca2786..4e312ea 100644
--- a/gremlin-python/glv/TraversalSource.template
+++ b/gremlin-python/glv/TraversalSource.template
@@ -134,15 +134,15 @@ def <%= method %>(*args):
statics.add_static('<%= method %>',<%= method %>)
<% } %>
+<% tokens.each { k,v -> %>
'''
-IO
+<%= k %>
'''
-
-class IO(object):
-<% io.each {k,v -> %>
- <%= k %> = "<%= v %>"
-<% } %>
+class <%= k %>(object):
+<% v.each {a,b -> %>
+ <%= a %> = "<%= b %>"
+<% }} %>
'''
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c0a35e25/gremlin-python/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-python/glv/generate.groovy b/gremlin-python/glv/generate.groovy
index f810e10..c7ad241 100644
--- a/gremlin-python/glv/generate.groovy
+++ b/gremlin-python/glv/generate.groovy
@@ -18,6 +18,10 @@
*/
import org.apache.tinkerpop.gremlin.jsr223.CoreImports
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ConnectedComponent
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.PageRank
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.PeerPressure
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ShortestPath
import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
@@ -25,6 +29,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.P
import org.apache.tinkerpop.gremlin.process.traversal.IO
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
import java.lang.reflect.Modifier
+
// this is a bit of a copy of what's in SymbolHelper - no way around it because this code generation task occurs
// before the SymbolHelper is available to the plugin.
def toPythonMap = ["global": "global_",
@@ -39,6 +44,13 @@ def toPythonMap = ["global": "global_",
"list": "list_",
"set": "set_",
"all": "all_"]
+
+def gatherTokensFrom = { tokenClasses ->
+ def m = [:]
+ tokenClasses.each { tc -> m << [(tc.simpleName) : tc.getFields().sort{ a, b -> a.name <=> b.name }.collectEntries{ f -> [(f.name) : f.get(null)]}]}
+ return m
+}
+
def toJavaMap = toPythonMap.collectEntries{k,v -> [(v):k]}
def toPython = { symbol -> toPythonMap.getOrDefault(symbol, symbol) }
def toJava = { symbol -> toJavaMap.getOrDefault(symbol, symbol) }
@@ -79,9 +91,7 @@ def binding = ["enums": CoreImports.getClassImports()
collect { toPython(it.name) }.
unique().
sort { a, b -> a <=> b },
- "io": IO.class.getFields().
- sort{ a, b -> a.name <=> b.name }.
- collectEntries{ f -> [(f.name) : f.get(null)]},
+ "tokens": gatherTokensFrom([IO, ConnectedComponent, ShortestPath, PageRank, PeerPressure]),
"toPython": toPython,
"toJava": toJava]
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c0a35e25/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
index 49bb7b1..4bb4c9c 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
@@ -304,11 +304,11 @@ def without(*args):
statics.add_static('without',without)
+
'''
IO
'''
-
class IO(object):
graphml = "graphml"
@@ -323,6 +323,58 @@ class IO(object):
writer = "~tinkerpop.io.writer"
+'''
+ConnectedComponent
+'''
+
+class ConnectedComponent(object):
+
+ component = "gremlin.connectedComponentVertexProgram.component"
+
+ edges = "~tinkerpop.connectedComponent.edges"
+
+ propertyName = "~tinkerpop.connectedComponent.propertyName"
+
+'''
+ShortestPath
+'''
+
+class ShortestPath(object):
+
+ distance = "~tinkerpop.shortestPath.distance"
+
+ edges = "~tinkerpop.shortestPath.edges"
+
+ includeEdges = "~tinkerpop.shortestPath.includeEdges"
+
+ maxDistance = "~tinkerpop.shortestPath.maxDistance"
+
+ target = "~tinkerpop.shortestPath.target"
+
+'''
+PageRank
+'''
+
+class PageRank(object):
+
+ edges = "~tinkerpop.pageRank.edges"
+
+ propertyName = "~tinkerpop.pageRank.propertyName"
+
+ times = "~tinkerpop.pageRank.times"
+
+'''
+PeerPressure
+'''
+
+class PeerPressure(object):
+
+ edges = "~tinkerpop.peerPressure.edges"
+
+ propertyName = "~tinkerpop.peerPressure.propertyName"
+
+ times = "~tinkerpop.peerPressure.times"
+
'''
[3/3] tinkerpop git commit: Improved handling of gremlin tokens in
.NET CTR
Posted by sp...@apache.org.
Improved handling of gremlin tokens in .NET CTR
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/fcabd01c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/fcabd01c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/fcabd01c
Branch: refs/heads/master
Commit: fcabd01c4425061334901082a81e62151adaeb64
Parents: 0598846
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Aug 31 14:03:50 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Aug 31 14:03:50 2018 -0400
----------------------------------------------------------------------
gremlin-dotnet/glv/IO.template | 46 ------------------
gremlin-dotnet/glv/Token.template | 43 +++++++++++++++++
gremlin-dotnet/glv/generate.groovy | 23 ++++++---
.../Process/Traversal/ConnectedComponent.cs | 47 ++++++++++++++++++
.../src/Gremlin.Net/Process/Traversal/IO.cs | 3 --
.../Gremlin.Net/Process/Traversal/PageRank.cs | 47 ++++++++++++++++++
.../Process/Traversal/PeerPressure.cs | 47 ++++++++++++++++++
.../Process/Traversal/ShortestPath.cs | 51 ++++++++++++++++++++
8 files changed, 251 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/glv/IO.template
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/IO.template b/gremlin-dotnet/glv/IO.template
deleted file mode 100644
index 7b25c88..0000000
--- a/gremlin-dotnet/glv/IO.template
+++ /dev/null
@@ -1,46 +0,0 @@
-#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
-
-// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-
-namespace Gremlin.Net.Process.Traversal
-{
-#pragma warning disable 1591
-
- /// <summary>
- /// <see cref="IO" /> keeps configuration options for the io() step.
- /// </summary>
- public class IO
- {
- <% io.each {k,v -> %>
- public const String <%= k %> = "<%= v %>";
- <% } %>
- }
-
-#pragma warning restore 1591
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/glv/Token.template
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/Token.template b/gremlin-dotnet/glv/Token.template
new file mode 100644
index 0000000..b86634a
--- /dev/null
+++ b/gremlin-dotnet/glv/Token.template
@@ -0,0 +1,43 @@
+#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
+
+// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
+namespace Gremlin.Net.Process.Traversal
+{
+#pragma warning disable 1591
+
+ public class <%= tokenName %>
+ {
+ <% tokenFields.each {k,v -> %>
+ public const String <%= k %> = "<%= v %>";
+ <% } %>
+ }
+
+#pragma warning restore 1591
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/glv/generate.groovy b/gremlin-dotnet/glv/generate.groovy
index 58a5026..0c93f3d 100644
--- a/gremlin-dotnet/glv/generate.groovy
+++ b/gremlin-dotnet/glv/generate.groovy
@@ -18,6 +18,10 @@
*/
import org.apache.tinkerpop.gremlin.jsr223.CoreImports
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ConnectedComponent
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.PageRank
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.PeerPressure
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ShortestPath
import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
@@ -225,6 +229,12 @@ def getGraphTraversalT2ForT2 = { t2 ->
return t2
}
+def gatherTokensFrom = { tokenClasses ->
+ def m = [:]
+ tokenClasses.each { tc -> m << [(tc.simpleName) : tc.getFields().sort{ a, b -> a.name <=> b.name }.collectEntries{ f -> [(f.name) : f.get(null)]}]}
+ return m
+}
+
def binding = ["pmethods": P.class.getMethods().
findAll { Modifier.isStatic(it.getModifiers()) }.
findAll { P.class.isAssignableFrom(it.returnType) }.
@@ -304,9 +314,7 @@ def binding = ["pmethods": P.class.getMethods().
def graphTraversalT2 = getGraphTraversalT2ForT2(t2)
return ["methodName": javaMethod.name, "t2":t2, "tParam":tParam, "parameters":parameters, "paramNames":paramNames, "callGenericTypeArg":callGenericTypeArg, "graphTraversalT2":graphTraversalT2]
},
- "io": IO.class.getFields().
- sort{ a, b -> a.name <=> b.name }.
- collectEntries{ f -> [(f.name) : f.get(null)]},
+ "tokens": gatherTokensFrom([IO, ConnectedComponent, ShortestPath, PageRank, PeerPressure]),
"toCSharpMethodName": toCSharpMethodName]
def engine = new groovy.text.GStringTemplateEngine()
@@ -326,10 +334,11 @@ def pTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/P.template
def pFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/P.cs")
pFile.newWriter().withWriter{ it << pTemplate }
-def ioTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/IO.template")).make(binding)
-def ioFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/IO.cs")
-ioFile.newWriter().withWriter{ it << ioTemplate }
-
+binding.tokens.each {k,v ->
+ def tokenTemplate = engine.createTemplate(new File("${projectBaseDir}/glv/Token.template")).make([tokenFields: v, tokenName: k])
+ def tokenFile = new File("${projectBaseDir}/src/Gremlin.Net/Process/Traversal/${k}.cs")
+ tokenFile.newWriter().withWriter{ it << tokenTemplate }
+}
def createEnum = { enumClass ->
def b = ["enumClass": enumClass,
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ConnectedComponent.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ConnectedComponent.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ConnectedComponent.cs
new file mode 100644
index 0000000..ca1f53e
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ConnectedComponent.cs
@@ -0,0 +1,47 @@
+#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
+
+// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
+namespace Gremlin.Net.Process.Traversal
+{
+#pragma warning disable 1591
+
+ public class ConnectedComponent
+ {
+
+ public const String component = "gremlin.connectedComponentVertexProgram.component";
+
+ public const String edges = "~tinkerpop.connectedComponent.edges";
+
+ public const String propertyName = "~tinkerpop.connectedComponent.propertyName";
+
+ }
+
+#pragma warning restore 1591
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
index 861b431..3a57d4b 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/IO.cs
@@ -32,9 +32,6 @@ namespace Gremlin.Net.Process.Traversal
{
#pragma warning disable 1591
- /// <summary>
- /// <see cref="IO" /> keeps configuration options for the io() step.
- /// </summary>
public class IO
{
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PageRank.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PageRank.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PageRank.cs
new file mode 100644
index 0000000..73d248a
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PageRank.cs
@@ -0,0 +1,47 @@
+#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
+
+// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
+namespace Gremlin.Net.Process.Traversal
+{
+#pragma warning disable 1591
+
+ public class PageRank
+ {
+
+ public const String edges = "~tinkerpop.pageRank.edges";
+
+ public const String propertyName = "~tinkerpop.pageRank.propertyName";
+
+ public const String times = "~tinkerpop.pageRank.times";
+
+ }
+
+#pragma warning restore 1591
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PeerPressure.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PeerPressure.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PeerPressure.cs
new file mode 100644
index 0000000..185879e
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/PeerPressure.cs
@@ -0,0 +1,47 @@
+#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
+
+// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
+namespace Gremlin.Net.Process.Traversal
+{
+#pragma warning disable 1591
+
+ public class PeerPressure
+ {
+
+ public const String edges = "~tinkerpop.peerPressure.edges";
+
+ public const String propertyName = "~tinkerpop.peerPressure.propertyName";
+
+ public const String times = "~tinkerpop.peerPressure.times";
+
+ }
+
+#pragma warning restore 1591
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fcabd01c/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ShortestPath.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ShortestPath.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ShortestPath.cs
new file mode 100644
index 0000000..f125e42
--- /dev/null
+++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/ShortestPath.cs
@@ -0,0 +1,51 @@
+#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
+
+// THIS IS A GENERATED FILE - DO NOT MODIFY THIS FILE DIRECTLY - see pom.xml
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
+namespace Gremlin.Net.Process.Traversal
+{
+#pragma warning disable 1591
+
+ public class ShortestPath
+ {
+
+ public const String distance = "~tinkerpop.shortestPath.distance";
+
+ public const String edges = "~tinkerpop.shortestPath.edges";
+
+ public const String includeEdges = "~tinkerpop.shortestPath.includeEdges";
+
+ public const String maxDistance = "~tinkerpop.shortestPath.maxDistance";
+
+ public const String target = "~tinkerpop.shortestPath.target";
+
+ }
+
+#pragma warning restore 1591
+}
\ No newline at end of file
[2/3] tinkerpop git commit: Improved handling of gremlin tokens in
javascript CTR
Posted by sp...@apache.org.
Improved handling of gremlin tokens in javascript CTR
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/05988461
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/05988461
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/05988461
Branch: refs/heads/master
Commit: 05988461773662be765e6b7d256918e6edc0b71d
Parents: c0a35e2
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Aug 31 13:43:37 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Aug 31 13:43:37 2018 -0400
----------------------------------------------------------------------
gremlin-javascript/glv/TraversalSource.template | 13 +--
gremlin-javascript/glv/generate.groovy | 14 ++-
.../gremlin-javascript/lib/process/traversal.js | 105 +++++++++++++++----
3 files changed, 105 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/05988461/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index 321956c..ffe0fbc 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -111,13 +111,14 @@ class Traversal {
};
}
-class IO {
-<% io.each {k,v -> %>
- static get <%= k %>() {
- return "<%= v %>"
- }
+<% tokens.each { k,v -> %>
+class <%= k %> {
+<% v.each {a,b -> %>
+ static get <%= a %>() {
+ return "<%= b %>"
+ }
+<% } %>}
<% } %>
-}
class P {
/**
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/05988461/gremlin-javascript/glv/generate.groovy
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/generate.groovy b/gremlin-javascript/glv/generate.groovy
index a339689..aab55d4 100644
--- a/gremlin-javascript/glv/generate.groovy
+++ b/gremlin-javascript/glv/generate.groovy
@@ -20,6 +20,10 @@
import groovy.text.GStringTemplateEngine
import org.apache.tinkerpop.gremlin.jsr223.CoreImports
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ConnectedComponent
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.PageRank
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.PeerPressure
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ShortestPath
import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
@@ -50,6 +54,12 @@ def determineVersion = {
return mavenVersion.replace("-SNAPSHOT", "-alpha1")
}
+def gatherTokensFrom = { tokenClasses ->
+ def m = [:]
+ tokenClasses.each { tc -> m << [(tc.simpleName) : tc.getFields().sort{ a, b -> a.name <=> b.name }.collectEntries{ f -> [(f.name) : f.get(null)]}]}
+ return m
+}
+
def binding = ["enums": CoreImports.getClassImports()
.findAll { Enum.class.isAssignableFrom(it) }
.sort { a, b -> a.getSimpleName() <=> b.getSimpleName() },
@@ -89,9 +99,7 @@ def binding = ["enums": CoreImports.getClassImports()
collect { it.name }.
unique().
sort { a, b -> a <=> b },
- "io": IO.class.getFields().
- sort{ a, b -> a.name <=> b.name }.
- collectEntries{ f -> [(f.name) : f.get(null)]},
+ "tokens": gatherTokensFrom([IO, ConnectedComponent, ShortestPath, PageRank, PeerPressure]),
"toJs": toJs,
"version": determineVersion(),
"decapitalize": decapitalize]
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/05988461/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index 09aec91..2b9ba26 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -111,34 +111,103 @@ class Traversal {
};
}
+
class IO {
- static get graphml() {
- return "graphml"
- }
+ static get graphml() {
+ return "graphml"
+ }
- static get graphson() {
- return "graphson"
- }
+ static get graphson() {
+ return "graphson"
+ }
- static get gryo() {
- return "gryo"
- }
+ static get gryo() {
+ return "gryo"
+ }
- static get reader() {
- return "~tinkerpop.io.reader"
- }
+ static get reader() {
+ return "~tinkerpop.io.reader"
+ }
- static get registry() {
- return "~tinkerpop.io.registry"
- }
+ static get registry() {
+ return "~tinkerpop.io.registry"
+ }
- static get writer() {
- return "~tinkerpop.io.writer"
- }
+ static get writer() {
+ return "~tinkerpop.io.writer"
+ }
+}
+class ConnectedComponent {
+
+ static get component() {
+ return "gremlin.connectedComponentVertexProgram.component"
+ }
+
+ static get edges() {
+ return "~tinkerpop.connectedComponent.edges"
+ }
+
+ static get propertyName() {
+ return "~tinkerpop.connectedComponent.propertyName"
+ }
}
+class ShortestPath {
+
+ static get distance() {
+ return "~tinkerpop.shortestPath.distance"
+ }
+
+ static get edges() {
+ return "~tinkerpop.shortestPath.edges"
+ }
+
+ static get includeEdges() {
+ return "~tinkerpop.shortestPath.includeEdges"
+ }
+
+ static get maxDistance() {
+ return "~tinkerpop.shortestPath.maxDistance"
+ }
+
+ static get target() {
+ return "~tinkerpop.shortestPath.target"
+ }
+}
+
+class PageRank {
+
+ static get edges() {
+ return "~tinkerpop.pageRank.edges"
+ }
+
+ static get propertyName() {
+ return "~tinkerpop.pageRank.propertyName"
+ }
+
+ static get times() {
+ return "~tinkerpop.pageRank.times"
+ }
+}
+
+class PeerPressure {
+
+ static get edges() {
+ return "~tinkerpop.peerPressure.edges"
+ }
+
+ static get propertyName() {
+ return "~tinkerpop.peerPressure.propertyName"
+ }
+
+ static get times() {
+ return "~tinkerpop.peerPressure.times"
+ }
+}
+
+
class P {
/**
* Represents an operation.