udf1.c 983 字节
Newer Older
S
shenglian zhou 已提交
1
#include <stdio.h>
H
Hongze Cheng 已提交
2 3
#include <stdlib.h>
#include <string.h>
S
shenglian zhou 已提交
4
#ifdef LINUX
5
#include <unistd.h>
S
shenglian zhou 已提交
6 7 8 9
#endif
#ifdef WINDOWS
#include <windows.h>
#endif
10
#include "taosudf.h"
S
shenglian zhou 已提交
11

H
Hongze Cheng 已提交
12
DLL_EXPORT int32_t udf1_init() { return 0; }
S
slzhou 已提交
13

H
Hongze Cheng 已提交
14
DLL_EXPORT int32_t udf1_destroy() { return 0; }
S
shenglian zhou 已提交
15

H
Hongze Cheng 已提交
16
DLL_EXPORT int32_t udf1(SUdfDataBlock *block, SUdfColumn *resultCol) {
S
shenglian zhou 已提交
17
  SUdfColumnData *resultData = &resultCol->colData;
S
slzhou 已提交
18
  for (int32_t i = 0; i < block->numOfRows; ++i) {
S
slzhou 已提交
19 20 21 22 23 24 25
    int j = 0;
    for (; j < block->numOfCols; ++j) {
      if (udfColDataIsNull(block->udfCols[j], i)) {
        udfColDataSetNull(resultCol, i);
        break;
      }
    }
H
Hongze Cheng 已提交
26
    if (j == block->numOfCols) {
S
slzhou 已提交
27 28 29
      int32_t luckyNum = 88;
      udfColDataSet(resultCol, i, (char *)&luckyNum, false);
    }
S
shenglian zhou 已提交
30
  }
H
Hongze Cheng 已提交
31
  // to simulate actual processing delay by udf
S
shenglian zhou 已提交
32
#ifdef LINUX
H
Hongze Cheng 已提交
33
  usleep(1 * 1000);  // usleep takes sleep time in us (1 millionth of a second)
S
shenglian zhou 已提交
34
#endif
35
#ifdef WINDOWS
S
shenglian zhou 已提交
36
  Sleep(1);
37
#endif
S
slzhou 已提交
38
  resultData->numOfRows = block->numOfRows;
S
shenglian zhou 已提交
39
  return 0;
S
slzhou 已提交
40
}