fix(query): fix syntax error.
This commit is contained in:
parent
fe09705855
commit
ab907e3344
|
@ -354,13 +354,13 @@ typedef struct SStoreMetaReader {
|
||||||
} SStoreMetaReader;
|
} SStoreMetaReader;
|
||||||
|
|
||||||
typedef struct SStoreMeta {
|
typedef struct SStoreMeta {
|
||||||
SMTbCursor *(*openTableMetaCursor)(); // metaOpenTbCursor
|
SMTbCursor *(*openTableMetaCursor)(void *pVnode); // metaOpenTbCursor
|
||||||
void (*closeTableMetaCursor)(); // metaCloseTbCursor
|
void (*closeTableMetaCursor)(SMTbCursor *pTbCur); // metaCloseTbCursor
|
||||||
int32_t (*cursorNext)(); // metaTbCursorNext
|
int32_t (*cursorNext)(); // metaTbCursorNext
|
||||||
int32_t (*cursorPrev)(); // metaTbCursorPrev
|
int32_t (*cursorPrev)(); // metaTbCursorPrev
|
||||||
|
|
||||||
int32_t (*getTableTags)(void *pVnode, uint64_t suid, SArray *uidList);
|
int32_t (*getTableTags)(void *pVnode, uint64_t suid, SArray *uidList);
|
||||||
int32_t (*getTableTagsByUid)();
|
int32_t (*getTableTagsByUid)(void *pVnode, int64_t suid, SArray *uidList);
|
||||||
const void *(*extractTagVal)(const void *tag, int16_t type, STagVal *tagVal); // todo remove it
|
const void *(*extractTagVal)(const void *tag, int16_t type, STagVal *tagVal); // todo remove it
|
||||||
|
|
||||||
int32_t (*getTableUidByName)(void *pVnode, char *tbName, uint64_t *uid);
|
int32_t (*getTableUidByName)(void *pVnode, char *tbName, uint64_t *uid);
|
||||||
|
|
|
@ -215,23 +215,6 @@ typedef struct SIndexMetaArg {
|
||||||
int (*metaFilterFunc)(void* metaEx, void* param, SArray* result);
|
int (*metaFilterFunc)(void* metaEx, void* param, SArray* result);
|
||||||
} SIndexMetaArg;
|
} SIndexMetaArg;
|
||||||
|
|
||||||
typedef enum { SFLT_NOT_INDEX, SFLT_COARSE_INDEX, SFLT_ACCURATE_INDEX } SIdxFltStatus;
|
|
||||||
|
|
||||||
SIdxFltStatus idxGetFltStatus(SNode* pFilterNode);
|
|
||||||
|
|
||||||
int32_t doFilterTag(SNode* pFilterNode, SIndexMetaArg* metaArg, SArray* result, SIdxFltStatus* status);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* init index env
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void indexInit(int32_t threads);
|
|
||||||
/*
|
|
||||||
* destory index env
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void indexCleanup();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the underlying storage module must implement this API to employ the index functions.
|
* the underlying storage module must implement this API to employ the index functions.
|
||||||
* @param pMeta
|
* @param pMeta
|
||||||
|
@ -256,6 +239,23 @@ typedef struct SMetaDataFilterAPI {
|
||||||
int32_t (*metaFilterTtl)(void *pVnode, SMetaFltParam *arg, SArray *pUids);
|
int32_t (*metaFilterTtl)(void *pVnode, SMetaFltParam *arg, SArray *pUids);
|
||||||
} SMetaDataFilterAPI;
|
} SMetaDataFilterAPI;
|
||||||
|
|
||||||
|
typedef enum { SFLT_NOT_INDEX, SFLT_COARSE_INDEX, SFLT_ACCURATE_INDEX } SIdxFltStatus;
|
||||||
|
|
||||||
|
SIdxFltStatus idxGetFltStatus(SNode* pFilterNode, SMetaDataFilterAPI* pAPI);
|
||||||
|
|
||||||
|
int32_t doFilterTag(SNode* pFilterNode, SIndexMetaArg* metaArg, SArray* result, SIdxFltStatus* status, SMetaDataFilterAPI* pAPI);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* init index env
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void indexInit(int32_t threads);
|
||||||
|
/*
|
||||||
|
* destory index env
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void indexCleanup();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -111,8 +111,8 @@ void metaReaderClear(SMetaReader *pReader);
|
||||||
int32_t metaReaderGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid);
|
int32_t metaReaderGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid);
|
||||||
int32_t metaReaderGetTableEntryByUidCache(SMetaReader *pReader, tb_uid_t uid);
|
int32_t metaReaderGetTableEntryByUidCache(SMetaReader *pReader, tb_uid_t uid);
|
||||||
int metaGetTableEntryByName(SMetaReader *pReader, const char *name);
|
int metaGetTableEntryByName(SMetaReader *pReader, const char *name);
|
||||||
int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList);
|
int32_t metaGetTableTags(void *pVnode, uint64_t suid, SArray *uidList);
|
||||||
int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList);
|
int32_t metaGetTableTagsByUids(void* pVnode, int64_t suid, SArray *uidList);
|
||||||
int32_t metaReadNext(SMetaReader *pReader);
|
int32_t metaReadNext(SMetaReader *pReader);
|
||||||
const void *metaGetTableTagVal(const void *tag, int16_t type, STagVal *tagVal);
|
const void *metaGetTableTagVal(const void *tag, int16_t type, STagVal *tagVal);
|
||||||
int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName);
|
int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName);
|
||||||
|
@ -140,18 +140,6 @@ int64_t metaGetNtbNum(SMeta *pMeta);
|
||||||
//} SMetaStbStats;
|
//} SMetaStbStats;
|
||||||
int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables);
|
int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables);
|
||||||
|
|
||||||
//typedef struct SMetaFltParam {
|
|
||||||
// tb_uid_t suid;
|
|
||||||
// int16_t cid;
|
|
||||||
// int16_t type;
|
|
||||||
// void *val;
|
|
||||||
// bool reverse;
|
|
||||||
// bool equal;
|
|
||||||
// int (*filterFunc)(void *a, void *b, int16_t type);
|
|
||||||
//
|
|
||||||
//} SMetaFltParam;
|
|
||||||
|
|
||||||
|
|
||||||
#if 1 // refact APIs below (TODO)
|
#if 1 // refact APIs below (TODO)
|
||||||
typedef SVCreateTbReq STbCfg;
|
typedef SVCreateTbReq STbCfg;
|
||||||
typedef SVCreateTSmaReq SSmaCfg;
|
typedef SVCreateTSmaReq SSmaCfg;
|
||||||
|
|
|
@ -1356,7 +1356,8 @@ static int32_t metaGetTableTagByUid(SMeta *pMeta, int64_t suid, int64_t uid, voi
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList) {
|
int32_t metaGetTableTagsByUids(void *pVnode, int64_t suid, SArray *uidList) {
|
||||||
|
SMeta* pMeta = ((SVnode*) pVnode)->pMeta;
|
||||||
const int32_t LIMIT = 128;
|
const int32_t LIMIT = 128;
|
||||||
|
|
||||||
int32_t isLock = false;
|
int32_t isLock = false;
|
||||||
|
@ -1388,8 +1389,8 @@ int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *pUidTagInfo) {
|
int32_t metaGetTableTags(void* pVnode, uint64_t suid, SArray *pUidTagInfo) {
|
||||||
SMCtbCursor *pCur = metaOpenCtbCursor(pMeta, suid, 1);
|
SMCtbCursor *pCur = metaOpenCtbCursor(((SVnode*)pVnode)->pMeta, suid, 1);
|
||||||
|
|
||||||
// If len > 0 means there already have uids, and we only want the
|
// If len > 0 means there already have uids, and we only want the
|
||||||
// tags of the specified tables, of which uid in the uid list. Otherwise, all table tags are retrieved and kept
|
// tags of the specified tables, of which uid in the uid list. Otherwise, all table tags are retrieved and kept
|
||||||
|
|
|
@ -72,6 +72,12 @@ void initMetadataAPI(SStoreMeta* pMeta) {
|
||||||
pMeta->getInvertIndex = vnodeGetIvtIdx;
|
pMeta->getInvertIndex = vnodeGetIvtIdx;
|
||||||
|
|
||||||
pMeta->extractTagVal = (const void *(*)(const void *, int16_t, STagVal *))metaGetTableTagVal;
|
pMeta->extractTagVal = (const void *(*)(const void *, int16_t, STagVal *))metaGetTableTagVal;
|
||||||
|
pMeta->getTableTags = metaGetTableTags;
|
||||||
|
pMeta->getTableTagsByUid = metaGetTableTagsByUids;
|
||||||
|
|
||||||
|
pMeta->getTableUidByName = metaGetTableUidByName;
|
||||||
|
pMeta->getTableTypeByName = metaGetTableTypeByName;
|
||||||
|
pMeta->getTableNameByUid = metaGetTableNameByUid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTqAPI(SStoreTqReader* pTq) {
|
void initTqAPI(SStoreTqReader* pTq) {
|
||||||
|
|
|
@ -1100,7 +1100,7 @@ int32_t getTableList(void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, S
|
||||||
.metaEx = pVnode, .idx = pStorageAPI->metaFn.storeGetIndexInfo(pVnode), .ivtIdx = pIndex, .suid = pScanNode->uid};
|
.metaEx = pVnode, .idx = pStorageAPI->metaFn.storeGetIndexInfo(pVnode), .ivtIdx = pIndex, .suid = pScanNode->uid};
|
||||||
|
|
||||||
status = SFLT_NOT_INDEX;
|
status = SFLT_NOT_INDEX;
|
||||||
code = doFilterTag(pTagIndexCond, &metaArg, pUidList, &status);
|
code = doFilterTag(pTagIndexCond, &metaArg, pUidList, &status, &pStorageAPI->metaFilter);
|
||||||
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
|
||||||
qWarn("failed to get tableIds from index, suid:%" PRIu64, pScanNode->uid);
|
qWarn("failed to get tableIds from index, suid:%" PRIu64, pScanNode->uid);
|
||||||
code = TSDB_CODE_SUCCESS;
|
code = TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -1485,7 +1485,7 @@ static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) {
|
||||||
} else {
|
} else {
|
||||||
if (pInfo->showRewrite == false) {
|
if (pInfo->showRewrite == false) {
|
||||||
if (pCondition != NULL && pInfo->pIdx == NULL) {
|
if (pCondition != NULL && pInfo->pIdx == NULL) {
|
||||||
SSTabFltArg arg = {.pMeta = pInfo->readHandle.vnode, .pVnode = pInfo->readHandle.vnode};
|
SSTabFltArg arg = {.pMeta = pInfo->readHandle.vnode, .pVnode = pInfo->readHandle.vnode, .pAPI = &pTaskInfo->storageAPI};
|
||||||
|
|
||||||
SSysTableIndex* idx = taosMemoryMalloc(sizeof(SSysTableIndex));
|
SSysTableIndex* idx = taosMemoryMalloc(sizeof(SSysTableIndex));
|
||||||
idx->init = 0;
|
idx->init = 0;
|
||||||
|
|
|
@ -86,6 +86,7 @@ typedef struct SIFCtx {
|
||||||
SHashObj *pRes; /* element is SIFParam */
|
SHashObj *pRes; /* element is SIFParam */
|
||||||
bool noExec; // true: just iterate condition tree, and add hint to executor plan
|
bool noExec; // true: just iterate condition tree, and add hint to executor plan
|
||||||
SIndexMetaArg arg;
|
SIndexMetaArg arg;
|
||||||
|
SMetaDataFilterAPI *pAPI;
|
||||||
} SIFCtx;
|
} SIFCtx;
|
||||||
|
|
||||||
static FORCE_INLINE int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) {
|
static FORCE_INLINE int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) {
|
||||||
|
@ -288,6 +289,8 @@ static int32_t sifInitParamValByCol(SNode *r, SNode *l, SIFParam *param, SIFCtx
|
||||||
}
|
}
|
||||||
static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
||||||
param->status = SFLT_COARSE_INDEX;
|
param->status = SFLT_COARSE_INDEX;
|
||||||
|
param->api = *ctx->pAPI;
|
||||||
|
|
||||||
switch (nodeType(node)) {
|
switch (nodeType(node)) {
|
||||||
case QUERY_NODE_VALUE: {
|
case QUERY_NODE_VALUE: {
|
||||||
SValueNode *vn = (SValueNode *)node;
|
SValueNode *vn = (SValueNode *)node;
|
||||||
|
@ -364,6 +367,7 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
|
||||||
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam));
|
SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam));
|
||||||
|
|
||||||
if (NULL == paramList) {
|
if (NULL == paramList) {
|
||||||
|
@ -972,8 +976,9 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
|
||||||
if (pNode == NULL || pDst == NULL) {
|
if (pNode == NULL || pDst == NULL) {
|
||||||
return TSDB_CODE_QRY_INVALID_INPUT;
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SIFCtx ctx = {.code = 0, .noExec = false, .arg = pDst->arg};
|
SIFCtx ctx = {.code = 0, .noExec = false, .arg = pDst->arg, .pAPI = &pDst->api};
|
||||||
ctx.pRes = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
ctx.pRes = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
|
|
||||||
if (NULL == ctx.pRes) {
|
if (NULL == ctx.pRes) {
|
||||||
|
@ -1006,13 +1011,13 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status) {
|
static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status, SMetaDataFilterAPI* pAPI) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (pNode == NULL) {
|
if (pNode == NULL) {
|
||||||
return TSDB_CODE_QRY_INVALID_INPUT;
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIFCtx ctx = {.code = 0, .noExec = true};
|
SIFCtx ctx = {.code = 0, .noExec = true, .pAPI = pAPI};
|
||||||
ctx.pRes = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
ctx.pRes = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||||
if (NULL == ctx.pRes) {
|
if (NULL == ctx.pRes) {
|
||||||
indexError("index-filter failed to taosHashInit");
|
indexError("index-filter failed to taosHashInit");
|
||||||
|
@ -1044,8 +1049,8 @@ static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doFilterTag(SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *result, SIdxFltStatus *status) {
|
int32_t doFilterTag(SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *result, SIdxFltStatus *status, SMetaDataFilterAPI* pAPI) {
|
||||||
SIdxFltStatus st = idxGetFltStatus(pFilterNode);
|
SIdxFltStatus st = idxGetFltStatus(pFilterNode, pAPI);
|
||||||
if (st == SFLT_NOT_INDEX) {
|
if (st == SFLT_NOT_INDEX) {
|
||||||
*status = st;
|
*status = st;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1054,7 +1059,7 @@ 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, .status = SFLT_NOT_INDEX};
|
SIFParam param = {.arg = *metaArg, .result = output, .status = SFLT_NOT_INDEX, .api = *pAPI};
|
||||||
int32_t code = sifCalculate((SNode *)pFilterNode, ¶m);
|
int32_t code = sifCalculate((SNode *)pFilterNode, ¶m);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
sifFreeParam(¶m);
|
sifFreeParam(¶m);
|
||||||
|
@ -1071,13 +1076,13 @@ int32_t doFilterTag(SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *result,
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIdxFltStatus idxGetFltStatus(SNode *pFilterNode) {
|
SIdxFltStatus idxGetFltStatus(SNode *pFilterNode, SMetaDataFilterAPI* pAPI) {
|
||||||
SIdxFltStatus st = SFLT_NOT_INDEX;
|
SIdxFltStatus st = SFLT_NOT_INDEX;
|
||||||
if (pFilterNode == NULL) {
|
if (pFilterNode == NULL) {
|
||||||
return SFLT_NOT_INDEX;
|
return SFLT_NOT_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sifGetFltHint((SNode *)pFilterNode, &st) != TSDB_CODE_SUCCESS) {
|
if (sifGetFltHint((SNode *)pFilterNode, &st, pAPI) != TSDB_CODE_SUCCESS) {
|
||||||
st = SFLT_NOT_INDEX;
|
st = SFLT_NOT_INDEX;
|
||||||
}
|
}
|
||||||
return st;
|
return st;
|
||||||
|
|
|
@ -8,7 +8,7 @@ IF(NOT TD_DARWIN)
|
||||||
ADD_EXECUTABLE(qworkerTest ${SOURCE_LIST})
|
ADD_EXECUTABLE(qworkerTest ${SOURCE_LIST})
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
qworkerTest
|
qworkerTest
|
||||||
PUBLIC os util common transport gtest qcom nodes planner qworker executor
|
PUBLIC os util common transport gtest qcom nodes planner qworker executor index
|
||||||
)
|
)
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(
|
TARGET_INCLUDE_DIRECTORIES(
|
||||||
|
|
Loading…
Reference in New Issue