opencypher / cypher-for-gremlin

Cypher for Gremlin adds Cypher support to any Gremlin graph database.
Apache License 2.0
359 stars 48 forks source link

Add support for SET params with array #267

Closed mad closed 5 years ago

mad commented 5 years ago

236

Signed-off-by: Pavel Ershov owner.mad.epa@gmail.com

dwitry commented 5 years ago

Hello @mad,

this PR allows to produce translation for setting collections in properties. However in my case it still fails on JanusGraph with Property value [[1, 2]] is of type class java.util.ArrayList is not supported.

Have you managed to configure it on JanusGraph side? If so, could you please share configuration.

mad commented 5 years ago

Hello @dwitry

I defined property with String[].class datatype, and StringArraySerializer do conversion from Iterable to String[]

dwitry commented 5 years ago

Hello @mad,

could you please share your JanusGraph configuration?

attributes.custom.attribute1.attribute-class = java.lang.String[].class
attributes.custom.attribute1.serializer-class = org.janusgraph.graphdb.database.serialize.attribute.StringArraySerializer

Fails on startup in my case.

mad commented 5 years ago

Hello @dwitry

class Scratch {
    public static void main(String[] args) {
        JanusGraph graph = JanusGraphFactory.open("inmemory");
        JanusGraphManagement mgmt = graph.openManagement();
        mgmt.makePropertyKey("P").dataType(String[].class).make();
        mgmt.commit();

        GraphTraversalSource traversal = graph.traversal();

        traversal.addV("A").property("P", Lists.newArrayList("a", "b")).iterate();
        Assert.assertArrayEquals(new String[] { "a", "b" }, (String[]) traversal.V().values("P").next());
        graph.close();
    }
}
dwitry commented 5 years ago
mad commented 5 years ago

@dwitry

No, default StringArraySerializer it is enough for handle String[] and all Iterable<String> see StandardSerializer and ArraySerializer.convertInternal

But if we defined property with ArrayList data type we need to register special serializer that provided by https://github.com/pluradj/janusgraph-attribute-serializer