Merge branch '3.0' into enh/TD-29968-3.0

This commit is contained in:
kailixu 2024-05-12 23:15:40 +08:00
commit 60e02eb3e6
35 changed files with 5645 additions and 1012 deletions

View File

@ -35,7 +35,6 @@ extern "C" {
#define CACHESCAN_RETRIEVE_TYPE_SINGLE 0x2
#define CACHESCAN_RETRIEVE_LAST_ROW 0x4
#define CACHESCAN_RETRIEVE_LAST 0x8
#define CACHESCAN_RETRIEVE_PK 0x10
#define META_READER_LOCK 0x0
#define META_READER_NOLOCK 0x1

View File

@ -16,6 +16,8 @@
#ifndef TDENGINE_STREAMMSG_H
#define TDENGINE_STREAMMSG_H
#include "tmsg.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -45,6 +47,9 @@ typedef struct {
int64_t expireTime;
} SStreamCheckpointSourceReq;
int32_t tEncodeStreamCheckpointSourceReq(SEncoder* pEncoder, const SStreamCheckpointSourceReq* pReq);
int32_t tDecodeStreamCheckpointSourceReq(SDecoder* pDecoder, SStreamCheckpointSourceReq* pReq);
typedef struct {
int64_t streamId;
int64_t checkpointId;
@ -55,9 +60,6 @@ typedef struct {
int8_t success;
} SStreamCheckpointSourceRsp;
int32_t tEncodeStreamCheckpointSourceReq(SEncoder* pEncoder, const SStreamCheckpointSourceReq* pReq);
int32_t tDecodeStreamCheckpointSourceReq(SDecoder* pDecoder, SStreamCheckpointSourceReq* pReq);
int32_t tEncodeStreamCheckpointSourceRsp(SEncoder* pEncoder, const SStreamCheckpointSourceRsp* pRsp);
typedef struct SStreamTaskNodeUpdateMsg {

View File

@ -707,6 +707,7 @@ int32_t streamMetaAddTaskLaunchResult(SStreamMeta* pMeta, int64_t streamId,
int64_t endTs, bool ready);
int32_t streamMetaResetTaskStatus(SStreamMeta* pMeta);
int32_t streamMetaAddFailedTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId);
void streamMetaAddFailedTaskSelf(SStreamTask* pTask, int64_t failedTs);
void streamMetaAddIntoUpdateTaskList(SStreamMeta* pMeta, SStreamTask* pTask, SStreamTask* pHTask, int32_t transId,
int64_t startTs);
void streamMetaRLock(SStreamMeta* pMeta);

View File

@ -60,15 +60,15 @@ int32_t tsTimeToGetAvailableConn = 500000;
int32_t tsKeepAliveIdle = 60;
int32_t tsNumOfCommitThreads = 2;
int32_t tsNumOfTaskQueueThreads = 10;
int32_t tsNumOfMnodeQueryThreads = 4;
int32_t tsNumOfTaskQueueThreads = 16;
int32_t tsNumOfMnodeQueryThreads = 16;
int32_t tsNumOfMnodeFetchThreads = 1;
int32_t tsNumOfMnodeReadThreads = 1;
int32_t tsNumOfVnodeQueryThreads = 4;
int32_t tsNumOfVnodeQueryThreads = 16;
float tsRatioOfVnodeStreamThreads = 0.5F;
int32_t tsNumOfVnodeFetchThreads = 4;
int32_t tsNumOfVnodeRsmaThreads = 2;
int32_t tsNumOfQnodeQueryThreads = 4;
int32_t tsNumOfQnodeQueryThreads = 16;
int32_t tsNumOfQnodeFetchThreads = 1;
int32_t tsNumOfSnodeStreamThreads = 4;
int32_t tsNumOfSnodeWriteThreads = 1;
@ -554,7 +554,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
if (cfgAddInt32(pCfg, "keepAliveIdle", tsKeepAliveIdle, 1, 7200000, CFG_SCOPE_BOTH, CFG_DYN_ENT_BOTH) != 0) return -1;
tsNumOfTaskQueueThreads = tsNumOfCores;
tsNumOfTaskQueueThreads = TMAX(tsNumOfTaskQueueThreads, 10);
tsNumOfTaskQueueThreads = TMAX(tsNumOfTaskQueueThreads, 16);
if (cfgAddInt32(pCfg, "numOfTaskQueueThreads", tsNumOfTaskQueueThreads, 4, 1024, CFG_SCOPE_CLIENT, CFG_DYN_NONE) != 0)
return -1;
@ -645,7 +645,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
return -1;
tsNumOfVnodeQueryThreads = tsNumOfCores * 2;
tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 4);
tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 16);
if (cfgAddInt32(pCfg, "numOfVnodeQueryThreads", tsNumOfVnodeQueryThreads, 4, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE) !=
0)
return -1;
@ -666,7 +666,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
return -1;
tsNumOfQnodeQueryThreads = tsNumOfCores * 2;
tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 4);
tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 16);
if (cfgAddInt32(pCfg, "numOfQnodeQueryThreads", tsNumOfQnodeQueryThreads, 4, 1024, CFG_SCOPE_SERVER, CFG_DYN_NONE) !=
0)
return -1;
@ -918,7 +918,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) {
pItem = cfgGetItem(tsCfg, "numOfVnodeQueryThreads");
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
tsNumOfVnodeQueryThreads = numOfCores * 2;
tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 4);
tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 16);
pItem->i32 = tsNumOfVnodeQueryThreads;
pItem->stype = stype;
}
@ -948,7 +948,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) {
pItem = cfgGetItem(tsCfg, "numOfQnodeQueryThreads");
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
tsNumOfQnodeQueryThreads = numOfCores * 2;
tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 4);
tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 16);
pItem->i32 = tsNumOfQnodeQueryThreads;
pItem->stype = stype;
}

View File

@ -316,7 +316,7 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
if (vmTsmaAdjustDays(&vnodeCfg, &req) < 0) {
dError("vgId:%d, failed to adjust tsma days since %s", req.vgId, terrstr());
code = terrno;
code = terrno != 0 ? terrno : -1;
goto _OVER;
}
@ -344,21 +344,21 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
dError("vgId:%d, failed to create vnode since %s", req.vgId, terrstr());
vmReleaseVnode(pMgmt, pVnode);
tFreeSCreateVnodeReq(&req);
code = terrno;
code = terrno != 0 ? terrno : -1;
return code;
}
SVnode *pImpl = vnodeOpen(path, diskPrimary, pMgmt->pTfs, pMgmt->msgCb, true);
if (pImpl == NULL) {
dError("vgId:%d, failed to open vnode since %s", req.vgId, terrstr());
code = terrno;
code = terrno != 0 ? terrno : -1;
goto _OVER;
}
code = vmOpenVnode(pMgmt, &wrapperCfg, pImpl);
if (code != 0) {
dError("vgId:%d, failed to open vnode since %s", req.vgId, terrstr());
code = terrno;
code = terrno != 0 ? terrno : code;
goto _OVER;
}
@ -379,7 +379,7 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
code = vmWriteVnodeListToFile(pMgmt);
if (code != 0) {
code = terrno;
code = terrno != 0 ? terrno : code;
goto _OVER;
}

View File

@ -894,36 +894,14 @@ typedef enum {
READER_EXEC_ROWS = 0x2,
} EExecMode;
#define LAST_COL_VERSION (0x1)
typedef struct {
int64_t version;
SRowKey rowKey;
int8_t dirty;
SColVal colVal;
} SLastCol;
typedef struct {
union {
int64_t val;
struct {
uint8_t *pData;
uint32_t nData;
};
};
} SValueV1;
typedef struct {
int16_t cid;
int8_t type;
int8_t flag;
SValueV1 value;
} SColValV1;
typedef struct {
TSKEY ts;
int8_t dirty;
SColValV1 colVal;
} SLastColV1;
int32_t tsdbOpenCache(STsdb *pTsdb);
void tsdbCloseCache(STsdb *pTsdb);
int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *row);

View File

@ -130,7 +130,6 @@ static void tsdbClosePgCache(STsdb *pTsdb) {
enum {
LFLAG_LAST_ROW = 0,
LFLAG_LAST = 1,
LFLAG_PRIMARY_KEY = CACHESCAN_RETRIEVE_PK,
};
typedef struct {
@ -139,10 +138,6 @@ typedef struct {
int8_t lflag;
} SLastKey;
#define LAST_COL_VERSION_BASE (((int64_t)(0x1)) << 63)
#define LAST_COL_VERSION (LAST_COL_VERSION_BASE + 2)
#define HAS_PRIMARY_KEY(k) (((k).lflag & LFLAG_PRIMARY_KEY) == LFLAG_PRIMARY_KEY)
#define IS_LAST_ROW_KEY(k) (((k).lflag & LFLAG_LAST) == LFLAG_LAST_ROW)
#define IS_LAST_KEY(k) (((k).lflag & LFLAG_LAST) == LFLAG_LAST)
@ -180,9 +175,9 @@ static int myCmp(void *state, const char *a, size_t alen, const char *b, size_t
return 1;
}
if (lhs->lflag < rhs->lflag) {
if ((lhs->lflag & LFLAG_LAST) < (rhs->lflag & LFLAG_LAST)) {
return -1;
} else if (lhs->lflag > rhs->lflag) {
} else if ((lhs->lflag & LFLAG_LAST) > (rhs->lflag & LFLAG_LAST)) {
return 1;
}
@ -335,133 +330,163 @@ static void rocksMayWrite(STsdb *pTsdb, bool force, bool read, bool lock) {
}
}
// note: new object do not own colVal's resource, just copy the pointer
static SLastCol *tsdbCacheConvertLastColV1(SLastColV1 *pLastColV1) {
SLastCol *pLastCol = taosMemoryCalloc(1, sizeof(SLastCol));
if (pLastCol == NULL) return NULL;
pLastCol->version = LAST_COL_VERSION;
pLastCol->rowKey.ts = pLastColV1->ts;
typedef struct {
TSKEY ts;
int8_t dirty;
struct {
int16_t cid;
int8_t type;
int8_t flag;
union {
int64_t val;
struct {
uint32_t nData;
uint8_t *pData;
};
} value;
} colVal;
} SLastColV0;
static int32_t tsdbCacheDeserializeV0(char const *value, SLastCol *pLastCol) {
SLastColV0 *pLastColV0 = (SLastColV0 *)value;
pLastCol->rowKey.ts = pLastColV0->ts;
pLastCol->rowKey.numOfPKs = 0;
pLastCol->dirty = pLastColV1->dirty;
pLastCol->colVal.cid = pLastColV1->colVal.cid;
pLastCol->colVal.flag = pLastColV1->colVal.flag;
pLastCol->colVal.value.type = pLastColV1->colVal.type;
pLastCol->colVal.value.val = pLastColV1->colVal.value.val;
pLastCol->dirty = pLastColV0->dirty;
pLastCol->colVal.cid = pLastColV0->colVal.cid;
pLastCol->colVal.flag = pLastColV0->colVal.flag;
pLastCol->colVal.value.type = pLastColV0->colVal.type;
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
pLastCol->colVal.value.nData = pLastColV0->colVal.value.nData;
pLastCol->colVal.value.pData = (uint8_t *)(&pLastColV0[1]);
return sizeof(SLastColV0) + pLastColV0->colVal.value.nData;
} else {
pLastCol->colVal.value.val = pLastColV0->colVal.value.val;
return sizeof(SLastColV0);
}
}
static SLastCol *tsdbCacheDeserialize(char const *value, size_t size) {
if (!value) {
return NULL;
}
SLastCol* pLastCol = taosMemoryCalloc(1, sizeof(SLastCol));
if (NULL == pLastCol) {
return NULL;
}
int32_t offset = tsdbCacheDeserializeV0(value, pLastCol);
if (offset == size) {
// version 0
return pLastCol;
}
static SLastCol *tsdbCacheDeserializeV1(char const *value) {
if (!value) {
} else if (offset > size) {
terrno = TSDB_CODE_INVALID_DATA_FMT;
taosMemoryFreeClear(pLastCol);
return NULL;
}
SLastColV1 *pLastColV1 = (SLastColV1 *)value;
SColValV1 *pColVal = &pLastColV1->colVal;
if (IS_VAR_DATA_TYPE(pColVal->type)) {
if (pColVal->value.nData > 0) {
pColVal->value.pData = (char *)value + sizeof(*pLastColV1);
} else {
pColVal->value.pData = NULL;
// version
int8_t version = *(int8_t *)(value + offset);
offset += sizeof(int8_t);
// numOfPKs
pLastCol->rowKey.numOfPKs = *(uint8_t *)(value + offset);
offset += sizeof(uint8_t);
// pks
for (int32_t i = 0; i < pLastCol->rowKey.numOfPKs; i++) {
pLastCol->rowKey.pks[i] = *(SValue *)(value + offset);
offset += sizeof(SValue);
if (IS_VAR_DATA_TYPE(pLastCol->rowKey.pks[i].type)) {
pLastCol->rowKey.pks[i].pData = (uint8_t *)value + offset;
offset += pLastCol->rowKey.pks[i].nData;
}
}
return tsdbCacheConvertLastColV1(pLastColV1);
}
static SLastCol *tsdbCacheDeserializeV2(char const *value) {
if (!value) {
if (offset > size) {
terrno = TSDB_CODE_INVALID_DATA_FMT;
taosMemoryFreeClear(pLastCol);
return NULL;
}
SLastCol *pLastCol = taosMemoryMalloc(sizeof(SLastCol));
*pLastCol = *(SLastCol *)(value);
char *currentPos = (char *)value + sizeof(*pLastCol);
for (int8_t i = 0; i < pLastCol->rowKey.numOfPKs; i++) {
SValue *pValue = &pLastCol->rowKey.pks[i];
if (IS_VAR_DATA_TYPE(pValue->type)) {
if (pValue->nData > 0) {
pValue->pData = currentPos;
currentPos += pValue->nData;
} else {
pValue->pData = NULL;
}
}
}
SColVal *pColVal = &pLastCol->colVal;
if (IS_VAR_DATA_TYPE(pColVal->value.type)) {
if (pColVal->value.nData > 0) {
pColVal->value.pData = currentPos;
currentPos += pColVal->value.nData;
} else {
pColVal->value.pData = NULL;
}
}
return pLastCol;
}
static SLastCol *tsdbCacheDeserialize(char const *value) {
if (!value) {
return NULL;
/*
typedef struct {
SLastColV0 lastColV0;
char colData[];
int8_t version;
uint8_t numOfPKs;
SValue pks[0];
char pk0Data[];
SValue pks[1];
char pk1Data[];
...
} SLastColDisk;
*/
static int32_t tsdbCacheSerializeV0(char const *value, SLastCol *pLastCol) {
SLastColV0 *pLastColV0 = (SLastColV0 *)value;
pLastColV0->ts = pLastCol->rowKey.ts;
pLastColV0->dirty = pLastCol->dirty;
pLastColV0->colVal.cid = pLastCol->colVal.cid;
pLastColV0->colVal.flag = pLastCol->colVal.flag;
pLastColV0->colVal.type = pLastCol->colVal.value.type;
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
pLastColV0->colVal.value.nData = pLastCol->colVal.value.nData;
if (pLastCol->colVal.value.nData > 0) {
memcpy(&pLastColV0[1], pLastCol->colVal.value.pData, pLastCol->colVal.value.nData);
}
return sizeof(SLastColV0) + pLastCol->colVal.value.nData;
} else {
pLastColV0->colVal.value.val = pLastCol->colVal.value.val;
return sizeof(SLastColV0);
}
bool hasVersion = ((*(int64_t *)value) & LAST_COL_VERSION_BASE) == LAST_COL_VERSION_BASE;
if (!hasVersion) {
return tsdbCacheDeserializeV1(value);
}
return tsdbCacheDeserializeV2(value);
}
static uint32_t tsdbCacheCopyVarData(SValue *from, SValue *to) {
ASSERT(from->nData >= 0);
if (from->nData > 0) {
memcpy(to->pData, from->pData, from->nData);
}
to->type = from->type;
to->nData = from->nData;
return from->nData;
return 0;
}
static void tsdbCacheSerialize(SLastCol *pLastCol, char **value, size_t *size) {
SColVal *pColVal = &pLastCol->colVal;
size_t length = sizeof(*pLastCol);
*size = sizeof(SLastColV0);
if (IS_VAR_DATA_TYPE(pLastCol->colVal.value.type)) {
*size += pLastCol->colVal.value.nData;
}
*size += sizeof(uint8_t) + sizeof(uint8_t); // version + numOfPKs
for (int8_t i = 0; i < pLastCol->rowKey.numOfPKs; i++) {
*size += sizeof(SValue);
if (IS_VAR_DATA_TYPE(pLastCol->rowKey.pks[i].type)) {
length += pLastCol->rowKey.pks[i].nData;
*size += pLastCol->rowKey.pks[i].nData;
}
}
if (IS_VAR_DATA_TYPE(pColVal->value.type)) {
length += pColVal->value.nData;
}
*value = taosMemoryMalloc(length);
*value = taosMemoryMalloc(*size);
// copy last col
SLastCol *pToLastCol = (SLastCol *)(*value);
*pToLastCol = *pLastCol;
char *currentPos = *value + sizeof(*pLastCol);
int32_t offset = tsdbCacheSerializeV0(*value, pLastCol);
// copy var data pks
// version
((uint8_t *)(*value + offset))[0] = LAST_COL_VERSION;
offset++;
// numOfPKs
((uint8_t *)(*value + offset))[0] = pLastCol->rowKey.numOfPKs;
offset++;
// pks
for (int8_t i = 0; i < pLastCol->rowKey.numOfPKs; i++) {
SValue *pFromValue = &pLastCol->rowKey.pks[i];
if (IS_VAR_DATA_TYPE(pFromValue->type)) {
SValue *pToValue = &pToLastCol->rowKey.pks[i];
pToValue->pData = (pFromValue->nData == 0) ? NULL : currentPos;
currentPos += tsdbCacheCopyVarData(pFromValue, pToValue);
((SValue *)(*value + offset))[0] = pLastCol->rowKey.pks[i];
offset += sizeof(SValue);
if (IS_VAR_DATA_TYPE(pLastCol->rowKey.pks[i].type)) {
if (pLastCol->rowKey.pks[i].nData > 0) {
memcpy(*value + offset, pLastCol->rowKey.pks[i].pData, pLastCol->rowKey.pks[i].nData);
}
offset += pLastCol->rowKey.pks[i].nData;
}
}
// copy var data value
if (IS_VAR_DATA_TYPE(pColVal->value.type)) {
SValue *pFromValue = &pColVal->value;
SValue *pToValue = &pToLastCol->colVal.value;
pToValue->pData = (pFromValue->nData == 0) ? NULL : currentPos;
currentPos += tsdbCacheCopyVarData(pFromValue, pToValue);
}
*size = length;
}
static void tsdbCachePutBatch(SLastCol *pLastCol, const void *key, size_t klen, SCacheFlushState *state) {
@ -571,8 +596,7 @@ static int32_t tsdbCacheNewTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, i
SRowKey noneRowKey = {0};
noneRowKey.ts = TSKEY_MIN;
noneRowKey.numOfPKs = 0;
SLastCol noneCol = {
.version = LAST_COL_VERSION, .rowKey = noneRowKey, .colVal = COL_VAL_NONE(cid, col_type), .dirty = 1};
SLastCol noneCol = {.rowKey = noneRowKey, .colVal = COL_VAL_NONE(cid, col_type), .dirty = 1};
SLastCol *pLastCol = &noneCol;
SLastCol *pTmpLastCol = taosMemoryCalloc(1, sizeof(SLastCol));
@ -644,11 +668,9 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid,
size_t *keys_list_sizes = taosMemoryCalloc(2, sizeof(size_t));
const size_t klen = ROCKS_KEY_LEN;
int8_t lflag = hasPrimaryKey ? LFLAG_PRIMARY_KEY : 0;
char *keys = taosMemoryCalloc(2, sizeof(SLastKey));
((SLastKey *)keys)[0] = (SLastKey){.lflag = lflag | LFLAG_LAST, .uid = uid, .cid = cid};
((SLastKey *)keys)[1] = (SLastKey){.lflag = lflag | LFLAG_LAST_ROW, .uid = uid, .cid = cid};
((SLastKey *)keys)[0] = (SLastKey){.lflag = LFLAG_LAST, .uid = uid, .cid = cid};
((SLastKey *)keys)[1] = (SLastKey){.lflag = LFLAG_LAST_ROW, .uid = uid, .cid = cid};
keys_list[0] = keys;
keys_list[1] = keys + sizeof(SLastKey);
@ -672,13 +694,13 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid,
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
{
SLastCol *pLastCol = tsdbCacheDeserialize(values_list[0]);
SLastCol *pLastCol = tsdbCacheDeserialize(values_list[0], values_list_sizes[0]);
if (NULL != pLastCol) {
rocksdb_writebatch_delete(wb, keys_list[0], klen);
}
taosMemoryFreeClear(pLastCol);
pLastCol = tsdbCacheDeserialize(values_list[1]);
pLastCol = tsdbCacheDeserialize(values_list[1], values_list_sizes[1]);
if (NULL != pLastCol) {
rocksdb_writebatch_delete(wb, keys_list[1], klen);
}
@ -724,18 +746,12 @@ int32_t tsdbCacheNewTable(STsdb *pTsdb, tb_uid_t uid, tb_uid_t suid, SSchemaWrap
taosThreadMutexLock(&pTsdb->lruMutex);
if (suid < 0) {
int8_t lflag = 0;
int nCols = pSchemaRow->nCols;
if (nCols >= 2) {
lflag = (pSchemaRow->pSchema[1].flags & COL_IS_KEY) ? LFLAG_PRIMARY_KEY : 0;
}
for (int i = 0; i < nCols; ++i) {
for (int i = 0; i < pSchemaRow->nCols; ++i) {
int16_t cid = pSchemaRow->pSchema[i].colId;
int8_t col_type = pSchemaRow->pSchema[i].type;
(void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, lflag | LFLAG_LAST_ROW);
(void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, lflag | LFLAG_LAST);
(void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST_ROW);
(void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST);
}
} else {
STSchema *pTSchema = NULL;
@ -745,18 +761,12 @@ int32_t tsdbCacheNewTable(STsdb *pTsdb, tb_uid_t uid, tb_uid_t suid, SSchemaWrap
return -1;
}
int8_t lflag = 0;
int nCols = pTSchema->numOfCols;
if (nCols >= 2) {
lflag = (pTSchema->columns[1].flags & COL_IS_KEY) ? LFLAG_PRIMARY_KEY : 0;
}
for (int i = 0; i < nCols; ++i) {
for (int i = 0; i < pTSchema->numOfCols; ++i) {
int16_t cid = pTSchema->columns[i].colId;
int8_t col_type = pTSchema->columns[i].type;
(void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, lflag | LFLAG_LAST_ROW);
(void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, lflag | LFLAG_LAST);
(void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST_ROW);
(void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST);
}
taosMemoryFree(pTSchema);
@ -935,7 +945,6 @@ static void tsdbCacheUpdateLastCol(SLastCol *pLastCol, SRowKey *pRowKey, SColVal
int nData = 0;
// update rowkey
pLastCol->version = LAST_COL_VERSION;
pLastCol->rowKey.ts = pRowKey->ts;
pLastCol->rowKey.numOfPKs = pRowKey->numOfPKs;
for (int8_t i = 0; i < pRowKey->numOfPKs; i++) {
@ -1016,14 +1025,13 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
STsdbRowKey tsdbRowKey = {0};
tsdbRowGetKey(pRow, &tsdbRowKey);
SRowKey *pRowKey = &tsdbRowKey.key;
int8_t lflag = (pRowKey->numOfPKs != 0) ? LFLAG_PRIMARY_KEY : 0;
taosThreadMutexLock(&pTsdb->lruMutex);
for (int i = 0; i < num_keys; ++i) {
SColVal *pColVal = (SColVal *)taosArrayGet(aColVal, i);
int16_t cid = pColVal->cid;
SLastKey *key = &(SLastKey){.lflag = lflag | LFLAG_LAST_ROW, .uid = uid, .cid = cid};
SLastKey *key = &(SLastKey){.lflag = LFLAG_LAST_ROW, .uid = uid, .cid = cid};
size_t klen = ROCKS_KEY_LEN;
LRUHandle *h = taosLRUCacheLookup(pCache, key, klen);
if (h) {
@ -1041,7 +1049,7 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
}
if (COL_VAL_IS_VALUE(pColVal)) {
key->lflag = lflag | LFLAG_LAST;
key->lflag = LFLAG_LAST;
LRUHandle *h = taosLRUCacheLookup(pCache, key, klen);
if (h) {
SLastCol *pLastCol = (SLastCol *)taosLRUCacheValue(pCache, h);
@ -1079,9 +1087,6 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
rocksdb_free(errs[i]);
}
taosMemoryFree(errs);
taosMemoryFree(keys_list);
taosMemoryFree(keys_list_sizes);
taosMemoryFree(values_list_sizes);
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
for (int i = 0; i < num_keys; ++i) {
@ -1089,7 +1094,7 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
SColVal *pColVal = (SColVal *)TARRAY_DATA(aColVal) + idxKey->idx;
// SColVal *pColVal = (SColVal *)taosArrayGet(aColVal, idxKey->idx);
SLastCol *pLastCol = tsdbCacheDeserialize(values_list[i]);
SLastCol *pLastCol = tsdbCacheDeserialize(values_list[i], values_list_sizes[i]);
SLastCol *PToFree = pLastCol;
if (IS_LAST_ROW_KEY(idxKey->key)) {
@ -1101,17 +1106,16 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
if (NULL == pLastCol || cmp_res < 0 || (cmp_res == 0 && !COL_VAL_IS_NONE(pColVal))) {
char *value = NULL;
size_t vlen = 0;
tsdbCacheSerialize(&(SLastCol){.version = LAST_COL_VERSION, .rowKey = *pRowKey, .colVal = *pColVal}, &value,
&vlen);
SLastCol lastColTmp = {.rowKey = *pRowKey, .colVal = *pColVal};
tsdbCacheSerialize(&lastColTmp, &value, &vlen);
// SLastKey key = (SLastKey){.ltype = 0, .uid = uid, .cid = pColVal->cid};
taosThreadMutexLock(&pTsdb->rCache.rMutex);
rocksdb_writebatch_put(wb, (char *)&idxKey->key, ROCKS_KEY_LEN, value, vlen);
taosThreadMutexUnlock(&pTsdb->rCache.rMutex);
pLastCol = (SLastCol *)value;
pLastCol = &lastColTmp;
SLastCol *pTmpLastCol = taosMemoryCalloc(1, sizeof(SLastCol));
*pTmpLastCol = *pLastCol;
pLastCol = pTmpLastCol;
@ -1143,17 +1147,16 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
if (NULL == pLastCol || (tRowKeyCompare(&pLastCol->rowKey, pRowKey) != 1)) {
char *value = NULL;
size_t vlen = 0;
tsdbCacheSerialize(&(SLastCol){.version = LAST_COL_VERSION, .rowKey = *pRowKey, .colVal = *pColVal}, &value,
&vlen);
SLastCol lastColTmp = {.rowKey = *pRowKey, .colVal = *pColVal};
tsdbCacheSerialize(&lastColTmp, &value, &vlen);
// SLastKey key = (SLastKey){.ltype = 1, .uid = uid, .cid = pColVal->cid};
taosThreadMutexLock(&pTsdb->rCache.rMutex);
rocksdb_writebatch_put(wb, (char *)&idxKey->key, ROCKS_KEY_LEN, value, vlen);
taosThreadMutexUnlock(&pTsdb->rCache.rMutex);
pLastCol = (SLastCol *)value;
pLastCol = &lastColTmp;
SLastCol *pTmpLastCol = taosMemoryCalloc(1, sizeof(SLastCol));
*pTmpLastCol = *pLastCol;
pLastCol = pTmpLastCol;
@ -1189,7 +1192,10 @@ int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSDBROW *pRow
rocksMayWrite(pTsdb, true, false, true);
taosMemoryFree(keys_list);
taosMemoryFree(keys_list_sizes);
taosMemoryFree(values_list);
taosMemoryFree(values_list_sizes);
taosArrayDestroy(remainCols);
}
@ -1465,8 +1471,7 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
}
// still null, then make up a none col value
SLastCol noneCol = {.version = LAST_COL_VERSION,
.rowKey.ts = TSKEY_MIN,
SLastCol noneCol = {.rowKey.ts = TSKEY_MIN,
.colVal = COL_VAL_NONE(idxKey->key.cid, pr->pSchema->columns[slotIds[i]].type)};
if (!pLastCol) {
pLastCol = &noneCol;
@ -1563,14 +1568,10 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA
rocksdb_free(errs[i]);
}
}
taosMemoryFree(key_list);
taosMemoryFree(keys_list);
taosMemoryFree(keys_list_sizes);
taosMemoryFree(errs);
SLRUCache *pCache = pTsdb->lruCache;
for (int i = 0, j = 0; i < num_keys && j < TARRAY_SIZE(remainCols); ++i) {
SLastCol *pLastCol = tsdbCacheDeserialize(values_list[i]);
SLastCol *pLastCol = tsdbCacheDeserialize(values_list[i], values_list_sizes[i]);
SLastCol *PToFree = pLastCol;
SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[j];
if (pLastCol) {
@ -1612,6 +1613,10 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA
}
}
taosMemoryFree(errs);
taosMemoryFree(key_list);
taosMemoryFree(keys_list);
taosMemoryFree(keys_list_sizes);
taosMemoryFree(values_list);
taosMemoryFree(values_list_sizes);
@ -1657,8 +1662,7 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
taosLRUCacheRelease(pCache, h, false);
} else {
SLastCol noneCol = {.version = LAST_COL_VERSION,
.rowKey.ts = TSKEY_MIN,
SLastCol noneCol = {.rowKey.ts = TSKEY_MIN,
.colVal = COL_VAL_NONE(cid, pr->pSchema->columns[pr->pSlotIds[i]].type)};
taosArrayPush(pLastArray, &noneCol);
@ -1723,17 +1727,12 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
size_t *keys_list_sizes = taosMemoryCalloc(num_keys * 2, sizeof(size_t));
const size_t klen = ROCKS_KEY_LEN;
int8_t lflag = 0;
if (num_keys >= 2) {
lflag = (pTSchema->columns[1].flags & COL_IS_KEY) ? LFLAG_PRIMARY_KEY : 0;
}
for (int i = 0; i < num_keys; ++i) {
int16_t cid = pTSchema->columns[i].colId;
char *keys = taosMemoryCalloc(2, sizeof(SLastKey));
((SLastKey *)keys)[0] = (SLastKey){.lflag = lflag | LFLAG_LAST, .uid = uid, .cid = cid};
((SLastKey *)keys)[1] = (SLastKey){.lflag = lflag | LFLAG_LAST_ROW, .uid = uid, .cid = cid};
((SLastKey *)keys)[0] = (SLastKey){.lflag = LFLAG_LAST, .uid = uid, .cid = cid};
((SLastKey *)keys)[1] = (SLastKey){.lflag = LFLAG_LAST_ROW, .uid = uid, .cid = cid};
keys_list[i] = keys;
keys_list[num_keys + i] = keys + sizeof(SLastKey);
@ -1763,14 +1762,14 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE
rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch;
for (int i = 0; i < num_keys; ++i) {
SLastCol *pLastCol = tsdbCacheDeserialize(values_list[i]);
SLastCol *pLastCol = tsdbCacheDeserialize(values_list[i], values_list_sizes[i]);
taosThreadMutexLock(&pTsdb->rCache.rMutex);
if (NULL != pLastCol && (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey)) {
rocksdb_writebatch_delete(wb, keys_list[i], klen);
}
taosMemoryFreeClear(pLastCol);
pLastCol = tsdbCacheDeserialize(values_list[i + num_keys]);
pLastCol = tsdbCacheDeserialize(values_list[i + num_keys], values_list_sizes[i + num_keys]);
if (NULL != pLastCol && (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey)) {
rocksdb_writebatch_delete(wb, keys_list[num_keys + i], klen);
}
@ -3296,8 +3295,7 @@ static int32_t initLastColArrayPartial(STSchema *pTSchema, SArray **ppColArray,
for (int32_t i = 0; i < nCols; ++i) {
int16_t slotId = slotIds[i];
SLastCol col = {.version = LAST_COL_VERSION,
.rowKey.ts = 0,
SLastCol col = {.rowKey.ts = 0,
.colVal = COL_VAL_NULL(pTSchema->columns[slotId].colId, pTSchema->columns[slotId].type)};
taosArrayPush(pColArray, &col);
}
@ -3403,12 +3401,12 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC
STColumn *pTColumn = &pTSchema->columns[0];
*pColVal = COL_VAL_VALUE(pTColumn->colId, ((SValue){.type = pTColumn->type, .val = rowTs}));
taosArraySet(pColArray, 0, &(SLastCol){.version = LAST_COL_VERSION, .rowKey.ts = rowTs, .colVal = *pColVal});
taosArraySet(pColArray, 0, &(SLastCol){.rowKey.ts = rowTs, .colVal = *pColVal});
continue;
}
tsdbRowGetColVal(pRow, pTSchema, slotIds[iCol], pColVal);
*pCol = (SLastCol){.version = LAST_COL_VERSION, .rowKey.ts = rowTs, .colVal = *pColVal};
*pCol = (SLastCol){.rowKey.ts = rowTs, .colVal = *pColVal};
if (IS_VAR_DATA_TYPE(pColVal->value.type) /*&& pColVal->value.nData > 0*/) {
if (pColVal->value.nData > 0) {
pCol->colVal.value.pData = taosMemoryMalloc(pCol->colVal.value.nData);
@ -3458,7 +3456,7 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC
tsdbRowGetColVal(pRow, pTSchema, slotIds[iCol], pColVal);
if (!COL_VAL_IS_VALUE(tColVal) && COL_VAL_IS_VALUE(pColVal)) {
SLastCol lastCol = {.version = LAST_COL_VERSION, .rowKey.ts = rowTs, .colVal = *pColVal};
SLastCol lastCol = {.rowKey.ts = rowTs, .colVal = *pColVal};
if (IS_VAR_DATA_TYPE(pColVal->value.type) /* && pColVal->value.nData > 0 */) {
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pColArray, iCol);
taosMemoryFree(pLastCol->colVal.value.pData);
@ -3582,12 +3580,12 @@ static int32_t mergeLastRowCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray,
STColumn *pTColumn = &pTSchema->columns[0];
*pColVal = COL_VAL_VALUE(pTColumn->colId, ((SValue){.type = pTColumn->type, .val = rowTs}));
taosArraySet(pColArray, 0, &(SLastCol){.version = LAST_COL_VERSION, .rowKey.ts = rowTs, .colVal = *pColVal});
taosArraySet(pColArray, 0, &(SLastCol){.rowKey.ts = rowTs, .colVal = *pColVal});
continue;
}
tsdbRowGetColVal(pRow, pTSchema, slotIds[iCol], pColVal);
*pCol = (SLastCol){.version = LAST_COL_VERSION, .rowKey.ts = rowTs, .colVal = *pColVal};
*pCol = (SLastCol){.rowKey.ts = rowTs, .colVal = *pColVal};
if (IS_VAR_DATA_TYPE(pColVal->value.type) /*&& pColVal->value.nData > 0*/) {
if (pColVal->value.nData > 0) {
pCol->colVal.value.pData = taosMemoryMalloc(pCol->colVal.value.nData);

View File

@ -385,9 +385,6 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
}
int8_t ltype = (pr->type & CACHESCAN_RETRIEVE_LAST) >> 3;
if (pr->rowKey.numOfPKs > 0) {
ltype |= CACHESCAN_RETRIEVE_PK;
}
STableKeyInfo* pTableList = pr->pTableList;

View File

@ -327,6 +327,7 @@ static int32_t abort_edit(STFileSystem *fs) {
} else if (fs->etype == TSDB_FEDIT_MERGE) {
current_fname(fs->tsdb, fname, TSDB_FCURRENT_M);
} else {
tsdbError("vgId:%d %s failed since invalid etype:%d", TD_VID(fs->tsdb->pVnode), __func__, fs->etype);
ASSERT(0);
}

View File

@ -666,6 +666,7 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, SSnapshotParam *pParam, SVSnapWriter
_err:
vError("vgId:%d, vnode snapshot writer open failed since %s", TD_VID(pVnode), tstrerror(code));
if (pWriter) taosMemoryFreeClear(pWriter);
*ppWriter = NULL;
return code;
}

View File

@ -1144,7 +1144,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq,
if (i < tbNames->size - 1) {
taosStringBuilderAppendChar(&sb, ',');
}
taosMemoryFreeClear(*key);
//taosMemoryFreeClear(*key);
}
size_t len = 0;
@ -1168,7 +1168,7 @@ _exit:
taosArrayDestroy(tbUids);
tDecoderClear(&decoder);
tEncoderClear(&encoder);
taosArrayDestroy(tbNames);
taosArrayDestroyP(tbNames, taosMemoryFree);
return rcode;
}

View File

@ -3448,13 +3448,14 @@ int32_t ctgDropTSMAForTbEnqueue(SCatalog *pCtg, SName *pName, bool syncOp) {
SCtgDBCache *pDbCache = NULL;
SCtgCacheOperation *pOp = NULL;
char dbFName[TSDB_DB_FNAME_LEN];
SCtgTSMACache *pCtgCache = NULL;
tNameGetFullDbName(pName, dbFName);
CTG_ERR_JRET(ctgGetDBCache(pCtg, dbFName, &pDbCache));
if (NULL == pDbCache || !pDbCache->tsmaCache) {
goto _return;
}
SCtgTSMACache *pCtgCache = taosHashGet(pDbCache->tsmaCache, pName->tname, strlen(pName->tname));
pCtgCache = taosHashAcquire(pDbCache->tsmaCache, pName->tname, strlen(pName->tname));
if (!pCtgCache) goto _return;
CTG_LOCK(CTG_READ, &pCtgCache->tsmaLock);
@ -3471,10 +3472,11 @@ int32_t ctgDropTSMAForTbEnqueue(SCatalog *pCtg, SName *pName, bool syncOp) {
}
CTG_UNLOCK(CTG_READ, &pCtgCache->tsmaLock);
CTG_ERR_JRET(ctgEnqueue(pCtg, pOp));
taosHashRelease(pDbCache->tsmaCache, pCtgCache);
return TSDB_CODE_SUCCESS;
_return:
if (pCtgCache) taosHashRelease(pDbCache->tsmaCache, pCtgCache);
if (pOp) {
taosMemoryFree(pOp->data);
taosMemoryFree(pOp);

View File

@ -160,9 +160,6 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
// partition by tbname
if (oneTableForEachGroup(pTableListInfo) || (totalTables == 1)) {
pInfo->retrieveType = CACHESCAN_RETRIEVE_TYPE_ALL | SCAN_ROW_TYPE(pScanNode->ignoreNull);
if (pInfo->numOfPks > 0) {
pInfo->retrieveType |= CACHESCAN_RETRIEVE_PK;
}
STableKeyInfo* pList = tableListGetInfo(pTableListInfo, 0);

View File

@ -4320,6 +4320,7 @@ void tableMergeScanTsdbNotifyCb(ETsdReaderNotifyType type, STsdReaderNotifyInfo*
int32_t startDurationForGroupTableMergeScan(SOperatorInfo* pOperator) {
STableMergeScanInfo* pInfo = pOperator->info;
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
int32_t code = TSDB_CODE_SUCCESS;
int32_t numOfTable = pInfo->tableEndIndex - pInfo->tableStartIndex + 1;
@ -4339,6 +4340,7 @@ int32_t startDurationForGroupTableMergeScan(SOperatorInfo* pOperator) {
return code;
}
}
tsortSetMergeLimit(pInfo->pSortHandle, pInfo->mergeLimit);
tsortSetMergeLimitReachedFp(pInfo->pSortHandle, tableMergeScanDoSkipTable, pInfo);
tsortSetAbortCheckFn(pInfo->pSortHandle, isTaskKilled, pOperator->pTaskInfo);

View File

@ -204,6 +204,11 @@ static bool checkDuplicateTimestamps(STimeSliceOperatorInfo* pSliceInfo, SColumn
SRowKey cur = {.ts = currentTs, .numOfPKs = (pPkCol != NULL)? 1:0};
if (pPkCol != NULL) {
cur.pks[0].type = pPkCol->info.type;
if (IS_VAR_DATA_TYPE(pPkCol->info.type)) {
cur.pks[0].pData = (uint8_t*)colDataGetVarData(pPkCol, curIndex);
} else {
memcpy(&cur.pks[0].val, colDataGetData(pPkCol, curIndex), pPkCol->info.bytes);
}
}
// let's discard the duplicated ts

View File

@ -260,6 +260,7 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page
pSortHandle->cmpParam.orderInfo = pSortInfo;
pSortHandle->cmpParam.cmpGroupId = false;
pSortHandle->cmpParam.sortType = type;
if (type == SORT_BLOCK_TS_MERGE) {
SBlockOrderInfo* pTsOrder = TARRAY_GET_ELEM(pSortInfo, 0);
pSortHandle->cmpParam.tsSlotId = pTsOrder->slotId;
@ -522,10 +523,9 @@ static int32_t sortComparInit(SMsortComparParam* pParam, SArray* pSources, int32
static void appendOneRowToDataBlock(SSDataBlock* pBlock, const SSDataBlock* pSource, int32_t* rowIndex) {
for (int32_t i = 0; i < taosArrayGetSize(pBlock->pDataBlock); ++i) {
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, i);
SColumnInfoData* pSrcColInfo = taosArrayGet(pSource->pDataBlock, i);
bool isNull = colDataIsNull(pSrcColInfo, pSource->info.rows, *rowIndex, NULL);
bool isNull = colDataIsNull(pSrcColInfo, pSource->info.rows, *rowIndex, NULL);
if (isNull) {
colDataSetVal(pColInfo, pBlock->info.rows, NULL, true);
} else {
@ -557,7 +557,9 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource* pSource, SMultiwayMergeT
pSource->pageIndex = -1;
pSource->src.pBlock = blockDataDestroy(pSource->src.pBlock);
} else {
if (pSource->pageIndex % 512 == 0) qDebug("begin source %p page %d", pSource, pSource->pageIndex);
if (pSource->pageIndex % 512 == 0) {
qDebug("begin source %p page %d", pSource, pSource->pageIndex);
}
int32_t* pPgId = taosArrayGet(pSource->pageIdList, pSource->pageIndex);
@ -635,7 +637,7 @@ static SSDataBlock* getSortedBlockDataInner(SSortHandle* pHandle, SMsortComparPa
// TODO: improve this function performance
int tsortComparBlockCell(SSDataBlock* pLeftBlock, SSDataBlock* pRightBlock,
int32_t tsortComparBlockCell(SSDataBlock* pLeftBlock, SSDataBlock* pRightBlock,
int32_t leftRowIndex, int32_t rightRowIndex, void* pCompareOrder) {
SBlockOrderInfo* pOrder = pCompareOrder;
SColumnInfoData* pLeftColInfoData = TARRAY_GET_ELEM(pLeftBlock->pDataBlock, pOrder->slotId);
@ -680,7 +682,7 @@ int tsortComparBlockCell(SSDataBlock* pLeftBlock, SSDataBlock* pRightBlock,
left1 = colDataGetData(pLeftColInfoData, leftRowIndex);
right1 = colDataGetData(pRightColInfoData, rightRowIndex);
__compar_fn_t fn = pOrder->compFn;
int ret = fn(left1, right1);
int32_t ret = fn(left1, right1);
return ret;
}
@ -719,7 +721,7 @@ int32_t msortComparFn(const void* pLeft, const void* pRight, void* param) {
int64_t* leftTs = (int64_t*)(pLeftTsCol->pData) + pLeftSource->src.rowIndex;
int64_t* rightTs = (int64_t*)(pRightTsCol->pData) + pRightSource->src.rowIndex;
int ret = pParam->cmpTsFn(leftTs, rightTs);
int32_t ret = pParam->cmpTsFn(leftTs, rightTs);
if (ret == 0 && pParam->pPkOrder) {
ret = tsortComparBlockCell(pLeftBlock, pRightBlock,
pLeftSource->src.rowIndex, pRightSource->src.rowIndex, (SBlockOrderInfo*)pParam->pPkOrder);
@ -782,7 +784,7 @@ int32_t msortComparFn(const void* pLeft, const void* pRight, void* param) {
pOrder->compFn = fn;
}
int ret = fn(left1, right1);
int32_t ret = fn(left1, right1);
if (ret == 0) {
continue;
} else {
@ -855,7 +857,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
return code;
}
int nMergedRows = 0;
int32_t nMergedRows = 0;
SArray* pPageIdList = taosArrayInit(4, sizeof(int32_t));
while (1) {
@ -1075,7 +1077,7 @@ static int32_t getRowBufFromExtMemFile(SSortHandle* pHandle, int32_t regionId, i
}
taosSeekCFile(pMemFile->pTdFile, pRegion->fileOffset, SEEK_SET);
int32_t readBytes = TMIN(pMemFile->blockSize, pRegion->regionSize);
int ret = taosReadFromCFile(pRegion->buf, readBytes, 1, pMemFile->pTdFile);
int32_t ret = taosReadFromCFile(pRegion->buf, readBytes, 1, pMemFile->pTdFile);
if (ret != 1) {
terrno = TAOS_SYSTEM_ERROR(errno);
return terrno;
@ -1095,7 +1097,7 @@ static int32_t getRowBufFromExtMemFile(SSortHandle* pHandle, int32_t regionId, i
memcpy(*ppRow, pRegion->buf + tupleOffset - pRegion->bufRegOffset, szThisBlock);
taosSeekCFile(pMemFile->pTdFile, pRegion->fileOffset + pRegion->bufRegOffset + pRegion->bufLen, SEEK_SET);
int32_t readBytes = TMIN(pMemFile->blockSize, pRegion->regionSize - (pRegion->bufRegOffset + pRegion->bufLen));
int ret = taosReadFromCFile(pRegion->buf, readBytes, 1, pMemFile->pTdFile);
int32_t ret = taosReadFromCFile(pRegion->buf, readBytes, 1, pMemFile->pTdFile);
if (ret != 1) {
taosMemoryFreeClear(*ppRow);
terrno = TAOS_SYSTEM_ERROR(errno);
@ -1214,7 +1216,7 @@ static int32_t tsortCloseRegion(SSortHandle* pHandle) {
pRegion->regionSize = pMemFile->currRegionOffset;
int32_t writeBytes = pRegion->regionSize - (pMemFile->writeFileOffset - pRegion->fileOffset);
if (writeBytes > 0) {
int ret = fwrite(pMemFile->writeBuf, writeBytes, 1, pMemFile->pTdFile);
int32_t ret = fwrite(pMemFile->writeBuf, writeBytes, 1, pMemFile->pTdFile);
if (ret != 1) {
terrno = TAOS_SYSTEM_ERROR(errno);
return terrno;
@ -1241,13 +1243,15 @@ static int32_t tsortFinalizeRegions(SSortHandle* pHandle) {
return TSDB_CODE_SUCCESS;
}
static int32_t saveBlockRowToExtRowsMemFile(SSortHandle* pHandle, SSDataBlock* pBlock, int32_t rowIdx, int32_t* pRegionId, int32_t* pOffset, int32_t* pLength) {
static int32_t saveBlockRowToExtRowsMemFile(SSortHandle* pHandle, SSDataBlock* pBlock, int32_t rowIdx,
int32_t* pRegionId, int32_t* pOffset, int32_t* pLength) {
SSortMemFile* pMemFile = pHandle->pExtRowsMemFile;
SSortMemFileRegion* pRegion = taosArrayGet(pMemFile->aFileRegions, pMemFile->currRegionId);
{
if (pMemFile->currRegionOffset + pHandle->extRowBytes >= pMemFile->writeBufSize) {
int32_t writeBytes = pMemFile->currRegionOffset - (pMemFile->writeFileOffset - pRegion->fileOffset);
int ret = fwrite(pMemFile->writeBuf, writeBytes, 1, pMemFile->pTdFile);
int32_t ret = fwrite(pMemFile->writeBuf, writeBytes, 1, pMemFile->pTdFile);
if (ret != 1) {
terrno = TAOS_SYSTEM_ERROR(errno);
return terrno;
@ -1255,11 +1259,13 @@ static int32_t saveBlockRowToExtRowsMemFile(SSortHandle* pHandle, SSDataBlock* p
pMemFile->writeFileOffset = pRegion->fileOffset + pMemFile->currRegionOffset;
}
}
*pRegionId = pMemFile->currRegionId;
*pOffset = pMemFile->currRegionOffset;
int32_t writeBufOffset = pMemFile->currRegionOffset - (pMemFile->writeFileOffset - pRegion->fileOffset);
int32_t blockLen = blockRowToBuf(pBlock, rowIdx, pMemFile->writeBuf + writeBufOffset);
*pLength = blockLen;
pMemFile->currRegionOffset += blockLen;
pMemFile->bRegionDirty = true;
return TSDB_CODE_SUCCESS;
@ -1317,27 +1323,30 @@ static void initRowIdSort(SSortHandle* pHandle) {
blockDataAppendColInfo(pSortInput, &offsetCol);
SColumnInfoData lengthCol = createColumnInfoData(TSDB_DATA_TYPE_INT, 4, 4);
blockDataAppendColInfo(pSortInput, &lengthCol);
if (pHandle->bSortPk) {
pkCol = createColumnInfoData(extPkCol->info.type, extPkCol->info.bytes, 5);
blockDataAppendColInfo(pSortInput, &pkCol);
}
blockDataDestroy(pHandle->pDataBlock);
pHandle->pDataBlock = pSortInput;
int32_t rowSize = blockDataGetRowSize(pHandle->pDataBlock);
size_t nCols = taosArrayGetSize(pHandle->pDataBlock->pDataBlock);
// int32_t rowSize = blockDataGetRowSize(pHandle->pDataBlock);
// size_t nCols = taosArrayGetSize(pHandle->pDataBlock->pDataBlock);
pHandle->pageSize = 256 * 1024; // 256k
pHandle->numOfPages = 256;
SArray* aOrder = taosArrayInit(1, sizeof(SBlockOrderInfo));
SArray* pOrderInfoList = taosArrayInit(1, sizeof(SBlockOrderInfo));
int32_t tsOrder = ((SBlockOrderInfo*)taosArrayGet(pHandle->pSortInfo, 0))->order;
SBlockOrderInfo* pTsOrder = taosArrayGet(pHandle->pSortInfo, 0);
SBlockOrderInfo biTs = {0};
biTs.order = pTsOrder->order;
biTs.order = tsOrder;
biTs.slotId = 0;
biTs.nullFirst = (biTs.order == TSDB_ORDER_ASC);
biTs.compFn = getKeyComparFunc(TSDB_DATA_TYPE_TIMESTAMP, biTs.order);
taosArrayPush(aOrder, &biTs);
taosArrayPush(pOrderInfoList, &biTs);
if (pHandle->bSortPk) {
SBlockOrderInfo biPk = {0};
@ -1345,11 +1354,11 @@ static void initRowIdSort(SSortHandle* pHandle) {
biPk.slotId = 4;
biPk.nullFirst = (biPk.order == TSDB_ORDER_ASC);
biPk.compFn = getKeyComparFunc(pkCol.info.type, biPk.order);
taosArrayPush(aOrder, &biPk);
taosArrayPush(pOrderInfoList, &biPk);
}
taosArrayDestroy(pHandle->pSortInfo);
pHandle->pSortInfo = aOrder;
return;
pHandle->pSortInfo = pOrderInfoList;
}
int32_t tsortSetSortByRowId(SSortHandle* pHandle, int32_t extRowsMemSize) {
@ -1440,77 +1449,170 @@ static int32_t appendDataBlockToPageBuf(SSortHandle* pHandle, SSDataBlock* blk,
return 0;
}
static int32_t getPageBufIncForRow(SSDataBlock* blk, int32_t row, int32_t rowIdxInPage) {
int sz = 0;
int numCols = taosArrayGetSize(blk->pDataBlock);
if (!blk->info.hasVarCol) {
sz += numCols * ((rowIdxInPage & 0x7) == 0 ? 1: 0);
sz += blockDataGetRowSize(blk);
static int32_t getPageBufIncForRow(SSDataBlock* pSrcBlock, int32_t srcRowIndex, int32_t dstRowIndex) {
int32_t size = 0;
int32_t numCols = taosArrayGetSize(pSrcBlock->pDataBlock);
if (!pSrcBlock->info.hasVarCol) {
size += numCols * ((dstRowIndex & 0x7) == 0 ? 1: 0);
size += blockDataGetRowSize(pSrcBlock);
} else {
for (int32_t i = 0; i < numCols; ++i) {
SColumnInfoData* pColInfoData = TARRAY_GET_ELEM(blk->pDataBlock, i);
SColumnInfoData* pColInfoData = TARRAY_GET_ELEM(pSrcBlock->pDataBlock, i);
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
if ((pColInfoData->varmeta.offset[row] != -1) && (pColInfoData->pData)) {
char* p = colDataGetData(pColInfoData, row);
sz += varDataTLen(p);
}
if ((pColInfoData->varmeta.offset[srcRowIndex] != -1) && (pColInfoData->pData)) {
char* p = colDataGetData(pColInfoData, srcRowIndex);
sz += sizeof(pColInfoData->varmeta.offset[0]);
if (pColInfoData->info.type == TSDB_DATA_TYPE_JSON) {
size += getJsonValueLen(p);
} else {
sz += pColInfoData->info.bytes;
size += varDataTLen(p);
}
}
if (((rowIdxInPage) & 0x07) == 0) {
sz += 1; // bitmap
size += sizeof(pColInfoData->varmeta.offset[0]);
} else {
size += pColInfoData->info.bytes;
if (((dstRowIndex) & 0x07) == 0) {
size += 1; // bitmap
}
}
}
}
return sz;
return size;
}
static int32_t getPageBufIncForRowIdSort(SSDataBlock* pDstBlock, int32_t srcRowIndex, int32_t dstRowIndex,
SColumnInfoData* pPkCol) {
int32_t size = 0;
int32_t numOfCols = blockDataGetNumOfCols(pDstBlock);
if (pPkCol == NULL) { // no var column
ASSERT((numOfCols == 4) && (!pDstBlock->info.hasVarCol));
size += numOfCols * ((dstRowIndex & 0x7) == 0 ? 1: 0);
size += blockDataGetRowSize(pDstBlock);
} else {
ASSERT(numOfCols == 5);
size += (numOfCols - 1) * (((dstRowIndex & 0x7) == 0)? 1:0);
for(int32_t i = 0; i < numOfCols - 1; ++i) {
SColumnInfoData* pColInfo = TARRAY_GET_ELEM(pDstBlock->pDataBlock, i);
size += pColInfo->info.bytes;
}
// handle the pk column, the last column, may be the var char column
if (IS_VAR_DATA_TYPE(pPkCol->info.type)) {
if ((pPkCol->varmeta.offset[srcRowIndex] != -1) && (pPkCol->pData)) {
char* p = colDataGetData(pPkCol, srcRowIndex);
size += varDataTLen(p);
}
size += sizeof(pPkCol->varmeta.offset[0]);
} else {
size += pPkCol->info.bytes;
if (((dstRowIndex) & 0x07) == 0) {
size += 1; // bitmap
}
}
}
return size;
}
static int32_t getBufIncForNewRow(SSortHandle* pHandle, int32_t dstRowIndex, SSDataBlock* pSrcBlock,
int32_t srcRowIndex) {
int32_t inc = 0;
if (pHandle->bSortByRowId) {
SColumnInfoData* pPkCol = NULL;
// there may be varchar column exists, so we need to get the pk info, and then calculate the row length
if (pHandle->bSortPk) {
SBlockOrderInfo* extRowsPkOrder = taosArrayGet(pHandle->aExtRowsOrders, 1);
pPkCol = taosArrayGet(pSrcBlock->pDataBlock, extRowsPkOrder->slotId);
}
inc = getPageBufIncForRowIdSort(pHandle->pDataBlock, srcRowIndex, dstRowIndex, pPkCol);
} else {
inc = getPageBufIncForRow(pSrcBlock, srcRowIndex, dstRowIndex);
}
return inc;
}
static int32_t initMergeSup(SBlkMergeSupport* pSup, SArray* pBlockList, int32_t tsOrder, int32_t tsSlotId, SBlockOrderInfo* pPkOrderInfo) {
memset(pSup, 0, sizeof(SBlkMergeSupport));
int32_t numOfBlocks = taosArrayGetSize(pBlockList);
pSup->aRowIdx = taosMemoryCalloc(numOfBlocks, sizeof(int32_t));
pSup->aTs = taosMemoryCalloc(numOfBlocks, sizeof(int64_t*));
pSup->tsOrder = tsOrder;
pSup->aBlks = taosMemoryCalloc(numOfBlocks, sizeof(SSDataBlock*));
for (int32_t i = 0; i < numOfBlocks; ++i) {
SSDataBlock* pBlock = taosArrayGetP(pBlockList, i);
SColumnInfoData* col = taosArrayGet(pBlock->pDataBlock, tsSlotId);
pSup->aTs[i] = (int64_t*)col->pData;
pSup->aRowIdx[i] = 0;
pSup->aBlks[i] = pBlock;
}
pSup->pPkOrder = pPkOrderInfo;
return TSDB_CODE_SUCCESS;
}
static void cleanupMergeSup(SBlkMergeSupport* pSup) {
taosMemoryFree(pSup->aRowIdx);
taosMemoryFree(pSup->aTs);
taosMemoryFree(pSup->aBlks);
}
static int32_t getTotalRows(SArray* pBlockList) {
int32_t totalRows = 0;
for (int32_t i = 0; i < taosArrayGetSize(pBlockList); ++i) {
SSDataBlock* blk = taosArrayGetP(pBlockList, i);
totalRows += blk->info.rows;
}
return totalRows;
}
static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray* aExtSrc) {
int32_t code = TSDB_CODE_SUCCESS;
int pgHeaderSz = sizeof(int32_t) + sizeof(int32_t) * taosArrayGetSize(pHandle->pDataBlock->pDataBlock);
int32_t rowCap = blockDataGetCapacityInRow(pHandle->pDataBlock, pHandle->pageSize, pgHeaderSz);
int32_t pageHeaderSize = sizeof(int32_t) + sizeof(int32_t) * blockDataGetNumOfCols(pHandle->pDataBlock);
int32_t rowCap = blockDataGetCapacityInRow(pHandle->pDataBlock, pHandle->pageSize, pageHeaderSize);
blockDataEnsureCapacity(pHandle->pDataBlock, rowCap);
blockDataCleanup(pHandle->pDataBlock);
int32_t numBlks = taosArrayGetSize(aBlk);
SBlockOrderInfo* pOrigBlockTsOrder = (!pHandle->bSortByRowId) ?
taosArrayGet(pHandle->pSortInfo, 0) : taosArrayGet(pHandle->aExtRowsOrders, 0);
SBlockOrderInfo* pHandleBlockTsOrder = taosArrayGet(pHandle->pSortInfo, 0);
SBlkMergeSupport sup = {0};
sup.aRowIdx = taosMemoryCalloc(numBlks, sizeof(int32_t));
sup.aTs = taosMemoryCalloc(numBlks, sizeof(int64_t*));
sup.tsOrder = pOrigBlockTsOrder->order;
sup.aBlks = taosMemoryCalloc(numBlks, sizeof(SSDataBlock*));
for (int i = 0; i < numBlks; ++i) {
SSDataBlock* blk = taosArrayGetP(aBlk, i);
SColumnInfoData* col = taosArrayGet(blk->pDataBlock, pOrigBlockTsOrder->slotId);
sup.aTs[i] = (int64_t*)col->pData;
sup.aRowIdx[i] = 0;
sup.aBlks[i] = blk;
}
SBlockOrderInfo* pOrigBlockTsOrder =
(!pHandle->bSortByRowId) ? taosArrayGet(pHandle->pSortInfo, 0) : taosArrayGet(pHandle->aExtRowsOrders, 0);
SBlockOrderInfo* pHandleBlockTsOrder = taosArrayGet(pHandle->pSortInfo, 0);
SBlockOrderInfo* pOrigBlockPkOrder = NULL;
if (pHandle->bSortPk) {
pOrigBlockPkOrder = (!pHandle->bSortByRowId) ?
taosArrayGet(pHandle->pSortInfo, 1) : taosArrayGet(pHandle->aExtRowsOrders, 1);
pOrigBlockPkOrder =
(!pHandle->bSortByRowId) ? taosArrayGet(pHandle->pSortInfo, 1) : taosArrayGet(pHandle->aExtRowsOrders, 1);
}
sup.pPkOrder = pOrigBlockPkOrder;
int32_t totalRows = 0;
for (int i = 0; i < numBlks; ++i) {
SSDataBlock* blk = taosArrayGetP(aBlk, i);
totalRows += blk->info.rows;
}
initMergeSup(&sup, aBlk, pOrigBlockTsOrder->order, pOrigBlockTsOrder->slotId, pOrigBlockPkOrder);
int32_t totalRows = getTotalRows(aBlk);
SMultiwayMergeTreeInfo* pTree = NULL;
__merge_compare_fn_t mergeCompareFn = (!pHandle->bSortPk) ? blockCompareTsFn : blockCompareTsPkFn;
code = tMergeTreeCreate(&pTree, taosArrayGetSize(aBlk), &sup, mergeCompareFn);
if (TSDB_CODE_SUCCESS != code) {
taosMemoryFree(sup.aRowIdx);
taosMemoryFree(sup.aTs);
taosMemoryFree(sup.aBlks);
cleanupMergeSup(&sup);
return code;
}
@ -1518,15 +1620,15 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray*
int32_t nRows = 0;
int32_t nMergedRows = 0;
bool mergeLimitReached = false;
size_t blkPgSz = pgHeaderSz;
size_t blkPgSz = pageHeaderSize;
int64_t lastPageBufTs = (pHandleBlockTsOrder->order == TSDB_ORDER_ASC) ? INT64_MAX : INT64_MIN;
int64_t currTs = (pHandleBlockTsOrder->order == TSDB_ORDER_ASC) ? INT64_MAX : INT64_MIN;
while (nRows < totalRows) {
int32_t minIdx = tMergeTreeGetChosenIndex(pTree);
SSDataBlock* minBlk = taosArrayGetP(aBlk, minIdx);
int32_t minRow = sup.aRowIdx[minIdx];
SSDataBlock* incBlock = (pHandle->bSortByRowId) ? pHandle->pDataBlock : minBlk;
int32_t bufInc = getPageBufIncForRow(incBlock, minRow, pHandle->pDataBlock->info.rows);
int32_t bufInc = getBufIncForNewRow(pHandle, pHandle->pDataBlock->info.rows, minBlk, minRow);
if (blkPgSz <= pHandle->pageSize && blkPgSz + bufInc > pHandle->pageSize) {
SColumnInfoData* tsCol = taosArrayGet(pHandle->pDataBlock->pDataBlock, pHandleBlockTsOrder->slotId);
@ -1535,16 +1637,15 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray*
if (code != TSDB_CODE_SUCCESS) {
taosMemoryFree(pTree);
taosArrayDestroy(aPgId);
taosMemoryFree(sup.aRowIdx);
taosMemoryFree(sup.aTs);
taosMemoryFree(sup.aBlks);
cleanupMergeSup(&sup);
return code;
}
nMergedRows += pHandle->pDataBlock->info.rows;
blockDataCleanup(pHandle->pDataBlock);
blkPgSz = pgHeaderSz;
incBlock = (pHandle->bSortByRowId) ? pHandle->pDataBlock : minBlk;
bufInc = getPageBufIncForRow(incBlock, minRow, 0);
blkPgSz = pageHeaderSize;
bufInc = getBufIncForNewRow(pHandle, 0, minBlk, minRow);
if ((pHandle->mergeLimit != -1) && (nMergedRows >= pHandle->mergeLimit)) {
mergeLimitReached = true;
@ -1552,16 +1653,20 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray*
(lastPageBufTs > pHandle->currMergeLimitTs && pHandleBlockTsOrder->order == TSDB_ORDER_DESC)) {
pHandle->currMergeLimitTs = lastPageBufTs;
}
break;
}
}
blockDataEnsureCapacity(pHandle->pDataBlock, pHandle->pDataBlock->info.rows + 1);
if (!pHandle->bSortByRowId) {
appendOneRowToDataBlock(pHandle->pDataBlock, minBlk, &minRow);
} else {
if (pHandle->bSortByRowId) {
appendToRowIndexDataBlock(pHandle, minBlk, &minRow);
} else {
appendOneRowToDataBlock(pHandle->pDataBlock, minBlk, &minRow);
}
blkPgSz += bufInc;
ASSERT(blkPgSz == blockDataGetSize(pHandle->pDataBlock) + pageHeaderSize);
++nRows;
@ -1572,6 +1677,7 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray*
}
tMergeTreeAdjust(pTree, tMergeTreeGetAdjustIndex(pTree));
}
if (pHandle->pDataBlock->info.rows > 0) {
if (!mergeLimitReached) {
SColumnInfoData* tsCol = taosArrayGet(pHandle->pDataBlock->pDataBlock, pHandleBlockTsOrder->slotId);
@ -1580,9 +1686,7 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray*
if (code != TSDB_CODE_SUCCESS) {
taosArrayDestroy(aPgId);
taosMemoryFree(pTree);
taosMemoryFree(sup.aRowIdx);
taosMemoryFree(sup.aTs);
taosMemoryFree(sup.aBlks);
cleanupMergeSup(&sup);
return code;
}
nMergedRows += pHandle->pDataBlock->info.rows;
@ -1600,10 +1704,7 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray*
SSDataBlock* pMemSrcBlk = createOneDataBlock(pHandle->pDataBlock, false);
doAddNewExternalMemSource(pHandle->pBuf, aExtSrc, pMemSrcBlk, &pHandle->sourceId, aPgId);
taosMemoryFree(sup.aRowIdx);
taosMemoryFree(sup.aTs);
taosMemoryFree(sup.aBlks);
cleanupMergeSup(&sup);
tMergeTreeDestroy(&pTree);
return 0;
@ -1724,7 +1825,7 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) {
code = sortBlocksToExtSource(pHandle, aBlkSort, aExtSrc);
if (code != TSDB_CODE_SUCCESS) {
for (int i = 0; i < taosArrayGetSize(aBlkSort); ++i) {
for (int32_t i = 0; i < taosArrayGetSize(aBlkSort); ++i) {
blockDataDestroy(taosArrayGetP(aBlkSort, i));
}
taosArrayClear(aBlkSort);
@ -1736,7 +1837,7 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) {
int64_t el = taosGetTimestampUs() - p;
pHandle->sortElapsed += el;
for (int i = 0; i < taosArrayGetSize(aBlkSort); ++i) {
for (int32_t i = 0; i < taosArrayGetSize(aBlkSort); ++i) {
blockDataDestroy(taosArrayGetP(aBlkSort, i));
}
taosArrayClear(aBlkSort);
@ -1750,7 +1851,7 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) {
if (tsortIsClosed(pHandle)) {
tSimpleHashClear(mUidBlk);
for (int i = 0; i < taosArrayGetSize(aBlkSort); ++i) {
for (int32_t i = 0; i < taosArrayGetSize(aBlkSort); ++i) {
blockDataDestroy(taosArrayGetP(aBlkSort, i));
}
taosArrayClear(aBlkSort);
@ -1759,7 +1860,7 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) {
}
tSimpleHashCleanup(mUidBlk);
for (int i = 0; i < taosArrayGetSize(aBlkSort); ++i) {
for (int32_t i = 0; i < taosArrayGetSize(aBlkSort); ++i) {
blockDataDestroy(taosArrayGetP(aBlkSort, i));
}
taosArrayDestroy(aBlkSort);
@ -2048,10 +2149,10 @@ static int32_t tupleComparFn(const void* pLeft, const void* pRight, void* param)
if (!lData) return pOrder->nullFirst ? -1 : 1;
if (!rData) return pOrder->nullFirst ? 1 : -1;
int type = ((SColumnInfoData*)taosArrayGet(pHandle->pDataBlock->pDataBlock, pOrder->slotId))->info.type;
int32_t type = ((SColumnInfoData*)taosArrayGet(pHandle->pDataBlock->pDataBlock, pOrder->slotId))->info.type;
__compar_fn_t fn = getKeyComparFunc(type, pOrder->order);
int ret = fn(lData, rData);
int32_t ret = fn(lData, rData);
if (ret == 0) {
continue;
} else {

View File

@ -677,6 +677,11 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
p += sizeof(uint64_t);
int8_t* fields = p;
if(*fields >= TSDB_DATA_TYPE_MAX || *fields < 0){
uError("fields type error:%d", *fields);
ret = TSDB_CODE_INVALID_PARA;
goto end;
}
p += numOfCols * (sizeof(int8_t) + sizeof(int32_t));
int32_t* colLength = (int32_t*)p;
@ -688,12 +693,12 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
SBoundColInfo* boundInfo = &pTableCxt->boundColsInfo;
if (tFields != NULL && numFields != numOfCols) {
if (errstr != NULL) snprintf(errstr, errstrLen, "numFields:%d != raw numOfCols:%d", numFields, numOfCols);
if (errstr != NULL) snprintf(errstr, errstrLen, "numFields:%d not equal to data cols:%d", numFields, numOfCols);
ret = TSDB_CODE_INVALID_PARA;
goto end;
}
if (tFields != NULL && numFields > boundInfo->numOfBound) {
if (errstr != NULL) snprintf(errstr, errstrLen, "numFields:%d > boundInfo->numOfBound:%d", numFields, boundInfo->numOfBound);
if (errstr != NULL) snprintf(errstr, errstrLen, "numFields:%d bigger than num of bound cols:%d", numFields, boundInfo->numOfBound);
ret = TSDB_CODE_INVALID_PARA;
goto end;
}
@ -702,8 +707,8 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
SSchema* pColSchema = &pSchema[j];
SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, j);
if (*fields != pColSchema->type && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) {
if (errstr != NULL) snprintf(errstr, errstrLen, "type or bytes not equal, id:%d, type:%d, raw type:%d. bytes:%d, raw bytes:%d",
pColSchema->colId, pColSchema->type, *fields, pColSchema->bytes, *(int32_t*)(fields + sizeof(int8_t)));
if (errstr != NULL) snprintf(errstr, errstrLen, "column type or bytes not equal, name:%s, schema type:%s, bytes:%d, data type:%s, bytes:%d",
pColSchema->name, tDataTypes[pColSchema->type].name, pColSchema->bytes, tDataTypes[*fields].name, *(int32_t*)(fields + sizeof(int8_t)));
ret = TSDB_CODE_INVALID_PARA;
goto end;
}
@ -732,8 +737,8 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
SSchema* pColSchema = &pSchema[j];
if (strcmp(pColSchema->name, tFields[i].name) == 0) {
if (*fields != pColSchema->type && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) {
if (errstr != NULL) snprintf(errstr, errstrLen, "type or bytes not equal, id:%d, type:%d, raw type:%d. bytes:%d, raw bytes:%d",
pColSchema->colId, pColSchema->type, *fields, pColSchema->bytes, *(int32_t*)(fields + sizeof(int8_t)));
if (errstr != NULL) snprintf(errstr, errstrLen, "column type or bytes not equal, name:%s, schema type:%s, bytes:%d, data type:%s, bytes:%d",
pColSchema->name, tDataTypes[pColSchema->type].name, pColSchema->bytes, tDataTypes[*fields].name, *(int32_t*)(fields + sizeof(int8_t)));
ret = TSDB_CODE_INVALID_PARA;
goto end;
}

View File

@ -38,6 +38,56 @@ static void getCheckRspStatus(STaskCheckInfo* pInfo, int64_t el, int32_t* numOfR
static int32_t addDownstreamFailedStatusResultAsync(SMsgCb* pMsgCb, int32_t vgId, int64_t streamId, int32_t taskId);
static SDownstreamStatusInfo* findCheckRspStatus(STaskCheckInfo* pInfo, int32_t taskId);
int32_t streamTaskCheckStatus(SStreamTask* pTask, int32_t upstreamTaskId, int32_t vgId, int64_t stage,
int64_t* oldStage) {
SStreamChildEpInfo* pInfo = streamTaskGetUpstreamTaskEpInfo(pTask, upstreamTaskId);
ASSERT(pInfo != NULL);
*oldStage = pInfo->stage;
const char* id = pTask->id.idStr;
if (stage == -1) {
stDebug("s-task:%s receive check msg from upstream task:0x%x(vgId:%d), invalid stageId:%" PRId64 ", not ready", id,
upstreamTaskId, vgId, stage);
return 0;
}
if (pInfo->stage == -1) {
pInfo->stage = stage;
stDebug("s-task:%s receive check msg from upstream task:0x%x(vgId:%d) first time, init stage value:%" PRId64, id,
upstreamTaskId, vgId, stage);
}
if (pInfo->stage < stage) {
stError("s-task:%s receive check msg from upstream task:0x%x(vgId:%d), new stage received:%" PRId64
", prev:%" PRId64,
id, upstreamTaskId, vgId, stage, pInfo->stage);
// record the checkpoint failure id and sent to mnode
taosThreadMutexLock(&pTask->lock);
ETaskStatus status = streamTaskGetStatus(pTask)->state;
if (status == TASK_STATUS__CK) {
streamTaskSetFailedCheckpointId(pTask);
}
taosThreadMutexUnlock(&pTask->lock);
}
if (pInfo->stage != stage) {
taosThreadMutexLock(&pTask->lock);
ETaskStatus status = streamTaskGetStatus(pTask)->state;
if (status == TASK_STATUS__CK) {
streamTaskSetFailedCheckpointId(pTask);
}
taosThreadMutexUnlock(&pTask->lock);
return TASK_UPSTREAM_NEW_STAGE;
} else if (pTask->status.downstreamReady != 1) {
stDebug("s-task:%s vgId:%d leader:%d, downstream not ready", id, vgId, (pTask->pMeta->role == NODE_ROLE_LEADER));
return TASK_DOWNSTREAM_NOT_READY;
} else {
return TASK_DOWNSTREAM_READY;
}
}
// check status
void streamTaskSendCheckMsg(SStreamTask* pTask) {
SDataRange* pRange = &pTask->dataRange;
@ -184,14 +234,7 @@ int32_t streamTaskProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp*
addIntoNodeUpdateList(pTask, pRsp->downstreamNodeId);
}
int32_t startTs = pTask->execInfo.checkTs;
streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, startTs, now, false);
// automatically set the related fill-history task to be failed.
if (HAS_RELATED_FILLHISTORY_TASK(pTask)) {
STaskId* pId = &pTask->hTaskInfo.id;
streamMetaAddTaskLaunchResult(pTask->pMeta, pId->streamId, pId->taskId, startTs, now, false);
}
streamMetaAddFailedTaskSelf(pTask, now);
} else { // TASK_DOWNSTREAM_NOT_READY, rsp-check monitor will retry in 300 ms
ASSERT(left > 0);
stDebug("s-task:%s (vgId:%d) recv check rsp from task:0x%x (vgId:%d) status:%d, total:%d not ready:%d", id,
@ -720,60 +763,3 @@ void rspMonitorFn(void* param, void* tmrId) {
taosArrayDestroy(pTimeoutList);
}
int32_t tEncodeStreamTaskCheckReq(SEncoder* pEncoder, const SStreamTaskCheckReq* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->reqId) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->downstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->downstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->childId) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->stage) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamTaskCheckReq(SDecoder* pDecoder, SStreamTaskCheckReq* pReq) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->reqId) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->upstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->upstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->downstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->downstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->childId) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->stage) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}
int32_t tEncodeStreamTaskCheckRsp(SEncoder* pEncoder, const SStreamTaskCheckRsp* pRsp) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pRsp->reqId) < 0) return -1;
if (tEncodeI64(pEncoder, pRsp->streamId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->upstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->upstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->downstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->downstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->childId) < 0) return -1;
if (tEncodeI64(pEncoder, pRsp->oldStage) < 0) return -1;
if (tEncodeI8(pEncoder, pRsp->status) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamTaskCheckRsp(SDecoder* pDecoder, SStreamTaskCheckRsp* pRsp) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pRsp->reqId) < 0) return -1;
if (tDecodeI64(pDecoder, &pRsp->streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->upstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->upstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->downstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->downstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->childId) < 0) return -1;
if (tDecodeI64(pDecoder, &pRsp->oldStage) < 0) return -1;
if (tDecodeI8(pDecoder, &pRsp->status) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}

View File

@ -34,92 +34,6 @@ static int32_t streamTaskBackupCheckpoint(const char* id, const char* path);
static int32_t deleteCheckpoint(const char* id);
static int32_t downloadCheckpointByNameS3(const char* id, const char* fname, const char* dstName);
int32_t tEncodeStreamCheckpointSourceReq(SEncoder* pEncoder, const SStreamCheckpointSourceReq* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->checkpointId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->nodeId) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pReq->mgmtEps) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->mnodeId) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->expireTime) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->transId) < 0) return -1;
if (tEncodeI8(pEncoder, pReq->mndTrigger) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamCheckpointSourceReq(SDecoder* pDecoder, SStreamCheckpointSourceReq* pReq) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->checkpointId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->nodeId) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &pReq->mgmtEps) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->mnodeId) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->expireTime) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->transId) < 0) return -1;
if (tDecodeI8(pDecoder, &pReq->mndTrigger) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}
int32_t tEncodeStreamCheckpointSourceRsp(SEncoder* pEncoder, const SStreamCheckpointSourceRsp* pRsp) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pRsp->streamId) < 0) return -1;
if (tEncodeI64(pEncoder, pRsp->checkpointId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->nodeId) < 0) return -1;
if (tEncodeI64(pEncoder, pRsp->expireTime) < 0) return -1;
if (tEncodeI8(pEncoder, pRsp->success) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tEncodeStreamCheckpointReadyMsg(SEncoder* pEncoder, const SStreamCheckpointReadyMsg* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->checkpointId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->downstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->downstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->childId) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamCheckpointReadyMsg(SDecoder* pDecoder, SStreamCheckpointReadyMsg* pRsp) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pRsp->streamId) < 0) return -1;
if (tDecodeI64(pDecoder, &pRsp->checkpointId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->downstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->downstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->upstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->upstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->childId) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}
int32_t tEncodeStreamTaskCheckpointReq(SEncoder* pEncoder, const SStreamTaskCheckpointReq* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->nodeId) < 0) return -1;
tEndEncode(pEncoder);
return 0;
}
int32_t tDecodeStreamTaskCheckpointReq(SDecoder* pDecoder, SStreamTaskCheckpointReq* pReq) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->nodeId) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}
static int32_t streamAlignCheckpoint(SStreamTask* pTask) {
int32_t num = taosArrayGetSize(pTask->upstreamInfo.pList);
int64_t old = atomic_val_compare_exchange_32(&pTask->chkInfo.downstreamAlignNum, 0, num);

View File

@ -43,67 +43,6 @@ void initRpcMsg(SRpcMsg* pMsg, int32_t msgType, void* pCont, int32_t contLen) {
pMsg->contLen = contLen;
}
int32_t tEncodeStreamDispatchReq(SEncoder* pEncoder, const SStreamDispatchReq* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->stage) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->msgId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->srcVgId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->type) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->type) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamChildId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamRelTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->blockNum) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->totalLen) < 0) return -1;
ASSERT(taosArrayGetSize(pReq->data) == pReq->blockNum);
ASSERT(taosArrayGetSize(pReq->dataLen) == pReq->blockNum);
for (int32_t i = 0; i < pReq->blockNum; i++) {
int32_t len = *(int32_t*)taosArrayGet(pReq->dataLen, i);
void* data = taosArrayGetP(pReq->data, i);
if (tEncodeI32(pEncoder, len) < 0) return -1;
if (tEncodeBinary(pEncoder, data, len) < 0) return -1;
}
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->stage) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->msgId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->srcVgId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->type) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->type) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->upstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->upstreamChildId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->upstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->upstreamRelTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->blockNum) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->totalLen) < 0) return -1;
ASSERT(pReq->blockNum > 0);
pReq->data = taosArrayInit(pReq->blockNum, sizeof(void*));
pReq->dataLen = taosArrayInit(pReq->blockNum, sizeof(int32_t));
for (int32_t i = 0; i < pReq->blockNum; i++) {
int32_t len1;
uint64_t len2;
void* data;
if (tDecodeI32(pDecoder, &len1) < 0) return -1;
if (tDecodeBinaryAlloc(pDecoder, &data, &len2) < 0) return -1;
ASSERT(len1 == len2);
taosArrayPush(pReq->dataLen, &len1);
taosArrayPush(pReq->data, &data);
}
tEndDecode(pDecoder);
return 0;
}
static int32_t tInitStreamDispatchReq(SStreamDispatchReq* pReq, const SStreamTask* pTask, int32_t vgId,
int32_t numOfBlocks, int64_t dstTaskId, int32_t type) {
pReq->streamId = pTask->id.streamId;
@ -129,41 +68,6 @@ static int32_t tInitStreamDispatchReq(SStreamDispatchReq* pReq, const SStreamTas
return TSDB_CODE_SUCCESS;
}
void tCleanupStreamDispatchReq(SStreamDispatchReq* pReq) {
taosArrayDestroyP(pReq->data, taosMemoryFree);
taosArrayDestroy(pReq->dataLen);
}
int32_t tEncodeStreamRetrieveReq(SEncoder* pEncoder, const SStreamRetrieveReq* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->reqId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->dstNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->dstTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->srcNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->srcTaskId) < 0) return -1;
if (tEncodeBinary(pEncoder, (const uint8_t*)pReq->pRetrieve, pReq->retrieveLen) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->reqId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->dstNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->dstTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->srcNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->srcTaskId) < 0) return -1;
uint64_t len = 0;
if (tDecodeBinaryAlloc(pDecoder, (void**)&pReq->pRetrieve, &len) < 0) return -1;
pReq->retrieveLen = (int32_t)len;
tEndDecode(pDecoder);
return 0;
}
void tCleanupStreamRetrieveReq(SStreamRetrieveReq* pReq) { taosMemoryFree(pReq->pRetrieve); }
void streamTaskSendRetrieveRsp(SStreamRetrieveReq *pReq, SRpcMsg* pRsp){
void* buf = rpcMallocCont(sizeof(SMsgHead) + sizeof(SStreamRetrieveRsp));
((SMsgHead*)buf)->vgId = htonl(pReq->srcNodeId);
@ -1262,45 +1166,3 @@ int32_t streamProcessDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pReq, S
return 0;
}
int32_t tEncodeStreamTaskUpdateMsg(SEncoder* pEncoder, const SStreamTaskNodeUpdateMsg* pMsg) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pMsg->streamId) < 0) return -1;
if (tEncodeI32(pEncoder, pMsg->taskId) < 0) return -1;
int32_t size = taosArrayGetSize(pMsg->pNodeList);
if (tEncodeI32(pEncoder, size) < 0) return -1;
for (int32_t i = 0; i < size; ++i) {
SNodeUpdateInfo* pInfo = taosArrayGet(pMsg->pNodeList, i);
if (tEncodeI32(pEncoder, pInfo->nodeId) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pInfo->prevEp) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pInfo->newEp) < 0) return -1;
}
// todo this new attribute will be result in being incompatible with previous version
if (tEncodeI32(pEncoder, pMsg->transId) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamTaskUpdateMsg(SDecoder* pDecoder, SStreamTaskNodeUpdateMsg* pMsg) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pMsg->streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &pMsg->taskId) < 0) return -1;
int32_t size = 0;
if (tDecodeI32(pDecoder, &size) < 0) return -1;
pMsg->pNodeList = taosArrayInit(size, sizeof(SNodeUpdateInfo));
for (int32_t i = 0; i < size; ++i) {
SNodeUpdateInfo info = {0};
if (tDecodeI32(pDecoder, &info.nodeId) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &info.prevEp) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &info.newEp) < 0) return -1;
taosArrayPush(pMsg->pNodeList, &info);
}
if (tDecodeI32(pDecoder, &pMsg->transId) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}

View File

@ -944,102 +944,6 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) {
taosArrayDestroy(pRecycleList);
}
int32_t tEncodeStreamHbMsg(SEncoder* pEncoder, const SStreamHbMsg* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->vgId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->numOfTasks) < 0) return -1;
for (int32_t i = 0; i < pReq->numOfTasks; ++i) {
STaskStatusEntry* ps = taosArrayGet(pReq->pTaskStatus, i);
if (tEncodeI64(pEncoder, ps->id.streamId) < 0) return -1;
if (tEncodeI32(pEncoder, ps->id.taskId) < 0) return -1;
if (tEncodeI32(pEncoder, ps->status) < 0) return -1;
if (tEncodeI64(pEncoder, ps->stage) < 0) return -1;
if (tEncodeI32(pEncoder, ps->nodeId) < 0) return -1;
if (tEncodeDouble(pEncoder, ps->inputQUsed) < 0) return -1;
if (tEncodeDouble(pEncoder, ps->inputRate) < 0) return -1;
if (tEncodeDouble(pEncoder, ps->sinkQuota) < 0) return -1;
if (tEncodeDouble(pEncoder, ps->sinkDataSize) < 0) return -1;
if (tEncodeI64(pEncoder, ps->processedVer) < 0) return -1;
if (tEncodeI64(pEncoder, ps->verRange.minVer) < 0) return -1;
if (tEncodeI64(pEncoder, ps->verRange.maxVer) < 0) return -1;
if (tEncodeI64(pEncoder, ps->checkpointInfo.activeId) < 0) return -1;
if (tEncodeI8(pEncoder, ps->checkpointInfo.failed) < 0) return -1;
if (tEncodeI32(pEncoder, ps->checkpointInfo.activeTransId) < 0) return -1;
if (tEncodeI64(pEncoder, ps->checkpointInfo.latestId) < 0) return -1;
if (tEncodeI64(pEncoder, ps->checkpointInfo.latestVer) < 0) return -1;
if (tEncodeI64(pEncoder, ps->checkpointInfo.latestTime) < 0) return -1;
if (tEncodeI64(pEncoder, ps->startTime) < 0) return -1;
if (tEncodeI64(pEncoder, ps->startCheckpointId) < 0) return -1;
if (tEncodeI64(pEncoder, ps->startCheckpointVer) < 0) return -1;
if (tEncodeI64(pEncoder, ps->hTaskId) < 0) return -1;
}
int32_t numOfVgs = taosArrayGetSize(pReq->pUpdateNodes);
if (tEncodeI32(pEncoder, numOfVgs) < 0) return -1;
for (int j = 0; j < numOfVgs; ++j) {
int32_t* pVgId = taosArrayGet(pReq->pUpdateNodes, j);
if (tEncodeI32(pEncoder, *pVgId) < 0) return -1;
}
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamHbMsg(SDecoder* pDecoder, SStreamHbMsg* pReq) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->vgId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->numOfTasks) < 0) return -1;
pReq->pTaskStatus = taosArrayInit(pReq->numOfTasks, sizeof(STaskStatusEntry));
for (int32_t i = 0; i < pReq->numOfTasks; ++i) {
int32_t taskId = 0;
STaskStatusEntry entry = {0};
if (tDecodeI64(pDecoder, &entry.id.streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &entry.status) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.stage) < 0) return -1;
if (tDecodeI32(pDecoder, &entry.nodeId) < 0) return -1;
if (tDecodeDouble(pDecoder, &entry.inputQUsed) < 0) return -1;
if (tDecodeDouble(pDecoder, &entry.inputRate) < 0) return -1;
if (tDecodeDouble(pDecoder, &entry.sinkQuota) < 0) return -1;
if (tDecodeDouble(pDecoder, &entry.sinkDataSize) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.processedVer) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.verRange.minVer) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.verRange.maxVer) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.checkpointInfo.activeId) < 0) return -1;
if (tDecodeI8(pDecoder, &entry.checkpointInfo.failed) < 0) return -1;
if (tDecodeI32(pDecoder, &entry.checkpointInfo.activeTransId) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.checkpointInfo.latestId) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.checkpointInfo.latestVer) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.checkpointInfo.latestTime) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.startTime) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.startCheckpointId) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.startCheckpointVer) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.hTaskId) < 0) return -1;
entry.id.taskId = taskId;
taosArrayPush(pReq->pTaskStatus, &entry);
}
int32_t numOfVgs = 0;
if (tDecodeI32(pDecoder, &numOfVgs) < 0) return -1;
pReq->pUpdateNodes = taosArrayInit(numOfVgs, sizeof(int32_t));
for (int j = 0; j < numOfVgs; ++j) {
int32_t vgId = 0;
if (tDecodeI32(pDecoder, &vgId) < 0) return -1;
taosArrayPush(pReq->pUpdateNodes, &vgId);
}
tEndDecode(pDecoder);
return 0;
}
static bool waitForEnoughDuration(SMetaHbInfo* pInfo) {
if ((++pInfo->tickCounter) >= META_HB_SEND_IDLE_COUNTER) { // reset the counter
pInfo->tickCounter = 0;
@ -1048,20 +952,6 @@ static bool waitForEnoughDuration(SMetaHbInfo* pInfo) {
return false;
}
void tCleanupStreamHbMsg(SStreamHbMsg* pMsg) {
if (pMsg == NULL) {
return;
}
if (pMsg->pUpdateNodes != NULL) {
taosArrayDestroy(pMsg->pUpdateNodes);
}
if (pMsg->pTaskStatus != NULL) {
taosArrayDestroy(pMsg->pTaskStatus);
}
}
static bool existInHbMsg(SStreamHbMsg* pMsg, SDownstreamTaskEpset* pTaskEpset) {
int32_t numOfExisted = taosArrayGetSize(pMsg->pUpdateNodes);
for (int k = 0; k < numOfExisted; ++k) {
@ -1491,12 +1381,11 @@ int32_t streamMetaStartAllTasks(SStreamMeta* pMeta) {
for (int32_t i = 0; i < numOfTasks; ++i) {
SStreamTaskId* pTaskId = taosArrayGet(pTaskList, i);
// todo: may be we should find the related fill-history task and set it failed.
// todo: use hashTable instead
SStreamTask* pTask = streamMetaAcquireTask(pMeta, pTaskId->streamId, pTaskId->taskId);
if (pTask == NULL) {
stError("vgId:%d failed to acquire task:0x%x during start tasks", pMeta->vgId, pTaskId->taskId);
streamMetaAddTaskLaunchResult(pMeta, pTaskId->streamId, pTaskId->taskId, 0, now, false);
streamMetaAddFailedTask(pMeta, pTaskId->streamId, pTaskId->taskId);
continue;
}
@ -1524,12 +1413,7 @@ int32_t streamMetaStartAllTasks(SStreamMeta* pMeta) {
if (ret != TSDB_CODE_SUCCESS) {
stError("vgId:%d failed to handle event:%d", pMeta->vgId, TASK_EVENT_INIT);
code = ret;
streamMetaAddTaskLaunchResult(pMeta, pTaskId->streamId, pTaskId->taskId, pInfo->checkTs, pInfo->readyTs, false);
if (HAS_RELATED_FILLHISTORY_TASK(pTask)) {
STaskId* pId = &pTask->hTaskInfo.id;
streamMetaAddTaskLaunchResult(pMeta, pId->streamId, pId->taskId, pInfo->checkTs, pInfo->readyTs, false);
}
streamMetaAddFailedTaskSelf(pTask, pInfo->readyTs);
}
streamMetaReleaseTask(pMeta, pTask);
@ -1601,12 +1485,10 @@ int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t tas
SStreamTask* pTask = streamMetaAcquireTask(pMeta, streamId, taskId);
if (pTask == NULL) {
stError("vgId:%d failed to acquire task:0x%x during start tasks", pMeta->vgId, taskId);
streamMetaAddTaskLaunchResult(pMeta, streamId, taskId, 0, taosGetTimestampMs(), false);
streamMetaAddFailedTask(pMeta, streamId, taskId);
return TSDB_CODE_STREAM_TASK_IVLD_STATUS;
}
// todo: may be we should find the related fill-history task and set it failed.
// fill-history task can only be launched by related stream tasks.
STaskExecStatisInfo* pInfo = &pTask->execInfo;
if (pTask->info.fillHistory == 1) {
@ -1618,13 +1500,8 @@ int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t tas
int32_t ret = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_INIT);
if (ret != TSDB_CODE_SUCCESS) {
stError("vgId:%d failed to handle event:%d", pMeta->vgId, TASK_EVENT_INIT);
streamMetaAddTaskLaunchResult(pMeta, streamId, taskId, pInfo->checkTs, pInfo->readyTs, false);
if (HAS_RELATED_FILLHISTORY_TASK(pTask)) {
STaskId* pId = &pTask->hTaskInfo.id;
streamMetaAddTaskLaunchResult(pMeta, pId->streamId, pId->taskId, pInfo->checkTs, pInfo->readyTs, false);
}
stError("s-task:%s vgId:%d failed to handle event:%d", pTask->id.idStr, pMeta->vgId, TASK_EVENT_INIT);
streamMetaAddFailedTaskSelf(pTask, pInfo->readyTs);
}
streamMetaReleaseTask(pMeta, pTask);
@ -1734,7 +1611,7 @@ int32_t streamMetaAddFailedTask(SStreamMeta* pMeta, int64_t streamId, int32_t ta
bool hasFillhistoryTask = false;
STaskId hId = {0};
stDebug("vgId:%d add failed task:0x%x", pMeta->vgId, taskId);
stDebug("vgId:%d add start failed task:0x%x", pMeta->vgId, taskId);
streamMetaRLock(pMeta);
@ -1762,6 +1639,17 @@ int32_t streamMetaAddFailedTask(SStreamMeta* pMeta, int64_t streamId, int32_t ta
return code;
}
void streamMetaAddFailedTaskSelf(SStreamTask* pTask, int64_t failedTs) {
int32_t startTs = pTask->execInfo.checkTs;
streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, startTs, failedTs, false);
// automatically set the related fill-history task to be failed.
if (HAS_RELATED_FILLHISTORY_TASK(pTask)) {
STaskId* pId = &pTask->hTaskInfo.id;
streamMetaAddTaskLaunchResult(pTask->pMeta, pId->streamId, pId->taskId, startTs, failedTs, false);
}
}
void streamMetaAddIntoUpdateTaskList(SStreamMeta* pMeta, SStreamTask* pTask, SStreamTask* pHTask, int32_t transId,
int64_t startTs) {
const char* id = pTask->id.idStr;

View File

@ -130,56 +130,6 @@ int32_t streamTaskStartScanHistory(SStreamTask* pTask) {
return 0;
}
int32_t streamTaskCheckStatus(SStreamTask* pTask, int32_t upstreamTaskId, int32_t vgId, int64_t stage,
int64_t* oldStage) {
SStreamChildEpInfo* pInfo = streamTaskGetUpstreamTaskEpInfo(pTask, upstreamTaskId);
ASSERT(pInfo != NULL);
*oldStage = pInfo->stage;
const char* id = pTask->id.idStr;
if (stage == -1) {
stDebug("s-task:%s receive check msg from upstream task:0x%x(vgId:%d), invalid stageId:%" PRId64 ", not ready", id,
upstreamTaskId, vgId, stage);
return 0;
}
if (pInfo->stage == -1) {
pInfo->stage = stage;
stDebug("s-task:%s receive check msg from upstream task:0x%x(vgId:%d) first time, init stage value:%" PRId64, id,
upstreamTaskId, vgId, stage);
}
if (pInfo->stage < stage) {
stError("s-task:%s receive check msg from upstream task:0x%x(vgId:%d), new stage received:%" PRId64
", prev:%" PRId64,
id, upstreamTaskId, vgId, stage, pInfo->stage);
// record the checkpoint failure id and sent to mnode
taosThreadMutexLock(&pTask->lock);
ETaskStatus status = streamTaskGetStatus(pTask)->state;
if (status == TASK_STATUS__CK) {
streamTaskSetFailedCheckpointId(pTask);
}
taosThreadMutexUnlock(&pTask->lock);
}
if (pInfo->stage != stage) {
taosThreadMutexLock(&pTask->lock);
ETaskStatus status = streamTaskGetStatus(pTask)->state;
if (status == TASK_STATUS__CK) {
streamTaskSetFailedCheckpointId(pTask);
}
taosThreadMutexUnlock(&pTask->lock);
return TASK_UPSTREAM_NEW_STAGE;
} else if (pTask->status.downstreamReady != 1) {
stDebug("s-task:%s vgId:%d leader:%d, downstream not ready", id, vgId, (pTask->pMeta->role == NODE_ROLE_LEADER));
return TASK_DOWNSTREAM_NOT_READY;
} else {
return TASK_DOWNSTREAM_READY;
}
}
int32_t streamTaskOnNormalTaskReady(SStreamTask* pTask) {
const char* id = pTask->id.idStr;

View File

@ -137,179 +137,6 @@ SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, SEpSet* pEpset,
return pTask;
}
int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo) {
if (tEncodeI32(pEncoder, pInfo->taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pInfo->nodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pInfo->childId) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pInfo->epSet) < 0) return -1;
if (tEncodeI64(pEncoder, pInfo->stage) < 0) return -1;
return 0;
}
int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo) {
if (tDecodeI32(pDecoder, &pInfo->taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pInfo->nodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pInfo->childId) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &pInfo->epSet) < 0) return -1;
if (tDecodeI64(pDecoder, &pInfo->stage) < 0) return -1;
return 0;
}
int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pTask->ver) < 0) return -1;
if (tEncodeI64(pEncoder, pTask->id.streamId) < 0) return -1;
if (tEncodeI32(pEncoder, pTask->id.taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pTask->info.totalLevel) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->info.taskLevel) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->outputInfo.type) < 0) return -1;
if (tEncodeI16(pEncoder, pTask->msgInfo.msgType) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->status.taskStatus) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->status.schedStatus) < 0) return -1;
if (tEncodeI32(pEncoder, pTask->info.selfChildId) < 0) return -1;
if (tEncodeI32(pEncoder, pTask->info.nodeId) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pTask->info.epSet) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pTask->info.mnodeEpset) < 0) return -1;
if (tEncodeI64(pEncoder, pTask->chkInfo.checkpointId) < 0) return -1;
if (tEncodeI64(pEncoder, pTask->chkInfo.checkpointVer) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->info.fillHistory) < 0) return -1;
if (tEncodeI64(pEncoder, pTask->hTaskInfo.id.streamId)) return -1;
int32_t taskId = pTask->hTaskInfo.id.taskId;
if (tEncodeI32(pEncoder, taskId)) return -1;
if (tEncodeI64(pEncoder, pTask->streamTaskId.streamId)) return -1;
taskId = pTask->streamTaskId.taskId;
if (tEncodeI32(pEncoder, taskId)) return -1;
if (tEncodeU64(pEncoder, pTask->dataRange.range.minVer)) return -1;
if (tEncodeU64(pEncoder, pTask->dataRange.range.maxVer)) return -1;
if (tEncodeI64(pEncoder, pTask->dataRange.window.skey)) return -1;
if (tEncodeI64(pEncoder, pTask->dataRange.window.ekey)) return -1;
int32_t epSz = taosArrayGetSize(pTask->upstreamInfo.pList);
if (tEncodeI32(pEncoder, epSz) < 0) return -1;
for (int32_t i = 0; i < epSz; i++) {
SStreamChildEpInfo* pInfo = taosArrayGetP(pTask->upstreamInfo.pList, i);
if (tEncodeStreamEpInfo(pEncoder, pInfo) < 0) return -1;
}
if (pTask->info.taskLevel != TASK_LEVEL__SINK) {
if (tEncodeCStr(pEncoder, pTask->exec.qmsg) < 0) return -1;
}
if (pTask->outputInfo.type == TASK_OUTPUT__TABLE) {
if (tEncodeI64(pEncoder, pTask->outputInfo.tbSink.stbUid) < 0) return -1;
if (tEncodeCStr(pEncoder, pTask->outputInfo.tbSink.stbFullName) < 0) return -1;
if (tEncodeSSchemaWrapper(pEncoder, pTask->outputInfo.tbSink.pSchemaWrapper) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__SMA) {
if (tEncodeI64(pEncoder, pTask->outputInfo.smaSink.smaId) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__FETCH) {
if (tEncodeI8(pEncoder, pTask->outputInfo.fetchSink.reserved) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
if (tEncodeI32(pEncoder, pTask->outputInfo.fixedDispatcher.taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pTask->outputInfo.fixedDispatcher.nodeId) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pTask->outputInfo.fixedDispatcher.epSet) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
if (tSerializeSUseDbRspImp(pEncoder, &pTask->outputInfo.shuffleDispatcher.dbInfo) < 0) return -1;
if (tEncodeCStr(pEncoder, pTask->outputInfo.shuffleDispatcher.stbFullName) < 0) return -1;
}
if (tEncodeI64(pEncoder, pTask->info.triggerParam) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->subtableWithoutMd5) < 0) return -1;
if (tEncodeCStrWithLen(pEncoder, pTask->reserve, sizeof(pTask->reserve) - 1) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
int32_t taskId = 0;
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pTask->ver) < 0) return -1;
if (pTask->ver <= SSTREAM_TASK_INCOMPATIBLE_VER || pTask->ver > SSTREAM_TASK_VER) return -1;
if (tDecodeI64(pDecoder, &pTask->id.streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &pTask->id.taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pTask->info.totalLevel) < 0) return -1;
if (tDecodeI8(pDecoder, &pTask->info.taskLevel) < 0) return -1;
if (tDecodeI8(pDecoder, &pTask->outputInfo.type) < 0) return -1;
if (tDecodeI16(pDecoder, &pTask->msgInfo.msgType) < 0) return -1;
if (tDecodeI8(pDecoder, &pTask->status.taskStatus) < 0) return -1;
if (tDecodeI8(pDecoder, &pTask->status.schedStatus) < 0) return -1;
if (tDecodeI32(pDecoder, &pTask->info.selfChildId) < 0) return -1;
if (tDecodeI32(pDecoder, &pTask->info.nodeId) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &pTask->info.epSet) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &pTask->info.mnodeEpset) < 0) return -1;
if (tDecodeI64(pDecoder, &pTask->chkInfo.checkpointId) < 0) return -1;
if (tDecodeI64(pDecoder, &pTask->chkInfo.checkpointVer) < 0) return -1;
if (tDecodeI8(pDecoder, &pTask->info.fillHistory) < 0) return -1;
if (tDecodeI64(pDecoder, &pTask->hTaskInfo.id.streamId)) return -1;
if (tDecodeI32(pDecoder, &taskId)) return -1;
pTask->hTaskInfo.id.taskId = taskId;
if (tDecodeI64(pDecoder, &pTask->streamTaskId.streamId)) return -1;
if (tDecodeI32(pDecoder, &taskId)) return -1;
pTask->streamTaskId.taskId = taskId;
if (tDecodeU64(pDecoder, (uint64_t*)&pTask->dataRange.range.minVer)) return -1;
if (tDecodeU64(pDecoder, (uint64_t*)&pTask->dataRange.range.maxVer)) return -1;
if (tDecodeI64(pDecoder, &pTask->dataRange.window.skey)) return -1;
if (tDecodeI64(pDecoder, &pTask->dataRange.window.ekey)) return -1;
int32_t epSz = -1;
if (tDecodeI32(pDecoder, &epSz) < 0) return -1;
pTask->upstreamInfo.pList = taosArrayInit(epSz, POINTER_BYTES);
for (int32_t i = 0; i < epSz; i++) {
SStreamChildEpInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamChildEpInfo));
if (pInfo == NULL) return -1;
if (tDecodeStreamEpInfo(pDecoder, pInfo) < 0) {
taosMemoryFreeClear(pInfo);
return -1;
}
taosArrayPush(pTask->upstreamInfo.pList, &pInfo);
}
if (pTask->info.taskLevel != TASK_LEVEL__SINK) {
if (tDecodeCStrAlloc(pDecoder, &pTask->exec.qmsg) < 0) return -1;
}
if (pTask->outputInfo.type == TASK_OUTPUT__TABLE) {
if (tDecodeI64(pDecoder, &pTask->outputInfo.tbSink.stbUid) < 0) return -1;
if (tDecodeCStrTo(pDecoder, pTask->outputInfo.tbSink.stbFullName) < 0) return -1;
pTask->outputInfo.tbSink.pSchemaWrapper = taosMemoryCalloc(1, sizeof(SSchemaWrapper));
if (pTask->outputInfo.tbSink.pSchemaWrapper == NULL) return -1;
if (tDecodeSSchemaWrapper(pDecoder, pTask->outputInfo.tbSink.pSchemaWrapper) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__SMA) {
if (tDecodeI64(pDecoder, &pTask->outputInfo.smaSink.smaId) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__FETCH) {
if (tDecodeI8(pDecoder, &pTask->outputInfo.fetchSink.reserved) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
if (tDecodeI32(pDecoder, &pTask->outputInfo.fixedDispatcher.taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pTask->outputInfo.fixedDispatcher.nodeId) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &pTask->outputInfo.fixedDispatcher.epSet) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
if (tDeserializeSUseDbRspImp(pDecoder, &pTask->outputInfo.shuffleDispatcher.dbInfo) < 0) return -1;
if (tDecodeCStrTo(pDecoder, pTask->outputInfo.shuffleDispatcher.stbFullName) < 0) return -1;
}
if (tDecodeI64(pDecoder, &pTask->info.triggerParam) < 0) return -1;
if (pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER){
if (tDecodeI8(pDecoder, &pTask->subtableWithoutMd5) < 0) return -1;
}
if (tDecodeCStrTo(pDecoder, pTask->reserve) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}
int32_t tDecodeStreamTaskChkInfo(SDecoder* pDecoder, SCheckpointInfo* pChkpInfo) {
int64_t skip64;
int8_t skip8;

View File

@ -0,0 +1,587 @@
/*
* 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 "os.h"
#include "streammsg.h"
#include "tstream.h"
int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo) {
if (tEncodeI32(pEncoder, pInfo->taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pInfo->nodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pInfo->childId) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pInfo->epSet) < 0) return -1;
if (tEncodeI64(pEncoder, pInfo->stage) < 0) return -1;
return 0;
}
int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo) {
if (tDecodeI32(pDecoder, &pInfo->taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pInfo->nodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pInfo->childId) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &pInfo->epSet) < 0) return -1;
if (tDecodeI64(pDecoder, &pInfo->stage) < 0) return -1;
return 0;
}
int32_t tEncodeStreamCheckpointSourceReq(SEncoder* pEncoder, const SStreamCheckpointSourceReq* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->checkpointId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->nodeId) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pReq->mgmtEps) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->mnodeId) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->expireTime) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->transId) < 0) return -1;
if (tEncodeI8(pEncoder, pReq->mndTrigger) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamCheckpointSourceReq(SDecoder* pDecoder, SStreamCheckpointSourceReq* pReq) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->checkpointId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->nodeId) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &pReq->mgmtEps) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->mnodeId) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->expireTime) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->transId) < 0) return -1;
if (tDecodeI8(pDecoder, &pReq->mndTrigger) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}
int32_t tEncodeStreamCheckpointSourceRsp(SEncoder* pEncoder, const SStreamCheckpointSourceRsp* pRsp) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pRsp->streamId) < 0) return -1;
if (tEncodeI64(pEncoder, pRsp->checkpointId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->nodeId) < 0) return -1;
if (tEncodeI64(pEncoder, pRsp->expireTime) < 0) return -1;
if (tEncodeI8(pEncoder, pRsp->success) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tEncodeStreamTaskUpdateMsg(SEncoder* pEncoder, const SStreamTaskNodeUpdateMsg* pMsg) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pMsg->streamId) < 0) return -1;
if (tEncodeI32(pEncoder, pMsg->taskId) < 0) return -1;
int32_t size = taosArrayGetSize(pMsg->pNodeList);
if (tEncodeI32(pEncoder, size) < 0) return -1;
for (int32_t i = 0; i < size; ++i) {
SNodeUpdateInfo* pInfo = taosArrayGet(pMsg->pNodeList, i);
if (tEncodeI32(pEncoder, pInfo->nodeId) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pInfo->prevEp) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pInfo->newEp) < 0) return -1;
}
// todo this new attribute will be result in being incompatible with previous version
if (tEncodeI32(pEncoder, pMsg->transId) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamTaskUpdateMsg(SDecoder* pDecoder, SStreamTaskNodeUpdateMsg* pMsg) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pMsg->streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &pMsg->taskId) < 0) return -1;
int32_t size = 0;
if (tDecodeI32(pDecoder, &size) < 0) return -1;
pMsg->pNodeList = taosArrayInit(size, sizeof(SNodeUpdateInfo));
for (int32_t i = 0; i < size; ++i) {
SNodeUpdateInfo info = {0};
if (tDecodeI32(pDecoder, &info.nodeId) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &info.prevEp) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &info.newEp) < 0) return -1;
taosArrayPush(pMsg->pNodeList, &info);
}
if (tDecodeI32(pDecoder, &pMsg->transId) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}
int32_t tEncodeStreamTaskCheckReq(SEncoder* pEncoder, const SStreamTaskCheckReq* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->reqId) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->downstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->downstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->childId) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->stage) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamTaskCheckReq(SDecoder* pDecoder, SStreamTaskCheckReq* pReq) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->reqId) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->upstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->upstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->downstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->downstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->childId) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->stage) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}
int32_t tEncodeStreamTaskCheckRsp(SEncoder* pEncoder, const SStreamTaskCheckRsp* pRsp) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pRsp->reqId) < 0) return -1;
if (tEncodeI64(pEncoder, pRsp->streamId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->upstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->upstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->downstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->downstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->childId) < 0) return -1;
if (tEncodeI64(pEncoder, pRsp->oldStage) < 0) return -1;
if (tEncodeI8(pEncoder, pRsp->status) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamTaskCheckRsp(SDecoder* pDecoder, SStreamTaskCheckRsp* pRsp) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pRsp->reqId) < 0) return -1;
if (tDecodeI64(pDecoder, &pRsp->streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->upstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->upstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->downstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->downstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->childId) < 0) return -1;
if (tDecodeI64(pDecoder, &pRsp->oldStage) < 0) return -1;
if (tDecodeI8(pDecoder, &pRsp->status) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}
int32_t tEncodeStreamCheckpointReadyMsg(SEncoder* pEncoder, const SStreamCheckpointReadyMsg* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->checkpointId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->downstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->downstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->childId) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamCheckpointReadyMsg(SDecoder* pDecoder, SStreamCheckpointReadyMsg* pRsp) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pRsp->streamId) < 0) return -1;
if (tDecodeI64(pDecoder, &pRsp->checkpointId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->downstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->downstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->upstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->upstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->childId) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}
int32_t tEncodeStreamDispatchReq(SEncoder* pEncoder, const SStreamDispatchReq* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->stage) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->msgId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->srcVgId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->type) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->type) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamChildId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->upstreamRelTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->blockNum) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->totalLen) < 0) return -1;
ASSERT(taosArrayGetSize(pReq->data) == pReq->blockNum);
ASSERT(taosArrayGetSize(pReq->dataLen) == pReq->blockNum);
for (int32_t i = 0; i < pReq->blockNum; i++) {
int32_t len = *(int32_t*)taosArrayGet(pReq->dataLen, i);
void* data = taosArrayGetP(pReq->data, i);
if (tEncodeI32(pEncoder, len) < 0) return -1;
if (tEncodeBinary(pEncoder, data, len) < 0) return -1;
}
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->stage) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->msgId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->srcVgId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->type) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->type) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->upstreamTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->upstreamChildId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->upstreamNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->upstreamRelTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->blockNum) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->totalLen) < 0) return -1;
ASSERT(pReq->blockNum > 0);
pReq->data = taosArrayInit(pReq->blockNum, sizeof(void*));
pReq->dataLen = taosArrayInit(pReq->blockNum, sizeof(int32_t));
for (int32_t i = 0; i < pReq->blockNum; i++) {
int32_t len1;
uint64_t len2;
void* data;
if (tDecodeI32(pDecoder, &len1) < 0) return -1;
if (tDecodeBinaryAlloc(pDecoder, &data, &len2) < 0) return -1;
ASSERT(len1 == len2);
taosArrayPush(pReq->dataLen, &len1);
taosArrayPush(pReq->data, &data);
}
tEndDecode(pDecoder);
return 0;
}
void tCleanupStreamDispatchReq(SStreamDispatchReq* pReq) {
taosArrayDestroyP(pReq->data, taosMemoryFree);
taosArrayDestroy(pReq->dataLen);
}
int32_t tEncodeStreamRetrieveReq(SEncoder* pEncoder, const SStreamRetrieveReq* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->reqId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->dstNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->dstTaskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->srcNodeId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->srcTaskId) < 0) return -1;
if (tEncodeBinary(pEncoder, (const uint8_t*)pReq->pRetrieve, pReq->retrieveLen) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->reqId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->dstNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->dstTaskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->srcNodeId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->srcTaskId) < 0) return -1;
uint64_t len = 0;
if (tDecodeBinaryAlloc(pDecoder, (void**)&pReq->pRetrieve, &len) < 0) return -1;
pReq->retrieveLen = (int32_t)len;
tEndDecode(pDecoder);
return 0;
}
void tCleanupStreamRetrieveReq(SStreamRetrieveReq* pReq) { taosMemoryFree(pReq->pRetrieve); }
int32_t tEncodeStreamTaskCheckpointReq(SEncoder* pEncoder, const SStreamTaskCheckpointReq* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->nodeId) < 0) return -1;
tEndEncode(pEncoder);
return 0;
}
int32_t tDecodeStreamTaskCheckpointReq(SDecoder* pDecoder, SStreamTaskCheckpointReq* pReq) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->nodeId) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}
int32_t tEncodeStreamHbMsg(SEncoder* pEncoder, const SStreamHbMsg* pReq) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->vgId) < 0) return -1;
if (tEncodeI32(pEncoder, pReq->numOfTasks) < 0) return -1;
for (int32_t i = 0; i < pReq->numOfTasks; ++i) {
STaskStatusEntry* ps = taosArrayGet(pReq->pTaskStatus, i);
if (tEncodeI64(pEncoder, ps->id.streamId) < 0) return -1;
if (tEncodeI32(pEncoder, ps->id.taskId) < 0) return -1;
if (tEncodeI32(pEncoder, ps->status) < 0) return -1;
if (tEncodeI64(pEncoder, ps->stage) < 0) return -1;
if (tEncodeI32(pEncoder, ps->nodeId) < 0) return -1;
if (tEncodeDouble(pEncoder, ps->inputQUsed) < 0) return -1;
if (tEncodeDouble(pEncoder, ps->inputRate) < 0) return -1;
if (tEncodeDouble(pEncoder, ps->sinkQuota) < 0) return -1;
if (tEncodeDouble(pEncoder, ps->sinkDataSize) < 0) return -1;
if (tEncodeI64(pEncoder, ps->processedVer) < 0) return -1;
if (tEncodeI64(pEncoder, ps->verRange.minVer) < 0) return -1;
if (tEncodeI64(pEncoder, ps->verRange.maxVer) < 0) return -1;
if (tEncodeI64(pEncoder, ps->checkpointInfo.activeId) < 0) return -1;
if (tEncodeI8(pEncoder, ps->checkpointInfo.failed) < 0) return -1;
if (tEncodeI32(pEncoder, ps->checkpointInfo.activeTransId) < 0) return -1;
if (tEncodeI64(pEncoder, ps->checkpointInfo.latestId) < 0) return -1;
if (tEncodeI64(pEncoder, ps->checkpointInfo.latestVer) < 0) return -1;
if (tEncodeI64(pEncoder, ps->checkpointInfo.latestTime) < 0) return -1;
if (tEncodeI64(pEncoder, ps->startTime) < 0) return -1;
if (tEncodeI64(pEncoder, ps->startCheckpointId) < 0) return -1;
if (tEncodeI64(pEncoder, ps->startCheckpointVer) < 0) return -1;
if (tEncodeI64(pEncoder, ps->hTaskId) < 0) return -1;
}
int32_t numOfVgs = taosArrayGetSize(pReq->pUpdateNodes);
if (tEncodeI32(pEncoder, numOfVgs) < 0) return -1;
for (int j = 0; j < numOfVgs; ++j) {
int32_t* pVgId = taosArrayGet(pReq->pUpdateNodes, j);
if (tEncodeI32(pEncoder, *pVgId) < 0) return -1;
}
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamHbMsg(SDecoder* pDecoder, SStreamHbMsg* pReq) {
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->vgId) < 0) return -1;
if (tDecodeI32(pDecoder, &pReq->numOfTasks) < 0) return -1;
pReq->pTaskStatus = taosArrayInit(pReq->numOfTasks, sizeof(STaskStatusEntry));
for (int32_t i = 0; i < pReq->numOfTasks; ++i) {
int32_t taskId = 0;
STaskStatusEntry entry = {0};
if (tDecodeI64(pDecoder, &entry.id.streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &entry.status) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.stage) < 0) return -1;
if (tDecodeI32(pDecoder, &entry.nodeId) < 0) return -1;
if (tDecodeDouble(pDecoder, &entry.inputQUsed) < 0) return -1;
if (tDecodeDouble(pDecoder, &entry.inputRate) < 0) return -1;
if (tDecodeDouble(pDecoder, &entry.sinkQuota) < 0) return -1;
if (tDecodeDouble(pDecoder, &entry.sinkDataSize) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.processedVer) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.verRange.minVer) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.verRange.maxVer) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.checkpointInfo.activeId) < 0) return -1;
if (tDecodeI8(pDecoder, &entry.checkpointInfo.failed) < 0) return -1;
if (tDecodeI32(pDecoder, &entry.checkpointInfo.activeTransId) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.checkpointInfo.latestId) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.checkpointInfo.latestVer) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.checkpointInfo.latestTime) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.startTime) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.startCheckpointId) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.startCheckpointVer) < 0) return -1;
if (tDecodeI64(pDecoder, &entry.hTaskId) < 0) return -1;
entry.id.taskId = taskId;
taosArrayPush(pReq->pTaskStatus, &entry);
}
int32_t numOfVgs = 0;
if (tDecodeI32(pDecoder, &numOfVgs) < 0) return -1;
pReq->pUpdateNodes = taosArrayInit(numOfVgs, sizeof(int32_t));
for (int j = 0; j < numOfVgs; ++j) {
int32_t vgId = 0;
if (tDecodeI32(pDecoder, &vgId) < 0) return -1;
taosArrayPush(pReq->pUpdateNodes, &vgId);
}
tEndDecode(pDecoder);
return 0;
}
void tCleanupStreamHbMsg(SStreamHbMsg* pMsg) {
if (pMsg == NULL) {
return;
}
if (pMsg->pUpdateNodes != NULL) {
taosArrayDestroy(pMsg->pUpdateNodes);
}
if (pMsg->pTaskStatus != NULL) {
taosArrayDestroy(pMsg->pTaskStatus);
}
}
int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
if (tStartEncode(pEncoder) < 0) return -1;
if (tEncodeI64(pEncoder, pTask->ver) < 0) return -1;
if (tEncodeI64(pEncoder, pTask->id.streamId) < 0) return -1;
if (tEncodeI32(pEncoder, pTask->id.taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pTask->info.totalLevel) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->info.taskLevel) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->outputInfo.type) < 0) return -1;
if (tEncodeI16(pEncoder, pTask->msgInfo.msgType) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->status.taskStatus) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->status.schedStatus) < 0) return -1;
if (tEncodeI32(pEncoder, pTask->info.selfChildId) < 0) return -1;
if (tEncodeI32(pEncoder, pTask->info.nodeId) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pTask->info.epSet) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pTask->info.mnodeEpset) < 0) return -1;
if (tEncodeI64(pEncoder, pTask->chkInfo.checkpointId) < 0) return -1;
if (tEncodeI64(pEncoder, pTask->chkInfo.checkpointVer) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->info.fillHistory) < 0) return -1;
if (tEncodeI64(pEncoder, pTask->hTaskInfo.id.streamId)) return -1;
int32_t taskId = pTask->hTaskInfo.id.taskId;
if (tEncodeI32(pEncoder, taskId)) return -1;
if (tEncodeI64(pEncoder, pTask->streamTaskId.streamId)) return -1;
taskId = pTask->streamTaskId.taskId;
if (tEncodeI32(pEncoder, taskId)) return -1;
if (tEncodeU64(pEncoder, pTask->dataRange.range.minVer)) return -1;
if (tEncodeU64(pEncoder, pTask->dataRange.range.maxVer)) return -1;
if (tEncodeI64(pEncoder, pTask->dataRange.window.skey)) return -1;
if (tEncodeI64(pEncoder, pTask->dataRange.window.ekey)) return -1;
int32_t epSz = taosArrayGetSize(pTask->upstreamInfo.pList);
if (tEncodeI32(pEncoder, epSz) < 0) return -1;
for (int32_t i = 0; i < epSz; i++) {
SStreamChildEpInfo* pInfo = taosArrayGetP(pTask->upstreamInfo.pList, i);
if (tEncodeStreamEpInfo(pEncoder, pInfo) < 0) return -1;
}
if (pTask->info.taskLevel != TASK_LEVEL__SINK) {
if (tEncodeCStr(pEncoder, pTask->exec.qmsg) < 0) return -1;
}
if (pTask->outputInfo.type == TASK_OUTPUT__TABLE) {
if (tEncodeI64(pEncoder, pTask->outputInfo.tbSink.stbUid) < 0) return -1;
if (tEncodeCStr(pEncoder, pTask->outputInfo.tbSink.stbFullName) < 0) return -1;
if (tEncodeSSchemaWrapper(pEncoder, pTask->outputInfo.tbSink.pSchemaWrapper) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__SMA) {
if (tEncodeI64(pEncoder, pTask->outputInfo.smaSink.smaId) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__FETCH) {
if (tEncodeI8(pEncoder, pTask->outputInfo.fetchSink.reserved) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
if (tEncodeI32(pEncoder, pTask->outputInfo.fixedDispatcher.taskId) < 0) return -1;
if (tEncodeI32(pEncoder, pTask->outputInfo.fixedDispatcher.nodeId) < 0) return -1;
if (tEncodeSEpSet(pEncoder, &pTask->outputInfo.fixedDispatcher.epSet) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
if (tSerializeSUseDbRspImp(pEncoder, &pTask->outputInfo.shuffleDispatcher.dbInfo) < 0) return -1;
if (tEncodeCStr(pEncoder, pTask->outputInfo.shuffleDispatcher.stbFullName) < 0) return -1;
}
if (tEncodeI64(pEncoder, pTask->info.triggerParam) < 0) return -1;
if (tEncodeI8(pEncoder, pTask->subtableWithoutMd5) < 0) return -1;
if (tEncodeCStrWithLen(pEncoder, pTask->reserve, sizeof(pTask->reserve) - 1) < 0) return -1;
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
int32_t taskId = 0;
if (tStartDecode(pDecoder) < 0) return -1;
if (tDecodeI64(pDecoder, &pTask->ver) < 0) return -1;
if (pTask->ver <= SSTREAM_TASK_INCOMPATIBLE_VER || pTask->ver > SSTREAM_TASK_VER) return -1;
if (tDecodeI64(pDecoder, &pTask->id.streamId) < 0) return -1;
if (tDecodeI32(pDecoder, &pTask->id.taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pTask->info.totalLevel) < 0) return -1;
if (tDecodeI8(pDecoder, &pTask->info.taskLevel) < 0) return -1;
if (tDecodeI8(pDecoder, &pTask->outputInfo.type) < 0) return -1;
if (tDecodeI16(pDecoder, &pTask->msgInfo.msgType) < 0) return -1;
if (tDecodeI8(pDecoder, &pTask->status.taskStatus) < 0) return -1;
if (tDecodeI8(pDecoder, &pTask->status.schedStatus) < 0) return -1;
if (tDecodeI32(pDecoder, &pTask->info.selfChildId) < 0) return -1;
if (tDecodeI32(pDecoder, &pTask->info.nodeId) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &pTask->info.epSet) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &pTask->info.mnodeEpset) < 0) return -1;
if (tDecodeI64(pDecoder, &pTask->chkInfo.checkpointId) < 0) return -1;
if (tDecodeI64(pDecoder, &pTask->chkInfo.checkpointVer) < 0) return -1;
if (tDecodeI8(pDecoder, &pTask->info.fillHistory) < 0) return -1;
if (tDecodeI64(pDecoder, &pTask->hTaskInfo.id.streamId)) return -1;
if (tDecodeI32(pDecoder, &taskId)) return -1;
pTask->hTaskInfo.id.taskId = taskId;
if (tDecodeI64(pDecoder, &pTask->streamTaskId.streamId)) return -1;
if (tDecodeI32(pDecoder, &taskId)) return -1;
pTask->streamTaskId.taskId = taskId;
if (tDecodeU64(pDecoder, (uint64_t*)&pTask->dataRange.range.minVer)) return -1;
if (tDecodeU64(pDecoder, (uint64_t*)&pTask->dataRange.range.maxVer)) return -1;
if (tDecodeI64(pDecoder, &pTask->dataRange.window.skey)) return -1;
if (tDecodeI64(pDecoder, &pTask->dataRange.window.ekey)) return -1;
int32_t epSz = -1;
if (tDecodeI32(pDecoder, &epSz) < 0) return -1;
pTask->upstreamInfo.pList = taosArrayInit(epSz, POINTER_BYTES);
for (int32_t i = 0; i < epSz; i++) {
SStreamChildEpInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamChildEpInfo));
if (pInfo == NULL) return -1;
if (tDecodeStreamEpInfo(pDecoder, pInfo) < 0) {
taosMemoryFreeClear(pInfo);
return -1;
}
taosArrayPush(pTask->upstreamInfo.pList, &pInfo);
}
if (pTask->info.taskLevel != TASK_LEVEL__SINK) {
if (tDecodeCStrAlloc(pDecoder, &pTask->exec.qmsg) < 0) return -1;
}
if (pTask->outputInfo.type == TASK_OUTPUT__TABLE) {
if (tDecodeI64(pDecoder, &pTask->outputInfo.tbSink.stbUid) < 0) return -1;
if (tDecodeCStrTo(pDecoder, pTask->outputInfo.tbSink.stbFullName) < 0) return -1;
pTask->outputInfo.tbSink.pSchemaWrapper = taosMemoryCalloc(1, sizeof(SSchemaWrapper));
if (pTask->outputInfo.tbSink.pSchemaWrapper == NULL) return -1;
if (tDecodeSSchemaWrapper(pDecoder, pTask->outputInfo.tbSink.pSchemaWrapper) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__SMA) {
if (tDecodeI64(pDecoder, &pTask->outputInfo.smaSink.smaId) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__FETCH) {
if (tDecodeI8(pDecoder, &pTask->outputInfo.fetchSink.reserved) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__FIXED_DISPATCH) {
if (tDecodeI32(pDecoder, &pTask->outputInfo.fixedDispatcher.taskId) < 0) return -1;
if (tDecodeI32(pDecoder, &pTask->outputInfo.fixedDispatcher.nodeId) < 0) return -1;
if (tDecodeSEpSet(pDecoder, &pTask->outputInfo.fixedDispatcher.epSet) < 0) return -1;
} else if (pTask->outputInfo.type == TASK_OUTPUT__SHUFFLE_DISPATCH) {
if (tDeserializeSUseDbRspImp(pDecoder, &pTask->outputInfo.shuffleDispatcher.dbInfo) < 0) return -1;
if (tDecodeCStrTo(pDecoder, pTask->outputInfo.shuffleDispatcher.stbFullName) < 0) return -1;
}
if (tDecodeI64(pDecoder, &pTask->info.triggerParam) < 0) return -1;
if (pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER){
if (tDecodeI8(pDecoder, &pTask->subtableWithoutMd5) < 0) return -1;
}
if (tDecodeCStrTo(pDecoder, pTask->reserve) < 0) return -1;
tEndDecode(pDecoder);
return 0;
}

View File

@ -720,7 +720,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_STAT, "Invalid tsma state"
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_PTR, "Invalid tsma pointer")
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_PARA, "Invalid tsma parameters")
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_TB, "Invalid table to create tsma, only stable or normal table allowed")
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_INTERVAL, "Invalid tsma interval, 1ms ~ 1h is allowed")
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_INTERVAL, "Invalid tsma interval, 1m ~ 1h is allowed")
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_FUNC_PARAM, "Invalid tsma func param, only one non-tag column allowed")
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_UNSUPPORTED_FUNC, "Tsma func not supported")
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_MUST_BE_DROPPED, "Tsma must be dropped first")

View File

@ -0,0 +1,672 @@
from frame.log import *
from frame.cases import *
from frame.sql import *
from frame.caseBase import *
from frame import *
from frame.eos import *
class TDTestCase(TBase):
"""Add test case to improve the compare.c coverage
"""
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
def prepare_data(self):
# database
tdSql.execute("create database db;")
tdSql.execute("use db;")
# create table
tdSql.execute("create table rt(ts timestamp, c_int8 tinyint, c_uint8 tinyint unsigned, c_bool bool, c_int16 smallint, c_uint16 smallint unsigned, c_int32 int, c_uint32 int unsigned, c_float float, c_int64 bigint, c_uint64 bigint unsigned, c_double double, c_binary binary(16), c_varchar varchar(16), c_nchar nchar(16), c_varbinary varbinary(16));")
# insert data
sql = "insert into rt values \
('2024-05-08 12:00:00.000', 1, 2, true, 1, 2, 1, 2, 1.1, 111111, 222222, 111111.111111, 'a', 'a', 'a', \"0x01\"), \
('2024-05-08 12:00:01.000', 2, 1, false, 2, 1, 2, 1, 2.2, 222222, 111111, 222222.222222, 'b', 'b', 'b', \"0x02\"), \
('2024-05-08 12:00:02.000', 3, 3, true, 3, 3, 3, 3, null, 333333, 333333, 3.1111111, 'c', 'c', 'c', \"0x03\"), \
('2024-05-08 12:00:03.000', 4, 4, false, 4, 4, 4, 4, 4.4, 444444, 222222, 444444.444444, 'd', 'd', 'd', \"0x04\"), \
('2024-05-08 12:00:04.000', 5, 5, true, 5, 5, 5, 5, 5.5, 2, 3, 555555.555555, 'e', 'e', 'e', \"0x05\"), \
('2024-05-08 12:00:05.000', 6, 6, false, -5, 5, 5, 5, 5.0, 6, 6, 5, 'e', 'e', 'e', \"0x06\");"
tdSql.execute(sql)
def test_notin(self):
# setChkNotInBytes1
tdSql.query("select * from rt where c_int8 not in (6, 7);")
tdSql.checkRows(5)
tdSql.query("select * from rt where c_int8 not in (1, 2);")
tdSql.checkRows(4)
tdSql.query("select * from rt where c_bool not in (true);")
tdSql.checkRows(3)
# setChkNotInBytes8
tdSql.query("select * from rt where c_int64 not in (6666666, 7777777);")
tdSql.checkRows(6)
tdSql.query("select * from rt where c_uint64 not in (5555555555);")
tdSql.checkRows(6)
tdSql.query("select * from rt where c_double not in (111111.111111, 222222.222222);")
tdSql.checkRows(4)
# setChkNotInString
tdSql.query("select * from rt where c_binary not in ('f', 'g', 'h');")
tdSql.checkRows(6)
tdSql.query("select * from rt where c_varchar not in ('a', 'b', 'c');")
tdSql.checkRows(3)
tdSql.query("select * from rt where c_nchar not in ('d', 'e', 'f');")
tdSql.checkRows(3)
tdSql.query("select * from rt where c_varbinary not in ('0x01', '0x02');")
tdSql.checkRows(4)
def test_compare_value(self):
# compareUint16Val
tdSql.query("select * from rt where c_uint16 = 5;")
tdSql.checkRows(2)
tdSql.query("select * from rt where c_uint16 < 5;")
tdSql.checkRows(4)
# compareFloatVal
tdSql.query("select * from rt where c_float is null;")
tdSql.checkRows(1)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float < t2.c_float;")
tdSql.checkRows(10)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float > t2.c_float;")
tdSql.checkRows(10)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float = t2.c_float;")
tdSql.checkRows(5)
# compareDoubleVal
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double = t2.c_double;")
tdSql.checkRows(6)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double < t2.c_double;")
tdSql.checkRows(15)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double > t2.c_double;")
tdSql.checkRows(15)
def test_compareInt8Int16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 > t2.c_int16;")
tdSql.checkRows(21)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 < t2.c_int16;")
tdSql.checkRows(10)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 = t2.c_int16;")
tdSql.checkRows(5)
def test_compareInt8Int32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 < t2.c_int32;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 > t2.c_int32;")
tdSql.checkRows(16)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 = t2.c_int32;")
tdSql.checkRows(6)
def test_compareInt8Int64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 < t2.c_int64;")
tdSql.checkRows(30)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 > t2.c_int64;")
tdSql.checkRows(4)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 = t2.c_int64;")
tdSql.checkRows(2)
def test_compareInt8Double(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 < t2.c_double;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 > t2.c_double;")
tdSql.checkRows(4)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 = t2.c_double;")
tdSql.checkRows(1)
def test_compareInt8Uint8(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 < t2.c_uint8;")
tdSql.checkRows(15)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 > t2.c_uint8;")
tdSql.checkRows(15)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 = t2.c_uint8;")
tdSql.checkRows(6)
def test_compareInt8Uint16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 < t2.c_uint16;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 > t2.c_uint16;")
tdSql.checkRows(16)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 = t2.c_uint16;")
tdSql.checkRows(6)
def test_compareInt8Uint32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 < t2.c_uint32;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 > t2.c_uint32;")
tdSql.checkRows(16)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 = t2.c_uint32;")
tdSql.checkRows(6)
def test_compareInt8Uint64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 < t2.c_uint64;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 > t2.c_uint64;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int8 = t2.c_uint64;")
tdSql.checkRows(2)
def test_compareInt16Int32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 < t2.c_int32;")
tdSql.checkRows(20)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 > t2.c_int32;")
tdSql.checkRows(10)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 = t2.c_int32;")
tdSql.checkRows(6)
def test_compareInt16Int64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 < t2.c_int64;")
tdSql.checkRows(32)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 > t2.c_int64;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 = t2.c_int32;")
tdSql.checkRows(6)
def test_compareInt16Double(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 < t2.c_double;")
tdSql.checkRows(33)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 > t2.c_double;")
tdSql.checkRows(2)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 = t2.c_double;")
tdSql.checkRows(1)
def test_compareInt16Uint8(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 < t2.c_uint8;")
tdSql.checkRows(21)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 > t2.c_uint8;")
tdSql.checkRows(10)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 = t2.c_uint8;")
tdSql.checkRows(5)
def test_compareInt16Uint16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 < t2.c_uint16;")
tdSql.checkRows(20)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 > t2.c_uint16;")
tdSql.checkRows(10)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 = t2.c_uint16;")
tdSql.checkRows(6)
def test_compareInt16Uint32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 < t2.c_uint32;")
tdSql.checkRows(20)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 > t2.c_uint32;")
tdSql.checkRows(10)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 = t2.c_uint32;")
tdSql.checkRows(6)
def test_compareInt16Uint64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 < t2.c_uint64;")
tdSql.checkRows(33)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 > t2.c_uint64;")
tdSql.checkRows(2)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int16 = t2.c_uint64;")
tdSql.checkRows(1)
def test_compareInt32Int16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 < t2.c_int16;")
tdSql.checkRows(10)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 > t2.c_int16;")
tdSql.checkRows(20)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 = t2.c_int16;")
tdSql.checkRows(6)
def test_compareInt32Int64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 < t2.c_int64;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 > t2.c_int64;")
tdSql.checkRows(4)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 = t2.c_int64;")
tdSql.checkRows(1)
def test_compareInt32Float(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 < t2.c_float;")
tdSql.checkRows(17)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 > t2.c_float;")
tdSql.checkRows(11)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 = t2.c_float;")
tdSql.checkRows(2)
def test_compareInt32Uint8(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 < t2.c_uint8;")
tdSql.checkRows(16)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 > t2.c_uint8;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 = t2.c_uint8;")
tdSql.checkRows(6)
def test_compareInt32Uint16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 < t2.c_uint16;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 > t2.c_uint16;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 = t2.c_uint16;")
tdSql.checkRows(8)
def test_compareInt32Uint32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 < t2.c_uint32;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 > t2.c_uint32;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 = t2.c_uint32;")
tdSql.checkRows(8)
def test_compareInt32Uint64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 < t2.c_uint64;")
tdSql.checkRows(32)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 > t2.c_uint64;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int32 = t2.c_uint64;")
tdSql.checkRows(1)
def test_compareInt64Uint8(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int64 < t2.c_uint8;")
tdSql.checkRows(4)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int64 > t2.c_uint8;")
tdSql.checkRows(30)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int64 = t2.c_uint8;")
tdSql.checkRows(2)
def test_compareInt64Uint16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int64 < t2.c_uint16;")
tdSql.checkRows(4)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int64 > t2.c_uint16;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int64 = t2.c_uint16;")
tdSql.checkRows(1)
def test_compareInt64Uint32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int64 < t2.c_uint32;")
tdSql.checkRows(4)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int64 > t2.c_uint32;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_int64 = t2.c_uint32;")
tdSql.checkRows(1)
def test_compareFloatInt32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float < t2.c_int32;")
tdSql.checkRows(11)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float > t2.c_int32;")
tdSql.checkRows(17)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float = t2.c_int32;")
tdSql.checkRows(2)
def test_compareFloatUint8(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float < t2.c_uint8;")
tdSql.checkRows(13)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float > t2.c_uint8;")
tdSql.checkRows(16)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float = t2.c_uint8;")
tdSql.checkRows(1)
def test_compareFloatUint16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float < t2.c_uint16;")
tdSql.checkRows(11)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float > t2.c_uint16;")
tdSql.checkRows(17)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float = t2.c_uint16;")
tdSql.checkRows(2)
def test_compareFloatUint32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float < t2.c_uint32;")
tdSql.checkRows(11)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float > t2.c_uint32;")
tdSql.checkRows(17)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float = t2.c_uint32;")
tdSql.checkRows(2)
def test_compareFloatUint64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float < t2.c_uint64;")
tdSql.checkRows(27)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float > t2.c_uint64;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_float = t2.c_uint64;")
tdSql.checkRows(0)
def test_compareDoubleUint8(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double < t2.c_uint8;")
tdSql.checkRows(4)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double > t2.c_uint8;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double = t2.c_uint8;")
tdSql.checkRows(1)
def test_compareDoubleUint16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double < t2.c_uint16;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double > t2.c_uint16;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double = t2.c_uint16;")
tdSql.checkRows(2)
def test_compareDoubleUint32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double < t2.c_uint32;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double > t2.c_uint32;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double = t2.c_uint32;")
tdSql.checkRows(2)
def test_compareDoubleUint64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double < t2.c_uint64;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double > t2.c_uint64;")
tdSql.checkRows(22)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_double = t2.c_uint64;")
tdSql.checkRows(0)
def test_compareUint8Int16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 < t2.c_int16;")
tdSql.checkRows(10)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 > t2.c_int16;")
tdSql.checkRows(21)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 = t2.c_int16;")
tdSql.checkRows(5)
def test_compareUint8Int32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 < t2.c_int32;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 > t2.c_int32;")
tdSql.checkRows(16)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 = t2.c_int32;")
tdSql.checkRows(6)
def test_compareUint8Int64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 < t2.c_int64;")
tdSql.checkRows(30)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 > t2.c_int64;")
tdSql.checkRows(4)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 = t2.c_int64;")
tdSql.checkRows(2)
def test_compareUint8Float(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 < t2.c_float;")
tdSql.checkRows(16)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 > t2.c_float;")
tdSql.checkRows(13)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 = t2.c_float;")
tdSql.checkRows(1)
def test_compareUint8Double(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 < t2.c_double;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 > t2.c_double;")
tdSql.checkRows(4)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 = t2.c_double;")
tdSql.checkRows(1)
def test_compareUint8Uint16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 < t2.c_uint16;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 > t2.c_uint16;")
tdSql.checkRows(16)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 = t2.c_uint16;")
tdSql.checkRows(6)
def test_compareUint8Uint32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 < t2.c_uint32;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 > t2.c_uint32;")
tdSql.checkRows(16)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 = t2.c_uint32;")
tdSql.checkRows(6)
def test_compareUint8Uint64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 < t2.c_uint64;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 > t2.c_uint64;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint8 = t2.c_uint64;")
tdSql.checkRows(2)
def test_compareUint16Int16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 < t2.c_int16;")
tdSql.checkRows(10)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 > t2.c_int16;")
tdSql.checkRows(20)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 = t2.c_int16;")
tdSql.checkRows(6)
def test_compareUint16Int32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 < t2.c_int32;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 > t2.c_int32;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 = t2.c_int32;")
tdSql.checkRows(8)
def test_compareUint16Int64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 < t2.c_int64;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 > t2.c_int64;")
tdSql.checkRows(4)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 = t2.c_int64;")
tdSql.checkRows(1)
def test_compareUint16Float(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 < t2.c_float;")
tdSql.checkRows(17)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 > t2.c_float;")
tdSql.checkRows(11)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 = t2.c_float;")
tdSql.checkRows(2)
def test_compareUint16Double(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 < t2.c_double;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 > t2.c_double;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 = t2.c_double;")
tdSql.checkRows(2)
def test_compareUint16Uint8(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 < t2.c_uint8;")
tdSql.checkRows(16)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 > t2.c_uint8;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 = t2.c_uint8;")
tdSql.checkRows(6)
def test_compareUint16Uint32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 < t2.c_uint32;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 > t2.c_uint32;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint16 = t2.c_uint32;")
tdSql.checkRows(8)
def test_compareUint32Int32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 < t2.c_int32;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 > t2.c_int32;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 = t2.c_int32;")
tdSql.checkRows(8)
def test_compareUint32Int64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 < t2.c_int64;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 > t2.c_int64;")
tdSql.checkRows(4)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 = t2.c_int64;")
tdSql.checkRows(1)
def test_compareUint32Float(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 < t2.c_float;")
tdSql.checkRows(17)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 > t2.c_float;")
tdSql.checkRows(11)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 = t2.c_float;")
tdSql.checkRows(2)
def test_compareUint32Double(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 < t2.c_double;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 > t2.c_double;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 = t2.c_double;")
tdSql.checkRows(2)
def test_compareUint32Uint8(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 < t2.c_uint8;")
tdSql.checkRows(16)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 > t2.c_uint8;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 = t2.c_uint8;")
tdSql.checkRows(6)
def test_compareUint32Uint16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 < t2.c_uint16;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 > t2.c_uint16;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 = t2.c_uint16;")
tdSql.checkRows(8)
def test_compareUint32Uint64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 < t2.c_uint64;")
tdSql.checkRows(32)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 > t2.c_uint64;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint32 = t2.c_uint64;")
tdSql.checkRows(1)
def test_compareUint64Int16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 < t2.c_int16;")
tdSql.checkRows(2)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 > t2.c_int16;")
tdSql.checkRows(33)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 = t2.c_int16;")
tdSql.checkRows(1)
def test_compareUint64Int32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 < t2.c_int32;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 > t2.c_int32;")
tdSql.checkRows(32)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 = t2.c_int32;")
tdSql.checkRows(1)
def test_compareUint64Int64(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 < t2.c_int64;")
tdSql.checkRows(17)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 > t2.c_int64;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 = t2.c_int64;")
tdSql.checkRows(5)
def test_compareUint64Float(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 < t2.c_float;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 > t2.c_float;")
tdSql.checkRows(27)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 = t2.c_float;")
tdSql.checkRows(0)
def test_compareUint64Double(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 < t2.c_double;")
tdSql.checkRows(22)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 > t2.c_double;")
tdSql.checkRows(14)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 = t2.c_double;")
tdSql.checkRows(0)
def test_compareUint64Uint8(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 < t2.c_uint8;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 > t2.c_uint8;")
tdSql.checkRows(31)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 = t2.c_uint8;")
tdSql.checkRows(2)
def test_compareUint64Uint16(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 < t2.c_uint16;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 > t2.c_uint16;")
tdSql.checkRows(32)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 = t2.c_uint16;")
tdSql.checkRows(1)
def test_compareUint64Uint32(self):
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 < t2.c_uint32;")
tdSql.checkRows(3)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 > t2.c_uint32;")
tdSql.checkRows(32)
tdSql.query("select * from rt t1 left join rt t2 on timetruncate(t1.ts, 1m) = timetruncate(t2.ts, 1m) where t1.c_uint64 = t2.c_uint32;")
tdSql.checkRows(1)
def run(self):
self.prepare_data()
self.test_notin()
self.test_compare_value()
self.test_compareInt8Int16()
self.test_compareInt8Int32()
self.test_compareInt8Int64()
self.test_compareInt8Double()
self.test_compareInt8Uint8()
self.test_compareInt8Uint16()
self.test_compareInt8Uint32()
self.test_compareInt8Uint64()
self.test_compareInt16Int32()
self.test_compareInt16Int64()
self.test_compareInt16Double()
self.test_compareInt16Uint8()
self.test_compareInt16Uint16()
self.test_compareInt16Uint32()
self.test_compareInt16Uint64()
self.test_compareInt32Int16()
self.test_compareInt32Int64()
self.test_compareInt32Float()
self.test_compareInt32Uint8()
self.test_compareInt32Uint16()
self.test_compareInt32Uint32()
self.test_compareInt32Uint64()
self.test_compareInt64Uint8()
self.test_compareInt64Uint16()
self.test_compareInt64Uint32()
self.test_compareFloatInt32()
self.test_compareFloatUint8()
self.test_compareFloatUint16()
self.test_compareFloatUint32()
self.test_compareFloatUint64()
self.test_compareDoubleUint8()
self.test_compareDoubleUint16()
self.test_compareDoubleUint32()
self.test_compareDoubleUint64()
self.test_compareUint8Int16()
self.test_compareUint8Int32()
self.test_compareUint8Int64()
self.test_compareUint8Float()
self.test_compareUint8Double()
self.test_compareUint8Uint16()
self.test_compareUint8Uint32()
self.test_compareUint8Uint64()
self.test_compareUint16Int16()
self.test_compareUint16Int32()
self.test_compareUint16Int64()
self.test_compareUint16Float()
self.test_compareUint16Double()
self.test_compareUint16Uint8()
self.test_compareUint16Uint32()
self.test_compareUint32Int32()
self.test_compareUint32Int64()
self.test_compareUint32Float()
self.test_compareUint32Double()
self.test_compareUint32Uint8()
self.test_compareUint32Uint16()
self.test_compareUint32Uint64()
self.test_compareUint64Int16()
self.test_compareUint64Int32()
self.test_compareUint64Int64()
self.test_compareUint64Float()
self.test_compareUint64Double()
self.test_compareUint64Uint8()
self.test_compareUint64Uint16()
self.test_compareUint64Uint32()
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -15,6 +15,7 @@
,,y,army,./pytest.sh python3 ./test.py -f community/cluster/snapshot.py -N 3 -L 3 -D 2
,,y,army,./pytest.sh python3 ./test.py -f community/query/function/test_func_elapsed.py
,,y,army,./pytest.sh python3 ./test.py -f community/query/test_join.py
,,y,army,./pytest.sh python3 ./test.py -f community/query/test_compare.py
,,y,army,./pytest.sh python3 ./test.py -f community/query/fill/fill_desc.py -N 3 -L 3 -D 2
,,y,army,./pytest.sh python3 ./test.py -f community/cluster/incSnapshot.py -N 3
,,y,army,./pytest.sh python3 ./test.py -f community/query/query_basic.py -N 3
@ -484,6 +485,30 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last_and_last_row.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last_and_last_row.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last_and_last_row.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last+last_row.py
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last+last_row.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last+last_row.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last+last_row.py -Q 4
#,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_1.py
#,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_1.py -R
#,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_1.py -Q 2
#,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_1.py -Q 3
#,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_1.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_2.py
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_2.py -R
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_2.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_2.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_2.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_3.py
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_3.py -R
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_3.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_3.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_3.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_4.py
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_4.py -R
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_4.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_4.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/primary_ts_base_4.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/leastsquares.py
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/leastsquares.py -R
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/length.py

View File

@ -162,15 +162,15 @@ class TDTestCase:
tdSql.checkData( i, 0, date_init_stamp)
tdSql.query(f"select cast(c2 as timestamp) as b from {self.dbname}.t1")
for i in range(len(data_t1_c2)):
if data_t1_c2[i] is None:
tdSql.checkData( i, 0 , None )
elif i == 10:
continue
else:
date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_t1_c2[i]) / 1000.0)
tdSql.checkData( i, 0, date_init_stamp)
# tdSql.query(f"select cast(c2 as timestamp) as b from {self.dbname}.t1")
# for i in range(len(data_t1_c2)):
# if data_t1_c2[i] is None:
# tdSql.checkData( i, 0 , None )
# elif i == 10:
# continue
# else:
# date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_t1_c2[i]) / 1000.0)
# tdSql.checkData( i, 0, date_init_stamp)
tdLog.printNoPrefix("==========step12: cast smallint to bigint, expect no changes")
@ -389,15 +389,15 @@ class TDTestCase:
date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_ct4_c6[i]) / 1000.0)
tdSql.checkData( i, 0, date_init_stamp)
tdSql.query(f"select cast(c6 as timestamp) as b from {self.dbname}.t1")
for i in range(len(data_t1_c6)):
if data_t1_c6[i] is None:
tdSql.checkData( i, 0 , None )
elif i == 10:
continue
else:
date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_t1_c6[i]) / 1000.0)
tdSql.checkData( i, 0, date_init_stamp)
# tdSql.query(f"select cast(c6 as timestamp) as b from {self.dbname}.t1")
# for i in range(len(data_t1_c6)):
# if data_t1_c6[i] is None:
# tdSql.checkData( i, 0 , None )
# elif i == 10:
# continue
# else:
# date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_t1_c6[i]) / 1000.0)
# tdSql.checkData( i, 0, date_init_stamp)
tdLog.printNoPrefix("==========step28: cast bool to bigint, expect no changes")
tdSql.query(f"select c7 from {self.dbname}.ct4")

View File

@ -0,0 +1,353 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from util.cases import tdCases
#from .nestedQueryInterval import *
from .nestedQuery import *
from faker import Faker
import random
class TDTestCase(TDTestCase):
def explain_scan_value(self,sql,cachemodel):
tdLog.info(cachemodel)
if cachemodel=='none':
tdSql.query(sql)
self.check_sql_result_include(sql,'Table Scan')
self.check_sql_result_not_include(sql,'Last Row Scan')
elif cachemodel=='last_row':
tdSql.query(sql)
self.check_sql_result_include(sql,'Last Row Scan')
self.check_sql_result_not_include(sql,'Table Scan')
elif cachemodel=='last_row_1':
tdSql.query("reset query cache;")
tdSql.query(sql)
self.check_sql_result_include(sql,'Last Row')
self.check_sql_result_include(sql,'Table')
elif cachemodel=='last_value':
tdSql.query(sql)
self.check_sql_result_not_include(sql,'Last Row Scan')
self.check_sql_result_include(sql,'Table Scan')
elif cachemodel=='last_value_1':
tdSql.query(sql)
self.check_sql_result_include(sql,'Last Row Scan')
self.check_sql_result_include(sql,'Table Scan')
elif cachemodel=='both':
tdSql.query(sql)
self.check_sql_result_include(sql,'Last Row Scan')
self.check_sql_result_not_include(sql,'Table Scan')
else:
tdSql.query(sql)
tdLog.info(sql)
tdLog.exit(f"explain_scan_value : checkEqual error")
def check_sql_result_include(self, sql,include_result):
result = os.popen("taos -s 'reset query cache; %s'" %sql)
res = result.read()
#tdLog.info(res)
if (include_result in res):
tdLog.info(f"check_sql_result_include : checkEqual success")
else :
tdLog.info(res)
tdLog.info(sql)
tdLog.exit(f"check_sql_result_include : checkEqual error")
def check_sql_result_not_include(self, sql,not_include_result):
result = os.popen("taos -s 'reset query cache; %s'" %sql)
res = result.read()
#tdLog.info(res)
if (not_include_result in res):
tdLog.info(res)
tdLog.info(sql)
tdLog.exit(f"check_sql_result_not_include : checkEqual error")
else :
tdLog.info(f"check_sql_result_not_include : checkEqual success")
def cachemodel_none(self, dbname="nested"):
sql = f"explain select last(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
# last(id+1)
sql = f"explain select last(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
#last(id)+1
sql = f"explain select last(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"none")
sql = f"explain select last(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"none")
def cachemodel_last_row(self, dbname="nested"):
sql = f"explain select last(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_value")
sql = f"explain select last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_row")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_row_1")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_value")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_row")
def cachemodel_last_value(self, dbname="nested"):
sql = f"explain select last(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_row")
sql = f"explain select last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_value")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_row_1")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_row")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_value")
sql = f"explain select last(q_int)+1 from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_row")
sql = f"explain select last_row(q_int)+1 from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_value")
sql = f"explain select last(q_int)+1,last_row(q_int)+1 from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_row_1")
sql = f"explain select last(q_int)+1,last(q_int)+1 from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_row")
sql = f"explain select last_row(q_int)+1,last_row(q_int)+1 from {dbname}.stable_1 "
self.explain_scan_value(sql,"last_value")
def cachemodel_both(self, dbname="nested"):
sql = f"explain select last(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"both")
sql = f"explain select last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"both")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"both")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"both")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 "
self.explain_scan_value(sql,"both")
sql = f"explain select last(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"both")
sql = f"explain select last_row(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"both")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"both")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"both")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 group by tbname"
self.explain_scan_value(sql,"both")
sql = f"explain select last(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"both")
sql = f"explain select last_row(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"both")
sql = f"explain select last(*),last_row(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"both")
sql = f"explain select last(*),last(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"both")
sql = f"explain select last_row(*),last_row(*) from {dbname}.stable_1 partition by tbname"
self.explain_scan_value(sql,"both")
def modify_tables(self):
fake = Faker('zh_CN')
tdSql.execute('delete from stable_1_3;')
tdSql.execute('delete from stable_1_4;')
tdSql.execute('''create table stable_1_5 using stable_1 tags('stable_1_5', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;'''
%(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
tdSql.execute('''create table stable_1_6 using stable_1 tags('stable_1_6', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;'''
%(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
tdSql.execute('''create table stable_1_7 using stable_1 tags('stable_1_7', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;'''
%(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
tdSql.execute('''create table stable_1_8 using stable_1 tags('stable_1_8', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;'''
%(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
tdSql.execute('''create table stable_1_9 using stable_1 tags('stable_1_9', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;'''
%(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
tdSql.execute('''create table stable_1_90 using stable_1 tags('stable_1_90', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;'''
%(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
tdSql.execute('''create table stable_1_91 using stable_1 tags('stable_1_91', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;'''
%(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
tdSql.execute('''create table stable_1_92 using stable_1 tags('stable_1_92', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;'''
%(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1),
fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) ,
fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1)))
tdSql.execute('alter stable stable_1 add tag t_int_null INT;')
tdSql.execute('alter stable stable_1 add tag t_bigint_null BIGINT;')
tdSql.execute('alter stable stable_1 add tag t_smallint_null SMALLINT;')
tdSql.execute('alter stable stable_1 add tag t_tinyint_null TINYINT;')
tdSql.execute('alter stable stable_1 add tag t_bool_null BOOL;')
tdSql.execute('alter stable stable_1 add tag t_binary_null VARCHAR(100);')
tdSql.execute('alter stable stable_1 add tag t_nchar_null NCHAR(100);')
tdSql.execute('alter stable stable_1 add tag t_float_null FLOAT;')
tdSql.execute('alter stable stable_1 add tag t_double_null DOUBLE;')
tdSql.execute('alter stable stable_1 add tag t_ts_null TIMESTAMP;')
tdSql.execute('alter stable stable_1 drop column q_nchar8;')
tdSql.execute('alter stable stable_1 drop column q_binary8;')
tdSql.execute('alter stable stable_1 drop column q_nchar7;')
tdSql.execute('alter stable stable_1 drop column q_binary7;')
tdSql.execute('alter stable stable_1 drop column q_nchar6;')
tdSql.execute('alter stable stable_1 drop column q_binary6;')
tdSql.execute('alter stable stable_1 drop column q_nchar5;')
tdSql.execute('alter stable stable_1 drop column q_binary5;')
tdSql.execute('alter stable stable_1 drop column q_nchar4;')
tdSql.execute('alter stable stable_1 drop column q_binary4;')
def run(self):
tdSql.prepare()
startTime = time.time()
self.dropandcreateDB_random("nested", 1)
self.modify_tables()
for i in range(2):
self.cachemodel_none()
tdSql.query("alter database nested cachemodel 'last_row' ")
tdSql.query("reset query cache;")
self.cachemodel_last_row()
tdSql.query("alter database nested cachemodel 'last_value' ")
tdSql.query("reset query cache;")
self.cachemodel_last_value()
tdSql.query("alter database nested cachemodel 'both' ")
tdSql.query("reset query cache;")
self.cachemodel_both()
tdSql.query("alter database nested cachemodel 'none' ")
tdSql.query("reset query cache;")
endTime = time.time()
print("total time %ds" % (endTime - startTime))
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from util.cases import tdCases
from .primary_ts_base import *
from faker import Faker
import random
class TDTestCase(TDTestCase):
def run(self):
startTime = time.time()
self.dropandcreateDB_primary_key(self.database, 1 , 1 ,'yes','yes','no')
self.fun_pk_interp(self.database,'interp','')
self.multiple_agg_groupby(self.database,1)
self.fun_pk_diff(self.database,'diff','')
self.fun_pk_twa(self.database,'derivative',',1s,0')
self.fun_pk_twa(self.database,'derivative',',1s,1')
self.fun_pk_unique(self.database,'unique','')
# self.fun_pk_last_init(self.database,'last','')
# self.fun_pk_last(self.database,'last','')
# self.fun_pk_last(self.database,'last_row','')
# self.fun_pk_first(self.database,'first','')
# self.query_pk_fun(self.database,'')
# self.touying_pk_1(self.database,1)
# self.touying_pk_where(self.database,'')
# self.touying_pk_where(self.database,'tags')
# self.touying_pk_where(self.database,'distinct')
# self.count_pk(self.database,1)
endTime = time.time()
print("total time %ds" % (endTime - startTime))
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,52 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from util.cases import tdCases
from .primary_ts_base import *
from faker import Faker
import random
class TDTestCase(TDTestCase):
def run(self):
startTime = time.time()
self.dropandcreateDB_primary_key(self.database, 1 , 1 ,'yes','yes','no')
# self.fun_pk_interp(self.database,'interp','')
# self.multiple_agg_groupby(self.database,1)
# self.fun_pk_diff(self.database,'diff','')
# self.fun_pk_twa(self.database,'derivative',',1s,0')
# self.fun_pk_twa(self.database,'derivative',',1s,1')
# self.fun_pk_unique(self.database,'unique','')
self.fun_pk_last_init(self.database,'last','')
self.fun_pk_last(self.database,'last','')
self.fun_pk_last(self.database,'last_row','')
self.fun_pk_first(self.database,'first','')
self.query_pk_fun(self.database,'')
# self.touying_pk_1(self.database,1)
# self.touying_pk_where(self.database,'')
# self.touying_pk_where(self.database,'tags')
# self.touying_pk_where(self.database,'distinct')
# self.count_pk(self.database,1)
endTime = time.time()
print("total time %ds" % (endTime - startTime))
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,52 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from util.cases import tdCases
from .primary_ts_base import *
from faker import Faker
import random
class TDTestCase(TDTestCase):
def run(self):
startTime = time.time()
self.dropandcreateDB_primary_key(self.database, 1 , 1 ,'yes','yes','no')
# self.fun_pk_interp(self.database,'interp','')
# self.multiple_agg_groupby(self.database,1)
# self.fun_pk_diff(self.database,'diff','')
# self.fun_pk_twa(self.database,'derivative',',1s,0')
# self.fun_pk_twa(self.database,'derivative',',1s,1')
# self.fun_pk_unique(self.database,'unique','')
# self.fun_pk_last_init(self.database,'last','')
# self.fun_pk_last(self.database,'last','')
# self.fun_pk_last(self.database,'last_row','')
# self.fun_pk_first(self.database,'first','')
# self.query_pk_fun(self.database,'')
self.touying_pk_1(self.database,1)
self.touying_pk_where(self.database,'')
# self.touying_pk_where(self.database,'tags')
# self.touying_pk_where(self.database,'distinct')
# self.count_pk(self.database,1)
endTime = time.time()
print("total time %ds" % (endTime - startTime))
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,52 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from util.cases import tdCases
from .primary_ts_base import *
from faker import Faker
import random
class TDTestCase(TDTestCase):
def run(self):
startTime = time.time()
self.dropandcreateDB_primary_key(self.database, 1 , 1 ,'yes','yes','no')
# self.fun_pk_interp(self.database,'interp','')
# self.multiple_agg_groupby(self.database,1)
# self.fun_pk_diff(self.database,'diff','')
# self.fun_pk_twa(self.database,'derivative',',1s,0')
# self.fun_pk_twa(self.database,'derivative',',1s,1')
# self.fun_pk_unique(self.database,'unique','')
# self.fun_pk_last_init(self.database,'last','')
# self.fun_pk_last(self.database,'last','')
# self.fun_pk_last(self.database,'last_row','')
# self.fun_pk_first(self.database,'first','')
# self.query_pk_fun(self.database,'')
# self.touying_pk_1(self.database,1)
# self.touying_pk_where(self.database,'')
self.touying_pk_where(self.database,'tags')
self.touying_pk_where(self.database,'distinct')
self.count_pk(self.database,1)
endTime = time.time()
print("total time %ds" % (endTime - startTime))
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -429,7 +429,7 @@ void printfIntroduction(bool community) {
printf(" * ------------------------------------------------------------------------------------ *\n");
printf(" * You are using TDengine OSS. To experience advanced features, like backup/restore, *\n");
printf(" * privilege control and more, or receive 7x24 technical support, try TDengine *\n");
printf(" * Enterprise or Free Cloud Trial. Learn more at https://tdengine.com *\n");
printf(" * Enterprise or TDengine Cloud. Learn more at https://tdengine.com *\n");
}
printf(" ****************************************************************************************\n\n");
}
@ -438,7 +438,7 @@ void printfIntroduction(bool community) {
void showAD(bool end) {
printf(" You are using TDengine OSS. To experience advanced features, like backup/restore, \n");
printf(" privilege control and more, or receive 7x24 technical support, try TDengine Enterprise \n");
printf(" or Free Cloud Trial. Learn more at https://tdengine.com \n");
printf(" or TDengine Cloud. Learn more at https://tdengine.com \n");
printf(" \n");
}