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

标签 go aerospike

我在 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

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

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

但是我的以下 go struct 无法检索它。它的到来是空的。结构模式有问题吗?

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

最佳答案

您的 user_w 架构是整数列表还是字符串列表? 因为你的 java 和 go 模式在这里不等同。 这就是 Go struct 无法解析您的 aerospike 数据的原因。

关于go - 如何在 Go 中反序列化 Aerospike 记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39510413/

相关文章:

go - 如何修复 linter 警告 `Error return value is not checked`?

sql - 是否可以使用 GoLang 数据库/sql 按名称检索列值

go - 如何使用 golang 在 aerospike 中添加列表?

c++ - Libevent aerospike 客户端::是否可以在我的事件处理机制中注册 Aerospike FD

file-io - 如何在 Go 中写入文件

arrays - 数组 Varchar (psql) 到数组字符串 (golang)

go - 如何在 GoLang 测试用例中发送 google.protobuf.Struct 数据?

php - session_set_start_handler 抛出警告

aerospike - 看到 memory_used_index_bytes 有 4G 而没有索引

go - 如何使用 golang 遍历 aerospike 中的列表?