Skip to content

Commit

Permalink
Revert #218 as support was removed on Neptune
Browse files Browse the repository at this point in the history
- Document specific

Signed-off-by: Dwitry [email protected]
  • Loading branch information
dwitry committed Jan 18, 2019
1 parent 40c3cc0 commit 7bae7bd
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ public interface SkipWithNeptune {
interface Limit0 extends SkipWithNeptune {
}

/**
* Unable to start traversal with `.inject` step.
* error message : no viable alternative at input 'g.inject'
*
* @see SpecificsTest#gInjectGremlin()
* @see SpecificsTest#gInject()
* @see NeptuneFlavor#injectWorkaround(Seq) Workaround
*/
interface gInject extends SkipWithNeptune {
}

/**
* Count step traversal is not aliased.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private List<Map<String, Object>> submitAndGet(String cypher) {
public void return100Elements() throws Exception {
Client client = gremlinServer.gremlinClient();

client.submit("g.inject(1).times(100).repeat(addV().property('the_property', 'the_value'))").all().get();
client.submit("g.V().limit(0).inject(1).times(100).repeat(addV().property('the_property', 'the_value'))").all().get();

List<Result> results = client.submit("g.V()").all().get();

Expand Down Expand Up @@ -226,4 +226,30 @@ public void noExceptionDetailMessage() throws Exception {
assertThatThrownBy(() -> client.submit("g.inject(1).math('_ / 0')").all().get())
.hasMessageContaining("Division by zero");
}

/**
* @see #gInject()
*/
@Test
@Category(SkipWithNeptune.gInject.class)
public void gInjectGremlin() throws Exception {
Client client = gremlinServer.gremlinClient();

String test = client.submit("g.inject('test')").one().getString();

assertThat(test).isEqualTo("test");
}

/**
* @see NeptuneFlavor#injectWorkaround(Seq)
*/
@Test
public void gInject() throws Exception {
List<Map<String, Object>> results = submitAndGet("RETURN 'test' as r");

assertThat(results)
.extracting("r")
.containsExactly("test");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.opencypher.gremlin.translation.ir.model.{GremlinStep, _}
object NeptuneFlavor extends GremlinRewriter {
override def apply(steps: Seq[GremlinStep]): Seq[GremlinStep] = {
Seq(
injectWorkaround(_),
limit0Workaround(_),
multipleLabelsWorkaround(_),
aggregateWithSameNameWorkaround(_),
Expand Down Expand Up @@ -80,6 +81,15 @@ object NeptuneFlavor extends GremlinRewriter {
})(bySteps)
}

private def injectWorkaround(steps: Seq[GremlinStep]): Seq[GremlinStep] = {
steps match {
case Inject(s) :: rest =>
Vertex :: Limit(0) :: Inject(s) :: rest
case _ =>
steps
}
}

private def limit0Workaround(steps: Seq[GremlinStep]): Seq[GremlinStep] = {
replace({
case Barrier :: Limit(0) :: rest =>
Expand Down

0 comments on commit 7bae7bd

Please sign in to comment.