TDengine/source/libs/function/inc/tudfInt.h

118 lines
2.8 KiB
C
Raw Normal View History

2022-03-24 06:09:29 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_TUDF_INT_H
#define TDENGINE_TUDF_INT_H
#ifdef __cplusplus
extern "C" {
#endif
enum {
UDF_TASK_SETUP = 0,
UDF_TASK_CALL = 1,
UDF_TASK_TEARDOWN = 2
};
2022-04-13 11:45:33 +00:00
enum {
TSDB_UDF_CALL_AGG_INIT = 0,
TSDB_UDF_CALL_AGG_PROC,
2022-04-15 04:19:22 +00:00
TSDB_UDF_CALL_AGG_MERGE,
TSDB_UDF_CALL_AGG_FIN,
2022-04-13 11:45:33 +00:00
TSDB_UDF_CALL_SCALA_PROC,
};
2022-03-24 06:09:29 +00:00
typedef struct SUdfSetupRequest {
2022-10-20 01:53:08 +00:00
char udfName[TSDB_FUNC_NAME_LEN + 1];
2022-03-24 06:09:29 +00:00
} SUdfSetupRequest;
typedef struct SUdfSetupResponse {
int64_t udfHandle;
2022-10-13 06:15:42 +00:00
int8_t outputType;
2023-03-10 04:36:58 +00:00
int32_t bytes;
2022-04-25 07:44:40 +00:00
int32_t bufSize;
2022-03-24 06:09:29 +00:00
} SUdfSetupResponse;
typedef struct SUdfCallRequest {
int64_t udfHandle;
2022-10-13 06:15:42 +00:00
int8_t callType;
2022-03-24 06:09:29 +00:00
2022-10-13 06:15:42 +00:00
SSDataBlock block;
2022-04-13 11:45:33 +00:00
SUdfInterBuf interBuf;
SUdfInterBuf interBuf2;
2022-10-13 06:15:42 +00:00
int8_t initFirst;
2022-03-24 06:09:29 +00:00
} SUdfCallRequest;
typedef struct SUdfCallResponse {
2022-10-13 06:15:42 +00:00
int8_t callType;
SSDataBlock resultData;
2022-04-17 07:07:11 +00:00
SUdfInterBuf resultBuf;
2022-03-24 06:09:29 +00:00
} SUdfCallResponse;
typedef struct SUdfTeardownRequest {
int64_t udfHandle;
} SUdfTeardownRequest;
typedef struct SUdfTeardownResponse {
2022-04-22 01:54:27 +00:00
#ifdef WINDOWS
size_t avoidCompilationErrors;
#endif
2022-03-24 06:09:29 +00:00
} SUdfTeardownResponse;
typedef struct SUdfRequest {
int32_t msgLen;
int64_t seqNum;
int8_t type;
2022-04-13 11:45:33 +00:00
union {
2022-10-13 06:15:42 +00:00
SUdfSetupRequest setup;
SUdfCallRequest call;
2022-04-13 11:45:33 +00:00
SUdfTeardownRequest teardown;
};
2022-03-24 06:09:29 +00:00
} SUdfRequest;
typedef struct SUdfResponse {
int32_t msgLen;
int64_t seqNum;
2022-10-13 06:15:42 +00:00
int8_t type;
2022-03-24 06:09:29 +00:00
int32_t code;
2022-04-13 11:45:33 +00:00
union {
2022-10-13 06:15:42 +00:00
SUdfSetupResponse setupRsp;
SUdfCallResponse callRsp;
2022-04-13 11:45:33 +00:00
SUdfTeardownResponse teardownRsp;
};
2022-03-24 06:09:29 +00:00
} SUdfResponse;
2022-10-13 06:15:42 +00:00
int32_t encodeUdfRequest(void **buf, const SUdfRequest *request);
void *decodeUdfRequest(const void *buf, SUdfRequest *request);
int32_t encodeUdfResponse(void **buf, const SUdfResponse *response);
2022-10-13 06:15:42 +00:00
void *decodeUdfResponse(const void *buf, SUdfResponse *response);
2022-03-24 06:09:29 +00:00
2022-05-05 11:03:05 +00:00
void freeUdfColumnData(SUdfColumnData *data, SUdfColumnMeta *meta);
2022-10-13 06:15:42 +00:00
void freeUdfColumn(SUdfColumn *col);
2022-04-14 11:29:41 +00:00
void freeUdfDataDataBlock(SUdfDataBlock *block);
2022-04-17 07:07:11 +00:00
int32_t convertDataBlockToUdfDataBlock(SSDataBlock *block, SUdfDataBlock *udfBlock);
int32_t convertUdfColumnToDataBlock(SUdfColumn *udfCol, SSDataBlock *block);
2024-07-27 10:33:08 +00:00
void getUdfdPipeName(char *pipeName, int32_t size);
2022-03-24 06:09:29 +00:00
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_TUDF_INT_H