Skip to content

Commit 5f5361e

Browse files
authored
Merge branch '3.7-dev' into TINKERPOP-2489
2 parents 77bb65b + 1624305 commit 5f5361e

File tree

19 files changed

+196
-81
lines changed

19 files changed

+196
-81
lines changed

CHANGELOG.asciidoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
3131
* Changed Gremlin grammar to make use of `g` to spawn child traversals a syntax error.
3232
* Added `unexpected-response` handler to `ws` for `gremlin-javascript`
3333
* Fixed bug in `TinkerTransactionGraph` where a read-only transaction may leave elements trapped in a "zombie transaction".
34-
* Changed 'gremlin-server.sh' to account for spaces in directory names.
34+
* Fixed bug in `gremlin.sh` where it couldn't accept a directory name containing spaces.
35+
* Fixed issue in `gremlin-console` where it couldn't accept plugin files that included empty lines or invalid plugin names.
36+
* Modified grammar to make `none()` usage more consistent as a filter step where it can now be used to chain additional traversal steps and be used anonymously.
37+
* Added missing anonymous support for `disjunct()` in Python and Javascript.
38+
* Fixed bug in 'gremlin-server.sh' to account for spaces in directory names.
3539
3640
[[release-3-7-3]]
3741
=== TinkerPop 3.7.3 (October 23, 2024)

gremlin-console/src/main/bin/gremlin.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,4 @@ fi
116116

117117
# Start the JVM, execute the application, and return its exit code
118118
# shellcheck disable=SC2068
119-
exec $JAVA ${JVM_OPTS[@]} org.apache.tinkerpop.gremlin.console.Console "$@"
119+
exec $JAVA "${JVM_OPTS[@]}" org.apache.tinkerpop.gremlin.console.Console "$@"

gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,15 @@ class Console {
151151
// if there are active plugins then initialize them in the order that they are listed
152152
activePlugins.each { pluginName ->
153153
def pluggedIn = mediator.availablePlugins[pluginName]
154-
pluggedIn.activate()
155154

156-
if (!io.quiet)
157-
io.out.println(Colorizer.render(Preferences.infoColor, "plugin activated: " + pluggedIn.getPlugin().getName()))
155+
if (pluggedIn != null) {
156+
pluggedIn.activate()
157+
158+
if (!io.quiet)
159+
io.out.println(Colorizer.render(Preferences.infoColor, "plugin activated: " + pluggedIn.getPlugin().getName()))
160+
} else if (!io.quiet) {
161+
io.out.println(Colorizer.render(Preferences.infoColor, "invalid plugin: " + pluginName))
162+
}
158163
}
159164

160165
// remove any "uninstalled" plugins from plugin state as it means they were installed, activated, but not

gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor
2222

2323
import java.util.concurrent.atomic.AtomicBoolean
2424

25+
import org.apache.commons.lang3.StringUtils
26+
2527
/**
2628
* @author Stephen Mallette (http://stephen.genoprime.com)
2729
*/
@@ -104,7 +106,7 @@ class Mediator {
104106

105107
static def readPluginState() {
106108
def file = new File(ConsoleFs.PLUGIN_CONFIG_FILE)
107-
return file.exists() ? file.readLines() : []
109+
return file.exists() ? file.readLines().findAll { StringUtils.isNotEmpty(it) } : []
108110
}
109111

110112
def void close() {

gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/DefaultGremlinBaseVisitor.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ protected void notImplemented(final ParseTree ctx) {
143143
* {@inheritDoc}
144144
*/
145145
@Override public T visitChainedTraversal(final GremlinParser.ChainedTraversalContext ctx) { notImplemented(ctx); return null; }
146-
/**
147-
* {@inheritDoc}
148-
*/
149-
@Override public T visitChainedParentOfGraphTraversal(final GremlinParser.ChainedParentOfGraphTraversalContext ctx) { notImplemented(ctx); return null; }
150146
/**
151147
* {@inheritDoc}
152148
*/
@@ -615,6 +611,10 @@ protected void notImplemented(final ParseTree ctx) {
615611
* {@inheritDoc}
616612
*/
617613
@Override public T visitTraversalMethod_min_Scope(final GremlinParser.TraversalMethod_min_ScopeContext ctx) { notImplemented(ctx); return null; }
614+
/**
615+
* {@inheritDoc}
616+
*/
617+
@Override public T visitTraversalMethod_none(final GremlinParser.TraversalMethod_noneContext ctx) { notImplemented(ctx); return null; }
618618
/**
619619
* {@inheritDoc}
620620
*/
@@ -1119,10 +1119,6 @@ protected void notImplemented(final ParseTree ctx) {
11191119
* {@inheritDoc}
11201120
*/
11211121
@Override public T visitTraversalSackMethod(final GremlinParser.TraversalSackMethodContext ctx) { notImplemented(ctx); return null; }
1122-
/**
1123-
* {@inheritDoc}
1124-
*/
1125-
@Override public T visitTraversalSelfMethod(final GremlinParser.TraversalSelfMethodContext ctx) { notImplemented(ctx); return null; }
11261122
/**
11271123
* {@inheritDoc}
11281124
*/
@@ -1247,10 +1243,6 @@ protected void notImplemented(final ParseTree ctx) {
12471243
* {@inheritDoc}
12481244
*/
12491245
@Override public T visitTraversalTerminalMethod_toBulkSet(final GremlinParser.TraversalTerminalMethod_toBulkSetContext ctx) { notImplemented(ctx); return null; }
1250-
/**
1251-
* {@inheritDoc}
1252-
*/
1253-
@Override public T visitTraversalSelfMethod_none(final GremlinParser.TraversalSelfMethod_noneContext ctx) { notImplemented(ctx); return null; }
12541246
/**
12551247
* {@inheritDoc}
12561248
*/

gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitor.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@
1818
*/
1919
package org.apache.tinkerpop.gremlin.language.grammar;
2020

21-
import org.apache.tinkerpop.gremlin.process.traversal.Merge;
2221
import org.apache.tinkerpop.gremlin.process.traversal.Operator;
2322
import org.apache.tinkerpop.gremlin.process.traversal.Order;
2423
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
2524
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
2625
import org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality;
2726

28-
import java.util.LinkedHashMap;
2927
import java.util.Map;
3028

3129
import java.util.function.BiFunction;
@@ -1082,6 +1080,14 @@ public GraphTraversal visitTraversalMethod_min_Scope(final GremlinParser.Travers
10821080
return graphTraversal.min(antlr.argumentVisitor.parseScope(ctx.traversalScopeArgument()));
10831081
}
10841082

1083+
/**
1084+
* {@inheritDoc}
1085+
*/
1086+
@Override
1087+
public GraphTraversal visitTraversalMethod_none(final GremlinParser.TraversalMethod_noneContext ctx) {
1088+
return this.graphTraversal.none();
1089+
}
1090+
10851091
/**
10861092
* {@inheritDoc}
10871093
*/

gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalRootVisitor.java

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ public TraversalRootVisitor(final GremlinAntlrToJava antlr, final Traversal trav
5656
public Traversal visitNestedTraversal(final GremlinParser.NestedTraversalContext ctx) {
5757
if (ctx.getChild(0) instanceof GremlinParser.RootTraversalContext) {
5858
return visitChildren(ctx);
59-
} else if (ctx.getChild(2) instanceof GremlinParser.ChainedParentOfGraphTraversalContext) {
60-
return new TraversalRootVisitor<Traversal>(antlr.createAnonymous.get()).
61-
visitChainedParentOfGraphTraversal(ctx.chainedTraversal().chainedParentOfGraphTraversal());
6259
} else {
6360
return new TraversalMethodVisitor(antlr, antlr.createAnonymous.get()).visitChainedTraversal(ctx.chainedTraversal());
6461
}
@@ -79,53 +76,14 @@ public Traversal visitRootTraversal(final GremlinParser.RootTraversalContext ctx
7976
(GremlinParser.TraversalSourceSpawnMethodContext) ctx.getChild(childIndexOfTraversalSourceSpawnMethod));
8077

8178
if (ctx.getChildCount() == 5) {
82-
// handle chained traversal
83-
final int childIndexOfChainedTraversal = 4;
84-
85-
if (ctx.getChild(childIndexOfChainedTraversal) instanceof GremlinParser.ChainedParentOfGraphTraversalContext) {
86-
final TraversalRootVisitor traversalRootVisitor = new TraversalRootVisitor(traversal);
87-
return traversalRootVisitor.visitChainedParentOfGraphTraversal(
88-
(GremlinParser.ChainedParentOfGraphTraversalContext) ctx.getChild(childIndexOfChainedTraversal));
89-
} else {
90-
final TraversalMethodVisitor traversalMethodVisitor = new TraversalMethodVisitor(antlr, traversal);
91-
return traversalMethodVisitor.visitChainedTraversal(
92-
(GremlinParser.ChainedTraversalContext) ctx.getChild(childIndexOfChainedTraversal));
93-
}
79+
final TraversalMethodVisitor traversalMethodVisitor = new TraversalMethodVisitor(antlr, traversal);
80+
return traversalMethodVisitor.visitChainedTraversal(
81+
(GremlinParser.ChainedTraversalContext) ctx.getChild(4));
9482
} else {
9583
return traversal;
9684
}
9785
}
9886

99-
/**
100-
* {@inheritDoc}
101-
*/
102-
@Override
103-
public Traversal visitTraversalSelfMethod(final GremlinParser.TraversalSelfMethodContext ctx) {
104-
return visitChildren(ctx);
105-
}
106-
107-
/**
108-
* {@inheritDoc}
109-
*/
110-
@Override
111-
public Traversal visitTraversalSelfMethod_none(final GremlinParser.TraversalSelfMethod_noneContext ctx) {
112-
this.traversal = traversal.none();
113-
return this.traversal;
114-
}
115-
116-
/**
117-
* {@inheritDoc}
118-
*/
119-
@Override
120-
public Traversal visitChainedParentOfGraphTraversal(final GremlinParser.ChainedParentOfGraphTraversalContext ctx) {
121-
if (ctx.getChildCount() == 1) {
122-
return visitChildren(ctx);
123-
} else {
124-
visit(ctx.getChild(0));
125-
return visit(ctx.getChild(2));
126-
}
127-
}
128-
12987
/**
13088
* {@inheritDoc}
13189
*/

gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/__.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,13 @@ public static <A> GraphTraversal<A, A> is(final Object value) {
10601060
return __.<A>start().is(value);
10611061
}
10621062

1063+
/**
1064+
* @see GraphTraversal#none()
1065+
*/
1066+
public static <A> GraphTraversal<A, A> none() {
1067+
return __.<A>start().none();
1068+
}
1069+
10631070
/**
10641071
* @see GraphTraversal#not(Traversal)
10651072
*/

gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalMethodVisitorTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,4 +1298,11 @@ public void shouldParseTraversalMethod_substring_long() throws Exception {
12981298
public void shouldParseTraversalMethod_substring_long_long() throws Exception {
12991299
compare(g.V().substring(1, 3), eval("g.V().substring(1, 3)"));
13001300
}
1301+
1302+
@Test
1303+
public void shouldParseTraversalMethod_none_somethingAfter() throws Exception {
1304+
compare(g.V().none().path(), eval("g.V().none().path()"));
1305+
compare(g.V().none().E(), eval("g.V().none().E()"));
1306+
compare(g.V().none().none(), eval("g.V().none().none()"));
1307+
}
13011308
}

gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslatorTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
2727
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
2828
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
29-
import org.apache.tinkerpop.gremlin.process.traversal.lambda.CardinalityValueTraversal;
3029
import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SeedStrategy;
3130
import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy;
3231
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
@@ -61,6 +60,20 @@ public void shouldTranslateOption() {
6160
assertEquals("g.V().has('person','name','marko')", gremlinAsPython);
6261
}
6362

63+
@Test
64+
public void shouldTranslateValues() {
65+
final String gremlinAsPython = translator.translate(
66+
g.V().values("age").asAdmin().getBytecode()).getScript();
67+
assertEquals("g.V().age", gremlinAsPython);
68+
}
69+
70+
@Test
71+
public void shouldTranslateNone() {
72+
final String gremlinAsPython = translator.translate(
73+
g.V().none().asAdmin().getBytecode()).getScript();
74+
assertEquals("g.V().none()", gremlinAsPython);
75+
}
76+
6477
@Test
6578
public void shouldTranslateCardinality() {
6679
final String gremlinAsPython = translator.translate(

0 commit comments

Comments
 (0)