提交 2b566dab 编写于 作者: S slzhou

fix: add function not implemented error

上级 844a0830
......@@ -80,10 +80,6 @@ typedef struct SUdfInterBuf {
} SUdfInterBuf;
typedef void *UdfcFuncHandle;
// dynamic lib init and destroy
typedef int32_t (*TUdfInitFunc)();
typedef int32_t (*TUdfDestroyFunc)();
#define UDF_MEMORY_EXP_GROWTH 1.5
#define NBIT (3u)
#define BitPos(_n) ((_n) & ((1 << NBIT) - 1))
......@@ -252,6 +248,10 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentR
return 0;
}
// dynamic lib init and destroy for C UDF
typedef int32_t (*TUdfInitFunc)();
typedef int32_t (*TUdfDestroyFunc)();
typedef int32_t (*TUdfScalarProcFunc)(SUdfDataBlock *block, SUdfColumn *resultCol);
typedef int32_t (*TUdfAggStartFunc)(SUdfInterBuf *buf);
......
......@@ -711,7 +711,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_UDF_NO_FUNC_HANDLE TAOS_DEF_ERROR_CODE(0, 0x2908)
#define TSDB_CODE_UDF_INVALID_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x2909)
#define TSDB_CODE_UDF_INVALID_OUTPUT_TYPE TAOS_DEF_ERROR_CODE(0, 0x290A)
#define TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED TAOS_DEF_ERROR_CODE(0, 0x290B)
#define TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED TAOS_DEF_ERROR_CODE(0, 0x290B)
#define TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED TAOS_DEF_ERROR_CODE(0, 0x290C)
// sml
#define TSDB_CODE_SML_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x3000)
......
......@@ -96,8 +96,15 @@ int32_t udfdCPluginUdfInit(SScriptUdfInfo *udf, void **pUdfCtx) {
strncat(mergeFuncName, mergeSuffix, strlen(mergeSuffix));
uv_dlsym(&udfCtx->lib, mergeFuncName, (void **)(&udfCtx->aggMergeFunc));
}
int32_t code = 0;
if (udfCtx->initFunc) {
(udfCtx->initFunc)();
// TODO: handle init call return error
code = (udfCtx->initFunc)();
if (code != 0) {
uv_dlclose(&udfCtx->lib);
taosMemoryFree(udfCtx);
return code;
}
}
*pUdfCtx = udfCtx;
return 0;
......@@ -105,26 +112,30 @@ int32_t udfdCPluginUdfInit(SScriptUdfInfo *udf, void **pUdfCtx) {
int32_t udfdCPluginUdfDestroy(void *udfCtx) {
SUdfCPluginCtx *ctx = udfCtx;
int32_t code = 0;
if (ctx->destroyFunc) {
(ctx->destroyFunc)();
code = (ctx->destroyFunc)();
}
uv_dlclose(&ctx->lib);
taosMemoryFree(ctx);
return 0;
return code;
}
int32_t udfdCPluginUdfScalarProc(SUdfDataBlock *block, SUdfColumn *resultCol, void *udfCtx) {
SUdfCPluginCtx *ctx = udfCtx;
if (ctx->scalarProcFunc) {
ctx->scalarProcFunc(block, resultCol);
return ctx->scalarProcFunc(block, resultCol);
} else {
return TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED;
}
return 0;
}
int32_t udfdCPluginUdfAggStart(SUdfInterBuf *buf, void *udfCtx) {
SUdfCPluginCtx *ctx = udfCtx;
if (ctx->aggStartFunc) {
ctx->aggStartFunc(buf);
return ctx->aggStartFunc(buf);
} else {
return TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED;
}
return 0;
}
......@@ -132,24 +143,28 @@ int32_t udfdCPluginUdfAggStart(SUdfInterBuf *buf, void *udfCtx) {
int32_t udfdCPluginUdfAggProc(SUdfDataBlock *block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf, void *udfCtx) {
SUdfCPluginCtx *ctx = udfCtx;
if (ctx->aggProcFunc) {
ctx->aggProcFunc(block, interBuf, newInterBuf);
return ctx->aggProcFunc(block, interBuf, newInterBuf);
} else {
return TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED;
}
return 0;
}
int32_t udfdCPluginUdfAggMerge(SUdfInterBuf *inputBuf1, SUdfInterBuf *inputBuf2, SUdfInterBuf *outputBuf,
void *udfCtx) {
SUdfCPluginCtx *ctx = udfCtx;
if (ctx->aggMergeFunc) {
ctx->aggMergeFunc(inputBuf1, inputBuf2, outputBuf);
return ctx->aggMergeFunc(inputBuf1, inputBuf2, outputBuf);
} else {
return TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED;
}
return 0;
}
int32_t udfdCPluginUdfAggFinish(SUdfInterBuf *buf, SUdfInterBuf *resultData, void *udfCtx) {
SUdfCPluginCtx *ctx = udfCtx;
if (ctx->aggFinishFunc) {
ctx->aggFinishFunc(buf, resultData);
return ctx->aggFinishFunc(buf, resultData);
} else {
return TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED;
}
return 0;
}
......
......@@ -583,6 +583,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_UDF_NO_FUNC_HANDLE, "udf no function han
TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INVALID_BUFSIZE, "udf invalid bufsize")
TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INVALID_OUTPUT_TYPE, "udf invalid output type")
TAOS_DEFINE_ERROR(TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED, "udf program language not supported")
TAOS_DEFINE_ERROR(TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED, "udf function not implemented")
//schemaless
TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_PROTOCOL_TYPE, "Invalid line protocol type")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册