Merge branch '3.0' into 3.0_udfd
This commit is contained in:
commit
2417c0088e
|
@ -179,7 +179,7 @@ typedef struct SQueryCostInfo {
|
||||||
uint32_t totalBlocks;
|
uint32_t totalBlocks;
|
||||||
uint32_t loadBlocks;
|
uint32_t loadBlocks;
|
||||||
uint32_t loadBlockStatis;
|
uint32_t loadBlockStatis;
|
||||||
uint32_t discardBlocks;
|
uint32_t skipBlocks;
|
||||||
uint64_t elapsedTime;
|
uint64_t elapsedTime;
|
||||||
uint64_t firstStageMergeTime;
|
uint64_t firstStageMergeTime;
|
||||||
uint64_t winInfoSize;
|
uint64_t winInfoSize;
|
||||||
|
|
|
@ -3144,7 +3144,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
|
||||||
if ((*status) == BLK_DATA_NO_NEEDED || (*status) == BLK_DATA_DISCARD) {
|
if ((*status) == BLK_DATA_NO_NEEDED || (*status) == BLK_DATA_DISCARD) {
|
||||||
qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
|
qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
|
||||||
pBlockInfo->window.ekey, pBlockInfo->rows);
|
pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
pCost->discardBlocks += 1;
|
pCost->skipBlocks += 1;
|
||||||
} else if ((*status) == BLK_DATA_STATIS_NEEDED) {
|
} else if ((*status) == BLK_DATA_STATIS_NEEDED) {
|
||||||
// this function never returns error?
|
// this function never returns error?
|
||||||
pCost->loadBlockStatis += 1;
|
pCost->loadBlockStatis += 1;
|
||||||
|
@ -3184,7 +3184,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
|
||||||
load = topbot_datablock_filter(&pTableScanInfo->pCtx[i], (char*)&(pBlock->pBlockStatis[i].min),
|
load = topbot_datablock_filter(&pTableScanInfo->pCtx[i], (char*)&(pBlock->pBlockStatis[i].min),
|
||||||
(char*)&(pBlock->pBlockStatis[i].max));
|
(char*)&(pBlock->pBlockStatis[i].max));
|
||||||
if (!load) { // current block has been discard due to filter applied
|
if (!load) { // current block has been discard due to filter applied
|
||||||
pCost->discardBlocks += 1;
|
pCost->skipBlocks += 1;
|
||||||
qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId,
|
qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId,
|
||||||
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
(*status) = BLK_DATA_DISCARD;
|
(*status) = BLK_DATA_DISCARD;
|
||||||
|
@ -3196,7 +3196,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
|
||||||
|
|
||||||
// current block has been discard due to filter applied
|
// current block has been discard due to filter applied
|
||||||
if (!doFilterByBlockStatistics(pRuntimeEnv, pBlock->pBlockStatis, pTableScanInfo->pCtx, pBlockInfo->rows)) {
|
if (!doFilterByBlockStatistics(pRuntimeEnv, pBlock->pBlockStatis, pTableScanInfo->pCtx, pBlockInfo->rows)) {
|
||||||
pCost->discardBlocks += 1;
|
pCost->skipBlocks += 1;
|
||||||
qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
|
qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
|
||||||
pBlockInfo->window.ekey, pBlockInfo->rows);
|
pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
(*status) = BLK_DATA_DISCARD;
|
(*status) = BLK_DATA_DISCARD;
|
||||||
|
|
|
@ -17,6 +17,7 @@ include(${TD_SUPPORT_DIR}/cmake.platform)
|
||||||
include(${TD_SUPPORT_DIR}/cmake.define)
|
include(${TD_SUPPORT_DIR}/cmake.define)
|
||||||
include(${TD_SUPPORT_DIR}/cmake.options)
|
include(${TD_SUPPORT_DIR}/cmake.options)
|
||||||
include(${TD_SUPPORT_DIR}/cmake.version)
|
include(${TD_SUPPORT_DIR}/cmake.version)
|
||||||
|
include(${TD_SUPPORT_DIR}/cmake.install)
|
||||||
|
|
||||||
# contrib
|
# contrib
|
||||||
add_subdirectory(contrib)
|
add_subdirectory(contrib)
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
IF (TD_LINUX)
|
||||||
|
SET(TD_MAKE_INSTALL_SH "${TD_SOURCE_DIR}/packaging/make_install.sh")
|
||||||
|
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
|
||||||
|
INSTALL(CODE "execute_process(COMMAND bash ${TD_MAKE_INSTALL_SH} ${TD_SOURCE_DIR} ${PROJECT_BINARY_DIR} Linux ${TD_VER_NUMBER})")
|
||||||
|
ELSEIF (TD_WINDOWS)
|
||||||
|
SET(CMAKE_INSTALL_PREFIX C:/TDengine)
|
||||||
|
|
||||||
|
INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/go DESTINATION connector)
|
||||||
|
INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/nodejs DESTINATION connector)
|
||||||
|
INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/python DESTINATION connector)
|
||||||
|
INSTALL(DIRECTORY ${TD_SOURCE_DIR}/src/connector/C\# DESTINATION connector)
|
||||||
|
INSTALL(DIRECTORY ${TD_SOURCE_DIR}/examples DESTINATION .)
|
||||||
|
INSTALL(FILES ${TD_SOURCE_DIR}/packaging/cfg/taos.cfg DESTINATION cfg)
|
||||||
|
INSTALL(FILES ${TD_SOURCE_DIR}/src/inc/taos.h DESTINATION include)
|
||||||
|
INSTALL(FILES ${TD_SOURCE_DIR}/src/inc/taoserror.h DESTINATION include)
|
||||||
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver)
|
||||||
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos_static.lib DESTINATION driver)
|
||||||
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver)
|
||||||
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.dll DESTINATION driver)
|
||||||
|
|
||||||
|
IF (TD_MVN_INSTALLED)
|
||||||
|
INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.38-dist.jar DESTINATION connector/jdbc)
|
||||||
|
ENDIF ()
|
||||||
|
ELSEIF (TD_DARWIN)
|
||||||
|
SET(TD_MAKE_INSTALL_SH "${TD_SOURCE_DIR}/packaging/tools/make_install.sh")
|
||||||
|
INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
|
||||||
|
INSTALL(CODE "execute_process(COMMAND bash ${TD_MAKE_INSTALL_SH} ${TD_SOURCE_DIR} ${PROJECT_BINARY_DIR} Darwin ${TD_VER_NUMBER})")
|
||||||
|
ENDIF ()
|
|
@ -18,15 +18,15 @@ target_sources(demoapi
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(tmq
|
target_link_libraries(tmq
|
||||||
taos
|
taos_static
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(tstream
|
target_link_libraries(tstream
|
||||||
taos
|
taos_static
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(demoapi
|
target_link_libraries(demoapi
|
||||||
taos
|
taos_static
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(tmq
|
target_include_directories(tmq
|
||||||
|
|
|
@ -222,8 +222,10 @@ static FORCE_INLINE int32_t tdSetBitmapValTypeI(void *pBitmap, int16_t colIdx, T
|
||||||
static FORCE_INLINE int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT valType);
|
static FORCE_INLINE int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT valType);
|
||||||
static FORCE_INLINE int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TDRowValT valType, int8_t bitmapMode);
|
static FORCE_INLINE int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TDRowValT valType, int8_t bitmapMode);
|
||||||
int32_t tdSetBitmapValTypeN(void *pBitmap, int16_t nEle, TDRowValT valType, int8_t bitmapMode);
|
int32_t tdSetBitmapValTypeN(void *pBitmap, int16_t nEle, TDRowValT valType, int8_t bitmapMode);
|
||||||
static FORCE_INLINE int32_t tdGetBitmapValTypeI(void *pBitmap, int16_t colIdx, TDRowValT *pValType);
|
static FORCE_INLINE int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pValType);
|
||||||
static FORCE_INLINE int32_t tdGetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT *pValType);
|
static FORCE_INLINE int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pValType);
|
||||||
|
static FORCE_INLINE int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValType, int8_t bitmapMode);
|
||||||
|
static FORCE_INLINE bool tdIsBitmapValTypeNormII(const void *pBitmap, int16_t idx);
|
||||||
int32_t tdAppendValToDataCol(SDataCol *pCol, TDRowValT valType, const void *val, int32_t numOfRows, int32_t maxPoints,
|
int32_t tdAppendValToDataCol(SDataCol *pCol, TDRowValT valType, const void *val, int32_t numOfRows, int32_t maxPoints,
|
||||||
int8_t bitmapMode);
|
int8_t bitmapMode);
|
||||||
static FORCE_INLINE int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val,
|
static FORCE_INLINE int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val,
|
||||||
|
@ -325,7 +327,16 @@ static FORCE_INLINE int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx,
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tdGetBitmapValType(void *pBitmap, int16_t colIdx, TDRowValT *pValType, int8_t bitmapMode) {
|
static FORCE_INLINE bool tdIsBitmapValTypeNormII(const void *pBitmap, int16_t idx) {
|
||||||
|
TDRowValT valType = 0;
|
||||||
|
tdGetBitmapValTypeII(pBitmap, idx, &valType);
|
||||||
|
if (tdValTypeIsNorm(valType)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValType, int8_t bitmapMode) {
|
||||||
switch (bitmapMode) {
|
switch (bitmapMode) {
|
||||||
case 0:
|
case 0:
|
||||||
tdGetBitmapValTypeII(pBitmap, colIdx, pValType);
|
tdGetBitmapValTypeII(pBitmap, colIdx, pValType);
|
||||||
|
@ -350,7 +361,7 @@ static FORCE_INLINE int32_t tdGetBitmapValType(void *pBitmap, int16_t colIdx, TD
|
||||||
* @param pValType
|
* @param pValType
|
||||||
* @return FORCE_INLINE
|
* @return FORCE_INLINE
|
||||||
*/
|
*/
|
||||||
static FORCE_INLINE int32_t tdGetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT *pValType) {
|
static FORCE_INLINE int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pValType) {
|
||||||
if (!pBitmap || colIdx < 0) {
|
if (!pBitmap || colIdx < 0) {
|
||||||
TASSERT(0);
|
TASSERT(0);
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
@ -449,7 +460,7 @@ static FORCE_INLINE int32_t tdSetBitmapValTypeI(void *pBitmap, int16_t colIdx, T
|
||||||
* @param pValType
|
* @param pValType
|
||||||
* @return FORCE_INLINE
|
* @return FORCE_INLINE
|
||||||
*/
|
*/
|
||||||
static FORCE_INLINE int32_t tdGetBitmapValTypeI(void *pBitmap, int16_t colIdx, TDRowValT *pValType) {
|
static FORCE_INLINE int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pValType) {
|
||||||
if (!pBitmap || colIdx < 0) {
|
if (!pBitmap || colIdx < 0) {
|
||||||
TASSERT(0);
|
TASSERT(0);
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
|
|
@ -195,45 +195,46 @@
|
||||||
#define TK_CAST 177
|
#define TK_CAST 177
|
||||||
#define TK_NOW 178
|
#define TK_NOW 178
|
||||||
#define TK_TODAY 179
|
#define TK_TODAY 179
|
||||||
#define TK_COUNT 180
|
#define TK_TIMEZONE 180
|
||||||
#define TK_FIRST 181
|
#define TK_COUNT 181
|
||||||
#define TK_LAST 182
|
#define TK_FIRST 182
|
||||||
#define TK_LAST_ROW 183
|
#define TK_LAST 183
|
||||||
#define TK_BETWEEN 184
|
#define TK_LAST_ROW 184
|
||||||
#define TK_IS 185
|
#define TK_BETWEEN 185
|
||||||
#define TK_NK_LT 186
|
#define TK_IS 186
|
||||||
#define TK_NK_GT 187
|
#define TK_NK_LT 187
|
||||||
#define TK_NK_LE 188
|
#define TK_NK_GT 188
|
||||||
#define TK_NK_GE 189
|
#define TK_NK_LE 189
|
||||||
#define TK_NK_NE 190
|
#define TK_NK_GE 190
|
||||||
#define TK_MATCH 191
|
#define TK_NK_NE 191
|
||||||
#define TK_NMATCH 192
|
#define TK_MATCH 192
|
||||||
#define TK_CONTAINS 193
|
#define TK_NMATCH 193
|
||||||
#define TK_JOIN 194
|
#define TK_CONTAINS 194
|
||||||
#define TK_INNER 195
|
#define TK_JOIN 195
|
||||||
#define TK_SELECT 196
|
#define TK_INNER 196
|
||||||
#define TK_DISTINCT 197
|
#define TK_SELECT 197
|
||||||
#define TK_WHERE 198
|
#define TK_DISTINCT 198
|
||||||
#define TK_PARTITION 199
|
#define TK_WHERE 199
|
||||||
#define TK_BY 200
|
#define TK_PARTITION 200
|
||||||
#define TK_SESSION 201
|
#define TK_BY 201
|
||||||
#define TK_STATE_WINDOW 202
|
#define TK_SESSION 202
|
||||||
#define TK_SLIDING 203
|
#define TK_STATE_WINDOW 203
|
||||||
#define TK_FILL 204
|
#define TK_SLIDING 204
|
||||||
#define TK_VALUE 205
|
#define TK_FILL 205
|
||||||
#define TK_NONE 206
|
#define TK_VALUE 206
|
||||||
#define TK_PREV 207
|
#define TK_NONE 207
|
||||||
#define TK_LINEAR 208
|
#define TK_PREV 208
|
||||||
#define TK_NEXT 209
|
#define TK_LINEAR 209
|
||||||
#define TK_GROUP 210
|
#define TK_NEXT 210
|
||||||
#define TK_HAVING 211
|
#define TK_GROUP 211
|
||||||
#define TK_ORDER 212
|
#define TK_HAVING 212
|
||||||
#define TK_SLIMIT 213
|
#define TK_ORDER 213
|
||||||
#define TK_SOFFSET 214
|
#define TK_SLIMIT 214
|
||||||
#define TK_LIMIT 215
|
#define TK_SOFFSET 215
|
||||||
#define TK_OFFSET 216
|
#define TK_LIMIT 216
|
||||||
#define TK_ASC 217
|
#define TK_OFFSET 217
|
||||||
#define TK_NULLS 218
|
#define TK_ASC 218
|
||||||
|
#define TK_NULLS 219
|
||||||
|
|
||||||
#define TK_NK_SPACE 300
|
#define TK_NK_SPACE 300
|
||||||
#define TK_NK_COMMENT 301
|
#define TK_NK_COMMENT 301
|
||||||
|
|
|
@ -248,7 +248,7 @@ typedef struct tDataTypeDescriptor {
|
||||||
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize);
|
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize);
|
||||||
int32_t (*decompFunc)(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output,
|
int32_t (*decompFunc)(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output,
|
||||||
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize);
|
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize);
|
||||||
void (*statisFunc)(const void *pData, int32_t numofrow, int64_t *min, int64_t *max, int64_t *sum, int16_t *minindex,
|
void (*statisFunc)(const void* pBitmap, const void *pData, int32_t numofrow, int64_t *min, int64_t *max, int64_t *sum, int16_t *minindex,
|
||||||
int16_t *maxindex, int16_t *numofnull);
|
int16_t *maxindex, int16_t *numofnull);
|
||||||
} tDataTypeDescriptor;
|
} tDataTypeDescriptor;
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,11 @@ typedef struct SScanLogicNode {
|
||||||
double ratio;
|
double ratio;
|
||||||
SNodeList* pDynamicScanFuncs;
|
SNodeList* pDynamicScanFuncs;
|
||||||
int32_t dataRequired;
|
int32_t dataRequired;
|
||||||
|
int64_t interval;
|
||||||
|
int64_t offset;
|
||||||
|
int64_t sliding;
|
||||||
|
int8_t intervalUnit;
|
||||||
|
int8_t slidingUnit;
|
||||||
} SScanLogicNode;
|
} SScanLogicNode;
|
||||||
|
|
||||||
typedef struct SJoinLogicNode {
|
typedef struct SJoinLogicNode {
|
||||||
|
@ -208,6 +213,11 @@ typedef struct STableScanPhysiNode {
|
||||||
double ratio;
|
double ratio;
|
||||||
int32_t dataRequired;
|
int32_t dataRequired;
|
||||||
SNodeList* pDynamicScanFuncs;
|
SNodeList* pDynamicScanFuncs;
|
||||||
|
int64_t interval;
|
||||||
|
int64_t offset;
|
||||||
|
int64_t sliding;
|
||||||
|
int8_t intervalUnit;
|
||||||
|
int8_t slidingUnit;
|
||||||
} STableScanPhysiNode;
|
} STableScanPhysiNode;
|
||||||
|
|
||||||
typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
typedef STableScanPhysiNode STableSeqScanPhysiNode;
|
||||||
|
@ -264,7 +274,6 @@ typedef struct SIntervalPhysiNode {
|
||||||
int64_t sliding;
|
int64_t sliding;
|
||||||
int8_t intervalUnit;
|
int8_t intervalUnit;
|
||||||
int8_t slidingUnit;
|
int8_t slidingUnit;
|
||||||
uint8_t precision;
|
|
||||||
SFillNode* pFill;
|
SFillNode* pFill;
|
||||||
} SIntervalPhysiNode;
|
} SIntervalPhysiNode;
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ typedef enum EColumnType {
|
||||||
typedef struct SColumnNode {
|
typedef struct SColumnNode {
|
||||||
SExprNode node; // QUERY_NODE_COLUMN
|
SExprNode node; // QUERY_NODE_COLUMN
|
||||||
uint64_t tableId;
|
uint64_t tableId;
|
||||||
|
int8_t tableType;
|
||||||
col_id_t colId;
|
col_id_t colId;
|
||||||
EColumnType colType; // column or tag
|
EColumnType colType; // column or tag
|
||||||
char dbName[TSDB_DB_NAME_LEN];
|
char dbName[TSDB_DB_NAME_LEN];
|
||||||
|
@ -196,8 +197,8 @@ typedef struct SStateWindowNode {
|
||||||
|
|
||||||
typedef struct SSessionWindowNode {
|
typedef struct SSessionWindowNode {
|
||||||
ENodeType type; // QUERY_NODE_SESSION_WINDOW
|
ENodeType type; // QUERY_NODE_SESSION_WINDOW
|
||||||
SNode* pCol; // timestamp primary key
|
SColumnNode* pCol; // timestamp primary key
|
||||||
SNode* pGap; // gap between two session window(in microseconds)
|
SValueNode* pGap; // gap between two session window(in microseconds)
|
||||||
} SSessionWindowNode;
|
} SSessionWindowNode;
|
||||||
|
|
||||||
typedef struct SIntervalWindowNode {
|
typedef struct SIntervalWindowNode {
|
||||||
|
|
|
@ -80,6 +80,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
|
||||||
int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
int32_t timezoneFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
|
||||||
bool getTimePseudoFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getTimePseudoFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
|
|
||||||
|
|
|
@ -579,7 +579,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_PAR_INVALID_PORT TAOS_DEF_ERROR_CODE(0, 0x2612)
|
#define TSDB_CODE_PAR_INVALID_PORT TAOS_DEF_ERROR_CODE(0, 0x2612)
|
||||||
#define TSDB_CODE_PAR_INVALID_ENDPOINT TAOS_DEF_ERROR_CODE(0, 0x2613)
|
#define TSDB_CODE_PAR_INVALID_ENDPOINT TAOS_DEF_ERROR_CODE(0, 0x2613)
|
||||||
#define TSDB_CODE_PAR_EXPRIE_STATEMENT TAOS_DEF_ERROR_CODE(0, 0x2614)
|
#define TSDB_CODE_PAR_EXPRIE_STATEMENT TAOS_DEF_ERROR_CODE(0, 0x2614)
|
||||||
#define TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2615)
|
#define TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2615)
|
||||||
#define TSDB_CODE_PAR_DB_NOT_SPECIFIED TAOS_DEF_ERROR_CODE(0, 0x2616)
|
#define TSDB_CODE_PAR_DB_NOT_SPECIFIED TAOS_DEF_ERROR_CODE(0, 0x2616)
|
||||||
#define TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME TAOS_DEF_ERROR_CODE(0, 0x2617)
|
#define TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME TAOS_DEF_ERROR_CODE(0, 0x2617)
|
||||||
#define TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR TAOS_DEF_ERROR_CODE(0, 0x2618)
|
#define TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR TAOS_DEF_ERROR_CODE(0, 0x2618)
|
||||||
|
@ -598,6 +598,17 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_PAR_INVALID_OPTION_UNIT TAOS_DEF_ERROR_CODE(0, 0x2625)
|
#define TSDB_CODE_PAR_INVALID_OPTION_UNIT TAOS_DEF_ERROR_CODE(0, 0x2625)
|
||||||
#define TSDB_CODE_PAR_INVALID_KEEP_UNIT TAOS_DEF_ERROR_CODE(0, 0x2626)
|
#define TSDB_CODE_PAR_INVALID_KEEP_UNIT TAOS_DEF_ERROR_CODE(0, 0x2626)
|
||||||
#define TSDB_CODE_PAR_AGG_FUNC_NESTING TAOS_DEF_ERROR_CODE(0, 0x2627)
|
#define TSDB_CODE_PAR_AGG_FUNC_NESTING TAOS_DEF_ERROR_CODE(0, 0x2627)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE TAOS_DEF_ERROR_CODE(0, 0x2628)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_STATE_WIN_COL TAOS_DEF_ERROR_CODE(0, 0x2629)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_STATE_WIN_TABLE TAOS_DEF_ERROR_CODE(0, 0x262A)
|
||||||
|
#define TSDB_CODE_PAR_INTER_SESSION_GAP TAOS_DEF_ERROR_CODE(0, 0x262B)
|
||||||
|
#define TSDB_CODE_PAR_INTER_SESSION_COL TAOS_DEF_ERROR_CODE(0, 0x262C)
|
||||||
|
#define TSDB_CODE_PAR_INTER_OFFSET_NEGATIVE TAOS_DEF_ERROR_CODE(0, 0x262D)
|
||||||
|
#define TSDB_CODE_PAR_INTER_OFFSET_UNIT TAOS_DEF_ERROR_CODE(0, 0x262E)
|
||||||
|
#define TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x262F)
|
||||||
|
#define TSDB_CODE_PAR_INTER_SLIDING_UNIT TAOS_DEF_ERROR_CODE(0, 0x2630)
|
||||||
|
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x2631)
|
||||||
|
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2632)
|
||||||
|
|
||||||
//planner
|
//planner
|
||||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||||
|
|
|
@ -0,0 +1,657 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# This file is used to install TAOS time-series database on linux systems. The operating system
|
||||||
|
# is required to use systemd to manage services at boot
|
||||||
|
|
||||||
|
set -e
|
||||||
|
#set -x
|
||||||
|
|
||||||
|
# -----------------------Variables definition
|
||||||
|
source_dir=$1
|
||||||
|
binary_dir=$2
|
||||||
|
osType=$3
|
||||||
|
verNumber=$4
|
||||||
|
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
script_dir=$(dirname $(readlink -f "$0"))
|
||||||
|
else
|
||||||
|
script_dir=${source_dir}/packaging/tools
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Dynamic directory
|
||||||
|
clientName="taos"
|
||||||
|
serverName="taosd"
|
||||||
|
logDir="/var/log/taos"
|
||||||
|
dataDir="/var/lib/taos"
|
||||||
|
configDir="/etc/taos"
|
||||||
|
configFile="taos.cfg"
|
||||||
|
installDir="/usr/local/taos"
|
||||||
|
productName="TDengine"
|
||||||
|
emailName="taosdata.com"
|
||||||
|
uninstallScript="rmtaos"
|
||||||
|
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
data_dir=${dataDir}
|
||||||
|
log_dir=${logDir}
|
||||||
|
|
||||||
|
cfg_install_dir=${configDir}
|
||||||
|
|
||||||
|
bin_link_dir="/usr/bin"
|
||||||
|
lib_link_dir="/usr/lib"
|
||||||
|
lib64_link_dir="/usr/lib64"
|
||||||
|
inc_link_dir="/usr/include"
|
||||||
|
|
||||||
|
install_main_dir=${installDir}
|
||||||
|
|
||||||
|
bin_dir="${installDir}/bin"
|
||||||
|
else
|
||||||
|
data_dir="/usr/local${dataDir}"
|
||||||
|
log_dir="/usr/local${logDir}"
|
||||||
|
|
||||||
|
cfg_install_dir="/usr/local${configDir}"
|
||||||
|
|
||||||
|
bin_link_dir="/usr/local/bin"
|
||||||
|
lib_link_dir="/usr/local/lib"
|
||||||
|
inc_link_dir="/usr/local/include"
|
||||||
|
|
||||||
|
install_main_dir="/usr/local/Cellar/tdengine/${verNumber}"
|
||||||
|
install_main_2_dir="/usr/local/Cellar/tdengine@${verNumber}/${verNumber}"
|
||||||
|
|
||||||
|
bin_dir="/usr/local/Cellar/tdengine/${verNumber}/bin"
|
||||||
|
bin_2_dir="/usr/local/Cellar/tdengine@${verNumber}/${verNumber}/bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
service_config_dir="/etc/systemd/system"
|
||||||
|
|
||||||
|
# Color setting
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[1;32m'
|
||||||
|
GREEN_DARK='\033[0;32m'
|
||||||
|
GREEN_UNDERLINE='\033[4;32m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
csudo=""
|
||||||
|
|
||||||
|
service_mod=2
|
||||||
|
os_type=0
|
||||||
|
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
if command -v sudo >/dev/null; then
|
||||||
|
csudo="sudo "
|
||||||
|
fi
|
||||||
|
initd_mod=0
|
||||||
|
if pidof systemd &>/dev/null; then
|
||||||
|
service_mod=0
|
||||||
|
elif $(which service &>/dev/null); then
|
||||||
|
service_mod=1
|
||||||
|
service_config_dir="/etc/init.d"
|
||||||
|
if $(which chkconfig &>/dev/null); then
|
||||||
|
initd_mod=1
|
||||||
|
elif $(which insserv &>/dev/null); then
|
||||||
|
initd_mod=2
|
||||||
|
elif $(which update-rc.d &>/dev/null); then
|
||||||
|
initd_mod=3
|
||||||
|
else
|
||||||
|
service_mod=2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
service_mod=2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get the operating system type for using the corresponding init file
|
||||||
|
# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification
|
||||||
|
#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
||||||
|
osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2)
|
||||||
|
#echo "osinfo: ${osinfo}"
|
||||||
|
if echo $osinfo | grep -qwi "ubuntu"; then
|
||||||
|
echo "this is ubuntu system"
|
||||||
|
os_type=1
|
||||||
|
elif echo $osinfo | grep -qwi "debian"; then
|
||||||
|
echo "this is debian system"
|
||||||
|
os_type=1
|
||||||
|
elif echo $osinfo | grep -qwi "Kylin"; then
|
||||||
|
echo "this is Kylin system"
|
||||||
|
os_type=1
|
||||||
|
elif echo $osinfo | grep -qwi "centos"; then
|
||||||
|
echo "this is centos system"
|
||||||
|
os_type=2
|
||||||
|
elif echo $osinfo | grep -qwi "fedora"; then
|
||||||
|
echo "this is fedora system"
|
||||||
|
os_type=2
|
||||||
|
else
|
||||||
|
echo "${osinfo}: This is an officially unverified linux system, If there are any problems with the installation and operation, "
|
||||||
|
echo "please feel free to contact ${emailName} for support."
|
||||||
|
os_type=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
function kill_taosadapter() {
|
||||||
|
pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}')
|
||||||
|
if [ -n "$pid" ]; then
|
||||||
|
${csudo}kill -9 $pid || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function kill_taosd() {
|
||||||
|
ps -ef | grep ${serverName}
|
||||||
|
pid=$(ps -ef | grep -w ${serverName} | grep -v "grep" | awk '{print $2}')
|
||||||
|
if [ -n "$pid" ]; then
|
||||||
|
${csudo}kill -9 $pid || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_main_path() {
|
||||||
|
#create install main dir and all sub dir
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
${csudo}rm -rf ${install_main_dir} || :
|
||||||
|
${csudo}mkdir -p ${install_main_dir}
|
||||||
|
${csudo}mkdir -p ${install_main_dir}/cfg
|
||||||
|
${csudo}mkdir -p ${install_main_dir}/bin
|
||||||
|
# ${csudo}mkdir -p ${install_main_dir}/connector
|
||||||
|
${csudo}mkdir -p ${install_main_dir}/driver
|
||||||
|
${csudo}mkdir -p ${install_main_dir}/examples
|
||||||
|
${csudo}mkdir -p ${install_main_dir}/include
|
||||||
|
# ${csudo}mkdir -p ${install_main_dir}/init.d
|
||||||
|
else
|
||||||
|
${csudo}rm -rf ${install_main_dir} || ${csudo}rm -rf ${install_main_2_dir} || :
|
||||||
|
${csudo}mkdir -p ${install_main_dir} || ${csudo}mkdir -p ${install_main_2_dir}
|
||||||
|
${csudo}mkdir -p ${install_main_dir}/cfg || ${csudo}mkdir -p ${install_main_2_dir}/cfg
|
||||||
|
${csudo}mkdir -p ${install_main_dir}/bin || ${csudo}mkdir -p ${install_main_2_dir}/bin
|
||||||
|
# ${csudo}mkdir -p ${install_main_dir}/connector || ${csudo}mkdir -p ${install_main_2_dir}/connector
|
||||||
|
${csudo}mkdir -p ${install_main_dir}/driver || ${csudo}mkdir -p ${install_main_2_dir}/driver
|
||||||
|
${csudo}mkdir -p ${install_main_dir}/examples || ${csudo}mkdir -p ${install_main_2_dir}/examples
|
||||||
|
${csudo}mkdir -p ${install_main_dir}/include || ${csudo}mkdir -p ${install_main_2_dir}/include
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_bin() {
|
||||||
|
# Remove links
|
||||||
|
${csudo}rm -f ${bin_link_dir}/${clientName} || :
|
||||||
|
${csudo}rm -f ${bin_link_dir}/${serverName} || :
|
||||||
|
${csudo}rm -f ${bin_link_dir}/taosadapter || :
|
||||||
|
${csudo}rm -f ${bin_link_dir}/taosdemo || :
|
||||||
|
${csudo}rm -f ${bin_link_dir}/taosdump || :
|
||||||
|
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
${csudo}rm -f ${bin_link_dir}/perfMonitor || :
|
||||||
|
${csudo}rm -f ${bin_link_dir}/set_core || :
|
||||||
|
${csudo}rm -f ${bin_link_dir}/run_taosd_and_taosadapter.sh || :
|
||||||
|
${csudo}rm -f ${bin_link_dir}/${uninstallScript} || :
|
||||||
|
|
||||||
|
${csudo}cp -r ${binary_dir}/build/bin/${clientName} ${install_main_dir}/bin || :
|
||||||
|
[ -f ${binary_dir}/build/bin/taosBenchmark ] && ${csudo}cp -r ${binary_dir}/build/bin/taosBenchmark ${install_main_dir}/bin || :
|
||||||
|
[ -f ${install_main_dir}/bin/taosBenchmark ] && ${csudo}ln -sf ${install_main_dir}/bin/taosBenchmark ${install_main_dir}/bin/taosdemo || :
|
||||||
|
[ -f ${binary_dir}/build/bin/taosdump ] && ${csudo}cp -r ${binary_dir}/build/bin/taosdump ${install_main_dir}/bin || :
|
||||||
|
[ -f ${binary_dir}/build/bin/taosadapter ] && ${csudo}cp -r ${binary_dir}/build/bin/taosadapter ${install_main_dir}/bin || :
|
||||||
|
${csudo}cp -r ${binary_dir}/build/bin/${serverName} ${install_main_dir}/bin || :
|
||||||
|
${csudo}cp -r ${binary_dir}/build/bin/tarbitrator ${install_main_dir}/bin || :
|
||||||
|
|
||||||
|
${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin || :
|
||||||
|
${csudo}cp -r ${script_dir}/remove.sh ${install_main_dir}/bin || :
|
||||||
|
${csudo}cp -r ${script_dir}/set_core.sh ${install_main_dir}/bin || :
|
||||||
|
${csudo}cp -r ${script_dir}/run_taosd_and_taosadapter.sh ${install_main_dir}/bin || :
|
||||||
|
${csudo}cp -r ${script_dir}/startPre.sh ${install_main_dir}/bin || :
|
||||||
|
|
||||||
|
${csudo}chmod 0555 ${install_main_dir}/bin/*
|
||||||
|
#Make link
|
||||||
|
[ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || :
|
||||||
|
[ -x ${install_main_dir}/bin/${serverName} ] && ${csudo}ln -s ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || :
|
||||||
|
[ -x ${install_main_dir}/bin/taosadapter ] && ${csudo}ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || :
|
||||||
|
[ -x ${install_main_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
|
||||||
|
[ -x ${install_main_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || :
|
||||||
|
[ -x ${install_main_dir}/bin/perfMonitor ] && ${csudo}ln -s ${install_main_dir}/bin/perfMonitor ${bin_link_dir}/perfMonitor || :
|
||||||
|
[ -x ${install_main_dir}/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || :
|
||||||
|
[ -x ${install_main_dir}/run_taosd_and_taosadapter.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_taosd_and_taosadapter.sh ${bin_link_dir}/run_taosd_and_taosadapter.sh || :
|
||||||
|
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || :
|
||||||
|
else
|
||||||
|
|
||||||
|
${csudo}cp -r ${binary_dir}/build/bin/* ${install_main_dir}/bin || ${csudo}cp -r ${binary_dir}/build/bin/* ${install_main_2_dir}/bin || :
|
||||||
|
${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin || ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_2_dir} || :
|
||||||
|
${csudo}cp -r ${script_dir}/remove_client.sh ${install_main_dir}/bin || ${csudo}cp -r ${script_dir}/remove_client.sh ${install_main_2_dir}/bin || :
|
||||||
|
${csudo}chmod 0555 ${install_main_dir}/bin/* || ${csudo}chmod 0555 ${install_main_2_dir}/bin/*
|
||||||
|
#Make link
|
||||||
|
[ -x ${install_main_dir}/bin/${clientName} ] || [ -x ${install_main_2_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || ${csudo}ln -s ${install_main_2_dir}/bin/${clientName} || :
|
||||||
|
[ -x ${install_main_dir}/bin/${serverName} ] || [ -x ${install_main_2_dir}/bin/${serverName} ] && ${csudo}ln -s ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || ${csudo}ln -s ${install_main_2_dir}/bin/${serverName} || :
|
||||||
|
[ -x ${install_main_dir}/bin/taosadapter ] || [ -x ${install_main_2_dir}/bin/taosadapter ] && ${csudo}ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || ${csudo}ln -s ${install_main_2_dir}/bin/taosadapter || :
|
||||||
|
[ -x ${install_main_dir}/bin/taosdump ] || [ -x ${install_main_2_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || ln -s ${install_main_2_dir}/bin/taosdump ${bin_link_dir}/taosdump || :
|
||||||
|
[ -x ${install_main_dir}/bin/taosdemo ] || [ -x ${install_main_2_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || ln -s ${install_main_2_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_jemalloc() {
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
/usr/bin/install -c -d /usr/local/bin
|
||||||
|
|
||||||
|
if [ -f "${binary_dir}/build/bin/jemalloc-config" ]; then
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc-config /usr/local/bin
|
||||||
|
fi
|
||||||
|
if [ -f "${binary_dir}/build/bin/jemalloc.sh" ]; then
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/bin/jemalloc.sh /usr/local/bin
|
||||||
|
fi
|
||||||
|
if [ -f "${binary_dir}/build/bin/jeprof" ]; then
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/bin/jeprof /usr/local/bin
|
||||||
|
fi
|
||||||
|
if [ -f "${binary_dir}/build/include/jemalloc/jemalloc.h" ]; then
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc
|
||||||
|
${csudo}/usr/bin/install -c -m 644 ${binary_dir}/build/include/jemalloc/jemalloc.h \
|
||||||
|
/usr/local/include/jemalloc
|
||||||
|
fi
|
||||||
|
if [ -f "${binary_dir}/build/lib/libjemalloc.so.2" ]; then
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/lib
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.so.2 /usr/local/lib
|
||||||
|
${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/lib
|
||||||
|
[ -f ${binary_dir}/build/lib/libjemalloc.a ] &&
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc.a /usr/local/lib
|
||||||
|
[ -f ${binary_dir}/build/lib/libjemalloc_pic.a ] &&
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/lib/libjemalloc_pic.a /usr/local/lib
|
||||||
|
if [ -f "${binary_dir}/build/lib/pkgconfig/jemalloc.pc" ]; then
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig
|
||||||
|
${csudo}/usr/bin/install -c -m 644 ${binary_dir}/build/lib/pkgconfig/jemalloc.pc \
|
||||||
|
/usr/local/lib/pkgconfig
|
||||||
|
fi
|
||||||
|
if [ -d /etc/ld.so.conf.d ]; then
|
||||||
|
echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf >/dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf"
|
||||||
|
${csudo}ldconfig
|
||||||
|
else
|
||||||
|
echo "/etc/ld.so.conf.d not found!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -f "${binary_dir}/build/share/doc/jemalloc/jemalloc.html" ]; then
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc
|
||||||
|
${csudo}/usr/bin/install -c -m 644 ${binary_dir}/build/share/doc/jemalloc/jemalloc.html \
|
||||||
|
/usr/local/share/doc/jemalloc
|
||||||
|
fi
|
||||||
|
if [ -f "${binary_dir}/build/share/man/man3/jemalloc.3" ]; then
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/share/man/man3
|
||||||
|
${csudo}/usr/bin/install -c -m 644 ${binary_dir}/build/share/man/man3/jemalloc.3 \
|
||||||
|
/usr/local/share/man/man3
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_avro() {
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
if [ -f "${binary_dir}/build/$1/libavro.so.23.0.0" ] && [ -d /usr/local/$1 ]; then
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/$1
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/$1/libavro.so.23.0.0 /usr/local/$1
|
||||||
|
${csudo}ln -sf libavro.so.23.0.0 /usr/local/$1/libavro.so.23
|
||||||
|
${csudo}ln -sf libavro.so.23 /usr/local/$1/libavro.so
|
||||||
|
${csudo}/usr/bin/install -c -d /usr/local/$1
|
||||||
|
[ -f ${binary_dir}/build/$1/libavro.a ] &&
|
||||||
|
${csudo}/usr/bin/install -c -m 755 ${binary_dir}/build/$1/libavro.a /usr/local/$1
|
||||||
|
|
||||||
|
if [ -d /etc/ld.so.conf.d ]; then
|
||||||
|
echo "/usr/local/$1" | ${csudo}tee /etc/ld.so.conf.d/libavro.conf >/dev/null || echo -e "failed to write /etc/ld.so.conf.d/libavro.conf"
|
||||||
|
${csudo}ldconfig
|
||||||
|
else
|
||||||
|
echo "/etc/ld.so.conf.d not found!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_lib() {
|
||||||
|
# Remove links
|
||||||
|
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
${csudo}cp ${binary_dir}/build/lib/libtaos.so.${verNumber} \
|
||||||
|
${install_main_dir}/driver &&
|
||||||
|
${csudo}chmod 777 ${install_main_dir}/driver/*
|
||||||
|
|
||||||
|
${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1
|
||||||
|
${csudo}ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so
|
||||||
|
|
||||||
|
if [ -d "${lib64_link_dir}" ]; then
|
||||||
|
${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1
|
||||||
|
${csudo}ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
${csudo}cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \
|
||||||
|
${install_main_dir}/driver ||
|
||||||
|
${csudo}cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \
|
||||||
|
${install_main_2_dir}/driver &&
|
||||||
|
${csudo}chmod 777 ${install_main_dir}/driver/* ||
|
||||||
|
${csudo}chmod 777 ${install_main_2_dir}/driver/*
|
||||||
|
|
||||||
|
${csudo}ln -sf ${install_main_dir}/driver/libtaos.* \
|
||||||
|
${install_main_dir}/driver/libtaos.1.dylib ||
|
||||||
|
${csudo}ln -sf ${install_main_2_dir}/driver/libtaos.* \
|
||||||
|
${install_main_2_dir}/driver/libtaos.1.dylib || :
|
||||||
|
|
||||||
|
${csudo}ln -sf ${install_main_dir}/driver/libtaos.1.dylib \
|
||||||
|
${install_main_dir}/driver/libtaos.dylib ||
|
||||||
|
${csudo}ln -sf ${install_main_2_dir}/driver/libtaos.1.dylib \
|
||||||
|
${install_main_2_dir}/driver/libtaos.dylib || :
|
||||||
|
|
||||||
|
${csudo}ln -sf ${install_main_dir}/driver/libtaos.${verNumber}.dylib \
|
||||||
|
${lib_link_dir}/libtaos.1.dylib ||
|
||||||
|
${csudo}ln -sf ${install_main_2_dir}/driver/libtaos.${verNumber}.dylib \
|
||||||
|
${lib_link_dir}/libtaos.1.dylib || :
|
||||||
|
|
||||||
|
${csudo}ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib || :
|
||||||
|
fi
|
||||||
|
|
||||||
|
install_jemalloc
|
||||||
|
install_avro lib
|
||||||
|
install_avro lib64
|
||||||
|
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
${csudo}ldconfig
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_header() {
|
||||||
|
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h || :
|
||||||
|
${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h \
|
||||||
|
${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/*
|
||||||
|
${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h
|
||||||
|
${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h
|
||||||
|
${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h
|
||||||
|
else
|
||||||
|
${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h \
|
||||||
|
${install_main_dir}/include ||
|
||||||
|
${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h \
|
||||||
|
${install_main_2_dir}/include &&
|
||||||
|
${csudo}chmod 644 ${install_main_dir}/include/* ||
|
||||||
|
${csudo}chmod 644 ${install_main_2_dir}/include/*
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_config() {
|
||||||
|
if [ ! -f ${cfg_install_dir}/${configFile} ]; then
|
||||||
|
${csudo}mkdir -p ${cfg_install_dir}
|
||||||
|
[ -f ${script_dir}/../cfg/${configFile} ] &&
|
||||||
|
${csudo}cp ${script_dir}/../cfg/${configFile} ${cfg_install_dir} || :
|
||||||
|
${csudo}chmod 644 ${cfg_install_dir}/${configFile}
|
||||||
|
${csudo}cp -f ${script_dir}/../cfg/${configFile} \
|
||||||
|
${cfg_install_dir}/${configFile}.${verNumber} || :
|
||||||
|
${csudo}ln -s ${cfg_install_dir}/${configFile} \
|
||||||
|
${install_main_dir}/cfg/${configFile}
|
||||||
|
else
|
||||||
|
${csudo}cp -f ${script_dir}/../cfg/${configFile} \
|
||||||
|
${cfg_install_dir}/${configFile}.${verNumber} || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_taosadapter_config() {
|
||||||
|
if [ ! -f "${cfg_install_dir}/taosadapter.toml" ]; then
|
||||||
|
${csudo}mkdir -p ${cfg_install_dir} || :
|
||||||
|
[ -f ${binary_dir}/test/cfg/taosadapter.toml ] &&
|
||||||
|
${csudo}cp ${binary_dir}/test/cfg/taosadapter.toml ${cfg_install_dir} || :
|
||||||
|
[ -f ${cfg_install_dir}/taosadapter.toml ] &&
|
||||||
|
${csudo}chmod 644 ${cfg_install_dir}/taosadapter.toml || :
|
||||||
|
[ -f ${binary_dir}/test/cfg/taosadapter.toml ] &&
|
||||||
|
${csudo}cp -f ${binary_dir}/test/cfg/taosadapter.toml \
|
||||||
|
${cfg_install_dir}/taosadapter.toml.${verNumber} || :
|
||||||
|
[ -f ${cfg_install_dir}/taosadapter.toml ] &&
|
||||||
|
${csudo}ln -s ${cfg_install_dir}/taosadapter.toml \
|
||||||
|
${install_main_dir}/cfg/taosadapter.toml || :
|
||||||
|
else
|
||||||
|
if [ -f "${binary_dir}/test/cfg/taosadapter.toml" ]; then
|
||||||
|
${csudo}cp -f ${binary_dir}/test/cfg/taosadapter.toml \
|
||||||
|
${cfg_install_dir}/taosadapter.toml.${verNumber} || :
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_log() {
|
||||||
|
${csudo}rm -rf ${log_dir} || :
|
||||||
|
${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir}
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
${csudo}ln -s ${log_dir} ${install_main_dir}/log
|
||||||
|
else
|
||||||
|
${csudo}ln -s ${log_dir} ${install_main_dir}/log || ${csudo}ln -s ${log_dir} ${install_main_2_dir}/log
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_data() {
|
||||||
|
${csudo}mkdir -p ${data_dir}
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
${csudo}ln -s ${data_dir} ${install_main_dir}/data
|
||||||
|
else
|
||||||
|
${csudo}ln -s ${data_dir} ${install_main_dir}/data || ${csudo}ln -s ${data_dir} ${install_main_2_dir}/data
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_connector() {
|
||||||
|
if find ${source_dir}/src/connector/go -mindepth 1 -maxdepth 1 | read; then
|
||||||
|
${csudo}cp -r ${source_dir}/src/connector/go ${install_main_dir}/connector || :
|
||||||
|
else
|
||||||
|
echo "WARNING: go connector not found, please check if want to use it!"
|
||||||
|
fi
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
${csudo}cp -rf ${source_dir}/src/connector/python ${install_main_dir}/connector || :
|
||||||
|
${csudo}cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &>/dev/null && ${csudo}chmod 777 ${install_main_dir}/connector/*.jar || echo &>/dev/null || :
|
||||||
|
else
|
||||||
|
${csudo}cp -rf ${source_dir}/src/connector/python ${install_main_dir}/connector || ${csudo}cp -rf ${source_dir}/src/connector/python ${install_main_2_dir}/connector || :
|
||||||
|
${csudo}cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &>/dev/null && ${csudo}chmod 777 ${install_main_dir}/connector/*.jar || echo &>/dev/null || :
|
||||||
|
${csudo}cp ${binary_dir}/build/lib/*.jar ${install_main_2_dir}/connector &>/dev/null && ${csudo}chmod 777 ${install_main_2_dir}/connector/*.jar || echo &>/dev/null || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_examples() {
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
${csudo}cp -rf ${source_dir}/examples/* ${install_main_dir}/examples || :
|
||||||
|
else
|
||||||
|
${csudo}cp -rf ${source_dir}/examples/* ${install_main_dir}/examples || ${csudo}cp -rf ${source_dir}/examples/* ${install_main_2_dir}/examples || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function clean_service_on_sysvinit() {
|
||||||
|
if pidof ${serverName} &>/dev/null; then
|
||||||
|
${csudo}service ${serverName} stop || :
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ((${initd_mod} == 1)); then
|
||||||
|
${csudo}chkconfig --del ${serverName} || :
|
||||||
|
elif ((${initd_mod} == 2)); then
|
||||||
|
${csudo}insserv -r ${serverName} || :
|
||||||
|
elif ((${initd_mod} == 3)); then
|
||||||
|
${csudo}update-rc.d -f ${serverName} remove || :
|
||||||
|
fi
|
||||||
|
|
||||||
|
${csudo}rm -f ${service_config_dir}/${serverName} || :
|
||||||
|
|
||||||
|
if $(which init &>/dev/null); then
|
||||||
|
${csudo}init q || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_service_on_sysvinit() {
|
||||||
|
clean_service_on_sysvinit
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
if ((${os_type} == 1)); then
|
||||||
|
# ${csudo}cp -f ${script_dir}/../deb/${serverName} ${install_main_dir}/init.d
|
||||||
|
${csudo}cp ${script_dir}/../deb/${serverName} ${service_config_dir} && ${csudo}chmod a+x ${service_config_dir}/${serverName} || :
|
||||||
|
elif ((${os_type} == 2)); then
|
||||||
|
# ${csudo}cp -f ${script_dir}/../rpm/${serverName} ${install_main_dir}/init.d
|
||||||
|
${csudo}cp ${script_dir}/../rpm/${serverName} ${service_config_dir} && ${csudo}chmod a+x ${service_config_dir}/${serverName} || :
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ((${initd_mod} == 1)); then
|
||||||
|
${csudo}chkconfig --add ${serverName} || :
|
||||||
|
${csudo}chkconfig --level 2345 ${serverName} on || :
|
||||||
|
elif ((${initd_mod} == 2)); then
|
||||||
|
${csudo}insserv ${serverName} || :
|
||||||
|
${csudo}insserv -d ${serverName} || :
|
||||||
|
elif ((${initd_mod} == 3)); then
|
||||||
|
${csudo}update-rc.d ${serverName} defaults || :
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function clean_service_on_systemd() {
|
||||||
|
taosd_service_config="${service_config_dir}/${serverName}.service"
|
||||||
|
|
||||||
|
if systemctl is-active --quiet ${serverName}; then
|
||||||
|
echo "${productName} is running, stopping it..."
|
||||||
|
${csudo}systemctl stop ${serverName} &>/dev/null || echo &>/dev/null
|
||||||
|
fi
|
||||||
|
${csudo}systemctl disable ${serverName} &>/dev/null || echo &>/dev/null
|
||||||
|
|
||||||
|
${csudo}rm -f ${taosd_service_config}
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_service_on_systemd() {
|
||||||
|
clean_service_on_systemd
|
||||||
|
|
||||||
|
taosd_service_config="${service_config_dir}/${serverName}.service"
|
||||||
|
|
||||||
|
${csudo}bash -c "echo '[Unit]' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'Description=${productName} server service' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'After=network-online.target' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'Wants=network-online.target' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo '[Service]' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'Type=simple' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'ExecStart=/usr/bin/${serverName}' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'ExecStartPre=${installDir}/bin/startPre.sh' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'LimitCORE=infinity' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'StandardOutput=null' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'Restart=always' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'StartLimitBurst=3' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo '[Install]' >> ${taosd_service_config}"
|
||||||
|
${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}"
|
||||||
|
${csudo}systemctl enable ${serverName}
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_taosadapter_service() {
|
||||||
|
if ((${service_mod} == 0)); then
|
||||||
|
[ -f ${binary_dir}/test/cfg/taosadapter.service ] &&
|
||||||
|
${csudo}cp ${binary_dir}/test/cfg/taosadapter.service \
|
||||||
|
${service_config_dir}/ || :
|
||||||
|
${csudo}systemctl daemon-reload
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_service() {
|
||||||
|
if ((${service_mod} == 0)); then
|
||||||
|
install_service_on_systemd
|
||||||
|
elif ((${service_mod} == 1)); then
|
||||||
|
install_service_on_sysvinit
|
||||||
|
else
|
||||||
|
kill_taosd
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_TDengine() {
|
||||||
|
echo -e "${GREEN}Start to update ${productName}...${NC}"
|
||||||
|
# Stop the service if running
|
||||||
|
|
||||||
|
if pidof ${serverName} &>/dev/null; then
|
||||||
|
if ((${service_mod} == 0)); then
|
||||||
|
${csudo}systemctl stop ${serverName} || :
|
||||||
|
elif ((${service_mod} == 1)); then
|
||||||
|
${csudo}service ${serverName} stop || :
|
||||||
|
else
|
||||||
|
kill_taosadapter
|
||||||
|
kill_taosd
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
install_main_path
|
||||||
|
|
||||||
|
install_log
|
||||||
|
install_header
|
||||||
|
install_lib
|
||||||
|
# install_connector
|
||||||
|
install_examples
|
||||||
|
install_bin
|
||||||
|
|
||||||
|
install_service
|
||||||
|
install_taosadapter_service
|
||||||
|
|
||||||
|
install_config
|
||||||
|
install_taosadapter_config
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo -e "\033[44;32;1m${productName} is updated successfully!${NC}"
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${configDir}/${configFile}"
|
||||||
|
echo -e "${GREEN_DARK}To configure Taos Adapter (if has) ${NC}: edit ${configDir}/taosadapter.toml"
|
||||||
|
if ((${service_mod} == 0)); then
|
||||||
|
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}"
|
||||||
|
elif ((${service_mod} == 1)); then
|
||||||
|
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${GREEN_DARK}To start Taos Adapter (if has)${NC}: taosadapter &${NC}"
|
||||||
|
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName}${NC} in shell${NC}"
|
||||||
|
echo
|
||||||
|
echo -e "\033[44;32;1m${productName} is updated successfully!${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_TDengine() {
|
||||||
|
# Start to install
|
||||||
|
echo -e "${GREEN}Start to install ${productName}...${NC}"
|
||||||
|
|
||||||
|
install_main_path
|
||||||
|
|
||||||
|
install_data
|
||||||
|
install_log
|
||||||
|
install_header
|
||||||
|
install_lib
|
||||||
|
# install_connector
|
||||||
|
install_examples
|
||||||
|
install_bin
|
||||||
|
|
||||||
|
install_service
|
||||||
|
install_taosadapter_service
|
||||||
|
|
||||||
|
install_config
|
||||||
|
install_taosadapter_config
|
||||||
|
|
||||||
|
# Ask if to start the service
|
||||||
|
echo
|
||||||
|
echo -e "\033[44;32;1m${productName} is installed successfully!${NC}"
|
||||||
|
echo
|
||||||
|
echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${configDir}/${configFile}"
|
||||||
|
echo -e "${GREEN_DARK}To configure taosadapter (if has) ${NC}: edit ${configDir}/taosadapter.toml"
|
||||||
|
if ((${service_mod} == 0)); then
|
||||||
|
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}"
|
||||||
|
elif ((${service_mod} == 1)); then
|
||||||
|
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${GREEN_DARK}To start Taos Adapter (if has)${NC}: taosadapter &${NC}"
|
||||||
|
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ./${serverName}${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName}${NC} in shell${NC}"
|
||||||
|
echo
|
||||||
|
echo -e "\033[44;32;1m${productName} is installed successfully!${NC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
## ==============================Main program starts from here============================
|
||||||
|
echo source directory: $1
|
||||||
|
echo binary directory: $2
|
||||||
|
if [ "$osType" != "Darwin" ]; then
|
||||||
|
if [ -x ${bin_dir}/${clientName} ]; then
|
||||||
|
update_TDengine
|
||||||
|
else
|
||||||
|
install_TDengine
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ -x ${bin_dir}/${clientName} ] || [ -x ${bin_2_dir}/${clientName} ]; then
|
||||||
|
update_TDengine
|
||||||
|
else
|
||||||
|
install_TDengine
|
||||||
|
fi
|
||||||
|
fi
|
|
@ -1,5 +1,5 @@
|
||||||
aux_source_directory(src CLIENT_SRC)
|
aux_source_directory(src CLIENT_SRC)
|
||||||
add_library(taos ${CLIENT_SRC})
|
add_library(taos SHARED ${CLIENT_SRC})
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
taos
|
taos
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
||||||
|
@ -11,6 +11,25 @@ target_link_libraries(
|
||||||
PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom
|
PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
taos
|
||||||
|
PROPERTIES
|
||||||
|
VERSION ${TD_VER_NUMBER}
|
||||||
|
SOVERSION ${TD_VER_NUMBER}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(taos_static STATIC ${CLIENT_SRC})
|
||||||
|
target_include_directories(
|
||||||
|
taos_static
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/client"
|
||||||
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
|
)
|
||||||
|
target_link_libraries(
|
||||||
|
taos_static
|
||||||
|
INTERFACE api
|
||||||
|
PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom
|
||||||
|
)
|
||||||
|
|
||||||
if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
ADD_SUBDIRECTORY(test)
|
ADD_SUBDIRECTORY(test)
|
||||||
endif(${BUILD_TEST})
|
endif(${BUILD_TEST})
|
|
@ -8,13 +8,13 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
||||||
ADD_EXECUTABLE(clientTest clientTests.cpp)
|
ADD_EXECUTABLE(clientTest clientTests.cpp)
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
clientTest
|
clientTest
|
||||||
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
|
PUBLIC os util common transport parser catalog scheduler function gtest taos_static qcom
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_EXECUTABLE(tmqTest tmqTest.cpp)
|
ADD_EXECUTABLE(tmqTest tmqTest.cpp)
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
tmqTest
|
tmqTest
|
||||||
PUBLIC os util common transport parser catalog scheduler function gtest taos qcom
|
PUBLIC os util common transport parser catalog scheduler function gtest taos_static qcom
|
||||||
)
|
)
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(
|
TARGET_INCLUDE_DIRECTORIES(
|
||||||
|
|
|
@ -662,7 +662,7 @@ TEST(testCase, agg_query_tables) {
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
pRes = taos_query(pConn, "select * from test_block_raw.all_type");
|
pRes = taos_query(pConn, "select count(*) from tu");
|
||||||
if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
@ -674,9 +674,6 @@ TEST(testCase, agg_query_tables) {
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
int32_t numOfFields = taos_num_fields(pRes);
|
||||||
|
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
void* data = NULL;
|
|
||||||
int32_t code = taos_fetch_raw_block(pRes, &n, &data);
|
|
||||||
|
|
||||||
char str[512] = {0};
|
char str[512] = {0};
|
||||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||||
int32_t* length = taos_fetch_lengths(pRes);
|
int32_t* length = taos_fetch_lengths(pRes);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "ttypes.h"
|
#include "ttypes.h"
|
||||||
#include "tcompression.h"
|
#include "tcompression.h"
|
||||||
|
#include "trow.h"
|
||||||
|
|
||||||
const int32_t TYPE_BYTES[15] = {
|
const int32_t TYPE_BYTES[15] = {
|
||||||
-1, // TSDB_DATA_TYPE_NULL
|
-1, // TSDB_DATA_TYPE_NULL
|
||||||
|
@ -49,7 +50,7 @@ const int32_t TYPE_BYTES[15] = {
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static void getStatics_bool(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
static void getStatics_bool(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||||
int8_t *data = (int8_t *)pData;
|
int8_t *data = (int8_t *)pData;
|
||||||
*min = INT64_MAX;
|
*min = INT64_MAX;
|
||||||
|
@ -60,7 +61,8 @@ static void getStatics_bool(const void *pData, int32_t numOfRow, int64_t *min, i
|
||||||
assert(numOfRow <= INT16_MAX);
|
assert(numOfRow <= INT16_MAX);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||||
if (data[i] == TSDB_DATA_BOOL_NULL) {
|
// if (data[i] == TSDB_DATA_BOOL_NULL) {
|
||||||
|
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||||
(*numOfNull) += 1;
|
(*numOfNull) += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +71,7 @@ static void getStatics_bool(const void *pData, int32_t numOfRow, int64_t *min, i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getStatics_i8(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
static void getStatics_i8(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||||
int8_t *data = (int8_t *)pData;
|
int8_t *data = (int8_t *)pData;
|
||||||
*min = INT64_MAX;
|
*min = INT64_MAX;
|
||||||
|
@ -80,7 +82,8 @@ static void getStatics_i8(const void *pData, int32_t numOfRow, int64_t *min, int
|
||||||
assert(numOfRow <= INT16_MAX);
|
assert(numOfRow <= INT16_MAX);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||||
if (((uint8_t)data[i]) == TSDB_DATA_TINYINT_NULL) {
|
// if (((uint8_t)data[i]) == TSDB_DATA_TINYINT_NULL) {
|
||||||
|
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||||
(*numOfNull) += 1;
|
(*numOfNull) += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +92,7 @@ static void getStatics_i8(const void *pData, int32_t numOfRow, int64_t *min, int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getStatics_u8(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
static void getStatics_u8(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||||
uint8_t *data = (uint8_t *)pData;
|
uint8_t *data = (uint8_t *)pData;
|
||||||
uint64_t _min = UINT64_MAX;
|
uint64_t _min = UINT64_MAX;
|
||||||
|
@ -102,7 +105,8 @@ static void getStatics_u8(const void *pData, int32_t numOfRow, int64_t *min, int
|
||||||
assert(numOfRow <= INT16_MAX);
|
assert(numOfRow <= INT16_MAX);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||||
if (((uint8_t)data[i]) == TSDB_DATA_UTINYINT_NULL) {
|
// if (((uint8_t)data[i]) == TSDB_DATA_UTINYINT_NULL) {
|
||||||
|
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||||
(*numOfNull) += 1;
|
(*numOfNull) += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +119,7 @@ static void getStatics_u8(const void *pData, int32_t numOfRow, int64_t *min, int
|
||||||
*sum = _sum;
|
*sum = _sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getStatics_i16(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
static void getStatics_i16(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||||
int16_t *data = (int16_t *)pData;
|
int16_t *data = (int16_t *)pData;
|
||||||
*min = INT64_MAX;
|
*min = INT64_MAX;
|
||||||
|
@ -126,7 +130,8 @@ static void getStatics_i16(const void *pData, int32_t numOfRow, int64_t *min, in
|
||||||
assert(numOfRow <= INT16_MAX);
|
assert(numOfRow <= INT16_MAX);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||||
if (((uint16_t)data[i]) == TSDB_DATA_SMALLINT_NULL) {
|
// if (((uint16_t)data[i]) == TSDB_DATA_SMALLINT_NULL) {
|
||||||
|
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||||
(*numOfNull) += 1;
|
(*numOfNull) += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +140,7 @@ static void getStatics_i16(const void *pData, int32_t numOfRow, int64_t *min, in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getStatics_u16(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
static void getStatics_u16(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||||
uint16_t *data = (uint16_t *)pData;
|
uint16_t *data = (uint16_t *)pData;
|
||||||
uint64_t _min = UINT64_MAX;
|
uint64_t _min = UINT64_MAX;
|
||||||
|
@ -148,7 +153,8 @@ static void getStatics_u16(const void *pData, int32_t numOfRow, int64_t *min, in
|
||||||
assert(numOfRow <= INT16_MAX);
|
assert(numOfRow <= INT16_MAX);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||||
if (((uint16_t)data[i]) == TSDB_DATA_USMALLINT_NULL) {
|
// if (((uint16_t)data[i]) == TSDB_DATA_USMALLINT_NULL) {
|
||||||
|
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||||
(*numOfNull) += 1;
|
(*numOfNull) += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -161,7 +167,7 @@ static void getStatics_u16(const void *pData, int32_t numOfRow, int64_t *min, in
|
||||||
*sum = _sum;
|
*sum = _sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getStatics_i32(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
static void getStatics_i32(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||||
int32_t *data = (int32_t *)pData;
|
int32_t *data = (int32_t *)pData;
|
||||||
*min = INT64_MAX;
|
*min = INT64_MAX;
|
||||||
|
@ -172,7 +178,8 @@ static void getStatics_i32(const void *pData, int32_t numOfRow, int64_t *min, in
|
||||||
assert(numOfRow <= INT16_MAX);
|
assert(numOfRow <= INT16_MAX);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||||
if (((uint32_t)data[i]) == TSDB_DATA_INT_NULL) {
|
// if (((uint32_t)data[i]) == TSDB_DATA_INT_NULL) {
|
||||||
|
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||||
(*numOfNull) += 1;
|
(*numOfNull) += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +188,7 @@ static void getStatics_i32(const void *pData, int32_t numOfRow, int64_t *min, in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getStatics_u32(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
static void getStatics_u32(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||||
uint32_t *data = (uint32_t *)pData;
|
uint32_t *data = (uint32_t *)pData;
|
||||||
uint64_t _min = UINT64_MAX;
|
uint64_t _min = UINT64_MAX;
|
||||||
|
@ -194,7 +201,8 @@ static void getStatics_u32(const void *pData, int32_t numOfRow, int64_t *min, in
|
||||||
assert(numOfRow <= INT16_MAX);
|
assert(numOfRow <= INT16_MAX);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||||
if (((uint32_t)data[i]) == TSDB_DATA_UINT_NULL) {
|
// if (((uint32_t)data[i]) == TSDB_DATA_UINT_NULL) {
|
||||||
|
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||||
(*numOfNull) += 1;
|
(*numOfNull) += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +215,7 @@ static void getStatics_u32(const void *pData, int32_t numOfRow, int64_t *min, in
|
||||||
*sum = _sum;
|
*sum = _sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getStatics_i64(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
static void getStatics_i64(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||||
int64_t *data = (int64_t *)pData;
|
int64_t *data = (int64_t *)pData;
|
||||||
*min = INT64_MAX;
|
*min = INT64_MAX;
|
||||||
|
@ -218,7 +226,8 @@ static void getStatics_i64(const void *pData, int32_t numOfRow, int64_t *min, in
|
||||||
assert(numOfRow <= INT16_MAX);
|
assert(numOfRow <= INT16_MAX);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||||
if (((uint64_t)data[i]) == TSDB_DATA_BIGINT_NULL) {
|
// if (((uint64_t)data[i]) == TSDB_DATA_BIGINT_NULL) {
|
||||||
|
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||||
(*numOfNull) += 1;
|
(*numOfNull) += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +236,7 @@ static void getStatics_i64(const void *pData, int32_t numOfRow, int64_t *min, in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getStatics_u64(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
static void getStatics_u64(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||||
uint64_t *data = (uint64_t *)pData;
|
uint64_t *data = (uint64_t *)pData;
|
||||||
uint64_t _min = UINT64_MAX;
|
uint64_t _min = UINT64_MAX;
|
||||||
|
@ -240,7 +249,8 @@ static void getStatics_u64(const void *pData, int32_t numOfRow, int64_t *min, in
|
||||||
assert(numOfRow <= INT16_MAX);
|
assert(numOfRow <= INT16_MAX);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||||
if (((uint64_t)data[i]) == TSDB_DATA_UBIGINT_NULL) {
|
// if (((uint64_t)data[i]) == TSDB_DATA_UBIGINT_NULL) {
|
||||||
|
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||||
(*numOfNull) += 1;
|
(*numOfNull) += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +263,7 @@ static void getStatics_u64(const void *pData, int32_t numOfRow, int64_t *min, in
|
||||||
*sum = _sum;
|
*sum = _sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
static void getStatics_f(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||||
float *data = (float *)pData;
|
float *data = (float *)pData;
|
||||||
float fmin = FLT_MAX;
|
float fmin = FLT_MAX;
|
||||||
|
@ -265,7 +275,8 @@ static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int6
|
||||||
assert(numOfRow <= INT16_MAX);
|
assert(numOfRow <= INT16_MAX);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||||
if ((*(uint32_t *)&(data[i])) == TSDB_DATA_FLOAT_NULL) {
|
// if ((*(uint32_t *)&(data[i])) == TSDB_DATA_FLOAT_NULL) {
|
||||||
|
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||||
(*numOfNull) += 1;
|
(*numOfNull) += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +300,7 @@ static void getStatics_f(const void *pData, int32_t numOfRow, int64_t *min, int6
|
||||||
SET_DOUBLE_VAL(min, fmin);
|
SET_DOUBLE_VAL(min, fmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getStatics_d(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
static void getStatics_d(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||||
double *data = (double *)pData;
|
double *data = (double *)pData;
|
||||||
double dmin = DBL_MAX;
|
double dmin = DBL_MAX;
|
||||||
|
@ -301,7 +312,8 @@ static void getStatics_d(const void *pData, int32_t numOfRow, int64_t *min, int6
|
||||||
assert(numOfRow <= INT16_MAX);
|
assert(numOfRow <= INT16_MAX);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||||
if ((*(uint64_t *)&(data[i])) == TSDB_DATA_DOUBLE_NULL) {
|
// if ((*(uint64_t *)&(data[i])) == TSDB_DATA_DOUBLE_NULL) {
|
||||||
|
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||||
(*numOfNull) += 1;
|
(*numOfNull) += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -325,13 +337,14 @@ static void getStatics_d(const void *pData, int32_t numOfRow, int64_t *min, int6
|
||||||
SET_DOUBLE_PTR(min, &dmin);
|
SET_DOUBLE_PTR(min, &dmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getStatics_bin(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
static void getStatics_bin(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||||
const char *data = pData;
|
const char *data = pData;
|
||||||
assert(numOfRow <= INT16_MAX);
|
assert(numOfRow <= INT16_MAX);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||||
if (isNull(data, TSDB_DATA_TYPE_BINARY)) {
|
// if (isNull(data, TSDB_DATA_TYPE_BINARY)) {
|
||||||
|
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||||
(*numOfNull) += 1;
|
(*numOfNull) += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,13 +358,14 @@ static void getStatics_bin(const void *pData, int32_t numOfRow, int64_t *min, in
|
||||||
*maxIndex = 0;
|
*maxIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getStatics_nchr(const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
static void getStatics_nchr(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||||
const char *data = pData;
|
const char *data = pData;
|
||||||
assert(numOfRow <= INT16_MAX);
|
assert(numOfRow <= INT16_MAX);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||||
if (isNull(data, TSDB_DATA_TYPE_NCHAR)) {
|
// if (isNull(data, TSDB_DATA_TYPE_NCHAR)) {
|
||||||
|
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||||
(*numOfNull) += 1;
|
(*numOfNull) += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,5 @@ target_include_directories(
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
dnode_interface cjson mnode vnode qnode snode bnode wal sync taos tfs monitor
|
dnode_interface cjson mnode vnode qnode snode bnode wal sync taos_static tfs monitor
|
||||||
)
|
)
|
|
@ -83,9 +83,9 @@ int32_t vmProcessGetVnodeLoadsReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
|
||||||
|
|
||||||
static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||||
pCfg->vgId = pCreate->vgId;
|
pCfg->vgId = pCreate->vgId;
|
||||||
pCfg->wsize = pCreate->cacheBlockSize;
|
pCfg->wsize = pCreate->cacheBlockSize * 1024 * 1024;
|
||||||
pCfg->ssize = pCreate->cacheBlockSize;
|
pCfg->ssize = 1024;
|
||||||
pCfg->lsize = pCreate->cacheBlockSize;
|
pCfg->lsize = 1024 * 1024;
|
||||||
pCfg->isHeapAllocator = true;
|
pCfg->isHeapAllocator = true;
|
||||||
pCfg->ttl = 4;
|
pCfg->ttl = 4;
|
||||||
pCfg->keep = pCreate->daysToKeep0;
|
pCfg->keep = pCreate->daysToKeep0;
|
||||||
|
@ -96,13 +96,12 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||||
pCfg->tsdbCfg.keep1 = pCreate->daysToKeep0;
|
pCfg->tsdbCfg.keep1 = pCreate->daysToKeep0;
|
||||||
pCfg->tsdbCfg.lruCacheSize = pCreate->cacheBlockSize;
|
pCfg->tsdbCfg.lruCacheSize = pCreate->cacheBlockSize;
|
||||||
pCfg->tsdbCfg.retentions = pCreate->pRetensions;
|
pCfg->tsdbCfg.retentions = pCreate->pRetensions;
|
||||||
pCfg->metaCfg.lruSize = pCreate->cacheBlockSize;
|
pCfg->walCfg.level = TAOS_WAL_WRITE;
|
||||||
pCfg->walCfg.fsyncPeriod = pCreate->fsyncPeriod;
|
pCfg->walCfg.fsyncPeriod = 0;
|
||||||
pCfg->walCfg.level = pCreate->walLevel;
|
pCfg->walCfg.retentionPeriod = 0;
|
||||||
pCfg->walCfg.retentionPeriod = 10;
|
pCfg->walCfg.retentionSize = 0;
|
||||||
pCfg->walCfg.retentionSize = 128;
|
pCfg->walCfg.rollPeriod = 0;
|
||||||
pCfg->walCfg.rollPeriod = 128;
|
pCfg->walCfg.segSize = 0;
|
||||||
pCfg->walCfg.segSize = 128;
|
|
||||||
pCfg->walCfg.vgId = pCreate->vgId;
|
pCfg->walCfg.vgId = pCreate->vgId;
|
||||||
pCfg->hashBegin = pCreate->hashBegin;
|
pCfg->hashBegin = pCreate->hashBegin;
|
||||||
pCfg->hashEnd = pCreate->hashEnd;
|
pCfg->hashEnd = pCreate->hashEnd;
|
||||||
|
@ -160,13 +159,10 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
msgCb.queueFps[APPLY_QUEUE] = vmPutMsgToApplyQueue;
|
msgCb.queueFps[APPLY_QUEUE] = vmPutMsgToApplyQueue;
|
||||||
msgCb.qsizeFp = vmGetQueueSize;
|
msgCb.qsizeFp = vmGetQueueSize;
|
||||||
|
|
||||||
vnodeCfg.msgCb = msgCb;
|
SVnode *pImpl = vnodeOpen(path, pMgmt->pTfs, msgCb);
|
||||||
vnodeCfg.pTfs = pMgmt->pTfs;
|
|
||||||
vnodeCfg.dbId = wrapperCfg.dbUid;
|
|
||||||
SVnode *pImpl = vnodeOpen(wrapperCfg.path, &vnodeCfg);
|
|
||||||
if (pImpl == NULL) {
|
if (pImpl == NULL) {
|
||||||
tFreeSCreateVnodeReq(&createReq);
|
|
||||||
dError("vgId:%d, failed to create vnode since %s", createReq.vgId, terrstr());
|
dError("vgId:%d, failed to create vnode since %s", createReq.vgId, terrstr());
|
||||||
|
tFreeSCreateVnodeReq(&createReq);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +171,7 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
tFreeSCreateVnodeReq(&createReq);
|
tFreeSCreateVnodeReq(&createReq);
|
||||||
dError("vgId:%d, failed to open vnode since %s", createReq.vgId, terrstr());
|
dError("vgId:%d, failed to open vnode since %s", createReq.vgId, terrstr());
|
||||||
vnodeClose(pImpl);
|
vnodeClose(pImpl);
|
||||||
vnodeDestroy(wrapperCfg.path);
|
vnodeDestroy(path, pMgmt->pTfs);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +180,7 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
tFreeSCreateVnodeReq(&createReq);
|
tFreeSCreateVnodeReq(&createReq);
|
||||||
vnodeClose(pImpl);
|
vnodeClose(pImpl);
|
||||||
vnodeDestroy(wrapperCfg.path);
|
vnodeDestroy(path, pMgmt->pTfs);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,8 @@ int32_t vmOpenVnode(SVnodesMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void vmCloseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
void vmCloseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
|
char path[TSDB_FILENAME_LEN];
|
||||||
|
|
||||||
taosWLockLatch(&pMgmt->latch);
|
taosWLockLatch(&pMgmt->latch);
|
||||||
taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t));
|
taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t));
|
||||||
taosWUnLockLatch(&pMgmt->latch);
|
taosWUnLockLatch(&pMgmt->latch);
|
||||||
|
@ -104,7 +106,8 @@ void vmCloseVnode(SVnodesMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||||
|
|
||||||
if (pVnode->dropped) {
|
if (pVnode->dropped) {
|
||||||
dDebug("vgId:%d, vnode is destroyed for dropped:%d", pVnode->vgId, pVnode->dropped);
|
dDebug("vgId:%d, vnode is destroyed for dropped:%d", pVnode->vgId, pVnode->dropped);
|
||||||
vnodeDestroy(pVnode->path);
|
snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, pVnode->vgId);
|
||||||
|
vnodeDestroy(path, pMgmt->pTfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(pVnode->path);
|
taosMemoryFree(pVnode->path);
|
||||||
|
@ -116,6 +119,7 @@ static void *vmOpenVnodeFunc(void *param) {
|
||||||
SVnodeThread *pThread = param;
|
SVnodeThread *pThread = param;
|
||||||
SVnodesMgmt *pMgmt = pThread->pMgmt;
|
SVnodesMgmt *pMgmt = pThread->pMgmt;
|
||||||
SDnode *pDnode = pMgmt->pDnode;
|
SDnode *pDnode = pMgmt->pDnode;
|
||||||
|
char path[TSDB_FILENAME_LEN];
|
||||||
|
|
||||||
dDebug("thread:%d, start to open %d vnodes", pThread->threadIndex, pThread->vnodeNum);
|
dDebug("thread:%d, start to open %d vnodes", pThread->threadIndex, pThread->vnodeNum);
|
||||||
setThreadName("open-vnodes");
|
setThreadName("open-vnodes");
|
||||||
|
@ -134,8 +138,8 @@ static void *vmOpenVnodeFunc(void *param) {
|
||||||
msgCb.queueFps[FETCH_QUEUE] = vmPutMsgToFetchQueue;
|
msgCb.queueFps[FETCH_QUEUE] = vmPutMsgToFetchQueue;
|
||||||
msgCb.queueFps[APPLY_QUEUE] = vmPutMsgToApplyQueue;
|
msgCb.queueFps[APPLY_QUEUE] = vmPutMsgToApplyQueue;
|
||||||
msgCb.qsizeFp = vmGetQueueSize;
|
msgCb.qsizeFp = vmGetQueueSize;
|
||||||
SVnodeCfg cfg = {.msgCb = msgCb, .pTfs = pMgmt->pTfs, .vgId = pCfg->vgId, .dbId = pCfg->dbUid};
|
snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, pCfg->vgId);
|
||||||
SVnode *pImpl = vnodeOpen(pCfg->path, &cfg);
|
SVnode *pImpl = vnodeOpen(path, pMgmt->pTfs, msgCb);
|
||||||
if (pImpl == NULL) {
|
if (pImpl == NULL) {
|
||||||
dError("vgId:%d, failed to open vnode by thread:%d", pCfg->vgId, pThread->threadIndex);
|
dError("vgId:%d, failed to open vnode by thread:%d", pCfg->vgId, pThread->threadIndex);
|
||||||
pThread->failed++;
|
pThread->failed++;
|
||||||
|
|
|
@ -18,12 +18,11 @@ target_sources(
|
||||||
"src/vnd/vnodeSvr.c"
|
"src/vnd/vnodeSvr.c"
|
||||||
|
|
||||||
# meta
|
# meta
|
||||||
# "src/meta/metaBDBImpl.c"
|
"src/meta/metaOpen.c"
|
||||||
"src/meta/metaIdx.c"
|
"src/meta/metaIdx.c"
|
||||||
"src/meta/metaMain.c"
|
|
||||||
"src/meta/metaTable.c"
|
"src/meta/metaTable.c"
|
||||||
"src/meta/metaTbUid.c"
|
|
||||||
"src/meta/metaTDBImpl.c"
|
"src/meta/metaTDBImpl.c"
|
||||||
|
# "src/meta/metaBDBImpl.c"
|
||||||
|
|
||||||
# tsdb
|
# tsdb
|
||||||
"src/tsdb/tsdbTDBImpl.c"
|
"src/tsdb/tsdbTDBImpl.c"
|
||||||
|
|
|
@ -37,16 +37,14 @@ extern "C" {
|
||||||
|
|
||||||
// vnode
|
// vnode
|
||||||
typedef struct SVnode SVnode;
|
typedef struct SVnode SVnode;
|
||||||
typedef struct SMetaCfg SMetaCfg; // todo: remove
|
|
||||||
typedef struct STsdbCfg STsdbCfg; // todo: remove
|
typedef struct STsdbCfg STsdbCfg; // todo: remove
|
||||||
typedef struct STqCfg STqCfg; // todo: remove
|
|
||||||
typedef struct SVnodeCfg SVnodeCfg;
|
typedef struct SVnodeCfg SVnodeCfg;
|
||||||
|
|
||||||
int vnodeInit(int nthreads);
|
int vnodeInit(int nthreads);
|
||||||
void vnodeCleanup();
|
void vnodeCleanup();
|
||||||
int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs);
|
int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs);
|
||||||
void vnodeDestroy(const char *path);
|
void vnodeDestroy(const char *path, STfs *pTfs);
|
||||||
SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg);
|
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb);
|
||||||
void vnodeClose(SVnode *pVnode);
|
void vnodeClose(SVnode *pVnode);
|
||||||
void vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs);
|
void vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs);
|
||||||
int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||||
|
@ -73,7 +71,6 @@ char *metaTbCursorNext(SMTbCursor *pTbCur);
|
||||||
|
|
||||||
// tsdb
|
// tsdb
|
||||||
typedef struct STsdb STsdb;
|
typedef struct STsdb STsdb;
|
||||||
typedef struct SDataStatis SDataStatis;
|
|
||||||
typedef struct STsdbQueryCond STsdbQueryCond;
|
typedef struct STsdbQueryCond STsdbQueryCond;
|
||||||
typedef void *tsdbReaderT;
|
typedef void *tsdbReaderT;
|
||||||
|
|
||||||
|
@ -93,7 +90,7 @@ int32_t tsdbQuerySTableByTagCond(void *pMeta, uint64_t uid, TSKEY skey, con
|
||||||
int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT *pHandle);
|
int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT *pHandle);
|
||||||
bool tsdbNextDataBlock(tsdbReaderT pTsdbReadHandle);
|
bool tsdbNextDataBlock(tsdbReaderT pTsdbReadHandle);
|
||||||
void tsdbRetrieveDataBlockInfo(tsdbReaderT *pTsdbReadHandle, SDataBlockInfo *pBlockInfo);
|
void tsdbRetrieveDataBlockInfo(tsdbReaderT *pTsdbReadHandle, SDataBlockInfo *pBlockInfo);
|
||||||
int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT *pTsdbReadHandle, SDataStatis **pBlockStatis);
|
int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT *pTsdbReadHandle, SColumnDataAgg **pBlockStatis);
|
||||||
SArray *tsdbRetrieveDataBlock(tsdbReaderT *pTsdbReadHandle, SArray *pColumnIdList);
|
SArray *tsdbRetrieveDataBlock(tsdbReaderT *pTsdbReadHandle, SArray *pColumnIdList);
|
||||||
void tsdbDestroyTableGroup(STableGroupInfo *pGroupList);
|
void tsdbDestroyTableGroup(STableGroupInfo *pGroupList);
|
||||||
int32_t tsdbGetOneTableGroup(void *pMeta, uint64_t uid, TSKEY startKey, STableGroupInfo *pGroupInfo);
|
int32_t tsdbGetOneTableGroup(void *pMeta, uint64_t uid, TSKEY startKey, STableGroupInfo *pGroupInfo);
|
||||||
|
@ -134,14 +131,9 @@ struct STsdbCfg {
|
||||||
SArray *retentions;
|
SArray *retentions;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct STqCfg {
|
|
||||||
int32_t reserved;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SVnodeCfg {
|
struct SVnodeCfg {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
uint64_t dbId;
|
uint64_t dbId;
|
||||||
STfs *pTfs;
|
|
||||||
uint64_t wsize;
|
uint64_t wsize;
|
||||||
uint64_t ssize;
|
uint64_t ssize;
|
||||||
uint64_t lsize;
|
uint64_t lsize;
|
||||||
|
@ -151,25 +143,12 @@ struct SVnodeCfg {
|
||||||
int8_t streamMode;
|
int8_t streamMode;
|
||||||
bool isWeak;
|
bool isWeak;
|
||||||
STsdbCfg tsdbCfg;
|
STsdbCfg tsdbCfg;
|
||||||
SMetaCfg metaCfg;
|
|
||||||
STqCfg tqCfg;
|
|
||||||
SWalCfg walCfg;
|
SWalCfg walCfg;
|
||||||
SMsgCb msgCb;
|
|
||||||
uint32_t hashBegin;
|
uint32_t hashBegin;
|
||||||
uint32_t hashEnd;
|
uint32_t hashEnd;
|
||||||
int8_t hashMethod;
|
int8_t hashMethod;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SDataStatis {
|
|
||||||
int16_t colId;
|
|
||||||
int16_t maxIndex;
|
|
||||||
int16_t minIndex;
|
|
||||||
int16_t numOfNull;
|
|
||||||
int64_t sum;
|
|
||||||
int64_t max;
|
|
||||||
int64_t min;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct STsdbQueryCond {
|
struct STsdbQueryCond {
|
||||||
STimeWindow twindow;
|
STimeWindow twindow;
|
||||||
int32_t order; // desc|asc order to iterate the data block
|
int32_t order; // desc|asc order to iterate the data block
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct SMetaCache SMetaCache;
|
|
||||||
typedef struct SMetaIdx SMetaIdx;
|
typedef struct SMetaIdx SMetaIdx;
|
||||||
typedef struct SMetaDB SMetaDB;
|
typedef struct SMetaDB SMetaDB;
|
||||||
typedef struct SMCtbCursor SMCtbCursor;
|
typedef struct SMCtbCursor SMCtbCursor;
|
||||||
|
@ -36,13 +35,22 @@ typedef struct SMSmaCursor SMSmaCursor;
|
||||||
#define metaTrace(...) do { if (metaDebugFlag & DEBUG_TRACE) { taosPrintLog("META ", DEBUG_TRACE, metaDebugFlag, __VA_ARGS__); }} while(0)
|
#define metaTrace(...) do { if (metaDebugFlag & DEBUG_TRACE) { taosPrintLog("META ", DEBUG_TRACE, metaDebugFlag, __VA_ARGS__); }} while(0)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
// metaOpen ==================
|
||||||
|
int metaOpen(SVnode* pVnode, SMeta** ppMeta);
|
||||||
|
int metaClose(SMeta* pMeta);
|
||||||
|
|
||||||
|
// metaIdx ==================
|
||||||
|
int metaOpenIdx(SMeta* pMeta);
|
||||||
|
void metaCloseIdx(SMeta* pMeta);
|
||||||
|
int metaSaveTableToIdx(SMeta* pMeta, const STbCfg* pTbOptions);
|
||||||
|
int metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid);
|
||||||
|
|
||||||
|
static FORCE_INLINE tb_uid_t metaGenerateUid(SMeta* pMeta) { return tGenIdPI64(); }
|
||||||
|
|
||||||
#define META_SUPER_TABLE TD_SUPER_TABLE
|
#define META_SUPER_TABLE TD_SUPER_TABLE
|
||||||
#define META_CHILD_TABLE TD_CHILD_TABLE
|
#define META_CHILD_TABLE TD_CHILD_TABLE
|
||||||
#define META_NORMAL_TABLE TD_NORMAL_TABLE
|
#define META_NORMAL_TABLE TD_NORMAL_TABLE
|
||||||
|
|
||||||
SMeta* metaOpen(const char* path, const SMetaCfg* pMetaCfg, SMemAllocatorFactory* pMAF);
|
|
||||||
void metaClose(SMeta* pMeta);
|
|
||||||
void metaRemove(const char* path);
|
|
||||||
int metaCreateTable(SMeta* pMeta, STbCfg* pTbCfg);
|
int metaCreateTable(SMeta* pMeta, STbCfg* pTbCfg);
|
||||||
int metaDropTable(SMeta* pMeta, tb_uid_t uid);
|
int metaDropTable(SMeta* pMeta, tb_uid_t uid);
|
||||||
int metaCommit(SMeta* pMeta);
|
int metaCommit(SMeta* pMeta);
|
||||||
|
@ -71,38 +79,15 @@ int metaRemoveTableFromDb(SMeta* pMeta, tb_uid_t uid);
|
||||||
int metaSaveSmaToDB(SMeta* pMeta, STSma* pTbCfg);
|
int metaSaveSmaToDB(SMeta* pMeta, STSma* pTbCfg);
|
||||||
int metaRemoveSmaFromDb(SMeta* pMeta, int64_t indexUid);
|
int metaRemoveSmaFromDb(SMeta* pMeta, int64_t indexUid);
|
||||||
|
|
||||||
// SMetaCache
|
|
||||||
int metaOpenCache(SMeta* pMeta);
|
|
||||||
void metaCloseCache(SMeta* pMeta);
|
|
||||||
|
|
||||||
// SMetaIdx
|
// SMetaIdx
|
||||||
int metaOpenIdx(SMeta* pMeta);
|
|
||||||
void metaCloseIdx(SMeta* pMeta);
|
|
||||||
int metaSaveTableToIdx(SMeta* pMeta, const STbCfg* pTbOptions);
|
|
||||||
int metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid);
|
|
||||||
|
|
||||||
// STbUidGnrt
|
|
||||||
typedef struct STbUidGenerator {
|
|
||||||
tb_uid_t nextUid;
|
|
||||||
} STbUidGenerator;
|
|
||||||
|
|
||||||
// STableUidGenerator
|
|
||||||
int metaOpenUidGnrt(SMeta* pMeta);
|
|
||||||
void metaCloseUidGnrt(SMeta* pMeta);
|
|
||||||
|
|
||||||
// tb_uid_t
|
|
||||||
#define IVLD_TB_UID 0
|
|
||||||
tb_uid_t metaGenerateUid(SMeta* pMeta);
|
tb_uid_t metaGenerateUid(SMeta* pMeta);
|
||||||
|
|
||||||
struct SMeta {
|
struct SMeta {
|
||||||
char* path;
|
char* path;
|
||||||
SVnode* pVnode;
|
SVnode* pVnode;
|
||||||
SMetaCfg options;
|
|
||||||
SMetaDB* pDB;
|
SMetaDB* pDB;
|
||||||
SMetaIdx* pIdx;
|
SMetaIdx* pIdx;
|
||||||
SMetaCache* pCache;
|
|
||||||
STbUidGenerator uidGnrt;
|
|
||||||
SMemAllocatorFactory* pmaf;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -160,7 +160,6 @@ struct STQ {
|
||||||
// the handle of meta kvstore
|
// the handle of meta kvstore
|
||||||
bool writeTrigger;
|
bool writeTrigger;
|
||||||
char* path;
|
char* path;
|
||||||
STqCfg* tqConfig;
|
|
||||||
STqMemRef tqMemRef;
|
STqMemRef tqMemRef;
|
||||||
STqMetaStore* tqMeta;
|
STqMetaStore* tqMeta;
|
||||||
// STqPushMgr* tqPushMgr;
|
// STqPushMgr* tqPushMgr;
|
||||||
|
@ -251,8 +250,7 @@ int tqInit();
|
||||||
void tqCleanUp();
|
void tqCleanUp();
|
||||||
|
|
||||||
// open in each vnode
|
// open in each vnode
|
||||||
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pMeta, STqCfg* tqConfig,
|
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pMeta, SMemAllocatorFactory* allocFac);
|
||||||
SMemAllocatorFactory* allocFac);
|
|
||||||
void tqClose(STQ*);
|
void tqClose(STQ*);
|
||||||
// required by vnode
|
// required by vnode
|
||||||
int tqPushMsg(STQ*, void* msg, int32_t msgLen, tmsg_t msgType, int64_t version);
|
int tqPushMsg(STQ*, void* msg, int32_t msgLen, tmsg_t msgType, int64_t version);
|
||||||
|
|
|
@ -438,7 +438,7 @@ int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo,
|
||||||
int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock);
|
int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock);
|
||||||
int tsdbEncodeSBlockIdx(void **buf, SBlockIdx *pIdx);
|
int tsdbEncodeSBlockIdx(void **buf, SBlockIdx *pIdx);
|
||||||
void *tsdbDecodeSBlockIdx(void *buf, SBlockIdx *pIdx);
|
void *tsdbDecodeSBlockIdx(void *buf, SBlockIdx *pIdx);
|
||||||
void tsdbGetBlockStatis(SReadH *pReadh, SDataStatis *pStatis, int numOfCols, SBlock *pBlock);
|
void tsdbGetBlockStatis(SReadH *pReadh, SColumnDataAgg *pStatis, int numOfCols, SBlock *pBlock);
|
||||||
|
|
||||||
static FORCE_INLINE int tsdbMakeRoom(void **ppBuf, size_t size) {
|
static FORCE_INLINE int tsdbMakeRoom(void **ppBuf, size_t size) {
|
||||||
void *pBuf = *ppBuf;
|
void *pBuf = *ppBuf;
|
||||||
|
|
|
@ -44,6 +44,11 @@ int vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
||||||
int vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg);
|
int vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg);
|
||||||
int vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo);
|
int vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo);
|
||||||
int vnodeLoadInfo(const char* dir, SVnodeInfo* pInfo);
|
int vnodeLoadInfo(const char* dir, SVnodeInfo* pInfo);
|
||||||
|
int vnodeBegin(SVnode* pVnode, int option);
|
||||||
|
int vnodeSyncCommit(SVnode* pVnode);
|
||||||
|
int vnodeAsyncCommit(SVnode* pVnode);
|
||||||
|
|
||||||
|
#define vnodeShouldCommit vnodeBufPoolIsFull
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// SVBufPool
|
// SVBufPool
|
||||||
|
@ -85,12 +90,7 @@ bool vmaIsFull(SVMemAllocator* pVMA);
|
||||||
extern const SVnodeCfg vnodeCfgDefault;
|
extern const SVnodeCfg vnodeCfgDefault;
|
||||||
|
|
||||||
int vnodeCheckCfg(const SVnodeCfg*);
|
int vnodeCheckCfg(const SVnodeCfg*);
|
||||||
void vnodeOptionsCopy(SVnodeCfg* pDest, const SVnodeCfg* pSrc);
|
|
||||||
|
|
||||||
// For commit
|
|
||||||
#define vnodeShouldCommit vnodeBufPoolIsFull
|
|
||||||
int vnodeSyncCommit(SVnode* pVnode);
|
|
||||||
int vnodeAsyncCommit(SVnode* pVnode);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -52,6 +52,11 @@ typedef struct SVState SVState;
|
||||||
typedef struct SVBufPool SVBufPool;
|
typedef struct SVBufPool SVBufPool;
|
||||||
typedef struct SQWorkerMgmt SQHandle;
|
typedef struct SQWorkerMgmt SQHandle;
|
||||||
|
|
||||||
|
#define VNODE_META_DIR "meta"
|
||||||
|
#define VNODE_TSDB_DIR "tsdb"
|
||||||
|
#define VNODE_TQ_DIR "tq"
|
||||||
|
#define VNODE_WAL_DIR "wal"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t streamType; // sma or other
|
int8_t streamType; // sma or other
|
||||||
int8_t dstType;
|
int8_t dstType;
|
||||||
|
@ -80,10 +85,11 @@ struct SVnodeInfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SVnode {
|
struct SVnode {
|
||||||
int32_t vgId;
|
|
||||||
char* path;
|
char* path;
|
||||||
SVnodeCfg config;
|
SVnodeCfg config;
|
||||||
SVState state;
|
SVState state;
|
||||||
|
STfs* pTfs;
|
||||||
|
SMsgCb msgCb;
|
||||||
SVBufPool* pBufPool;
|
SVBufPool* pBufPool;
|
||||||
SMeta* pMeta;
|
SMeta* pMeta;
|
||||||
STsdb* pTsdb;
|
STsdb* pTsdb;
|
||||||
|
@ -92,10 +98,10 @@ struct SVnode {
|
||||||
SSink* pSink;
|
SSink* pSink;
|
||||||
tsem_t canCommit;
|
tsem_t canCommit;
|
||||||
SQHandle* pQuery;
|
SQHandle* pQuery;
|
||||||
SMsgCb msgCb;
|
|
||||||
STfs* pTfs;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define TD_VID(PVNODE) (PVNODE)->config.vgId
|
||||||
|
|
||||||
// sma
|
// sma
|
||||||
void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data);
|
void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data);
|
||||||
|
|
||||||
|
|
|
@ -1,111 +0,0 @@
|
||||||
/*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "tcoding.h"
|
|
||||||
|
|
||||||
#include "vnodeInt.h"
|
|
||||||
|
|
||||||
static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF);
|
|
||||||
static void metaFree(SMeta *pMeta);
|
|
||||||
static int metaOpenImpl(SMeta *pMeta);
|
|
||||||
static void metaCloseImpl(SMeta *pMeta);
|
|
||||||
|
|
||||||
SMeta *metaOpen(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF) {
|
|
||||||
SMeta *pMeta = NULL;
|
|
||||||
|
|
||||||
// Allocate handle
|
|
||||||
pMeta = metaNew(path, pMetaCfg, pMAF);
|
|
||||||
if (pMeta == NULL) {
|
|
||||||
// TODO: handle error
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create META path (TODO)
|
|
||||||
taosMkDir(path);
|
|
||||||
|
|
||||||
// Open meta
|
|
||||||
if (metaOpenImpl(pMeta) < 0) {
|
|
||||||
metaFree(pMeta);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pMeta;
|
|
||||||
}
|
|
||||||
|
|
||||||
void metaClose(SMeta *pMeta) {
|
|
||||||
if (pMeta) {
|
|
||||||
metaCloseImpl(pMeta);
|
|
||||||
metaFree(pMeta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void metaRemove(const char *path) { taosRemoveDir(path); }
|
|
||||||
|
|
||||||
/* ------------------------ STATIC METHODS ------------------------ */
|
|
||||||
static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorFactory *pMAF) {
|
|
||||||
SMeta *pMeta;
|
|
||||||
size_t psize = strlen(path);
|
|
||||||
|
|
||||||
pMeta = (SMeta *)taosMemoryCalloc(1, sizeof(*pMeta));
|
|
||||||
if (pMeta == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pMeta->path = strdup(path);
|
|
||||||
if (pMeta->path == NULL) {
|
|
||||||
metaFree(pMeta);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pMeta;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void metaFree(SMeta *pMeta) {
|
|
||||||
if (pMeta) {
|
|
||||||
taosMemoryFreeClear(pMeta->path);
|
|
||||||
taosMemoryFree(pMeta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int metaOpenImpl(SMeta *pMeta) {
|
|
||||||
// Open meta db
|
|
||||||
if (metaOpenDB(pMeta) < 0) {
|
|
||||||
// TODO: handle error
|
|
||||||
metaCloseImpl(pMeta);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open meta index
|
|
||||||
if (metaOpenIdx(pMeta) < 0) {
|
|
||||||
// TODO: handle error
|
|
||||||
metaCloseImpl(pMeta);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open meta table uid generator
|
|
||||||
if (metaOpenUidGnrt(pMeta) < 0) {
|
|
||||||
// TODO: handle error
|
|
||||||
metaCloseImpl(pMeta);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void metaCloseImpl(SMeta *pMeta) {
|
|
||||||
metaCloseUidGnrt(pMeta);
|
|
||||||
metaCloseIdx(pMeta);
|
|
||||||
metaCloseDB(pMeta);
|
|
||||||
}
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "vnodeInt.h"
|
||||||
|
|
||||||
|
int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
||||||
|
SMeta *pMeta = NULL;
|
||||||
|
int slen;
|
||||||
|
|
||||||
|
*ppMeta = NULL;
|
||||||
|
|
||||||
|
// create handle
|
||||||
|
slen = strlen(tfsGetPrimaryPath(pVnode->pTfs)) + strlen(pVnode->path) + strlen(VNODE_META_DIR) + 3;
|
||||||
|
if ((pMeta = taosMemoryCalloc(1, sizeof(*pMeta) + slen)) == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pMeta->path = (char *)&pMeta[1];
|
||||||
|
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
||||||
|
VNODE_META_DIR);
|
||||||
|
pMeta->pVnode = pVnode;
|
||||||
|
|
||||||
|
// create path if not created yet
|
||||||
|
taosMkDir(pMeta->path);
|
||||||
|
|
||||||
|
// open meta
|
||||||
|
if (metaOpenDB(pMeta) < 0) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metaOpenIdx(pMeta) < 0) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppMeta = pMeta;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
if (pMeta->pIdx) metaCloseIdx(pMeta);
|
||||||
|
if (pMeta->pDB) metaCloseDB(pMeta);
|
||||||
|
taosMemoryFree(pMeta);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int metaClose(SMeta *pMeta) {
|
||||||
|
if (pMeta) {
|
||||||
|
metaCloseIdx(pMeta);
|
||||||
|
metaCloseDB(pMeta);
|
||||||
|
taosMemoryFree(pMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,30 +0,0 @@
|
||||||
/*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "vnodeInt.h"
|
|
||||||
|
|
||||||
int metaOpenUidGnrt(SMeta *pMeta) {
|
|
||||||
// Init a generator
|
|
||||||
pMeta->uidGnrt.nextUid = IVLD_TB_UID;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void metaCloseUidGnrt(SMeta *pMeta) { /* TODO */
|
|
||||||
}
|
|
||||||
|
|
||||||
tb_uid_t metaGenerateUid(SMeta *pMeta) {
|
|
||||||
// Generate a new table UID
|
|
||||||
return tGenIdPI64();
|
|
||||||
}
|
|
|
@ -19,15 +19,13 @@ int32_t tqInit() { return tqPushMgrInit(); }
|
||||||
|
|
||||||
void tqCleanUp() { tqPushMgrCleanUp(); }
|
void tqCleanUp() { tqPushMgrCleanUp(); }
|
||||||
|
|
||||||
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STqCfg* tqConfig,
|
STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, SMemAllocatorFactory* allocFac) {
|
||||||
SMemAllocatorFactory* allocFac) {
|
|
||||||
STQ* pTq = taosMemoryMalloc(sizeof(STQ));
|
STQ* pTq = taosMemoryMalloc(sizeof(STQ));
|
||||||
if (pTq == NULL) {
|
if (pTq == NULL) {
|
||||||
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pTq->path = strdup(path);
|
pTq->path = strdup(path);
|
||||||
pTq->tqConfig = tqConfig;
|
|
||||||
pTq->pVnode = pVnode;
|
pTq->pVnode = pVnode;
|
||||||
pTq->pWal = pWal;
|
pTq->pWal = pWal;
|
||||||
pTq->pVnodeMeta = pVnodeMeta;
|
pTq->pVnodeMeta = pVnodeMeta;
|
||||||
|
@ -267,7 +265,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
vDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld", consumerId, pReq->epoch,
|
vDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld", consumerId, pReq->epoch,
|
||||||
pTq->pVnode->vgId, pReq->currentOffset, fetchOffset);
|
TD_VID(pTq->pVnode), pReq->currentOffset, fetchOffset);
|
||||||
|
|
||||||
SMqPollRsp rsp = {
|
SMqPollRsp rsp = {
|
||||||
/*.consumerId = consumerId,*/
|
/*.consumerId = consumerId,*/
|
||||||
|
@ -277,7 +275,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
|
|
||||||
STqConsumer* pConsumer = tqHandleGet(pTq->tqMeta, consumerId);
|
STqConsumer* pConsumer = tqHandleGet(pTq->tqMeta, consumerId);
|
||||||
if (pConsumer == NULL) {
|
if (pConsumer == NULL) {
|
||||||
vWarn("tmq poll: consumer %ld (epoch %d) not found in vg %d", consumerId, pReq->epoch, pTq->pVnode->vgId);
|
vWarn("tmq poll: consumer %ld (epoch %d) not found in vg %d", consumerId, pReq->epoch, TD_VID(pTq->pVnode));
|
||||||
pMsg->pCont = NULL;
|
pMsg->pCont = NULL;
|
||||||
pMsg->contLen = 0;
|
pMsg->contLen = 0;
|
||||||
pMsg->code = -1;
|
pMsg->code = -1;
|
||||||
|
@ -303,7 +301,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
}
|
}
|
||||||
if (pTopic == NULL) {
|
if (pTopic == NULL) {
|
||||||
vWarn("tmq poll: consumer %ld (epoch %d) topic %s not found in vg %d", consumerId, pReq->epoch, pReq->topic,
|
vWarn("tmq poll: consumer %ld (epoch %d) topic %s not found in vg %d", consumerId, pReq->epoch, pReq->topic,
|
||||||
pTq->pVnode->vgId);
|
TD_VID(pTq->pVnode));
|
||||||
pMsg->pCont = NULL;
|
pMsg->pCont = NULL;
|
||||||
pMsg->contLen = 0;
|
pMsg->contLen = 0;
|
||||||
pMsg->code = -1;
|
pMsg->code = -1;
|
||||||
|
@ -312,7 +310,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
vDebug("poll topic %s from consumer %ld (epoch %d) vg %d", pTopic->topicName, consumerId, pReq->epoch,
|
vDebug("poll topic %s from consumer %ld (epoch %d) vg %d", pTopic->topicName, consumerId, pReq->epoch,
|
||||||
pTq->pVnode->vgId);
|
TD_VID(pTq->pVnode));
|
||||||
|
|
||||||
rsp.reqOffset = pReq->currentOffset;
|
rsp.reqOffset = pReq->currentOffset;
|
||||||
rsp.skipLogNum = 0;
|
rsp.skipLogNum = 0;
|
||||||
|
@ -323,7 +321,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
consumerEpoch = atomic_load_32(&pConsumer->epoch);
|
consumerEpoch = atomic_load_32(&pConsumer->epoch);
|
||||||
if (consumerEpoch > reqEpoch) {
|
if (consumerEpoch > reqEpoch) {
|
||||||
vDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, found new consumer epoch %d discard req epoch %d",
|
vDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, found new consumer epoch %d discard req epoch %d",
|
||||||
consumerId, pReq->epoch, pTq->pVnode->vgId, fetchOffset, consumerEpoch, reqEpoch);
|
consumerId, pReq->epoch, TD_VID(pTq->pVnode), fetchOffset, consumerEpoch, reqEpoch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SWalReadHead* pHead;
|
SWalReadHead* pHead;
|
||||||
|
@ -332,11 +330,11 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
// if data inserted during waiting, launch query and
|
// if data inserted during waiting, launch query and
|
||||||
// response to user
|
// response to user
|
||||||
vDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", consumerId, pReq->epoch,
|
vDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", consumerId, pReq->epoch,
|
||||||
pTq->pVnode->vgId, fetchOffset);
|
TD_VID(pTq->pVnode), fetchOffset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch,
|
vDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch,
|
||||||
pTq->pVnode->vgId, fetchOffset, pHead->msgType);
|
TD_VID(pTq->pVnode), fetchOffset, pHead->msgType);
|
||||||
/*int8_t pos = fetchOffset % TQ_BUFFER_SIZE;*/
|
/*int8_t pos = fetchOffset % TQ_BUFFER_SIZE;*/
|
||||||
/*pHead = pTopic->pReadhandle->pHead;*/
|
/*pHead = pTopic->pReadhandle->pHead;*/
|
||||||
if (pHead->msgType == TDMT_VND_SUBMIT) {
|
if (pHead->msgType == TDMT_VND_SUBMIT) {
|
||||||
|
@ -361,7 +359,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
|
|
||||||
if (taosArrayGetSize(pRes) == 0) {
|
if (taosArrayGetSize(pRes) == 0) {
|
||||||
vDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d skip log %ld since not wanted", consumerId,
|
vDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d skip log %ld since not wanted", consumerId,
|
||||||
pReq->epoch, pTq->pVnode->vgId, fetchOffset);
|
pReq->epoch, TD_VID(pTq->pVnode), fetchOffset);
|
||||||
fetchOffset++;
|
fetchOffset++;
|
||||||
rsp.skipLogNum++;
|
rsp.skipLogNum++;
|
||||||
taosArrayDestroy(pRes);
|
taosArrayDestroy(pRes);
|
||||||
|
@ -390,7 +388,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
pMsg->pCont = buf;
|
pMsg->pCont = buf;
|
||||||
pMsg->contLen = tlen;
|
pMsg->contLen = tlen;
|
||||||
pMsg->code = 0;
|
pMsg->code = 0;
|
||||||
vDebug("vg %d offset %ld msgType %d from consumer %ld (epoch %d) actual rsp", pTq->pVnode->vgId, fetchOffset,
|
vDebug("vg %d offset %ld msgType %d from consumer %ld (epoch %d) actual rsp", TD_VID(pTq->pVnode), fetchOffset,
|
||||||
pHead->msgType, consumerId, pReq->epoch);
|
pHead->msgType, consumerId, pReq->epoch);
|
||||||
tmsgSendRsp(pMsg);
|
tmsgSendRsp(pMsg);
|
||||||
taosMemoryFree(pHead);
|
taosMemoryFree(pHead);
|
||||||
|
@ -422,7 +420,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
pMsg->contLen = tlen;
|
pMsg->contLen = tlen;
|
||||||
pMsg->code = 0;
|
pMsg->code = 0;
|
||||||
tmsgSendRsp(pMsg);
|
tmsgSendRsp(pMsg);
|
||||||
vDebug("vg %d offset %ld from consumer %ld (epoch %d) not rsp", pTq->pVnode->vgId, fetchOffset, consumerId,
|
vDebug("vg %d offset %ld from consumer %ld (epoch %d) not rsp", TD_VID(pTq->pVnode), fetchOffset, consumerId,
|
||||||
pReq->epoch);
|
pReq->epoch);
|
||||||
/*}*/
|
/*}*/
|
||||||
|
|
||||||
|
@ -446,14 +444,14 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
vDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld", consumerId, pReq->epoch,
|
vDebug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld", consumerId, pReq->epoch,
|
||||||
pTq->pVnode->vgId, pReq->currentOffset, fetchOffset);
|
TD_VID(pTq->pVnode), pReq->currentOffset, fetchOffset);
|
||||||
|
|
||||||
SMqPollRspV2 rspV2 = {0};
|
SMqPollRspV2 rspV2 = {0};
|
||||||
rspV2.dataLen = 0;
|
rspV2.dataLen = 0;
|
||||||
|
|
||||||
STqConsumer* pConsumer = tqHandleGet(pTq->tqMeta, consumerId);
|
STqConsumer* pConsumer = tqHandleGet(pTq->tqMeta, consumerId);
|
||||||
if (pConsumer == NULL) {
|
if (pConsumer == NULL) {
|
||||||
vWarn("tmq poll: consumer %ld (epoch %d) not found in vg %d", consumerId, pReq->epoch, pTq->pVnode->vgId);
|
vWarn("tmq poll: consumer %ld (epoch %d) not found in vg %d", consumerId, pReq->epoch, TD_VID(pTq->pVnode));
|
||||||
pMsg->pCont = NULL;
|
pMsg->pCont = NULL;
|
||||||
pMsg->contLen = 0;
|
pMsg->contLen = 0;
|
||||||
pMsg->code = -1;
|
pMsg->code = -1;
|
||||||
|
@ -479,7 +477,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
}
|
}
|
||||||
if (pTopic == NULL) {
|
if (pTopic == NULL) {
|
||||||
vWarn("tmq poll: consumer %ld (epoch %d) topic %s not found in vg %d", consumerId, pReq->epoch, pReq->topic,
|
vWarn("tmq poll: consumer %ld (epoch %d) topic %s not found in vg %d", consumerId, pReq->epoch, pReq->topic,
|
||||||
pTq->pVnode->vgId);
|
TD_VID(pTq->pVnode));
|
||||||
pMsg->pCont = NULL;
|
pMsg->pCont = NULL;
|
||||||
pMsg->contLen = 0;
|
pMsg->contLen = 0;
|
||||||
pMsg->code = -1;
|
pMsg->code = -1;
|
||||||
|
@ -488,7 +486,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
vDebug("poll topic %s from consumer %ld (epoch %d) vg %d", pTopic->topicName, consumerId, pReq->epoch,
|
vDebug("poll topic %s from consumer %ld (epoch %d) vg %d", pTopic->topicName, consumerId, pReq->epoch,
|
||||||
pTq->pVnode->vgId);
|
TD_VID(pTq->pVnode));
|
||||||
|
|
||||||
rspV2.reqOffset = pReq->currentOffset;
|
rspV2.reqOffset = pReq->currentOffset;
|
||||||
rspV2.skipLogNum = 0;
|
rspV2.skipLogNum = 0;
|
||||||
|
@ -499,7 +497,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
consumerEpoch = atomic_load_32(&pConsumer->epoch);
|
consumerEpoch = atomic_load_32(&pConsumer->epoch);
|
||||||
if (consumerEpoch > reqEpoch) {
|
if (consumerEpoch > reqEpoch) {
|
||||||
vDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, found new consumer epoch %d discard req epoch %d",
|
vDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, found new consumer epoch %d discard req epoch %d",
|
||||||
consumerId, pReq->epoch, pTq->pVnode->vgId, fetchOffset, consumerEpoch, reqEpoch);
|
consumerId, pReq->epoch, TD_VID(pTq->pVnode), fetchOffset, consumerEpoch, reqEpoch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SWalReadHead* pHead;
|
SWalReadHead* pHead;
|
||||||
|
@ -508,11 +506,11 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
// if data inserted during waiting, launch query and
|
// if data inserted during waiting, launch query and
|
||||||
// response to user
|
// response to user
|
||||||
vDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", consumerId, pReq->epoch,
|
vDebug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", consumerId, pReq->epoch,
|
||||||
pTq->pVnode->vgId, fetchOffset);
|
TD_VID(pTq->pVnode), fetchOffset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch,
|
vDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch,
|
||||||
pTq->pVnode->vgId, fetchOffset, pHead->msgType);
|
TD_VID(pTq->pVnode), fetchOffset, pHead->msgType);
|
||||||
/*int8_t pos = fetchOffset % TQ_BUFFER_SIZE;*/
|
/*int8_t pos = fetchOffset % TQ_BUFFER_SIZE;*/
|
||||||
/*pHead = pTopic->pReadhandle->pHead;*/
|
/*pHead = pTopic->pReadhandle->pHead;*/
|
||||||
if (pHead->msgType == TDMT_VND_SUBMIT) {
|
if (pHead->msgType == TDMT_VND_SUBMIT) {
|
||||||
|
@ -537,7 +535,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
|
|
||||||
if (taosArrayGetSize(pRes) == 0) {
|
if (taosArrayGetSize(pRes) == 0) {
|
||||||
vDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d skip log %ld since not wanted", consumerId,
|
vDebug("tmq poll: consumer %ld (epoch %d) iter log, vg %d skip log %ld since not wanted", consumerId,
|
||||||
pReq->epoch, pTq->pVnode->vgId, fetchOffset);
|
pReq->epoch, TD_VID(pTq->pVnode), fetchOffset);
|
||||||
fetchOffset++;
|
fetchOffset++;
|
||||||
rspV2.skipLogNum++;
|
rspV2.skipLogNum++;
|
||||||
taosArrayDestroy(pRes);
|
taosArrayDestroy(pRes);
|
||||||
|
@ -597,7 +595,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
pMsg->pCont = buf;
|
pMsg->pCont = buf;
|
||||||
pMsg->contLen = msgLen;
|
pMsg->contLen = msgLen;
|
||||||
pMsg->code = 0;
|
pMsg->code = 0;
|
||||||
vDebug("vg %d offset %ld msgType %d from consumer %ld (epoch %d) actual rsp", pTq->pVnode->vgId, fetchOffset,
|
vDebug("vg %d offset %ld msgType %d from consumer %ld (epoch %d) actual rsp", TD_VID(pTq->pVnode), fetchOffset,
|
||||||
pHead->msgType, consumerId, pReq->epoch);
|
pHead->msgType, consumerId, pReq->epoch);
|
||||||
tmsgSendRsp(pMsg);
|
tmsgSendRsp(pMsg);
|
||||||
taosMemoryFree(pHead);
|
taosMemoryFree(pHead);
|
||||||
|
@ -631,7 +629,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
|
||||||
pMsg->contLen = tlen;
|
pMsg->contLen = tlen;
|
||||||
pMsg->code = 0;
|
pMsg->code = 0;
|
||||||
tmsgSendRsp(pMsg);
|
tmsgSendRsp(pMsg);
|
||||||
vDebug("vg %d offset %ld from consumer %ld (epoch %d) not rsp", pTq->pVnode->vgId, fetchOffset, consumerId,
|
vDebug("vg %d offset %ld from consumer %ld (epoch %d) not rsp", TD_VID(pTq->pVnode), fetchOffset, consumerId,
|
||||||
pReq->epoch);
|
pReq->epoch);
|
||||||
/*}*/
|
/*}*/
|
||||||
|
|
||||||
|
@ -742,7 +740,7 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) {
|
||||||
pTopic->buffer.output[i].task = qCreateStreamExecTaskInfo(req.qmsg, &handle);
|
pTopic->buffer.output[i].task = qCreateStreamExecTaskInfo(req.qmsg, &handle);
|
||||||
ASSERT(pTopic->buffer.output[i].task);
|
ASSERT(pTopic->buffer.output[i].task);
|
||||||
}
|
}
|
||||||
vDebug("set topic %s to consumer %ld on vg %d", pTopic->topicName, req.consumerId, pTq->pVnode->vgId);
|
vDebug("set topic %s to consumer %ld on vg %d", pTopic->topicName, req.consumerId, TD_VID(pTq->pVnode));
|
||||||
taosArrayPush(pConsumer->topics, pTopic);
|
taosArrayPush(pConsumer->topics, pTopic);
|
||||||
if (create) {
|
if (create) {
|
||||||
tqHandleMovePut(pTq->tqMeta, req.consumerId, pConsumer);
|
tqHandleMovePut(pTq->tqMeta, req.consumerId, pConsumer);
|
||||||
|
|
|
@ -1250,7 +1250,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
||||||
&(pBlockCol->sum), &(pBlockCol->minIndex), &(pBlockCol->maxIndex),
|
&(pBlockCol->sum), &(pBlockCol->minIndex), &(pBlockCol->maxIndex),
|
||||||
&(pBlockCol->numOfNull));
|
&(pBlockCol->numOfNull));
|
||||||
#endif
|
#endif
|
||||||
(*tDataTypes[pDataCol->type].statisFunc)(pDataCol->pData, rowsToWrite, &(pAggrBlkCol->min), &(pAggrBlkCol->max),
|
(*tDataTypes[pDataCol->type].statisFunc)(pDataCol->pBitmap, pDataCol->pData, rowsToWrite, &(pAggrBlkCol->min), &(pAggrBlkCol->max),
|
||||||
&(pAggrBlkCol->sum), &(pAggrBlkCol->minIndex), &(pAggrBlkCol->maxIndex),
|
&(pAggrBlkCol->sum), &(pAggrBlkCol->minIndex), &(pAggrBlkCol->maxIndex),
|
||||||
&(pAggrBlkCol->numOfNull));
|
&(pAggrBlkCol->numOfNull));
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ typedef struct STsdbReadHandle {
|
||||||
SQueryFilePos cur; // current position
|
SQueryFilePos cur; // current position
|
||||||
int16_t order;
|
int16_t order;
|
||||||
STimeWindow window; // the primary query time window that applies to all queries
|
STimeWindow window; // the primary query time window that applies to all queries
|
||||||
SDataStatis* statis; // query level statistics, only one table block statistics info exists at any time
|
SColumnDataAgg* statis; // query level statistics, only one table block statistics info exists at any time
|
||||||
int32_t numOfBlocks;
|
int32_t numOfBlocks;
|
||||||
SArray* pColumns; // column list, SColumnInfoData array list
|
SArray* pColumns; // column list, SColumnInfoData array list
|
||||||
bool locateStart;
|
bool locateStart;
|
||||||
|
@ -377,7 +377,7 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, STsdbQueryCond* pCond,
|
||||||
|
|
||||||
if (pCond->numOfCols > 0) {
|
if (pCond->numOfCols > 0) {
|
||||||
// allocate buffer in order to load data blocks from file
|
// allocate buffer in order to load data blocks from file
|
||||||
pReadHandle->statis = taosMemoryCalloc(pCond->numOfCols, sizeof(SDataStatis));
|
pReadHandle->statis = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnDataAgg));
|
||||||
if (pReadHandle->statis == NULL) {
|
if (pReadHandle->statis == NULL) {
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
@ -477,7 +477,7 @@ void tsdbResetQueryHandle(tsdbReaderT queryHandle, STsdbQueryCond* pCond) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate buffer in order to load data blocks from file
|
// allocate buffer in order to load data blocks from file
|
||||||
memset(pTsdbReadHandle->statis, 0, sizeof(SDataStatis));
|
memset(pTsdbReadHandle->statis, 0, sizeof(SColumnDataAgg));
|
||||||
|
|
||||||
tsdbInitDataBlockLoadInfo(&pTsdbReadHandle->dataBlockLoadInfo);
|
tsdbInitDataBlockLoadInfo(&pTsdbReadHandle->dataBlockLoadInfo);
|
||||||
tsdbInitCompBlockLoadInfo(&pTsdbReadHandle->compBlockLoadInfo);
|
tsdbInitCompBlockLoadInfo(&pTsdbReadHandle->compBlockLoadInfo);
|
||||||
|
@ -505,7 +505,7 @@ void tsdbResetQueryHandleForNewTable(tsdbReaderT queryHandle, STsdbQueryCond* pC
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate buffer in order to load data blocks from file
|
// allocate buffer in order to load data blocks from file
|
||||||
memset(pTsdbReadHandle->statis, 0, sizeof(SDataStatis));
|
memset(pTsdbReadHandle->statis, 0, sizeof(SColumnDataAgg));
|
||||||
|
|
||||||
tsdbInitDataBlockLoadInfo(&pTsdbReadHandle->dataBlockLoadInfo);
|
tsdbInitDataBlockLoadInfo(&pTsdbReadHandle->dataBlockLoadInfo);
|
||||||
tsdbInitCompBlockLoadInfo(&pTsdbReadHandle->compBlockLoadInfo);
|
tsdbInitCompBlockLoadInfo(&pTsdbReadHandle->compBlockLoadInfo);
|
||||||
|
@ -3222,7 +3222,7 @@ void tsdbRetrieveDataBlockInfo(tsdbReaderT* pTsdbReadHandle, SDataBlockInfo* pDa
|
||||||
/*
|
/*
|
||||||
* return null for mixed data block, if not a complete file data block, the statistics value will always return NULL
|
* return null for mixed data block, if not a complete file data block, the statistics value will always return NULL
|
||||||
*/
|
*/
|
||||||
int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SDataStatis** pBlockStatis) {
|
int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SColumnDataAgg** pBlockStatis) {
|
||||||
STsdbReadHandle* pHandle = (STsdbReadHandle*)pTsdbReadHandle;
|
STsdbReadHandle* pHandle = (STsdbReadHandle*)pTsdbReadHandle;
|
||||||
|
|
||||||
SQueryFilePos* c = &pHandle->cur;
|
SQueryFilePos* c = &pHandle->cur;
|
||||||
|
@ -3252,7 +3252,7 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SDataStati
|
||||||
int16_t* colIds = pHandle->defaultLoadColumn->pData;
|
int16_t* colIds = pHandle->defaultLoadColumn->pData;
|
||||||
|
|
||||||
size_t numOfCols = QH_GET_NUM_OF_COLS(pHandle);
|
size_t numOfCols = QH_GET_NUM_OF_COLS(pHandle);
|
||||||
memset(pHandle->statis, 0, numOfCols * sizeof(SDataStatis));
|
memset(pHandle->statis, 0, numOfCols * sizeof(SColumnDataAgg));
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
pHandle->statis[i].colId = colIds[i];
|
pHandle->statis[i].colId = colIds[i];
|
||||||
}
|
}
|
||||||
|
@ -3260,7 +3260,7 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SDataStati
|
||||||
tsdbGetBlockStatis(&pHandle->rhelper, pHandle->statis, (int)numOfCols, pBlockInfo->compBlock);
|
tsdbGetBlockStatis(&pHandle->rhelper, pHandle->statis, (int)numOfCols, pBlockInfo->compBlock);
|
||||||
|
|
||||||
// always load the first primary timestamp column data
|
// always load the first primary timestamp column data
|
||||||
SDataStatis* pPrimaryColStatis = &pHandle->statis[0];
|
SColumnDataAgg* pPrimaryColStatis = &pHandle->statis[0];
|
||||||
assert(pPrimaryColStatis->colId == PRIMARYKEY_TIMESTAMP_COL_ID);
|
assert(pPrimaryColStatis->colId == PRIMARYKEY_TIMESTAMP_COL_ID);
|
||||||
|
|
||||||
pPrimaryColStatis->numOfNull = 0;
|
pPrimaryColStatis->numOfNull = 0;
|
||||||
|
|
|
@ -433,7 +433,7 @@ void *tsdbDecodeSBlockIdx(void *buf, SBlockIdx *pIdx) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsdbGetBlockStatis(SReadH *pReadh, SDataStatis *pStatis, int numOfCols, SBlock *pBlock) {
|
void tsdbGetBlockStatis(SReadH *pReadh, SColumnDataAgg *pStatis, int numOfCols, SBlock *pBlock) {
|
||||||
#ifdef TD_REFACTOR_3
|
#ifdef TD_REFACTOR_3
|
||||||
SBlockData *pBlockData = pReadh->pBlkData;
|
SBlockData *pBlockData = pReadh->pBlkData;
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,6 @@ int vnodeCheckCfg(const SVnodeCfg *pCfg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1 //======================================================================
|
|
||||||
void vnodeOptionsCopy(SVnodeCfg *pDest, const SVnodeCfg *pSrc) {
|
|
||||||
memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeCfg));
|
|
||||||
}
|
|
||||||
|
|
||||||
int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) {
|
int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) {
|
||||||
uint32_t hashValue = 0;
|
uint32_t hashValue = 0;
|
||||||
|
|
||||||
|
@ -47,5 +42,3 @@ int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) {
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
|
@ -108,7 +108,7 @@ int vnodeLoadInfo(const char *dir, SVnodeInfo *pInfo) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
pData = taosMemoryMalloc(size);
|
pData = taosMemoryMalloc(size + 1);
|
||||||
if (pData == NULL) {
|
if (pData == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -119,6 +119,8 @@ int vnodeLoadInfo(const char *dir, SVnodeInfo *pInfo) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pData[size] = '\0';
|
||||||
|
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
|
|
||||||
// decode info
|
// decode info
|
||||||
|
@ -202,6 +204,16 @@ static int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
|
||||||
if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "wal.vgId", pCfg->walCfg.vgId) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "wal.retentionPeriod", pCfg->walCfg.retentionPeriod) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "wal.rollPeriod", pCfg->walCfg.rollPeriod) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "wal.retentionSize", pCfg->walCfg.retentionSize) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "wal.segSize", pCfg->walCfg.segSize) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "wal.level", pCfg->walCfg.level) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "hashBegin", pCfg->hashBegin) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "hashEnd", pCfg->hashEnd) < 0) return -1;
|
||||||
|
if (tjsonAddIntegerToObject(pJson, "hashMethod", pCfg->hashMethod) < 0) return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -229,6 +241,16 @@ static int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
||||||
if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1;
|
if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1;
|
if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1;
|
if (tjsonGetNumberValue(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1;
|
||||||
|
if (tjsonGetNumberValue(pJson, "wal.vgId", pCfg->walCfg.vgId) < 0) return -1;
|
||||||
|
if (tjsonGetNumberValue(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod) < 0) return -1;
|
||||||
|
if (tjsonGetNumberValue(pJson, "wal.retentionPeriod", pCfg->walCfg.retentionPeriod) < 0) return -1;
|
||||||
|
if (tjsonGetNumberValue(pJson, "wal.rollPeriod", pCfg->walCfg.rollPeriod) < 0) return -1;
|
||||||
|
if (tjsonGetNumberValue(pJson, "wal.retentionSize", pCfg->walCfg.retentionSize) < 0) return -1;
|
||||||
|
if (tjsonGetNumberValue(pJson, "wal.segSize", pCfg->walCfg.segSize) < 0) return -1;
|
||||||
|
if (tjsonGetNumberValue(pJson, "wal.level", pCfg->walCfg.level) < 0) return -1;
|
||||||
|
if (tjsonGetNumberValue(pJson, "hashBegin", pCfg->hashBegin) < 0) return -1;
|
||||||
|
if (tjsonGetNumberValue(pJson, "hashEnd", pCfg->hashEnd) < 0) return -1;
|
||||||
|
if (tjsonGetNumberValue(pJson, "hashMethod", pCfg->hashMethod) < 0) return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +308,7 @@ _err:
|
||||||
static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo) {
|
static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo) {
|
||||||
SJson *pJson = NULL;
|
SJson *pJson = NULL;
|
||||||
|
|
||||||
pJson = tjsonCreateObject();
|
pJson = tjsonParse(pData);
|
||||||
if (pJson == NULL) {
|
if (pJson == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,6 @@
|
||||||
|
|
||||||
#include "vnodeInt.h"
|
#include "vnodeInt.h"
|
||||||
|
|
||||||
static SVnode *vnodeNew(const char *path, const SVnodeCfg *pVnodeCfg);
|
|
||||||
static void vnodeFree(SVnode *pVnode);
|
|
||||||
static int vnodeOpenImpl(SVnode *pVnode);
|
|
||||||
static void vnodeCloseImpl(SVnode *pVnode);
|
|
||||||
|
|
||||||
int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
|
int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
|
||||||
SVnodeInfo info = {0};
|
SVnodeInfo info = {0};
|
||||||
char dir[TSDB_FILENAME_LEN];
|
char dir[TSDB_FILENAME_LEN];
|
||||||
|
@ -51,141 +46,117 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) {
|
void vnodeDestroy(const char *path, STfs *pTfs) { tfsRmdir(pTfs, path); }
|
||||||
|
|
||||||
|
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
SVnode *pVnode = NULL;
|
SVnode *pVnode = NULL;
|
||||||
|
SVnodeInfo info = {0};
|
||||||
|
char dir[TSDB_FILENAME_LEN];
|
||||||
|
char tdir[TSDB_FILENAME_LEN * 2];
|
||||||
|
int ret;
|
||||||
|
|
||||||
// Set default options
|
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path);
|
||||||
SVnodeCfg cfg = vnodeCfgDefault;
|
|
||||||
if (pVnodeCfg != NULL) {
|
|
||||||
cfg.vgId = pVnodeCfg->vgId;
|
|
||||||
cfg.msgCb = pVnodeCfg->msgCb;
|
|
||||||
cfg.pTfs = pVnodeCfg->pTfs;
|
|
||||||
cfg.dbId = pVnodeCfg->dbId;
|
|
||||||
cfg.hashBegin = pVnodeCfg->hashBegin;
|
|
||||||
cfg.hashEnd = pVnodeCfg->hashEnd;
|
|
||||||
cfg.hashMethod = pVnodeCfg->hashMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate options
|
// load vnode info
|
||||||
if (vnodeCheckCfg(&cfg) < 0) {
|
ret = vnodeLoadInfo(dir, &info);
|
||||||
// TODO
|
if (ret < 0) {
|
||||||
|
vError("failed to open vnode from %s since %s", path, tstrerror(terrno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the handle
|
// create handle
|
||||||
pVnode = vnodeNew(path, &cfg);
|
pVnode = (SVnode *)taosMemoryCalloc(1, sizeof(*pVnode) + strlen(path) + 1);
|
||||||
if (pVnode == NULL) {
|
if (pVnode == NULL) {
|
||||||
// TODO: handle error
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
vError("vgId: %d failed to open vnode since %s", info.config.vgId, tstrerror(terrno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMkDir(path);
|
pVnode->path = (char *)&pVnode[1];
|
||||||
|
strcpy(pVnode->path, path);
|
||||||
|
pVnode->config = info.config;
|
||||||
|
pVnode->state.committed = info.state.committed;
|
||||||
|
pVnode->state.processed = pVnode->state.applied = pVnode->state.committed;
|
||||||
|
pVnode->pTfs = pTfs;
|
||||||
|
pVnode->msgCb = msgCb;
|
||||||
|
|
||||||
// Open the vnode
|
tsem_init(&(pVnode->canCommit), 0, 1);
|
||||||
if (vnodeOpenImpl(pVnode) < 0) {
|
|
||||||
// TODO: handle error
|
// open buffer pool
|
||||||
return NULL;
|
if (vnodeOpenBufPool(pVnode) < 0) {
|
||||||
|
vError("vgId: %d failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// open meta
|
||||||
|
if (metaOpen(pVnode, &pVnode->pMeta) < 0) {
|
||||||
|
vError("vgId: %d failed to open vnode meta since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// open tsdb
|
||||||
|
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TSDB_DIR);
|
||||||
|
pVnode->pTsdb =
|
||||||
|
tsdbOpen(tdir, TD_VID(pVnode), &(pVnode->config.tsdbCfg), vBufPoolGetMAF(pVnode), pVnode->pMeta, pVnode->pTfs);
|
||||||
|
if (pVnode->pTsdb == NULL) {
|
||||||
|
vError("vgId: %d failed to open vnode tsdb since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// open wal
|
||||||
|
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
|
||||||
|
pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
|
||||||
|
if (pVnode->pWal == NULL) {
|
||||||
|
vError("vgId: %d failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// open tq
|
||||||
|
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
|
||||||
|
pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal, pVnode->pMeta, vBufPoolGetMAF(pVnode));
|
||||||
|
if (pVnode->pTq == NULL) {
|
||||||
|
vError("vgId: %d failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// open query
|
||||||
|
if (vnodeQueryOpen(pVnode)) {
|
||||||
|
vError("vgId: %d failed to open vnode query since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (vnodeBegin() < 0) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return pVnode;
|
return pVnode;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
if (pVnode->pQuery) vnodeQueryClose(pVnode);
|
||||||
|
if (pVnode->pTq) tqClose(pVnode->pTq);
|
||||||
|
if (pVnode->pWal) walClose(pVnode->pWal);
|
||||||
|
if (pVnode->pTsdb) tsdbClose(pVnode->pTsdb);
|
||||||
|
if (pVnode->pMeta) metaClose(pVnode->pMeta);
|
||||||
|
tsem_destroy(&(pVnode->canCommit));
|
||||||
|
taosMemoryFree(pVnode);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeClose(SVnode *pVnode) {
|
void vnodeClose(SVnode *pVnode) {
|
||||||
if (pVnode) {
|
if (pVnode) {
|
||||||
vnodeCloseImpl(pVnode);
|
// commit (TODO: use option to control)
|
||||||
vnodeFree(pVnode);
|
vnodeSyncCommit(pVnode);
|
||||||
}
|
// close vnode
|
||||||
}
|
vnodeQueryClose(pVnode);
|
||||||
|
walClose(pVnode->pWal);
|
||||||
void vnodeDestroy(const char *path) { taosRemoveDir(path); }
|
tqClose(pVnode->pTq);
|
||||||
|
tsdbClose(pVnode->pTsdb);
|
||||||
/* ------------------------ STATIC METHODS ------------------------ */
|
metaClose(pVnode->pMeta);
|
||||||
static SVnode *vnodeNew(const char *path, const SVnodeCfg *pVnodeCfg) {
|
vnodeCloseBufPool(pVnode);
|
||||||
SVnode *pVnode = NULL;
|
// destroy handle
|
||||||
|
|
||||||
pVnode = (SVnode *)taosMemoryCalloc(1, sizeof(*pVnode));
|
|
||||||
if (pVnode == NULL) {
|
|
||||||
// TODO
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pVnode->vgId = pVnodeCfg->vgId;
|
|
||||||
pVnode->msgCb = pVnodeCfg->msgCb;
|
|
||||||
pVnode->pTfs = pVnodeCfg->pTfs;
|
|
||||||
pVnode->path = strdup(path);
|
|
||||||
vnodeOptionsCopy(&(pVnode->config), pVnodeCfg);
|
|
||||||
|
|
||||||
tsem_init(&(pVnode->canCommit), 0, 1);
|
|
||||||
|
|
||||||
return pVnode;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vnodeFree(SVnode *pVnode) {
|
|
||||||
if (pVnode) {
|
|
||||||
tsem_destroy(&(pVnode->canCommit));
|
tsem_destroy(&(pVnode->canCommit));
|
||||||
taosMemoryFreeClear(pVnode->path);
|
|
||||||
taosMemoryFree(pVnode);
|
taosMemoryFree(pVnode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeOpenImpl(SVnode *pVnode) {
|
|
||||||
char dir[TSDB_FILENAME_LEN];
|
|
||||||
|
|
||||||
if (vnodeOpenBufPool(pVnode) < 0) {
|
|
||||||
// TODO: handle error
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open meta
|
|
||||||
sprintf(dir, "%s/meta", pVnode->path);
|
|
||||||
pVnode->pMeta = metaOpen(dir, &(pVnode->config.metaCfg), vBufPoolGetMAF(pVnode));
|
|
||||||
if (pVnode->pMeta == NULL) {
|
|
||||||
// TODO: handle error
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open tsdb
|
|
||||||
sprintf(dir, "%s/tsdb", pVnode->path);
|
|
||||||
pVnode->pTsdb =
|
|
||||||
tsdbOpen(dir, pVnode->vgId, &(pVnode->config.tsdbCfg), vBufPoolGetMAF(pVnode), pVnode->pMeta, pVnode->pTfs);
|
|
||||||
if (pVnode->pTsdb == NULL) {
|
|
||||||
// TODO: handle error
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open WAL
|
|
||||||
sprintf(dir, "%s/wal", pVnode->path);
|
|
||||||
pVnode->pWal = walOpen(dir, &(pVnode->config.walCfg));
|
|
||||||
if (pVnode->pWal == NULL) {
|
|
||||||
// TODO: handle error
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open TQ
|
|
||||||
sprintf(dir, "%s/tq", pVnode->path);
|
|
||||||
pVnode->pTq = tqOpen(dir, pVnode, pVnode->pWal, pVnode->pMeta, &(pVnode->config.tqCfg), vBufPoolGetMAF(pVnode));
|
|
||||||
if (pVnode->pTq == NULL) {
|
|
||||||
// TODO: handle error
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open Query
|
|
||||||
if (vnodeQueryOpen(pVnode)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vnodeCloseImpl(SVnode *pVnode) {
|
|
||||||
vnodeSyncCommit(pVnode);
|
|
||||||
if (pVnode) {
|
|
||||||
vnodeCloseBufPool(pVnode);
|
|
||||||
metaClose(pVnode->pMeta);
|
|
||||||
tsdbClose(pVnode->pTsdb);
|
|
||||||
tqClose(pVnode->pTq);
|
|
||||||
walClose(pVnode->pWal);
|
|
||||||
vnodeQueryClose(pVnode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "vnodeInt.h"
|
#include "vnodeInt.h"
|
||||||
|
|
||||||
int vnodeQueryOpen(SVnode *pVnode) {
|
int vnodeQueryOpen(SVnode *pVnode) {
|
||||||
return qWorkerInit(NODE_TYPE_VNODE, pVnode->vgId, NULL, (void **)&pVnode->pQuery, &pVnode->msgCb);
|
return qWorkerInit(NODE_TYPE_VNODE, TD_VID(pVnode), NULL, (void **)&pVnode->pQuery, &pVnode->msgCb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeQueryClose(SVnode *pVnode) { qWorkerDestroy((void **)&pVnode->pQuery); }
|
void vnodeQueryClose(SVnode *pVnode) { qWorkerDestroy((void **)&pVnode->pQuery); }
|
||||||
|
@ -101,7 +101,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
metaRsp.numOfColumns = nCols;
|
metaRsp.numOfColumns = nCols;
|
||||||
metaRsp.tableType = pTbCfg->type;
|
metaRsp.tableType = pTbCfg->type;
|
||||||
metaRsp.tuid = uid;
|
metaRsp.tuid = uid;
|
||||||
metaRsp.vgId = pVnode->vgId;
|
metaRsp.vgId = TD_VID(pVnode);
|
||||||
|
|
||||||
memcpy(metaRsp.pSchemas, pSW->pSchema, sizeof(SSchema) * pSW->nCols);
|
memcpy(metaRsp.pSchemas, pSW->pSchema, sizeof(SSchema) * pSW->nCols);
|
||||||
if (nTagCols) {
|
if (nTagCols) {
|
||||||
|
@ -151,7 +151,7 @@ _exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
||||||
pLoad->vgId = pVnode->vgId;
|
pLoad->vgId = TD_VID(pVnode);
|
||||||
pLoad->role = TAOS_SYNC_STATE_LEADER;
|
pLoad->role = TAOS_SYNC_STATE_LEADER;
|
||||||
pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
|
pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
|
||||||
pLoad->numOfTimeSeries = 400;
|
pLoad->numOfTimeSeries = 400;
|
||||||
|
|
|
@ -36,7 +36,7 @@ void vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs) {
|
||||||
if (walWrite(pVnode->pWal, ver, pRpc->msgType, pRpc->pCont, pRpc->contLen) < 0) {
|
if (walWrite(pVnode->pWal, ver, pRpc->msgType, pRpc->pCont, pRpc->contLen) < 0) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
/*ASSERT(false);*/
|
/*ASSERT(false);*/
|
||||||
vError("vnode:%d write wal error since %s", pVnode->vgId, terrstr());
|
vError("vnode:%d write wal error since %s", TD_VID(pVnode), terrstr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,12 +73,12 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
case TDMT_VND_ALTER_STB:
|
case TDMT_VND_ALTER_STB:
|
||||||
return vnodeProcessAlterStbReq(pVnode, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)));
|
return vnodeProcessAlterStbReq(pVnode, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)));
|
||||||
case TDMT_VND_DROP_STB:
|
case TDMT_VND_DROP_STB:
|
||||||
vTrace("vgId:%d, process drop stb req", pVnode->vgId);
|
vTrace("vgId:%d, process drop stb req", TD_VID(pVnode));
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_DROP_TABLE:
|
case TDMT_VND_DROP_TABLE:
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_SUBMIT:
|
case TDMT_VND_SUBMIT:
|
||||||
/*printf("vnode %d write data %ld\n", pVnode->vgId, ver);*/
|
/*printf("vnode %d write data %ld\n", TD_VID(pVnode), ver);*/
|
||||||
if (pVnode->config.streamMode == 0) {
|
if (pVnode->config.streamMode == 0) {
|
||||||
*pRsp = taosMemoryCalloc(1, sizeof(SRpcMsg));
|
*pRsp = taosMemoryCalloc(1, sizeof(SRpcMsg));
|
||||||
(*pRsp)->handle = pMsg->handle;
|
(*pRsp)->handle = pMsg->handle;
|
||||||
|
@ -245,7 +245,7 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
|
||||||
|
|
||||||
if (metaCreateTable(pVnode->pMeta, pCreateTbReq) < 0) {
|
if (metaCreateTable(pVnode->pMeta, pCreateTbReq) < 0) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
vError("vgId:%d, failed to create table: %s", pVnode->vgId, pCreateTbReq->name);
|
vError("vgId:%d, failed to create table: %s", TD_VID(pVnode), pCreateTbReq->name);
|
||||||
}
|
}
|
||||||
// TODO: to encapsule a free API
|
// TODO: to encapsule a free API
|
||||||
taosMemoryFree(pCreateTbReq->name);
|
taosMemoryFree(pCreateTbReq->name);
|
||||||
|
@ -268,7 +268,7 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vTrace("vgId:%d process create %" PRIzu " tables", pVnode->vgId, taosArrayGetSize(vCreateTbBatchReq.pArray));
|
vTrace("vgId:%d process create %" PRIzu " tables", TD_VID(pVnode), taosArrayGetSize(vCreateTbBatchReq.pArray));
|
||||||
taosArrayDestroy(vCreateTbBatchReq.pArray);
|
taosArrayDestroy(vCreateTbBatchReq.pArray);
|
||||||
if (vCreateTbBatchRsp.rspList) {
|
if (vCreateTbBatchRsp.rspList) {
|
||||||
int32_t contLen = tSerializeSVCreateTbBatchRsp(NULL, 0, &vCreateTbBatchRsp);
|
int32_t contLen = tSerializeSVCreateTbBatchRsp(NULL, 0, &vCreateTbBatchRsp);
|
||||||
|
@ -289,7 +289,7 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
|
||||||
|
|
||||||
static int vnodeProcessAlterStbReq(SVnode *pVnode, void *pReq) {
|
static int vnodeProcessAlterStbReq(SVnode *pVnode, void *pReq) {
|
||||||
SVCreateTbReq vAlterTbReq = {0};
|
SVCreateTbReq vAlterTbReq = {0};
|
||||||
vTrace("vgId:%d, process alter stb req", pVnode->vgId);
|
vTrace("vgId:%d, process alter stb req", TD_VID(pVnode));
|
||||||
tDeserializeSVCreateTbReq(pReq, &vAlterTbReq);
|
tDeserializeSVCreateTbReq(pReq, &vAlterTbReq);
|
||||||
// TODO: to encapsule a free API
|
// TODO: to encapsule a free API
|
||||||
taosMemoryFree(vAlterTbReq.stbCfg.pSchema);
|
taosMemoryFree(vAlterTbReq.stbCfg.pSchema);
|
||||||
|
|
|
@ -8,7 +8,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
||||||
ADD_EXECUTABLE(catalogTest ${SOURCE_LIST})
|
ADD_EXECUTABLE(catalogTest ${SOURCE_LIST})
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
catalogTest
|
catalogTest
|
||||||
PUBLIC os util common catalog transport gtest qcom taos
|
PUBLIC os util common catalog transport gtest qcom taos_static
|
||||||
)
|
)
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(
|
TARGET_INCLUDE_DIRECTORIES(
|
||||||
|
|
|
@ -316,6 +316,9 @@ int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t getIntervalPrecision(SIntervalPhysiNode* pIntNode) {
|
||||||
|
return ((SColumnNode*)pIntNode->window.pTspk)->node.resType.precision;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) {
|
int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
|
@ -658,10 +661,10 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pIntNode->window.node.pOutputDataBlockDesc->outputRowSize);
|
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pIntNode->window.node.pOutputDataBlockDesc->outputRowSize);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
|
uint8_t precision = getIntervalPrecision(pIntNode);
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT, INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, pIntNode->precision),
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT, INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, precision),
|
||||||
pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(pIntNode->precision),
|
pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(precision),
|
||||||
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, pIntNode->precision), pIntNode->slidingUnit);
|
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, precision), pIntNode->slidingUnit);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,8 @@ typedef struct SResultRowInfo {
|
||||||
SResultRowPosition *pPosition;
|
SResultRowPosition *pPosition;
|
||||||
int32_t size; // number of result set
|
int32_t size; // number of result set
|
||||||
int32_t capacity; // max capacity
|
int32_t capacity; // max capacity
|
||||||
int32_t curPos; // current active result row index of pResult list
|
// int32_t curPos; // current active result row index of pResult list
|
||||||
|
SResultRowPosition cur;
|
||||||
} SResultRowInfo;
|
} SResultRowInfo;
|
||||||
|
|
||||||
struct STaskAttr;
|
struct STaskAttr;
|
||||||
|
|
|
@ -81,11 +81,11 @@ typedef struct SResultInfo { // TODO refactor
|
||||||
} SResultInfo;
|
} SResultInfo;
|
||||||
|
|
||||||
typedef struct STableQueryInfo {
|
typedef struct STableQueryInfo {
|
||||||
TSKEY lastKey; // last check ts
|
TSKEY lastKey; // last check ts, todo remove it later
|
||||||
uint64_t uid; // table uid
|
SResultRowPosition pos; // current active time window
|
||||||
int32_t groupIndex; // group id in table list
|
// int32_t groupIndex; // group id in table list
|
||||||
// SVariant tag;
|
// SVariant tag;
|
||||||
SResultRowInfo resInfo; // result info
|
// SResultRowInfo resInfo; // result info
|
||||||
} STableQueryInfo;
|
} STableQueryInfo;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -133,7 +133,8 @@ typedef struct STaskCostInfo {
|
||||||
uint32_t totalBlocks;
|
uint32_t totalBlocks;
|
||||||
uint32_t loadBlocks;
|
uint32_t loadBlocks;
|
||||||
uint32_t loadBlockStatis;
|
uint32_t loadBlockStatis;
|
||||||
uint32_t discardBlocks;
|
uint32_t skipBlocks;
|
||||||
|
uint32_t filterOutBlocks;
|
||||||
uint64_t elapsedTime;
|
uint64_t elapsedTime;
|
||||||
uint64_t firstStageMergeTime;
|
uint64_t firstStageMergeTime;
|
||||||
uint64_t winInfoSize;
|
uint64_t winInfoSize;
|
||||||
|
@ -271,6 +272,7 @@ typedef struct SOperatorInfo {
|
||||||
SResultInfo resultInfo;
|
SResultInfo resultInfo;
|
||||||
struct SOperatorInfo** pDownstream; // downstram pointer list
|
struct SOperatorInfo** pDownstream; // downstram pointer list
|
||||||
int32_t numOfDownstream; // number of downstream. The value is always ONE expect for join operator
|
int32_t numOfDownstream; // number of downstream. The value is always ONE expect for join operator
|
||||||
|
// todo extract struct
|
||||||
__optr_open_fn_t _openFn; // DO NOT invoke this function directly
|
__optr_open_fn_t _openFn; // DO NOT invoke this function directly
|
||||||
__optr_fn_t getNextFn;
|
__optr_fn_t getNextFn;
|
||||||
__optr_fn_t getStreamResFn; // execute the aggregate in the stream model.
|
__optr_fn_t getStreamResFn; // execute the aggregate in the stream model.
|
||||||
|
@ -348,6 +350,8 @@ typedef struct STableScanInfo {
|
||||||
|
|
||||||
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
|
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
|
||||||
int32_t dataBlockLoadFlag;
|
int32_t dataBlockLoadFlag;
|
||||||
|
double sampleRatio; // data block sample ratio
|
||||||
|
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded.
|
||||||
} STableScanInfo;
|
} STableScanInfo;
|
||||||
|
|
||||||
typedef struct STagScanInfo {
|
typedef struct STagScanInfo {
|
||||||
|
@ -430,12 +434,16 @@ typedef struct STableIntervalOperatorInfo {
|
||||||
|
|
||||||
typedef struct SAggOperatorInfo {
|
typedef struct SAggOperatorInfo {
|
||||||
SOptrBasicInfo binfo;
|
SOptrBasicInfo binfo;
|
||||||
SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file
|
|
||||||
SAggSupporter aggSup;
|
SAggSupporter aggSup;
|
||||||
STableQueryInfo *current;
|
STableQueryInfo *current;
|
||||||
uint32_t groupId;
|
uint64_t groupId;
|
||||||
SGroupResInfo groupResInfo;
|
SGroupResInfo groupResInfo;
|
||||||
STableQueryInfo *pTableQueryInfo;
|
STableQueryInfo *pTableQueryInfo;
|
||||||
|
|
||||||
|
SExprInfo *pScalarExprInfo;
|
||||||
|
int32_t numOfScalarExpr; // the number of scalar expression before the aggregate function can be applied
|
||||||
|
SqlFunctionCtx *pScalarCtx; // scalar function requried sql function struct.
|
||||||
|
int32_t *rowCellInfoOffset; // offset value for each row result cell info
|
||||||
} SAggOperatorInfo;
|
} SAggOperatorInfo;
|
||||||
|
|
||||||
typedef struct SProjectOperatorInfo {
|
typedef struct SProjectOperatorInfo {
|
||||||
|
@ -594,10 +602,7 @@ typedef struct SJoinOperatorInfo {
|
||||||
SSDataBlock *pRight;
|
SSDataBlock *pRight;
|
||||||
int32_t rightPos;
|
int32_t rightPos;
|
||||||
SColumnInfo rightCol;
|
SColumnInfo rightCol;
|
||||||
|
|
||||||
SNode *pOnCondition;
|
SNode *pOnCondition;
|
||||||
// SJoinStatus *status;
|
|
||||||
// int32_t numOfUpstream;
|
|
||||||
// SRspResultInfo resultInfo;
|
// SRspResultInfo resultInfo;
|
||||||
} SJoinOperatorInfo;
|
} SJoinOperatorInfo;
|
||||||
|
|
||||||
|
@ -618,6 +623,8 @@ void doDestroyBasicInfo(SOptrBasicInfo* pInfo, int32_t numOfOutput);
|
||||||
int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData,
|
int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData,
|
||||||
int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total,
|
int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total,
|
||||||
SArray* pColList);
|
SArray* pColList);
|
||||||
|
void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key, int64_t keyFirst, int64_t keyLast, STimeWindow* win);
|
||||||
|
|
||||||
void doSetOperatorCompleted(SOperatorInfo* pOperator);
|
void doSetOperatorCompleted(SOperatorInfo* pOperator);
|
||||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock);
|
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock);
|
||||||
SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset);
|
SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset);
|
||||||
|
@ -625,10 +632,10 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
|
||||||
SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfCols, int32_t dataLoadFlag, int32_t repeatTime,
|
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfCols, int32_t dataLoadFlag, int32_t repeatTime,
|
||||||
int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock, SNode* pCondition, SExecTaskInfo* pTaskInfo);
|
int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock, SNode* pCondition,
|
||||||
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock,
|
SInterval* pInterval, double ratio, SExecTaskInfo* pTaskInfo);
|
||||||
SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo,
|
||||||
SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
||||||
|
|
||||||
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t num, SSDataBlock* pResBlock, SLimit* pLimit, SLimit* pSlimit, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t num, SSDataBlock* pResBlock, SLimit* pLimit, SLimit* pSlimit, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo *createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pResBlock, SArray* pSortInfo, SArray* pIndexMap, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo *createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pResBlock, SArray* pSortInfo, SArray* pIndexMap, SExecTaskInfo* pTaskInfo);
|
||||||
|
@ -669,8 +676,6 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
|
||||||
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
|
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
|
||||||
SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
|
SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
|
||||||
SExprInfo* pExpr, int32_t numOfOutput);
|
SExprInfo* pExpr, int32_t numOfOutput);
|
||||||
SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
|
|
||||||
SExprInfo* pExpr, int32_t numOfOutput);
|
|
||||||
SOperatorInfo* createTagScanOperatorInfo(SReaderHandle* pReaderHandle, SExprInfo* pExpr, int32_t numOfOutput);
|
SOperatorInfo* createTagScanOperatorInfo(SReaderHandle* pReaderHandle, SExprInfo* pExpr, int32_t numOfOutput);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -53,10 +53,10 @@ int32_t getOutputInterResultBufSize(STaskAttr* pQueryAttr) {
|
||||||
|
|
||||||
int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size) {
|
int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size) {
|
||||||
pResultRowInfo->size = 0;
|
pResultRowInfo->size = 0;
|
||||||
pResultRowInfo->curPos = -1;
|
|
||||||
pResultRowInfo->capacity = size;
|
pResultRowInfo->capacity = size;
|
||||||
pResultRowInfo->pPosition = taosMemoryCalloc(pResultRowInfo->capacity, sizeof(SResultRowPosition));
|
pResultRowInfo->cur.pageId = -1;
|
||||||
|
|
||||||
|
pResultRowInfo->pPosition = taosMemoryCalloc(pResultRowInfo->capacity, sizeof(SResultRowPosition));
|
||||||
if (pResultRowInfo->pPosition == NULL) {
|
if (pResultRowInfo->pPosition == NULL) {
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,6 @@ void closeAllResultRows(SResultRowInfo *pResultRowInfo) {
|
||||||
assert(pResultRowInfo->size >= 0 && pResultRowInfo->capacity >= pResultRowInfo->size);
|
assert(pResultRowInfo->size >= 0 && pResultRowInfo->capacity >= pResultRowInfo->size);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pResultRowInfo->size; ++i) {
|
for (int32_t i = 0; i < pResultRowInfo->size; ++i) {
|
||||||
// ASSERT(0);
|
|
||||||
// SResultRow* pRow = pResultRowInfo->pResult[i];
|
// SResultRow* pRow = pResultRowInfo->pResult[i];
|
||||||
// if (pRow->closed) {
|
// if (pRow->closed) {
|
||||||
// continue;
|
// continue;
|
||||||
|
@ -378,7 +377,7 @@ static int32_t mergeIntoGroupResultImplRv(STaskRuntimeEnv *pRuntimeEnv, SGroupRe
|
||||||
static UNUSED_FUNC int32_t mergeIntoGroupResultImpl(STaskRuntimeEnv *pRuntimeEnv, SGroupResInfo* pGroupResInfo, SArray *pTableList,
|
static UNUSED_FUNC int32_t mergeIntoGroupResultImpl(STaskRuntimeEnv *pRuntimeEnv, SGroupResInfo* pGroupResInfo, SArray *pTableList,
|
||||||
int32_t* rowCellInfoOffset) {
|
int32_t* rowCellInfoOffset) {
|
||||||
bool ascQuery = true;
|
bool ascQuery = true;
|
||||||
|
#if 0
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
int32_t *posList = NULL;
|
int32_t *posList = NULL;
|
||||||
|
@ -402,16 +401,16 @@ static UNUSED_FUNC int32_t mergeIntoGroupResultImpl(STaskRuntimeEnv *pRuntimeEnv
|
||||||
int32_t numOfTables = 0;
|
int32_t numOfTables = 0;
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
STableQueryInfo *item = taosArrayGetP(pTableList, i);
|
STableQueryInfo *item = taosArrayGetP(pTableList, i);
|
||||||
if (item->resInfo.size > 0) {
|
// if (item->resInfo.size > 0) {
|
||||||
pTableQueryInfoList[numOfTables++] = item;
|
// pTableQueryInfoList[numOfTables++] = item;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// there is no data in current group
|
// there is no data in current group
|
||||||
// no need to merge results since only one table in each group
|
// no need to merge results since only one table in each group
|
||||||
if (numOfTables == 0) {
|
// if (numOfTables == 0) {
|
||||||
goto _end;
|
// goto _end;
|
||||||
}
|
// }
|
||||||
|
|
||||||
int32_t order = TSDB_ORDER_ASC;
|
int32_t order = TSDB_ORDER_ASC;
|
||||||
SCompSupporter cs = {pTableQueryInfoList, posList, order};
|
SCompSupporter cs = {pTableQueryInfoList, posList, order};
|
||||||
|
@ -498,6 +497,7 @@ int32_t mergeIntoGroupResult(SGroupResInfo* pGroupResInfo, STaskRuntimeEnv* pRun
|
||||||
// int64_t elapsedTime = taosGetTimestampUs() - st;
|
// int64_t elapsedTime = taosGetTimestampUs() - st;
|
||||||
// qDebug("QInfo:%"PRIu64" merge res data into group, index:%d, total group:%d, elapsed time:%" PRId64 "us", GET_TASKID(pRuntimeEnv),
|
// qDebug("QInfo:%"PRIu64" merge res data into group, index:%d, total group:%d, elapsed time:%" PRId64 "us", GET_TASKID(pRuntimeEnv),
|
||||||
// pGroupResInfo->currentGroup, pGroupResInfo->totalGroup, elapsedTime);
|
// pGroupResInfo->currentGroup, pGroupResInfo->totalGroup, elapsedTime);
|
||||||
|
#endif
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ static void getNextTimeWindow(SInterval* pInterval, int32_t precision, int32_t o
|
||||||
static void doSetTagValueToResultBuf(char* output, const char* val, int16_t type, int16_t bytes);
|
static void doSetTagValueToResultBuf(char* output, const char* val, int16_t type, int16_t bytes);
|
||||||
static bool functionNeedToExecute(SqlFunctionCtx* pCtx);
|
static bool functionNeedToExecute(SqlFunctionCtx* pCtx);
|
||||||
|
|
||||||
static void setBlockStatisInfo(SqlFunctionCtx* pCtx, SSDataBlock* pSDataBlock, SColumn* pColumn);
|
static void setBlockStatisInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pSDataBlock, SColumn* pColumn);
|
||||||
|
|
||||||
static void destroyTableQueryInfoImpl(STableQueryInfo* pTableQueryInfo);
|
static void destroyTableQueryInfoImpl(STableQueryInfo* pTableQueryInfo);
|
||||||
static bool hasMainOutput(STaskAttr* pQueryAttr);
|
static bool hasMainOutput(STaskAttr* pQueryAttr);
|
||||||
|
@ -237,13 +237,10 @@ void operatorDummyCloseFn(void* param, int32_t numOfCols) {}
|
||||||
static int32_t doCopyToSDataBlock(SSDataBlock* pBlock, int32_t rowCapacity, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo,
|
static int32_t doCopyToSDataBlock(SSDataBlock* pBlock, int32_t rowCapacity, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo,
|
||||||
int32_t orderType, int32_t* rowCellOffset);
|
int32_t orderType, int32_t* rowCellOffset);
|
||||||
static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size);
|
static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size);
|
||||||
static void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key, int64_t keyFirst,
|
|
||||||
int64_t keyLast, STimeWindow* win);
|
|
||||||
|
|
||||||
static void setResultBufSize(STaskAttr* pQueryAttr, SResultInfo* pResultInfo);
|
static void setResultBufSize(STaskAttr* pQueryAttr, SResultInfo* pResultInfo);
|
||||||
static void setCtxTagForJoin(STaskRuntimeEnv* pRuntimeEnv, SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, void* pTable);
|
static void setCtxTagForJoin(STaskRuntimeEnv* pRuntimeEnv, SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, void* pTable);
|
||||||
static void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, int32_t tableGroupId,
|
static void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, uint64_t groupId, SExecTaskInfo* pTaskInfo);
|
||||||
SExecTaskInfo* pTaskInfo);
|
|
||||||
|
|
||||||
SArray* getOrderCheckColumns(STaskAttr* pQuery);
|
SArray* getOrderCheckColumns(STaskAttr* pQuery);
|
||||||
|
|
||||||
|
@ -325,8 +322,7 @@ static bool isSelectivityWithTagsQuery(SqlFunctionCtx* pCtx, int32_t numOfOutput
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hasNull(SColumn* pColumn, SColumnDataAgg* pStatis) {
|
static bool hasNull(SColumn* pColumn, SColumnDataAgg* pStatis) {
|
||||||
if (TSDB_COL_IS_TAG(pColumn->flag) || TSDB_COL_IS_UD_COL(pColumn->flag) ||
|
if (TSDB_COL_IS_TAG(pColumn->flag) || TSDB_COL_IS_UD_COL(pColumn->flag) || pColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
pColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,11 +435,11 @@ SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId,
|
||||||
return pResultRow;
|
return pResultRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, int64_t tid,
|
static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, int64_t uid,
|
||||||
char* pData, int16_t bytes, bool masterscan, uint64_t tableGroupId,
|
char* pData, int16_t bytes, bool masterscan, uint64_t groupId,
|
||||||
SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup) {
|
SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup) {
|
||||||
bool existInCurrentResusltRowInfo = false;
|
bool existInCurrentResusltRowInfo = false;
|
||||||
SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, tableGroupId);
|
SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, groupId);
|
||||||
|
|
||||||
SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes));
|
SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes));
|
||||||
|
|
||||||
|
@ -460,13 +456,12 @@ static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultR
|
||||||
if (p1 != NULL) {
|
if (p1 != NULL) {
|
||||||
if (pResultRowInfo->size == 0) {
|
if (pResultRowInfo->size == 0) {
|
||||||
existInCurrentResusltRowInfo = false; // this time window created by other timestamp that does not belongs to current table.
|
existInCurrentResusltRowInfo = false; // this time window created by other timestamp that does not belongs to current table.
|
||||||
assert(pResultRowInfo->curPos == -1);
|
// assert(pResultRowInfo->curPos == -1);
|
||||||
} else if (pResultRowInfo->size == 1) {
|
} else if (pResultRowInfo->size == 1) {
|
||||||
// ASSERT(0);
|
|
||||||
SResultRowPosition* p = &pResultRowInfo->pPosition[0];
|
SResultRowPosition* p = &pResultRowInfo->pPosition[0];
|
||||||
existInCurrentResusltRowInfo = (p->pageId == p1->pageId && p->offset == p1->offset);
|
existInCurrentResusltRowInfo = (p->pageId == p1->pageId && p->offset == p1->offset);
|
||||||
} else { // check if current pResultRowInfo contains the existInCurrentResusltRowInfo pResultRow
|
} else { // check if current pResultRowInfo contains the existInCurrentResusltRowInfo pResultRow
|
||||||
SET_RES_EXT_WINDOW_KEY(pSup->keyBuf, pData, bytes, tid, pResultRowInfo);
|
SET_RES_EXT_WINDOW_KEY(pSup->keyBuf, pData, bytes, uid, pResultRowInfo);
|
||||||
int64_t* index = taosHashGet(pSup->pResultRowListSet, pSup->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes));
|
int64_t* index = taosHashGet(pSup->pResultRowListSet, pSup->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes));
|
||||||
if (index != NULL) {
|
if (index != NULL) {
|
||||||
// TODO check the scan order for current opened time window
|
// TODO check the scan order for current opened time window
|
||||||
|
@ -487,35 +482,34 @@ static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultR
|
||||||
SResultRow* pResult = NULL;
|
SResultRow* pResult = NULL;
|
||||||
if (!existInCurrentResusltRowInfo) {
|
if (!existInCurrentResusltRowInfo) {
|
||||||
// 1. close current opened time window
|
// 1. close current opened time window
|
||||||
if (pResultRowInfo->curPos != -1) { // todo extract function
|
if (pResultRowInfo->cur.pageId != -1) { // todo extract function
|
||||||
SResultRowPosition* pos = &pResultRowInfo->pPosition[pResultRowInfo->curPos];
|
SResultRowPosition pos = pResultRowInfo->cur;
|
||||||
SFilePage* pPage = getBufPage(pResultBuf, pos->pageId);
|
SFilePage* pPage = getBufPage(pResultBuf, pos.pageId);
|
||||||
SResultRow* pRow = (SResultRow*)((char*)pPage + pos->offset);
|
SResultRow* pRow = (SResultRow*)((char*)pPage + pos.offset);
|
||||||
closeResultRow(pRow);
|
closeResultRow(pRow);
|
||||||
releaseBufPage(pResultBuf, pPage);
|
releaseBufPage(pResultBuf, pPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareResultListBuffer(pResultRowInfo, pTaskInfo->env);
|
prepareResultListBuffer(pResultRowInfo, pTaskInfo->env);
|
||||||
if (p1 == NULL) {
|
if (p1 == NULL) {
|
||||||
pResult = getNewResultRow_rv(pResultBuf, tableGroupId, pSup->resultRowSize);
|
pResult = getNewResultRow_rv(pResultBuf, groupId, pSup->resultRowSize);
|
||||||
initResultRow(pResult);
|
initResultRow(pResult);
|
||||||
|
|
||||||
// add a new result set for a new group
|
// add a new result set for a new group
|
||||||
SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset};
|
SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset};
|
||||||
taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos, sizeof(SResultRowPosition));
|
taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos, sizeof(SResultRowPosition));
|
||||||
SResultRowCell cell = {.groupId = tableGroupId, .pos = pos};
|
SResultRowCell cell = {.groupId = groupId, .pos = pos};
|
||||||
taosArrayPush(pSup->pResultRowArrayList, &cell);
|
taosArrayPush(pSup->pResultRowArrayList, &cell);
|
||||||
} else {
|
} else {
|
||||||
pResult = getResultRowByPos(pResultBuf, p1);
|
pResult = getResultRowByPos(pResultBuf, p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. set the new time window to be the new active time window
|
// 2. set the new time window to be the new active time window
|
||||||
pResultRowInfo->curPos = pResultRowInfo->size;
|
// pResultRowInfo->curPos = pResultRowInfo->size;
|
||||||
pResultRowInfo->pPosition[pResultRowInfo->size++] = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset};
|
pResultRowInfo->pPosition[pResultRowInfo->size++] = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset};
|
||||||
|
pResultRowInfo->cur = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset};
|
||||||
int64_t index = pResultRowInfo->curPos;
|
SET_RES_EXT_WINDOW_KEY(pSup->keyBuf, pData, bytes, uid, pResultRowInfo);
|
||||||
SET_RES_EXT_WINDOW_KEY(pSup->keyBuf, pData, bytes, tid, pResultRowInfo);
|
taosHashPut(pSup->pResultRowListSet, pSup->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes), &pResultRowInfo->cur, POINTER_BYTES);
|
||||||
taosHashPut(pSup->pResultRowListSet, pSup->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes), &index, POINTER_BYTES);
|
|
||||||
} else {
|
} else {
|
||||||
pResult = getResultRowByPos(pResultBuf, p1);
|
pResult = getResultRowByPos(pResultBuf, p1);
|
||||||
}
|
}
|
||||||
|
@ -553,11 +547,11 @@ static STimeWindow getActiveTimeWindow(SDiskbasedBuf * pBuf, SResultRowInfo* pRe
|
||||||
int32_t precision, STimeWindow* win) {
|
int32_t precision, STimeWindow* win) {
|
||||||
STimeWindow w = {0};
|
STimeWindow w = {0};
|
||||||
|
|
||||||
if (pResultRowInfo->curPos == -1) { // the first window, from the previous stored value
|
if (pResultRowInfo->cur.pageId == -1) { // the first window, from the previous stored value
|
||||||
getInitialStartTimeWindow(pInterval, precision, ts, &w, win->ekey, true);
|
getInitialStartTimeWindow(pInterval, precision, ts, &w, win->ekey, true);
|
||||||
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||||
} else {
|
} else {
|
||||||
w = getResultRow(pBuf, pResultRowInfo, pResultRowInfo->curPos)->win;
|
w = getResultRowByPos(pBuf, &pResultRowInfo->cur)->win;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w.skey > ts || w.ekey < ts) {
|
if (w.skey > ts || w.ekey < ts) {
|
||||||
|
@ -791,17 +785,17 @@ static void doUpdateResultRowIndex(SResultRowInfo* pResultRowInfo, TSKEY lastKey
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
//
|
||||||
static void updateResultRowInfoActiveIndex(SResultRowInfo* pResultRowInfo, const STimeWindow* pWin, TSKEY lastKey,
|
//static void updateResultRowInfoActiveIndex(SResultRowInfo* pResultRowInfo, const STimeWindow* pWin, TSKEY lastKey,
|
||||||
bool ascQuery, bool interp) {
|
// bool ascQuery, bool interp) {
|
||||||
if ((lastKey > pWin->ekey && ascQuery) || (lastKey < pWin->ekey && (!ascQuery))) {
|
// if ((lastKey > pWin->ekey && ascQuery) || (lastKey < pWin->ekey && (!ascQuery))) {
|
||||||
closeAllResultRows(pResultRowInfo);
|
// closeAllResultRows(pResultRowInfo);
|
||||||
pResultRowInfo->curPos = pResultRowInfo->size - 1;
|
// pResultRowInfo->curPos = pResultRowInfo->size - 1;
|
||||||
} else {
|
// } else {
|
||||||
int32_t step = ascQuery ? 1 : -1;
|
// int32_t step = ascQuery ? 1 : -1;
|
||||||
doUpdateResultRowIndex(pResultRowInfo, lastKey - step, ascQuery, interp);
|
// doUpdateResultRowIndex(pResultRowInfo, lastKey - step, ascQuery, interp);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
static int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos,
|
static int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos,
|
||||||
TSKEY ekey, __block_search_fn_t searchFn, STableQueryInfo* item,
|
TSKEY ekey, __block_search_fn_t searchFn, STableQueryInfo* item,
|
||||||
|
@ -1043,22 +1037,19 @@ static TSKEY getStartTsKey(STimeWindow* win, const TSKEY* tsCols, int32_t rows,
|
||||||
|
|
||||||
static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order);
|
static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order);
|
||||||
|
|
||||||
static void doSetInputDataBlockInfo(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock,
|
static void doSetInputDataBlockInfo(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order) {
|
||||||
int32_t order) {
|
|
||||||
for (int32_t i = 0; i < pOperator->numOfOutput; ++i) {
|
for (int32_t i = 0; i < pOperator->numOfOutput; ++i) {
|
||||||
pCtx[i].order = order;
|
pCtx[i].order = order;
|
||||||
pCtx[i].size = pBlock->info.rows;
|
pCtx[i].size = pBlock->info.rows;
|
||||||
pCtx[i].currentStage = (uint8_t)pOperator->pRuntimeEnv->scanFlag;
|
setBlockStatisInfo(&pCtx[i], &pOperator->pExpr[i], pBlock, NULL /*&pOperator->pExpr[i].base.colInfo*/);
|
||||||
|
|
||||||
setBlockStatisInfo(&pCtx[i], pBlock, NULL /*&pOperator->pExpr[i].base.colInfo*/);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order) {
|
void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order) {
|
||||||
if (pBlock->pDataBlock != NULL) {
|
if (pBlock->pBlockAgg != NULL) {
|
||||||
doSetInputDataBlock(pOperator, pCtx, pBlock, order);
|
|
||||||
} else {
|
|
||||||
doSetInputDataBlockInfo(pOperator, pCtx, pBlock, order);
|
doSetInputDataBlockInfo(pOperator, pCtx, pBlock, order);
|
||||||
|
} else {
|
||||||
|
doSetInputDataBlock(pOperator, pCtx, pBlock, order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1097,13 +1088,6 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx,
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// in case of the block distribution query, the inputBytes is not a constant value.
|
|
||||||
//pCtx[i].input.pData[0] = taosArrayGet(pBlock->pDataBlock, slotId);
|
|
||||||
//pCtx[i].input.totalRows = pBlock->info.rows;
|
|
||||||
//pCtx[i].input.numOfRows = pBlock->info.rows;
|
|
||||||
//pCtx[i].input.startRowIndex = 0;
|
|
||||||
|
|
||||||
|
|
||||||
// uint32_t status = aAggs[pCtx[i].functionId].status;
|
// uint32_t status = aAggs[pCtx[i].functionId].status;
|
||||||
// if ((status & (FUNCSTATE_SELECTIVITY | FUNCSTATE_NEED_TS)) != 0) {
|
// if ((status & (FUNCSTATE_SELECTIVITY | FUNCSTATE_NEED_TS)) != 0) {
|
||||||
// SColumnInfoData* tsInfo = taosArrayGet(pBlock->pDataBlock, 0);
|
// SColumnInfoData* tsInfo = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
|
@ -1401,7 +1385,7 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
||||||
int32_t step = 1;
|
int32_t step = 1;
|
||||||
bool ascScan = true;
|
bool ascScan = true;
|
||||||
|
|
||||||
int32_t prevIndex = pResultRowInfo->curPos;
|
// int32_t prevIndex = pResultRowInfo->curPos;
|
||||||
|
|
||||||
TSKEY* tsCols = NULL;
|
TSKEY* tsCols = NULL;
|
||||||
if (pSDataBlock->pDataBlock != NULL) {
|
if (pSDataBlock->pDataBlock != NULL) {
|
||||||
|
@ -1436,7 +1420,7 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
|
||||||
getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC);
|
getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC);
|
||||||
|
|
||||||
// prev time window not interpolation yet.
|
// prev time window not interpolation yet.
|
||||||
int32_t curIndex = pResultRowInfo->curPos;
|
// int32_t curIndex = pResultRowInfo->curPos;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (prevIndex != -1 && prevIndex < curIndex && pInfo->timeWindowInterpo) {
|
if (prevIndex != -1 && prevIndex < curIndex && pInfo->timeWindowInterpo) {
|
||||||
|
@ -1746,27 +1730,36 @@ static bool functionNeedToExecute(SqlFunctionCtx* pCtx) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBlockStatisInfo(SqlFunctionCtx* pCtx, SSDataBlock* pSDataBlock, SColumn* pColumn) {
|
void setBlockStatisInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pBlock, SColumn* pColumn) {
|
||||||
SColumnDataAgg* pAgg = NULL;
|
if (pBlock->pBlockAgg != NULL /*&& TSDB_COL_IS_NORMAL_COL(pColumn->flag)*/) {
|
||||||
|
for (int32_t j = 0; j < pExprInfo->base.numOfParams; ++j) {
|
||||||
|
SFunctParam* pFuncParam = &pExprInfo->base.pParam[j];
|
||||||
|
if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) {
|
||||||
|
int32_t slotId = pFuncParam->pCol->slotId;
|
||||||
|
SInputColumnInfoData* pInput = &pCtx->input;
|
||||||
|
|
||||||
if (pSDataBlock->pBlockAgg != NULL && TSDB_COL_IS_NORMAL_COL(pColumn->flag)) {
|
pInput->pColumnDataAgg[j] = &pBlock->pBlockAgg[slotId];
|
||||||
pAgg = &pSDataBlock->pBlockAgg[pCtx->columnIndex];
|
pInput->colDataAggIsSet = true;
|
||||||
|
pInput->numOfRows = pBlock->info.rows;
|
||||||
|
pInput->totalRows = pBlock->info.rows;
|
||||||
|
|
||||||
pCtx->agg = *pAgg;
|
// Here we set the column info data since the data type for each column data is required, but
|
||||||
pCtx->isAggSet = true;
|
// the data in the corresponding SColumnInfoData will not be used.
|
||||||
assert(pCtx->agg.numOfNull <= pSDataBlock->info.rows);
|
pInput->pData[j] = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pCtx->isAggSet = false;
|
pCtx->input.colDataAggIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCtx->hasNull = hasNull(pColumn, pAgg);
|
// pCtx->hasNull = hasNull(pColumn, pAgg);
|
||||||
|
|
||||||
// set the statistics data for primary time stamp column
|
// set the statistics data for primary time stamp column
|
||||||
if (pCtx->functionId == FUNCTION_SPREAD && pColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
// if (pCtx->functionId == FUNCTION_SPREAD && pColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
pCtx->isAggSet = true;
|
// pCtx->isAggSet = true;
|
||||||
pCtx->agg.min = pSDataBlock->info.window.skey;
|
// pCtx->agg.min = pBlock->info.window.skey;
|
||||||
pCtx->agg.max = pSDataBlock->info.window.ekey;
|
// pCtx->agg.max = pBlock->info.window.ekey;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the output buffer for the selectivity + tag query
|
// set the output buffer for the selectivity + tag query
|
||||||
|
@ -2447,7 +2440,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
|
||||||
if ((*status) == BLK_DATA_NOT_LOAD || (*status) == BLK_DATA_FILTEROUT) {
|
if ((*status) == BLK_DATA_NOT_LOAD || (*status) == BLK_DATA_FILTEROUT) {
|
||||||
//qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
|
//qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
|
||||||
// pBlockInfo->window.ekey, pBlockInfo->rows);
|
// pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
pCost->discardBlocks += 1;
|
pCost->skipBlocks += 1;
|
||||||
} else if ((*status) == BLK_DATA_SMA_LOAD) {
|
} else if ((*status) == BLK_DATA_SMA_LOAD) {
|
||||||
// this function never returns error?
|
// this function never returns error?
|
||||||
pCost->loadBlockStatis += 1;
|
pCost->loadBlockStatis += 1;
|
||||||
|
@ -2487,7 +2480,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
|
||||||
// load = topbot_datablock_filter(&pTableScanInfo->pCtx[i], (char*)&(pBlock->pBlockAgg[i].min),
|
// load = topbot_datablock_filter(&pTableScanInfo->pCtx[i], (char*)&(pBlock->pBlockAgg[i].min),
|
||||||
// (char*)&(pBlock->pBlockAgg[i].max));
|
// (char*)&(pBlock->pBlockAgg[i].max));
|
||||||
if (!load) { // current block has been discard due to filter applied
|
if (!load) { // current block has been discard due to filter applied
|
||||||
pCost->discardBlocks += 1;
|
pCost->skipBlocks += 1;
|
||||||
//qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId,
|
//qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId,
|
||||||
// pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
// pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
(*status) = BLK_DATA_FILTEROUT;
|
(*status) = BLK_DATA_FILTEROUT;
|
||||||
|
@ -2499,7 +2492,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
|
||||||
|
|
||||||
// current block has been discard due to filter applied
|
// current block has been discard due to filter applied
|
||||||
// if (!doFilterByBlockStatistics(pRuntimeEnv, pBlock->pBlockAgg, pTableScanInfo->pCtx, pBlockInfo->rows)) {
|
// if (!doFilterByBlockStatistics(pRuntimeEnv, pBlock->pBlockAgg, pTableScanInfo->pCtx, pBlockInfo->rows)) {
|
||||||
// pCost->discardBlocks += 1;
|
// pCost->skipBlocks += 1;
|
||||||
// qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
|
// qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
|
||||||
// pBlockInfo->window.ekey, pBlockInfo->rows);
|
// pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
// (*status) = BLK_DATA_FILTEROUT;
|
// (*status) = BLK_DATA_FILTEROUT;
|
||||||
|
@ -2725,12 +2718,12 @@ static void updateTableQueryInfoForReverseScan(STableQueryInfo* pTableQueryInfo)
|
||||||
// pTableQueryInfo->cur.vgroupIndex = -1;
|
// pTableQueryInfo->cur.vgroupIndex = -1;
|
||||||
|
|
||||||
// set the index to be the end slot of result rows array
|
// set the index to be the end slot of result rows array
|
||||||
SResultRowInfo* pResultRowInfo = &pTableQueryInfo->resInfo;
|
// SResultRowInfo* pResultRowInfo = &pTableQueryInfo->resInfo;
|
||||||
if (pResultRowInfo->size > 0) {
|
// if (pResultRowInfo->size > 0) {
|
||||||
pResultRowInfo->curPos = pResultRowInfo->size - 1;
|
// pResultRowInfo->curPos = pResultRowInfo->size - 1;
|
||||||
} else {
|
// } else {
|
||||||
pResultRowInfo->curPos = -1;
|
// pResultRowInfo->curPos = -1;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void initResultRow(SResultRow* pResultRow) {
|
void initResultRow(SResultRow* pResultRow) {
|
||||||
|
@ -2889,7 +2882,7 @@ void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SD
|
||||||
pCtx[j].resultInfo = getResultCell(pRow, j, rowCellInfoOffset);
|
pCtx[j].resultInfo = getResultCell(pRow, j, rowCellInfoOffset);
|
||||||
|
|
||||||
struct SResultRowEntryInfo* pResInfo = pCtx[j].resultInfo;
|
struct SResultRowEntryInfo* pResInfo = pCtx[j].resultInfo;
|
||||||
if (isRowEntryCompleted(pResInfo) && isRowEntryInitialized(pResInfo)) {
|
if (!isRowEntryInitialized(pResInfo)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2962,10 +2955,10 @@ STableQueryInfo* createTableQueryInfo(void* buf, bool groupbyColumn, STimeWindow
|
||||||
// set more initial size of interval/groupby query
|
// set more initial size of interval/groupby query
|
||||||
// if (/*QUERY_IS_INTERVAL_QUERY(pQueryAttr) || */groupbyColumn) {
|
// if (/*QUERY_IS_INTERVAL_QUERY(pQueryAttr) || */groupbyColumn) {
|
||||||
int32_t initialSize = 128;
|
int32_t initialSize = 128;
|
||||||
int32_t code = initResultRowInfo(&pTableQueryInfo->resInfo, initialSize);
|
// int32_t code = initResultRowInfo(&pTableQueryInfo->resInfo, initialSize);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
// if (code != TSDB_CODE_SUCCESS) {
|
||||||
return NULL;
|
// return NULL;
|
||||||
}
|
// }
|
||||||
// } else { // in other aggregate query, do not initialize the windowResInfo
|
// } else { // in other aggregate query, do not initialize the windowResInfo
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ -2978,7 +2971,7 @@ void destroyTableQueryInfoImpl(STableQueryInfo* pTableQueryInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// taosVariantDestroy(&pTableQueryInfo->tag);
|
// taosVariantDestroy(&pTableQueryInfo->tag);
|
||||||
cleanupResultRowInfo(&pTableQueryInfo->resInfo);
|
// cleanupResultRowInfo(&pTableQueryInfo->resInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setResultRowOutputBufInitCtx_rv(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowCellInfoOffset) {
|
void setResultRowOutputBufInitCtx_rv(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowCellInfoOffset) {
|
||||||
|
@ -3053,18 +3046,17 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) {
|
||||||
blockDataUpdateTsWindow(pBlock);
|
blockDataUpdateTsWindow(pBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, int32_t tableGroupId, SExecTaskInfo* pTaskInfo) {
|
void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, uint64_t groupId, SExecTaskInfo* pTaskInfo) {
|
||||||
// for simple group by query without interval, all the tables belong to one group result.
|
// for simple group by query without interval, all the tables belong to one group result.
|
||||||
int64_t uid = 0;
|
int64_t uid = 0;
|
||||||
int64_t tid = 0;
|
|
||||||
|
|
||||||
SResultRowInfo* pResultRowInfo = &pAggInfo->binfo.resultRowInfo;
|
SResultRowInfo* pResultRowInfo = &pAggInfo->binfo.resultRowInfo;
|
||||||
SqlFunctionCtx* pCtx = pAggInfo->binfo.pCtx;
|
SqlFunctionCtx* pCtx = pAggInfo->binfo.pCtx;
|
||||||
int32_t* rowCellInfoOffset = pAggInfo->binfo.rowCellInfoOffset;
|
int32_t* rowCellInfoOffset = pAggInfo->binfo.rowCellInfoOffset;
|
||||||
|
|
||||||
SResultRow* pResultRow =
|
SResultRow* pResultRow =
|
||||||
doSetResultOutBufByKey_rv(pAggInfo->pResultBuf, pResultRowInfo, tid, (char*)&tableGroupId, sizeof(tableGroupId),
|
doSetResultOutBufByKey_rv(pAggInfo->aggSup.pResultBuf, pResultRowInfo, uid, (char*)&groupId, sizeof(groupId),
|
||||||
true, uid, pTaskInfo, false, &pAggInfo->aggSup);
|
true, groupId, pTaskInfo, false, &pAggInfo->aggSup);
|
||||||
assert(pResultRow != NULL);
|
assert(pResultRow != NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3072,7 +3064,7 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, i
|
||||||
* all group belong to one result set, and each group result has different group id so set the id to be one
|
* all group belong to one result set, and each group result has different group id so set the id to be one
|
||||||
*/
|
*/
|
||||||
if (pResultRow->pageId == -1) {
|
if (pResultRow->pageId == -1) {
|
||||||
int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->pResultBuf, tableGroupId, pAggInfo->binfo.pRes->info.rowSize);
|
int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->aggSup.pResultBuf, groupId, pAggInfo->binfo.pRes->info.rowSize);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3081,18 +3073,15 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, i
|
||||||
setResultRowOutputBufInitCtx_rv(pResultRow, pCtx, numOfOutput, rowCellInfoOffset);
|
setResultRowOutputBufInitCtx_rv(pResultRow, pCtx, numOfOutput, rowCellInfoOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setExecutionContext(int32_t numOfOutput, int32_t tableGroupId, TSKEY nextKey, SExecTaskInfo* pTaskInfo,
|
void setExecutionContext(int32_t numOfOutput, uint64_t groupId, SExecTaskInfo* pTaskInfo, SAggOperatorInfo* pAggInfo) {
|
||||||
STableQueryInfo* pTableQueryInfo, SAggOperatorInfo* pAggInfo) {
|
if (pAggInfo->groupId != INT32_MIN && pAggInfo->groupId == groupId) {
|
||||||
// lastKey needs to be updated
|
|
||||||
pTableQueryInfo->lastKey = nextKey;
|
|
||||||
if (pAggInfo->groupId != INT32_MIN && pAggInfo->groupId == tableGroupId) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
doSetTableGroupOutputBuf(pAggInfo, numOfOutput, tableGroupId, pTaskInfo);
|
doSetTableGroupOutputBuf(pAggInfo, numOfOutput, groupId, pTaskInfo);
|
||||||
|
|
||||||
// record the current active group id
|
// record the current active group id
|
||||||
pAggInfo->groupId = tableGroupId;
|
pAggInfo->groupId = groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCtxTagForJoin(STaskRuntimeEnv* pRuntimeEnv, SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, void* pTable) {
|
void setCtxTagForJoin(STaskRuntimeEnv* pRuntimeEnv, SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, void* pTable) {
|
||||||
|
@ -3173,17 +3162,14 @@ int32_t setTimestampListJoinInfo(STaskRuntimeEnv* pRuntimeEnv, SVariant* pTag, S
|
||||||
* merged during merge stage. In this case, we need the pTableQueryInfo->lastResRows to decide if there
|
* merged during merge stage. In this case, we need the pTableQueryInfo->lastResRows to decide if there
|
||||||
* is a previous result generated or not.
|
* is a previous result generated or not.
|
||||||
*/
|
*/
|
||||||
void setIntervalQueryRange(STaskRuntimeEnv* pRuntimeEnv, TSKEY key) {
|
void setIntervalQueryRange(STableQueryInfo* pTableQueryInfo, TSKEY key, STimeWindow* pQRange) {
|
||||||
STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr;
|
// SResultRowInfo* pResultRowInfo = &pTableQueryInfo->resInfo;
|
||||||
STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current;
|
// if (pResultRowInfo->curPos != -1) {
|
||||||
SResultRowInfo* pResultRowInfo = &pTableQueryInfo->resInfo;
|
// return;
|
||||||
|
// }
|
||||||
if (pResultRowInfo->curPos != -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// pTableQueryInfo->win.skey = key;
|
// pTableQueryInfo->win.skey = key;
|
||||||
STimeWindow win = {.skey = key, .ekey = pQueryAttr->window.ekey};
|
// STimeWindow win = {.skey = key, .ekey = pQRange->ekey};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In handling the both ascending and descending order super table query, we need to find the first qualified
|
* In handling the both ascending and descending order super table query, we need to find the first qualified
|
||||||
|
@ -3191,10 +3177,10 @@ void setIntervalQueryRange(STaskRuntimeEnv* pRuntimeEnv, TSKEY key) {
|
||||||
* In ascending query, the key is the first qualified timestamp. However, in the descending order query, additional
|
* In ascending query, the key is the first qualified timestamp. However, in the descending order query, additional
|
||||||
* operations involve.
|
* operations involve.
|
||||||
*/
|
*/
|
||||||
STimeWindow w = TSWINDOW_INITIALIZER;
|
// STimeWindow w = TSWINDOW_INITIALIZER;
|
||||||
|
//
|
||||||
TSKEY sk = TMIN(win.skey, win.ekey);
|
// TSKEY sk = TMIN(win.skey, win.ekey);
|
||||||
TSKEY ek = TMAX(win.skey, win.ekey);
|
// TSKEY ek = TMAX(win.skey, win.ekey);
|
||||||
// getAlignQueryTimeWindow(pQueryAttr, win.skey, sk, ek, &w);
|
// getAlignQueryTimeWindow(pQueryAttr, win.skey, sk, ek, &w);
|
||||||
|
|
||||||
// if (pResultRowInfo->prevSKey == TSKEY_INITIAL_VAL) {
|
// if (pResultRowInfo->prevSKey == TSKEY_INITIAL_VAL) {
|
||||||
|
@ -3795,19 +3781,6 @@ static STableIdInfo createTableIdInfo(STableQueryInfo* pTableQueryInfo) {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
static void doCloseAllTimeWindow(STaskRuntimeEnv* pRuntimeEnv) {
|
|
||||||
size_t numOfGroup = GET_NUM_OF_TABLEGROUP(pRuntimeEnv);
|
|
||||||
for (int32_t i = 0; i < numOfGroup; ++i) {
|
|
||||||
SArray* group = GET_TABLEGROUP(pRuntimeEnv, i);
|
|
||||||
|
|
||||||
size_t num = taosArrayGetSize(group);
|
|
||||||
for (int32_t j = 0; j < num; ++j) {
|
|
||||||
STableQueryInfo* item = taosArrayGetP(group, j);
|
|
||||||
closeAllResultRows(&item->resInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
SSourceDataInfo* pSourceDataInfo = (SSourceDataInfo*)param;
|
SSourceDataInfo* pSourceDataInfo = (SSourceDataInfo*)param;
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
@ -4859,7 +4832,9 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
SAggOperatorInfo* pAggInfo = pOperator->info;
|
SAggOperatorInfo* pAggInfo = pOperator->info;
|
||||||
|
|
||||||
SOptrBasicInfo* pInfo = &pAggInfo->binfo;
|
SOptrBasicInfo* pInfo = &pAggInfo->binfo;
|
||||||
|
|
||||||
int32_t order = TSDB_ORDER_ASC;
|
int32_t order = TSDB_ORDER_ASC;
|
||||||
|
@ -4878,7 +4853,13 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
|
||||||
// setTagValue(pOperator, pAggInfo->current->pTable, pInfo->pCtx, pOperator->numOfOutput);
|
// setTagValue(pOperator, pAggInfo->current->pTable, pInfo->pCtx, pOperator->numOfOutput);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// there is an scalar expression that needs to be calculated before apply the group aggregation.
|
||||||
|
if (pAggInfo->pScalarExprInfo != NULL) {
|
||||||
|
projectApplyFunctions(pAggInfo->pScalarExprInfo, pBlock, pBlock, pAggInfo->pScalarCtx, pAggInfo->numOfScalarExpr, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
|
setExecutionContext(pOperator->numOfOutput, pBlock->info.groupId, pTaskInfo, pAggInfo);
|
||||||
setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order);
|
setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order);
|
||||||
doAggregateImpl(pOperator, 0, pInfo->pCtx);
|
doAggregateImpl(pOperator, 0, pInfo->pCtx);
|
||||||
|
|
||||||
|
@ -4898,8 +4879,11 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
finalizeQueryResult(pInfo->pCtx, pOperator->numOfOutput);
|
closeAllResultRows(&pAggInfo->binfo.resultRowInfo);
|
||||||
|
finalizeMultiTupleQueryResult(pAggInfo->binfo.pCtx, pOperator->numOfOutput, pAggInfo->aggSup.pResultBuf,
|
||||||
|
&pAggInfo->binfo.resultRowInfo, pAggInfo->binfo.rowCellInfoOffset);
|
||||||
|
|
||||||
|
initGroupResInfo(&pAggInfo->groupResInfo, &pAggInfo->binfo.resultRowInfo);
|
||||||
OPTR_SET_OPENED(pOperator);
|
OPTR_SET_OPENED(pOperator);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -4918,9 +4902,13 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator, bool* newgroup)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
getNumOfResult(pInfo->pCtx, pOperator->numOfOutput, pInfo->pRes);
|
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
|
toSDatablock(pInfo->pRes, pOperator->resultInfo.capacity, &pAggInfo->groupResInfo, pOperator->pExpr, pAggInfo->aggSup.pResultBuf, pInfo->rowCellInfoOffset);
|
||||||
|
if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
|
}
|
||||||
|
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
return (blockDataGetNumOfRows(pInfo->pRes) != 0) ? pInfo->pRes : NULL;
|
return (blockDataGetNumOfRows(pInfo->pRes) != 0) ? pInfo->pRes : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4936,7 +4924,7 @@ void aggEncodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasi
|
||||||
int32_t offset = sizeof(int32_t);
|
int32_t offset = sizeof(int32_t);
|
||||||
|
|
||||||
// prepare memory
|
// prepare memory
|
||||||
SResultRowPosition* pos = &pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.curPos];
|
SResultRowPosition* pos = &pInfo->resultRowInfo.cur;
|
||||||
void* pPage = getBufPage(pSup->pResultBuf, pos->pageId);
|
void* pPage = getBufPage(pSup->pResultBuf, pos->pageId);
|
||||||
SResultRow* pRow = (SResultRow*)((char*)pPage + pos->offset);
|
SResultRow* pRow = (SResultRow*)((char*)pPage + pos->offset);
|
||||||
setBufPageDirty(pPage, true);
|
setBufPageDirty(pPage, true);
|
||||||
|
@ -5023,8 +5011,9 @@ bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasi
|
||||||
|
|
||||||
initResultRow(resultRow);
|
initResultRow(resultRow);
|
||||||
prepareResultListBuffer(&pInfo->resultRowInfo, pOperator->pTaskInfo->env);
|
prepareResultListBuffer(&pInfo->resultRowInfo, pOperator->pTaskInfo->env);
|
||||||
pInfo->resultRowInfo.curPos = pInfo->resultRowInfo.size;
|
// pInfo->resultRowInfo.cur = pInfo->resultRowInfo.size;
|
||||||
pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.size++] = (SResultRowPosition) {.pageId = resultRow->pageId, .offset = resultRow->offset};
|
pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.size++] = (SResultRowPosition) {.pageId = resultRow->pageId, .offset = resultRow->offset};
|
||||||
|
pInfo->resultRowInfo.cur = (SResultRowPosition) {.pageId = resultRow->pageId, .offset = resultRow->offset};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset != length) {
|
if (offset != length) {
|
||||||
|
@ -5033,74 +5022,6 @@ bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasi
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doMultiTableAggregate(SOperatorInfo* pOperator, bool* newgroup) {
|
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SAggOperatorInfo* pAggInfo = pOperator->info;
|
|
||||||
SOptrBasicInfo* pInfo = &pAggInfo->binfo;
|
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
|
||||||
toSDatablock(pInfo->pRes, pAggInfo->binfo.capacity, &pAggInfo->groupResInfo, pOperator->pExpr, pAggInfo->pResultBuf, pAggInfo->binfo.rowCellInfoOffset);
|
|
||||||
if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) {
|
|
||||||
pOperator->status = OP_EXEC_DONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pInfo->pRes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// table scan order
|
|
||||||
int32_t order = TSDB_ORDER_ASC;
|
|
||||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
|
||||||
SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup);
|
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
|
||||||
|
|
||||||
if (pBlock == NULL) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->pCtx, pOperator->numOfOutput);
|
|
||||||
// if (downstream->operatorType == OP_TableScan) {
|
|
||||||
// STableScanInfo* pScanInfo = downstream->info;
|
|
||||||
// order = getTableScanOrder(pScanInfo);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
|
||||||
setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order);
|
|
||||||
|
|
||||||
TSKEY key = 0;
|
|
||||||
if (order == TSDB_ORDER_ASC) {
|
|
||||||
key = pBlock->info.window.ekey;
|
|
||||||
TSKEY_MAX_ADD(key, 1);
|
|
||||||
} else {
|
|
||||||
key = pBlock->info.window.skey;
|
|
||||||
TSKEY_MIN_SUB(key, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
setExecutionContext(pOperator->numOfOutput, pAggInfo->current->groupIndex, key, pTaskInfo, pAggInfo->current,
|
|
||||||
pAggInfo);
|
|
||||||
doAggregateImpl(pOperator, 0, pInfo->pCtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
|
||||||
closeAllResultRows(&pInfo->resultRowInfo);
|
|
||||||
updateNumOfRowsInResultRows(pInfo->pCtx, pOperator->numOfOutput, &pInfo->resultRowInfo, pInfo->rowCellInfoOffset);
|
|
||||||
|
|
||||||
initGroupResInfo(&pAggInfo->groupResInfo, &pInfo->resultRowInfo);
|
|
||||||
toSDatablock(pInfo->pRes, pAggInfo->binfo.capacity, &pAggInfo->groupResInfo, pOperator->pExpr, pAggInfo->pResultBuf, pAggInfo->binfo.rowCellInfoOffset);
|
|
||||||
|
|
||||||
if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) {
|
|
||||||
doSetOperatorCompleted(pOperator);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pInfo->pRes;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator, bool* newgroup) {
|
static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
SProjectOperatorInfo* pProjectInfo = pOperator->info;
|
SProjectOperatorInfo* pProjectInfo = pOperator->info;
|
||||||
SOptrBasicInfo* pInfo = &pProjectInfo->binfo;
|
SOptrBasicInfo* pInfo = &pProjectInfo->binfo;
|
||||||
|
@ -5232,6 +5153,7 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
STableIntervalOperatorInfo* pInfo = pOperator->info;
|
STableIntervalOperatorInfo* pInfo = pOperator->info;
|
||||||
|
|
||||||
int32_t order = TSDB_ORDER_ASC;
|
int32_t order = TSDB_ORDER_ASC;
|
||||||
|
@ -5251,6 +5173,9 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
// setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->pCtx, pOperator->numOfOutput);
|
// setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->pCtx, pOperator->numOfOutput);
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order);
|
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order);
|
||||||
|
STableQueryInfo* pTableQueryInfo = pInfo->pCurrent;
|
||||||
|
|
||||||
|
setIntervalQueryRange(pTableQueryInfo, pBlock->info.window.skey, &pTaskInfo->window);
|
||||||
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0);
|
hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0);
|
||||||
|
|
||||||
#if 0 // test for encode/decode result info
|
#if 0 // test for encode/decode result info
|
||||||
|
@ -5288,15 +5213,15 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator, bool* newgro
|
||||||
|
|
||||||
if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) {
|
if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM) {
|
||||||
return pOperator->getStreamResFn(pOperator, newgroup);
|
return pOperator->getStreamResFn(pOperator, newgroup);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
pTaskInfo->code = pOperator->_openFn(pOperator);
|
pTaskInfo->code = pOperator->_openFn(pOperator);
|
||||||
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
|
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity);
|
blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity);
|
||||||
toSDatablock(pInfo->binfo.pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset);
|
toSDatablock(pInfo->binfo.pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr,
|
||||||
|
pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset);
|
||||||
|
|
||||||
if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
|
@ -5304,6 +5229,7 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator, bool* newgro
|
||||||
|
|
||||||
return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
|
return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* doStreamIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) {
|
static SSDataBlock* doStreamIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) {
|
||||||
STableIntervalOperatorInfo* pInfo = pOperator->info;
|
STableIntervalOperatorInfo* pInfo = pOperator->info;
|
||||||
|
@ -5411,20 +5337,18 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableIntervalOperatorInfo* pIntervalInfo = pOperator->info;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
STaskRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv;
|
|
||||||
|
|
||||||
|
STableIntervalOperatorInfo* pInfo = pOperator->info;
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
|
if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
// copyToSDataBlock(NULL, 3000, pIntervalInfo->pRes, pIntervalInfo->rowCellInfoOffset);
|
|
||||||
if (pIntervalInfo->binfo.pRes->info.rows == 0 || !hasRemainData(&pRuntimeEnv->groupResInfo)) {
|
|
||||||
doSetOperatorCompleted(pOperator);
|
doSetOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
return pIntervalInfo->binfo.pRes;
|
|
||||||
|
return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr;
|
|
||||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -5437,25 +5361,30 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup
|
||||||
}
|
}
|
||||||
|
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current;
|
|
||||||
|
|
||||||
// setTagValue(pOperator, pTableQueryInfo->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput);
|
// setTagValue(pOperator, pTableQueryInfo->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput);
|
||||||
setInputDataBlock(pOperator, pIntervalInfo->binfo.pCtx, pBlock, TSDB_ORDER_ASC);
|
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, TSDB_ORDER_ASC);
|
||||||
setIntervalQueryRange(pRuntimeEnv, pBlock->info.window.skey);
|
STableQueryInfo* pTableQueryInfo = pInfo->pCurrent;
|
||||||
|
|
||||||
hashIntervalAgg(pOperator, &pTableQueryInfo->resInfo, pBlock, pTableQueryInfo->groupIndex);
|
setIntervalQueryRange(pTableQueryInfo, pBlock->info.window.skey, &pTaskInfo->window);
|
||||||
|
// hashIntervalAgg(pOperator, &pTableQueryInfo->resInfo, pBlock, pBlock->info.groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
closeAllResultRows(&pInfo->binfo.resultRowInfo);
|
||||||
doCloseAllTimeWindow(pRuntimeEnv);
|
finalizeMultiTupleQueryResult(pInfo->binfo.pCtx, pOperator->numOfOutput, pInfo->aggSup.pResultBuf,
|
||||||
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
&pInfo->binfo.resultRowInfo, pInfo->binfo.rowCellInfoOffset);
|
||||||
|
|
||||||
// copyToSDataBlock(pRuntimeEnv, 3000, pIntervalInfo->pRes, pIntervalInfo->rowCellInfoOffset);
|
initGroupResInfo(&pInfo->groupResInfo, &pInfo->binfo.resultRowInfo);
|
||||||
if (pIntervalInfo->binfo.pRes->info.rows == 0 || !hasRemainData(&pRuntimeEnv->groupResInfo)) {
|
OPTR_SET_OPENED(pOperator);
|
||||||
pOperator->status = OP_EXEC_DONE;
|
|
||||||
|
blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity);
|
||||||
|
toSDatablock(pInfo->binfo.pRes, pInfo->binfo.capacity, &pInfo->groupResInfo, pOperator->pExpr,
|
||||||
|
pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset);
|
||||||
|
|
||||||
|
if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
|
doSetOperatorCompleted(pOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pIntervalInfo->binfo.pRes;
|
return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doAllSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup) {
|
static SSDataBlock* doAllSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
|
@ -5491,14 +5420,13 @@ static SSDataBlock* doAllSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgr
|
||||||
|
|
||||||
// setTagValue(pOperator, pTableQueryInfo->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput);
|
// setTagValue(pOperator, pTableQueryInfo->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput);
|
||||||
// setInputDataBlock(pOperator, pIntervalInfo->binfo.pCtx, pBlock, pQueryAttr->order.order);
|
// setInputDataBlock(pOperator, pIntervalInfo->binfo.pCtx, pBlock, pQueryAttr->order.order);
|
||||||
setIntervalQueryRange(pRuntimeEnv, pBlock->info.window.skey);
|
// setIntervalQueryRange(pRuntimeEnv, pBlock->info.window.skey);
|
||||||
|
|
||||||
hashAllIntervalAgg(pOperator, &pTableQueryInfo->resInfo, pBlock, pTableQueryInfo->groupIndex);
|
// hashAllIntervalAgg(pOperator, &pTableQueryInfo->resInfo, pBlock, pTableQueryInfo->groupIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
// pQueryAttr->order.order = order; // TODO : restore the order
|
// pQueryAttr->order.order = order; // TODO : restore the order
|
||||||
doCloseAllTimeWindow(pRuntimeEnv);
|
|
||||||
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
||||||
|
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
|
@ -5872,9 +5800,9 @@ static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInf
|
||||||
STableKeyInfo* pk = taosArrayGet(pa, j);
|
STableKeyInfo* pk = taosArrayGet(pa, j);
|
||||||
|
|
||||||
STableQueryInfo* pTQueryInfo = &pTableQueryInfo[index++];
|
STableQueryInfo* pTQueryInfo = &pTableQueryInfo[index++];
|
||||||
pTQueryInfo->uid = pk->uid;
|
// pTQueryInfo->uid = pk->uid;
|
||||||
pTQueryInfo->lastKey = pk->lastKey;
|
pTQueryInfo->lastKey = pk->lastKey;
|
||||||
pTQueryInfo->groupIndex = i;
|
// pTQueryInfo->groupIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5884,15 +5812,14 @@ static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInf
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo,
|
SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo,
|
||||||
const STableGroupInfo* pTableGroupInfo) {
|
int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo) {
|
||||||
SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo));
|
SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
//(int32_t)(getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery));
|
|
||||||
int32_t numOfRows = 1;
|
int32_t numOfRows = 1;
|
||||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||||
int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResultBlock, keyBufSize, pTaskInfo->id.str);
|
int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResultBlock, keyBufSize, pTaskInfo->id.str);
|
||||||
|
@ -5901,7 +5828,18 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
setFunctionResultOutput(&pInfo->binfo, &pInfo->aggSup, MAIN_SCAN, pTaskInfo);
|
pOperator->resultInfo.capacity = 4096;
|
||||||
|
pOperator->resultInfo.threshold = 4096 * 0.75;
|
||||||
|
|
||||||
|
int32_t numOfGroup = 10; // todo replaced with true value
|
||||||
|
pInfo->groupId = INT32_MIN;
|
||||||
|
initResultRowInfo(&pInfo->binfo.resultRowInfo, numOfGroup);
|
||||||
|
|
||||||
|
pInfo->pScalarExprInfo = pScalarExprInfo;
|
||||||
|
pInfo->numOfScalarExpr = numOfScalarExpr;
|
||||||
|
if (pInfo->pScalarExprInfo != NULL) {
|
||||||
|
pInfo->pScalarCtx = createSqlFunctionCtx(pScalarExprInfo, numOfCols, &pInfo->rowCellInfoOffset);
|
||||||
|
}
|
||||||
|
|
||||||
pOperator->name = "TableAggregate";
|
pOperator->name = "TableAggregate";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_AGG;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_AGG;
|
||||||
|
@ -5910,11 +5848,11 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pExpr = pExprInfo;
|
pOperator->pExpr = pExprInfo;
|
||||||
pOperator->numOfOutput = numOfCols;
|
pOperator->numOfOutput = numOfCols;
|
||||||
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
pOperator->_openFn = doOpenAggregateOptr;
|
pOperator->_openFn = doOpenAggregateOptr;
|
||||||
pOperator->getNextFn = getAggregateResult;
|
pOperator->getNextFn = getAggregateResult;
|
||||||
pOperator->closeFn = destroyAggOperatorInfo;
|
pOperator->closeFn = destroyAggOperatorInfo;
|
||||||
|
|
||||||
pOperator->encodeResultRow = aggEncodeResultRow;
|
pOperator->encodeResultRow = aggEncodeResultRow;
|
||||||
pOperator->decodeResultRow = aggDecodeResultRow;
|
pOperator->decodeResultRow = aggDecodeResultRow;
|
||||||
|
|
||||||
|
@ -6005,46 +5943,6 @@ void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
tsem_destroy(&pExInfo->ready);
|
tsem_destroy(&pExInfo->ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
|
||||||
SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo,
|
|
||||||
const STableGroupInfo* pTableGroupInfo) {
|
|
||||||
SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo));
|
|
||||||
|
|
||||||
int32_t numOfRows = 1;
|
|
||||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
|
||||||
int32_t code =
|
|
||||||
initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, keyBufSize, pTaskInfo->id.str);
|
|
||||||
pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo);
|
|
||||||
if (code != TSDB_CODE_SUCCESS || pInfo->pTableQueryInfo == NULL) {
|
|
||||||
goto _error;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t tableGroup = taosArrayGetSize(pTableGroupInfo->pGroupList);
|
|
||||||
initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)tableGroup);
|
|
||||||
|
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
|
||||||
pOperator->name = "MultiTableAggregate";
|
|
||||||
// pOperator->operatorType = OP_MultiTableAggregate;
|
|
||||||
pOperator->blockingOptr = true;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
pOperator->pExpr = pExprInfo;
|
|
||||||
pOperator->numOfOutput = numOfCols;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
|
||||||
|
|
||||||
pOperator->getNextFn = doMultiTableAggregate;
|
|
||||||
pOperator->closeFn = destroyAggOperatorInfo;
|
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
goto _error;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pOperator;
|
|
||||||
|
|
||||||
_error:
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols) {
|
static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols) {
|
||||||
SArray* pList = taosArrayInit(4, sizeof(int32_t));
|
SArray* pList = taosArrayInit(4, sizeof(int32_t));
|
||||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
@ -6276,52 +6174,6 @@ _error:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
|
|
||||||
SExprInfo* pExpr, int32_t numOfOutput) {
|
|
||||||
STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo));
|
|
||||||
|
|
||||||
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8);
|
|
||||||
|
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
|
||||||
pOperator->name = "MultiTableTimeIntervalOperator";
|
|
||||||
// pOperator->operatorType = OP_MultiTableTimeInterval;
|
|
||||||
pOperator->blockingOptr = true;
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->pExpr = pExpr;
|
|
||||||
pOperator->numOfOutput = numOfOutput;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
|
|
||||||
pOperator->getNextFn = doSTableIntervalAgg;
|
|
||||||
pOperator->closeFn = destroyBasicOperatorInfo;
|
|
||||||
|
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
|
||||||
return pOperator;
|
|
||||||
}
|
|
||||||
|
|
||||||
SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
|
|
||||||
SExprInfo* pExpr, int32_t numOfOutput) {
|
|
||||||
STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo));
|
|
||||||
|
|
||||||
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8);
|
|
||||||
|
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
|
||||||
pOperator->name = "AllMultiTableTimeIntervalOperator";
|
|
||||||
// pOperator->operatorType = OP_AllMultiTableTimeInterval;
|
|
||||||
pOperator->blockingOptr = true;
|
|
||||||
|
|
||||||
pOperator->status = OP_NOT_OPENED;
|
|
||||||
pOperator->pExpr = pExpr;
|
|
||||||
pOperator->numOfOutput = numOfOutput;
|
|
||||||
pOperator->info = pInfo;
|
|
||||||
|
|
||||||
pOperator->getNextFn = doAllSTableIntervalAgg;
|
|
||||||
pOperator->closeFn = destroyBasicOperatorInfo;
|
|
||||||
|
|
||||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
|
||||||
|
|
||||||
return pOperator;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t numOfCols, int64_t* fillVal,
|
static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t numOfCols, int64_t* fillVal,
|
||||||
STimeWindow win, int32_t capacity, const char* id, SInterval* pInterval, int32_t fillType) {
|
STimeWindow win, int32_t capacity, const char* id, SInterval* pInterval, int32_t fillType) {
|
||||||
struct SFillColInfo* pColInfo = createFillColInfo(pExpr, numOfCols, (int64_t*)fillVal);
|
struct SFillColInfo* pColInfo = createFillColInfo(pExpr, numOfCols, (int64_t*)fillVal);
|
||||||
|
@ -6733,8 +6585,9 @@ static SArray* extractPartitionColInfo(SNodeList* pNodeList);
|
||||||
|
|
||||||
SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle,
|
SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle,
|
||||||
uint64_t queryId, uint64_t taskId, STableGroupInfo* pTableGroupInfo) {
|
uint64_t queryId, uint64_t taskId, STableGroupInfo* pTableGroupInfo) {
|
||||||
if (pPhyNode->pChildren == NULL || LIST_LENGTH(pPhyNode->pChildren) == 0) {
|
|
||||||
int32_t type = nodeType(pPhyNode);
|
int32_t type = nodeType(pPhyNode);
|
||||||
|
|
||||||
|
if (pPhyNode->pChildren == NULL || LIST_LENGTH(pPhyNode->pChildren) == 0) {
|
||||||
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) {
|
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) {
|
||||||
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode;
|
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode;
|
||||||
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode* ) pPhyNode;
|
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode* ) pPhyNode;
|
||||||
|
@ -6748,8 +6601,16 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
|
SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols);
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc);
|
||||||
|
|
||||||
return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pTableScanNode->dataRequired, pScanPhyNode->count,
|
SInterval interval = {
|
||||||
pScanPhyNode->reverse, pColList, pResBlock, pScanPhyNode->node.pConditions, pTaskInfo);
|
.interval = pTableScanNode->interval,
|
||||||
|
.sliding = pTableScanNode->sliding,
|
||||||
|
.intervalUnit = pTableScanNode->intervalUnit,
|
||||||
|
.slidingUnit = pTableScanNode->slidingUnit,
|
||||||
|
.offset = pTableScanNode->offset,
|
||||||
|
};
|
||||||
|
|
||||||
|
return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pTableScanNode->dataRequired,
|
||||||
|
pScanPhyNode->count, pScanPhyNode->reverse, pColList, pResBlock, pScanPhyNode->node.pConditions, &interval, pTableScanNode->ratio, pTaskInfo);
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
||||||
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode;
|
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode;
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pExchange->node.pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createResDataBlock(pExchange->node.pOutputDataBlockDesc);
|
||||||
|
@ -6784,7 +6645,6 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
int32_t type = nodeType(pPhyNode);
|
|
||||||
size_t size = LIST_LENGTH(pPhyNode->pChildren);
|
size_t size = LIST_LENGTH(pPhyNode->pChildren);
|
||||||
|
|
||||||
SOperatorInfo** ops = taosMemoryCalloc(size, POINTER_BYTES);
|
SOperatorInfo** ops = taosMemoryCalloc(size, POINTER_BYTES);
|
||||||
|
@ -6807,17 +6667,17 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num);
|
SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num);
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
|
||||||
|
|
||||||
SExprInfo* pScalarExprInfo = NULL;
|
|
||||||
int32_t numOfScalarExpr = 0;
|
int32_t numOfScalarExpr = 0;
|
||||||
if (pAggNode->pGroupKeys != NULL) {
|
SExprInfo* pScalarExprInfo = NULL;
|
||||||
SArray* pColList = extractColumnInfo(pAggNode->pGroupKeys);
|
|
||||||
if (pAggNode->pExprs != NULL) {
|
if (pAggNode->pExprs != NULL) {
|
||||||
pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr);
|
pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pAggNode->pGroupKeys != NULL) {
|
||||||
|
SArray* pColList = extractColumnInfo(pAggNode->pGroupKeys);
|
||||||
pOptr = createGroupOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo, NULL);
|
pOptr = createGroupOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo, NULL);
|
||||||
} else {
|
} else {
|
||||||
pOptr = createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo);
|
pOptr = createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pScalarExprInfo, numOfScalarExpr, pTaskInfo, pTableGroupInfo);
|
||||||
}
|
}
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_INTERVAL == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_INTERVAL == type) {
|
||||||
SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode;
|
SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode;
|
||||||
|
@ -6831,7 +6691,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
.intervalUnit = pIntervalPhyNode->intervalUnit,
|
.intervalUnit = pIntervalPhyNode->intervalUnit,
|
||||||
.slidingUnit = pIntervalPhyNode->slidingUnit,
|
.slidingUnit = pIntervalPhyNode->slidingUnit,
|
||||||
.offset = pIntervalPhyNode->offset,
|
.offset = pIntervalPhyNode->offset,
|
||||||
.precision = pIntervalPhyNode->precision
|
.precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t primaryTsSlotId = ((SColumnNode*) pIntervalPhyNode->window.pTspk)->slotId;
|
int32_t primaryTsSlotId = ((SColumnNode*) pIntervalPhyNode->window.pTspk)->slotId;
|
||||||
|
@ -6870,16 +6730,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
pOptr = createJoinOperatorInfo(ops, size, pExprInfo, num, pResBlock, pJoinNode->pOnConditions, pTaskInfo);
|
pOptr = createJoinOperatorInfo(ops, size, pExprInfo, num, pResBlock, pJoinNode->pOnConditions, pTaskInfo);
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
} /*else if (pPhyNode->info.type == OP_MultiTableAggregate) {
|
|
||||||
size_t size = taosArrayGetSize(pPhyNode->pChildren);
|
|
||||||
assert(size == 1);
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
|
||||||
SPhysiNode* pChildNode = taosArrayGetP(pPhyNode->pChildren, i);
|
|
||||||
SOperatorInfo* op = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo);
|
|
||||||
return createMultiTableAggOperatorInfo(op, pPhyNode->pTargets, pTaskInfo, pTableGroupInfo);
|
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
taosMemoryFree(ops);
|
taosMemoryFree(ops);
|
||||||
return pOptr;
|
return pOptr;
|
||||||
|
@ -7480,7 +7331,7 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
|
||||||
|
|
||||||
pOperator->name = "JoinOperator";
|
pOperator->name = "JoinOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_JOIN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_JOIN;
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blockingOptr = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->pExpr = pExprInfo;
|
pOperator->pExpr = pExprInfo;
|
||||||
pOperator->numOfOutput = numOfCols;
|
pOperator->numOfOutput = numOfCols;
|
||||||
|
|
|
@ -286,7 +286,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order);
|
setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order);
|
||||||
|
|
||||||
// there is an scalar expression that needs to be calculated before apply the group aggregation.
|
// there is an scalar expression that needs to be calculated right before apply the group aggregation.
|
||||||
if (pInfo->pScalarExprInfo != NULL) {
|
if (pInfo->pScalarExprInfo != NULL) {
|
||||||
projectApplyFunctions(pInfo->pScalarExprInfo, pBlock, pBlock, pInfo->pScalarFuncCtx, pInfo->numOfScalarExpr, NULL);
|
projectApplyFunctions(pInfo->pScalarExprInfo, pBlock, pBlock, pInfo->pScalarFuncCtx, pInfo->numOfScalarExpr, NULL);
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,6 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
|
||||||
pInfo->numOfScalarExpr = numOfScalarExpr;
|
pInfo->numOfScalarExpr = numOfScalarExpr;
|
||||||
pInfo->pScalarFuncCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pInfo->binfo.rowCellInfoOffset);
|
pInfo->pScalarFuncCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pInfo->binfo.rowCellInfoOffset);
|
||||||
|
|
||||||
|
|
||||||
int32_t code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, pGroupColList);
|
int32_t code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, pGroupColList);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
|
|
|
@ -22,38 +22,275 @@ typedef struct SIFCtx {
|
||||||
SHashObj *pRes; /* element is SScalarParam */
|
SHashObj *pRes; /* element is SScalarParam */
|
||||||
} SIFCtx;
|
} SIFCtx;
|
||||||
|
|
||||||
|
#define SIF_ERR_RET(c) \
|
||||||
|
do { \
|
||||||
|
int32_t _code = c; \
|
||||||
|
if (_code != TSDB_CODE_SUCCESS) { \
|
||||||
|
terrno = _code; \
|
||||||
|
return _code; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#define SIF_RET(c) \
|
||||||
|
do { \
|
||||||
|
int32_t _code = c; \
|
||||||
|
if (_code != TSDB_CODE_SUCCESS) { \
|
||||||
|
terrno = _code; \
|
||||||
|
} \
|
||||||
|
return _code; \
|
||||||
|
} while (0)
|
||||||
|
#define SIF_ERR_JRET(c) \
|
||||||
|
do { \
|
||||||
|
code = c; \
|
||||||
|
if (code != TSDB_CODE_SUCCESS) { \
|
||||||
|
terrno = code; \
|
||||||
|
goto _return; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
typedef struct SIFParam {
|
typedef struct SIFParam {
|
||||||
SArray * result;
|
SArray * result;
|
||||||
SHashObj *pFilter;
|
SHashObj *pFilter;
|
||||||
} SIFParam;
|
} SIFParam;
|
||||||
|
|
||||||
|
typedef int32_t (*sif_func_t)(SNode *left, SNode *rigth, SIFParam *output);
|
||||||
// construct tag filter operator later
|
// construct tag filter operator later
|
||||||
static void destroyTagFilterOperatorInfo(void *param) {
|
static void destroyTagFilterOperatorInfo(void *param) { STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param; }
|
||||||
STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sifFreeParam(SIFParam *param) {
|
static void sifFreeParam(SIFParam *param) {
|
||||||
if (param == NULL) return;
|
if (param == NULL) return;
|
||||||
taosArrayDestroy(param->result);
|
taosArrayDestroy(param->result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sifInitOperParams(SIFParam *params, SOperatorNode *node, SIFCtx *ctx) {
|
static int32_t sifGetOperParamNum(EOperatorType ty) {
|
||||||
|
if (OP_TYPE_IS_NULL == ty || OP_TYPE_IS_NOT_NULL == ty || OP_TYPE_IS_TRUE == ty || OP_TYPE_IS_NOT_TRUE == ty || OP_TYPE_IS_FALSE == ty ||
|
||||||
|
OP_TYPE_IS_NOT_FALSE == ty || OP_TYPE_IS_UNKNOWN == ty || OP_TYPE_IS_NOT_UNKNOWN == ty || OP_TYPE_MINUS == ty) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
||||||
|
switch (nodeType(node)) {
|
||||||
|
case QUERY_NODE_VALUE: {
|
||||||
|
SValueNode *vn = (SValueNode *)node;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QUERY_NODE_COLUMN: {
|
||||||
|
SColumnNode *cn = (SColumnNode *)node;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QUERY_NODE_NODE_LIST: {
|
||||||
|
SNodeListNode *nl = (SNodeListNode *)node;
|
||||||
|
if (LIST_LENGTH(nl->pNodeList) <= 0) {
|
||||||
|
qError("invalid length for node:%p, length: %d", node, LIST_LENGTH(nl->pNodeList));
|
||||||
|
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) {
|
||||||
|
taosHashCleanup(param->pFilter);
|
||||||
|
qError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param));
|
||||||
|
SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QUERY_NODE_FUNCTION:
|
||||||
|
case QUERY_NODE_OPERATOR:
|
||||||
|
case QUERY_NODE_LOGIC_CONDITION: {
|
||||||
|
SIFParam *res = (SIFParam *)taosHashGet(ctx->pRes, &node, POINTER_BYTES);
|
||||||
|
if (NULL == res) {
|
||||||
|
qError("no result for node, type:%d, node:%p", nodeType(node), node);
|
||||||
|
SIF_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||||
|
}
|
||||||
|
*param = *res;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx *ctx) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
return code;
|
int32_t nParam = sifGetOperParamNum(node->opType);
|
||||||
|
if (NULL == node->pLeft || (nParam == 2 && NULL == node->pRight)) {
|
||||||
|
qError("invalid operation node, left: %p, rigth: %p", node->pLeft, node->pRight);
|
||||||
|
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam));
|
||||||
|
if (NULL == paramList) {
|
||||||
|
SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
SIF_ERR_JRET(sifInitParam(node->pLeft, ¶mList[0], ctx));
|
||||||
|
if (nParam > 1) {
|
||||||
|
SIF_ERR_JRET(sifInitParam(node->pRight, ¶mList[1], ctx));
|
||||||
|
}
|
||||||
|
*params = paramList;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
_return:
|
||||||
|
taosMemoryFree(paramList);
|
||||||
|
SIF_RET(code);
|
||||||
|
}
|
||||||
|
static int32_t sifInitParamList(SIFParam **params, SNodeList *nodeList, SIFCtx *ctx) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SIFParam *tParams = taosMemoryCalloc(nodeList->length, sizeof(SIFParam));
|
||||||
|
if (tParams == NULL) {
|
||||||
|
qError("failed to calloc, nodeList: %p", nodeList);
|
||||||
|
SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
SListCell *cell = nodeList->pHead;
|
||||||
|
for (int32_t i = 0; i < nodeList->length; i++) {
|
||||||
|
if (NULL == cell || NULL == cell->pNode) {
|
||||||
|
SIF_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
SIF_ERR_JRET(sifInitParam(cell->pNode, &tParams[i], ctx));
|
||||||
|
cell = cell->pNext;
|
||||||
|
}
|
||||||
|
*params = tParams;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
taosMemoryFree(tParams);
|
||||||
|
SIF_RET(code);
|
||||||
}
|
}
|
||||||
static int32_t sifExecFunction(SFunctionNode *node, SIFCtx *ctx, SIFParam *output) {
|
static int32_t sifExecFunction(SFunctionNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||||
qError("index-filter not support buildin function");
|
qError("index-filter not support buildin function");
|
||||||
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sifLessThanFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
static int32_t sifLessEqualFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifGreaterThanFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifGreaterEqualFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sifEqualFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifNotEqualFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifInFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifNotInFunc(SNode *left, SNode *right, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifLikeFunc(SNode *left, SNode *right, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifNotLikeFunc(SNode *left, SNode *right, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sifMatchFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifNotMatchFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// impl later
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
static int32_t sifDefaultFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
||||||
|
// add more except
|
||||||
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static sif_func_t sifGetOperFn(int32_t funcId) {
|
||||||
|
// impl later
|
||||||
|
switch (funcId) {
|
||||||
|
case OP_TYPE_GREATER_THAN:
|
||||||
|
return sifGreaterThanFunc;
|
||||||
|
case OP_TYPE_GREATER_EQUAL:
|
||||||
|
return sifGreaterEqualFunc;
|
||||||
|
case OP_TYPE_LOWER_THAN:
|
||||||
|
return sifLessThanFunc;
|
||||||
|
case OP_TYPE_LOWER_EQUAL:
|
||||||
|
return sifLessEqualFunc;
|
||||||
|
case OP_TYPE_EQUAL:
|
||||||
|
return sifEqualFunc;
|
||||||
|
case OP_TYPE_NOT_EQUAL:
|
||||||
|
return sifNotEqualFunc;
|
||||||
|
case OP_TYPE_IN:
|
||||||
|
return sifInFunc;
|
||||||
|
case OP_TYPE_NOT_IN:
|
||||||
|
return sifNotInFunc;
|
||||||
|
case OP_TYPE_LIKE:
|
||||||
|
return sifLikeFunc;
|
||||||
|
case OP_TYPE_NOT_LIKE:
|
||||||
|
return sifNotLikeFunc;
|
||||||
|
case OP_TYPE_MATCH:
|
||||||
|
return sifMatchFunc;
|
||||||
|
case OP_TYPE_NMATCH:
|
||||||
|
return sifNotMatchFunc;
|
||||||
|
default:
|
||||||
|
return sifDefaultFunc;
|
||||||
|
}
|
||||||
|
return sifDefaultFunc;
|
||||||
|
}
|
||||||
static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
|
static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||||
|
int32_t code = 0;
|
||||||
SIFParam *params = NULL;
|
SIFParam *params = NULL;
|
||||||
|
SIF_ERR_RET(sifInitOperParams(¶ms, node, ctx));
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
int32_t nParam = sifGetOperParamNum(node->opType);
|
||||||
|
if (nParam <= 1) {
|
||||||
|
SIF_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
sif_func_t operFn = sifGetOperFn(node->opType);
|
||||||
|
|
||||||
|
return operFn(node->pLeft, node->pRight, output);
|
||||||
|
_return:
|
||||||
|
taosMemoryFree(params);
|
||||||
|
SIF_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *output) { return TSDB_CODE_SUCCESS; }
|
static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||||
|
if (NULL == node->pParameterList || node->pParameterList->length <= 0) {
|
||||||
|
qError("invalid logic parameter list, list:%p, paramNum:%d", node->pParameterList, node->pParameterList ? node->pParameterList->length : 0);
|
||||||
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code;
|
||||||
|
SIFParam *params = NULL;
|
||||||
|
SIF_ERR_RET(sifInitParamList(¶ms, node->pParameterList, ctx));
|
||||||
|
|
||||||
|
for (int32_t m = 0; m < node->pParameterList->length; m++) {
|
||||||
|
// add impl later
|
||||||
|
if (node->condType == LOGIC_COND_TYPE_AND) {
|
||||||
|
taosArrayAddAll(output->result, params[m].result);
|
||||||
|
} else if (node->condType == LOGIC_COND_TYPE_OR) {
|
||||||
|
taosArrayAddAll(output->result, params[m].result);
|
||||||
|
} else if (node->condType == LOGIC_COND_TYPE_NOT) {
|
||||||
|
taosArrayAddAll(output->result, params[m].result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_return:
|
||||||
|
taosMemoryFree(params);
|
||||||
|
SIF_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
static EDealRes sifWalkFunction(SNode *pNode, void *context) {
|
static EDealRes sifWalkFunction(SNode *pNode, void *context) {
|
||||||
// impl later
|
|
||||||
SFunctionNode *node = (SFunctionNode *)pNode;
|
SFunctionNode *node = (SFunctionNode *)pNode;
|
||||||
SIFParam output = {0};
|
SIFParam output = {0};
|
||||||
|
|
||||||
|
@ -104,8 +341,7 @@ static EDealRes sifWalkOper(SNode *pNode, void *context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EDealRes sifCalcWalker(SNode *node, void *context) {
|
EDealRes sifCalcWalker(SNode *node, void *context) {
|
||||||
if (QUERY_NODE_VALUE == nodeType(node) || QUERY_NODE_NODE_LIST == nodeType(node) ||
|
if (QUERY_NODE_VALUE == nodeType(node) || QUERY_NODE_NODE_LIST == nodeType(node) || QUERY_NODE_COLUMN == nodeType(node)) {
|
||||||
QUERY_NODE_COLUMN == nodeType(node)) {
|
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
SIFCtx *ctx = (SIFCtx *)context;
|
SIFCtx *ctx = (SIFCtx *)context;
|
||||||
|
|
|
@ -13,11 +13,13 @@
|
||||||
* 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 "tglobal.h"
|
#include <common/ttime.h>
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
|
#include "functionMgt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
|
#include "tglobal.h"
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
#include "vnode.h"
|
#include "vnode.h"
|
||||||
|
|
||||||
|
@ -64,6 +66,111 @@ static void setupQueryRangeForReverseScan(STableScanInfo* pTableScanInfo) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// relocated the column data according to the slotId
|
||||||
|
static void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray* pCols) {
|
||||||
|
int32_t numOfCols = pBlock->info.numOfCols;
|
||||||
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
SColumnInfoData* p = taosArrayGet(pCols, i);
|
||||||
|
SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, i);
|
||||||
|
if (!pmInfo->output) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(pmInfo->colId == p->info.colId);
|
||||||
|
taosArraySet(pBlock->pDataBlock, pmInfo->targetSlotId, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void getNextTimeWindow(SInterval* pInterval, STimeWindow* tw, int32_t order) {
|
||||||
|
int32_t factor = GET_FORWARD_DIRECTION_FACTOR(order);
|
||||||
|
if (pInterval->intervalUnit != 'n' && pInterval->intervalUnit != 'y') {
|
||||||
|
tw->skey += pInterval->sliding * factor;
|
||||||
|
tw->ekey = tw->skey + pInterval->interval - 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t key = tw->skey, interval = pInterval->interval;
|
||||||
|
//convert key to second
|
||||||
|
key = convertTimePrecision(key, pInterval->precision, TSDB_TIME_PRECISION_MILLI) / 1000;
|
||||||
|
|
||||||
|
if (pInterval->intervalUnit == 'y') {
|
||||||
|
interval *= 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm tm;
|
||||||
|
time_t t = (time_t)key;
|
||||||
|
taosLocalTime(&t, &tm);
|
||||||
|
|
||||||
|
int mon = (int)(tm.tm_year * 12 + tm.tm_mon + interval * factor);
|
||||||
|
tm.tm_year = mon / 12;
|
||||||
|
tm.tm_mon = mon % 12;
|
||||||
|
tw->skey = convertTimePrecision((int64_t)taosMktime(&tm) * 1000L, TSDB_TIME_PRECISION_MILLI, pInterval->precision);
|
||||||
|
|
||||||
|
mon = (int)(mon + interval);
|
||||||
|
tm.tm_year = mon / 12;
|
||||||
|
tm.tm_mon = mon % 12;
|
||||||
|
tw->ekey = convertTimePrecision((int64_t)taosMktime(&tm) * 1000L, TSDB_TIME_PRECISION_MILLI, pInterval->precision);
|
||||||
|
|
||||||
|
tw->ekey -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockInfo) {
|
||||||
|
STimeWindow w = {0};
|
||||||
|
|
||||||
|
// 0 by default, which means it is not a interval operator of the upstream operator.
|
||||||
|
if (pInterval->interval == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo handle the time range case
|
||||||
|
TSKEY sk = INT64_MIN;
|
||||||
|
TSKEY ek = INT64_MAX;
|
||||||
|
// TSKEY sk = MIN(pQueryAttr->window.skey, pQueryAttr->window.ekey);
|
||||||
|
// TSKEY ek = MAX(pQueryAttr->window.skey, pQueryAttr->window.ekey);
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
getAlignQueryTimeWindow(pInterval, pInterval->precision, pBlockInfo->window.skey, sk, ek, &w);
|
||||||
|
assert(w.ekey >= pBlockInfo->window.skey);
|
||||||
|
|
||||||
|
if (w.ekey < pBlockInfo->window.ekey) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(1) { // todo handle the desc order scan case
|
||||||
|
getNextTimeWindow(pInterval, &w, TSDB_ORDER_ASC);
|
||||||
|
if (w.skey > pBlockInfo->window.ekey) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(w.ekey > pBlockInfo->window.ekey);
|
||||||
|
if (w.skey <= pBlockInfo->window.ekey && w.skey > pBlockInfo->window.skey) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// getAlignQueryTimeWindow(pQueryAttr, pBlockInfo->window.ekey, sk, ek, &w);
|
||||||
|
// assert(w.skey <= pBlockInfo->window.ekey);
|
||||||
|
//
|
||||||
|
// if (w.skey > pBlockInfo->window.skey) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// while(1) {
|
||||||
|
// getNextTimeWindow(pQueryAttr, &w);
|
||||||
|
// if (w.ekey < pBlockInfo->window.skey) {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// assert(w.skey < pBlockInfo->window.skey);
|
||||||
|
// if (w.ekey < pBlockInfo->window.ekey && w.ekey >= pBlockInfo->window.skey) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) {
|
int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) {
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
STableScanInfo* pInfo = pOperator->info;
|
STableScanInfo* pInfo = pOperator->info;
|
||||||
|
@ -71,31 +178,81 @@ int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo,
|
||||||
STaskCostInfo* pCost = &pTaskInfo->cost;
|
STaskCostInfo* pCost = &pTaskInfo->cost;
|
||||||
|
|
||||||
pCost->totalBlocks += 1;
|
pCost->totalBlocks += 1;
|
||||||
pCost->loadBlocks += 1;
|
|
||||||
|
|
||||||
pCost->totalRows += pBlock->info.rows;
|
pCost->totalRows += pBlock->info.rows;
|
||||||
pCost->totalCheckedRows += pBlock->info.rows;
|
|
||||||
|
|
||||||
*status = pInfo->dataBlockLoadFlag;
|
*status = pInfo->dataBlockLoadFlag;
|
||||||
|
if (pTableScanInfo->pFilterNode != NULL || overlapWithTimeWindow(&pTableScanInfo->interval, &pBlock->info)) {
|
||||||
|
(*status) = FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDataBlockInfo* pBlockInfo = &pBlock->info;
|
||||||
|
taosMemoryFreeClear(pBlock->pBlockAgg);
|
||||||
|
|
||||||
|
if (*status == FUNC_DATA_REQUIRED_FILTEROUT) {
|
||||||
|
qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), pBlockInfo->window.skey,
|
||||||
|
pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
|
pCost->filterOutBlocks += 1;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
} else if (*status == FUNC_DATA_REQUIRED_NOT_LOAD) {
|
||||||
|
qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), pBlockInfo->window.skey,
|
||||||
|
pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
|
pCost->skipBlocks += 1;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
} else if (*status == FUNC_DATA_REQUIRED_STATIS_LOAD) {
|
||||||
|
pCost->loadBlockStatis += 1;
|
||||||
|
|
||||||
|
SColumnDataAgg* pColAgg = NULL;
|
||||||
|
tsdbRetrieveDataBlockStatisInfo(pTableScanInfo->dataReader, &pColAgg);
|
||||||
|
|
||||||
|
if (pColAgg != NULL) {
|
||||||
|
int32_t numOfCols = pBlock->info.numOfCols;
|
||||||
|
|
||||||
|
// todo create this buffer during creating operator
|
||||||
|
pBlock->pBlockAgg = taosMemoryCalloc(numOfCols, sizeof(SColumnDataAgg));
|
||||||
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
SColMatchInfo* pColMatchInfo = taosArrayGet(pTableScanInfo->pColMatchInfo, i);
|
||||||
|
if (!pColMatchInfo->output) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pBlock->pBlockAgg[pColMatchInfo->targetSlotId] = pColAgg[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
} else { // failed to load the block sma data, data block statistics does not exist, load data block instead
|
||||||
|
*status = FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT (*status == FUNC_DATA_REQUIRED_DATA_LOAD);
|
||||||
|
|
||||||
|
// todo filter data block according to the block sma data firstly
|
||||||
|
#if 0
|
||||||
|
if (!doFilterByBlockStatistics(pBlock->pBlockStatis, pTableScanInfo->pCtx, pBlockInfo->rows)) {
|
||||||
|
pCost->filterOutBlocks += 1;
|
||||||
|
qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), pBlockInfo->window.skey,
|
||||||
|
pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
|
(*status) = FUNC_DATA_REQUIRED_FILTEROUT;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pCost->totalCheckedRows += pBlock->info.rows;
|
||||||
|
pCost->loadBlocks += 1;
|
||||||
|
|
||||||
SArray* pCols = tsdbRetrieveDataBlock(pTableScanInfo->dataReader, NULL);
|
SArray* pCols = tsdbRetrieveDataBlock(pTableScanInfo->dataReader, NULL);
|
||||||
if (pCols == NULL) {
|
if (pCols == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfCols = pBlock->info.numOfCols;
|
relocateColumnData(pBlock, pTableScanInfo->pColMatchInfo, pCols);
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
|
||||||
SColumnInfoData* p = taosArrayGet(pCols, i);
|
|
||||||
SColMatchInfo* pColMatchInfo = taosArrayGet(pTableScanInfo->pColMatchInfo, i);
|
|
||||||
if (!pColMatchInfo->output) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT(pColMatchInfo->colId == p->info.colId);
|
|
||||||
taosArraySet(pBlock->pDataBlock, pColMatchInfo->targetSlotId, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
doFilter(pTableScanInfo->pFilterNode, pBlock);
|
doFilter(pTableScanInfo->pFilterNode, pBlock);
|
||||||
|
if (pBlock->info.rows == 0) {
|
||||||
|
pCost->filterOutBlocks += 1;
|
||||||
|
qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), pBlockInfo->window.skey,
|
||||||
|
pBlockInfo->window.ekey, pBlockInfo->rows);
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +271,6 @@ static void setupEnvForReverseScan(STableScanInfo* pTableScanInfo, SqlFunctionCt
|
||||||
|
|
||||||
static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
|
static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
STableScanInfo* pTableScanInfo = pOperator->info;
|
STableScanInfo* pTableScanInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
|
||||||
|
|
||||||
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
||||||
STableGroupInfo* pTableGroupInfo = &pOperator->pTaskInfo->tableqinfoGroupInfo;
|
STableGroupInfo* pTableGroupInfo = &pOperator->pTaskInfo->tableqinfoGroupInfo;
|
||||||
|
@ -141,15 +297,15 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// this function never returns error?
|
// this function never returns error?
|
||||||
uint32_t status = BLK_DATA_DATA_LOAD;
|
uint32_t status = 0;
|
||||||
int32_t code = loadDataBlock(pOperator, pTableScanInfo, pBlock, &status);
|
int32_t code = loadDataBlock(pOperator, pTableScanInfo, pBlock, &status);
|
||||||
// int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status);
|
// int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
longjmp(pOperator->pTaskInfo->env, code);
|
longjmp(pOperator->pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// current block is ignored according to filter result by block statistics data, continue load the next block
|
// current block is filter out according to filter condition, continue load the next block
|
||||||
if (status == BLK_DATA_FILTEROUT || pBlock->info.rows == 0) {
|
if (status == FUNC_DATA_REQUIRED_FILTEROUT || pBlock->info.rows == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,9 +348,9 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
||||||
pTableScanInfo->scanFlag = REPEAT_SCAN;
|
pTableScanInfo->scanFlag = REPEAT_SCAN;
|
||||||
|
|
||||||
if (pResultRowInfo->size > 0) {
|
// if (pResultRowInfo->size > 0) {
|
||||||
pResultRowInfo->curPos = 0;
|
// pResultRowInfo->curPos = 0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
qDebug("%s start to repeat scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64,
|
qDebug("%s start to repeat scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64,
|
||||||
GET_TASKID(pTaskInfo), pTaskInfo->window.skey, pTaskInfo->window.ekey);
|
GET_TASKID(pTaskInfo), pTaskInfo->window.skey, pTaskInfo->window.ekey);
|
||||||
|
@ -211,7 +367,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
GET_TASKID(pTaskInfo), pTaskInfo->window.skey, pTaskInfo->window.ekey);
|
GET_TASKID(pTaskInfo), pTaskInfo->window.skey, pTaskInfo->window.ekey);
|
||||||
|
|
||||||
if (pResultRowInfo->size > 0) {
|
if (pResultRowInfo->size > 0) {
|
||||||
pResultRowInfo->curPos = pResultRowInfo->size - 1;
|
// pResultRowInfo->curPos = pResultRowInfo->size - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = doTableScanImpl(pOperator, newgroup);
|
p = doTableScanImpl(pOperator, newgroup);
|
||||||
|
@ -222,7 +378,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
|
|
||||||
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput, int32_t dataLoadFlag,
|
SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput, int32_t dataLoadFlag,
|
||||||
int32_t repeatTime, int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock,
|
int32_t repeatTime, int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock,
|
||||||
SNode* pCondition, SExecTaskInfo* pTaskInfo) {
|
SNode* pCondition, SInterval* pInterval, double sampleRatio, SExecTaskInfo* pTaskInfo) {
|
||||||
assert(repeatTime > 0);
|
assert(repeatTime > 0);
|
||||||
|
|
||||||
STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo));
|
STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo));
|
||||||
|
@ -235,6 +391,8 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pInfo->interval = *pInterval;
|
||||||
|
pInfo->sampleRatio = sampleRatio;
|
||||||
pInfo->dataBlockLoadFlag= dataLoadFlag;
|
pInfo->dataBlockLoadFlag= dataLoadFlag;
|
||||||
pInfo->pResBlock = pResBlock;
|
pInfo->pResBlock = pResBlock;
|
||||||
pInfo->pFilterNode = pCondition;
|
pInfo->pFilterNode = pCondition;
|
||||||
|
|
|
@ -8,7 +8,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
||||||
ADD_EXECUTABLE(executorTest ${SOURCE_LIST})
|
ADD_EXECUTABLE(executorTest ${SOURCE_LIST})
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
executorTest
|
executorTest
|
||||||
PRIVATE os util common transport gtest taos qcom executor function planner scalar nodes
|
PRIVATE os util common transport gtest taos_static qcom executor function planner scalar nodes
|
||||||
)
|
)
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(
|
TARGET_INCLUDE_DIRECTORIES(
|
||||||
|
|
|
@ -30,6 +30,7 @@ EFuncDataRequired countDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWind
|
||||||
bool getCountFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getCountFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
int32_t countFunction(SqlFunctionCtx *pCtx);
|
int32_t countFunction(SqlFunctionCtx *pCtx);
|
||||||
|
|
||||||
|
EFuncDataRequired statisDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||||
bool getSumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
bool getSumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
int32_t sumFunction(SqlFunctionCtx *pCtx);
|
int32_t sumFunction(SqlFunctionCtx *pCtx);
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,12 @@ static int32_t translateTimePseudoColumn(SFunctionNode* pFunc, char* pErrBuf, in
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t translateTimezone(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
|
// pseudo column do not need to check parameters
|
||||||
|
pFunc->node.resType = (SDataType){.bytes = TD_TIMEZONE_LEN, .type = TSDB_DATA_TYPE_BINARY};
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translatePercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
static int32_t translatePercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||||
if (2 != LIST_LENGTH(pFunc->pParameterList)) {
|
if (2 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||||
|
@ -399,8 +405,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "sum",
|
.name = "sum",
|
||||||
.type = FUNCTION_TYPE_SUM,
|
.type = FUNCTION_TYPE_SUM,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||||
.translateFunc = translateSum,
|
.translateFunc = translateSum,
|
||||||
|
.dataRequiredFunc = statisDataRequired,
|
||||||
.getEnvFunc = getSumFuncEnv,
|
.getEnvFunc = getSumFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = sumFunction,
|
.processFunc = sumFunction,
|
||||||
|
@ -409,8 +416,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "min",
|
.name = "min",
|
||||||
.type = FUNCTION_TYPE_MIN,
|
.type = FUNCTION_TYPE_MIN,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||||
.translateFunc = translateInOutNum,
|
.translateFunc = translateInOutNum,
|
||||||
|
.dataRequiredFunc = statisDataRequired,
|
||||||
.getEnvFunc = getMinmaxFuncEnv,
|
.getEnvFunc = getMinmaxFuncEnv,
|
||||||
.initFunc = minFunctionSetup,
|
.initFunc = minFunctionSetup,
|
||||||
.processFunc = minFunction,
|
.processFunc = minFunction,
|
||||||
|
@ -419,8 +427,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "max",
|
.name = "max",
|
||||||
.type = FUNCTION_TYPE_MAX,
|
.type = FUNCTION_TYPE_MAX,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||||
.translateFunc = translateInOutNum,
|
.translateFunc = translateInOutNum,
|
||||||
|
.dataRequiredFunc = statisDataRequired,
|
||||||
.getEnvFunc = getMinmaxFuncEnv,
|
.getEnvFunc = getMinmaxFuncEnv,
|
||||||
.initFunc = maxFunctionSetup,
|
.initFunc = maxFunctionSetup,
|
||||||
.processFunc = maxFunction,
|
.processFunc = maxFunction,
|
||||||
|
@ -816,6 +825,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.sprocessFunc = todayFunction,
|
.sprocessFunc = todayFunction,
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "timezone",
|
||||||
|
.type = FUNCTION_TYPE_TIMEZONE,
|
||||||
|
.classification = FUNC_MGT_SCALAR_FUNC,
|
||||||
|
.translateFunc = translateTimezone,
|
||||||
|
.getEnvFunc = NULL,
|
||||||
|
.initFunc = NULL,
|
||||||
|
.sprocessFunc = timezoneFunction,
|
||||||
|
.finalizeFunc = NULL
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "_rowts",
|
.name = "_rowts",
|
||||||
.type = FUNCTION_TYPE_ROWTS,
|
.type = FUNCTION_TYPE_ROWTS,
|
||||||
|
|
|
@ -183,6 +183,10 @@ bool getSumFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EFuncDataRequired statisDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow){
|
||||||
|
return FUNC_DATA_REQUIRED_STATIS_LOAD;
|
||||||
|
}
|
||||||
|
|
||||||
bool maxFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) {
|
bool maxFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) {
|
||||||
if (!functionSetup(pCtx, pResultInfo)) {
|
if (!functionSetup(pCtx, pResultInfo)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -357,20 +361,15 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
|
||||||
index = pInput->pColumnDataAgg[0]->maxIndex;
|
index = pInput->pColumnDataAgg[0]->maxIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSKEY key = TSKEY_INITIAL_VAL;
|
|
||||||
if (pCtx->ptsList != NULL) {
|
|
||||||
// the index is the original position, not the relative position
|
// the index is the original position, not the relative position
|
||||||
key = pCtx->ptsList[index];
|
TSKEY key = (pCtx->ptsList != NULL)? pCtx->ptsList[index]:TSKEY_INITIAL_VAL;
|
||||||
}
|
|
||||||
|
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||||
|
int64_t prev = 0;
|
||||||
|
GET_TYPED_DATA(prev, int64_t, type, buf);
|
||||||
|
|
||||||
int64_t val = GET_INT64_VAL(tval);
|
int64_t val = GET_INT64_VAL(tval);
|
||||||
|
if ((prev < val) ^ isMinFunc) {
|
||||||
#if defined(_DEBUG_VIEW)
|
|
||||||
qDebug("max value updated according to pre-cal:%d", *data);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((*(int64_t*)buf < val) ^ isMinFunc) {
|
|
||||||
*(int64_t*) buf = val;
|
*(int64_t*) buf = val;
|
||||||
for (int32_t i = 0; i < (pCtx)->subsidiaryRes.numOfCols; ++i) {
|
for (int32_t i = 0; i < (pCtx)->subsidiaryRes.numOfCols; ++i) {
|
||||||
SqlFunctionCtx* __ctx = pCtx->subsidiaryRes.pCtx[i];
|
SqlFunctionCtx* __ctx = pCtx->subsidiaryRes.pCtx[i];
|
||||||
|
@ -383,14 +382,28 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||||
|
uint64_t prev = 0;
|
||||||
|
GET_TYPED_DATA(prev, uint64_t, type, buf);
|
||||||
|
|
||||||
uint64_t val = GET_UINT64_VAL(tval);
|
uint64_t val = GET_UINT64_VAL(tval);
|
||||||
UPDATE_DATA(pCtx, *(uint64_t*)buf, val, numOfElems, isMinFunc, key);
|
if ((prev < val) ^ isMinFunc) {
|
||||||
|
*(uint64_t*) buf = val;
|
||||||
|
for (int32_t i = 0; i < (pCtx)->subsidiaryRes.numOfCols; ++i) {
|
||||||
|
SqlFunctionCtx* __ctx = pCtx->subsidiaryRes.pCtx[i];
|
||||||
|
if (__ctx->functionId == FUNCTION_TS_DUMMY) { // TODO refactor
|
||||||
|
__ctx->tag.i = key;
|
||||||
|
__ctx->tag.nType = TSDB_DATA_TYPE_BIGINT;
|
||||||
|
}
|
||||||
|
|
||||||
|
__ctx->fpSet.process(__ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (type == TSDB_DATA_TYPE_DOUBLE) {
|
} else if (type == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
double val = GET_DOUBLE_VAL(tval);
|
double val = GET_DOUBLE_VAL(tval);
|
||||||
UPDATE_DATA(pCtx, *(double*) buf, val, numOfElems, isMinFunc, key);
|
UPDATE_DATA(pCtx, *(double*) buf, val, numOfElems, isMinFunc, key);
|
||||||
} else if (type == TSDB_DATA_TYPE_FLOAT) {
|
} else if (type == TSDB_DATA_TYPE_FLOAT) {
|
||||||
double val = GET_DOUBLE_VAL(tval);
|
double val = GET_DOUBLE_VAL(tval);
|
||||||
UPDATE_DATA(pCtx, *(float*)buf, (float)val, numOfElems, isMinFunc, key);
|
UPDATE_DATA(pCtx, *(float*) buf, val, numOfElems, isMinFunc, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return numOfElems;
|
return numOfElems;
|
||||||
|
|
|
@ -748,6 +748,11 @@ static const char* jkTableScanPhysiPlanEndKey = "EndKey";
|
||||||
static const char* jkTableScanPhysiPlanRatio = "Ratio";
|
static const char* jkTableScanPhysiPlanRatio = "Ratio";
|
||||||
static const char* jkTableScanPhysiPlanDataRequired = "DataRequired";
|
static const char* jkTableScanPhysiPlanDataRequired = "DataRequired";
|
||||||
static const char* jkTableScanPhysiPlanDynamicScanFuncs = "DynamicScanFuncs";
|
static const char* jkTableScanPhysiPlanDynamicScanFuncs = "DynamicScanFuncs";
|
||||||
|
static const char* jkTableScanPhysiPlanInterval = "Interval";
|
||||||
|
static const char* jkTableScanPhysiPlanOffset = "Offset";
|
||||||
|
static const char* jkTableScanPhysiPlanSliding = "Sliding";
|
||||||
|
static const char* jkTableScanPhysiPlanIntervalUnit = "intervalUnit";
|
||||||
|
static const char* jkTableScanPhysiPlanSlidingUnit = "slidingUnit";
|
||||||
|
|
||||||
static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj;
|
const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj;
|
||||||
|
@ -771,6 +776,21 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodeListToJson(pJson, jkTableScanPhysiPlanDynamicScanFuncs, pNode->pDynamicScanFuncs);
|
code = nodeListToJson(pJson, jkTableScanPhysiPlanDynamicScanFuncs, pNode->pDynamicScanFuncs);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanInterval, pNode->interval);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanOffset, pNode->offset);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanSliding, pNode->sliding);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanIntervalUnit, pNode->intervalUnit);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkTableScanPhysiPlanSlidingUnit, pNode->slidingUnit);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -797,6 +817,21 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeList(pJson, jkTableScanPhysiPlanDynamicScanFuncs, &pNode->pDynamicScanFuncs);
|
code = jsonToNodeList(pJson, jkTableScanPhysiPlanDynamicScanFuncs, &pNode->pDynamicScanFuncs);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanInterval, pNode->interval);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanOffset, pNode->offset);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSliding, pNode->sliding);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanIntervalUnit, pNode->intervalUnit);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetNumberValue(pJson, jkTableScanPhysiPlanSlidingUnit, pNode->slidingUnit);
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1159,7 +1194,6 @@ static const char* jkIntervalPhysiPlanSliding = "Sliding";
|
||||||
static const char* jkIntervalPhysiPlanIntervalUnit = "intervalUnit";
|
static const char* jkIntervalPhysiPlanIntervalUnit = "intervalUnit";
|
||||||
static const char* jkIntervalPhysiPlanSlidingUnit = "slidingUnit";
|
static const char* jkIntervalPhysiPlanSlidingUnit = "slidingUnit";
|
||||||
static const char* jkIntervalPhysiPlanFill = "Fill";
|
static const char* jkIntervalPhysiPlanFill = "Fill";
|
||||||
static const char* jkIntervalPhysiPlanPrecision = "Precision";
|
|
||||||
|
|
||||||
static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
const SIntervalPhysiNode* pNode = (const SIntervalPhysiNode*)pObj;
|
const SIntervalPhysiNode* pNode = (const SIntervalPhysiNode*)pObj;
|
||||||
|
@ -1183,9 +1217,6 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddObject(pJson, jkIntervalPhysiPlanFill, nodeToJson, pNode->pFill);
|
code = tjsonAddObject(pJson, jkIntervalPhysiPlanFill, nodeToJson, pNode->pFill);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanPrecision, pNode->precision);
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1212,9 +1243,6 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeObject(pJson, jkIntervalPhysiPlanFill, (SNode**)&pNode->pFill);
|
code = jsonToNodeObject(pJson, jkIntervalPhysiPlanFill, (SNode**)&pNode->pFill);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = tjsonGetUTinyIntValue(pJson, jkIntervalPhysiPlanPrecision, &pNode->precision);
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,9 +87,9 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
|
||||||
}
|
}
|
||||||
case QUERY_NODE_SESSION_WINDOW: {
|
case QUERY_NODE_SESSION_WINDOW: {
|
||||||
SSessionWindowNode* pSession = (SSessionWindowNode*)pNode;
|
SSessionWindowNode* pSession = (SSessionWindowNode*)pNode;
|
||||||
res = walkNode(pSession->pCol, order, walker, pContext);
|
res = walkNode((SNode*)pSession->pCol, order, walker, pContext);
|
||||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||||
res = walkNode(pSession->pGap, order, walker, pContext);
|
res = walkNode((SNode*)pSession->pGap, order, walker, pContext);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -227,9 +227,9 @@ static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewrit
|
||||||
}
|
}
|
||||||
case QUERY_NODE_SESSION_WINDOW: {
|
case QUERY_NODE_SESSION_WINDOW: {
|
||||||
SSessionWindowNode* pSession = (SSessionWindowNode*)pNode;
|
SSessionWindowNode* pSession = (SSessionWindowNode*)pNode;
|
||||||
res = rewriteNode(&pSession->pCol, order, rewriter, pContext);
|
res = rewriteNode((SNode**)&pSession->pCol, order, rewriter, pContext);
|
||||||
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
if (DEAL_RES_ERROR != res && DEAL_RES_END != res) {
|
||||||
res = rewriteNode(&pSession->pGap, order, rewriter, pContext);
|
res = rewriteNode((SNode**)&pSession->pGap, order, rewriter, pContext);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL
|
||||||
SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
||||||
SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight);
|
||||||
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList);
|
SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList);
|
||||||
SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncName);
|
SNode* createFunctionNodeNoArg(SAstCreateContext* pCxt, const SToken* pFuncName);
|
||||||
SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt);
|
SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt);
|
||||||
SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList);
|
SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList);
|
||||||
SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2);
|
SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2);
|
||||||
|
|
|
@ -603,12 +603,13 @@ pseudo_column(A) ::= WDURATION(B).
|
||||||
function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
function_expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||||
function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
function_expression(A) ::= star_func(B) NK_LP star_func_para_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
|
||||||
function_expression(A) ::= CAST(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
function_expression(A) ::= CAST(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
|
||||||
function_expression(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); }
|
function_expression(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNodeNoArg(pCxt, &B)); }
|
||||||
|
|
||||||
%type noarg_func { SToken }
|
%type noarg_func { SToken }
|
||||||
%destructor noarg_func { }
|
%destructor noarg_func { }
|
||||||
noarg_func(A) ::= NOW(B). { A = B; }
|
noarg_func(A) ::= NOW(B). { A = B; }
|
||||||
noarg_func(A) ::= TODAY(B). { A = B; }
|
noarg_func(A) ::= TODAY(B). { A = B; }
|
||||||
|
noarg_func(A) ::= TIMEZONE(B). { A = B; }
|
||||||
|
|
||||||
%type star_func { SToken }
|
%type star_func { SToken }
|
||||||
%destructor star_func { }
|
%destructor star_func { }
|
||||||
|
|
|
@ -260,7 +260,8 @@ SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken*
|
||||||
CHECK_OUT_OF_MEM(val);
|
CHECK_OUT_OF_MEM(val);
|
||||||
if (NULL != pLiteral) {
|
if (NULL != pLiteral) {
|
||||||
val->literal = strndup(pLiteral->z, pLiteral->n);
|
val->literal = strndup(pLiteral->z, pLiteral->n);
|
||||||
if (TK_NK_ID != pLiteral->type && (IS_VAR_DATA_TYPE(dataType) || TSDB_DATA_TYPE_TIMESTAMP == dataType)) {
|
if (TK_NK_ID != pLiteral->type && TK_TIMEZONE != pLiteral->type &&
|
||||||
|
(IS_VAR_DATA_TYPE(dataType) || TSDB_DATA_TYPE_TIMESTAMP == dataType)) {
|
||||||
trimString(pLiteral->z, pLiteral->n, val->literal, pLiteral->n);
|
trimString(pLiteral->z, pLiteral->n, val->literal, pLiteral->n);
|
||||||
}
|
}
|
||||||
CHECK_OUT_OF_MEM(val->literal);
|
CHECK_OUT_OF_MEM(val->literal);
|
||||||
|
@ -367,7 +368,7 @@ SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNod
|
||||||
return (SNode*)func;
|
return (SNode*)func;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncName) {
|
SNode* createFunctionNodeNoArg(SAstCreateContext* pCxt, const SToken* pFuncName) {
|
||||||
SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||||
CHECK_OUT_OF_MEM(func);
|
CHECK_OUT_OF_MEM(func);
|
||||||
char buf[64] = {0};
|
char buf[64] = {0};
|
||||||
|
@ -386,11 +387,11 @@ SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncNam
|
||||||
dataType = TSDB_DATA_TYPE_BIGINT;
|
dataType = TSDB_DATA_TYPE_BIGINT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//case TK_TIMEZONE: {
|
case TK_TIMEZONE: {
|
||||||
// strncpy(buf, tsTimezoneStr, strlen(tsTimezoneStr));
|
strncpy(buf, tsTimezoneStr, strlen(tsTimezoneStr));
|
||||||
// dataType = TSDB_DATA_TYPE_BINARY;
|
dataType = TSDB_DATA_TYPE_BINARY;
|
||||||
// break;
|
break;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
SToken token = {.type = pFuncName->type, .n = strlen(buf), .z = buf};
|
SToken token = {.type = pFuncName->type, .n = strlen(buf), .z = buf};
|
||||||
|
|
||||||
|
@ -499,8 +500,8 @@ SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order
|
||||||
SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap) {
|
SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap) {
|
||||||
SSessionWindowNode* session = (SSessionWindowNode*)nodesMakeNode(QUERY_NODE_SESSION_WINDOW);
|
SSessionWindowNode* session = (SSessionWindowNode*)nodesMakeNode(QUERY_NODE_SESSION_WINDOW);
|
||||||
CHECK_OUT_OF_MEM(session);
|
CHECK_OUT_OF_MEM(session);
|
||||||
session->pCol = pCol;
|
session->pCol = (SColumnNode*)pCol;
|
||||||
session->pGap = pGap;
|
session->pGap = (SValueNode*)pGap;
|
||||||
return (SNode*)session;
|
return (SNode*)session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"TAGS", TK_TAGS},
|
{"TAGS", TK_TAGS},
|
||||||
{"TBNAME", TK_TBNAME},
|
{"TBNAME", TK_TBNAME},
|
||||||
{"TIMESTAMP", TK_TIMESTAMP},
|
{"TIMESTAMP", TK_TIMESTAMP},
|
||||||
|
{"TIMEZONE", TK_TIMEZONE},
|
||||||
{"TINYINT", TK_TINYINT},
|
{"TINYINT", TK_TINYINT},
|
||||||
{"TODAY", TK_TODAY},
|
{"TODAY", TK_TODAY},
|
||||||
{"TOPIC", TK_TOPIC},
|
{"TOPIC", TK_TOPIC},
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "cmdnodes.h"
|
#include "cmdnodes.h"
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
#include "parUtil.h"
|
#include "parUtil.h"
|
||||||
|
#include "tglobal.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
#define GET_OPTION_VAL(pVal, defaultVal) (NULL == (pVal) ? (defaultVal) : getBigintFromValueNode((SValueNode*)(pVal)))
|
#define GET_OPTION_VAL(pVal, defaultVal) (NULL == (pVal) ? (defaultVal) : getBigintFromValueNode((SValueNode*)(pVal)))
|
||||||
|
@ -227,6 +228,7 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p
|
||||||
strcpy(pCol->node.aliasName, pColSchema->name);
|
strcpy(pCol->node.aliasName, pColSchema->name);
|
||||||
}
|
}
|
||||||
pCol->tableId = pTable->pMeta->uid;
|
pCol->tableId = pTable->pMeta->uid;
|
||||||
|
pCol->tableType = pTable->pMeta->tableType;
|
||||||
pCol->colId = pColSchema->colId;
|
pCol->colId = pColSchema->colId;
|
||||||
pCol->colType = isTag ? COLUMN_TYPE_TAG : COLUMN_TYPE_COLUMN;
|
pCol->colType = isTag ? COLUMN_TYPE_TAG : COLUMN_TYPE_COLUMN;
|
||||||
pCol->node.resType.type = pColSchema->type;
|
pCol->node.resType.type = pColSchema->type;
|
||||||
|
@ -364,18 +366,38 @@ static bool translateColumnUseAlias(STranslateContext* pCxt, SColumnNode* pCol)
|
||||||
}
|
}
|
||||||
|
|
||||||
static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
|
static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
|
||||||
// count(*)/first(*)/last(*)
|
// count(*)/first(*)/last(*) and so on
|
||||||
if (0 == strcmp(pCol->colName, "*")) {
|
if (0 == strcmp(pCol->colName, "*")) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EDealRes res = DEAL_RES_CONTINUE;
|
||||||
if ('\0' != pCol->tableAlias[0]) {
|
if ('\0' != pCol->tableAlias[0]) {
|
||||||
return translateColumnWithPrefix(pCxt, pCol);
|
res = translateColumnWithPrefix(pCxt, pCol);
|
||||||
}
|
} else {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (SQL_CLAUSE_ORDER_BY == pCxt->currClause) {
|
if (SQL_CLAUSE_ORDER_BY == pCxt->currClause) {
|
||||||
found = translateColumnUseAlias(pCxt, pCol);
|
found = translateColumnUseAlias(pCxt, pCol);
|
||||||
}
|
}
|
||||||
return found ? DEAL_RES_CONTINUE : translateColumnWithoutPrefix(pCxt, pCol);
|
res = (found ? DEAL_RES_CONTINUE : translateColumnWithoutPrefix(pCxt, pCol));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DEAL_RES_ERROR == res) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SQL_CLAUSE_WINDOW == pCxt->currClause && QUERY_NODE_STATE_WINDOW == nodeType(pCxt->pCurrStmt->pWindow)) {
|
||||||
|
if (!IS_INTEGER_TYPE(pCol->node.resType.type)) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE);
|
||||||
|
}
|
||||||
|
if (COLUMN_TYPE_TAG == pCol->colType) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_STATE_WIN_COL);
|
||||||
|
}
|
||||||
|
if (TSDB_SUPER_TABLE == pCol->tableType) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_STATE_WIN_TABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
||||||
|
@ -466,8 +488,18 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
|
||||||
TSDB_DATA_TYPE_BLOB == rdt.type) {
|
TSDB_DATA_TYPE_BLOB == rdt.type) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
|
||||||
}
|
}
|
||||||
|
if (TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_TIMESTAMP == rdt.type) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_BIGINT == rdt.type) ||
|
||||||
|
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && TSDB_DATA_TYPE_BIGINT == ldt.type)) {
|
||||||
|
pOp->node.resType.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||||
|
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes;
|
||||||
|
} else {
|
||||||
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
|
pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE;
|
||||||
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
|
pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes;
|
||||||
|
}
|
||||||
} else if (nodesIsComparisonOp(pOp)) {
|
} else if (nodesIsComparisonOp(pOp)) {
|
||||||
if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type ||
|
if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type ||
|
||||||
TSDB_DATA_TYPE_BLOB == rdt.type) {
|
TSDB_DATA_TYPE_BLOB == rdt.type) {
|
||||||
|
@ -639,7 +671,7 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
|
||||||
if (!pSelect->isDistinct) {
|
if (!pSelect->isDistinct) {
|
||||||
nodesWalkExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt);
|
nodesWalkExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt);
|
||||||
}
|
}
|
||||||
if (cxt.existAggFunc && cxt.existCol) {
|
if ((cxt.existAggFunc || NULL != pSelect->pWindow) && cxt.existCol) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SINGLE_GROUP);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SINGLE_GROUP);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1091,20 +1123,100 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
return translateExprList(pCxt, pSelect->pGroupByList);
|
return translateExprList(pCxt, pSelect->pGroupByList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* pInterval) {
|
static bool isValTimeUnit(char unit) {
|
||||||
SValueNode* pIntervalVal = (SValueNode*)pInterval->pInterval;
|
return ('n' == unit || 'y' == unit);
|
||||||
SValueNode* pIntervalOffset = (SValueNode*)pInterval->pOffset;
|
|
||||||
SValueNode* pSliding = (SValueNode*)pInterval->pSliding;
|
|
||||||
if (pIntervalVal->datum.i <= 0) {
|
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL, pIntervalVal->literal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int64_t getMonthsFromTimeVal(int64_t val, int32_t fromPrecision, char unit) {
|
||||||
|
int64_t days = convertTimeFromPrecisionToUnit(val, fromPrecision, 'd');
|
||||||
|
switch (unit) {
|
||||||
|
case 'b':
|
||||||
|
case 'u':
|
||||||
|
case 'a':
|
||||||
|
case 's':
|
||||||
|
case 'm':
|
||||||
|
case 'h':
|
||||||
|
case 'd':
|
||||||
|
case 'w':
|
||||||
|
return days / 28;
|
||||||
|
case 'n':
|
||||||
|
return val;
|
||||||
|
case 'y':
|
||||||
|
return val * 12;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* pInterval) {
|
||||||
|
uint8_t precision = ((SColumnNode*)pInterval->pCol)->node.resType.precision;
|
||||||
|
|
||||||
|
SValueNode* pInter = (SValueNode*)pInterval->pInterval;
|
||||||
|
bool valInter = isValTimeUnit(pInter->unit);
|
||||||
|
if (pInter->datum.i <= 0 ||
|
||||||
|
(!valInter && convertTimePrecision(pInter->datum.i, precision, TSDB_TIME_PRECISION_MICRO) < tsMinIntervalTime)) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL, tsMinIntervalTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL != pInterval->pOffset) {
|
||||||
|
SValueNode* pOffset = (SValueNode*)pInterval->pOffset;
|
||||||
|
if (pOffset->datum.i <= 0) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_NEGATIVE);
|
||||||
|
}
|
||||||
|
if (pInter->unit == 'n' && pOffset->unit == 'y') {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_UNIT);
|
||||||
|
}
|
||||||
|
bool fixed = !isValTimeUnit(pOffset->unit) && !valInter;
|
||||||
|
if ((fixed && pOffset->datum.i >= pInter->datum.i) ||
|
||||||
|
(!fixed && getMonthsFromTimeVal(pOffset->datum.i, precision, pOffset->unit) >= getMonthsFromTimeVal(pInter->datum.i, precision, pInter->unit))) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL != pInterval->pSliding) {
|
||||||
|
const static int32_t INTERVAL_SLIDING_FACTOR = 100;
|
||||||
|
|
||||||
|
SValueNode* pSliding = (SValueNode*)pInterval->pSliding;
|
||||||
|
if (pInter->unit == 'n' || pInter->unit == 'y') {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_UNIT);
|
||||||
|
}
|
||||||
|
if ((pSliding->datum.i < convertTimePrecision(tsMinSlidingTime, TSDB_TIME_PRECISION_MILLI, precision)) ||
|
||||||
|
(pInter->datum.i / pSliding->datum.i > INTERVAL_SLIDING_FACTOR)) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL);
|
||||||
|
}
|
||||||
|
if (pSliding->datum.i > pInter->datum.i) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doTranslateWindow(STranslateContext* pCxt, SNode* pWindow) {
|
static int32_t checkStateWindow(STranslateContext* pCxt, SStateWindowNode* pState) {
|
||||||
|
// todo check for "function not support for state_window"
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t checkSessionWindow(STranslateContext* pCxt, SSessionWindowNode* pSession) {
|
||||||
|
if ('y' == pSession->pGap->unit || 'n' == pSession->pGap->unit || 0 == pSession->pGap->datum.i) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SESSION_GAP);
|
||||||
|
}
|
||||||
|
if (PRIMARYKEY_TIMESTAMP_COL_ID != pSession->pCol->colId) {
|
||||||
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SESSION_COL);
|
||||||
|
}
|
||||||
|
// todo check for "function not support for session"
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t checkWindow(STranslateContext* pCxt, SNode* pWindow) {
|
||||||
switch (nodeType(pWindow)) {
|
switch (nodeType(pWindow)) {
|
||||||
|
case QUERY_NODE_STATE_WINDOW:
|
||||||
|
return checkStateWindow(pCxt, (SStateWindowNode*)pWindow);
|
||||||
|
case QUERY_NODE_SESSION_WINDOW:
|
||||||
|
return checkSessionWindow(pCxt, (SSessionWindowNode*)pWindow);
|
||||||
case QUERY_NODE_INTERVAL_WINDOW:
|
case QUERY_NODE_INTERVAL_WINDOW:
|
||||||
return translateIntervalWindow(pCxt, (SIntervalWindowNode*)pWindow);
|
return checkIntervalWindow(pCxt, (SIntervalWindowNode*)pWindow);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1118,7 +1230,7 @@ static int32_t translateWindow(STranslateContext* pCxt, SNode* pWindow) {
|
||||||
pCxt->currClause = SQL_CLAUSE_WINDOW;
|
pCxt->currClause = SQL_CLAUSE_WINDOW;
|
||||||
int32_t code = translateExpr(pCxt, pWindow);
|
int32_t code = translateExpr(pCxt, pWindow);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = doTranslateWindow(pCxt, pWindow);
|
code = checkWindow(pCxt, pWindow);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
return "Endpoint should be in the format of 'fqdn:port'";
|
return "Endpoint should be in the format of 'fqdn:port'";
|
||||||
case TSDB_CODE_PAR_EXPRIE_STATEMENT:
|
case TSDB_CODE_PAR_EXPRIE_STATEMENT:
|
||||||
return "This statement is no longer supported";
|
return "This statement is no longer supported";
|
||||||
case TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL:
|
case TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL:
|
||||||
return "This interval value is too small : %s";
|
return "Interval cannot be less than %d us";
|
||||||
case TSDB_CODE_PAR_DB_NOT_SPECIFIED:
|
case TSDB_CODE_PAR_DB_NOT_SPECIFIED:
|
||||||
return "Database not specified";
|
return "Database not specified";
|
||||||
case TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME:
|
case TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME:
|
||||||
|
@ -93,6 +93,28 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
||||||
return "Invalid option keep unit: %c, %c, %c, only m, h, d allowed";
|
return "Invalid option keep unit: %c, %c, %c, only m, h, d allowed";
|
||||||
case TSDB_CODE_PAR_AGG_FUNC_NESTING:
|
case TSDB_CODE_PAR_AGG_FUNC_NESTING:
|
||||||
return "Aggregate functions do not support nesting";
|
return "Aggregate functions do not support nesting";
|
||||||
|
case TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE:
|
||||||
|
return "Only support STATE_WINDOW on integer column";
|
||||||
|
case TSDB_CODE_PAR_INVALID_STATE_WIN_COL:
|
||||||
|
return "Not support STATE_WINDOW on tag column";
|
||||||
|
case TSDB_CODE_PAR_INVALID_STATE_WIN_TABLE:
|
||||||
|
return "STATE_WINDOW not support for super table query";
|
||||||
|
case TSDB_CODE_PAR_INTER_SESSION_GAP:
|
||||||
|
return "SESSION gap should be fixed time window, and greater than 0";
|
||||||
|
case TSDB_CODE_PAR_INTER_SESSION_COL:
|
||||||
|
return "Only support SESSION on primary timestamp column";
|
||||||
|
case TSDB_CODE_PAR_INTER_OFFSET_NEGATIVE:
|
||||||
|
return "Interval offset cannot be negative";
|
||||||
|
case TSDB_CODE_PAR_INTER_OFFSET_UNIT:
|
||||||
|
return "Cannot use 'year' as offset when interval is 'month'";
|
||||||
|
case TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG:
|
||||||
|
return "Interval offset should be shorter than interval";
|
||||||
|
case TSDB_CODE_PAR_INTER_SLIDING_UNIT:
|
||||||
|
return "Does not support sliding when interval is natural month/year";
|
||||||
|
case TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG:
|
||||||
|
return "sliding value no larger than the interval value";
|
||||||
|
case TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL:
|
||||||
|
return "sliding value can not less than 1% of interval value";
|
||||||
case TSDB_CODE_OUT_OF_MEMORY:
|
case TSDB_CODE_OUT_OF_MEMORY:
|
||||||
return "Out of memory";
|
return "Out of memory";
|
||||||
default:
|
default:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -166,12 +166,24 @@ static int32_t osdGetDataRequired(SNodeList* pFuncs) {
|
||||||
return dataRequired;
|
return dataRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setScanWindowInfo(SScanLogicNode* pScan) {
|
||||||
|
if (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pScan->node.pParent) &&
|
||||||
|
WINDOW_TYPE_INTERVAL == ((SWindowLogicNode*)pScan->node.pParent)->winType) {
|
||||||
|
pScan->interval = ((SWindowLogicNode*)pScan->node.pParent)->interval;
|
||||||
|
pScan->offset = ((SWindowLogicNode*)pScan->node.pParent)->offset;
|
||||||
|
pScan->sliding = ((SWindowLogicNode*)pScan->node.pParent)->sliding;
|
||||||
|
pScan->intervalUnit = ((SWindowLogicNode*)pScan->node.pParent)->intervalUnit;
|
||||||
|
pScan->slidingUnit = ((SWindowLogicNode*)pScan->node.pParent)->slidingUnit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t osdOptimize(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
static int32_t osdOptimize(SOptimizeContext* pCxt, SLogicNode* pLogicNode) {
|
||||||
SOsdInfo info = {0};
|
SOsdInfo info = {0};
|
||||||
int32_t code = osdMatch(pCxt, pLogicNode, &info);
|
int32_t code = osdMatch(pCxt, pLogicNode, &info);
|
||||||
if (TSDB_CODE_SUCCESS == code && (NULL != info.pDsoFuncs || NULL != info.pSdrFuncs)) {
|
if (TSDB_CODE_SUCCESS == code && (NULL != info.pDsoFuncs || NULL != info.pSdrFuncs)) {
|
||||||
info.pScan->dataRequired = osdGetDataRequired(info.pSdrFuncs);
|
info.pScan->dataRequired = osdGetDataRequired(info.pSdrFuncs);
|
||||||
info.pScan->pDynamicScanFuncs = info.pDsoFuncs;
|
info.pScan->pDynamicScanFuncs = info.pDsoFuncs;
|
||||||
|
setScanWindowInfo((SScanLogicNode*)info.pScan);
|
||||||
OPTIMIZE_FLAG_SET_MASK(info.pScan->node.optimizedFlag, OPTIMIZE_FLAG_OSD);
|
OPTIMIZE_FLAG_SET_MASK(info.pScan->node.optimizedFlag, OPTIMIZE_FLAG_OSD);
|
||||||
pCxt->optimized = true;
|
pCxt->optimized = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -443,6 +443,11 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp
|
||||||
nodesDestroyNode(pTableScan);
|
nodesDestroyNode(pTableScan);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
pTableScan->interval = pScanLogicNode->interval;
|
||||||
|
pTableScan->offset = pScanLogicNode->offset;
|
||||||
|
pTableScan->sliding = pScanLogicNode->sliding;
|
||||||
|
pTableScan->intervalUnit = pScanLogicNode->intervalUnit;
|
||||||
|
pTableScan->slidingUnit = pScanLogicNode->slidingUnit;
|
||||||
|
|
||||||
return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode);
|
return createScanPhysiNodeFinalize(pCxt, pScanLogicNode, (SScanPhysiNode*)pTableScan, pPhyNode);
|
||||||
}
|
}
|
||||||
|
@ -819,7 +824,6 @@ static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil
|
||||||
pInterval->sliding = pWindowLogicNode->sliding;
|
pInterval->sliding = pWindowLogicNode->sliding;
|
||||||
pInterval->intervalUnit = pWindowLogicNode->intervalUnit;
|
pInterval->intervalUnit = pWindowLogicNode->intervalUnit;
|
||||||
pInterval->slidingUnit = pWindowLogicNode->slidingUnit;
|
pInterval->slidingUnit = pWindowLogicNode->slidingUnit;
|
||||||
pInterval->precision = ((SColumnNode*)pWindowLogicNode->pTspk)->node.resType.precision;
|
|
||||||
|
|
||||||
pInterval->pFill = nodesCloneNode(pWindowLogicNode->pFill);
|
pInterval->pFill = nodesCloneNode(pWindowLogicNode->pFill);
|
||||||
if (NULL != pWindowLogicNode->pFill && NULL == pInterval->pFill) {
|
if (NULL != pWindowLogicNode->pFill && NULL == pInterval->pFill) {
|
||||||
|
|
|
@ -666,18 +666,14 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
if (inputNum!= 3) {
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t inputType = pInput[0].columnData->info.type;
|
int16_t inputType = pInput[0].columnData->info.type;
|
||||||
int16_t outputType = *(int16_t *)pInput[1].columnData->pData;
|
int16_t outputType = pOutput[0].columnData->info.type;
|
||||||
if (outputType != TSDB_DATA_TYPE_BIGINT && outputType != TSDB_DATA_TYPE_UBIGINT &&
|
if (outputType != TSDB_DATA_TYPE_BIGINT && outputType != TSDB_DATA_TYPE_UBIGINT &&
|
||||||
outputType != TSDB_DATA_TYPE_VARCHAR && outputType != TSDB_DATA_TYPE_NCHAR &&
|
outputType != TSDB_DATA_TYPE_VARCHAR && outputType != TSDB_DATA_TYPE_NCHAR &&
|
||||||
outputType != TSDB_DATA_TYPE_TIMESTAMP) {
|
outputType != TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
int64_t outputLen = *(int64_t *)pInput[2].columnData->pData;
|
int64_t outputLen = pOutput[0].columnData->info.bytes;
|
||||||
|
|
||||||
char *input = NULL;
|
char *input = NULL;
|
||||||
char *outputBuf = taosMemoryCalloc(outputLen * pInput[0].numOfRows, 1);
|
char *outputBuf = taosMemoryCalloc(outputLen * pInput[0].numOfRows, 1);
|
||||||
|
@ -1275,6 +1271,14 @@ int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOut
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t timezoneFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
|
if (inputNum != 1) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
colDataAppend(pOutput->columnData, pOutput->numOfRows, (char *)colDataGetData(pInput->columnData, 0), false);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t atanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
int32_t atanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||||
return doScalarFunctionUnique(pInput, inputNum, pOutput, atan);
|
return doScalarFunctionUnique(pInput, inputNum, pOutput, atan);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,8 @@ _getBigintValue_fn_t getVectorBigintValueFn(int32_t srcType) {
|
||||||
p = getVectorBigintValue_FLOAT;
|
p = getVectorBigintValue_FLOAT;
|
||||||
}else if(srcType==TSDB_DATA_TYPE_DOUBLE) {
|
}else if(srcType==TSDB_DATA_TYPE_DOUBLE) {
|
||||||
p = getVectorBigintValue_DOUBLE;
|
p = getVectorBigintValue_DOUBLE;
|
||||||
|
}else if(srcType==TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
|
p = getVectorBigintValue_BIGINT;
|
||||||
}else {
|
}else {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
@ -565,6 +567,25 @@ static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vectorMathBigintAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) {
|
||||||
|
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||||
|
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||||
|
|
||||||
|
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||||
|
|
||||||
|
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||||
|
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||||
|
} else {
|
||||||
|
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||||
|
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) + getVectorBigintValueFnRight(pRightCol->pData, 0);
|
||||||
|
}
|
||||||
|
pOutputCol->hasNull = pLeftCol->hasNull;
|
||||||
|
if (pOutputCol->hasNull) {
|
||||||
|
memcpy(pOutputCol->nullbitmap, pLeftCol->nullbitmap, BitmapLen(numOfRows));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static SColumnInfoData* doVectorConvert(SScalarParam* pInput, int32_t* doConvert) {
|
static SColumnInfoData* doVectorConvert(SScalarParam* pInput, int32_t* doConvert) {
|
||||||
SScalarParam convertParam = {0};
|
SScalarParam convertParam = {0};
|
||||||
|
|
||||||
|
@ -599,10 +620,35 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
||||||
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
||||||
SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert);
|
SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert);
|
||||||
|
|
||||||
|
if ((GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_BIGINT) ||
|
||||||
|
(GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BIGINT)) { //timestamp plus duration
|
||||||
|
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||||
|
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||||
|
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||||
|
|
||||||
|
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||||
|
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||||
|
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) + getVectorBigintValueFnRight(pRightCol->pData, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull);
|
||||||
|
if (pOutputCol->hasNull) {
|
||||||
|
int32_t numOfBitLen = BitmapLen(pLeft->numOfRows);
|
||||||
|
for (int32_t j = 0; j < numOfBitLen; ++j) {
|
||||||
|
pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (pLeft->numOfRows == 1) {
|
||||||
|
vectorMathBigintAddHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i);
|
||||||
|
} else if (pRight->numOfRows == 1) {
|
||||||
|
vectorMathBigintAddHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
double *output = (double *)pOutputCol->pData;
|
||||||
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
||||||
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
||||||
|
|
||||||
double *output = (double *)pOutputCol->pData;
|
|
||||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||||
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) + getVectorDoubleValueFnRight(pRightCol->pData, i);
|
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) + getVectorDoubleValueFnRight(pRightCol->pData, i);
|
||||||
|
@ -621,6 +667,7 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
||||||
} else if (pRight->numOfRows == 1) {
|
} else if (pRight->numOfRows == 1) {
|
||||||
vectorMathAddHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i);
|
vectorMathAddHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
doReleaseVec(pLeftCol, leftConvert);
|
doReleaseVec(pLeftCol, leftConvert);
|
||||||
doReleaseVec(pRightCol, rightConvert);
|
doReleaseVec(pRightCol, rightConvert);
|
||||||
|
@ -646,6 +693,25 @@ static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vectorMathBigintSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t factor, int32_t i) {
|
||||||
|
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||||
|
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||||
|
|
||||||
|
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||||
|
|
||||||
|
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||||
|
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||||
|
} else {
|
||||||
|
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||||
|
*output = (getVectorBigintValueFnLeft(pLeftCol->pData, i) - getVectorBigintValueFnRight(pRightCol->pData, 0)) * factor;
|
||||||
|
}
|
||||||
|
pOutputCol->hasNull = pLeftCol->hasNull;
|
||||||
|
if (pOutputCol->hasNull) {
|
||||||
|
memcpy(pOutputCol->nullbitmap, pLeftCol->nullbitmap, BitmapLen(numOfRows));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
|
void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
|
||||||
SColumnInfoData *pOutputCol = pOut->columnData;
|
SColumnInfoData *pOutputCol = pOut->columnData;
|
||||||
|
|
||||||
|
@ -658,10 +724,35 @@ void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
||||||
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
||||||
SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert);
|
SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert);
|
||||||
|
|
||||||
|
if ((GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_BIGINT) ||
|
||||||
|
(GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BIGINT)) { //timestamp minus duration
|
||||||
|
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||||
|
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||||
|
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||||
|
|
||||||
|
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||||
|
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||||
|
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) - getVectorBigintValueFnRight(pRightCol->pData, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
pOutputCol->hasNull = (pLeftCol->hasNull || pRightCol->hasNull);
|
||||||
|
if (pOutputCol->hasNull) {
|
||||||
|
int32_t numOfBitLen = BitmapLen(pLeft->numOfRows);
|
||||||
|
for (int32_t j = 0; j < numOfBitLen; ++j) {
|
||||||
|
pOutputCol->nullbitmap[j] = pLeftCol->nullbitmap[j] | pRightCol->nullbitmap[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (pLeft->numOfRows == 1) {
|
||||||
|
vectorMathBigintSubHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, -1, i);
|
||||||
|
} else if (pRight->numOfRows == 1) {
|
||||||
|
vectorMathBigintSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
double *output = (double *)pOutputCol->pData;
|
||||||
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
||||||
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
||||||
|
|
||||||
double *output = (double *)pOutputCol->pData;
|
|
||||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||||
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) - getVectorDoubleValueFnRight(pRightCol->pData, i);
|
*output = getVectorDoubleValueFnLeft(pLeftCol->pData, i) - getVectorDoubleValueFnRight(pRightCol->pData, i);
|
||||||
|
@ -680,6 +771,7 @@ void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
||||||
} else if (pRight->numOfRows == 1) {
|
} else if (pRight->numOfRows == 1) {
|
||||||
vectorMathSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i);
|
vectorMathSubHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, 1, i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
doReleaseVec(pLeftCol, leftConvert);
|
doReleaseVec(pLeftCol, leftConvert);
|
||||||
doReleaseVec(pRightCol, rightConvert);
|
doReleaseVec(pRightCol, rightConvert);
|
||||||
|
|
|
@ -8,7 +8,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
||||||
ADD_EXECUTABLE(schedulerTest ${SOURCE_LIST})
|
ADD_EXECUTABLE(schedulerTest ${SOURCE_LIST})
|
||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
schedulerTest
|
schedulerTest
|
||||||
PUBLIC os util common catalog transport gtest qcom taos planner scheduler
|
PUBLIC os util common catalog transport gtest qcom taos_static planner scheduler
|
||||||
)
|
)
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(
|
TARGET_INCLUDE_DIRECTORIES(
|
||||||
|
|
|
@ -45,8 +45,8 @@ sql explain select * from information_schema.user_stables;
|
||||||
sql explain select count(*),sum(f1) from tb1;
|
sql explain select count(*),sum(f1) from tb1;
|
||||||
sql explain select count(*),sum(f1) from st1;
|
sql explain select count(*),sum(f1) from st1;
|
||||||
sql explain select count(*),sum(f1) from st1 group by f1;
|
sql explain select count(*),sum(f1) from st1 group by f1;
|
||||||
sql explain select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev);
|
sql explain select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev);
|
||||||
sql explain select min(f1) from st1 interval(1m, 2a) sliding(3n);
|
sql explain select min(f1) from st1 interval(1m, 2a) sliding(30s);
|
||||||
|
|
||||||
print ======== step3
|
print ======== step3
|
||||||
sql explain verbose true select * from st1 where -2;
|
sql explain verbose true select * from st1 where -2;
|
||||||
|
@ -65,8 +65,8 @@ sql explain analyze select * from information_schema.user_stables;
|
||||||
sql explain analyze select count(*),sum(f1) from tb1;
|
sql explain analyze select count(*),sum(f1) from tb1;
|
||||||
sql explain analyze select count(*),sum(f1) from st1;
|
sql explain analyze select count(*),sum(f1) from st1;
|
||||||
sql explain analyze select count(*),sum(f1) from st1 group by f1;
|
sql explain analyze select count(*),sum(f1) from st1 group by f1;
|
||||||
sql explain analyze select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev);
|
sql explain analyze select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev);
|
||||||
sql explain analyze select min(f1) from st1 interval(3n, 2a) sliding(1n);
|
sql explain analyze select min(f1) from st1 interval(3m, 2a) sliding(1m);
|
||||||
|
|
||||||
print ======== step5
|
print ======== step5
|
||||||
sql explain analyze verbose true select ts from st1 where -2;
|
sql explain analyze verbose true select ts from st1 where -2;
|
||||||
|
@ -78,20 +78,20 @@ sql explain analyze verbose true select * from information_schema.user_stables;
|
||||||
sql explain analyze verbose true select count(*),sum(f1) from tb1;
|
sql explain analyze verbose true select count(*),sum(f1) from tb1;
|
||||||
sql explain analyze verbose true select count(*),sum(f1) from st1;
|
sql explain analyze verbose true select count(*),sum(f1) from st1;
|
||||||
sql explain analyze verbose true select count(*),sum(f1) from st1 group by f1;
|
sql explain analyze verbose true select count(*),sum(f1) from st1 group by f1;
|
||||||
sql explain analyze verbose true select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev);
|
sql explain analyze verbose true select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev);
|
||||||
sql explain analyze verbose true select ts from tb1 where f1 > 0;
|
sql explain analyze verbose true select ts from tb1 where f1 > 0;
|
||||||
sql explain analyze verbose true select f1 from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00';
|
sql explain analyze verbose true select f1 from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00';
|
||||||
sql explain analyze verbose true select * from information_schema.user_stables where db_name='db2';
|
sql explain analyze verbose true select * from information_schema.user_stables where db_name='db2';
|
||||||
sql explain analyze verbose true select count(*),sum(f1) from st1 where f1 > 0 and ts > '2021-10-31 00:00:00' group by f1 having sum(f1) > 0;
|
sql explain analyze verbose true select count(*),sum(f1) from st1 where f1 > 0 and ts > '2021-10-31 00:00:00' group by f1 having sum(f1) > 0;
|
||||||
sql explain analyze verbose true select min(f1) from st1 interval(3n, 2a) sliding(1n);
|
sql explain analyze verbose true select min(f1) from st1 interval(3m, 2a) sliding(1m);
|
||||||
sql explain analyze verbose true select * from (select min(f1),count(*) a from st1 where f1 > 0) where a < 0;
|
sql explain analyze verbose true select * from (select min(f1),count(*) a from st1 where f1 > 0) where a < 0;
|
||||||
|
|
||||||
#not pass case
|
#not pass case
|
||||||
#sql explain verbose true select count(*),sum(f1) as aa from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by aa;
|
#sql explain verbose true select count(*),sum(f1) as aa from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by aa;
|
||||||
#sql explain verbose true select * from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts;
|
#sql explain verbose true select * from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts;
|
||||||
#sql explain verbose true select count(*),sum(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts;
|
#sql explain verbose true select count(*),sum(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts;
|
||||||
#sql explain verbose true select count(f1) from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1s, 2d) sliding(3s) order by ts;
|
#sql explain verbose true select count(f1) from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(10s, 2s) sliding(3s) order by ts;
|
||||||
#sql explain verbose true select min(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1m, 2a) sliding(3n) fill(linear) order by ts;
|
#sql explain verbose true select min(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1m, 2a) sliding(30s) fill(linear) order by ts;
|
||||||
#sql explain select max(f1) from tb1 SESSION(ts, 1s);
|
#sql explain select max(f1) from tb1 SESSION(ts, 1s);
|
||||||
#sql explain select max(f1) from st1 SESSION(ts, 1s);
|
#sql explain select max(f1) from st1 SESSION(ts, 1s);
|
||||||
#sql explain select * from tb1, tb2 where tb1.ts=tb2.ts;
|
#sql explain select * from tb1, tb2 where tb1.ts=tb2.ts;
|
||||||
|
|
|
@ -200,43 +200,8 @@ if $data02 != 2678400000 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w)
|
sql_error select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w)
|
||||||
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w)
|
sql_error select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w)
|
||||||
print ===> rows: $rows
|
|
||||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
|
||||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
|
||||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
|
||||||
print ===> rows3: $data30 $data31 $data32 $data33 $data34
|
|
||||||
if $rows != 4 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data00 != @21-11-30 08:00:00.000@ then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data01 != NULL then
|
|
||||||
print expect null, actual: $data01
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data31 != $data34 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w)
|
|
||||||
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w)
|
|
||||||
print ===> rows: $rows
|
|
||||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
|
||||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
|
||||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
|
||||||
print ===> rows3: $data30 $data31 $data32 $data33 $data34
|
|
||||||
if $rows != 4 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data01 != NULL then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data04 != 1 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n)
|
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n)
|
||||||
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n)
|
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n)
|
||||||
|
@ -254,37 +219,8 @@ if $data04 != 2 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n)
|
sql_error select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n)
|
||||||
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n)
|
sql_error select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n)
|
||||||
print ===> rows: $rows
|
|
||||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
|
||||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
|
||||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
|
||||||
if $rows != 3 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data00 != 2 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data04 != 2 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n)
|
|
||||||
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n)
|
|
||||||
print ===> rows: $rows
|
|
||||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
|
||||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
|
||||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
|
||||||
if $rows != 3 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data01 != 2 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data04 != 2 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
print =============== stop and restart taosd
|
print =============== stop and restart taosd
|
||||||
|
|
|
@ -290,32 +290,33 @@ print ================> syntax error check not active ================> reactive
|
||||||
sql_error select * from dev_001 session(ts,1w)
|
sql_error select * from dev_001 session(ts,1w)
|
||||||
sql_error select count(*) from st session(ts,1w)
|
sql_error select count(*) from st session(ts,1w)
|
||||||
sql_error select count(*) from dev_001 group by tagtype session(ts,1w)
|
sql_error select count(*) from dev_001 group by tagtype session(ts,1w)
|
||||||
sql select count(*) from dev_001 session(ts,1n)
|
sql_error sql select count(*) from dev_001 session(ts,1n)
|
||||||
sql select count(*) from dev_001 session(ts,1y)
|
sql_error sql select count(*) from dev_001 session(ts,1y)
|
||||||
sql select count(*) from dev_001 session(ts,0s)
|
sql_error sql select count(*) from dev_001 session(ts,0s)
|
||||||
sql_error select count(*) from dev_001 session(i,1y)
|
sql_error select count(*) from dev_001 session(i,1y)
|
||||||
sql_error select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0'
|
sql_error select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0'
|
||||||
|
|
||||||
print ====> create database d1 precision 'us'
|
# vnode does not return the precision of the table
|
||||||
sql create database d1 precision 'us'
|
#print ====> create database d1 precision 'us'
|
||||||
sql use d1
|
#sql create database d1 precision 'us'
|
||||||
sql create table dev_001 (ts timestamp ,i timestamp ,j int)
|
#sql use d1
|
||||||
sql insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4)
|
#sql create table dev_001 (ts timestamp ,i timestamp ,j int)
|
||||||
print ====> select count(*) from dev_001 session(ts,1u)
|
#sql insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4)
|
||||||
sql select _wstartts, count(*) from dev_001 session(ts,1u)
|
#print ====> select count(*) from dev_001 session(ts,1u)
|
||||||
print rows: $rows
|
#sql select _wstartts, count(*) from dev_001 session(ts,1u)
|
||||||
print $data00 $data01 $data02 $data03
|
#print rows: $rows
|
||||||
print $data10 $data11 $data12 $data13
|
#print $data00 $data01 $data02 $data03
|
||||||
print $data20 $data21 $data22 $data23
|
#print $data10 $data11 $data12 $data13
|
||||||
print $data30 $data31 $data32 $data33
|
#print $data20 $data21 $data22 $data23
|
||||||
if $rows != 4 then
|
#print $data30 $data31 $data32 $data33
|
||||||
print expect 2, actual: $rows
|
#if $rows != 4 then
|
||||||
return -1
|
# print expect 2, actual: $rows
|
||||||
endi
|
# return -1
|
||||||
|
#endi
|
||||||
if $data01 != 1 then
|
#
|
||||||
return -1
|
#if $data01 != 1 then
|
||||||
endi
|
# return -1
|
||||||
|
#endi
|
||||||
|
|
||||||
#sql_error select count(*) from dev_001 session(i,1s)
|
#sql_error select count(*) from dev_001 session(i,1s)
|
||||||
sql create table secondts(ts timestamp,t2 timestamp,i int)
|
sql create table secondts(ts timestamp,t2 timestamp,i int)
|
||||||
|
|
|
@ -132,11 +132,13 @@ print =============== step7
|
||||||
# return -1
|
# return -1
|
||||||
# endi
|
# endi
|
||||||
|
|
||||||
sql select count(tbcol) from $mt
|
# TODO
|
||||||
print ===> $data00
|
# print ==========> block opt will cause this crash, table scan need to fix this during plan gen ===============>
|
||||||
if $data00 != $totalNum then
|
#sql select count(tbcol) from $mt
|
||||||
return -1
|
#print ===> $data00
|
||||||
endi
|
#if $data00 != $totalNum then
|
||||||
|
# return -1
|
||||||
|
#endi
|
||||||
|
|
||||||
print =============== step8
|
print =============== step8
|
||||||
# TODO
|
# TODO
|
||||||
|
|
|
@ -206,6 +206,7 @@ print =============== query data from st
|
||||||
print ==============select * against super will cause crash.
|
print ==============select * against super will cause crash.
|
||||||
sql select ts from st
|
sql select ts from st
|
||||||
if $rows != 21 then
|
if $rows != 21 then
|
||||||
|
print expect 21, actual $rows
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
|
|
@ -3,21 +3,21 @@ add_executable(tmq_demo tmqDemo.c)
|
||||||
add_executable(tmq_sim tmqSim.c)
|
add_executable(tmq_sim tmqSim.c)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
create_table
|
create_table
|
||||||
PUBLIC taos
|
PUBLIC taos_static
|
||||||
PUBLIC util
|
PUBLIC util
|
||||||
PUBLIC common
|
PUBLIC common
|
||||||
PUBLIC os
|
PUBLIC os
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
tmq_demo
|
tmq_demo
|
||||||
PUBLIC taos
|
PUBLIC taos_static
|
||||||
PUBLIC util
|
PUBLIC util
|
||||||
PUBLIC common
|
PUBLIC common
|
||||||
PUBLIC os
|
PUBLIC os
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
tmq_sim
|
tmq_sim
|
||||||
PUBLIC taos
|
PUBLIC taos_static
|
||||||
PUBLIC util
|
PUBLIC util
|
||||||
PUBLIC common
|
PUBLIC common
|
||||||
PUBLIC os
|
PUBLIC os
|
||||||
|
|
|
@ -2,7 +2,7 @@ aux_source_directory(src TSIM_SRC)
|
||||||
add_executable(tsim ${TSIM_SRC})
|
add_executable(tsim ${TSIM_SRC})
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
tsim
|
tsim
|
||||||
PUBLIC taos
|
PUBLIC taos_static
|
||||||
PUBLIC util
|
PUBLIC util
|
||||||
PUBLIC common
|
PUBLIC common
|
||||||
PUBLIC os
|
PUBLIC os
|
||||||
|
|
|
@ -3,7 +3,7 @@ aux_source_directory(src SHELL_SRC)
|
||||||
add_executable(shell ${SHELL_SRC})
|
add_executable(shell ${SHELL_SRC})
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
shell
|
shell
|
||||||
PUBLIC taos
|
PUBLIC taos_static
|
||||||
PRIVATE os common transport util
|
PRIVATE os common transport util
|
||||||
)
|
)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
|
|
Loading…
Reference in New Issue