如何在aerospike

时间:2017-07-05 13:04:53

标签: null records aerospike aql

enter image description here我正在使用aerospike,在aql中我插入了一些数据,我希望获得有关airospike中特定字段的记录的空值,我在该图片中标记图片一条记录没有名称它的空白空间

2 个答案:

答案 0 :(得分:4)

Aeropsike是无模式的 - 每条记录都是自我描述的。任何非null的bin都是记录的一部分。任何更新为null的bin实际上都会从记录中删除。因此,请考虑记录单位而不是带有列的表。您可以从记录中查询特定的bin,如果没有找到,Aeropsike将返回null。这是java API:

public final Record get(Policy policy,
         Key key,
         String... binNames)
                 throws AerospikeException
Read record header and bins for specified key. The policy can be used to specify timeouts.
Specified by:
get in interface IAerospikeClient
Parameters:
policy - generic configuration parameters, pass in null for defaults
key - unique record identifier
binNames - bins to retrieve
Returns:
if found, return record instance. If not found, return null.
Throws:
AerospikeException - if read fails

答案 1 :(得分:1)

运行一些测试代码 - 记录密钥对其他一些分箱有效:

userRecord = client.get(null, userKey, "notThereBin");
    if (userRecord != null) {
        console.printf("\nINFO: User record with notThereBin read successfully! Here are the details:\n");
        console.printf("notThereBin:  " + userRecord.getValue("notThereBin") + "\n");
    } else {
        console.printf("ERROR: User record not found!\n");
    }

,输出为:

    INFO: User record with notThereBin read successfully! Here are the details:

notThereBin:  null