Custom attribute serializer

503 views
Skip to first unread message

J MacNaught

unread,
Sep 11, 2017, 5:42:02 PM9/11/17
to JanusGraph users
Hi all,

I'm porting my application from Titan to JanusGraph.

I was able to define a custom serializer for certain Java types, for example, ArrayList.

I cannot get this to work in JanusGraph.

I have this in my configuration: 

root.attributes.custom.attribute1.attribute-class=java.util.HashMap
root.attributes.custom.attribute1.serializer-class=com.ibm.research.psyche.core.serializer.GenericSerializer
root.attributes.custom.attribute2.attribute-class = java.util.LinkedHashMap
root.attributes.custom.attribute2.serializer-class = com.ibm.research.psyche.core.serializer.GenericSerializer
root.attributes.custom.attribute3.attribute-class = java.util.ArrayList
root.attributes.custom.attribute3.serializer-class = com.ibm.research.psyche.core.serializer.GenericSerializer
root.attributes.custom.attribute4.attribute-class = java.util.LinkedList
root.attributes.custom.attribute4.serializer-class = com.ibm.research.psyche.core.serializer.GenericSerializer


I get this error when defining the property:

java.lang.IllegalArgumentException: Not a supported data type: class java.util.ArrayList

at com.google.common.base.Preconditions.checkArgument(Preconditions.java:120) ~[guava-15.0.jar:?]

at org.janusgraph.graphdb.types.StandardPropertyKeyMaker.make(StandardPropertyKeyMaker.java:93) ~[janusgraph-core-0.1.1.jar:?]

.....



Are custom attributes supported anymore?

Note that the Configuration Reference in the documentations says that the option name should be this: 

attributes.custom.[X].attribute-class

But you get this error: java.lang.IllegalStateException: Need to set configuration value: root.attributes.custom.attribute-class


Thanks!

Jason Plurad

unread,
Sep 13, 2017, 2:42:44 PM9/13/17
to JanusGraph users
That functionality works. I've ported my Titan example over to JanusGraph. You shouldn't have "root." on your properties.
Note that JanusGraph registers a standard serializer for HashMap, so an exception would have been thrown if you attempted to register one for it.

J MacNaught

unread,
Sep 13, 2017, 5:30:03 PM9/13/17
to JanusGraph users
Thank you for the example, it helped to know it was supposed to work.  However, I couldn't get your example to work at first. I still got this error:
        java.lang.IllegalStateException: Need to set configuration value: root.attributes.custom.attribute-class
which is really not helpful because if you change the option name to "root.xxx" the error messages go away, but it's not really fixed.

Ultimately, the only way I could get it to work was to delete my cassandra database and start over.   I thought that options which were GLOBAL_OFFLINE could still be configured after DB initialization.

Robert Dale

unread,
Sep 13, 2017, 5:33:45 PM9/13/17
to J MacNaught, JanusGraph users
You can change it, just not through the properties file. You have to use the Management interface.   See  http://docs.janusgraph.org/latest/configuration.html#configuration-global

Robert Dale

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/f4aae20d-0702-40b3-add9-3ee43fbc6386%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

J MacNaught

unread,
Sep 13, 2017, 6:05:04 PM9/13/17
to JanusGraph users
Aha!
Perhaps it would be best to configure it programmatically from the beginning.  I already have a java program to define all my schema elements.

Robert Dale

To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-use...@googlegroups.com.

Rohit

unread,
Sep 26, 2018, 4:20:31 AM9/26/18
to JanusGraph users
I am getting below exception while running gremlin server.

Caused by: java.lang.IllegalArgumentException: Duplicate attribute registration: class java.util.HashMap and class java.util.HashMap

How to resolve this issue?






 Robert Dale wrote:

Robert Dale

To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-use...@googlegroups.com.

Jason Plurad

unread,
Sep 26, 2018, 11:15:28 AM9/26/18
to JanusGraph users
Do you have a stack trace? That would be helpful, as would more details on how you are registering your custom attribute serialization.

Rohit

unread,
Sep 27, 2018, 10:01:33 AM9/27/18
to JanusGraph users
Hi

We might have define custom attribute serializer for same class.

I have the attribute via Java Client.

mgmt = graph.openManagement();
mgmt.set("attributes.custom.attribute68.attribute-class", "java.util.HashMap");
mgmt.set("attributes.custom.attribute68.serializer-class", "com.vz.attribute.serializer.HashMapSerializer");
 
mgmt.commit();

And I am getting the below line printed as well
*** HashMapSerializer constructor

For the serializer , I have taken inputs from Janusgraph documentation plus your github repo.


however , In the next step I getting below Error


java.lang.IllegalArgumentException: Encountered missing datatype registration for number: 68
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145) ~[guava-18.0.jar:na]
at org.janusgraph.graphdb.database.serialize.StandardSerializer.getDataType(StandardSerializer.java:192) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.serialize.StandardSerializer.access$600(StandardSerializer.java:56) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.serialize.StandardSerializer$ClassSerializer.getClass(StandardSerializer.java:432) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.serialize.StandardSerializer$ClassSerializer.read(StandardSerializer.java:426) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.serialize.StandardSerializer$ClassSerializer.read(StandardSerializer.java:410) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.serialize.StandardSerializer.readObjectNotNullInternal(StandardSerializer.java:264) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.serialize.StandardSerializer.readClassAndObject(StandardSerializer.java:273) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.EdgeSerializer.readPropertyValue(EdgeSerializer.java:198) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.EdgeSerializer.readPropertyValue(EdgeSerializer.java:193) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.EdgeSerializer.parseRelation(EdgeSerializer.java:136) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.database.EdgeSerializer.readRelation(EdgeSerializer.java:73) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.transaction.RelationConstructor.readRelation(RelationConstructor.java:75) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.transaction.RelationConstructor$1$1.next(RelationConstructor.java:60) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.transaction.RelationConstructor$1$1.next(RelationConstructor.java:48) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.types.vertices.JanusGraphSchemaVertex.getDefinition(JanusGraphSchemaVertex.java:87) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.types.vertices.RelationTypeVertex.multiplicity(RelationTypeVertex.java:65) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.types.vertices.PropertyKeyVertex.cardinality(PropertyKeyVertex.java:36) ~[janusgraph-core-0.2.0.jar:na]
at org.janusgraph.graphdb.tinkerpop.JanusGraphFeatures$JanusGraphVertexFeatures.getCardinality(JanusGraphFeatures.java:160) ~[janusgraph-core-0.2.0.jar:na]
at org.apache.tinkerpop.gremlin.structure.util.Attachable$Method.lambda$createVertex$12(Attachable.java:296) ~[gremlin-core-3.3.1.jar:3.3.1]
at java.util.Iterator.forEachRemaining(Unknown Source) ~[na:1.8.0_73]
at org.apache.tinkerpop.gremlin.structure.util.Attachable$Method.createVertex(Attachable.java:293) ~[gremlin-core-3.3.1.jar:3.3.1]
at org.apache.tinkerpop.gremlin.structure.util.Attachable$Method.lambda$create$10(Attachable.java:149) ~[gremlin-core-3.3.1.jar:3.3.1]
at org.apache.tinkerpop.gremlin.structure.util.Attachable.attach(Attachable.java:63) ~[gremlin-core-3.3.1.jar:3.3.1]
at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader.lambda$readGraph$1(GraphSONReader.java:107) ~[gremlin-core-3.3.1.jar:3.3.1]
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source) ~[na:1.8.0_73]
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) ~[na:1.8.0_73]
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) ~[na:1.8.0_73]
at java.util.ArrayList$Itr.forEachRemaining(Unknown Source) ~[na:1.8.0_73]
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source) ~[na:1.8.0_73]
at java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[na:1.8.0_73]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[na:1.8.0_73]
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source) ~[na:1.8.0_73]
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source) ~[na:1.8.0_73]
at java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[na:1.8.0_73]
at java.util.stream.ReferencePipeline.forEach(Unknown Source) ~[na:1.8.0_73]
at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader.readGraph(GraphSONReader.java:105) ~[gremlin-core-3.3.1.jar:3.3.1]

rohit....@verizon.com

unread,
Sep 27, 2018, 10:11:46 AM9/27/18
to JanusGraph users
 I want this hashmap for data loading via graphson

as...@appranix.com

unread,
Jun 3, 2020, 8:32:34 AM6/3/20
to JanusGraph users
I am getting error: Need to set configuration value: root.attributes.custom.attribute-class while following https://github.com/pluradj/janusgraph-attribute-serializer
Please help me, someone.
Reply all
Reply to author
Forward
0 new messages