feature/qnode
This commit is contained in:
parent
93baf85a4f
commit
1e194d2249
|
@ -1294,8 +1294,21 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, void *out, int
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
bool *output=(bool *)out;
|
bool *output=(bool *)out;
|
||||||
_getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type);
|
_getValueAddr_fn_t getVectorValueAddrFnLeft = NULL;
|
||||||
_getValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type);
|
_getValueAddr_fn_t getVectorValueAddrFnRight = NULL;
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(pLeft->type) && !pLeft->colData) {
|
||||||
|
getVectorValueAddrFnLeft = getVectorValueAddr_default;
|
||||||
|
} else {
|
||||||
|
getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(pRight->type) && !pRight->colData) {
|
||||||
|
getVectorValueAddrFnRight = getVectorValueAddr_default;
|
||||||
|
} else {
|
||||||
|
getVectorValueAddrFnRight = getVectorValueAddrFn(pRight->type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (pLeft->num == pRight->num) {
|
if (pLeft->num == pRight->num) {
|
||||||
for (; i < pRight->num && i >= 0; i += step, output += 1) {
|
for (; i < pRight->num && i >= 0; i += step, output += 1) {
|
||||||
|
@ -1420,7 +1433,13 @@ void vectorIsNull(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
bool *output=(bool *)out;
|
bool *output=(bool *)out;
|
||||||
_getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type);
|
_getValueAddr_fn_t getVectorValueAddrFnLeft = NULL;
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(pLeft->type) && !pLeft->colData) {
|
||||||
|
getVectorValueAddrFnLeft = getVectorValueAddr_default;
|
||||||
|
} else {
|
||||||
|
getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type);
|
||||||
|
}
|
||||||
|
|
||||||
for (; i >= 0 && i < pLeft->num; i += step, output += 1) {
|
for (; i >= 0 && i < pLeft->num; i += step, output += 1) {
|
||||||
if (isNull(getVectorValueAddrFnLeft(pLeft->data,i), pLeft->type)) {
|
if (isNull(getVectorValueAddrFnLeft(pLeft->data,i), pLeft->type)) {
|
||||||
|
@ -1440,7 +1459,13 @@ void vectorNotNull(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
bool *output = (bool *)out;
|
bool *output = (bool *)out;
|
||||||
_getValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type);
|
_getValueAddr_fn_t getVectorValueAddrFnLeft = NULL;
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(pLeft->type) && !pLeft->colData) {
|
||||||
|
getVectorValueAddrFnLeft = getVectorValueAddr_default;
|
||||||
|
} else {
|
||||||
|
getVectorValueAddrFnLeft = getVectorValueAddrFn(pLeft->type);
|
||||||
|
}
|
||||||
|
|
||||||
for (; i >= 0 && i < pLeft->num; i += step, output += 1) {
|
for (; i >= 0 && i < pLeft->num; i += step, output += 1) {
|
||||||
if (isNull(getVectorValueAddrFnLeft(pLeft->data,i), pLeft->type)) {
|
if (isNull(getVectorValueAddrFnLeft(pLeft->data,i), pLeft->type)) {
|
||||||
|
@ -1456,6 +1481,11 @@ void vectorNotNull(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
|
||||||
|
|
||||||
void vectorIsTrue(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) {
|
void vectorIsTrue(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) {
|
||||||
SScalarParam output = {.data = out, .num = pLeft->num, .type = TSDB_DATA_TYPE_BOOL};
|
SScalarParam output = {.data = out, .num = pLeft->num, .type = TSDB_DATA_TYPE_BOOL};
|
||||||
|
|
||||||
|
if (pLeft->colData) {
|
||||||
|
SColumnInfoData *colInfo = (SColumnInfoData *)pLeft->data;
|
||||||
|
pLeft->data = colInfo->pData;
|
||||||
|
}
|
||||||
|
|
||||||
vectorConvertImpl(pLeft, &output);
|
vectorConvertImpl(pLeft, &output);
|
||||||
}
|
}
|
||||||
|
|
|
@ -975,6 +975,129 @@ TEST(columnTest, binary_column_in_binary_list) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(columnTest, binary_column_like_binary) {
|
||||||
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL;
|
||||||
|
char rightv[64] = {0};
|
||||||
|
char leftv[5][5]= {0};
|
||||||
|
SSDataBlock *src = NULL;
|
||||||
|
SScalarParam res = {0};
|
||||||
|
bool eRes[5] = {true, false, true, false, true};
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < 5; ++i) {
|
||||||
|
leftv[i][2] = 'a';
|
||||||
|
leftv[i][3] = 'a';
|
||||||
|
leftv[i][4] = '0' + i % 2;
|
||||||
|
varDataSetLen(leftv[i], 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]);
|
||||||
|
scltMakeColRefNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv);
|
||||||
|
|
||||||
|
sprintf(&rightv[2], "%s", "__0");
|
||||||
|
varDataSetLen(rightv, strlen(&rightv[2]));
|
||||||
|
scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv);
|
||||||
|
scltMakeOpNode(&opNode, OP_TYPE_LIKE, TSDB_DATA_TYPE_BOOL, pLeft, pRight);
|
||||||
|
|
||||||
|
int32_t code = scalarCalculate(opNode, src, &res);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
ASSERT_EQ(res.num, rowNum);
|
||||||
|
ASSERT_EQ(res.type, TSDB_DATA_TYPE_BOOL);
|
||||||
|
ASSERT_EQ(res.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes);
|
||||||
|
for (int32_t i = 0; i < rowNum; ++i) {
|
||||||
|
ASSERT_EQ(*((bool *)res.data + i), eRes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(columnTest, binary_column_is_true) {
|
||||||
|
SNode *pLeft = NULL, *opNode = NULL;
|
||||||
|
char leftv[5][5]= {0};
|
||||||
|
SSDataBlock *src = NULL;
|
||||||
|
SScalarParam res = {0};
|
||||||
|
bool eRes[5] = {false, true, false, true, false};
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < 5; ++i) {
|
||||||
|
leftv[i][2] = '0' + i % 2;
|
||||||
|
leftv[i][3] = 'a';
|
||||||
|
leftv[i][4] = '0' + i % 2;
|
||||||
|
varDataSetLen(leftv[i], 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]);
|
||||||
|
scltMakeColRefNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv);
|
||||||
|
|
||||||
|
scltMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, pLeft, NULL);
|
||||||
|
|
||||||
|
int32_t code = scalarCalculate(opNode, src, &res);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
ASSERT_EQ(res.num, rowNum);
|
||||||
|
ASSERT_EQ(res.type, TSDB_DATA_TYPE_BOOL);
|
||||||
|
ASSERT_EQ(res.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes);
|
||||||
|
for (int32_t i = 0; i < rowNum; ++i) {
|
||||||
|
ASSERT_EQ(*((bool *)res.data + i), eRes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(columnTest, binary_column_is_null) {
|
||||||
|
SNode *pLeft = NULL, *opNode = NULL;
|
||||||
|
char leftv[5][5]= {0};
|
||||||
|
SSDataBlock *src = NULL;
|
||||||
|
SScalarParam res = {0};
|
||||||
|
bool eRes[5] = {false, false, false, false, true};
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < 4; ++i) {
|
||||||
|
leftv[i][2] = '0' + i % 2;
|
||||||
|
leftv[i][3] = 'a';
|
||||||
|
leftv[i][4] = '0' + i % 2;
|
||||||
|
varDataSetLen(leftv[i], 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
setVardataNull(leftv[4], TSDB_DATA_TYPE_BINARY);
|
||||||
|
|
||||||
|
int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]);
|
||||||
|
scltMakeColRefNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv);
|
||||||
|
|
||||||
|
scltMakeOpNode(&opNode, OP_TYPE_IS_NULL, TSDB_DATA_TYPE_BOOL, pLeft, NULL);
|
||||||
|
|
||||||
|
int32_t code = scalarCalculate(opNode, src, &res);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
ASSERT_EQ(res.num, rowNum);
|
||||||
|
ASSERT_EQ(res.type, TSDB_DATA_TYPE_BOOL);
|
||||||
|
ASSERT_EQ(res.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes);
|
||||||
|
for (int32_t i = 0; i < rowNum; ++i) {
|
||||||
|
ASSERT_EQ(*((bool *)res.data + i), eRes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(columnTest, binary_column_is_not_null) {
|
||||||
|
SNode *pLeft = NULL, *opNode = NULL;
|
||||||
|
char leftv[5][5]= {0};
|
||||||
|
SSDataBlock *src = NULL;
|
||||||
|
SScalarParam res = {0};
|
||||||
|
bool eRes[5] = {true, true, true, true, false};
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < 4; ++i) {
|
||||||
|
leftv[i][2] = '0' + i % 2;
|
||||||
|
leftv[i][3] = 'a';
|
||||||
|
leftv[i][4] = '0' + i % 2;
|
||||||
|
varDataSetLen(leftv[i], 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
setVardataNull(leftv[4], TSDB_DATA_TYPE_BINARY);
|
||||||
|
|
||||||
|
int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]);
|
||||||
|
scltMakeColRefNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv);
|
||||||
|
|
||||||
|
scltMakeOpNode(&opNode, OP_TYPE_IS_NOT_NULL, TSDB_DATA_TYPE_BOOL, pLeft, NULL);
|
||||||
|
|
||||||
|
int32_t code = scalarCalculate(opNode, src, &res);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
ASSERT_EQ(res.num, rowNum);
|
||||||
|
ASSERT_EQ(res.type, TSDB_DATA_TYPE_BOOL);
|
||||||
|
ASSERT_EQ(res.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes);
|
||||||
|
for (int32_t i = 0; i < rowNum; ++i) {
|
||||||
|
ASSERT_EQ(*((bool *)res.data + i), eRes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
Loading…
Reference in New Issue