Aerospike 客户端具有scanAll方法,用于从其存储中读取所有行。我在以下代码中使用它:
ScanPolicy policy = new ScanPolicy();
policy.concurrentNodes = true;
policy.priority = Priority.DEFAULT;
policy.includeBinData = true;
policy.scanPercent = 100;
client.scanAll(policy, "namespaceName", "setName", new ScanCallback() {
@Override
public void scanCallback(Key key, Record record) throws AerospikeException {
STORE.put(key.userKey.toLong(), record.getValue("binName").toString());
}
});
但它以 结束NullPointerException
,因为 userKey 为空。所有其他字段都按预期有效。用户键是 Long 值,用于保存数据:
client.put(writePolicy, new Key("namespaceName", "setName", userKey), new Bin("binName", value));
一切都很好,如果我做这样的单一请求:
client.get(readPolicy, new Key("namespaceName", "setName", userKey));
可能有什么问题?为什么 userKey 为空?