编译程序时C++ Vertica 错误::VerticaTypeâ 没有名为 'getVarcharLength' 的成员
Vertica Error while compiling C++ program : :VerticaTypeâ has no member named âgetVarcharLengthâ
代码:
// Include the top-level Vertica SDK file
#include "/opt/vertica/sdk/include/Vertica.h"
#include <sstream>
#include <iostream>
using namespace Vertica;
using namespace std;
// Using the Vertica namespace means we don't have to prefix all
// class references with Vertica::
using namespace Vertica;
/*
* ScalarFunction implementation for a UDSF that adds
* two numbers together.
*/
class Add2Ints : public ScalarFunction
{
public:
/*
* This function does all of the actual processing for the UDF.
* In this case, it simply reads two integer values and returns
* their sum.
*
* The inputs are retrieved via arg_reader
* The outputs are returned via arg_writer
*/
virtual void processBlock(ServerInterface &srvInterface,
BlockReader &arg_reader,
BlockWriter &res_writer)
{
// While we have input to process
do
{
// Read the two integer input parameters by calling the
// BlockReader.getIntRef class function
const vint a = arg_reader.getIntRef(0);
const vint b = arg_reader.getIntRef(1);
// Call BlockWriter.setInt to store the output value, which is
// two input values added together
res_writer.setInt(a+b);
// Finish writing the row, and advance to the next output row
res_writer.next();
// Continue looping until there are no more input rows
}
while (arg_reader.next());
}
};
/*
* This class provides metadata about the ScalarFunction class, and
* also instantiates a member of that class when needed.
*/
class Add2IntsFactory : public ScalarFunctionFactory
{
// return an instance of Add2Ints to perform the actual addition.
virtual ScalarFunction *createScalarFunction(ServerInterface &interface)
{
// Calls the vt_createFuncObj to create the new Add2Ints class instance.
return vt_createFuncObj(interface.allocator, Add2Ints);
}
virtual void getPrototype(ServerInterface &interface,
ColumnTypes &argTypes,
ColumnTypes &returnType)
{
// Takes two ints as inputs, so add ints to the argTypes object
argTypes.addInt();
argTypes.addInt();
// returns a single int, so add a single int to the returnType object.
// Note that ScalarFunctions *always* return a single value.
returnType.addInt();
}
};
// Determine the length of the varchar string being returned.
virtual void Add2IntsFactory::getReturnType(ServerInterface &srvInterface,const SizedColumnTypes &argTypes,SizedColumnTypes &returnType)
{
const VerticaType &t = argTypes.getColumnType(0);
returnType.addVarchar(t.getVarcharLength());
}
// Register the factory with Vertica
RegisterFactory(Add2IntsFactory);
错误:
"::"标记之前应为初始值设定项
你能帮忙吗?
Add2IntsFactory::getReturnType
是在类外声明的。你做不到。
相关文章:
- 将成员变量添加到共享库中的类中,不会破坏二进制兼容性吗
- 对RValue对象调用的LValue ref限定成员函数
- 为什么使用 "this" 指针调用派生成员函数?
- 具有奇怪重复模板模式的派生类中的成员变量已损坏
- 助记符和指向成员语法的指针
- 用于访问容器<T>数据成员的正确 API
- 内置函数可查看CPP中的成员变量
- 是否可以初始化不可复制类型的成员变量(或基类)
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- 找不到成员对象:没有名为get_event()的成员,也处理多态性和向量
- 嵌套在类中时无法设置成员数据
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 将函数类成员映射到类本身内部
- 基于另一个成员参数将函数调用从类传递给它的一个成员
- 将Ref对象作为类成员
- 将包含C样式数组的对象初始化为成员变量(C++)
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 将公共但非静态的成员函数与ALGLIB集成
- 多成员Constexpr结构初始化
- 我们可以访问一个不存在的联盟的成员吗