如何在Go中反序列化Aerospike记录?

huangapple go评论70阅读模式
英文:

How to desialize Aerospike record in Go?

问题

我正在使用Aerospike中的相当复杂的模式:

数据模式:
bin名称:user_ids
类型:字符串列表

bin名称:user_w
类型:整数列表

bin名称:users
类型:map<String>,其中列表再次是类型为字符串的列表,每个列表的大小为3

我能够将此模式直接读入Java对象,并使用以下数据结构:

userIds = (List) r.getList("user_ids");
userWeights = (List) r.getList("user_w");
users = (Map<String, List>) r.getValue("users");

然而,我的以下Go结构无法检索它。它为空。结构模式有问题吗?

type AudienceRecord struct {
user_ids []string
user_w []int64
users map[string][][]string
}

英文:

I am having quite complex schema in aerospike:-

DATA SCHEMA:
bin name: user_ids
Type: List of Strings

bin name: user_w
Type: List of Integers

bin name: users
Type: map&lt;String&lt;List&gt;&gt; where list is again list(size 3) of lists each of type String

I am able to read this schema directly into Java object with following data structure:-

		userIds = (List&lt;String&gt;) r.getList(&quot;user_ids&quot;);
		userWeights = (List&lt;String&gt;) r.getList(&quot;user_w&quot;);
		users = (Map&lt;String, List&gt;) r.getValue(&quot;users&quot;);

However my following go struct is not able to retrieve it. Its coming as empty. Is something wrong with the struct schema?

type AudienceRecord struct {
    user_ids []string
    user_w  []int64
    users   map[string][][]string
}

答案1

得分: 1

您的user_w模式是整数列表还是字符串列表?因为您的Java和Go模式在这里并不等价。这就是为什么Go结构无法解析您的Aerospike数据的原因。

英文:

Your user_w schema is either List of integers, or list of strings ?
Because your java and go schemas aren't equivalent here.
That is why Go struct is not able to parse your aerospike data.

huangapple
  • 本文由 发表于 2016年9月15日 19:55:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/39510413.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定