sclvector.h 3.9 KB
Newer Older
H
Haojun Liao 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

16 17
#ifndef _TD_COMMON_BIN_SCALAR_OPERATOR_H_
#define _TD_COMMON_BIN_SCALAR_OPERATOR_H_
H
Haojun Liao 已提交
18 19 20 21 22

#ifdef __cplusplus
extern "C" {
#endif

23
typedef double (*_getDoubleValue_fn_t)(void *src, int32_t index);
H
Haojun Liao 已提交
24

25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
static FORCE_INLINE double getVectorDoubleValue_TINYINT(void *src, int32_t index) {
  return (double)*((int8_t *)src + index);
}
static FORCE_INLINE double getVectorDoubleValue_UTINYINT(void *src, int32_t index) {
  return (double)*((uint8_t *)src + index);
}
static FORCE_INLINE double getVectorDoubleValue_SMALLINT(void *src, int32_t index) {
  return (double)*((int16_t *)src + index);
}
static FORCE_INLINE double getVectorDoubleValue_USMALLINT(void *src, int32_t index) {
  return (double)*((uint16_t *)src + index);
}
static FORCE_INLINE double getVectorDoubleValue_INT(void *src, int32_t index) {
  return (double)*((int32_t *)src + index);
}
static FORCE_INLINE double getVectorDoubleValue_UINT(void *src, int32_t index) {
  return (double)*((uint32_t *)src + index);
}
static FORCE_INLINE double getVectorDoubleValue_BIGINT(void *src, int32_t index) {
  return (double)*((int64_t *)src + index);
}
static FORCE_INLINE double getVectorDoubleValue_UBIGINT(void *src, int32_t index) {
  return (double)*((uint64_t *)src + index);
}
static FORCE_INLINE double getVectorDoubleValue_FLOAT(void *src, int32_t index) {
  return (double)*((float *)src + index);
}
static FORCE_INLINE double getVectorDoubleValue_DOUBLE(void *src, int32_t index) {
  return (double)*((double *)src + index);
}
55 56 57
static FORCE_INLINE double getVectorDoubleValue_BOOL(void *src, int32_t index) {
  return (double)*((bool *)src + index);
}
D
dapan1121 已提交
58

59 60
double getVectorDoubleValue_JSON(void *src, int32_t index);

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
static FORCE_INLINE _getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) {
  _getDoubleValue_fn_t p = NULL;
  if (srcType == TSDB_DATA_TYPE_TINYINT) {
    p = getVectorDoubleValue_TINYINT;
  } else if (srcType == TSDB_DATA_TYPE_UTINYINT) {
    p = getVectorDoubleValue_UTINYINT;
  } else if (srcType == TSDB_DATA_TYPE_SMALLINT) {
    p = getVectorDoubleValue_SMALLINT;
  } else if (srcType == TSDB_DATA_TYPE_USMALLINT) {
    p = getVectorDoubleValue_USMALLINT;
  } else if (srcType == TSDB_DATA_TYPE_INT) {
    p = getVectorDoubleValue_INT;
  } else if (srcType == TSDB_DATA_TYPE_UINT) {
    p = getVectorDoubleValue_UINT;
  } else if (srcType == TSDB_DATA_TYPE_BIGINT) {
    p = getVectorDoubleValue_BIGINT;
  } else if (srcType == TSDB_DATA_TYPE_UBIGINT) {
    p = getVectorDoubleValue_UBIGINT;
  } else if (srcType == TSDB_DATA_TYPE_FLOAT) {
    p = getVectorDoubleValue_FLOAT;
  } else if (srcType == TSDB_DATA_TYPE_DOUBLE) {
    p = getVectorDoubleValue_DOUBLE;
D
dapan1121 已提交
83 84
  } else if (srcType == TSDB_DATA_TYPE_TIMESTAMP) {
    p = getVectorDoubleValue_BIGINT;
85 86
  } else if (srcType == TSDB_DATA_TYPE_JSON) {
    p = getVectorDoubleValue_JSON;
87 88
  } else if (srcType == TSDB_DATA_TYPE_BOOL) {
    p = getVectorDoubleValue_BOOL;
89 90
  } else if (srcType == TSDB_DATA_TYPE_NULL) {
    p = NULL;
91
  } else {
92
    ASSERT(0);
93 94 95
  }
  return p;
}
D
dapan1121 已提交
96

D
dapan1121 已提交
97
typedef void (*_bufConverteFunc)(char *buf, SScalarParam* pOut, int32_t outType);
D
dapan 已提交
98
typedef void (*_bin_scalar_fn_t)(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *output, int32_t order);
99
_bin_scalar_fn_t getBinScalarOperatorFn(int32_t binOperator);
H
Haojun Liao 已提交
100 101 102 103 104

#ifdef __cplusplus
}
#endif

105
#endif  /*_TD_COMMON_BIN_SCALAR_OPERATOR_H_*/