提交 8f7bd35a 编写于 作者: weixin_48148422's avatar weixin_48148422

TD-97: tbname criteria with other criteria is done

上级 5741959c
...@@ -783,13 +783,17 @@ static void exprTreeTraverseImpl(tExprNode *pExpr, SArray *pResult, SBinaryFilte ...@@ -783,13 +783,17 @@ static void exprTreeTraverseImpl(tExprNode *pExpr, SArray *pResult, SBinaryFilte
taosArrayCopy(pResult, array); taosArrayCopy(pResult, array);
} }
static void tSQLBinaryTraverseOnSkipList(tExprNode *pExpr, SArray *pResult, SSkipList *pSkipList,
SBinaryFilterSupp *param) { static void tSQLBinaryTraverseOnSkipList(
tExprNode *pExpr,
SArray *pResult,
SSkipList *pSkipList,
SBinaryFilterSupp *param
) {
SSkipListIterator* iter = tSkipListCreateIter(pSkipList); SSkipListIterator* iter = tSkipListCreateIter(pSkipList);
while (tSkipListIterNext(iter)) { while (tSkipListIterNext(iter)) {
SSkipListNode *pNode = tSkipListIterGet(iter); SSkipListNode *pNode = tSkipListIterGet(iter);
if (filterItem(pExpr, pNode, param)) { if (filterItem(pExpr, pNode, param)) {
taosArrayPush(pResult, SL_GET_NODE_DATA(pNode)); taosArrayPush(pResult, SL_GET_NODE_DATA(pNode));
} }
......
...@@ -1357,16 +1357,26 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) { ...@@ -1357,16 +1357,26 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) {
STable* pTable = *(STable**)(SL_GET_NODE_DATA((SSkipListNode*)pNode)); STable* pTable = *(STable**)(SL_GET_NODE_DATA((SSkipListNode*)pNode));
char* val = dataRowTuple(pTable->tagVal); // todo not only the first column char* val = NULL;
int8_t type = pInfo->sch.type; int8_t type = pInfo->sch.type;
if (pInfo->colIndex == TSDB_TBNAME_COLUMN_INDEX) {
val = pTable->name;
type = TSDB_DATA_TYPE_BINARY;
} else {
val = dataRowTuple(pTable->tagVal); // todo not only the first column
}
int32_t ret = 0; int32_t ret = 0;
if (pInfo->q.nType == TSDB_DATA_TYPE_BINARY || pInfo->q.nType == TSDB_DATA_TYPE_NCHAR) { if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
ret = pInfo->compare(val, pInfo->q.pz); if (pInfo->optr == TSDB_RELATION_IN) {
ret = pInfo->compare(val, pInfo->q.arr);
} else {
ret = pInfo->compare(val, pInfo->q.pz);
}
} else { } else {
tVariant t = {0}; tVariant t = {0};
tVariantCreateFromBinary(&t, val, (uint32_t)pInfo->sch.bytes, type); tVariantCreateFromBinary(&t, val, (uint32_t)pInfo->sch.bytes, type);
ret = pInfo->compare(&t.i64Key, &pInfo->q.i64Key); ret = pInfo->compare(&t.i64Key, &pInfo->q.i64Key);
} }
...@@ -1393,7 +1403,7 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) { ...@@ -1393,7 +1403,7 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) {
return ret == 0; return ret == 0;
} }
case TSDB_RELATION_IN: { case TSDB_RELATION_IN: {
return ret == 1;
} }
default: default:
...@@ -1474,8 +1484,8 @@ int32_t tsdbQueryByTagsCond( ...@@ -1474,8 +1484,8 @@ int32_t tsdbQueryByTagsCond(
expr = calloc(1, sizeof(tExprNode)); expr = calloc(1, sizeof(tExprNode));
expr->nodeType = TSQL_NODE_EXPR; expr->nodeType = TSQL_NODE_EXPR;
expr->_node.optr = tagNameRelType; expr->_node.optr = tagNameRelType;
expr->_node.pLeft = tbnameExpr; expr->_node.pLeft = tagExpr;
expr->_node.pRight = tagExpr; expr->_node.pRight = tbnameExpr;
} }
} }
......
...@@ -77,10 +77,11 @@ void* taosArrayPush(SArray* pArray, void* pData) { ...@@ -77,10 +77,11 @@ void* taosArrayPush(SArray* pArray, void* pData) {
} }
void* taosArrayPop(SArray* pArray) { void* taosArrayPop(SArray* pArray) {
if (pArray == NULL || pArray->size == 0) { assert( pArray != NULL );
if (pArray->size == 0) {
return NULL; return NULL;
} }
pArray->size -= 1; pArray->size -= 1;
return TARRAY_GET_ELEM(pArray, pArray->size); return TARRAY_GET_ELEM(pArray, pArray->size);
} }
......
...@@ -215,7 +215,7 @@ static UNUSED_FUNC int32_t compareStrPatternComp(const void* pLeft, const void* ...@@ -215,7 +215,7 @@ static UNUSED_FUNC int32_t compareStrPatternComp(const void* pLeft, const void*
return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; return (ret == TSDB_PATTERN_MATCH) ? 0 : 1;
} }
static int32_t compareStrInList(const void* pLeft, const void* pRight) { static int32_t compareFindStrInArray(const void* pLeft, const void* pRight) {
const SArray* arr = (const SArray*)pRight; const SArray* arr = (const SArray*)pRight;
return taosArraySearchString(arr, pLeft) == NULL ? 0 : 1; return taosArraySearchString(arr, pLeft) == NULL ? 0 : 1;
} }
...@@ -277,7 +277,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t filterDataType, int32_t optr) ...@@ -277,7 +277,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t filterDataType, int32_t optr)
} else if (optr == TSDB_RELATION_IN) { } else if (optr == TSDB_RELATION_IN) {
assert(filterDataType == TSDB_DATA_TYPE_ARRAY); assert(filterDataType == TSDB_DATA_TYPE_ARRAY);
comparFn = compareStrInList; comparFn = compareFindStrInArray;
} else { /* normal relational comparFn */ } else { /* normal relational comparFn */
assert(filterDataType == TSDB_DATA_TYPE_BINARY); assert(filterDataType == TSDB_DATA_TYPE_BINARY);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册