Merge remote-tracking branch 'haoyifan/vnode_read' into develop
This commit is contained in:
commit
f14e986e52
|
@ -117,7 +117,7 @@ static int32_t flushFromResultBuf(SQInfo *pQInfo);
|
||||||
bool doFilterData(SQuery *pQuery, int32_t elemPos) {
|
bool doFilterData(SQuery *pQuery, int32_t elemPos) {
|
||||||
for (int32_t k = 0; k < pQuery->numOfFilterCols; ++k) {
|
for (int32_t k = 0; k < pQuery->numOfFilterCols; ++k) {
|
||||||
SSingleColumnFilterInfo *pFilterInfo = &pQuery->pFilterInfo[k];
|
SSingleColumnFilterInfo *pFilterInfo = &pQuery->pFilterInfo[k];
|
||||||
|
|
||||||
char *pElem = pFilterInfo->pData + pFilterInfo->info.bytes * elemPos;
|
char *pElem = pFilterInfo->pData + pFilterInfo->info.bytes * elemPos;
|
||||||
if (isNull(pElem, pFilterInfo->info.type)) {
|
if (isNull(pElem, pFilterInfo->info.type)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -126,7 +126,7 @@ bool doFilterData(SQuery *pQuery, int32_t elemPos) {
|
||||||
bool qualified = false;
|
bool qualified = false;
|
||||||
for (int32_t j = 0; j < pFilterInfo->numOfFilters; ++j) {
|
for (int32_t j = 0; j < pFilterInfo->numOfFilters; ++j) {
|
||||||
SColumnFilterElem *pFilterElem = &pFilterInfo->pFilters[j];
|
SColumnFilterElem *pFilterElem = &pFilterInfo->pFilters[j];
|
||||||
|
|
||||||
if (pFilterElem->fp(pFilterElem, pElem, pElem)) {
|
if (pFilterElem->fp(pFilterElem, pElem, pElem)) {
|
||||||
qualified = true;
|
qualified = true;
|
||||||
break;
|
break;
|
||||||
|
@ -765,7 +765,7 @@ static char *getDataBlock(SQueryRuntimeEnv *pRuntimeEnv, SArithmeticSupport *sas
|
||||||
SArray *pDataBlock) {
|
SArray *pDataBlock) {
|
||||||
char *dataBlock = NULL;
|
char *dataBlock = NULL;
|
||||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||||
|
|
||||||
SQLFunctionCtx *pCtx = pRuntimeEnv->pCtx;
|
SQLFunctionCtx *pCtx = pRuntimeEnv->pCtx;
|
||||||
|
|
||||||
int32_t functionId = pQuery->pSelectExpr[col].base.functionId;
|
int32_t functionId = pQuery->pSelectExpr[col].base.functionId;
|
||||||
|
@ -778,18 +778,18 @@ static char *getDataBlock(SQueryRuntimeEnv *pRuntimeEnv, SArithmeticSupport *sas
|
||||||
} else {
|
} else {
|
||||||
pCtx->startOffset = pQuery->pos - (size - 1);
|
pCtx->startOffset = pQuery->pos - (size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sas->offset = 0;
|
sas->offset = 0;
|
||||||
sas->colList = pQuery->colList;
|
sas->colList = pQuery->colList;
|
||||||
sas->numOfCols = pQuery->numOfCols;
|
sas->numOfCols = pQuery->numOfCols;
|
||||||
sas->data = calloc(pQuery->numOfCols, POINTER_BYTES);
|
sas->data = calloc(pQuery->numOfCols, POINTER_BYTES);
|
||||||
|
|
||||||
// here the pQuery->colList and sas->colList are identical
|
// here the pQuery->colList and sas->colList are identical
|
||||||
for (int32_t i = 0; i < pQuery->numOfCols; ++i) {
|
for (int32_t i = 0; i < pQuery->numOfCols; ++i) {
|
||||||
SColumnInfo *pColMsg = &pQuery->colList[i];
|
SColumnInfo *pColMsg = &pQuery->colList[i];
|
||||||
|
|
||||||
int32_t numOfCols = taosArrayGetSize(pDataBlock);
|
int32_t numOfCols = taosArrayGetSize(pDataBlock);
|
||||||
|
|
||||||
dataBlock = NULL;
|
dataBlock = NULL;
|
||||||
for (int32_t k = 0; k < numOfCols; ++k) { //todo refactor
|
for (int32_t k = 0; k < numOfCols; ++k) { //todo refactor
|
||||||
SColumnInfoData *p = taosArrayGet(pDataBlock, k);
|
SColumnInfoData *p = taosArrayGet(pDataBlock, k);
|
||||||
|
@ -798,7 +798,7 @@ static char *getDataBlock(SQueryRuntimeEnv *pRuntimeEnv, SArithmeticSupport *sas
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(dataBlock != NULL);
|
assert(dataBlock != NULL);
|
||||||
sas->data[i] = dataBlock/* + pQuery->colList[i].bytes*/; // start from the offset
|
sas->data[i] = dataBlock/* + pQuery->colList[i].bytes*/; // start from the offset
|
||||||
}
|
}
|
||||||
|
@ -838,7 +838,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
|
||||||
}
|
}
|
||||||
|
|
||||||
SArithmeticSupport *sasArray = calloc((size_t)pQuery->numOfOutput, sizeof(SArithmeticSupport));
|
SArithmeticSupport *sasArray = calloc((size_t)pQuery->numOfOutput, sizeof(SArithmeticSupport));
|
||||||
|
|
||||||
for (int32_t k = 0; k < pQuery->numOfOutput; ++k) {
|
for (int32_t k = 0; k < pQuery->numOfOutput; ++k) {
|
||||||
char *dataBlock = getDataBlock(pRuntimeEnv, &sasArray[k], k, pDataBlockInfo->rows, pDataBlock);
|
char *dataBlock = getDataBlock(pRuntimeEnv, &sasArray[k], k, pDataBlockInfo->rows, pDataBlock);
|
||||||
setExecParams(pQuery, &pCtx[k], dataBlock, tsCols, pDataBlockInfo, pStatis, &sasArray[k], k);
|
setExecParams(pQuery, &pCtx[k], dataBlock, tsCols, pDataBlockInfo, pStatis, &sasArray[k], k);
|
||||||
|
@ -901,10 +901,10 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
|
||||||
if (pQuery->pSelectExpr[i].base.functionId != TSDB_FUNC_ARITHM) {
|
if (pQuery->pSelectExpr[i].base.functionId != TSDB_FUNC_ARITHM) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(sasArray[i].data);
|
tfree(sasArray[i].data);
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(sasArray);
|
tfree(sasArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -964,7 +964,7 @@ static char *getGroupbyColumnData(SQuery *pQuery, int16_t *type, int16_t *bytes,
|
||||||
* column in cache with the corresponding meter schema is reinforced.
|
* column in cache with the corresponding meter schema is reinforced.
|
||||||
*/
|
*/
|
||||||
int32_t numOfCols = taosArrayGetSize(pDataBlock);
|
int32_t numOfCols = taosArrayGetSize(pDataBlock);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColumnInfoData *p = taosArrayGet(pDataBlock, i);
|
SColumnInfoData *p = taosArrayGet(pDataBlock, i);
|
||||||
if (pColIndex->colId == p->info.colId) {
|
if (pColIndex->colId == p->info.colId) {
|
||||||
|
@ -972,7 +972,7 @@ static char *getGroupbyColumnData(SQuery *pQuery, int16_t *type, int16_t *bytes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1037,7 +1037,7 @@ static bool functionNeedToExecute(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx
|
||||||
static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pStatis, SDataBlockInfo *pDataBlockInfo,
|
static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pStatis, SDataBlockInfo *pDataBlockInfo,
|
||||||
SWindowResInfo *pWindowResInfo, SArray *pDataBlock) {
|
SWindowResInfo *pWindowResInfo, SArray *pDataBlock) {
|
||||||
SQLFunctionCtx *pCtx = pRuntimeEnv->pCtx;
|
SQLFunctionCtx *pCtx = pRuntimeEnv->pCtx;
|
||||||
|
|
||||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||||
STableQueryInfo* item = pQuery->current;
|
STableQueryInfo* item = pQuery->current;
|
||||||
|
|
||||||
|
@ -1170,10 +1170,10 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
|
||||||
if (pQuery->pSelectExpr[i].base.functionId != TSDB_FUNC_ARITHM) {
|
if (pQuery->pSelectExpr[i].base.functionId != TSDB_FUNC_ARITHM) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(sasArray[i].data);
|
tfree(sasArray[i].data);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(sasArray);
|
free(sasArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1362,7 +1362,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order
|
||||||
|
|
||||||
SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i];
|
SQLFunctionCtx *pCtx = &pRuntimeEnv->pCtx[i];
|
||||||
SColIndex* pIndex = &pSqlFuncMsg->colInfo;
|
SColIndex* pIndex = &pSqlFuncMsg->colInfo;
|
||||||
|
|
||||||
int32_t index = pSqlFuncMsg->colInfo.colIndex;
|
int32_t index = pSqlFuncMsg->colInfo.colIndex;
|
||||||
if (TSDB_COL_IS_TAG(pIndex->flag)) {
|
if (TSDB_COL_IS_TAG(pIndex->flag)) {
|
||||||
if (pIndex->colId == TSDB_TBNAME_COLUMN_INDEX) { // todo refactor
|
if (pIndex->colId == TSDB_TBNAME_COLUMN_INDEX) { // todo refactor
|
||||||
|
@ -1443,7 +1443,7 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
|
||||||
|
|
||||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||||
SQInfo* pQInfo = (SQInfo*) GET_QINFO_ADDR(pRuntimeEnv);
|
SQInfo* pQInfo = (SQInfo*) GET_QINFO_ADDR(pRuntimeEnv);
|
||||||
|
|
||||||
qTrace("QInfo:%p teardown runtime env", pQInfo);
|
qTrace("QInfo:%p teardown runtime env", pQInfo);
|
||||||
cleanupTimeWindowInfo(&pRuntimeEnv->windowResInfo, pQuery->numOfOutput);
|
cleanupTimeWindowInfo(&pRuntimeEnv->windowResInfo, pQuery->numOfOutput);
|
||||||
|
|
||||||
|
@ -1485,7 +1485,7 @@ static bool isQueryKilled(SQInfo *pQInfo) {
|
||||||
pQInfo->killed = 1;
|
pQInfo->killed = 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (pQInfo->killed == 1);
|
return (pQInfo->killed == 1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1591,7 +1591,7 @@ static bool onlyQueryTags(SQuery* pQuery) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1893,14 +1893,14 @@ UNUSED_FUNC void vnodeDecMeterRefcnt(SQInfo *pQInfo) {
|
||||||
for (int32_t i = 0; i < pQInfo->groupInfo.numOfTables; ++i) {
|
for (int32_t i = 0; i < pQInfo->groupInfo.numOfTables; ++i) {
|
||||||
SMeterObj *pMeter = getMeterObj(pQInfo->groupInfo, pQInfo->pSidSet->pTableIdList[i]->sid);
|
SMeterObj *pMeter = getMeterObj(pQInfo->groupInfo, pQInfo->pSidSet->pTableIdList[i]->sid);
|
||||||
atomic_fetch_sub_32(&(pMeter->numOfQueries), 1);
|
atomic_fetch_sub_32(&(pMeter->numOfQueries), 1);
|
||||||
|
|
||||||
if (pMeter->numOfQueries > 0) {
|
if (pMeter->numOfQueries > 0) {
|
||||||
qTrace("QInfo:%p vid:%d sid:%d meterId:%s, query is over, numOfQueries:%d", pQInfo, pMeter->vnode, pMeter->sid,
|
qTrace("QInfo:%p vid:%d sid:%d meterId:%s, query is over, numOfQueries:%d", pQInfo, pMeter->vnode, pMeter->sid,
|
||||||
pMeter->meterId, pMeter->numOfQueries);
|
pMeter->meterId, pMeter->numOfQueries);
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in order to reduce log output, for all meters of which numOfQueries count are 0,
|
* in order to reduce log output, for all meters of which numOfQueries count are 0,
|
||||||
* we do not output corresponding information
|
* we do not output corresponding information
|
||||||
|
@ -1922,26 +1922,26 @@ static bool needToLoadDataBlock(SQuery *pQuery, SDataStatis *pDataStatis, SQLFun
|
||||||
for (int32_t k = 0; k < pQuery->numOfFilterCols; ++k) {
|
for (int32_t k = 0; k < pQuery->numOfFilterCols; ++k) {
|
||||||
SSingleColumnFilterInfo *pFilterInfo = &pQuery->pFilterInfo[k];
|
SSingleColumnFilterInfo *pFilterInfo = &pQuery->pFilterInfo[k];
|
||||||
int32_t colIndex = pFilterInfo->info.colIndex;
|
int32_t colIndex = pFilterInfo->info.colIndex;
|
||||||
|
|
||||||
// this column not valid in current data block
|
// this column not valid in current data block
|
||||||
if (colIndex < 0 || pDataStatis[colIndex].colId != pFilterInfo->info.data.colId) {
|
if (colIndex < 0 || pDataStatis[colIndex].colId != pFilterInfo->info.data.colId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// not support pre-filter operation on binary/nchar data type
|
// not support pre-filter operation on binary/nchar data type
|
||||||
if (!vnodeSupportPrefilter(pFilterInfo->info.data.type)) {
|
if (!vnodeSupportPrefilter(pFilterInfo->info.data.type)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// all points in current column are NULL, no need to check its boundary value
|
// all points in current column are NULL, no need to check its boundary value
|
||||||
if (pDataStatis[colIndex].numOfNull == numOfTotalPoints) {
|
if (pDataStatis[colIndex].numOfNull == numOfTotalPoints) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pFilterInfo->info.info.type == TSDB_DATA_TYPE_FLOAT) {
|
if (pFilterInfo->info.info.type == TSDB_DATA_TYPE_FLOAT) {
|
||||||
float minval = *(double *)(&pDataStatis[colIndex].min);
|
float minval = *(double *)(&pDataStatis[colIndex].min);
|
||||||
float maxval = *(double *)(&pDataStatis[colIndex].max);
|
float maxval = *(double *)(&pDataStatis[colIndex].max);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pFilterInfo->numOfFilters; ++i) {
|
for (int32_t i = 0; i < pFilterInfo->numOfFilters; ++i) {
|
||||||
if (pFilterInfo->pFilters[i].fp(&pFilterInfo->pFilters[i], (char *)&minval, (char *)&maxval)) {
|
if (pFilterInfo->pFilters[i].fp(&pFilterInfo->pFilters[i], (char *)&minval, (char *)&maxval)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1956,7 +1956,7 @@ static bool needToLoadDataBlock(SQuery *pQuery, SDataStatis *pDataStatis, SQLFun
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo disable this opt code block temporarily
|
// todo disable this opt code block temporarily
|
||||||
// for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
// for (int32_t i = 0; i < pQuery->numOfOutput; ++i) {
|
||||||
// int32_t functId = pQuery->pSelectExpr[i].base.functionId;
|
// int32_t functId = pQuery->pSelectExpr[i].base.functionId;
|
||||||
|
@ -2392,7 +2392,7 @@ void UNUSED_FUNC displayInterResult(tFilePage **pdata, SQueryRuntimeEnv* pRuntim
|
||||||
SQuery* pQuery = pRuntimeEnv->pQuery;
|
SQuery* pQuery = pRuntimeEnv->pQuery;
|
||||||
int32_t numOfCols = pQuery->numOfOutput;
|
int32_t numOfCols = pQuery->numOfOutput;
|
||||||
printf("super table query intermediate result, total:%d\n", numOfRows);
|
printf("super table query intermediate result, total:%d\n", numOfRows);
|
||||||
|
|
||||||
for (int32_t j = 0; j < numOfRows; ++j) {
|
for (int32_t j = 0; j < numOfRows; ++j) {
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
|
||||||
|
@ -3534,7 +3534,7 @@ void stableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, STableQueryInfo
|
||||||
SQuery * pQuery = pRuntimeEnv->pQuery;
|
SQuery * pQuery = pRuntimeEnv->pQuery;
|
||||||
SWindowResInfo * pWindowResInfo = &pTableQueryInfo->windowResInfo;
|
SWindowResInfo * pWindowResInfo = &pTableQueryInfo->windowResInfo;
|
||||||
pQuery->pos = QUERY_IS_ASC_QUERY(pQuery)? 0 : pDataBlockInfo->rows - 1;
|
pQuery->pos = QUERY_IS_ASC_QUERY(pQuery)? 0 : pDataBlockInfo->rows - 1;
|
||||||
|
|
||||||
if (pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf != NULL) {
|
if (pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf != NULL) {
|
||||||
rowwiseApplyFunctions(pRuntimeEnv, pStatis, pDataBlockInfo, pWindowResInfo, pDataBlock);
|
rowwiseApplyFunctions(pRuntimeEnv, pStatis, pDataBlockInfo, pWindowResInfo, pDataBlock);
|
||||||
} else {
|
} else {
|
||||||
|
@ -4110,11 +4110,11 @@ static int64_t queryOnDataBlocks(SQInfo *pQInfo) {
|
||||||
if (pInfo->id.tid == blockInfo.tid) {
|
if (pInfo->id.tid == blockInfo.tid) {
|
||||||
assert(pInfo->id.uid == blockInfo.uid);
|
assert(pInfo->id.uid == blockInfo.uid);
|
||||||
pTableQueryInfo = item->info;
|
pTableQueryInfo = item->info;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTableQueryInfo != NULL) {
|
if (pTableQueryInfo != NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4182,11 +4182,11 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
|
||||||
tsdbCleanupQueryHandle(pRuntimeEnv->pQueryHandle);
|
tsdbCleanupQueryHandle(pRuntimeEnv->pQueryHandle);
|
||||||
pRuntimeEnv->pQueryHandle = NULL;
|
pRuntimeEnv->pQueryHandle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRuntimeEnv->pQueryHandle = tsdbQueryTables(pQInfo->tsdb, &cond, &gp);
|
pRuntimeEnv->pQueryHandle = tsdbQueryTables(pQInfo->tsdb, &cond, &gp);
|
||||||
taosArrayDestroy(tx);
|
taosArrayDestroy(tx);
|
||||||
taosArrayDestroy(g1);
|
taosArrayDestroy(g1);
|
||||||
|
|
||||||
if (pRuntimeEnv->pTSBuf != NULL) {
|
if (pRuntimeEnv->pTSBuf != NULL) {
|
||||||
if (pRuntimeEnv->cur.vgroupIndex == -1) {
|
if (pRuntimeEnv->cur.vgroupIndex == -1) {
|
||||||
int64_t tag = pRuntimeEnv->pCtx[0].tag.i64Key;
|
int64_t tag = pRuntimeEnv->pCtx[0].tag.i64Key;
|
||||||
|
@ -4859,22 +4859,22 @@ static void stableQueryImpl(SQInfo *pQInfo) {
|
||||||
|
|
||||||
static int32_t getColumnIndexInSource(SQueryTableMsg *pQueryMsg, SSqlFuncMsg *pExprMsg, SColumnInfo* pTagCols) {
|
static int32_t getColumnIndexInSource(SQueryTableMsg *pQueryMsg, SSqlFuncMsg *pExprMsg, SColumnInfo* pTagCols) {
|
||||||
int32_t j = 0;
|
int32_t j = 0;
|
||||||
|
|
||||||
if (TSDB_COL_IS_TAG(pExprMsg->colInfo.flag)) {
|
if (TSDB_COL_IS_TAG(pExprMsg->colInfo.flag)) {
|
||||||
while(j < pQueryMsg->numOfTags) {
|
while(j < pQueryMsg->numOfTags) {
|
||||||
if (pExprMsg->colInfo.colId == pTagCols[j].colId) {
|
if (pExprMsg->colInfo.colId == pTagCols[j].colId) {
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
j += 1;
|
j += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
while (j < pQueryMsg->numOfCols) {
|
while (j < pQueryMsg->numOfCols) {
|
||||||
if (pExprMsg->colInfo.colId == pQueryMsg->colList[j].colId) {
|
if (pExprMsg->colInfo.colId == pQueryMsg->colList[j].colId) {
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
j += 1;
|
j += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4923,7 +4923,7 @@ static bool validateQuerySourceCols(SQueryTableMsg *pQueryMsg, SSqlFuncMsg** pEx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5065,10 +5065,10 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
|
||||||
|
|
||||||
pExprMsg = (SSqlFuncMsg *)pMsg;
|
pExprMsg = (SSqlFuncMsg *)pMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validateQuerySourceCols(pQueryMsg, *pExpr)) {
|
if (!validateQuerySourceCols(pQueryMsg, *pExpr)) {
|
||||||
tfree(*pExpr);
|
tfree(*pExpr);
|
||||||
|
|
||||||
return TSDB_CODE_INVALID_QUERY_MSG;
|
return TSDB_CODE_INVALID_QUERY_MSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5111,12 +5111,12 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
|
||||||
(*tagCols) = calloc(1, sizeof(SColumnInfo) * pQueryMsg->numOfTags);
|
(*tagCols) = calloc(1, sizeof(SColumnInfo) * pQueryMsg->numOfTags);
|
||||||
for (int32_t i = 0; i < pQueryMsg->numOfTags; ++i) {
|
for (int32_t i = 0; i < pQueryMsg->numOfTags; ++i) {
|
||||||
SColumnInfo* pTagCol = (SColumnInfo*) pMsg;
|
SColumnInfo* pTagCol = (SColumnInfo*) pMsg;
|
||||||
|
|
||||||
pTagCol->colId = htons(pTagCol->colId);
|
pTagCol->colId = htons(pTagCol->colId);
|
||||||
pTagCol->bytes = htons(pTagCol->bytes);
|
pTagCol->bytes = htons(pTagCol->bytes);
|
||||||
pTagCol->type = htons(pTagCol->type);
|
pTagCol->type = htons(pTagCol->type);
|
||||||
pTagCol->numOfFilters = 0;
|
pTagCol->numOfFilters = 0;
|
||||||
|
|
||||||
(*tagCols)[i] = *pTagCol;
|
(*tagCols)[i] = *pTagCol;
|
||||||
pMsg += sizeof(SColumnInfo);
|
pMsg += sizeof(SColumnInfo);
|
||||||
}
|
}
|
||||||
|
@ -5128,14 +5128,14 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
|
||||||
memcpy(*tagCond, pMsg, pQueryMsg->tagCondLen);
|
memcpy(*tagCond, pMsg, pQueryMsg->tagCondLen);
|
||||||
pMsg += pQueryMsg->tagCondLen;
|
pMsg += pQueryMsg->tagCondLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*pMsg != 0) {
|
if (*pMsg != 0) {
|
||||||
size_t len = strlen(pMsg) + 1;
|
size_t len = strlen(pMsg) + 1;
|
||||||
*tbnameCond = malloc(len);
|
*tbnameCond = malloc(len);
|
||||||
strcpy(*tbnameCond, pMsg);
|
strcpy(*tbnameCond, pMsg);
|
||||||
pMsg += len;
|
pMsg += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
qTrace("qmsg:%p query %d tables, qrange:%" PRId64 "-%" PRId64 ", numOfGroupbyTagCols:%d, order:%d, "
|
qTrace("qmsg:%p query %d tables, qrange:%" PRId64 "-%" PRId64 ", numOfGroupbyTagCols:%d, order:%d, "
|
||||||
"outputCols:%d, numOfCols:%d, interval:%" PRId64 ", fillType:%d, comptsLen:%d, limit:%" PRId64 ", offset:%" PRId64,
|
"outputCols:%d, numOfCols:%d, interval:%" PRId64 ", fillType:%d, comptsLen:%d, limit:%" PRId64 ", offset:%" PRId64,
|
||||||
pQueryMsg, pQueryMsg->numOfTables, pQueryMsg->window.skey, pQueryMsg->window.ekey, pQueryMsg->numOfGroupCols,
|
pQueryMsg, pQueryMsg->numOfTables, pQueryMsg->window.skey, pQueryMsg->window.ekey, pQueryMsg->numOfGroupCols,
|
||||||
|
@ -5160,7 +5160,7 @@ static int32_t buildAirthmeticExprFromMsg(SExprInfo *pArithExprInfo, SQueryTable
|
||||||
qError("qmsg:%p failed to create arithmetic expression string from:%s", pQueryMsg, pArithExprInfo->base.arg[0].argValue.pz);
|
qError("qmsg:%p failed to create arithmetic expression string from:%s", pQueryMsg, pArithExprInfo->base.arg[0].argValue.pz);
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
pArithExprInfo->pExpr = pExprNode;
|
pArithExprInfo->pExpr = pExprNode;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -5225,7 +5225,7 @@ static int32_t createSqlFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo
|
||||||
for (int32_t i = 0; i < pQueryMsg->numOfOutput; ++i) {
|
for (int32_t i = 0; i < pQueryMsg->numOfOutput; ++i) {
|
||||||
pExprs[i].base = *pExprMsg[i];
|
pExprs[i].base = *pExprMsg[i];
|
||||||
int16_t functId = pExprs[i].base.functionId;
|
int16_t functId = pExprs[i].base.functionId;
|
||||||
|
|
||||||
if (functId == TSDB_FUNC_TOP || functId == TSDB_FUNC_BOTTOM) {
|
if (functId == TSDB_FUNC_TOP || functId == TSDB_FUNC_BOTTOM) {
|
||||||
int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].base, pTagCols);
|
int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].base, pTagCols);
|
||||||
assert(j < pQueryMsg->numOfCols);
|
assert(j < pQueryMsg->numOfCols);
|
||||||
|
@ -5265,7 +5265,7 @@ static SSqlGroupbyExpr *createGroupbyExprFromMsg(SQueryTableMsg *pQueryMsg, SCol
|
||||||
for(int32_t i = 0; i < pQueryMsg->numOfGroupCols; ++i) {
|
for(int32_t i = 0; i < pQueryMsg->numOfGroupCols; ++i) {
|
||||||
taosArrayPush(pGroupbyExpr->columnInfo, &pColIndex[i]);
|
taosArrayPush(pGroupbyExpr->columnInfo, &pColIndex[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pGroupbyExpr;
|
return pGroupbyExpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5288,7 +5288,7 @@ static int32_t createFilterInfo(void *pQInfo, SQuery *pQuery) {
|
||||||
|
|
||||||
memcpy(&pFilterInfo->info, &pQuery->colList[i], sizeof(SColumnInfoData));
|
memcpy(&pFilterInfo->info, &pQuery->colList[i], sizeof(SColumnInfoData));
|
||||||
pFilterInfo->info = pQuery->colList[i];
|
pFilterInfo->info = pQuery->colList[i];
|
||||||
|
|
||||||
pFilterInfo->numOfFilters = pQuery->colList[i].numOfFilters;
|
pFilterInfo->numOfFilters = pQuery->colList[i].numOfFilters;
|
||||||
pFilterInfo->pFilters = calloc(pFilterInfo->numOfFilters, sizeof(SColumnFilterElem));
|
pFilterInfo->pFilters = calloc(pFilterInfo->numOfFilters, sizeof(SColumnFilterElem));
|
||||||
|
|
||||||
|
@ -5435,9 +5435,9 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
|
||||||
pQuery->colList[i] = pQueryMsg->colList[i];
|
pQuery->colList[i] = pQueryMsg->colList[i];
|
||||||
pQuery->colList[i].filters = tscFilterInfoClone(pQueryMsg->colList[i].filters, pQuery->colList[i].numOfFilters);
|
pQuery->colList[i].filters = tscFilterInfoClone(pQueryMsg->colList[i].filters, pQuery->colList[i].numOfFilters);
|
||||||
}
|
}
|
||||||
|
|
||||||
pQuery->tagColList = pTagCols;
|
pQuery->tagColList = pTagCols;
|
||||||
|
|
||||||
// calculate the result row size
|
// calculate the result row size
|
||||||
for (int16_t col = 0; col < numOfOutput; ++col) {
|
for (int16_t col = 0; col < numOfOutput; ++col) {
|
||||||
assert(pExprs[col].bytes > 0);
|
assert(pExprs[col].bytes > 0);
|
||||||
|
@ -5484,22 +5484,23 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
|
||||||
|
|
||||||
// to make sure third party won't overwrite this structure
|
// to make sure third party won't overwrite this structure
|
||||||
pQInfo->signature = pQInfo;
|
pQInfo->signature = pQInfo;
|
||||||
|
|
||||||
pQInfo->tableIdGroupInfo = *groupInfo;
|
pQInfo->tableIdGroupInfo = *groupInfo;
|
||||||
size_t numOfGroups = taosArrayGetSize(groupInfo->pGroupList);
|
size_t numOfGroups = taosArrayGetSize(groupInfo->pGroupList);
|
||||||
|
|
||||||
pQInfo->groupInfo.pGroupList = taosArrayInit(numOfGroups, POINTER_BYTES);
|
pQInfo->groupInfo.pGroupList = taosArrayInit(numOfGroups, POINTER_BYTES);
|
||||||
pQInfo->groupInfo.numOfTables = groupInfo->numOfTables;
|
pQInfo->groupInfo.numOfTables = groupInfo->numOfTables;
|
||||||
|
|
||||||
int tableIndex = 0;
|
int tableIndex = 0;
|
||||||
STimeWindow window = pQueryMsg->window;
|
STimeWindow window = pQueryMsg->window;
|
||||||
taosArraySort(pTableIdList, compareTableIdInfo);
|
taosArraySort(pTableIdList, compareTableIdInfo);
|
||||||
|
|
||||||
for(int32_t i = 0; i < numOfGroups; ++i) {
|
for(int32_t i = 0; i < numOfGroups; ++i) {
|
||||||
SArray* pa = taosArrayGetP(groupInfo->pGroupList, i);
|
SArray* pa = taosArrayGetP(groupInfo->pGroupList, i);
|
||||||
size_t s = taosArrayGetSize(pa);
|
size_t s = taosArrayGetSize(pa);
|
||||||
|
|
||||||
SArray* p1 = taosArrayInit(s, sizeof(SGroupItem));
|
SArray* p1 = taosArrayInit(s, sizeof(SGroupItem));
|
||||||
|
|
||||||
for(int32_t j = 0; j < s; ++j) {
|
for(int32_t j = 0; j < s; ++j) {
|
||||||
STableId id = *(STableId*) taosArrayGet(pa, j);
|
STableId id = *(STableId*) taosArrayGet(pa, j);
|
||||||
SGroupItem item = { .id = id };
|
SGroupItem item = { .id = id };
|
||||||
|
@ -5515,6 +5516,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SArray* pTableIdList,
|
||||||
item.info->tableIndex = tableIndex++;
|
item.info->tableIndex = tableIndex++;
|
||||||
taosArrayPush(p1, &item);
|
taosArrayPush(p1, &item);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(pQInfo->groupInfo.pGroupList, &p1);
|
taosArrayPush(pQInfo->groupInfo.pGroupList, &p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5658,7 +5660,7 @@ static void freeQInfo(SQInfo *pQInfo) {
|
||||||
int32_t numOfGroups = taosArrayGetSize(pQInfo->groupInfo.pGroupList);
|
int32_t numOfGroups = taosArrayGetSize(pQInfo->groupInfo.pGroupList);
|
||||||
for (int32_t i = 0; i < numOfGroups; ++i) {
|
for (int32_t i = 0; i < numOfGroups; ++i) {
|
||||||
SArray *p = taosArrayGetP(pQInfo->groupInfo.pGroupList, i);
|
SArray *p = taosArrayGetP(pQInfo->groupInfo.pGroupList, i);
|
||||||
|
|
||||||
size_t num = taosArrayGetSize(p);
|
size_t num = taosArrayGetSize(p);
|
||||||
for(int32_t j = 0; j < num; ++j) {
|
for(int32_t j = 0; j < num; ++j) {
|
||||||
SGroupItem* item = taosArrayGet(p, j);
|
SGroupItem* item = taosArrayGet(p, j);
|
||||||
|
@ -5666,17 +5668,17 @@ static void freeQInfo(SQInfo *pQInfo) {
|
||||||
destroyTableQueryInfo(item->info, pQuery->numOfOutput);
|
destroyTableQueryInfo(item->info, pQuery->numOfOutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(p);
|
taosArrayDestroy(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pQInfo->groupInfo.pGroupList);
|
taosArrayDestroy(pQInfo->groupInfo.pGroupList);
|
||||||
|
|
||||||
for(int32_t i = 0; i < numOfGroups; ++i) {
|
for(int32_t i = 0; i < numOfGroups; ++i) {
|
||||||
SArray* p = taosArrayGetP(pQInfo->tableIdGroupInfo.pGroupList, i);
|
SArray* p = taosArrayGetP(pQInfo->tableIdGroupInfo.pGroupList, i);
|
||||||
taosArrayDestroy(p);
|
taosArrayDestroy(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pQInfo->tableIdGroupInfo.pGroupList);
|
taosArrayDestroy(pQInfo->tableIdGroupInfo.pGroupList);
|
||||||
taosArrayDestroy(pQInfo->arrTableIdInfo);
|
taosArrayDestroy(pQInfo->arrTableIdInfo);
|
||||||
|
|
||||||
|
@ -5684,14 +5686,14 @@ static void freeQInfo(SQInfo *pQInfo) {
|
||||||
taosArrayDestroy(pQuery->pGroupbyExpr->columnInfo);
|
taosArrayDestroy(pQuery->pGroupbyExpr->columnInfo);
|
||||||
tfree(pQuery->pGroupbyExpr);
|
tfree(pQuery->pGroupbyExpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pQuery->tagColList);
|
tfree(pQuery->tagColList);
|
||||||
tfree(pQuery->pFilterInfo);
|
tfree(pQuery->pFilterInfo);
|
||||||
tfree(pQuery->colList);
|
tfree(pQuery->colList);
|
||||||
tfree(pQuery->sdata);
|
tfree(pQuery->sdata);
|
||||||
|
|
||||||
tfree(pQuery);
|
tfree(pQuery);
|
||||||
|
|
||||||
qTrace("QInfo:%p QInfo is freed", pQInfo);
|
qTrace("QInfo:%p QInfo is freed", pQInfo);
|
||||||
|
|
||||||
// destroy signature, in order to avoid the query process pass the object safety check
|
// destroy signature, in order to avoid the query process pass the object safety check
|
||||||
|
@ -5744,7 +5746,7 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
|
||||||
qError("QInfo:%p failed to open tmp file to send ts-comp data to client, path:%s, reason:%s", pQInfo,
|
qError("QInfo:%p failed to open tmp file to send ts-comp data to client, path:%s, reason:%s", pQInfo,
|
||||||
pQuery->sdata[0]->data, strerror(errno));
|
pQuery->sdata[0]->data, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
// all data returned, set query over
|
// all data returned, set query over
|
||||||
if (Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) {
|
if (Q_STATUS_EQUAL(pQuery->status, QUERY_COMPLETED)) {
|
||||||
setQueryStatus(pQuery, QUERY_OVER);
|
setQueryStatus(pQuery, QUERY_OVER);
|
||||||
|
@ -5861,7 +5863,12 @@ _over:
|
||||||
tfree(tagCond);
|
tfree(tagCond);
|
||||||
tfree(tbnameCond);
|
tfree(tbnameCond);
|
||||||
taosArrayDestroy(pTableIdList);
|
taosArrayDestroy(pTableIdList);
|
||||||
|
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tfree(*pQInfo);
|
||||||
|
*pQInfo = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// if failed to add ref for all meters in this query, abort current query
|
// if failed to add ref for all meters in this query, abort current query
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -5885,7 +5892,7 @@ void qTableQuery(qinfo_t qinfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
qTrace("QInfo:%p query task is launched", pQInfo);
|
qTrace("QInfo:%p query task is launched", pQInfo);
|
||||||
|
|
||||||
if (onlyQueryTags(pQInfo->runtimeEnv.pQuery)) {
|
if (onlyQueryTags(pQInfo->runtimeEnv.pQuery)) {
|
||||||
buildTagQueryResult(pQInfo); // todo support the limit/offset
|
buildTagQueryResult(pQInfo); // todo support the limit/offset
|
||||||
} else if (pQInfo->runtimeEnv.stableQuery) {
|
} else if (pQInfo->runtimeEnv.stableQuery) {
|
||||||
|
@ -5893,7 +5900,7 @@ void qTableQuery(qinfo_t qinfo) {
|
||||||
} else {
|
} else {
|
||||||
tableQueryImpl(pQInfo);
|
tableQueryImpl(pQInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
sem_post(&pQInfo->dataReady);
|
sem_post(&pQInfo->dataReady);
|
||||||
// vnodeDecRefCount(pQInfo);
|
// vnodeDecRefCount(pQInfo);
|
||||||
}
|
}
|
||||||
|
@ -5987,7 +5994,7 @@ int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *co
|
||||||
static void buildTagQueryResult(SQInfo* pQInfo) {
|
static void buildTagQueryResult(SQInfo* pQInfo) {
|
||||||
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
|
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
|
||||||
SQuery * pQuery = pRuntimeEnv->pQuery;
|
SQuery * pQuery = pRuntimeEnv->pQuery;
|
||||||
|
|
||||||
size_t num = taosArrayGetSize(pQInfo->groupInfo.pGroupList);
|
size_t num = taosArrayGetSize(pQInfo->groupInfo.pGroupList);
|
||||||
assert(num == 0 || num == 1);
|
assert(num == 0 || num == 1);
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
|
@ -5996,44 +6003,44 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
|
||||||
|
|
||||||
SArray* pa = taosArrayGetP(pQInfo->groupInfo.pGroupList, 0);
|
SArray* pa = taosArrayGetP(pQInfo->groupInfo.pGroupList, 0);
|
||||||
num = taosArrayGetSize(pa);
|
num = taosArrayGetSize(pa);
|
||||||
|
|
||||||
assert(num == pQInfo->groupInfo.numOfTables);
|
assert(num == pQInfo->groupInfo.numOfTables);
|
||||||
int16_t type, bytes;
|
int16_t type, bytes;
|
||||||
|
|
||||||
int32_t functionId = pQuery->pSelectExpr[0].base.functionId;
|
int32_t functionId = pQuery->pSelectExpr[0].base.functionId;
|
||||||
if (functionId == TSDB_FUNC_TID_TAG) { // return the tags & table Id
|
if (functionId == TSDB_FUNC_TID_TAG) { // return the tags & table Id
|
||||||
assert(pQuery->numOfOutput == 1);
|
assert(pQuery->numOfOutput == 1);
|
||||||
SExprInfo* pExprInfo = &pQuery->pSelectExpr[0];
|
SExprInfo* pExprInfo = &pQuery->pSelectExpr[0];
|
||||||
|
|
||||||
int32_t rsize = pExprInfo->bytes;
|
int32_t rsize = pExprInfo->bytes;
|
||||||
char* data = NULL;
|
char* data = NULL;
|
||||||
|
|
||||||
for(int32_t i = 0; i < num; ++i) {
|
for(int32_t i = 0; i < num; ++i) {
|
||||||
SGroupItem* item = taosArrayGet(pa, i);
|
SGroupItem* item = taosArrayGet(pa, i);
|
||||||
|
|
||||||
char* output = pQuery->sdata[0]->data + i * rsize;
|
char* output = pQuery->sdata[0]->data + i * rsize;
|
||||||
varDataSetLen(output, rsize - VARSTR_HEADER_SIZE);
|
varDataSetLen(output, rsize - VARSTR_HEADER_SIZE);
|
||||||
|
|
||||||
output = varDataVal(output);
|
output = varDataVal(output);
|
||||||
*(int64_t*) output = item->id.uid; // memory align problem, todo serialize
|
*(int64_t*) output = item->id.uid; // memory align problem, todo serialize
|
||||||
output += sizeof(item->id.uid);
|
output += sizeof(item->id.uid);
|
||||||
|
|
||||||
*(int32_t*) output = item->id.tid;
|
*(int32_t*) output = item->id.tid;
|
||||||
output += sizeof(item->id.tid);
|
output += sizeof(item->id.tid);
|
||||||
|
|
||||||
*(int32_t*) output = pQInfo->vgId;
|
*(int32_t*) output = pQInfo->vgId;
|
||||||
output += sizeof(pQInfo->vgId);
|
output += sizeof(pQInfo->vgId);
|
||||||
|
|
||||||
tsdbGetTableTagVal(pQInfo->tsdb, &item->id, pExprInfo->base.colInfo.colId, &type, &bytes, &data);
|
tsdbGetTableTagVal(pQInfo->tsdb, &item->id, pExprInfo->base.colInfo.colId, &type, &bytes, &data);
|
||||||
memcpy(output, data, bytes);
|
memcpy(output, data, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
qTrace("QInfo:%p create (tableId, tag) info completed, rows:%d", pQInfo, num);
|
qTrace("QInfo:%p create (tableId, tag) info completed, rows:%d", pQInfo, num);
|
||||||
} else { // return only the tags|table name etc.
|
} else { // return only the tags|table name etc.
|
||||||
for(int32_t i = 0; i < num; ++i) {
|
for(int32_t i = 0; i < num; ++i) {
|
||||||
SExprInfo* pExprInfo = pQuery->pSelectExpr;
|
SExprInfo* pExprInfo = pQuery->pSelectExpr;
|
||||||
SGroupItem* item = taosArrayGet(pa, i);
|
SGroupItem* item = taosArrayGet(pa, i);
|
||||||
|
|
||||||
char* data = NULL;
|
char* data = NULL;
|
||||||
for(int32_t j = 0; j < pQuery->numOfOutput; ++j) {
|
for(int32_t j = 0; j < pQuery->numOfOutput; ++j) {
|
||||||
// todo check the return value, refactor codes
|
// todo check the return value, refactor codes
|
||||||
|
@ -6059,7 +6066,7 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
|
||||||
pQInfo->tableIndex = pQInfo->groupInfo.numOfTables;
|
pQInfo->tableIndex = pQInfo->groupInfo.numOfTables;
|
||||||
qTrace("QInfo:%p create tag values results completed, rows:%d", pQInfo, num);
|
qTrace("QInfo:%p create tag values results completed, rows:%d", pQInfo, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
pQuery->rec.rows = num;
|
pQuery->rec.rows = num;
|
||||||
setQueryStatus(pQuery, QUERY_COMPLETED);
|
setQueryStatus(pQuery, QUERY_COMPLETED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ void vnodeInitReadFp(void) {
|
||||||
int32_t vnodeProcessRead(void *param, int msgType, void *pCont, int32_t contLen, SRspRet *ret) {
|
int32_t vnodeProcessRead(void *param, int msgType, void *pCont, int32_t contLen, SRspRet *ret) {
|
||||||
SVnodeObj *pVnode = (SVnodeObj *)param;
|
SVnodeObj *pVnode = (SVnodeObj *)param;
|
||||||
|
|
||||||
if (vnodeProcessReadMsgFp[msgType] == NULL)
|
if (vnodeProcessReadMsgFp[msgType] == NULL)
|
||||||
return TSDB_CODE_MSG_NOT_PROCESSED;
|
return TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
|
|
||||||
if (pVnode->status == TAOS_VN_STATUS_DELETING || pVnode->status == TAOS_VN_STATUS_CLOSING)
|
if (pVnode->status == TAOS_VN_STATUS_DELETING || pVnode->status == TAOS_VN_STATUS_CLOSING)
|
||||||
return TSDB_CODE_INVALID_VGROUP_ID;
|
return TSDB_CODE_INVALID_VGROUP_ID;
|
||||||
|
@ -53,26 +53,29 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t cont
|
||||||
memset(pRet, 0, sizeof(SRspRet));
|
memset(pRet, 0, sizeof(SRspRet));
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
qinfo_t pQInfo = NULL;
|
qinfo_t pQInfo = NULL;
|
||||||
if (contLen != 0) {
|
if (contLen != 0) {
|
||||||
pRet->code = qCreateQueryInfo(pVnode->tsdb, pVnode->vgId, pQueryTableMsg, &pQInfo);
|
pRet->code = qCreateQueryInfo(pVnode->tsdb, pVnode->vgId, pQueryTableMsg, &pQInfo);
|
||||||
|
|
||||||
SQueryTableRsp *pRsp = (SQueryTableRsp *) rpcMallocCont(sizeof(SQueryTableRsp));
|
SQueryTableRsp *pRsp = (SQueryTableRsp *) rpcMallocCont(sizeof(SQueryTableRsp));
|
||||||
pRsp->qhandle = htobe64((uint64_t) (pQInfo));
|
pRsp->qhandle = htobe64((uint64_t) (pQInfo));
|
||||||
pRsp->code = pRet->code;
|
pRsp->code = pRet->code;
|
||||||
|
|
||||||
pRet->len = sizeof(SQueryTableRsp);
|
pRet->len = sizeof(SQueryTableRsp);
|
||||||
pRet->rsp = pRsp;
|
pRet->rsp = pRsp;
|
||||||
|
|
||||||
vTrace("vgId:%d, QInfo:%p, dnode query msg disposed", pVnode->vgId, pQInfo);
|
vTrace("vgId:%d, QInfo:%p, dnode query msg disposed", pVnode->vgId, pQInfo);
|
||||||
} else {
|
} else {
|
||||||
|
assert(pCont != NULL);
|
||||||
pQInfo = pCont;
|
pQInfo = pCont;
|
||||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
qTableQuery(pQInfo); // do execute query
|
if (pQInfo != NULL) {
|
||||||
|
qTableQuery(pQInfo); // do execute query
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue