Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Titan 0.9.0.M2自定义属性序列化程序-HashMap作为属性值_Titan - Fatal编程技术网

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

Titan 0.9.0.M2自定义属性序列化程序-HashMap作为属性值,titan,Titan,泰坦版本:0.9.0.M2 我正在尝试实现一个自定义序列化程序,以便将HashMap用作属性值。我已根据中提供的说明编写了我的课程。它实现了AttributeSerializer,有一个equals方法,最后是一个无参数构造函数 我已按如下方式设置配置选项: attributes.custom.attribute10.attribute-class=java.util.HashMap attributes.custom.attribute10.serializer-class=com.graph

泰坦版本:0.9.0.M2

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

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

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

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

请评论我是否这样做是正确的方法,以及可能的解决方案。我在一篇与Titan相关的文章中读到,一些配置键可能会随着版本的不同而变化,这可能是原因吗

还有谁能评论一下如何指定完整的“自定义类”名称、“自定义序列化程序”名称以及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

:你好,杰森,谢谢你的意见。我已经正确配置了图形,并且能够添加HashMap属性。但当我尝试检索附加值时,我得到一个“线程“main”java.lang.ArrayIndexOutOfBoundsException中的异常:所需大小[1]超过实际剩余大小[0]”错误。我已经发布了HashMapSerializer类的代码以及完整的堆栈跟踪。如果时间允许,请看一下并提供一些意见。另外,在回答中执行上述步骤后,您是否通过添加和检索HashMap属性值来测试它?