c++ - as_ldt_init 初始化失败——C++ 客户端

标签 c++ aerospike

就在我开始使用 aerospike 的前一天。我在使用 LDT(大型数据类型——大型列表)编写示例时遇到了一些问题。我想创建一个带有 currdate 并附加为键 (20160419_2000_List) 的键,稍后我将添加原始数据(字节数组)作为列表值。 为此,我能够正确连接数据库,但无法为列表创建 key 。你能指导我吗? 您可以引用以下代码以了解我在做什么。

 m_sTFPKeyStr.assign(datevalue);  //datavalue consists datatime string
        m_sTFPListStr.assign("List_");
        m_sTFPListStr.append(datevalue);
        as_key_init_str(&m_sTFPKey, m_sInputNameSpace.c_str(), m_sInputSetName.c_str(), m_sTFPKeyStr.c_str());

        if (!as_ldt_init(m_sTFPListKey, m_sTFPListStr.c_str(), AS_LDT_LLIST, NULL))
        {
            memset(logmessage, 0x0, sizeof(logmessage));
            sprintf(logmessage, "CDataBaseManager::SaveTFP Fails to initialize tfplist key %s", m_sTFPListStr.c_str());
            m_pCaptureManager->m_pLogMgr->LogMsg(logmessage);
            return;
        }

最佳答案

检查代码中 m_sTFPListStr 的长度。

将检查参数的函数 as_ldt_init 的代码:

as_ldt * as_ldt_init(as_ldt * ldt, const as_bin_name name, const as_ldt_type type, const as_udf_module_name module)
{
  if (!name || name[0] == '\0' || strlen(name) > AS_BIN_NAME_MAX_LEN
     || (module && strlen(module) > AS_UDF_MODULE_MAX_LEN) )
  {
    return NULL;
  }
  ...
}

作为 AS_BIN_NAME_MAX_LEN 的值:

#define AS_BIN_NAME_MAX_LEN (AS_BIN_NAME_MAX_SIZE - 1)
#define AS_BIN_NAME_MAX_SIZE 15

关于c++ - as_ldt_init 初始化失败——C++ 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36711651/

相关文章:

c++ - 函数模板语法的默认模板参数

c++ - 在获取程序的当前内存方面需要帮助

Python C++ 模块无法读取由 Windows 上的 Python 程序创建的文件

在 C 中将 gwan 与 aerospike db 连接起来

go - Aerospike Go Client : No available connections to the node. 连接池为空,限制连接数

java - 如果我改变了java类的包。旧序列化版本的反序列化仍然有效吗?

asp.net-core - Autofac 依赖解析异常

C++ 跳过调用中的第一个默认参数

c++ - 虚拟机上奇怪的程序延迟行为

java - Aerospike map 操作失败