[td-98] extract the query.h, and add it into the global inc folder
This commit is contained in:
parent
33dbf05191
commit
13f1efd8ed
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef TDENGINE_QUERY_H
|
||||||
|
#define TDENGINE_QUERY_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
|
#include "hash.h"
|
||||||
|
#include "tsdb.h"
|
||||||
|
#include "qinterpolation.h"
|
||||||
|
#include "qresultBuf.h"
|
||||||
|
#include "qsqlparser.h"
|
||||||
|
#include "qtsbuf.h"
|
||||||
|
#include "taosdef.h"
|
||||||
|
#include "tref.h"
|
||||||
|
#include "tsqlfunction.h"
|
||||||
|
#include "tarray.h"
|
||||||
|
|
||||||
|
typedef void* qinfo_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create the qinfo object according to QueryTableMsg
|
||||||
|
* @param pVnode
|
||||||
|
* @param pQueryTableMsg
|
||||||
|
* @param pQInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int32_t qCreateQueryInfo(void* pVnode, SQueryTableMsg* pQueryTableMsg, qinfo_t* pQInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy QInfo object
|
||||||
|
*
|
||||||
|
* @param pQInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void qDestroyQueryInfo(qinfo_t pQInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the main query execution function, including query on both table and multitables,
|
||||||
|
* which are decided according to the tag or table name query conditions
|
||||||
|
*
|
||||||
|
* @param pQInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void qTableQuery(qinfo_t pQInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the produced results information, if current query is not paused or completed,
|
||||||
|
* this function will be blocked to wait for the query execution completed or paused,
|
||||||
|
* in which case enough results have been produced already.
|
||||||
|
*
|
||||||
|
* @param pQInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int32_t qRetrieveQueryResultInfo(qinfo_t pQInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Retrieve the actual results to fill the response message payload.
|
||||||
|
* Note that this function must be executed after qRetrieveQueryResultInfo is invoked.
|
||||||
|
*
|
||||||
|
* @param pQInfo qinfo object
|
||||||
|
* @param pRsp response message
|
||||||
|
* @param contLen payload length
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int32_t qDumpRetrieveResult(qinfo_t pQInfo, SRetrieveTableRsp** pRsp, int32_t* contLen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decide if more results will be produced or not
|
||||||
|
*
|
||||||
|
* @param pQInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool qHasMoreResultsToRetrieve(qinfo_t pQInfo);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // TDENGINE_QUERY_H
|
|
@ -109,8 +109,6 @@ typedef struct STableQueryInfo {
|
||||||
} STableQueryInfo;
|
} STableQueryInfo;
|
||||||
|
|
||||||
typedef struct STableDataInfo {
|
typedef struct STableDataInfo {
|
||||||
// int32_t numOfBlocks;
|
|
||||||
// int32_t start; // start block index
|
|
||||||
int32_t tableIndex;
|
int32_t tableIndex;
|
||||||
int32_t groupIdx; // group id in table list
|
int32_t groupIdx; // group id in table list
|
||||||
STableQueryInfo* pTableQInfo;
|
STableQueryInfo* pTableQInfo;
|
||||||
|
@ -188,50 +186,8 @@ typedef struct SQInfo {
|
||||||
*/
|
*/
|
||||||
int32_t tableIndex;
|
int32_t tableIndex;
|
||||||
int32_t numOfGroupResultPages;
|
int32_t numOfGroupResultPages;
|
||||||
// STableDataInfo* pTableDataInfo;
|
|
||||||
TSKEY* tsList;
|
TSKEY* tsList;
|
||||||
} SQInfo;
|
} SQInfo;
|
||||||
|
|
||||||
/**
|
|
||||||
* create the qinfo object before adding the query task to each tsdb query worker
|
|
||||||
*
|
|
||||||
* @param pReadMsg
|
|
||||||
* @param pQInfo
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int32_t qCreateQueryInfo(void* pVnode, SQueryTableMsg* pQueryTableMsg, SQInfo** pQInfo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* destroy the query info struct
|
|
||||||
* @param pQInfo
|
|
||||||
*/
|
|
||||||
void qDestroyQueryInfo(SQInfo* pQInfo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* query on single table
|
|
||||||
* @param pReadMsg
|
|
||||||
*/
|
|
||||||
void qTableQuery(SQInfo* pQInfo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* wait for the query completed, and retrieve final results to client
|
|
||||||
* @param pQInfo
|
|
||||||
*/
|
|
||||||
int32_t qRetrieveQueryResultInfo(SQInfo* pQInfo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param pQInfo
|
|
||||||
* @param pRsp
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int32_t qDumpRetrieveResult(SQInfo *pQInfo, SRetrieveTableRsp** pRsp, int32_t* contLen);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param pQInfo
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
bool qHasMoreResultsToRetrieve(SQInfo* pQInfo);
|
|
||||||
|
|
||||||
#endif // TDENGINE_QUERYEXECUTOR_H
|
#endif // TDENGINE_QUERYEXECUTOR_H
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include <tsdbMain.h>
|
#include "tsdbMain.h" //todo use TableId instead of STable object
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
@ -28,7 +28,6 @@
|
||||||
#include "qresultBuf.h"
|
#include "qresultBuf.h"
|
||||||
#include "queryExecutor.h"
|
#include "queryExecutor.h"
|
||||||
#include "queryUtil.h"
|
#include "queryUtil.h"
|
||||||
#include "tsdb.h"
|
|
||||||
|
|
||||||
#define DEFAULT_INTERN_BUF_SIZE 16384L
|
#define DEFAULT_INTERN_BUF_SIZE 16384L
|
||||||
|
|
||||||
|
@ -4754,14 +4753,6 @@ static void createTableDataInfo(SQInfo* pQInfo) {
|
||||||
SQuery* pQuery = pQInfo->runtimeEnv.pQuery;
|
SQuery* pQuery = pQInfo->runtimeEnv.pQuery;
|
||||||
|
|
||||||
// todo make sure the table are added the reference count to gauranteed that all involved tables are valid
|
// todo make sure the table are added the reference count to gauranteed that all involved tables are valid
|
||||||
// if (pQInfo->pTableDataInfo == NULL) {
|
|
||||||
// pQInfo->pTableDataInfo = (STableDataInfo *)calloc(1, sizeof(STableDataInfo) * pQInfo->groupInfo.numOfTables);
|
|
||||||
// if (pQInfo->pTableDataInfo == NULL) {
|
|
||||||
// dError("QInfo:%p failed to allocate memory, %s", pQInfo, strerror(errno));
|
|
||||||
// pQInfo->code = -TSDB_CODE_SERV_OUT_OF_MEMORY;
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
size_t numOfGroups = taosArrayGetSize(pQInfo->groupInfo.pGroupList);
|
size_t numOfGroups = taosArrayGetSize(pQInfo->groupInfo.pGroupList);
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
for (int32_t i = 0; i < numOfGroups; ++i) { // load all meter meta info
|
for (int32_t i = 0; i < numOfGroups; ++i) { // load all meter meta info
|
||||||
|
|
|
@ -20,10 +20,8 @@
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "tcompare.h"
|
#include "tcompare.h"
|
||||||
|
|
||||||
#include "../../../query/inc/qast.h"
|
#include "../../../query/inc/qast.h" // todo move to common module
|
||||||
#include "../../../query/inc/qextbuffer.h"
|
#include "../../../query/inc/tlosertree.h" // todo move to util module
|
||||||
#include "../../../query/inc/tlosertree.h"
|
|
||||||
#include "../../../query/inc/tsqlfunction.h"
|
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "tsdbMain.h"
|
#include "tsdbMain.h"
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "dataformat.h"
|
#include "dataformat.h"
|
||||||
#include "vnode.h"
|
#include "vnode.h"
|
||||||
#include "vnodeInt.h"
|
#include "vnodeInt.h"
|
||||||
#include "queryExecutor.h"
|
#include "query.h"
|
||||||
|
|
||||||
static int32_t (*vnodeProcessReadMsgFp[TSDB_MSG_TYPE_MAX])(SVnodeObj *, void *pCont, int32_t contLen, SRspRet *pRet);
|
static int32_t (*vnodeProcessReadMsgFp[TSDB_MSG_TYPE_MAX])(SVnodeObj *, void *pCont, int32_t contLen, SRspRet *pRet);
|
||||||
static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t contLen, SRspRet *pRet);
|
static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t contLen, SRspRet *pRet);
|
||||||
|
@ -54,7 +54,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t cont
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
SQInfo* pQInfo = NULL;
|
qinfo_t pQInfo = NULL;
|
||||||
if (contLen != 0) {
|
if (contLen != 0) {
|
||||||
void* tsdb = vnodeGetTsdb(pVnode);
|
void* tsdb = vnodeGetTsdb(pVnode);
|
||||||
pRet->code = qCreateQueryInfo(tsdb, pQueryTableMsg, &pQInfo);
|
pRet->code = qCreateQueryInfo(tsdb, pQueryTableMsg, &pQInfo);
|
||||||
|
|
Loading…
Reference in New Issue