Date
1 - 3 of 3
Failing to store List as property value
mkj....@...
I have this code: JanusGraph graph = JanusGraphFactory.open("/janusgraph-0.2.0-hadoop2/conf/janusgraph-cassandra.properties"); JanusGraphManagement mgmt = graph.openManagement(); mgmt.makePropertyKey("test1").dataType(String.class).cardinality(Cardinality.LIST).make(); mgmt.commit(); JanusGraphVertex v = graph.addVertex(); ArrayList al = new ArrayList(); al.add("aaa"); al.add("bbb"); v.property("test1", al); System.out.println("V = " + v); ArrayList al1 = (ArrayList)v.property("test1"); System.out.println(al1); i am getting this error: Exception in thread "main" java.lang.ClassCastException: org.janusgraph.graphdb.relations.StandardVertexProperty cannot be cast to java.util.ArrayList |
|
Debasish Kanhar <d.k...@...>
Hi Manish, Well you are adding List property to JanusGraph in wrong way. The way I do to create List properties once the schema is defined is as follows: The following things should work, and if it doesn't let us know.
Now we have to iterate over the list elements, and add it to JanusGraphVertex v object as follows:
Or else, if you want to add manually, this should suffice:
As you can see, gremlin doesn't expect you to pass List, and it will parse that list into property. Rather it expects you to pass the list element wise, and it keeps on appending to property key which you defined as List in schema declaration. If the same wasn't declared as List in schema, then it replaces the prior value. |
|
Debasish Kanhar <d.k...@...>
And next time please use JanusGraph users mailing list for such queries :-) On Sunday, 19 August 2018 14:12:42 UTC+5:30, Debasish Kanhar wrote:
|
|