提交 4265fcb6 编写于 作者: H Haojun Liao

Merge remote-tracking branch 'origin/fix/liaohj' into fix/liaohj

...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
*/ */
#include "meta.h" #include "meta.h"
#include "osMemory.h"
#include "tencode.h"
void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags) { void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags) {
memset(pReader, 0, sizeof(*pReader)); memset(pReader, 0, sizeof(*pReader));
...@@ -1235,9 +1237,14 @@ END: ...@@ -1235,9 +1237,14 @@ END:
return 0; return 0;
} }
int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
int32_t ret = 0; SMetaEntry oStbEntry = {0};
int32_t ret = -1;
char *buf = NULL; char *buf = NULL;
void *pData = NULL;
int nData = 0;
SDecoder dc = {0};
STbDbKey tbDbKey = {0};
STagIdxKey *pKey = NULL; STagIdxKey *pKey = NULL;
int32_t nKey = 0; int32_t nKey = 0;
...@@ -1249,6 +1256,35 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { ...@@ -1249,6 +1256,35 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
pCursor->type = param->type; pCursor->type = param->type;
metaRLock(pMeta); metaRLock(pMeta);
if (tdbTbGet(pMeta->pUidIdx, &param->suid, sizeof(tb_uid_t), &pData, &nData) != 0) {
goto END;
}
tbDbKey.uid = param->suid;
tbDbKey.version = ((SUidIdxVal *)pData)[0].version;
tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData);
tDecoderInit(&dc, pData, nData);
ret = metaDecodeEntry(&dc, &oStbEntry);
if (oStbEntry.stbEntry.schemaTag.pSchema == NULL || oStbEntry.stbEntry.schemaTag.pSchema == NULL) {
ret = -1;
goto END;
}
for (int i = 0; i < oStbEntry.stbEntry.schemaTag.nCols; i++) {
SSchema *schema = oStbEntry.stbEntry.schemaTag.pSchema + i;
if (schema->colId == param->cid && param->type == schema->type && IS_IDX_ON(schema)) {
ret = 0;
}
if (i == 0) {
ret = 0;
}
}
if (ret != 0) {
goto END;
}
ret = tdbTbcOpen(pMeta->pTagIdx, &pCursor->pCur, NULL); ret = tdbTbcOpen(pMeta->pTagIdx, &pCursor->pCur, NULL);
if (ret < 0) { if (ret < 0) {
goto END; goto END;
...@@ -1353,6 +1389,10 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { ...@@ -1353,6 +1389,10 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
END: END:
if (pCursor->pMeta) metaULock(pCursor->pMeta); if (pCursor->pMeta) metaULock(pCursor->pMeta);
if (pCursor->pCur) tdbTbcClose(pCursor->pCur); if (pCursor->pCur) tdbTbcClose(pCursor->pCur);
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
tDecoderClear(&dc);
tdbFree(pData);
taosMemoryFree(buf); taosMemoryFree(buf);
taosMemoryFree(pKey); taosMemoryFree(pKey);
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "functionMgt.h" #include "functionMgt.h"
#include "index.h" #include "index.h"
#include "os.h" #include "os.h"
#include "query.h"
#include "tdatablock.h" #include "tdatablock.h"
#include "thash.h" #include "thash.h"
#include "tmsg.h" #include "tmsg.h"
...@@ -1061,7 +1062,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, ...@@ -1061,7 +1062,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
status = SFLT_NOT_INDEX; status = SFLT_NOT_INDEX;
code = doFilterTag(pTagIndexCond, &metaArg, pUidList, &status); code = doFilterTag(pTagIndexCond, &metaArg, pUidList, &status);
if (code != 0 || status == SFLT_NOT_INDEX) { // temporarily disable it for performance sake if (code != 0 || status == SFLT_NOT_INDEX) { // temporarily disable it for performance sake
// qError("failed to get tableIds from index, reason:%s, suid:%" PRIu64, tstrerror(code), tableUid); qWarn("failed to get tableIds from index, suid:%" PRIu64, pScanNode->uid);
code = TDB_CODE_SUCCESS; code = TDB_CODE_SUCCESS;
} else { } else {
qInfo("succ to get filter result, table num: %d", (int)taosArrayGetSize(pUidList)); qInfo("succ to get filter result, table num: %d", (int)taosArrayGetSize(pUidList));
......
...@@ -677,6 +677,11 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) { ...@@ -677,6 +677,11 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
_return: _return:
for (int i = 0; i < nParam; i++) sifFreeParam(&params[i]); for (int i = 0; i < nParam; i++) sifFreeParam(&params[i]);
taosMemoryFree(params); taosMemoryFree(params);
if (code != 0) {
output->status = SFLT_NOT_INDEX;
} else {
output->status = SFLT_COARSE_INDEX;
}
return code; return code;
} }
...@@ -717,7 +722,7 @@ _return: ...@@ -717,7 +722,7 @@ _return:
static EDealRes sifWalkFunction(SNode *pNode, void *context) { static EDealRes sifWalkFunction(SNode *pNode, void *context) {
SFunctionNode *node = (SFunctionNode *)pNode; SFunctionNode *node = (SFunctionNode *)pNode;
SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t))}; SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t)), .status = SFLT_COARSE_INDEX};
SIFCtx *ctx = context; SIFCtx *ctx = context;
ctx->code = sifExecFunction(node, ctx, &output); ctx->code = sifExecFunction(node, ctx, &output);
...@@ -735,7 +740,7 @@ static EDealRes sifWalkFunction(SNode *pNode, void *context) { ...@@ -735,7 +740,7 @@ static EDealRes sifWalkFunction(SNode *pNode, void *context) {
static EDealRes sifWalkLogic(SNode *pNode, void *context) { static EDealRes sifWalkLogic(SNode *pNode, void *context) {
SLogicConditionNode *node = (SLogicConditionNode *)pNode; SLogicConditionNode *node = (SLogicConditionNode *)pNode;
SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t))}; SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t)), .status = SFLT_COARSE_INDEX};
SIFCtx *ctx = context; SIFCtx *ctx = context;
ctx->code = sifExecLogic(node, ctx, &output); ctx->code = sifExecLogic(node, ctx, &output);
...@@ -831,6 +836,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) { ...@@ -831,6 +836,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
if (res->result != NULL) { if (res->result != NULL) {
taosArrayAddAll(pDst->result, res->result); taosArrayAddAll(pDst->result, res->result);
} }
pDst->status = res->status;
sifFreeParam(res); sifFreeParam(res);
taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES); taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES);
...@@ -887,16 +893,20 @@ int32_t doFilterTag(SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *result, ...@@ -887,16 +893,20 @@ int32_t doFilterTag(SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *result,
SFilterInfo *filter = NULL; SFilterInfo *filter = NULL;
SArray *output = taosArrayInit(8, sizeof(uint64_t)); SArray *output = taosArrayInit(8, sizeof(uint64_t));
SIFParam param = {.arg = *metaArg, .result = output}; SIFParam param = {.arg = *metaArg, .result = output, .status = SFLT_NOT_INDEX};
int32_t code = sifCalculate((SNode *)pFilterNode, &param); int32_t code = sifCalculate((SNode *)pFilterNode, &param);
if (code != 0) { if (code != 0) {
sifFreeParam(&param); sifFreeParam(&param);
return code; return code;
} }
if (param.status == SFLT_NOT_INDEX) {
*status = param.status;
} else {
*status = st;
}
taosArrayAddAll(result, param.result); taosArrayAddAll(result, param.result);
sifFreeParam(&param); sifFreeParam(&param);
*status = st;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册