提交 c5d972fa 编写于 作者: S shenglian zhou

begin to add more math functions

上级 27c94691
......@@ -57,19 +57,20 @@ typedef struct {
char* data;
} tExprOperandInfo;
typedef void (*_expr_scalar_function_t)(tExprOperandInfo* pInputs, uint8_t numInputs, tExprOperandInfo* pOutput, int32_t order);
typedef void (*_expr_scalar_function_t)(int16_t functionId, tExprOperandInfo* pInputs, uint8_t numInputs, tExprOperandInfo* pOutput, int32_t order);
_expr_scalar_function_t getExprScalarFunction(uint16_t scalar);
typedef struct tScalarFunctionInfo{
int16_t functionId; // scalar function id & ~TSDB_FUNC_FLAG_SCALAR == index
char name[TSDB_FUNC_SCALAR_NAME_MAX_LEN];
_expr_scalar_function_t scalarFunc;
} tScalarFunctionInfo;
/* global scalar sql functions array */
extern struct tScalarFunctionInfo aScalarFunctions[TSDB_FUNC_SCALAR_MAX_NUM];
typedef bool (*__result_filter_fn_t)(const void *, void *);
typedef void (*__do_filter_suppl_fn_t)(void *, void *);
......
......@@ -265,7 +265,7 @@ void exprTreeFunctionNodeTraverse(tExprNode *pExpr, int32_t numOfRows, char *pOu
output.type = TSDB_DATA_TYPE_DOUBLE;
output.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
scalarFn(pInputs, numChildren, &output, order);
scalarFn(pExpr->_func.functionId, pInputs, numChildren, &output, order);
for (int i = 0; i < numChildren; ++i) {
tfree(pChildrenOutput[i]);
......@@ -744,7 +744,7 @@ tExprNode* exprdup(tExprNode* pNode) {
}
void vectorPow(tExprOperandInfo* pInputs, uint8_t numInputs, tExprOperandInfo* pOutput, int32_t order) {
void vectorPow(int16_t functionId, tExprOperandInfo* pInputs, uint8_t numInputs, tExprOperandInfo* pOutput, int32_t order) {
assert(numInputs == 2);
assert(pInputs[1].numOfRows == 1 && pInputs[0].numOfRows >= 1);
int numOfRows = pInputs[0].numOfRows;
......@@ -766,7 +766,7 @@ void vectorPow(tExprOperandInfo* pInputs, uint8_t numInputs, tExprOperandInfo* p
}
}
void vectorLog(tExprOperandInfo* pInputs, uint8_t numInputs, tExprOperandInfo* pOutput, int32_t order) {
void vectorLog(int16_t functionId, tExprOperandInfo* pInputs, uint8_t numInputs, tExprOperandInfo* pOutput, int32_t order) {
assert(numInputs == 2);
assert(pInputs[1].numOfRows == 1 && pInputs[0].numOfRows >= 1);
int numOfRows = pInputs[0].numOfRows;
......@@ -789,25 +789,22 @@ void vectorLog(tExprOperandInfo* pInputs, uint8_t numInputs, tExprOperandInfo* p
}
_expr_scalar_function_t getExprScalarFunction(uint16_t scalarFunc) {
switch (scalarFunc) {
case TSDB_FUNC_SCALAR_POW:
return vectorPow;
case TSDB_FUNC_SCALAR_LOG:
return vectorLog;
default:
assert(0);
return NULL;
}
_expr_scalar_function_t getExprScalarFunction(uint16_t funcId) {
assert(TSDB_FUNC_IS_SCALAR(funcId));
int16_t scalaIdx = TSDB_FUNC_SCALAR_INDEX(funcId);
assert(scalaIdx>=0 && scalaIdx <= TSDB_FUNC_SCALAR_MAX_NUM);
return aScalarFunctions[scalaIdx].scalarFunc;
}
tScalarFunctionInfo aScalarFunctions[] = {
{
TSDB_FUNC_SCALAR_POW,
"pow"
"pow",
vectorPow
},
{
TSDB_FUNC_SCALAR_LOG,
"log"
"log",
vectorLog
},
};
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册