udf1_dup.c 996 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef LINUX
#include <unistd.h>
#endif
#ifdef WINDOWS
#include <windows.h>
#endif
#include "taosudf.h"


A
Alex Duan 已提交
13
DLL_EXPORT int32_t udf1_dup_init() { return 0; }
14

A
Alex Duan 已提交
15
DLL_EXPORT int32_t udf1_dup_destroy() { return 0; }
16

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