英文:
How to desialize Aerospike record in Go?
问题
我正在使用Aerospike中的相当复杂的模式:
数据模式:
bin名称:user_ids
类型:字符串列表
bin名称:user_w
类型:整数列表
bin名称:users
类型:map<String>,其中列表再次是类型为字符串的列表,每个列表的大小为3
我能够将此模式直接读入Java对象,并使用以下数据结构:
userIds = (List
userWeights = (List
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<String<List>> 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<String>) r.getList("user_ids");
userWeights = (List<String>) r.getList("user_w");
users = (Map<String, List>) r.getValue("users");
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论