1

Let's say I have two nodes - A and B.

I am trying to merge these two nodes in a graph using gremlin - Java. Was able to generate the query using this SO answer - https://stackoverflow.com/a/46435070

g.V(parentNode).union(identity(), janusClient.g.V(aliasNode))
  .unfold()
  .sideEffect(properties().group("p").by(T.key).by(value()))
  .sideEffect(__.outE().group("o").by(T.label).by(__.project("p","iv").by(__.valueMap()).by(__.inV()).fold()))
  .sideEffect(__.inE().group("i").by(T.label).by(__.project("p","ov").by(__.valueMap()).by(__.outV()).fold()))
  .sideEffect(__.drop())
  .cap("p","o","i").as("poi")
  .addV().as("u")
  .sideEffect(
      __.select("poi").select("p").unfold().as("kv")
        .select("u").property(__.select("kv").select(Column.keys), __.select("kv").select(Column.values)))
  .sideEffect(
      __.select("poi").select("o").unfold().as("x").select(Column.values)
        .unfold().addE(__.select("x").select(Column.keys)).from(__.select("u")).to(__.select("iv")))
  .sideEffect(
      __.select("poi").select("i").unfold().as("x").select(Column.values)
        .unfold().addE(__.select("x").select(Column.keys)).from(__.select("ov")).to(__.select("u"))).iterate();

The problem is with this line .addE(__.select("x").select(Column.keys)) in the last sideEffect step. This does not compile since .addE expects argument of type Traversal while __.select("x").select(Column.keys) returns a result of type GraphTraversal.

Replacing with String.valueOf(.addE(__.select("x").select(Column.keys))) does not yield the desired results.

Any help appreciated!

G-Ark
  • 78
  • 4

1 Answers1

1

I think you might just have a generics problem perhaps? addE(Traversal<?, String>) was added at 3.3.1 but you're trying to give it a GraphTraversal<S, Collection<E2>> where E2 I should be a String in this case. You should be able to workaround it with a bit of type erasure - just cast to Traversal:

addE((Traversal) __.select("x").select(Column.keys))
stephen mallette
  • 45,298
  • 5
  • 67
  • 135