Titan 0.9.0.M2自定义属性序列化程序 - HashMap作为属性值

时间:2015-07-22 00:45:47

标签: titan

泰坦版:0.9.0.M2

我正在尝试使用HashMap作为属性值来实现自定义序列化程序。我根据here中提供的说明写了我的课。它实现了AttributeSerializer,有一个equals方法,最后是一个无参数构造函数。

我已按如下方式设置配置选项:

attributes.custom.attribute10.attribute-class = java.util.HashMap  attributes.custom.attribute10.serializer-class = com.graph.HashMapSerializer

我已将序列化程序打包到jar中并放在Titan发行版的lib文件夹中。我试图启动Titan,但看到错误 '需要设置配置值:root.attributes.custom.serializer-class' 以及' 无法在'gremlin-server'日志中实例化配置的序列化程序类 '。我尝试了很多选项,包括更改属性编号和放在几个不同位置的jar中,但没有成功。

请以正确的方式评论我是否正在这样做以及可能的解决方案。我在Titan相关帖子中读过一些配置键可能会因版本而异,这可能是某种原因吗?

也有人可以评论如何指定完整的“自定义类”名称,“自定义序列化器”名称以及放置jar的确切位置吗?

感谢您的时间。

1 个答案:

答案 0 :(得分:2)

将jar放在$TITAN_HOME/lib下很好,但我认为你的属性应该是这样的:

attributes.custom.attribute1.attribute-class = java.util.HashMap
attributes.custom.attribute1.serializer-class = com.graph.HashMapSerializer

文档中的示例提到他们已经配置了9个自定义属性,这就是它使用attribute10的原因。您可以使用TitanManagement界面验证图表中设置了哪些序列化程序。

$ ./bin/gremlin.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.tinkergraph
plugin activated: aurelius.titan
gremlin> graph = TitanFactory.build().set('storage.backend','berkeleyje').set('storage.directory','/home/vagrant/titan-0.9.0-SNAPSHOT-hadoop1/db/berkeley').open()
==>standardtitangraph[berkeleyje:/home/vagrant/titan-0.9.0-SNAPSHOT-hadoop1/db/berkeley]
gremlin> mgmt = graph.openManagement()
==>com.thinkaurelius.titan.graphdb.database.management.ManagementSystem@78226c36
gremlin> mgmt.get('attributes.custom.attribute10.attribute-class')
==>null
gremlin> mgmt.get('attributes.custom.attribute1.attribute-class')
==>java.util.HashMap