tudfInt.h 2.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * 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

S
shenglian zhou 已提交
22 23 24
//TODO replaces them with fnDebug
//#define debugPrint(...) taosPrintLog("Function", DEBUG_INFO,  135, __VA_ARGS__)
#define debugPrint(...) {fprintf(stderr, __VA_ARGS__);fprintf(stderr, "\n");}
25 26 27 28 29 30 31
enum {
  UDF_TASK_SETUP = 0,
  UDF_TASK_CALL = 1,
  UDF_TASK_TEARDOWN = 2

};

S
shenglian zhou 已提交
32 33 34 35 36 37
enum {
  TSDB_UDF_CALL_AGG_PROC = 0,
  TSDb_UDF_CALL_AGG_FIN,
  TSDB_UDF_CALL_SCALA_PROC,
};

38
typedef struct SUdfSetupRequest {
S
shenglian zhou 已提交
39 40
  char udfName[TSDB_FUNC_NAME_LEN];
  SEpSet epSet;
41 42 43 44 45 46 47 48
} SUdfSetupRequest;

typedef struct SUdfSetupResponse {
  int64_t udfHandle;
} SUdfSetupResponse;

typedef struct SUdfCallRequest {
  int64_t udfHandle;
S
shenglian zhou 已提交
49
  int8_t callType;
50

S
shenglian zhou 已提交
51 52 53
  SUdfDataBlock block;
  SUdfInterBuf interBuf;
  bool initFirst;
54 55 56
} SUdfCallRequest;

typedef struct SUdfCallResponse {
S
shenglian zhou 已提交
57 58
  SUdfColumnData resultData;
  SUdfInterBuf interBuf;
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
} SUdfCallResponse;


typedef struct SUdfTeardownRequest {
  int64_t udfHandle;
} SUdfTeardownRequest;


typedef struct SUdfTeardownResponse {
} SUdfTeardownResponse;

typedef struct SUdfRequest {
  int32_t msgLen;
  int64_t seqNum;

  int8_t type;
S
shenglian zhou 已提交
75 76 77 78 79
  union {
    SUdfSetupRequest setup;
    SUdfCallRequest call;
    SUdfTeardownRequest teardown;
  };
80 81 82 83 84 85 86 87
} SUdfRequest;

typedef struct SUdfResponse {
  int32_t msgLen;
  int64_t seqNum;

  int8_t type;
  int32_t code;
S
shenglian zhou 已提交
88 89 90 91 92
  union {
    SUdfSetupResponse setupRsp;
    SUdfCallResponse callRsp;
    SUdfTeardownResponse teardownRsp;
  };
93 94
} SUdfResponse;

S
shenglian zhou 已提交
95
int32_t decodeRequest(char *buf, int32_t bufLen, SUdfRequest *pRequest);
96
int32_t encodeRequest(char **buf, int32_t *bufLen, SUdfRequest *request);
S
shenglian zhou 已提交
97 98
int32_t decodeResponse(char *buf, int32_t bufLen, SUdfResponse *pResponse);
int32_t encodeResponse(char **buf, int32_t *bufLen, SUdfResponse *response);
99

S
shenglian zhou 已提交
100 101 102 103
void freeUdfColumnData(SUdfColumnData *data);
void freeUdfColumn(SUdfColumn* col);
void freeUdfDataDataBlock(SUdfDataBlock *block);

104 105 106 107 108
#ifdef __cplusplus
}
#endif

#endif  // TDENGINE_TUDF_INT_H