merge from 3.0
This commit is contained in:
commit
bdbf365ed0
|
@ -207,7 +207,7 @@ typedef struct {
|
|||
// Submit message for one table
|
||||
typedef struct SSubmitBlk {
|
||||
int64_t uid; // table unique id
|
||||
int32_t tid; // table id
|
||||
int64_t suid; // stable id
|
||||
int32_t padding; // TODO just for padding here
|
||||
int32_t sversion; // data schema version
|
||||
int32_t dataLen; // data part length, not including the SSubmitBlk head
|
||||
|
@ -232,12 +232,12 @@ typedef struct {
|
|||
} SSubmitBlkIter;
|
||||
|
||||
typedef struct {
|
||||
int32_t totalLen;
|
||||
int32_t len;
|
||||
void* pMsg;
|
||||
int32_t totalLen;
|
||||
int32_t len;
|
||||
const void* pMsg;
|
||||
} SSubmitMsgIter;
|
||||
|
||||
int32_t tInitSubmitMsgIter(SSubmitReq* pMsg, SSubmitMsgIter* pIter);
|
||||
int32_t tInitSubmitMsgIter(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
|
||||
int32_t tGetSubmitMsgNext(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
|
||||
int32_t tInitSubmitBlkIter(SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
|
||||
STSRow* tGetSubmitBlkNext(SSubmitBlkIter* pIter);
|
||||
|
@ -2093,6 +2093,11 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW) {
|
|||
}
|
||||
}
|
||||
|
||||
static FORCE_INLINE void tdFreeTSmaWrapper(STSmaWrapper* pSW) {
|
||||
tdDestroyTSmaWrapper(pSW);
|
||||
tfree(pSW);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) {
|
||||
int32_t tlen = 0;
|
||||
|
||||
|
|
|
@ -159,6 +159,7 @@ typedef struct {
|
|||
(IS_SIGNED_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
|
||||
#define IS_CONVERT_AS_UNSIGNED(_t) (IS_UNSIGNED_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL))
|
||||
|
||||
// TODO remove this function
|
||||
static FORCE_INLINE bool isNull(const void *val, int32_t type) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
|
|
|
@ -199,6 +199,7 @@ typedef struct SIndexOptions {
|
|||
typedef struct SCreateIndexStmt {
|
||||
ENodeType type;
|
||||
EIndexType indexType;
|
||||
bool ignoreExists;
|
||||
char indexName[TSDB_INDEX_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
SNodeList* pCols;
|
||||
|
@ -207,6 +208,7 @@ typedef struct SCreateIndexStmt {
|
|||
|
||||
typedef struct SDropIndexStmt {
|
||||
ENodeType type;
|
||||
bool ignoreNotExists;
|
||||
char indexName[TSDB_INDEX_NAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
} SDropIndexStmt;
|
||||
|
|
|
@ -60,6 +60,8 @@ int32_t qParseQuerySql(SParseContext* pCxt, SQuery** pQuery);
|
|||
|
||||
void qDestroyQuery(SQuery* pQueryNode);
|
||||
|
||||
int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -453,6 +453,10 @@ enum {
|
|||
SND_WORKER_TYPE__UNIQUE,
|
||||
};
|
||||
|
||||
#define MND_VGID -1
|
||||
#define QND_VGID 1
|
||||
#define VND_VGID 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -84,6 +84,8 @@ typedef uint16_t VarDataLenT; // maxVarDataLen: 32767
|
|||
#define varDataLen(v) ((VarDataLenT *)(v))[0]
|
||||
#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE)
|
||||
|
||||
#define NCHAR_WIDTH_TO_BYTES(n) ((n) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE)
|
||||
|
||||
typedef int32_t VarDataOffsetT;
|
||||
|
||||
typedef struct tstr {
|
||||
|
|
|
@ -155,6 +155,7 @@ typedef struct SReqResultInfo {
|
|||
TAOS_FIELD* fields;
|
||||
uint32_t numOfCols;
|
||||
int32_t* length;
|
||||
char** convertBuf;
|
||||
TAOS_ROW row;
|
||||
SResultColumn* pCol;
|
||||
uint32_t numOfRows;
|
||||
|
|
|
@ -169,6 +169,13 @@ static void doFreeReqResultInfo(SReqResultInfo *pResInfo) {
|
|||
tfree(pResInfo->row);
|
||||
tfree(pResInfo->pCol);
|
||||
tfree(pResInfo->fields);
|
||||
|
||||
if (pResInfo->convertBuf != NULL) {
|
||||
for (int32_t i = 0; i < pResInfo->numOfCols; ++i) {
|
||||
tfree(pResInfo->convertBuf[i]);
|
||||
}
|
||||
tfree(pResInfo->convertBuf);
|
||||
}
|
||||
}
|
||||
|
||||
static void doDestroyRequest(void *p) {
|
||||
|
|
|
@ -634,18 +634,30 @@ _return:
|
|||
for (int32_t i = 0; i < pResultInfo->numOfCols; ++i) {
|
||||
SResultColumn* pCol = &pResultInfo->pCol[i];
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
||||
int32_t type = pResultInfo->fields[i].type;
|
||||
int32_t bytes = pResultInfo->fields[i].bytes;
|
||||
|
||||
if (IS_VAR_DATA_TYPE(type)) {
|
||||
if (pCol->offset[pResultInfo->current] != -1) {
|
||||
char* pStart = pResultInfo->pCol[i].offset[pResultInfo->current] + pResultInfo->pCol[i].pData;
|
||||
|
||||
pResultInfo->length[i] = varDataLen(pStart);
|
||||
pResultInfo->row[i] = varDataVal(pStart);
|
||||
|
||||
if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(pResultInfo->convertBuf[i]));
|
||||
ASSERT(len <= bytes);
|
||||
|
||||
pResultInfo->row[i] = varDataVal(pResultInfo->convertBuf[i]);
|
||||
varDataSetLen(pResultInfo->convertBuf[i], len);
|
||||
pResultInfo->length[i] = len;
|
||||
}
|
||||
} else {
|
||||
pResultInfo->row[i] = NULL;
|
||||
}
|
||||
} else {
|
||||
if (!colDataIsNull_f(pCol->nullbitmap, pResultInfo->current)) {
|
||||
pResultInfo->row[i] = pResultInfo->pCol[i].pData + pResultInfo->fields[i].bytes * pResultInfo->current;
|
||||
pResultInfo->row[i] = pResultInfo->pCol[i].pData + bytes * pResultInfo->current;
|
||||
} else {
|
||||
pResultInfo->row[i] = NULL;
|
||||
}
|
||||
|
@ -661,13 +673,20 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) {
|
|||
pResInfo->row = calloc(pResInfo->numOfCols, POINTER_BYTES);
|
||||
pResInfo->pCol = calloc(pResInfo->numOfCols, sizeof(SResultColumn));
|
||||
pResInfo->length = calloc(pResInfo->numOfCols, sizeof(int32_t));
|
||||
pResInfo->convertBuf = calloc(pResInfo->numOfCols, POINTER_BYTES);
|
||||
|
||||
if (pResInfo->row == NULL || pResInfo->pCol == NULL || pResInfo->length == NULL || pResInfo->convertBuf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for(int32_t i = 0; i < pResInfo->numOfCols; ++i) {
|
||||
if(pResInfo->fields[i].type == TSDB_DATA_TYPE_NCHAR) {
|
||||
pResInfo->convertBuf[i] = calloc(1, NCHAR_WIDTH_TO_BYTES(pResInfo->fields[i].bytes));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pResInfo->row == NULL || pResInfo->pCol == NULL || pResInfo->length == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows) {
|
||||
|
|
|
@ -52,7 +52,7 @@ TEST(testCase, driverInit_Test) {
|
|||
// taosInitGlobalCfg();
|
||||
// taos_init();
|
||||
}
|
||||
|
||||
#if 0
|
||||
TEST(testCase, connect_Test) {
|
||||
// taos_options(TSDB_OPTION_CONFIGDIR, "/home/ubuntu/first/cfg");
|
||||
|
||||
|
@ -652,6 +652,7 @@ TEST(testCase, projection_query_stables) {
|
|||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(testCase, agg_query_tables) {
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
|
@ -660,7 +661,7 @@ TEST(testCase, agg_query_tables) {
|
|||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "select count(*), sum(k),min(k),max(k) from tu");
|
||||
pRes = taos_query(pConn, "select count(*) from tu");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
|
|
|
@ -180,6 +180,10 @@ static int32_t taosSetTfsCfg(SConfig *pCfg) {
|
|||
memcpy(&tsDiskCfg[index], pCfg, sizeof(SDiskCfg));
|
||||
if (pCfg->level == 0 && pCfg->primary == 1) {
|
||||
tstrncpy(tsDataDir, pCfg->dir, PATH_MAX);
|
||||
if (taosMkDir(tsDataDir) != 0) {
|
||||
uError("failed to create dataDir:%s since %s", tsDataDir, terrstr());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (taosMkDir(pCfg->dir) != 0) {
|
||||
uError("failed to create tfsDir:%s since %s", tsDataDir, terrstr());
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#undef TD_MSG_SEG_CODE_
|
||||
#include "tmsgdef.h"
|
||||
|
||||
int32_t tInitSubmitMsgIter(SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
|
||||
int32_t tInitSubmitMsgIter(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
|
||||
if (pMsg == NULL) {
|
||||
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
|
||||
return -1;
|
||||
|
|
|
@ -458,16 +458,21 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
|
|||
if (duration == 0) {
|
||||
return t;
|
||||
}
|
||||
if (unit == 'y') {
|
||||
duration *= 12;
|
||||
} else if (unit != 'n') {
|
||||
|
||||
if (unit != 'n' && unit != 'y') {
|
||||
return t + duration;
|
||||
}
|
||||
|
||||
// The following code handles the y/n time duration
|
||||
int64_t numOfMonth = duration;
|
||||
if (unit == 'y') {
|
||||
numOfMonth *= 12;
|
||||
}
|
||||
|
||||
struct tm tm;
|
||||
time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision));
|
||||
taosLocalTime(&tt, &tm);
|
||||
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)duration;
|
||||
int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)numOfMonth;
|
||||
tm.tm_year = mon / 12;
|
||||
tm.tm_mon = mon % 12;
|
||||
|
||||
|
@ -557,8 +562,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
|
|||
|
||||
// not enough time range
|
||||
if (start < 0 || INT64_MAX - start > pInterval->interval - 1) {
|
||||
end = start + pInterval->interval - 1;
|
||||
|
||||
end = taosTimeAdd(start, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||
while (end < t && ((start + pInterval->sliding) <= INT64_MAX)) { // move forward to the correct time window
|
||||
start += pInterval->sliding;
|
||||
|
||||
|
@ -574,12 +578,23 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
|
|||
}
|
||||
}
|
||||
|
||||
ASSERT(pInterval->offset >= 0);
|
||||
|
||||
if (pInterval->offset > 0) {
|
||||
start = taosTimeAdd(start, pInterval->offset, pInterval->offsetUnit, precision);
|
||||
if (start > t) {
|
||||
start = taosTimeAdd(start, -pInterval->interval, pInterval->intervalUnit, precision);
|
||||
} else {
|
||||
// try to move current window to the left-hande-side, due to the offset effect.
|
||||
int64_t end = taosTimeAdd(start, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||
ASSERT(end >= t);
|
||||
end = taosTimeAdd(end, -pInterval->sliding, pInterval->slidingUnit, precision);
|
||||
if (end >= t) {
|
||||
start = taosTimeAdd(start, -pInterval->sliding, pInterval->slidingUnit, precision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,11 @@ int32_t bmStartWorker(SBnodeMgmt *pMgmt) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
dDebug("bnode workers are initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bmStopWorker(SBnodeMgmt *pMgmt) { tMultiWorkerCleanup(&pMgmt->writeWorker); }
|
||||
void bmStopWorker(SBnodeMgmt *pMgmt) {
|
||||
tMultiWorkerCleanup(&pMgmt->writeWorker);
|
||||
dDebug("bnode workers are closed");
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "os.h"
|
||||
|
||||
#include "cJSON.h"
|
||||
#include "monitor.h"
|
||||
#include "tcache.h"
|
||||
#include "tcrc32c.h"
|
||||
#include "tdatablock.h"
|
||||
|
@ -36,8 +35,7 @@
|
|||
#include "tworker.h"
|
||||
|
||||
#include "dnode.h"
|
||||
#include "tfs.h"
|
||||
#include "wal.h"
|
||||
#include "monitor.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -53,7 +51,6 @@ extern "C" {
|
|||
typedef enum { DNODE, VNODES, QNODE, SNODE, MNODE, BNODE, NODE_MAX } ENodeType;
|
||||
typedef enum { DND_STAT_INIT, DND_STAT_RUNNING, DND_STAT_STOPPED } EDndStatus;
|
||||
typedef enum { DND_ENV_INIT, DND_ENV_READY, DND_ENV_CLEANUP } EEnvStatus;
|
||||
typedef enum { DND_WORKER_SINGLE, DND_WORKER_MULTI } EWorkerType;
|
||||
typedef enum { PROC_SINGLE, PROC_CHILD, PROC_PARENT } EProcType;
|
||||
|
||||
typedef struct SMgmtFp SMgmtFp;
|
||||
|
@ -75,10 +72,8 @@ typedef int32_t (*DropNodeFp)(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
|
|||
typedef int32_t (*RequireNodeFp)(SMgmtWrapper *pWrapper, bool *required);
|
||||
|
||||
typedef struct SMsgHandle {
|
||||
int32_t vgId;
|
||||
NodeMsgFp vgIdMsgFp;
|
||||
SMgmtWrapper *pVgIdWrapper; // Handle the case where the same message type is distributed to qnode or vnode
|
||||
NodeMsgFp msgFp;
|
||||
SMgmtWrapper *pQndWrapper;
|
||||
SMgmtWrapper *pMndWrapper;
|
||||
SMgmtWrapper *pWrapper;
|
||||
} SMsgHandle;
|
||||
|
||||
|
@ -129,29 +124,30 @@ typedef struct SDnode {
|
|||
bool dropped;
|
||||
EDndStatus status;
|
||||
EDndEvent event;
|
||||
EProcType procType;
|
||||
SStartupReq startup;
|
||||
TdFilePtr pLockFile;
|
||||
STransMgmt trans;
|
||||
SMgmtWrapper wrappers[NODE_MAX];
|
||||
} SDnode;
|
||||
|
||||
EDndStatus dndGetStatus(SDnode *pDnode);
|
||||
void dndSetStatus(SDnode *pDnode, EDndStatus stat);
|
||||
SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, ENodeType nodeType);
|
||||
void dndSetMsgHandle(SMgmtWrapper *pWrapper, int32_t msgType, NodeMsgFp nodeMsgFp, int32_t vgId);
|
||||
void dndReportStartup(SDnode *pDnode, char *pName, char *pDesc);
|
||||
void dndSendMonitorReport(SDnode *pDnode);
|
||||
EDndStatus dndGetStatus(SDnode *pDnode);
|
||||
void dndSetStatus(SDnode *pDnode, EDndStatus stat);
|
||||
void dndSetMsgHandle(SMgmtWrapper *pWrapper, int32_t msgType, NodeMsgFp nodeMsgFp, int32_t vgId);
|
||||
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc);
|
||||
void dndSendMonitorReport(SDnode *pDnode);
|
||||
|
||||
int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pMsg);
|
||||
int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, SEpSet *pEpSet, SRpcMsg *pMsg);
|
||||
void dndSendRsp(SMgmtWrapper *pWrapper, SRpcMsg *pRsp);
|
||||
|
||||
int32_t dndProcessNodeMsg(SDnode *pDnode, SNodeMsg *pMsg);
|
||||
|
||||
int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed);
|
||||
int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed);
|
||||
|
||||
SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, ENodeType nodeType);
|
||||
int32_t dndMarkWrapper(SMgmtWrapper *pWrapper);
|
||||
void dndReleaseWrapper(SMgmtWrapper *pWrapper);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,7 +34,7 @@ int32_t dndInit();
|
|||
void dndCleanup();
|
||||
const char *dndStatStr(EDndStatus stat);
|
||||
void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup);
|
||||
TdFilePtr dndCheckRunning(char *dataDir);
|
||||
TdFilePtr dndCheckRunning(const char *dataDir);
|
||||
void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pMsg);
|
||||
|
||||
// dndMsg.c
|
||||
|
@ -50,10 +50,6 @@ SDnode *dndCreate(const SDnodeOpt *pOption);
|
|||
void dndClose(SDnode *pDnode);
|
||||
void dndHandleEvent(SDnode *pDnode, EDndEvent event);
|
||||
|
||||
SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, ENodeType nodeType);
|
||||
int32_t dndMarkWrapper(SMgmtWrapper *pWrapper);
|
||||
void dndReleaseWrapper(SMgmtWrapper *pWrapper);
|
||||
|
||||
// dndTransport.c
|
||||
int32_t dndInitServer(SDnode *pDnode);
|
||||
void dndCleanupServer(SDnode *pDnode);
|
||||
|
|
|
@ -50,16 +50,23 @@ int32_t dndOpenNode(SMgmtWrapper *pWrapper) {
|
|||
}
|
||||
|
||||
void dndCloseNode(SMgmtWrapper *pWrapper) {
|
||||
dDebug("node:%s, start to close", pWrapper->name);
|
||||
taosWLockLatch(&pWrapper->latch);
|
||||
if (pWrapper->deployed) {
|
||||
(*pWrapper->fp.closeFp)(pWrapper);
|
||||
pWrapper->deployed = false;
|
||||
}
|
||||
taosWUnLockLatch(&pWrapper->latch);
|
||||
|
||||
while (pWrapper->refCount > 0) {
|
||||
taosMsleep(10);
|
||||
}
|
||||
|
||||
if (pWrapper->pProc) {
|
||||
taosProcCleanup(pWrapper->pProc);
|
||||
pWrapper->pProc = NULL;
|
||||
}
|
||||
taosWUnLockLatch(&pWrapper->latch);
|
||||
dDebug("node:%s, has been closed", pWrapper->name);
|
||||
}
|
||||
|
||||
static int32_t dndRunInSingleProcess(SDnode *pDnode) {
|
||||
|
|
|
@ -15,11 +15,12 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "dndInt.h"
|
||||
#include "wal.h"
|
||||
|
||||
static int8_t once = DND_ENV_INIT;
|
||||
|
||||
int32_t dndInit() {
|
||||
dDebug("start to init dnode env");
|
||||
dInfo("start to init dnode env");
|
||||
if (atomic_val_compare_exchange_8(&once, DND_ENV_INIT, DND_ENV_READY) != DND_ENV_INIT) {
|
||||
terrno = TSDB_CODE_REPEAT_INIT;
|
||||
dError("failed to init dnode env since %s", terrstr());
|
||||
|
@ -52,7 +53,7 @@ int32_t dndInit() {
|
|||
}
|
||||
|
||||
void dndCleanup() {
|
||||
dDebug("start to cleanup dnode env");
|
||||
dInfo("start to cleanup dnode env");
|
||||
if (atomic_val_compare_exchange_8(&once, DND_ENV_READY, DND_ENV_CLEANUP) != DND_ENV_READY) {
|
||||
dError("dnode env is already cleaned up");
|
||||
return;
|
||||
|
@ -92,7 +93,7 @@ const char *dndStatStr(EDndStatus status) {
|
|||
}
|
||||
}
|
||||
|
||||
void dndReportStartup(SDnode *pDnode, char *pName, char *pDesc) {
|
||||
void dndReportStartup(SDnode *pDnode, const char *pName, const char *pDesc) {
|
||||
SStartupReq *pStartup = &pDnode->startup;
|
||||
tstrncpy(pStartup->name, pName, TSDB_STEP_NAME_LEN);
|
||||
tstrncpy(pStartup->desc, pDesc, TSDB_STEP_DESC_LEN);
|
||||
|
@ -104,21 +105,21 @@ void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup) {
|
|||
pStartup->finished = (dndGetStatus(pDnode) == DND_STAT_RUNNING);
|
||||
}
|
||||
|
||||
TdFilePtr dndCheckRunning(char *dataDir) {
|
||||
TdFilePtr dndCheckRunning(const char *dataDir) {
|
||||
char filepath[PATH_MAX] = {0};
|
||||
snprintf(filepath, sizeof(filepath), "%s/.running", dataDir);
|
||||
|
||||
TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to lock file:%s since %s, quit", filepath, terrstr());
|
||||
dError("failed to lock file:%s since %s", filepath, terrstr());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t ret = taosLockFile(pFile);
|
||||
if (ret != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
dError("failed to lock file:%s since %s, quit", filepath, terrstr());
|
||||
dError("failed to lock file:%s since %s", filepath, terrstr());
|
||||
taosCloseFile(&pFile);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -129,12 +130,10 @@ TdFilePtr dndCheckRunning(char *dataDir) {
|
|||
|
||||
void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
|
||||
dDebug("startup req is received");
|
||||
|
||||
SStartupReq *pStartup = rpcMallocCont(sizeof(SStartupReq));
|
||||
dndGetStartup(pDnode, pStartup);
|
||||
|
||||
dDebug("startup req is sent, step:%s desc:%s finished:%d", pStartup->name, pStartup->desc, pStartup->finished);
|
||||
|
||||
SRpcMsg rpcRsp = {.handle = pReq->handle, .pCont = pStartup, .contLen = sizeof(SStartupReq)};
|
||||
rpcSendResponse(&rpcRsp);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,12 @@ static int32_t dndGetMonitorDiskInfo(SDnode *pDnode, SMonDiskInfo *pInfo) {
|
|||
tstrncpy(pInfo->tempdir.name, tsTempDir, sizeof(pInfo->tempdir.name));
|
||||
pInfo->tempdir.size = tsTempSpace.size;
|
||||
|
||||
return vmMonitorTfsInfo(dndAcquireWrapper(pDnode, VNODES), pInfo);
|
||||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, VNODES);
|
||||
if (pWrapper != NULL) {
|
||||
vmMonitorTfsInfo(pWrapper, pInfo);
|
||||
dndReleaseWrapper(pWrapper);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dndGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) {
|
||||
|
@ -45,8 +50,17 @@ static void dndGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
|
|||
taosGetCardInfo(&pInfo->net_in, &pInfo->net_out);
|
||||
taosGetProcIO(&pInfo->io_read, &pInfo->io_write, &pInfo->io_read_disk, &pInfo->io_write_disk);
|
||||
|
||||
vmMonitorVnodeReqs(dndAcquireWrapper(pDnode, VNODES), pInfo);
|
||||
pInfo->has_mnode = (dndAcquireWrapper(pDnode, MNODE)->required);
|
||||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, VNODES);
|
||||
if (pWrapper != NULL) {
|
||||
vmMonitorVnodeReqs(pWrapper, pInfo);
|
||||
dndReleaseWrapper(pWrapper);
|
||||
}
|
||||
|
||||
pWrapper = dndAcquireWrapper(pDnode, MNODE);
|
||||
if (pWrapper != NULL) {
|
||||
pInfo->has_mnode = pWrapper->required;
|
||||
dndReleaseWrapper(pWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
void dndSendMonitorReport(SDnode *pDnode) {
|
||||
|
@ -63,10 +77,15 @@ void dndSendMonitorReport(SDnode *pDnode) {
|
|||
SMonClusterInfo clusterInfo = {0};
|
||||
SMonVgroupInfo vgroupInfo = {0};
|
||||
SMonGrantInfo grantInfo = {0};
|
||||
if (mmMonitorMnodeInfo(dndAcquireWrapper(pDnode, MNODE), &clusterInfo, &vgroupInfo, &grantInfo) == 0) {
|
||||
monSetClusterInfo(pMonitor, &clusterInfo);
|
||||
monSetVgroupInfo(pMonitor, &vgroupInfo);
|
||||
monSetGrantInfo(pMonitor, &grantInfo);
|
||||
|
||||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, MNODE);
|
||||
if (pWrapper != NULL) {
|
||||
if (mmMonitorMnodeInfo(pWrapper, &clusterInfo, &vgroupInfo, &grantInfo) == 0) {
|
||||
monSetClusterInfo(pMonitor, &clusterInfo);
|
||||
monSetVgroupInfo(pMonitor, &vgroupInfo);
|
||||
monSetGrantInfo(pMonitor, &grantInfo);
|
||||
}
|
||||
dndReleaseWrapper(pWrapper);
|
||||
}
|
||||
|
||||
SMonDnodeInfo dnodeInfo = {0};
|
||||
|
|
|
@ -20,8 +20,8 @@ static void dndUpdateMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
|
|||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, DNODE);
|
||||
if (pWrapper != NULL) {
|
||||
dmUpdateMnodeEpSet(pWrapper->pMgmt, pEpSet);
|
||||
dndReleaseWrapper(pWrapper);
|
||||
}
|
||||
dndReleaseWrapper(pWrapper);
|
||||
}
|
||||
|
||||
static inline NodeMsgFp dndGetMsgFp(SMgmtWrapper *pWrapper, SRpcMsg *pRpc) {
|
||||
|
|
|
@ -58,7 +58,7 @@ static void dndClearMemory(SDnode *pDnode) {
|
|||
SDnode *dndCreate(const SDnodeOpt *pOption) {
|
||||
dInfo("start to create dnode object");
|
||||
int32_t code = -1;
|
||||
char path[PATH_MAX];
|
||||
char path[PATH_MAX] = {0};
|
||||
SDnode *pDnode = NULL;
|
||||
|
||||
pDnode = calloc(1, sizeof(SDnode));
|
||||
|
@ -117,6 +117,7 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
|
|||
_OVER:
|
||||
if (code != 0 && pDnode) {
|
||||
dndClearMemory(pDnode);
|
||||
pDnode = NULL;
|
||||
dError("failed to create dnode object since %s", terrstr());
|
||||
} else {
|
||||
dInfo("dnode object is created, data:%p", pDnode);
|
||||
|
|
|
@ -20,13 +20,15 @@
|
|||
#define INTERNAL_CKEY "_key"
|
||||
#define INTERNAL_SECRET "_pwd"
|
||||
|
||||
static inline void dndProcessQVnodeRpcMsg(SMsgHandle *pHandle, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||
static inline void dndProcessQMVnodeRpcMsg(SMsgHandle *pHandle, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||
SMsgHead *pHead = pMsg->pCont;
|
||||
int32_t vgId = htonl(pHead->vgId);
|
||||
|
||||
SMgmtWrapper *pWrapper = pHandle->pWrapper;
|
||||
if (vgId == pHandle->vgId && pHandle->pVgIdWrapper != NULL) {
|
||||
pWrapper = pHandle->pVgIdWrapper;
|
||||
if (vgId == QND_VGID) {
|
||||
pWrapper = pHandle->pQndWrapper;
|
||||
} else if (vgId == MND_VGID) {
|
||||
pWrapper = pHandle->pMndWrapper;
|
||||
}
|
||||
|
||||
dTrace("msg:%s will be processed by %s, handle:%p app:%p vgId:%d", TMSG_INFO(pMsg->msgType), pWrapper->name,
|
||||
|
@ -46,13 +48,13 @@ static void dndProcessResponse(void *parent, SRpcMsg *pRsp, SEpSet *pEpSet) {
|
|||
}
|
||||
|
||||
SMsgHandle *pHandle = &pMgmt->msgHandles[TMSG_INDEX(msgType)];
|
||||
if (pHandle->msgFp != NULL) {
|
||||
if (pHandle->vgId == 0) {
|
||||
if (pHandle->pWrapper != NULL) {
|
||||
if (pHandle->pMndWrapper == NULL && pHandle->pQndWrapper == NULL) {
|
||||
dTrace("rsp:%s will be processed by %s, handle:%p app:%p code:0x%04x:%s", TMSG_INFO(msgType),
|
||||
pHandle->pWrapper->name, pRsp->handle, pRsp->ahandle, pRsp->code & 0XFFFF, tstrerror(pRsp->code));
|
||||
dndProcessRpcMsg(pHandle->pWrapper, pRsp, pEpSet);
|
||||
} else {
|
||||
dndProcessQVnodeRpcMsg(pHandle, pRsp, pEpSet);
|
||||
dndProcessQMVnodeRpcMsg(pHandle, pRsp, pEpSet);
|
||||
}
|
||||
} else {
|
||||
dError("rsp:%s not processed since no handle, handle:%p app:%p", TMSG_INFO(msgType), pRsp->handle, pRsp->ahandle);
|
||||
|
@ -126,13 +128,13 @@ static void dndProcessRequest(void *param, SRpcMsg *pReq, SEpSet *pEpSet) {
|
|||
}
|
||||
|
||||
SMsgHandle *pHandle = &pMgmt->msgHandles[TMSG_INDEX(msgType)];
|
||||
if (pHandle->msgFp != NULL) {
|
||||
if (pHandle->vgId == 0) {
|
||||
if (pHandle->pWrapper != NULL) {
|
||||
if (pHandle->pMndWrapper == NULL && pHandle->pQndWrapper == NULL) {
|
||||
dTrace("req:%s will be processed by %s, handle:%p app:%p", TMSG_INFO(msgType), pHandle->pWrapper->name,
|
||||
pReq->handle, pReq->ahandle);
|
||||
dndProcessRpcMsg(pHandle->pWrapper, pReq, pEpSet);
|
||||
} else {
|
||||
dndProcessQVnodeRpcMsg(pHandle, pReq, pEpSet);
|
||||
dndProcessQMVnodeRpcMsg(pHandle, pReq, pEpSet);
|
||||
}
|
||||
} else {
|
||||
dError("req:%s not processed since no handle, handle:%p app:%p", TMSG_INFO(msgType), pReq->handle, pReq->ahandle);
|
||||
|
@ -144,9 +146,14 @@ static void dndProcessRequest(void *param, SRpcMsg *pReq, SEpSet *pEpSet) {
|
|||
|
||||
static void dndSendMsgToMnodeRecv(SDnode *pDnode, SRpcMsg *pRpcMsg, SRpcMsg *pRpcRsp) {
|
||||
STransMgmt *pMgmt = &pDnode->trans;
|
||||
SEpSet epSet = {0};
|
||||
|
||||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, DNODE);
|
||||
if (pWrapper != NULL) {
|
||||
dmGetMnodeEpSet(pWrapper->pMgmt, &epSet);
|
||||
dndReleaseWrapper(pWrapper);
|
||||
}
|
||||
|
||||
SEpSet epSet = {0};
|
||||
dmGetMnodeEpSet(dndAcquireWrapper(pDnode, DNODE)->pMgmt, &epSet);
|
||||
rpcSendRecv(pMgmt->clientRpc, &epSet, pRpcMsg, pRpcRsp);
|
||||
}
|
||||
|
||||
|
@ -180,9 +187,14 @@ static int32_t dndRetrieveUserAuthInfo(void *parent, char *user, char *spi, char
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (mmGetUserAuth(dndAcquireWrapper(pDnode, MNODE), user, spi, encrypt, secret, ckey) == 0) {
|
||||
dTrace("user:%s, get auth from mnode, spi:%d encrypt:%d", user, *spi, *encrypt);
|
||||
return 0;
|
||||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, MNODE);
|
||||
if (pWrapper != NULL) {
|
||||
if (mmGetUserAuth(pWrapper, user, spi, encrypt, secret, ckey) == 0) {
|
||||
dndReleaseWrapper(pWrapper);
|
||||
dTrace("user:%s, get auth from mnode, spi:%d encrypt:%d", user, *spi, *encrypt);
|
||||
return 0;
|
||||
}
|
||||
dndReleaseWrapper(pWrapper);
|
||||
}
|
||||
|
||||
if (terrno != TSDB_CODE_APP_NOT_READY) {
|
||||
|
@ -269,21 +281,27 @@ int32_t dndInitMsgHandle(SDnode *pDnode) {
|
|||
int32_t vgId = pWrapper->msgVgIds[msgIndex];
|
||||
if (msgFp == NULL) continue;
|
||||
|
||||
// dTrace("msg:%s will be processed by %s, vgId:%d", tMsgInfo[msgIndex], pWrapper->name, vgId);
|
||||
|
||||
SMsgHandle *pHandle = &pMgmt->msgHandles[msgIndex];
|
||||
if (pHandle->msgFp != NULL && pHandle->vgId == vgId) {
|
||||
dError("msg:%s has multiple process nodes, prev node:%s:%d, curr node:%s:%d", tMsgInfo[msgIndex],
|
||||
pHandle->pWrapper->name, pHandle->pWrapper->msgVgIds[msgIndex], pWrapper->name, vgId);
|
||||
return -1;
|
||||
} else {
|
||||
dTrace("msg:%s will be processed by %s, vgId:%d", tMsgInfo[msgIndex], pWrapper->name, vgId);
|
||||
if (vgId == 0) {
|
||||
pHandle->msgFp = msgFp;
|
||||
pHandle->pWrapper = pWrapper;
|
||||
} else {
|
||||
pHandle->vgId = vgId;
|
||||
pHandle->vgIdMsgFp = msgFp;
|
||||
pHandle->pVgIdWrapper = pWrapper;
|
||||
if (vgId == QND_VGID) {
|
||||
if (pHandle->pQndWrapper != NULL) {
|
||||
dError("msg:%s has multiple process nodes", tMsgInfo[msgIndex]);
|
||||
return -1;
|
||||
}
|
||||
pHandle->pQndWrapper = pWrapper;
|
||||
} else if (vgId == MND_VGID) {
|
||||
if (pHandle->pMndWrapper != NULL) {
|
||||
dError("msg:%s has multiple process nodes", tMsgInfo[msgIndex]);
|
||||
return -1;
|
||||
}
|
||||
pHandle->pMndWrapper = pWrapper;
|
||||
} else {
|
||||
if (pHandle->pWrapper != NULL) {
|
||||
dError("msg:%s has multiple process nodes", tMsgInfo[msgIndex]);
|
||||
return -1;
|
||||
}
|
||||
pHandle->pWrapper = pWrapper;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -320,7 +338,12 @@ int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
|
|||
SDnode *pDnode = pWrapper->pDnode;
|
||||
STransMgmt *pTrans = &pDnode->trans;
|
||||
SEpSet epSet = {0};
|
||||
dmGetMnodeEpSet(dndAcquireWrapper(pDnode, DNODE)->pMgmt, &epSet);
|
||||
|
||||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, DNODE);
|
||||
if (pWrapper != NULL) {
|
||||
dmGetMnodeEpSet(pWrapper->pMgmt, &epSet);
|
||||
dndReleaseWrapper(pWrapper);
|
||||
}
|
||||
return dndSendRpcReq(pTrans, &epSet, pReq);
|
||||
}
|
||||
}
|
||||
|
@ -328,7 +351,12 @@ int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
|
|||
void dndSendRpcRsp(SMgmtWrapper *pWrapper, SRpcMsg *pRsp) {
|
||||
if (pRsp->code == TSDB_CODE_APP_NOT_READY) {
|
||||
SMgmtWrapper *pDnodeWrapper = dndAcquireWrapper(pWrapper->pDnode, DNODE);
|
||||
dmSendRedirectRsp(pDnodeWrapper->pMgmt, pRsp);
|
||||
if (pDnodeWrapper != NULL) {
|
||||
dmSendRedirectRsp(pDnodeWrapper->pMgmt, pRsp);
|
||||
dndReleaseWrapper(pDnodeWrapper);
|
||||
} else {
|
||||
rpcSendResponse(pRsp);
|
||||
}
|
||||
} else {
|
||||
rpcSendResponse(pRsp);
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) {
|
|||
}
|
||||
|
||||
pMgmt->updateTime = taosGetTimestampMs();
|
||||
dDebug("successed to write %s", file);
|
||||
dDebug("successed to write %s", realfile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,14 +74,14 @@ void dmSendRedirectRsp(SDnodeMgmt *pMgmt, SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
static int32_t dmStart(SMgmtWrapper *pWrapper) {
|
||||
dDebug("dnode mgmt start to run");
|
||||
dDebug("dnode-mgmt start to run");
|
||||
return dmStartThread(pWrapper->pMgmt);
|
||||
}
|
||||
|
||||
int32_t dmInit(SMgmtWrapper *pWrapper) {
|
||||
SDnode *pDnode = pWrapper->pDnode;
|
||||
SDnodeMgmt *pMgmt = calloc(1, sizeof(SDnodeMgmt));
|
||||
dInfo("dnode-mgmt is initialized");
|
||||
dInfo("dnode-mgmt start to init");
|
||||
|
||||
pDnode->dnodeId = 0;
|
||||
pDnode->dropped = 0;
|
||||
|
|
|
@ -41,8 +41,12 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
|||
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
|
||||
taosRUnLockLatch(&pMgmt->latch);
|
||||
|
||||
req.pVloads = taosArrayInit(TSDB_MAX_VNODES, sizeof(SVnodeLoad));
|
||||
vmMonitorVnodeLoads(dndAcquireWrapper(pDnode, VNODES), req.pVloads);
|
||||
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, VNODES);
|
||||
if (pWrapper != NULL) {
|
||||
req.pVloads = taosArrayInit(TSDB_MAX_VNODES, sizeof(SVnodeLoad));
|
||||
vmMonitorVnodeLoads(pWrapper, req.pVloads);
|
||||
dndReleaseWrapper(pWrapper);
|
||||
}
|
||||
|
||||
int32_t contLen = tSerializeSStatusReq(NULL, 0, &req);
|
||||
void *pHead = rpcMallocCont(contLen);
|
||||
|
@ -114,19 +118,19 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
|||
|
||||
void dmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||
// Requests handled by DNODE
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_NETWORK_TEST, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_NETWORK_TEST, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||
|
||||
// Requests handled by MNODE
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_STATUS_RSP, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT_RSP, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH_RSP, (NodeMsgFp)dmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_STATUS_RSP, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT_RSP, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH_RSP, (NodeMsgFp)dmProcessMgmtMsg, VND_VGID);
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ int32_t dmStartWorker(SDnodeMgmt *pMgmt) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
dDebug("dnode workers are initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -136,6 +137,7 @@ void dmStopWorker(SDnodeMgmt *pMgmt) {
|
|||
taosDestoryThread(pMgmt->threadId);
|
||||
pMgmt->threadId = NULL;
|
||||
}
|
||||
dDebug("dnode workers are closed");
|
||||
}
|
||||
|
||||
int32_t dmProcessMgmtMsg(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
||||
|
@ -144,6 +146,6 @@ int32_t dmProcessMgmtMsg(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
|||
pWorker = &pMgmt->statusWorker;
|
||||
}
|
||||
|
||||
dTrace("msg:%p, will be written to worker %s", pMsg, pWorker->name);
|
||||
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
||||
return taosWriteQitem(pWorker->queue, pMsg);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mmInt.h"
|
||||
#include "wal.h"
|
||||
|
||||
static bool mmDeployRequired(SDnode *pDnode) {
|
||||
if (pDnode->dnodeId > 0) return false;
|
||||
|
@ -226,7 +227,7 @@ static int32_t mmOpen(SMgmtWrapper *pWrapper) {
|
|||
}
|
||||
|
||||
static int32_t mmStart(SMgmtWrapper *pWrapper) {
|
||||
dDebug("mnode mgmt start to run");
|
||||
dDebug("mnode-mgmt start to run");
|
||||
SMnodeMgmt *pMgmt = pWrapper->pMgmt;
|
||||
return mndStart(pMgmt->pMnode);
|
||||
}
|
||||
|
|
|
@ -75,84 +75,90 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
|
|||
|
||||
void mmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||
// Requests handled by DNODE
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_MNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_QNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_QNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_SNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_SNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_BNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_BNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CONFIG_DNODE_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
|
||||
// Requests handled by MNODE
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CONNECT, (NodeMsgFp)mmProcessReadMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_ACCT, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_ACCT, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_ACCT, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_USER, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_USER, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_USER, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_GET_USER_AUTH, (NodeMsgFp)mmProcessReadMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CONFIG_DNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_MNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_MNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_QNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_QNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_BNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_BNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_USE_DB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_DB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_SYNC_DB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_COMPACT_DB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_FUNC, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_RETRIEVE_FUNC, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_FUNC, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_STB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_STB, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SMA, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SMA, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_TABLE_META, (NodeMsgFp)mmProcessReadMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_VGROUP_LIST, (NodeMsgFp)mmProcessReadMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW, (NodeMsgFp)mmProcessReadMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW_RETRIEVE, (NodeMsgFp)mmProcessReadMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, (NodeMsgFp)mmProcessReadMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_STATUS, (NodeMsgFp)mmProcessReadMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH, (NodeMsgFp)mmProcessReadMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_TOPIC, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_TOPIC, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_TOPIC, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_SUBSCRIBE, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_MQ_COMMIT_OFFSET, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_GET_SUB_EP, (NodeMsgFp)mmProcessReadMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STREAM, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CONNECT, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_ACCT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_ACCT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_ACCT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_USER, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_USER, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_USER, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_GET_USER_AUTH, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CONFIG_DNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_MNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_MNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_QNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_QNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_BNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_BNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_USE_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_SYNC_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_COMPACT_DB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_FUNC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_RETRIEVE_FUNC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_FUNC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_STB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_STB, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_SMA, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_SMA, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_TABLE_META, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_VGROUP_LIST, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_QUERY, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_CONN, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_HEARTBEAT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_SHOW_RETRIEVE, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_SYSTABLE_RETRIEVE, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_STATUS, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_KILL_TRANS, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_GRANT, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_AUTH, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_MNODE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_TOPIC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_ALTER_TOPIC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_DROP_TOPIC, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_SUBSCRIBE, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_MQ_COMMIT_OFFSET, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_GET_SUB_EP, (NodeMsgFp)mmProcessReadMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_MND_CREATE_STREAM, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
|
||||
// Requests handled by VNODE
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA_RSP, (NodeMsgFp)mmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA_RSP, (NodeMsgFp)mmProcessWriteMsg, VND_VGID);
|
||||
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)mmProcessReadMsg, MND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)mmProcessReadMsg, MND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)mmProcessReadMsg, MND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)mmProcessReadMsg, MND_VGID);
|
||||
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
dDebug("mnode workers are initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -115,4 +116,5 @@ void mmStopWorker(SMnodeMgmt *pMgmt) {
|
|||
tSingleWorkerCleanup(&pMgmt->readWorker);
|
||||
tSingleWorkerCleanup(&pMgmt->writeWorker);
|
||||
tSingleWorkerCleanup(&pMgmt->syncWorker);
|
||||
dDebug("mnode workers are closed");
|
||||
}
|
||||
|
|
|
@ -56,14 +56,14 @@ int32_t qmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
|||
|
||||
void qmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||
// Requests handled by VNODE
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)qmProcessQueryMsg, 1);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)qmProcessQueryMsg, 1);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)qmProcessFetchMsg, 1);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)qmProcessFetchMsg, 1);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)qmProcessQueryMsg, QND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)qmProcessQueryMsg, QND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)qmProcessFetchMsg, 1);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)qmProcessFetchMsg, 1);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)qmProcessFetchMsg, 1);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)qmProcessFetchMsg, 1);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)qmProcessFetchMsg, 1);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)qmProcessFetchMsg, QND_VGID);
|
||||
}
|
||||
|
|
|
@ -132,10 +132,12 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
dDebug("qnode workers are initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void qmStopWorker(SQnodeMgmt *pMgmt) {
|
||||
tSingleWorkerCleanup(&pMgmt->queryWorker);
|
||||
tSingleWorkerCleanup(&pMgmt->fetchWorker);
|
||||
dDebug("qnode workers are closed");
|
||||
}
|
||||
|
|
|
@ -56,6 +56,6 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
|||
|
||||
void smInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||
// Requests handled by SNODE
|
||||
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_DEPLOY, (NodeMsgFp)smProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_EXEC, (NodeMsgFp)smProcessExecMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_DEPLOY, (NodeMsgFp)smProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_SND_TASK_EXEC, (NodeMsgFp)smProcessExecMsg, VND_VGID);
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
dDebug("snode workers are initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -90,6 +91,7 @@ void smStopWorker(SSnodeMgmt *pMgmt) {
|
|||
}
|
||||
taosArrayDestroy(pMgmt->uniqueWorkers);
|
||||
tSingleWorkerCleanup(&pMgmt->sharedWorker);
|
||||
dDebug("snode workers are closed");
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t smGetSWIdFromMsg(SRpcMsg *pMsg) {
|
||||
|
|
|
@ -257,14 +257,14 @@ static void vmCleanup(SMgmtWrapper *pWrapper) {
|
|||
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||
if (pMgmt == NULL) return;
|
||||
|
||||
dInfo("vnodes-mgmt start to cleanup");
|
||||
dInfo("vnode-mgmt start to cleanup");
|
||||
vmCloseVnodes(pMgmt);
|
||||
vmStopWorker(pMgmt);
|
||||
vnodeCleanup();
|
||||
// walCleanUp();
|
||||
free(pMgmt);
|
||||
pWrapper->pMgmt = NULL;
|
||||
dInfo("vnodes-mgmt is cleaned up");
|
||||
dInfo("vnode-mgmt is cleaned up");
|
||||
}
|
||||
|
||||
static int32_t vmInit(SMgmtWrapper *pWrapper) {
|
||||
|
@ -272,7 +272,7 @@ static int32_t vmInit(SMgmtWrapper *pWrapper) {
|
|||
SVnodesMgmt *pMgmt = calloc(1, sizeof(SVnodesMgmt));
|
||||
int32_t code = -1;
|
||||
|
||||
dInfo("vnodes-mgmt start to init");
|
||||
dInfo("vnode-mgmt start to init");
|
||||
if (pMgmt == NULL) goto _OVER;
|
||||
|
||||
pMgmt->path = pWrapper->path;
|
||||
|
@ -312,7 +312,7 @@ static int32_t vmInit(SMgmtWrapper *pWrapper) {
|
|||
}
|
||||
|
||||
if (vmOpenVnodes(pMgmt) != 0) {
|
||||
dError("failed to open vnodes since %s", terrstr());
|
||||
dError("failed to open vnode since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -244,49 +244,49 @@ int32_t vmProcessCompactVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
|
|||
|
||||
void vmInitMsgHandles(SMgmtWrapper *pWrapper) {
|
||||
// Requests handled by VNODE
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_SUBMIT, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)vmProcessQueryMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)vmProcessQueryMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_UPDATE_TAG_VAL, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TABLE_META, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TABLES_META, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CONSUME, (NodeMsgFp)vmProcessQueryMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_QUERY, (NodeMsgFp)vmProcessQueryMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CONNECT, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_DISCONNECT, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_TABLE, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TABLE, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_SMA, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES_FETCH, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CONSUME, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY, (NodeMsgFp)vmProcessWriteMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_EXEC, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_PIPE_EXEC, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_MERGE_EXEC, (NodeMsgFp)vmProcessMergeMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_STREAM_TRIGGER, (NodeMsgFp)vmProcessFetchMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_SUBMIT, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY, (NodeMsgFp)vmProcessQueryMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_CONTINUE, (NodeMsgFp)vmProcessQueryMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_FETCH_RSP, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_UPDATE_TAG_VAL, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TABLE_META, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TABLES_META, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CONSUME, (NodeMsgFp)vmProcessQueryMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_QUERY, (NodeMsgFp)vmProcessQueryMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_CONNECT, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_DISCONNECT, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_RES_READY, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASKS_STATUS, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_TASK, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TASK, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_STB, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_STB, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_STB, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_TABLE, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_ALTER_TABLE, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_TABLE, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CANCEL_SMA, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_SHOW_TABLES_FETCH, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CONN, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_REB, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_MQ_SET_CUR, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_CONSUME, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY, (NodeMsgFp)vmProcessWriteMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_QUERY_HEARTBEAT, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_EXEC, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_PIPE_EXEC, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_TASK_MERGE_EXEC, (NodeMsgFp)vmProcessMergeMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_VND_STREAM_TRIGGER, (NodeMsgFp)vmProcessFetchMsg, VND_VGID);
|
||||
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE, (NodeMsgFp)vmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE, (NodeMsgFp)vmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE, (NodeMsgFp)vmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE, (NodeMsgFp)vmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE, (NodeMsgFp)vmProcessMgmtMsg, 0);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_CREATE_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_ALTER_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_DROP_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_SYNC_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
||||
dndSetMsgHandle(pWrapper, TDMT_DND_COMPACT_VNODE, (NodeMsgFp)vmProcessMgmtMsg, VND_VGID);
|
||||
}
|
||||
|
|
|
@ -372,7 +372,7 @@ int32_t vmStartWorker(SVnodesMgmt *pMgmt) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
dDebug("vnode workers is initialized");
|
||||
dDebug("vnode workers are initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -382,5 +382,5 @@ void vmStopWorker(SVnodesMgmt *pMgmt) {
|
|||
tQWorkerCleanup(&pMgmt->queryPool);
|
||||
tWWorkerCleanup(&pMgmt->writePool);
|
||||
tWWorkerCleanup(&pMgmt->syncPool);
|
||||
dDebug("vnode workers is closed");
|
||||
dDebug("vnode workers are closed");
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ target_include_directories(
|
|||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
target_link_libraries(
|
||||
mnode scheduler sdb wal transport cjson sync monitor
|
||||
mnode scheduler sdb wal transport cjson sync monitor parser
|
||||
)
|
||||
|
||||
if(${BUILD_TEST})
|
||||
|
|
|
@ -69,7 +69,7 @@ void mndCleanupSma(SMnode *pMnode) {}
|
|||
static SSdbRaw *mndSmaActionEncode(SSmaObj *pSma) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
int32_t size = sizeof(SSmaObj) + pSma->exprLen + pSma->tagsFilterLen + TSDB_SMA_RESERVE_SIZE;
|
||||
int32_t size = sizeof(SSmaObj) + pSma->exprLen + pSma->tagsFilterLen + pSma->sqlLen + pSma->astLen + TSDB_SMA_RESERVE_SIZE;
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_SMA, TSDB_SMA_VER_NUMBER, size);
|
||||
if (pRaw == NULL) goto _OVER;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "mndStream.h"
|
||||
#include "parser.h"
|
||||
#include "mndAuth.h"
|
||||
#include "mndDb.h"
|
||||
#include "mndDnode.h"
|
||||
|
@ -218,28 +219,6 @@ static int32_t mndCheckCreateStreamReq(SCMCreateStreamReq *pCreate) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static SArray *mndExtractNamesFromAst(const SNode *pAst) {
|
||||
if (pAst->type != QUERY_NODE_SELECT_STMT) return NULL;
|
||||
|
||||
SArray *names = taosArrayInit(0, sizeof(void *));
|
||||
if (names == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
SSelectStmt *pSelect = (SSelectStmt *)pAst;
|
||||
SNodeList *pNodes = pSelect->pProjectionList;
|
||||
SListCell *pCell = pNodes->pHead;
|
||||
while (pCell != NULL) {
|
||||
if (pCell->pNode->type != QUERY_NODE_FUNCTION) {
|
||||
continue;
|
||||
}
|
||||
SFunctionNode *pFunction = (SFunctionNode *)pCell->pNode;
|
||||
char *name = strdup(pFunction->node.aliasName);
|
||||
taosArrayPush(names, &name);
|
||||
pCell = pCell->pNext;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
static int32_t mndStreamGetPlanString(const char *ast, char **pStr) {
|
||||
if (NULL == ast) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -269,18 +248,23 @@ static int32_t mndStreamGetPlanString(const char *ast, char **pStr) {
|
|||
|
||||
int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast, STrans *pTrans) {
|
||||
SNode *pAst = NULL;
|
||||
#if 1 // TODO: remove debug info later
|
||||
printf("ast = %s\n", ast);
|
||||
#endif
|
||||
if (nodesStringToNode(ast, &pAst) < 0) {
|
||||
return -1;
|
||||
}
|
||||
#if 1
|
||||
SArray *names = mndExtractNamesFromAst(pAst);
|
||||
SSchemaWrapper sw = {0};
|
||||
qExtractResultSchema(pAst, (int32_t*)&sw.nCols, &sw.pSchema);
|
||||
|
||||
printf("|");
|
||||
for (int i = 0; i < taosArrayGetSize(names); i++) {
|
||||
printf(" %15s |", (char *)taosArrayGetP(names, i));
|
||||
for (int i = 0; i < sw.nCols; i++) {
|
||||
printf(" %15s |", (char *)sw.pSchema[i].name);
|
||||
}
|
||||
printf("\n=======================================================\n");
|
||||
|
||||
pStream->ColAlias = names;
|
||||
pStream->ColAlias = NULL;
|
||||
#endif
|
||||
|
||||
if (TSDB_CODE_SUCCESS != mndStreamGetPlanString(ast, &pStream->physicalPlan)) {
|
||||
|
|
|
@ -87,6 +87,15 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp);
|
|||
int tsdbPrepareCommit(STsdb *pTsdb);
|
||||
int tsdbCommit(STsdb *pTsdb);
|
||||
|
||||
/**
|
||||
* @brief When submit msg received, update the relative expired window synchronously.
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param msg
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, const char *msg);
|
||||
|
||||
/**
|
||||
* @brief Insert tSma(Time-range-wise SMA) data from stream computing engine
|
||||
*
|
||||
|
@ -95,11 +104,18 @@ int tsdbCommit(STsdb *pTsdb);
|
|||
* @return int32_t
|
||||
*/
|
||||
int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg);
|
||||
int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, int8_t smaType, char *msg);
|
||||
|
||||
/**
|
||||
* @brief Drop tSma data and local cache.
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param indexUid
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t tsdbDropTSmaData(STsdb *pTsdb, int64_t indexUid);
|
||||
|
||||
/**
|
||||
* @brief Insert RSma(Time-range-wise Rollup SMA) data.
|
||||
* @brief Insert RSma(Rollup SMA) data.
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param msg
|
||||
|
@ -108,6 +124,20 @@ int32_t tsdbDropTSmaData(STsdb *pTsdb, int64_t indexUid);
|
|||
int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg);
|
||||
|
||||
// TODO: This is the basic params, and should wrap the params to a queryHandle.
|
||||
/**
|
||||
* @brief Get tSma(Time-range-wise SMA) data.
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param pData
|
||||
* @param indexUid
|
||||
* @param interval
|
||||
* @param intervalUnit
|
||||
* @param tableUid
|
||||
* @param colId
|
||||
* @param querySKey
|
||||
* @param nMaxResult
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, int8_t intervalUnit,
|
||||
tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, int32_t nMaxResult);
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ struct STsdb {
|
|||
#define REPO_ID(r) ((r)->vgId)
|
||||
#define REPO_CFG(r) (&(r)->config)
|
||||
#define REPO_FS(r) (r)->fs
|
||||
#define REPO_META(r) (r)->pMeta
|
||||
#define REPO_TFS(r) (r)->pTfs
|
||||
#define IS_REPO_LOCKED(r) (r)->repoLocked
|
||||
#define REPO_SMA_ENV(r, t) ((TSDB_SMA_TYPE_ROLLUP == (t)) ? (r)->pRSmaEnv : (r)->pTSmaEnv)
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#ifndef _TD_TSDB_SMA_H_
|
||||
#define _TD_TSDB_SMA_H_
|
||||
|
||||
#define TSDB_SMA_TEST // remove after test finished
|
||||
|
||||
typedef struct SSmaStat SSmaStat;
|
||||
typedef struct SSmaEnv SSmaEnv;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ int32_t tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t
|
|||
if (pReadHandle->pBlock == NULL) break;
|
||||
|
||||
pReadHandle->pBlock->uid = htobe64(pReadHandle->pBlock->uid);
|
||||
pReadHandle->pBlock->tid = htonl(pReadHandle->pBlock->tid);
|
||||
pReadHandle->pBlock->suid = htobe64(pReadHandle->pBlock->suid);
|
||||
pReadHandle->pBlock->sversion = htonl(pReadHandle->pBlock->sversion);
|
||||
pReadHandle->pBlock->dataLen = htonl(pReadHandle->pBlock->dataLen);
|
||||
pReadHandle->pBlock->schemaLen = htonl(pReadHandle->pBlock->schemaLen);
|
||||
|
|
|
@ -248,7 +248,7 @@ static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) {
|
|||
if (pBlock == NULL) break;
|
||||
|
||||
pBlock->uid = htobe64(pBlock->uid);
|
||||
pBlock->tid = htonl(pBlock->tid);
|
||||
pBlock->suid = htobe64(pBlock->suid);
|
||||
pBlock->sversion = htonl(pBlock->sversion);
|
||||
pBlock->dataLen = htonl(pBlock->dataLen);
|
||||
pBlock->schemaLen = htonl(pBlock->schemaLen);
|
||||
|
|
|
@ -38,7 +38,7 @@ typedef enum {
|
|||
} ESmaStorageLevel;
|
||||
|
||||
typedef struct {
|
||||
STsdb * pTsdb;
|
||||
STsdb *pTsdb;
|
||||
SDBFile dFile;
|
||||
int32_t interval; // interval with the precision of DB
|
||||
} STSmaWriteH;
|
||||
|
@ -49,7 +49,7 @@ typedef struct {
|
|||
} SmaFsIter;
|
||||
|
||||
typedef struct {
|
||||
STsdb * pTsdb;
|
||||
STsdb *pTsdb;
|
||||
SDBFile dFile;
|
||||
int32_t interval; // interval with the precision of DB
|
||||
int32_t blockSize; // size of SMA block item
|
||||
|
@ -69,7 +69,7 @@ typedef struct {
|
|||
*/
|
||||
int8_t state; // ETsdbSmaStat
|
||||
SHashObj *expiredWindows; // key: skey of time window, value: N/A
|
||||
STSma * pSma; // cache schema
|
||||
STSma *pSma; // cache schema
|
||||
} SSmaStatItem;
|
||||
|
||||
struct SSmaStat {
|
||||
|
@ -80,9 +80,9 @@ struct SSmaStat {
|
|||
// declaration of static functions
|
||||
|
||||
// expired window
|
||||
static int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg);
|
||||
static int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, const char *msg);
|
||||
static int32_t tsdbInitSmaStat(SSmaStat **pSmaStat);
|
||||
static void * tsdbFreeSmaStatItem(SSmaStatItem *pSmaStatItem);
|
||||
static void *tsdbFreeSmaStatItem(SSmaStatItem *pSmaStatItem);
|
||||
static int32_t tsdbDestroySmaState(SSmaStat *pSmaStat);
|
||||
static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path, SDiskID did);
|
||||
static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SDiskID did, SSmaEnv **pEnv);
|
||||
|
@ -124,7 +124,7 @@ static FORCE_INLINE int8_t tsdbSmaStat(SSmaStatItem *pStatItem) {
|
|||
}
|
||||
|
||||
static FORCE_INLINE bool tsdbSmaStatIsOK(SSmaStatItem *pStatItem, int8_t *state) {
|
||||
if(!pStatItem) {
|
||||
if (!pStatItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -384,49 +384,20 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Update expired window according to msg from stream computing module.
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param smaType ETsdbSmaType
|
||||
* @param msg
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) {
|
||||
if (!msg || !pTsdb->pMeta) {
|
||||
terrno = TSDB_CODE_INVALID_PTR;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
static STimeWindow getActiveTimeWindowX(int64_t ts, SInterval* pInterval) {
|
||||
STimeWindow tw = {0};
|
||||
tw.skey = 100;
|
||||
tw.ekey = 1000;
|
||||
return tw;
|
||||
}
|
||||
|
||||
// TODO: decode the msg from Stream Computing module => start
|
||||
int64_t indexUid = SMA_TEST_INDEX_UID;
|
||||
const int32_t SMA_TEST_EXPIRED_WINDOW_SIZE = 10;
|
||||
TSKEY expiredWindows[SMA_TEST_EXPIRED_WINDOW_SIZE];
|
||||
TSKEY skey1 = 1646987196 * 1e3;
|
||||
for (int32_t i = 0; i < SMA_TEST_EXPIRED_WINDOW_SIZE; ++i) {
|
||||
expiredWindows[i] = skey1 + i;
|
||||
}
|
||||
// TODO: decode the msg <= end
|
||||
|
||||
if (tsdbCheckAndInitSmaEnv(pTsdb, smaType) != TSDB_CODE_SUCCESS) {
|
||||
terrno = TSDB_CODE_TDB_INIT_FAILED;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SSmaEnv * pEnv = REPO_SMA_ENV(pTsdb, smaType);
|
||||
SSmaStat *pStat = SMA_ENV_STAT(pEnv);
|
||||
SHashObj *pItemsHash = SMA_ENV_STAT_ITEMS(pEnv);
|
||||
|
||||
TASSERT(pEnv != NULL && pStat != NULL && pItemsHash != NULL);
|
||||
|
||||
tsdbRefSmaStat(pTsdb, pStat);
|
||||
static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey) {
|
||||
SSmaStatItem *pItem = taosHashGet(pItemsHash, &indexUid, sizeof(indexUid));
|
||||
if (pItem == NULL) {
|
||||
pItem = tsdbNewSmaStatItem(TSDB_SMA_STAT_EXPIRED); // TODO use the real state
|
||||
if (pItem == NULL) {
|
||||
// Response to stream computing: OOM
|
||||
// For query, if the indexUid not found, the TSDB should tell query module to query raw TS data.
|
||||
tsdbUnRefSmaStat(pTsdb, pStat);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
|
@ -436,7 +407,6 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) {
|
|||
terrno = TSDB_CODE_TDB_NO_SMA_INDEX_IN_META;
|
||||
taosHashCleanup(pItem->expiredWindows);
|
||||
free(pItem);
|
||||
tsdbUnRefSmaStat(pTsdb, pStat);
|
||||
tsdbWarn("vgId:%d update expired window failed for smaIndex %" PRIi64 " since %s", REPO_ID(pTsdb), indexUid,
|
||||
tstrerror(terrno));
|
||||
return TSDB_CODE_FAILED;
|
||||
|
@ -447,34 +417,150 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) {
|
|||
// If error occurs during put smaStatItem, free the resources of pItem
|
||||
taosHashCleanup(pItem->expiredWindows);
|
||||
free(pItem);
|
||||
tsdbUnRefSmaStat(pTsdb, pStat);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
int8_t state = TSDB_SMA_STAT_EXPIRED;
|
||||
if (taosHashPut(pItem->expiredWindows, &winSKey, sizeof(TSKEY), &state, sizeof(state)) != 0) {
|
||||
// If error occurs during taosHashPut expired windows, remove the smaIndex from pTsdb->pSmaStat, thus TSDB would
|
||||
// tell query module to query raw TS data.
|
||||
// N.B.
|
||||
// 1) It is assumed to be extemely little probability event of fail to taosHashPut.
|
||||
// 2) This would solve the inconsistency to some extent, but not completely, unless we record all expired
|
||||
// windows failed to put into hash table.
|
||||
taosHashCleanup(pItem->expiredWindows);
|
||||
tfree(pItem->pSma);
|
||||
taosHashRemove(pItemsHash, &indexUid, sizeof(indexUid));
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
tsdbDebug("vgId:%d smaIndex %" PRIi64 " tsKey %" PRIi64 " is put to hash", REPO_ID(pTsdb), indexUid, winSKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update expired window according to msg from stream computing module.
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param msg SSubmitReq
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, const char *msg) {
|
||||
const SSubmitReq *pMsg = (const SSubmitReq *)msg;
|
||||
|
||||
if (pMsg->length <= sizeof(SSubmitReq)) {
|
||||
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
if (!pTsdb->pMeta) {
|
||||
terrno = TSDB_CODE_INVALID_PTR;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
// TODO: decode the msg from Stream Computing module => start
|
||||
#ifdef TSDB_SMA_TESTx
|
||||
int64_t indexUid = SMA_TEST_INDEX_UID;
|
||||
const int32_t SMA_TEST_EXPIRED_WINDOW_SIZE = 10;
|
||||
TSKEY expiredWindows[SMA_TEST_EXPIRED_WINDOW_SIZE];
|
||||
TSKEY skey1 = 1646987196 * 1e3;
|
||||
for (int32_t i = 0; i < SMA_TEST_EXPIRED_WINDOW_SIZE; ++i) {
|
||||
if (taosHashPut(pItem->expiredWindows, expiredWindows + i, sizeof(TSKEY), &state, sizeof(state)) != 0) {
|
||||
// If error occurs during taosHashPut expired windows, remove the smaIndex from pTsdb->pSmaStat, thus TSDB would
|
||||
// tell query module to query raw TS data.
|
||||
// N.B.
|
||||
// 1) It is assumed to be extemely little probability event of fail to taosHashPut.
|
||||
// 2) This would solve the inconsistency to some extent, but not completely, unless we record all expired
|
||||
// windows failed to put into hash table.
|
||||
taosHashCleanup(pItem->expiredWindows);
|
||||
tfree(pItem->pSma);
|
||||
taosHashRemove(pItemsHash, &indexUid, sizeof(indexUid));
|
||||
tsdbUnRefSmaStat(pTsdb, pStat);
|
||||
return TSDB_CODE_FAILED;
|
||||
expiredWindows[i] = skey1 + i;
|
||||
}
|
||||
#else
|
||||
|
||||
#endif
|
||||
// TODO: decode the msg <= end
|
||||
|
||||
if (tsdbCheckAndInitSmaEnv(pTsdb, TSDB_SMA_TYPE_TIME_RANGE) != TSDB_CODE_SUCCESS) {
|
||||
terrno = TSDB_CODE_TDB_INIT_FAILED;
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
#ifndef TSDB_SMA_TEST
|
||||
TSKEY expiredWindows[SMA_TEST_EXPIRED_WINDOW_SIZE];
|
||||
#endif
|
||||
|
||||
|
||||
// Firstly, assume that tSma can only be created on super table/normal table.
|
||||
// getActiveTimeWindow
|
||||
|
||||
|
||||
SSmaEnv *pEnv = REPO_SMA_ENV(pTsdb, TSDB_SMA_TYPE_TIME_RANGE);
|
||||
SSmaStat *pStat = SMA_ENV_STAT(pEnv);
|
||||
SHashObj *pItemsHash = SMA_ENV_STAT_ITEMS(pEnv);
|
||||
|
||||
TASSERT(pEnv != NULL && pStat != NULL && pItemsHash != NULL);
|
||||
|
||||
|
||||
|
||||
SSubmitMsgIter msgIter = {0};
|
||||
SSubmitBlk *pBlock = NULL;
|
||||
SInterval interval = {0};
|
||||
|
||||
|
||||
if (tInitSubmitMsgIter(pMsg, &msgIter) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
// basic procedure
|
||||
// TODO: optimization
|
||||
tsdbRefSmaStat(pTsdb, pStat);
|
||||
|
||||
while (true) {
|
||||
tGetSubmitMsgNext(&msgIter, &pBlock);
|
||||
if (pBlock == NULL) break;
|
||||
|
||||
int64_t suid = htobe64(pBlock->uid);
|
||||
STSmaWrapper *pSW = NULL;
|
||||
STSma *pTSma = NULL;
|
||||
|
||||
while (true) {
|
||||
SSubmitBlkIter blkIter = {0};
|
||||
if (tInitSubmitBlkIter(pBlock, &blkIter) != TSDB_CODE_SUCCESS) {
|
||||
tdFreeTSmaWrapper(pSW);
|
||||
break;
|
||||
}
|
||||
STSRow *row = tGetSubmitBlkNext(&blkIter);
|
||||
if (row == NULL) {
|
||||
tdFreeTSmaWrapper(pSW);
|
||||
break;
|
||||
}
|
||||
if(pSW == NULL) {
|
||||
if((pSW =metaGetSmaInfoByTable(REPO_META(pTsdb), suid)) == NULL) {
|
||||
break;
|
||||
}
|
||||
if((pSW->number) <= 0 || (pSW->tSma == NULL)) {
|
||||
tdFreeTSmaWrapper(pSW);
|
||||
break;
|
||||
}
|
||||
pTSma = pSW->tSma;
|
||||
}
|
||||
|
||||
interval.interval = pTSma->interval;
|
||||
interval.intervalUnit = pTSma->intervalUnit;
|
||||
interval.offset = pTSma->offset;
|
||||
interval.precision = REPO_CFG(pTsdb)->precision;
|
||||
interval.sliding = pTSma->sliding;
|
||||
interval.slidingUnit = pTSma->slidingUnit;
|
||||
|
||||
STimeWindow tw = getActiveTimeWindowX(TD_ROW_KEY(row), &interval);
|
||||
tsdbSetExpiredWindow(pTsdb, pItemsHash, pTSma->indexUid, TD_ROW_KEY(row));
|
||||
}
|
||||
tsdbDebug("vgId:%d smaIndex %" PRIi64 " tsKey %" PRIi64 " is put to hash", REPO_ID(pTsdb), indexUid,
|
||||
expiredWindows[i]);
|
||||
}
|
||||
|
||||
tsdbUnRefSmaStat(pTsdb, pStat);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief When sma data received from stream computing, make the relative expired window valid.
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param pStat
|
||||
* @param indexUid
|
||||
* @param skey
|
||||
* @return int32_t
|
||||
*/
|
||||
static int32_t tsdbResetExpiredWindow(STsdb *pTsdb, SSmaStat *pStat, int64_t indexUid, TSKEY skey) {
|
||||
SSmaStatItem *pItem = NULL;
|
||||
|
||||
|
@ -582,7 +668,7 @@ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t k
|
|||
|
||||
#ifdef _TEST_SMA_PRINT_DEBUG_LOG_
|
||||
uint32_t valueSize = 0;
|
||||
void * data = tsdbGetSmaDataByKey(pDBFile, smaKey, keyLen, &valueSize);
|
||||
void *data = tsdbGetSmaDataByKey(pDBFile, smaKey, keyLen, &valueSize);
|
||||
ASSERT(data != NULL);
|
||||
for (uint32_t v = 0; v < valueSize; v += 8) {
|
||||
tsdbWarn("vgId:%d insert sma data val[%d] %" PRIi64, REPO_ID(pSmaH->pTsdb), v, *(int64_t *)POINTER_SHIFT(data, v));
|
||||
|
@ -699,7 +785,7 @@ static int32_t tsdbInsertTSmaDataSection(STSmaWriteH *pSmaH, STSmaDataWrapper *p
|
|||
assert(pTbData->dataLen > 0);
|
||||
STSmaColData *pColData = (STSmaColData *)POINTER_SHIFT(pTbData->data, tbLen);
|
||||
char smaKey[SMA_KEY_LEN] = {0};
|
||||
void * pSmaKey = &smaKey;
|
||||
void *pSmaKey = &smaKey;
|
||||
#if 0
|
||||
printf("tsdbInsertTSmaDataSection: index %" PRIi64 ", skey %" PRIi64 " table[%" PRIi64 "]col[%" PRIu16 "]\n",
|
||||
pData->indexUid, pData->skey, pTbData->tableUid, pColData->colId);
|
||||
|
@ -773,11 +859,10 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe
|
|||
* @return int32_t
|
||||
*/
|
||||
static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
|
||||
STsdbCfg * pCfg = REPO_CFG(pTsdb);
|
||||
STsdbCfg *pCfg = REPO_CFG(pTsdb);
|
||||
STSmaDataWrapper *pData = (STSmaDataWrapper *)msg;
|
||||
SSmaEnv * pEnv = atomic_load_ptr(&pTsdb->pTSmaEnv);
|
||||
int64_t indexUid = SMA_TEST_INDEX_UID;
|
||||
|
||||
SSmaEnv *pEnv = atomic_load_ptr(&pTsdb->pTSmaEnv);
|
||||
int64_t indexUid = SMA_TEST_INDEX_UID;
|
||||
|
||||
if (pEnv == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_PTR;
|
||||
|
@ -797,7 +882,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
|
|||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SSmaStat *pStat = SMA_ENV_STAT(pTsdb->pTSmaEnv);
|
||||
SSmaStat *pStat = SMA_ENV_STAT(pTsdb->pTSmaEnv);
|
||||
SSmaStatItem *pItem = NULL;
|
||||
|
||||
tsdbRefSmaStat(pTsdb, pStat);
|
||||
|
@ -812,8 +897,8 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
|
|||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
char rPath[TSDB_FILENAME_LEN] = {0};
|
||||
char aPath[TSDB_FILENAME_LEN] = {0};
|
||||
char rPath[TSDB_FILENAME_LEN] = {0};
|
||||
char aPath[TSDB_FILENAME_LEN] = {0};
|
||||
snprintf(rPath, TSDB_FILENAME_LEN, "%s%s%" PRIi64, SMA_ENV_PATH(pEnv), TD_DIRSEP, indexUid);
|
||||
tfsAbsoluteName(REPO_TFS(pTsdb), SMA_ENV_DID(pEnv), rPath, aPath);
|
||||
if (!taosCheckExistFile(aPath)) {
|
||||
|
@ -859,9 +944,9 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
|
|||
/**
|
||||
* @brief Drop tSma data and local cache
|
||||
* - insert/query reference
|
||||
* @param pTsdb
|
||||
* @param msg
|
||||
* @return int32_t
|
||||
* @param pTsdb
|
||||
* @param msg
|
||||
* @return int32_t
|
||||
*/
|
||||
static int32_t tsdbDropTSmaDataImpl(STsdb *pTsdb, int64_t indexUid) {
|
||||
SSmaEnv *pEnv = atomic_load_ptr(&pTsdb->pTSmaEnv);
|
||||
|
@ -902,8 +987,7 @@ static int32_t tsdbDropTSmaDataImpl(STsdb *pTsdb, int64_t indexUid) {
|
|||
}
|
||||
}
|
||||
// clear sma data files
|
||||
// TODO:
|
||||
|
||||
// TODO:
|
||||
}
|
||||
|
||||
static int32_t tsdbSetRSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int32_t fid) {
|
||||
|
@ -917,9 +1001,9 @@ static int32_t tsdbSetRSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData,
|
|||
}
|
||||
|
||||
static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg) {
|
||||
STsdbCfg * pCfg = REPO_CFG(pTsdb);
|
||||
STsdbCfg *pCfg = REPO_CFG(pTsdb);
|
||||
STSmaDataWrapper *pData = (STSmaDataWrapper *)msg;
|
||||
SSmaEnv * pEnv = atomic_load_ptr(&pTsdb->pRSmaEnv);
|
||||
SSmaEnv *pEnv = atomic_load_ptr(&pTsdb->pRSmaEnv);
|
||||
|
||||
if (pEnv == NULL) {
|
||||
terrno = TSDB_CODE_INVALID_PTR;
|
||||
|
@ -1137,7 +1221,7 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_
|
|||
tReadH.dFile.path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8),
|
||||
*(int64_t *)POINTER_SHIFT(smaKey, 10), SMA_KEY_LEN);
|
||||
|
||||
void * result = NULL;
|
||||
void *result = NULL;
|
||||
uint32_t valueSize = 0;
|
||||
if ((result = tsdbGetSmaDataByKey(&tReadH.dFile, smaKey, SMA_KEY_LEN, &valueSize)) == NULL) {
|
||||
tsdbWarn("vgId:%d get sma data failed from smaIndex %" PRIi64 ", smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64
|
||||
|
@ -1219,15 +1303,8 @@ int32_t tsdbRemoveTSmaData(STsdb *pTsdb, void *smaIndex, STimeWindow *pWin) {
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Insert/Update tSma(Time-range-wise SMA) data from stream computing engine
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param param
|
||||
* @param msg
|
||||
* @return int32_t
|
||||
* TODO: Who is responsible for resource allocate and release?
|
||||
*/
|
||||
|
||||
// TODO: Who is responsible for resource allocate and release?
|
||||
int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if ((code = tsdbInsertTSmaDataImpl(pTsdb, msg)) < 0) {
|
||||
|
@ -1236,21 +1313,14 @@ int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg) {
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, int8_t smaType, char *msg) {
|
||||
int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, const char *msg) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if ((code = tsdbUpdateExpiredWindow(pTsdb, smaType, msg)) < 0) {
|
||||
if ((code = tsdbUpdateExpiredWindowImpl(pTsdb, msg)) < 0) {
|
||||
tsdbWarn("vgId:%d update expired sma window failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Insert Time-range-wise Rollup Sma(RSma) data
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param msg
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if ((code = tsdbInsertRSmaDataImpl(pTsdb, msg)) < 0) {
|
||||
|
@ -1259,20 +1329,7 @@ int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg) {
|
|||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get tSma data
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param pData
|
||||
* @param indexUid
|
||||
* @param interval
|
||||
* @param intervalUnit
|
||||
* @param tableUid
|
||||
* @param colId
|
||||
* @param querySKey
|
||||
* @param nMaxResult
|
||||
* @return int32_t
|
||||
*/
|
||||
|
||||
int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, int8_t intervalUnit,
|
||||
tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, int32_t nMaxResult) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -1283,13 +1340,7 @@ int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid,
|
|||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Drop tSma Data and caches
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param msg
|
||||
* @return int32_t
|
||||
*/
|
||||
|
||||
int32_t tsdbDropTSmaData(STsdb *pTsdb, int64_t indexUid) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if ((code = tsdbDropTSmaDataImpl(pTsdb, indexUid)) < 0) {
|
||||
|
|
|
@ -32,48 +32,4 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp) {
|
|||
}
|
||||
}
|
||||
return tsdbMemTableInsert(pTsdb, pTsdb->mem, pMsg, NULL);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* @brief Insert/Update tSma(Time-range-wise SMA) data from stream computing engine
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param param
|
||||
* @param msg
|
||||
* @return int32_t
|
||||
* TODO: Who is responsible for resource allocate and release?
|
||||
*/
|
||||
int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if ((code = tsdbInsertTSmaDataImpl(pTsdb, msg)) < 0) {
|
||||
tsdbWarn("vgId:%d insert tSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, int8_t smaType, char *msg) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if ((code = tsdbUpdateExpiredWindow(pTsdb, smaType, msg)) < 0) {
|
||||
tsdbWarn("vgId:%d update expired sma window failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Insert Time-range-wise Rollup Sma(RSma) data
|
||||
*
|
||||
* @param pTsdb
|
||||
* @param param
|
||||
* @param msg
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if ((code = tsdbInsertRSmaDataImpl(pTsdb, msg)) < 0) {
|
||||
tsdbWarn("vgId:%d insert rSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
|
@ -98,7 +98,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
|
|||
tSma.slidingUnit = TIME_UNIT_HOUR;
|
||||
tSma.sliding = 0;
|
||||
tstrncpy(tSma.indexName, "sma_index_test", TSDB_INDEX_NAME_LEN);
|
||||
tstrncpy(tSma.timezone, "Asia/Shanghai", TD_TIMEZONE_LEN);
|
||||
tSma.timezoneInt = 8;
|
||||
tSma.indexUid = 2345678910;
|
||||
tSma.tableUid = 1234567890;
|
||||
|
||||
|
@ -128,7 +128,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
|
|||
ASSERT_EQ(pSma->intervalUnit, qSma->intervalUnit);
|
||||
ASSERT_EQ(pSma->slidingUnit, qSma->slidingUnit);
|
||||
ASSERT_STRCASEEQ(pSma->indexName, qSma->indexName);
|
||||
ASSERT_STRCASEEQ(pSma->timezone, qSma->timezone);
|
||||
ASSERT_EQ(pSma->timezoneInt, qSma->timezoneInt);
|
||||
ASSERT_EQ(pSma->indexUid, qSma->indexUid);
|
||||
ASSERT_EQ(pSma->tableUid, qSma->tableUid);
|
||||
ASSERT_EQ(pSma->interval, qSma->interval);
|
||||
|
@ -150,7 +150,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
|
|||
TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
||||
const char * smaIndexName1 = "sma_index_test_1";
|
||||
const char * smaIndexName2 = "sma_index_test_2";
|
||||
const char * timezone = "Asia/Shanghai";
|
||||
int8_t timezone = 8;
|
||||
const char * expr = "select count(a,b, top 20), from table interval 1d, sliding 1h;";
|
||||
const char * tagsFilter = "I'm tags filter";
|
||||
const char * smaTestDir = "./smaTest";
|
||||
|
@ -167,7 +167,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
|||
tSma.sliding = 0;
|
||||
tSma.indexUid = indexUid1;
|
||||
tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN);
|
||||
tstrncpy(tSma.timezone, timezone, TD_TIMEZONE_LEN);
|
||||
tSma.timezoneInt = 8;
|
||||
tSma.tableUid = tbUid;
|
||||
|
||||
tSma.exprLen = strlen(expr);
|
||||
|
@ -207,7 +207,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
|||
qSmaCfg = metaGetSmaInfoByIndex(pMeta, indexUid1);
|
||||
assert(qSmaCfg != NULL);
|
||||
printf("name1 = %s\n", qSmaCfg->indexName);
|
||||
printf("timezone1 = %s\n", qSmaCfg->timezone);
|
||||
printf("timezone1 = %" PRIi8 "\n", qSmaCfg->timezoneInt);
|
||||
printf("expr1 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : "");
|
||||
printf("tagsFilter1 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : "");
|
||||
ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1);
|
||||
|
@ -218,7 +218,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
|||
qSmaCfg = metaGetSmaInfoByIndex(pMeta, indexUid2);
|
||||
assert(qSmaCfg != NULL);
|
||||
printf("name2 = %s\n", qSmaCfg->indexName);
|
||||
printf("timezone2 = %s\n", qSmaCfg->timezone);
|
||||
printf("timezone2 = %" PRIi8 "\n", qSmaCfg->timezoneInt);
|
||||
printf("expr2 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : "");
|
||||
printf("tagsFilter2 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : "");
|
||||
ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2);
|
||||
|
@ -246,13 +246,13 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
|||
assert(pSW != NULL);
|
||||
ASSERT_EQ(pSW->number, nCntTSma);
|
||||
ASSERT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1);
|
||||
ASSERT_STRCASEEQ(pSW->tSma->timezone, timezone);
|
||||
ASSERT_EQ(pSW->tSma->timezoneInt, timezone);
|
||||
ASSERT_STRCASEEQ(pSW->tSma->expr, expr);
|
||||
ASSERT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter);
|
||||
ASSERT_EQ(pSW->tSma->indexUid, indexUid1);
|
||||
ASSERT_EQ(pSW->tSma->tableUid, tbUid);
|
||||
ASSERT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2);
|
||||
ASSERT_STRCASEEQ((pSW->tSma + 1)->timezone, timezone);
|
||||
ASSERT_EQ((pSW->tSma + 1)->timezoneInt, timezone);
|
||||
ASSERT_STRCASEEQ((pSW->tSma + 1)->expr, expr);
|
||||
ASSERT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter);
|
||||
ASSERT_EQ((pSW->tSma + 1)->indexUid, indexUid2);
|
||||
|
@ -284,7 +284,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
|
|||
TEST(testCase, tSma_Data_Insert_Query_Test) {
|
||||
// step 1: prepare meta
|
||||
const char * smaIndexName1 = "sma_index_test_1";
|
||||
const char * timezone = "Asia/Shanghai";
|
||||
const int8_t timezone = 8;
|
||||
const char * expr = "select count(a,b, top 20), from table interval 1d, sliding 1h;";
|
||||
const char * tagsFilter = "where tags.location='Beijing' and tags.district='ChaoYang'";
|
||||
const char * smaTestDir = "./smaTest";
|
||||
|
@ -305,7 +305,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
|
|||
tSma.sliding = 0;
|
||||
tSma.indexUid = indexUid1;
|
||||
tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN);
|
||||
tstrncpy(tSma.timezone, timezone, TD_TIMEZONE_LEN);
|
||||
tSma.timezoneInt = timezone;
|
||||
tSma.tableUid = tbUid;
|
||||
|
||||
tSma.exprLen = strlen(expr);
|
||||
|
@ -369,7 +369,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
|
|||
|
||||
char *msg = (char *)calloc(1, 100);
|
||||
ASSERT_NE(msg, nullptr);
|
||||
ASSERT_EQ(tsdbUpdateSmaWindow(pTsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0);
|
||||
ASSERT_EQ(tsdbUpdateSmaWindow(pTsdb, msg), 0);
|
||||
|
||||
// init
|
||||
int32_t allocCnt = 0;
|
||||
|
|
|
@ -243,6 +243,8 @@ typedef struct STaskAttr {
|
|||
|
||||
struct SOperatorInfo;
|
||||
|
||||
typedef void (*__optr_encode_fn_t)(struct SOperatorInfo* pOperator, char **result, int32_t *length);
|
||||
typedef bool (*__optr_decode_fn_t)(struct SOperatorInfo* pOperator, char *result, int32_t length);
|
||||
typedef int32_t (*__optr_open_fn_t)(struct SOperatorInfo* param);
|
||||
typedef SSDataBlock* (*__optr_fn_t)(struct SOperatorInfo* param, bool* newgroup);
|
||||
typedef void (*__optr_close_fn_t)(void* param, int32_t num);
|
||||
|
@ -332,6 +334,8 @@ typedef struct SOperatorInfo {
|
|||
__optr_fn_t cleanupFn;
|
||||
__optr_close_fn_t closeFn;
|
||||
__optr_open_fn_t _openFn; // DO NOT invoke this function directly
|
||||
__optr_encode_fn_t encodeResultRow; //
|
||||
__optr_decode_fn_t decodeResultRow;
|
||||
} SOperatorInfo;
|
||||
|
||||
typedef struct {
|
||||
|
@ -661,6 +665,9 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
|
|||
SArray* pGroupColList, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
|
||||
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols, SInterval* pInterval, SSDataBlock* pResBlock,
|
||||
int32_t fillType, char* fillVal, bool multigroupResult, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createDistinctOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr,
|
||||
int32_t numOfOutput);
|
||||
SOperatorInfo* createTableBlockInfoScanOperator(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
|
||||
|
||||
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
|
||||
SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
|
||||
|
@ -671,9 +678,7 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim
|
|||
SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
|
||||
SExprInfo* pExpr, int32_t numOfOutput);
|
||||
SOperatorInfo* createTagScanOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput);
|
||||
SOperatorInfo* createDistinctOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr,
|
||||
int32_t numOfOutput);
|
||||
SOperatorInfo* createTableBlockInfoScanOperator(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
|
||||
|
||||
SOperatorInfo* createMultiwaySortOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput,
|
||||
int32_t numOfRows, void* merger);
|
||||
SOperatorInfo* createGlobalAggregateOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
|
||||
|
|
|
@ -674,12 +674,7 @@ static void getInitialStartTimeWindow(SInterval* pInterval, int32_t precision, T
|
|||
|
||||
int64_t key = w->skey;
|
||||
while(key < ts) { // moving towards end
|
||||
if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') {
|
||||
key = taosTimeAdd(key, pInterval->sliding, pInterval->slidingUnit, precision);
|
||||
} else {
|
||||
key += pInterval->sliding;
|
||||
}
|
||||
|
||||
key = taosTimeAdd(key, pInterval->sliding, pInterval->slidingUnit, precision);
|
||||
if (key >= ts) {
|
||||
break;
|
||||
}
|
||||
|
@ -695,12 +690,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t
|
|||
|
||||
if (pResultRowInfo->curPos == -1) { // the first window, from the previous stored value
|
||||
getInitialStartTimeWindow(pInterval, precision, ts, &w, win->ekey, true);
|
||||
|
||||
if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') {
|
||||
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||
} else {
|
||||
w.ekey = w.skey + pInterval->interval - 1;
|
||||
}
|
||||
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||
} else {
|
||||
w = getResultRow(pResultRowInfo, pResultRowInfo->curPos)->win;
|
||||
}
|
||||
|
@ -722,7 +712,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t
|
|||
}
|
||||
|
||||
w.skey = st;
|
||||
w.ekey = w.skey + pInterval->interval - 1;
|
||||
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||
}
|
||||
}
|
||||
return w;
|
||||
|
@ -2208,7 +2198,7 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExprInfo, int32_t num
|
|||
}
|
||||
|
||||
for(int32_t i = 1; i < numOfOutput; ++i) {
|
||||
(*rowCellInfoOffset)[i] = (int32_t)((*rowCellInfoOffset)[i - 1] + sizeof(SResultRowEntryInfo) + pFuncCtx[i].resDataInfo.interBufSize);
|
||||
(*rowCellInfoOffset)[i] = (int32_t)((*rowCellInfoOffset)[i - 1] + sizeof(SResultRowEntryInfo) + pFuncCtx[i - 1].resDataInfo.interBufSize);
|
||||
}
|
||||
|
||||
setCtxTagColumnInfo(pFuncCtx, numOfOutput);
|
||||
|
@ -2407,7 +2397,7 @@ static bool isCachedLastQuery(STaskAttr *pQueryAttr) {
|
|||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//todo refactor : return window
|
||||
void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key, int64_t keyFirst, int64_t keyLast, STimeWindow *win) {
|
||||
assert(key >= keyFirst && key <= keyLast && pInterval->sliding <= pInterval->interval);
|
||||
ASSERT(key >= keyFirst && key <= keyLast);
|
||||
win->skey = taosTimeTruncate(key, pInterval, precision);
|
||||
|
||||
/*
|
||||
|
@ -2417,10 +2407,8 @@ void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t ke
|
|||
if (keyFirst > (INT64_MAX - pInterval->interval)) {
|
||||
assert(keyLast - keyFirst < pInterval->interval);
|
||||
win->ekey = INT64_MAX;
|
||||
} else if (pInterval->intervalUnit == 'n' || pInterval->intervalUnit == 'y') {
|
||||
win->ekey = taosTimeAdd(win->skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||
} else {
|
||||
win->ekey = win->skey + pInterval->interval - 1;
|
||||
win->ekey = taosTimeAdd(win->skey, pInterval->interval, pInterval->intervalUnit, precision) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6391,6 +6379,111 @@ static SSDataBlock* getAggregateResult(SOperatorInfo *pOperator, bool* newgroup)
|
|||
return (blockDataGetNumOfRows(pInfo->pRes) != 0)? pInfo->pRes:NULL;
|
||||
}
|
||||
|
||||
static void aggEncodeResultRow(SOperatorInfo* pOperator, char **result, int32_t *length) {
|
||||
SAggOperatorInfo *pAggInfo = pOperator->info;
|
||||
SAggSupporter *pSup = &pAggInfo->aggSup;
|
||||
|
||||
int32_t size = taosHashGetSize(pSup->pResultRowHashTable);
|
||||
size_t keyLen = POINTER_BYTES; // estimate the key length
|
||||
int32_t totalSize = sizeof(int32_t) + size * (sizeof(int32_t) + keyLen + sizeof(int32_t) + pSup->resultRowSize);
|
||||
*result = calloc(1, totalSize);
|
||||
if(*result == NULL){
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
*(int32_t*)(*result) = size;
|
||||
int32_t offset = sizeof(int32_t);
|
||||
void *pIter = taosHashIterate(pSup->pResultRowHashTable, NULL);
|
||||
while (pIter) {
|
||||
void *key = taosHashGetKey(pIter, &keyLen);
|
||||
SResultRow **p1 = (SResultRow **)pIter;
|
||||
|
||||
// recalculate the result size
|
||||
int32_t realTotalSize = offset + sizeof(int32_t) + keyLen + sizeof(int32_t) + pSup->resultRowSize;
|
||||
if (realTotalSize > totalSize){
|
||||
char *tmp = realloc(*result, realTotalSize);
|
||||
if (tmp == NULL){
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
free(*result);
|
||||
*result = NULL;
|
||||
return;
|
||||
}else{
|
||||
*result = tmp;
|
||||
}
|
||||
}
|
||||
// save key
|
||||
*(int32_t*)(*result + offset) = keyLen;
|
||||
offset += sizeof(int32_t);
|
||||
memcpy(*result + offset, key, keyLen);
|
||||
offset += keyLen;
|
||||
|
||||
// save value
|
||||
*(int32_t*)(*result + offset) = pSup->resultRowSize;
|
||||
offset += sizeof(int32_t);
|
||||
memcpy(*result + offset, *p1, pSup->resultRowSize);
|
||||
offset += pSup->resultRowSize;
|
||||
|
||||
pIter = taosHashIterate(pSup->pResultRowHashTable, pIter);
|
||||
}
|
||||
|
||||
if(length) {
|
||||
*length = offset;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static bool aggDecodeResultRow(SOperatorInfo* pOperator, char *result, int32_t length) {
|
||||
if (!result || length <= 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
SAggOperatorInfo *pAggInfo = pOperator->info;
|
||||
SAggSupporter *pSup = &pAggInfo->aggSup;
|
||||
SOptrBasicInfo *pInfo = &pAggInfo->binfo;
|
||||
|
||||
// int32_t size = taosHashGetSize(pSup->pResultRowHashTable);
|
||||
int32_t count = *(int32_t*)(result);
|
||||
|
||||
int32_t offset = sizeof(int32_t);
|
||||
while(count-- > 0 && length > offset){
|
||||
int32_t keyLen = *(int32_t*)(result + offset);
|
||||
offset += sizeof(int32_t);
|
||||
|
||||
uint64_t tableGroupId = *(uint64_t *)(result + offset);
|
||||
SResultRow *resultRow = getNewResultRow_rv(pSup->pResultBuf, tableGroupId, pSup->resultRowSize);
|
||||
if (!resultRow){
|
||||
terrno = TSDB_CODE_TSC_INVALID_INPUT;
|
||||
return false;
|
||||
}
|
||||
// add a new result set for a new group
|
||||
taosHashPut(pSup->pResultRowHashTable, result + offset, keyLen, &resultRow, POINTER_BYTES);
|
||||
|
||||
offset += keyLen;
|
||||
int32_t valueLen = *(int32_t*)(result + offset);
|
||||
if (valueLen != pSup->resultRowSize){
|
||||
terrno = TSDB_CODE_TSC_INVALID_INPUT;
|
||||
return false;
|
||||
}
|
||||
offset += sizeof(int32_t);
|
||||
int32_t pageId = resultRow->pageId;
|
||||
int32_t pOffset = resultRow->offset;
|
||||
memcpy(resultRow, result + offset, valueLen);
|
||||
resultRow->pageId = pageId;
|
||||
resultRow->offset = pOffset;
|
||||
offset += valueLen;
|
||||
|
||||
initResultRow(resultRow);
|
||||
|
||||
pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.size++] = (SResultRowPosition) {.pageId = resultRow->pageId, .offset = resultRow->offset};
|
||||
}
|
||||
|
||||
if (offset != length){
|
||||
terrno = TSDB_CODE_TSC_INVALID_INPUT;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static SSDataBlock* doMultiTableAggregate(SOperatorInfo *pOperator, bool* newgroup) {
|
||||
if (pOperator->status == OP_EXEC_DONE) {
|
||||
return NULL;
|
||||
|
@ -7086,10 +7179,10 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo *pOperator, bool* newgrou
|
|||
static void doHandleRemainBlockForNewGroupImpl(SFillOperatorInfo *pInfo, SResultInfo* pResultInfo, bool* newgroup, SExecTaskInfo* pTaskInfo) {
|
||||
pInfo->totalInputRows = pInfo->existNewGroupBlock->info.rows;
|
||||
|
||||
// int64_t ekey = Q_STATUS_EQUAL(pRuntimeEnv->status, TASK_COMPLETED)? pTaskInfo->window.ekey:pInfo->existNewGroupBlock->info.window.ekey;
|
||||
int64_t ekey = Q_STATUS_EQUAL(pTaskInfo->status, TASK_COMPLETED)? pTaskInfo->window.ekey:pInfo->existNewGroupBlock->info.window.ekey;
|
||||
taosResetFillInfo(pInfo->pFillInfo, getFillInfoStart(pInfo->pFillInfo));
|
||||
|
||||
// taosFillSetStartInfo(pInfo->pFillInfo, pInfo->existNewGroupBlock->info.rows, ekey);
|
||||
taosFillSetStartInfo(pInfo->pFillInfo, pInfo->existNewGroupBlock->info.rows, ekey);
|
||||
taosFillSetInputDataBlock(pInfo->pFillInfo, pInfo->existNewGroupBlock);
|
||||
|
||||
doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, pResultInfo->capacity, pInfo->p);
|
||||
|
@ -7097,7 +7190,7 @@ static void doHandleRemainBlockForNewGroupImpl(SFillOperatorInfo *pInfo, SResult
|
|||
*newgroup = true;
|
||||
}
|
||||
|
||||
static void doHandleRemainBlockFromNewGroup(SFillOperatorInfo *pInfo, SResultInfo *pResultInfo, bool *newgroup) {
|
||||
static void doHandleRemainBlockFromNewGroup(SFillOperatorInfo *pInfo, SResultInfo *pResultInfo, bool *newgroup, SExecTaskInfo* pTaskInfo) {
|
||||
if (taosFillHasMoreResults(pInfo->pFillInfo)) {
|
||||
*newgroup = false;
|
||||
doFillTimeIntervalGapsInResults(pInfo->pFillInfo, pInfo->pRes, (int32_t)pResultInfo->capacity, pInfo->p);
|
||||
|
@ -7108,12 +7201,13 @@ static void doHandleRemainBlockFromNewGroup(SFillOperatorInfo *pInfo, SResultInf
|
|||
|
||||
// handle the cached new group data block
|
||||
if (pInfo->existNewGroupBlock) {
|
||||
// doHandleRemainBlockForNewGroupImpl(pInfo, pResultInfo, newgroup);
|
||||
doHandleRemainBlockForNewGroupImpl(pInfo, pResultInfo, newgroup, pTaskInfo);
|
||||
}
|
||||
}
|
||||
|
||||
static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
|
||||
SFillOperatorInfo *pInfo = pOperator->info;
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
|
||||
SResultInfo* pResultInfo = &pOperator->resultInfo;
|
||||
blockDataCleanup(pInfo->pRes);
|
||||
|
@ -7121,7 +7215,7 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
doHandleRemainBlockFromNewGroup(pInfo, pResultInfo, newgroup);
|
||||
doHandleRemainBlockFromNewGroup(pInfo, pResultInfo, newgroup, pTaskInfo);
|
||||
if (pInfo->pRes->info.rows > pResultInfo->threshold || (!pInfo->multigroupResult && pInfo->pRes->info.rows > 0)) {
|
||||
return pInfo->pRes;
|
||||
}
|
||||
|
@ -7142,7 +7236,7 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
|
|||
|
||||
// Fill the previous group data block, before handle the data block of new group.
|
||||
// Close the fill operation for previous group data block
|
||||
// taosFillSetStartInfo(pInfo->pFillInfo, 0, pRuntimeEnv->pQueryAttr->window.ekey);
|
||||
taosFillSetStartInfo(pInfo->pFillInfo, 0, pTaskInfo->window.ekey);
|
||||
} else {
|
||||
if (pBlock == NULL) {
|
||||
if (pInfo->totalInputRows == 0) {
|
||||
|
@ -7150,7 +7244,7 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// taosFillSetStartInfo(pInfo->pFillInfo, 0, pRuntimeEnv->pQueryAttr->window.ekey);
|
||||
taosFillSetStartInfo(pInfo->pFillInfo, 0, pTaskInfo->window.ekey);
|
||||
} else {
|
||||
pInfo->totalInputRows += pBlock->info.rows;
|
||||
taosFillSetStartInfo(pInfo->pFillInfo, pBlock->info.rows, pBlock->info.window.ekey);
|
||||
|
@ -7168,14 +7262,13 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
|
|||
return pInfo->pRes;
|
||||
}
|
||||
|
||||
// doHandleRemainBlockFromNewGroup(pInfo, pRuntimeEnv, newgroup);
|
||||
doHandleRemainBlockFromNewGroup(pInfo, pResultInfo, newgroup, pTaskInfo);
|
||||
if (pInfo->pRes->info.rows > pOperator->resultInfo.threshold || pBlock == NULL) {
|
||||
return pInfo->pRes;
|
||||
}
|
||||
} else if (pInfo->existNewGroupBlock) { // try next group
|
||||
assert(pBlock != NULL);
|
||||
// doHandleRemainBlockForNewGroupImpl(pInfo, pRuntimeEnv, newgroup);
|
||||
|
||||
doHandleRemainBlockForNewGroupImpl(pInfo, pResultInfo, newgroup, pTaskInfo);
|
||||
if (pInfo->pRes->info.rows > pResultInfo->threshold) {
|
||||
return pInfo->pRes;
|
||||
}
|
||||
|
@ -7312,6 +7405,8 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
pOperator->_openFn = doOpenAggregateOptr;
|
||||
pOperator->getNextFn = getAggregateResult;
|
||||
pOperator->closeFn = destroyAggOperatorInfo;
|
||||
pOperator->encodeResultRow = aggEncodeResultRow;
|
||||
pOperator->decodeResultRow = aggDecodeResultRow;
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -7576,7 +7671,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
|||
}
|
||||
|
||||
pInfo->order = TSDB_ORDER_ASC;
|
||||
pInfo->precision = TSDB_TIME_PRECISION_MICRO;
|
||||
pInfo->precision = TSDB_TIME_PRECISION_MILLI;
|
||||
pInfo->win = pTaskInfo->window;
|
||||
pInfo->interval = *pInterval;
|
||||
|
||||
|
@ -7863,10 +7958,10 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExp
|
|||
pInfo->intervalInfo = *pInterval;
|
||||
|
||||
SResultInfo* pResultInfo = &pOperator->resultInfo;
|
||||
// int32_t code = initFillInfo(pInfo, pExpr, numOfCols, fillVal, , pResultInfo->capacity, pTaskInfo->id.str, pInterval, fillType);
|
||||
// if (code != TSDB_CODE_SUCCESS) {
|
||||
// goto _error;
|
||||
// }
|
||||
int32_t code = initFillInfo(pInfo, pExpr, numOfCols, (int64_t*) fillVal, pTaskInfo->window, pResultInfo->capacity, pTaskInfo->id.str, pInterval, fillType);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
pOperator->name = "FillOperator";
|
||||
pOperator->blockingOptr = false;
|
||||
|
@ -7881,7 +7976,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExp
|
|||
|
||||
pOperator->closeFn = destroySFillOperatorInfo;
|
||||
|
||||
int32_t code = appendDownstream(pOperator, &downstream, 1);
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
return pOperator;
|
||||
|
||||
_error:
|
||||
|
|
|
@ -1,12 +1,55 @@
|
|||
aux_source_directory(src FUNCTION_SRC)
|
||||
list(REMOVE_ITEM FUNCTION_SRC src/udfd.c)
|
||||
add_library(function STATIC ${FUNCTION_SRC})
|
||||
target_include_directories(
|
||||
function
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/function"
|
||||
PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/include/libs/function"
|
||||
"${CMAKE_SOURCE_DIR}/contrib/libuv/include"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
function
|
||||
PUBLIC uv_a
|
||||
PRIVATE os util common nodes
|
||||
)
|
||||
)
|
||||
|
||||
add_executable(runUdf test/runUdf.c)
|
||||
target_include_directories(
|
||||
runUdf
|
||||
PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/include/libs/function"
|
||||
"${CMAKE_SOURCE_DIR}/contrib/libuv/include"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
target_link_libraries(
|
||||
runUdf
|
||||
PUBLIC uv_a
|
||||
PRIVATE os util common nodes function
|
||||
)
|
||||
|
||||
add_library(udf1 MODULE test/udf1.c)
|
||||
target_include_directories(
|
||||
udf1
|
||||
PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/include/libs/function"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
|
||||
#SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/bin)
|
||||
add_executable(udfd src/udfd.c)
|
||||
target_include_directories(
|
||||
udfd
|
||||
PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/include/libs/function"
|
||||
"${CMAKE_SOURCE_DIR}/contrib/libuv/include"
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
udfd
|
||||
PUBLIC uv_a
|
||||
PRIVATE os util common nodes function
|
||||
)
|
||||
|
||||
|
|
|
@ -20,68 +20,116 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "os.h"
|
||||
#include "taoserror.h"
|
||||
//======================================================================================
|
||||
//begin API to taosd and qworker
|
||||
/**
|
||||
* start udf dameon service
|
||||
* @return error code
|
||||
*/
|
||||
int32_t startUdfService();
|
||||
|
||||
/**
|
||||
* stop udf dameon service
|
||||
* @return error code
|
||||
*/
|
||||
int32_t stopUdfService();
|
||||
|
||||
enum {
|
||||
TSDB_UDF_FUNC_NORMAL = 0,
|
||||
TSDB_UDF_FUNC_INIT,
|
||||
TSDB_UDF_FUNC_FINALIZE,
|
||||
TSDB_UDF_FUNC_MERGE,
|
||||
TSDB_UDF_FUNC_DESTROY,
|
||||
TSDB_UDF_FUNC_MAX_NUM
|
||||
TSDB_UDF_TYPE_SCALAR = 0,
|
||||
TSDB_UDF_TYPE_AGGREGATE = 1
|
||||
};
|
||||
|
||||
typedef struct SUdfInit {
|
||||
int32_t maybe_null; /* 1 if function can return NULL */
|
||||
uint32_t decimals; /* for real functions */
|
||||
uint64_t length; /* For string functions */
|
||||
char* ptr; /* free pointer for function data */
|
||||
int32_t const_item; /* 0 if result is independent of arguments */
|
||||
|
||||
// script like lua/javascript
|
||||
void* script_ctx;
|
||||
void (*destroyCtxFunc)(void* script_ctx);
|
||||
} SUdfInit;
|
||||
enum {
|
||||
TSDB_UDF_SCRIPT_BIN_LIB = 0,
|
||||
TSDB_UDF_SCRIPT_LUA = 1,
|
||||
};
|
||||
|
||||
typedef struct SUdfInfo {
|
||||
int32_t functionId; // system assigned function id
|
||||
int32_t funcType; // scalar function or aggregate function
|
||||
int8_t resType; // result type
|
||||
int16_t resBytes; // result byte
|
||||
int32_t contLen; // content length
|
||||
int32_t bufSize; // interbuf size
|
||||
char* name; // function name
|
||||
void* handle; // handle loaded in mem
|
||||
void* funcs[TSDB_UDF_FUNC_MAX_NUM]; // function ptr
|
||||
char *udfName; // function name
|
||||
int32_t udfType; // scalar function or aggregate function
|
||||
int8_t scriptType;
|
||||
char *path;
|
||||
|
||||
// for script like lua/javascript only
|
||||
int isScript;
|
||||
void* pScriptCtx;
|
||||
int8_t resType; // result type
|
||||
int16_t resBytes; // result byte
|
||||
int32_t bufSize; //interbuf size
|
||||
|
||||
SUdfInit init;
|
||||
char* content;
|
||||
char* path;
|
||||
} SUdfInfo;
|
||||
|
||||
typedef void *UdfHandle;
|
||||
|
||||
/**
|
||||
* setup udf
|
||||
* @param udf, in
|
||||
* @param handle, out
|
||||
* @return error code
|
||||
*/
|
||||
int32_t setupUdf(SUdfInfo* udf, UdfHandle *handle);
|
||||
|
||||
|
||||
enum {
|
||||
TSDB_UDF_STEP_NORMAL = 0,
|
||||
TSDB_UDF_STEP_MERGE,
|
||||
TSDb_UDF_STEP_FINALIZE,
|
||||
TSDB_UDF_STEP_MAX_NUM
|
||||
};
|
||||
/**
|
||||
* call udf
|
||||
* @param handle udf handle
|
||||
* @param step
|
||||
* @param state
|
||||
* @param stateSize
|
||||
* @param input
|
||||
* @param newstate
|
||||
* @param newStateSize
|
||||
* @param output
|
||||
* @return error code
|
||||
*/
|
||||
|
||||
//TODO: must change the following after metadata flow and data flow between qworker and udfd is well defined
|
||||
typedef struct SUdfDataBlock {
|
||||
char* data;
|
||||
int32_t size;
|
||||
} SUdfDataBlock;
|
||||
|
||||
int32_t callUdf(UdfHandle handle, int8_t step, char *state, int32_t stateSize, SUdfDataBlock input, char **newstate,
|
||||
int32_t *newStateSize, SUdfDataBlock *output);
|
||||
|
||||
/**
|
||||
* tearn down udf
|
||||
* @param handle
|
||||
* @return
|
||||
*/
|
||||
int32_t teardownUdf(UdfHandle handle);
|
||||
|
||||
// end API to taosd and qworker
|
||||
//=============================================================================================================================
|
||||
// TODO: Must change
|
||||
// begin API to UDF writer.
|
||||
|
||||
// script
|
||||
|
||||
typedef int32_t (*scriptInitFunc)(void* pCtx);
|
||||
typedef void (*scriptNormalFunc)(void* pCtx, char* data, int16_t iType, int16_t iBytes, int32_t numOfRows,
|
||||
int64_t* ptList, int64_t key, char* dataOutput, char* tsOutput, int32_t* numOfOutput,
|
||||
int16_t oType, int16_t oBytes);
|
||||
typedef void (*scriptFinalizeFunc)(void* pCtx, int64_t key, char* dataOutput, int32_t* numOfOutput);
|
||||
typedef void (*scriptMergeFunc)(void* pCtx, char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput);
|
||||
typedef void (*scriptDestroyFunc)(void* pCtx);
|
||||
//typedef int32_t (*scriptInitFunc)(void* pCtx);
|
||||
//typedef void (*scriptNormalFunc)(void* pCtx, char* data, int16_t iType, int16_t iBytes, int32_t numOfRows,
|
||||
// int64_t* ptList, int64_t key, char* dataOutput, char* tsOutput, int32_t* numOfOutput,
|
||||
// int16_t oType, int16_t oBytes);
|
||||
//typedef void (*scriptFinalizeFunc)(void* pCtx, int64_t key, char* dataOutput, int32_t* numOfOutput);
|
||||
//typedef void (*scriptMergeFunc)(void* pCtx, char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput);
|
||||
//typedef void (*scriptDestroyFunc)(void* pCtx);
|
||||
|
||||
// dynamic lib
|
||||
typedef void (*udfNormalFunc)(char* data, int16_t itype, int16_t iBytes, int32_t numOfRows, int64_t* ts,
|
||||
char* dataOutput, char* interBuf, char* tsOutput, int32_t* numOfOutput, int16_t oType,
|
||||
int16_t oBytes, SUdfInit* buf);
|
||||
typedef int32_t (*udfInitFunc)(SUdfInit* data);
|
||||
typedef void (*udfFinalizeFunc)(char* dataOutput, char* interBuf, int32_t* numOfOutput, SUdfInit* buf);
|
||||
typedef void (*udfMergeFunc)(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf);
|
||||
typedef void (*udfDestroyFunc)(SUdfInit* buf);
|
||||
typedef int32_t (*TUdfInitFunc)();
|
||||
typedef void (*TUdfDestroyFunc)();
|
||||
|
||||
typedef void (*TUdfFunc)(int8_t step,
|
||||
char *state, int32_t stateSize, SUdfDataBlock input,
|
||||
char **newstate, int32_t *newStateSize, SUdfDataBlock *output);
|
||||
|
||||
//typedef void (*udfMergeFunc)(char *data, int32_t numOfRows, char *dataOutput, int32_t* numOfOutput);
|
||||
//typedef void (*udfFinalizeFunc)(char* state, int32_t stateSize, SUdfDataBlock *output);
|
||||
|
||||
// end API to UDF writer
|
||||
//=======================================================================================================================
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_TUDF_INT_H
|
||||
#define TDENGINE_TUDF_INT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//TODO replaces them with fnDebug
|
||||
//#define debugPrint(...) taosPrintLog("Function", DEBUG_INFO, 135, __VA_ARGS__)
|
||||
#define debugPrint(...) {fprintf(stderr, __VA_ARGS__);fprintf(stderr, "\n");}
|
||||
enum {
|
||||
UDF_TASK_SETUP = 0,
|
||||
UDF_TASK_CALL = 1,
|
||||
UDF_TASK_TEARDOWN = 2
|
||||
|
||||
};
|
||||
|
||||
typedef struct SUdfSetupRequest {
|
||||
char udfName[16]; //
|
||||
int8_t scriptType; // 0:c, 1: lua, 2:js
|
||||
int8_t udfType; //udaf, udf
|
||||
int16_t pathSize;
|
||||
char *path;
|
||||
} SUdfSetupRequest;
|
||||
|
||||
typedef struct SUdfSetupResponse {
|
||||
int64_t udfHandle;
|
||||
} SUdfSetupResponse;
|
||||
|
||||
|
||||
typedef struct SUdfCallRequest {
|
||||
int64_t udfHandle;
|
||||
int8_t step;
|
||||
|
||||
int32_t inputBytes;
|
||||
char *input;
|
||||
|
||||
int32_t stateBytes;
|
||||
char *state;
|
||||
} SUdfCallRequest;
|
||||
|
||||
|
||||
typedef struct SUdfCallResponse {
|
||||
int32_t outputBytes;
|
||||
char *output;
|
||||
int32_t newStateBytes;
|
||||
char *newState;
|
||||
} SUdfCallResponse;
|
||||
|
||||
|
||||
typedef struct SUdfTeardownRequest {
|
||||
int64_t udfHandle;
|
||||
} SUdfTeardownRequest;
|
||||
|
||||
|
||||
typedef struct SUdfTeardownResponse {
|
||||
} SUdfTeardownResponse;
|
||||
|
||||
typedef struct SUdfRequest {
|
||||
int32_t msgLen;
|
||||
int64_t seqNum;
|
||||
|
||||
int8_t type;
|
||||
void *subReq;
|
||||
} SUdfRequest;
|
||||
|
||||
typedef struct SUdfResponse {
|
||||
int32_t msgLen;
|
||||
int64_t seqNum;
|
||||
|
||||
int8_t type;
|
||||
int32_t code;
|
||||
void *subRsp;
|
||||
} SUdfResponse;
|
||||
|
||||
int32_t decodeRequest(char *buf, int32_t bufLen, SUdfRequest **pRequest);
|
||||
int32_t encodeResponse(char **buf, int32_t *bufLen, SUdfResponse *response);
|
||||
int32_t encodeRequest(char **buf, int32_t *bufLen, SUdfRequest *request);
|
||||
int32_t decodeResponse(char *buf, int32_t bufLen, SUdfResponse **pResponse);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TDENGINE_TUDF_INT_H
|
|
@ -0,0 +1,110 @@
|
|||
//
|
||||
// Created by shenglian on 28/02/22.
|
||||
//
|
||||
|
||||
#ifndef UDF_UDF_H
|
||||
#define UDF_UDF_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#define DEBUG
|
||||
#ifdef DEBUG
|
||||
#define debugPrint(...) fprintf(__VA_ARGS__)
|
||||
#else
|
||||
#define debugPrint(...) /**/
|
||||
#endif
|
||||
|
||||
enum {
|
||||
UDF_TASK_SETUP = 0,
|
||||
UDF_TASK_CALL = 1,
|
||||
UDF_TASK_TEARDOWN = 2
|
||||
|
||||
};
|
||||
|
||||
typedef struct SSDataBlock{
|
||||
char *data;
|
||||
int32_t size;
|
||||
} SSDataBlock;
|
||||
|
||||
typedef struct SUdfInfo {
|
||||
char *udfName;
|
||||
char *path;
|
||||
} SUdfInfo;
|
||||
|
||||
typedef void *UdfHandle;
|
||||
|
||||
int32_t startUdfService();
|
||||
|
||||
int32_t stopUdfService();
|
||||
|
||||
//int32_t setupUdf(SUdfInfo *udf, int32_t numOfUdfs, UdfHandle *handles);
|
||||
|
||||
int32_t setupUdf(SUdfInfo* udf, UdfHandle* handle);
|
||||
|
||||
int32_t callUdf(UdfHandle handle, int8_t step, char *state, int32_t stateSize, SSDataBlock input, char **newstate,
|
||||
int32_t *newStateSize, SSDataBlock *output);
|
||||
|
||||
int32_t teardownUdf(UdfHandle handle);
|
||||
|
||||
typedef struct SUdfSetupRequest {
|
||||
char udfName[16]; //
|
||||
int8_t scriptType; // 0:c, 1: lua, 2:js
|
||||
int8_t udfType; //udaf, udf, udtf
|
||||
int16_t pathSize;
|
||||
char *path;
|
||||
} SUdfSetupRequest;
|
||||
|
||||
typedef struct SUdfSetupResponse {
|
||||
int64_t udfHandle;
|
||||
} SUdfSetupResponse;
|
||||
|
||||
|
||||
typedef struct SUdfCallRequest {
|
||||
int64_t udfHandle;
|
||||
int8_t step;
|
||||
|
||||
int32_t inputBytes;
|
||||
char *input;
|
||||
|
||||
int32_t stateBytes;
|
||||
char *state;
|
||||
} SUdfCallRequest;
|
||||
|
||||
|
||||
typedef struct SUdfCallResponse {
|
||||
int32_t outputBytes;
|
||||
char *output;
|
||||
int32_t newStateBytes;
|
||||
char *newState;
|
||||
} SUdfCallResponse;
|
||||
|
||||
|
||||
typedef struct SUdfTeardownRequest {
|
||||
int64_t udfHandle;
|
||||
} SUdfTeardownRequest;
|
||||
|
||||
|
||||
typedef struct SUdfTeardownResponse {
|
||||
} SUdfTeardownResponse;
|
||||
|
||||
typedef struct SUdfRequest {
|
||||
int32_t msgLen;
|
||||
int64_t seqNum;
|
||||
|
||||
int8_t type;
|
||||
void *subReq;
|
||||
} SUdfRequest;
|
||||
|
||||
typedef struct SUdfResponse {
|
||||
int32_t msgLen;
|
||||
int64_t seqNum;
|
||||
|
||||
int8_t type;
|
||||
int32_t code;
|
||||
void *subRsp;
|
||||
} SUdfResponse;
|
||||
|
||||
int32_t decodeRequest(char *buf, int32_t bufLen, SUdfRequest **pRequest);
|
||||
int32_t encodeResponse(char **buf, int32_t *bufLen, SUdfResponse *response);
|
||||
int32_t encodeRequest(char **buf, int32_t *bufLen, SUdfRequest *request);
|
||||
int32_t decodeResponse(char *buf, int32_t bufLen, SUdfResponse **pResponse);
|
||||
#endif //UDF_UDF_H
|
|
@ -528,11 +528,10 @@ void firstFunction(SqlFunctionCtx *pCtx) {
|
|||
char* buf = GET_ROWCELL_INTERBUF(pResInfo);
|
||||
|
||||
SInputColumnInfoData* pInput = &pCtx->input;
|
||||
|
||||
SColumnInfoData* pInputCol = pInput->pData[0];
|
||||
|
||||
// All null data column, return directly.
|
||||
if (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows) {
|
||||
if (pInput->colDataAggIsSet && (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows)) {
|
||||
ASSERT(pInputCol->hasNull == true);
|
||||
return;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,356 @@
|
|||
/*
|
||||
* 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 "uv.h"
|
||||
#include "os.h"
|
||||
#include "tlog.h"
|
||||
|
||||
#include "tudf.h"
|
||||
#include "tudfInt.h"
|
||||
|
||||
|
||||
static uv_loop_t *loop;
|
||||
|
||||
typedef struct SUdfdUvConn {
|
||||
uv_stream_t *client;
|
||||
char *inputBuf;
|
||||
int32_t inputLen;
|
||||
int32_t inputCap;
|
||||
int32_t inputTotal;
|
||||
} SUdfdUvConn;
|
||||
|
||||
typedef struct SUvUdfWork {
|
||||
uv_stream_t *client;
|
||||
uv_buf_t input;
|
||||
uv_buf_t output;
|
||||
} SUvUdfWork;
|
||||
|
||||
typedef struct SUdf {
|
||||
int32_t refCount;
|
||||
|
||||
char name[16];
|
||||
int8_t type;
|
||||
|
||||
uv_lib_t lib;
|
||||
TUdfFunc normalFunc;
|
||||
} SUdf;
|
||||
|
||||
//TODO: low priority: change name onxxx to xxxCb, and udfc or udfd as prefix
|
||||
//TODO: add private udf structure.
|
||||
typedef struct SUdfHandle {
|
||||
SUdf *udf;
|
||||
} SUdfHandle;
|
||||
|
||||
|
||||
void udfdProcessRequest(uv_work_t *req) {
|
||||
SUvUdfWork *uvUdf = (SUvUdfWork *) (req->data);
|
||||
SUdfRequest *request = NULL;
|
||||
decodeRequest(uvUdf->input.base, uvUdf->input.len, &request);
|
||||
|
||||
switch (request->type) {
|
||||
case UDF_TASK_SETUP: {
|
||||
debugPrint("%s", "process setup request");
|
||||
SUdf *udf = malloc(sizeof(SUdf));
|
||||
udf->refCount = 0;
|
||||
SUdfSetupRequest *setup = request->subReq;
|
||||
strcpy(udf->name, setup->udfName);
|
||||
int err = uv_dlopen(setup->path, &udf->lib);
|
||||
if (err != 0) {
|
||||
debugPrint("can not load library %s. error: %s", setup->path, uv_strerror(err));
|
||||
//TODO set error
|
||||
}
|
||||
|
||||
char normalFuncName[32] = {0};
|
||||
strcpy(normalFuncName, setup->udfName);
|
||||
//TODO error,
|
||||
//TODO find all functions normal, init, destroy, normal, merge, finalize
|
||||
uv_dlsym(&udf->lib, normalFuncName, (void **) (&udf->normalFunc));
|
||||
|
||||
SUdfHandle *handle = malloc(sizeof(SUdfHandle));
|
||||
handle->udf = udf;
|
||||
udf->refCount++;
|
||||
//TODO: allocate private structure and call init function and set it to handle
|
||||
SUdfResponse *rsp = malloc(sizeof(SUdfResponse));
|
||||
rsp->seqNum = request->seqNum;
|
||||
rsp->type = request->type;
|
||||
rsp->code = 0;
|
||||
SUdfSetupResponse *subRsp = malloc(sizeof(SUdfSetupResponse));
|
||||
subRsp->udfHandle = (int64_t) (handle);
|
||||
rsp->subRsp = subRsp;
|
||||
char *buf;
|
||||
int32_t len;
|
||||
encodeResponse(&buf, &len, rsp);
|
||||
|
||||
uvUdf->output = uv_buf_init(buf, len);
|
||||
|
||||
free(rsp->subRsp);
|
||||
free(rsp);
|
||||
free(request->subReq);
|
||||
free(request);
|
||||
free(uvUdf->input.base);
|
||||
break;
|
||||
}
|
||||
|
||||
case UDF_TASK_CALL: {
|
||||
debugPrint("%s", "process call request");
|
||||
SUdfCallRequest *call = request->subReq;
|
||||
SUdfHandle *handle = (SUdfHandle *) (call->udfHandle);
|
||||
SUdf *udf = handle->udf;
|
||||
char *newState;
|
||||
int32_t newStateSize;
|
||||
SUdfDataBlock input = {.data = call->input, .size= call->inputBytes};
|
||||
SUdfDataBlock output;
|
||||
//TODO: call different functions according to the step
|
||||
udf->normalFunc(call->step, call->state, call->stateBytes, input, &newState, &newStateSize, &output);
|
||||
|
||||
SUdfResponse *rsp = malloc(sizeof(SUdfResponse));
|
||||
rsp->seqNum = request->seqNum;
|
||||
rsp->type = request->type;
|
||||
rsp->code = 0;
|
||||
SUdfCallResponse *subRsp = malloc(sizeof(SUdfCallResponse));
|
||||
subRsp->outputBytes = output.size;
|
||||
subRsp->output = output.data;
|
||||
subRsp->newStateBytes = newStateSize;
|
||||
subRsp->newState = newState;
|
||||
rsp->subRsp = subRsp;
|
||||
|
||||
char *buf;
|
||||
int32_t len;
|
||||
encodeResponse(&buf, &len, rsp);
|
||||
uvUdf->output = uv_buf_init(buf, len);
|
||||
|
||||
free(rsp->subRsp);
|
||||
free(rsp);
|
||||
free(newState);
|
||||
free(output.data);
|
||||
free(request->subReq);
|
||||
free(request);
|
||||
free(uvUdf->input.base);
|
||||
break;
|
||||
}
|
||||
case UDF_TASK_TEARDOWN: {
|
||||
debugPrint("%s", "process teardown request");
|
||||
|
||||
SUdfTeardownRequest *teardown = request->subReq;
|
||||
SUdfHandle *handle = (SUdfHandle *) (teardown->udfHandle);
|
||||
SUdf *udf = handle->udf;
|
||||
udf->refCount--;
|
||||
if (udf->refCount == 0) {
|
||||
uv_dlclose(&udf->lib);
|
||||
}
|
||||
free(udf);
|
||||
//TODO: call destroy and free udf private
|
||||
free(handle);
|
||||
|
||||
SUdfResponse *rsp = malloc(sizeof(SUdfResponse));
|
||||
rsp->seqNum = request->seqNum;
|
||||
rsp->type = request->type;
|
||||
rsp->code = 0;
|
||||
SUdfTeardownResponse *subRsp = malloc(sizeof(SUdfTeardownResponse));
|
||||
rsp->subRsp = subRsp;
|
||||
char *buf;
|
||||
int32_t len;
|
||||
encodeResponse(&buf, &len, rsp);
|
||||
uvUdf->output = uv_buf_init(buf, len);
|
||||
|
||||
free(rsp->subRsp);
|
||||
free(rsp);
|
||||
free(request->subReq);
|
||||
free(request);
|
||||
free(uvUdf->input.base);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void udfdOnWrite(uv_write_t *req, int status) {
|
||||
debugPrint("%s", "after writing to pipe");
|
||||
if (status < 0) {
|
||||
debugPrint("Write error %s", uv_err_name(status));
|
||||
}
|
||||
SUvUdfWork *work = (SUvUdfWork *) req->data;
|
||||
debugPrint("\tlength: %zu", work->output.len);
|
||||
free(work->output.base);
|
||||
free(work);
|
||||
free(req);
|
||||
}
|
||||
|
||||
|
||||
void udfdSendResponse(uv_work_t *work, int status) {
|
||||
debugPrint("%s", "send response");
|
||||
SUvUdfWork *udfWork = (SUvUdfWork *) (work->data);
|
||||
|
||||
uv_write_t *write_req = malloc(sizeof(uv_write_t));
|
||||
write_req->data = udfWork;
|
||||
uv_write(write_req, udfWork->client, &udfWork->output, 1, udfdOnWrite);
|
||||
|
||||
free(work);
|
||||
}
|
||||
|
||||
void udfdAllocBuffer(uv_handle_t *handle, size_t suggestedSize, uv_buf_t *buf) {
|
||||
debugPrint("%s", "allocate buffer for read");
|
||||
SUdfdUvConn *ctx = handle->data;
|
||||
int32_t msgHeadSize = sizeof(int32_t) + sizeof(int64_t);
|
||||
if (ctx->inputCap == 0) {
|
||||
ctx->inputBuf = malloc(msgHeadSize);
|
||||
if (ctx->inputBuf) {
|
||||
ctx->inputLen = 0;
|
||||
ctx->inputCap = msgHeadSize;
|
||||
ctx->inputTotal = -1;
|
||||
|
||||
buf->base = ctx->inputBuf;
|
||||
buf->len = ctx->inputCap;
|
||||
} else {
|
||||
//TODO: log error
|
||||
buf->base = NULL;
|
||||
buf->len = 0;
|
||||
}
|
||||
} else {
|
||||
ctx->inputCap = ctx->inputTotal > ctx->inputCap ? ctx->inputTotal : ctx->inputCap;
|
||||
void *inputBuf = realloc(ctx->inputBuf, ctx->inputCap);
|
||||
if (inputBuf) {
|
||||
ctx->inputBuf = inputBuf;
|
||||
buf->base = ctx->inputBuf + ctx->inputLen;
|
||||
buf->len = ctx->inputCap - ctx->inputLen;
|
||||
} else {
|
||||
//TODO: log error
|
||||
buf->base = NULL;
|
||||
buf->len = 0;
|
||||
}
|
||||
}
|
||||
debugPrint("\tinput buf cap - len - total : %d - %d - %d", ctx->inputCap, ctx->inputLen, ctx->inputTotal);
|
||||
|
||||
}
|
||||
|
||||
bool isUdfdUvMsgComplete(SUdfdUvConn *pipe) {
|
||||
if (pipe->inputTotal == -1 && pipe->inputLen >= sizeof(int32_t)) {
|
||||
pipe->inputTotal = *(int32_t *) (pipe->inputBuf);
|
||||
}
|
||||
if (pipe->inputLen == pipe->inputCap && pipe->inputTotal == pipe->inputCap) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void udfdHandleRequest(SUdfdUvConn *conn) {
|
||||
uv_work_t *work = malloc(sizeof(uv_work_t));
|
||||
SUvUdfWork *udfWork = malloc(sizeof(SUvUdfWork));
|
||||
udfWork->client = conn->client;
|
||||
udfWork->input = uv_buf_init(conn->inputBuf, conn->inputLen);
|
||||
conn->inputBuf = NULL;
|
||||
conn->inputLen = 0;
|
||||
conn->inputCap = 0;
|
||||
conn->inputTotal = -1;
|
||||
work->data = udfWork;
|
||||
uv_queue_work(loop, work, udfdProcessRequest, udfdSendResponse);
|
||||
}
|
||||
|
||||
void udfdPipeCloseCb(uv_handle_t *pipe) {
|
||||
SUdfdUvConn *conn = pipe->data;
|
||||
free(conn->client);
|
||||
free(conn->inputBuf);
|
||||
free(conn);
|
||||
}
|
||||
|
||||
void udfdUvHandleError(SUdfdUvConn *conn) {
|
||||
uv_close((uv_handle_t *) conn->client, udfdPipeCloseCb);
|
||||
}
|
||||
|
||||
void udfdPipeRead(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) {
|
||||
debugPrint("%s, nread: %zd", "read from pipe", nread);
|
||||
|
||||
if (nread == 0) return;
|
||||
|
||||
SUdfdUvConn *conn = client->data;
|
||||
|
||||
if (nread > 0) {
|
||||
conn->inputLen += nread;
|
||||
if (isUdfdUvMsgComplete(conn)) {
|
||||
udfdHandleRequest(conn);
|
||||
} else {
|
||||
//log error or continue;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (nread < 0) {
|
||||
debugPrint("Read error %s", uv_err_name(nread));
|
||||
if (nread == UV_EOF) {
|
||||
//TODO check more when close
|
||||
} else {
|
||||
}
|
||||
udfdUvHandleError(conn);
|
||||
}
|
||||
}
|
||||
|
||||
void udfdOnNewConnection(uv_stream_t *server, int status) {
|
||||
debugPrint("%s", "on new connection");
|
||||
if (status < 0) {
|
||||
// TODO
|
||||
return;
|
||||
}
|
||||
|
||||
uv_pipe_t *client = (uv_pipe_t *) malloc(sizeof(uv_pipe_t));
|
||||
uv_pipe_init(loop, client, 0);
|
||||
if (uv_accept(server, (uv_stream_t *) client) == 0) {
|
||||
SUdfdUvConn *ctx = malloc(sizeof(SUdfdUvConn));
|
||||
ctx->client = (uv_stream_t *) client;
|
||||
ctx->inputBuf = 0;
|
||||
ctx->inputLen = 0;
|
||||
ctx->inputCap = 0;
|
||||
client->data = ctx;
|
||||
ctx->client = (uv_stream_t *) client;
|
||||
uv_read_start((uv_stream_t *) client, udfdAllocBuffer, udfdPipeRead);
|
||||
} else {
|
||||
uv_close((uv_handle_t *) client, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void removeListeningPipe(int sig) {
|
||||
uv_fs_t req;
|
||||
uv_fs_unlink(loop, &req, "udf.sock", NULL);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main() {
|
||||
debugPrint("libuv version: %x", UV_VERSION_HEX);
|
||||
|
||||
loop = uv_default_loop();
|
||||
uv_fs_t req;
|
||||
uv_fs_unlink(loop, &req, "udf.sock", NULL);
|
||||
|
||||
uv_pipe_t server;
|
||||
uv_pipe_init(loop, &server, 0);
|
||||
|
||||
signal(SIGINT, removeListeningPipe);
|
||||
|
||||
int r;
|
||||
if ((r = uv_pipe_bind(&server, "udf.sock"))) {
|
||||
debugPrint("Bind error %s\n", uv_err_name(r));
|
||||
removeListeningPipe(0);
|
||||
return 1;
|
||||
}
|
||||
if ((r = uv_listen((uv_stream_t *) &server, 128, udfdOnNewConnection))) {
|
||||
debugPrint("Listen error %s", uv_err_name(r));
|
||||
return 2;
|
||||
}
|
||||
uv_run(loop, UV_RUN_DEFAULT);
|
||||
uv_loop_close(loop);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "uv.h"
|
||||
#include "tudf.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
startUdfService();
|
||||
uv_sleep(1000);
|
||||
char path[256] = {0};
|
||||
size_t cwdSize = 256;
|
||||
int err = uv_cwd(path, &cwdSize);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "err cwd: %s\n", uv_strerror(err));
|
||||
return err;
|
||||
}
|
||||
fprintf(stdout, "current working directory:%s\n", path);
|
||||
strcat(path, "/libudf1.so");
|
||||
SUdfInfo udfInfo = {.udfName="udf1", .path=path};
|
||||
|
||||
UdfHandle handle;
|
||||
setupUdf(&udfInfo, &handle);
|
||||
|
||||
//char state[5000000] = "state";
|
||||
//char input[5000000] = "input";
|
||||
int dataSize = 500;
|
||||
int callCount = 2;
|
||||
if (argc > 1) dataSize = atoi(argv[1]);
|
||||
if (argc > 2) callCount = atoi(argv[2]);
|
||||
char *state = malloc(dataSize);
|
||||
char *input = malloc(dataSize);
|
||||
SUdfDataBlock blockInput = {.data = input, .size = dataSize};
|
||||
SUdfDataBlock blockOutput;
|
||||
char* newState;
|
||||
int32_t newStateSize;
|
||||
for (int l = 0; l < callCount; ++l) {
|
||||
callUdf(handle, 0, state, dataSize, blockInput, &newState, &newStateSize, &blockOutput);
|
||||
}
|
||||
free(state);
|
||||
free(input);
|
||||
teardownUdf(handle);
|
||||
|
||||
stopUdfService();
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "tudf.h"
|
||||
|
||||
void udf1(int8_t step, char *state, int32_t stateSize, SUdfDataBlock input,
|
||||
char **newState, int32_t *newStateSize, SUdfDataBlock *output) {
|
||||
fprintf(stdout, "%s, step:%d\n", "udf function called", step);
|
||||
char *newStateBuf = malloc(stateSize);
|
||||
memcpy(newStateBuf, state, stateSize);
|
||||
*newState = newStateBuf;
|
||||
*newStateSize = stateSize;
|
||||
|
||||
char *outputBuf = malloc(input.size);
|
||||
memcpy(outputBuf, input.data, input.size);
|
||||
output->data = outputBuf;
|
||||
output->size = input.size;
|
||||
return;
|
||||
}
|
|
@ -141,12 +141,12 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
|||
case TSDB_DATA_TYPE_NCHAR:
|
||||
case TSDB_DATA_TYPE_VARCHAR:
|
||||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
pDst->datum.p = malloc(pSrc->node.resType.bytes + VARSTR_HEADER_SIZE);
|
||||
pDst->datum.p = malloc(pSrc->node.resType.bytes + VARSTR_HEADER_SIZE + 1);
|
||||
if (NULL == pDst->datum.p) {
|
||||
nodesDestroyNode(pDst);
|
||||
return NULL;
|
||||
}
|
||||
memcpy(pDst->datum.p, pSrc->datum.p, pSrc->node.resType.bytes + VARSTR_HEADER_SIZE);
|
||||
memcpy(pDst->datum.p, pSrc->datum.p, pSrc->node.resType.bytes + VARSTR_HEADER_SIZE + 1);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_JSON:
|
||||
case TSDB_DATA_TYPE_DECIMAL:
|
||||
|
|
|
@ -1480,7 +1480,7 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) {
|
|||
case TSDB_DATA_TYPE_NCHAR:
|
||||
case TSDB_DATA_TYPE_VARCHAR:
|
||||
case TSDB_DATA_TYPE_VARBINARY: {
|
||||
pNode->datum.p = calloc(1, pNode->node.resType.bytes);
|
||||
pNode->datum.p = calloc(1, pNode->node.resType.bytes + VARSTR_HEADER_SIZE + 1);
|
||||
if (NULL == pNode->datum.p) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
break;
|
||||
|
@ -1807,6 +1807,45 @@ static int32_t groupingSetNodeToJson(const void* pObj, SJson* pJson) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static const char* jkIntervalWindowInterval = "Interval";
|
||||
static const char* jkIntervalWindowOffset = "Offset";
|
||||
static const char* jkIntervalWindowSliding = "Sliding";
|
||||
static const char* jkIntervalWindowFill = "Fill";
|
||||
|
||||
static int32_t intervalWindowNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SIntervalWindowNode* pNode = (const SIntervalWindowNode*)pObj;
|
||||
|
||||
int32_t code = tjsonAddObject(pJson, jkIntervalWindowInterval, nodeToJson, pNode->pInterval);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkIntervalWindowOffset, nodeToJson, pNode->pOffset);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkIntervalWindowSliding, nodeToJson, pNode->pSliding);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkIntervalWindowFill, nodeToJson, pNode->pFill);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t jsonToIntervalWindowNode(const SJson* pJson, void* pObj) {
|
||||
SIntervalWindowNode* pNode = (SIntervalWindowNode*)pObj;
|
||||
|
||||
int32_t code = jsonToNodeObject(pJson, jkIntervalWindowInterval, &pNode->pInterval);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkIntervalWindowOffset, &pNode->pOffset);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkIntervalWindowSliding, &pNode->pSliding);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkIntervalWindowFill, &pNode->pFill);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static const char* jkNodeListDataType = "DataType";
|
||||
static const char* jkNodeListNodeList = "NodeList";
|
||||
|
||||
|
@ -2119,8 +2158,9 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
|||
case QUERY_NODE_LIMIT:
|
||||
case QUERY_NODE_STATE_WINDOW:
|
||||
case QUERY_NODE_SESSION_WINDOW:
|
||||
case QUERY_NODE_INTERVAL_WINDOW:
|
||||
break;
|
||||
case QUERY_NODE_INTERVAL_WINDOW:
|
||||
return intervalWindowNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_NODE_LIST:
|
||||
return nodeListNodeToJson(pObj, pJson);
|
||||
case QUERY_NODE_FILL:
|
||||
|
@ -2222,7 +2262,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
|||
// case QUERY_NODE_LIMIT:
|
||||
// case QUERY_NODE_STATE_WINDOW:
|
||||
// case QUERY_NODE_SESSION_WINDOW:
|
||||
// case QUERY_NODE_INTERVAL_WINDOW:
|
||||
case QUERY_NODE_INTERVAL_WINDOW:
|
||||
return jsonToIntervalWindowNode(pJson, pObj);
|
||||
case QUERY_NODE_NODE_LIST:
|
||||
return jsonToNodeListNode(pJson, pObj);
|
||||
// case QUERY_NODE_FILL:
|
||||
|
|
|
@ -150,9 +150,9 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName);
|
|||
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort);
|
||||
SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode);
|
||||
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue);
|
||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, SToken* pIndexName, SToken* pTableName, SNodeList* pCols, SNode* pOptions);
|
||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName, SToken* pTableName, SNodeList* pCols, SNode* pOptions);
|
||||
SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding);
|
||||
SNode* createDropIndexStmt(SAstCreateContext* pCxt, SToken* pIndexName, SToken* pTableName);
|
||||
SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName, SToken* pTableName);
|
||||
SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId);
|
||||
SNode* createDropQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId);
|
||||
SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName);
|
||||
|
|
|
@ -118,7 +118,7 @@ static FORCE_INLINE void getMemRowAppendInfo(SSchema *pSchema, uint8_t rowType,
|
|||
}
|
||||
|
||||
static FORCE_INLINE int32_t setBlockInfo(SSubmitBlk *pBlocks, STableDataBlocks* dataBuf, int32_t numOfRows) {
|
||||
pBlocks->tid = dataBuf->pTableMeta->suid;
|
||||
pBlocks->suid = (TSDB_NORMAL_TABLE == dataBuf->pTableMeta->tableType ? dataBuf->pTableMeta->uid : dataBuf->pTableMeta->suid);
|
||||
pBlocks->uid = dataBuf->pTableMeta->uid;
|
||||
pBlocks->sversion = dataBuf->pTableMeta->sversion;
|
||||
|
||||
|
|
|
@ -313,10 +313,11 @@ func_name_list(A) ::= func_name_list(B) NK_COMMA col_name(C).
|
|||
func_name(A) ::= function_name(B). { A = createFunctionNode(pCxt, &B, NULL); }
|
||||
|
||||
/************************************************ create index ********************************************************/
|
||||
cmd ::= CREATE SMA INDEX index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &A, &B, NULL, C); }
|
||||
cmd ::= CREATE FULLTEXT INDEX
|
||||
index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &A, &B, C, NULL); }
|
||||
cmd ::= DROP INDEX index_name(A) ON table_name(B). { pCxt->pRootNode = createDropIndexStmt(pCxt, &A, &B); }
|
||||
cmd ::= CREATE SMA INDEX not_exists_opt(D)
|
||||
index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, &A, &B, NULL, C); }
|
||||
cmd ::= CREATE FULLTEXT INDEX not_exists_opt(D)
|
||||
index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, D, &A, &B, C, NULL); }
|
||||
cmd ::= DROP INDEX exists_opt(C) index_name(A) ON table_name(B). { pCxt->pRootNode = createDropIndexStmt(pCxt, C, &A, &B); }
|
||||
|
||||
index_options(A) ::= . { A = NULL; }
|
||||
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
|
||||
|
|
|
@ -1160,13 +1160,14 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
|
|||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, SToken* pIndexName, SToken* pTableName, SNodeList* pCols, SNode* pOptions) {
|
||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName, SToken* pTableName, SNodeList* pCols, SNode* pOptions) {
|
||||
if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) {
|
||||
return NULL;
|
||||
}
|
||||
SCreateIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->indexType = type;
|
||||
pStmt->ignoreExists = ignoreExists;
|
||||
strncpy(pStmt->indexName, pIndexName->z, pIndexName->n);
|
||||
strncpy(pStmt->tableName, pTableName->z, pTableName->n);
|
||||
pStmt->pCols = pCols;
|
||||
|
@ -1184,12 +1185,13 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
|
|||
return (SNode*)pOptions;
|
||||
}
|
||||
|
||||
SNode* createDropIndexStmt(SAstCreateContext* pCxt, SToken* pIndexName, SToken* pTableName) {
|
||||
SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName, SToken* pTableName) {
|
||||
if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) {
|
||||
return NULL;
|
||||
}
|
||||
SDropIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->ignoreNotExists = ignoreNotExists;
|
||||
strncpy(pStmt->indexName, pIndexName->z, pIndexName->n);
|
||||
strncpy(pStmt->tableName, pTableName->z, pTableName->n);
|
||||
return (SNode*)pStmt;
|
||||
|
|
|
@ -48,11 +48,6 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
enum {
|
||||
TSDB_USE_SERVER_TS = 0,
|
||||
TSDB_USE_CLI_TS = 1,
|
||||
};
|
||||
|
||||
typedef struct SInsertParseContext {
|
||||
SParseContext* pComCxt; // input
|
||||
char *pSql; // input
|
||||
|
@ -264,7 +259,7 @@ static void buildMsgHeader(STableDataBlocks* src, SVgDataBlocks* blocks) {
|
|||
while (numOfBlocks--) {
|
||||
int32_t dataLen = blk->dataLen;
|
||||
blk->uid = htobe64(blk->uid);
|
||||
blk->tid = htonl(blk->tid);
|
||||
blk->suid = htobe64(blk->suid);
|
||||
blk->padding = htonl(blk->padding);
|
||||
blk->sversion = htonl(blk->sversion);
|
||||
blk->dataLen = htonl(blk->dataLen);
|
||||
|
@ -303,20 +298,7 @@ static int32_t checkTimestamp(STableDataBlocks *pDataBlocks, const char *start)
|
|||
}
|
||||
|
||||
TSKEY k = *(TSKEY *)start;
|
||||
|
||||
if (k == INT64_MIN) {
|
||||
if (pDataBlocks->tsSource == TSDB_USE_CLI_TS) {
|
||||
return TSDB_CODE_FAILED; // client time/server time can not be mixed
|
||||
}
|
||||
pDataBlocks->tsSource = TSDB_USE_SERVER_TS;
|
||||
} else {
|
||||
if (pDataBlocks->tsSource == TSDB_USE_SERVER_TS) {
|
||||
return TSDB_CODE_FAILED; // client time/server time can not be mixed
|
||||
}
|
||||
pDataBlocks->tsSource = TSDB_USE_CLI_TS;
|
||||
}
|
||||
|
||||
if (k <= pDataBlocks->prevTS && (pDataBlocks->tsSource == TSDB_USE_CLI_TS)) {
|
||||
if (k <= pDataBlocks->prevTS) {
|
||||
pDataBlocks->ordered = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,6 @@ static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t star
|
|||
dataBuf->prevTS = INT64_MIN;
|
||||
dataBuf->rowSize = rowSize;
|
||||
dataBuf->size = startOffset;
|
||||
dataBuf->tsSource = -1;
|
||||
dataBuf->vgId = dataBuf->pTableMeta->vgId;
|
||||
|
||||
assert(defaultSize > 0 && pTableMeta != NULL && dataBuf->pTableMeta != NULL);
|
||||
|
|
|
@ -383,7 +383,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
|
|||
case TSDB_DATA_TYPE_NCHAR:
|
||||
case TSDB_DATA_TYPE_VARCHAR:
|
||||
case TSDB_DATA_TYPE_VARBINARY: {
|
||||
pVal->datum.p = calloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE);
|
||||
pVal->datum.p = calloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1);
|
||||
if (NULL == pVal->datum.p) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -1406,34 +1406,110 @@ static int32_t translateShowTables(STranslateContext* pCxt) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
|
||||
SVCreateTSmaReq createSmaReq = {0};
|
||||
static int32_t getSmaIndexDstVgId(STranslateContext* pCxt, char* pTableName, int32_t* pVgId) {
|
||||
SVgroupInfo vg = {0};
|
||||
int32_t code = getTableHashVgroup(pCxt, pCxt->pParseCxt->db, pTableName, &vg);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pVgId = vg.vgId;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t getSmaIndexSql(STranslateContext* pCxt, char** pSql, int32_t* pLen) {
|
||||
*pSql = strdup(pCxt->pParseCxt->pSql);
|
||||
if (NULL == *pSql) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
*pLen = pCxt->pParseCxt->sqlLen + 1;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t getSmaIndexExpr(STranslateContext* pCxt, SCreateIndexStmt* pStmt, char** pExpr, int32_t* pLen) {
|
||||
return nodesListToString(pStmt->pOptions->pFuncs, false, pExpr, pLen);
|
||||
}
|
||||
|
||||
static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pStmt, char** pAst, int32_t* pLen) {
|
||||
SSelectStmt* pSelect = nodesMakeNode(QUERY_NODE_SELECT_STMT);
|
||||
if (NULL == pSelect) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SRealTableNode* pTable = nodesMakeNode(QUERY_NODE_REAL_TABLE);
|
||||
if (NULL == pTable) {
|
||||
nodesDestroyNode(pSelect);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
strcpy(pTable->table.dbName, pCxt->pParseCxt->db);
|
||||
strcpy(pTable->table.tableName, pStmt->tableName);
|
||||
pSelect->pFromTable = (SNode*)pTable;
|
||||
|
||||
pSelect->pProjectionList = nodesCloneList(pStmt->pOptions->pFuncs);
|
||||
if (NULL == pTable) {
|
||||
nodesDestroyNode(pSelect);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SIntervalWindowNode* pInterval = nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW);
|
||||
if (NULL == pInterval) {
|
||||
nodesDestroyNode(pSelect);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pSelect->pWindow = (SNode*)pInterval;
|
||||
pInterval->pInterval = nodesCloneNode(pStmt->pOptions->pInterval);
|
||||
pInterval->pOffset = nodesCloneNode(pStmt->pOptions->pOffset);
|
||||
pInterval->pSliding = nodesCloneNode(pStmt->pOptions->pSliding);
|
||||
if (NULL == pInterval->pInterval || (NULL != pStmt->pOptions->pOffset && NULL == pInterval->pOffset) ||
|
||||
(NULL != pStmt->pOptions->pSliding && NULL == pInterval->pSliding)) {
|
||||
nodesDestroyNode(pSelect);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int32_t code = translateQuery(pCxt, (SNode*)pSelect);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesNodeToString(pSelect, false, pAst, pLen);
|
||||
}
|
||||
nodesDestroyNode(pSelect);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SMCreateSmaReq* pReq) {
|
||||
SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId };
|
||||
strcpy(name.dbname, pCxt->pParseCxt->db);
|
||||
strcpy(name.tname, pStmt->indexName);
|
||||
tNameExtractFullName(&name, pReq->name);
|
||||
strcpy(name.tname, pStmt->tableName);
|
||||
name.tname[strlen(pStmt->tableName)] = '\0';
|
||||
tNameExtractFullName(&name, pReq->stb);
|
||||
pReq->igExists = pStmt->ignoreExists;
|
||||
pReq->interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i;
|
||||
pReq->intervalUnit = ((SValueNode*)pStmt->pOptions->pInterval)->unit;
|
||||
pReq->offset = (NULL != pStmt->pOptions->pOffset ? ((SValueNode*)pStmt->pOptions->pOffset)->datum.i : 0);
|
||||
pReq->sliding = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pReq->interval);
|
||||
pReq->slidingUnit = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pReq->intervalUnit);
|
||||
|
||||
int32_t code = getSmaIndexDstVgId(pCxt, pStmt->tableName, &pReq->dstVgId);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = getSmaIndexSql(pCxt, &pReq->sql, &pReq->sqlLen);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = getSmaIndexExpr(pCxt, pStmt, &pReq->expr, &pReq->exprLen);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = getSmaIndexBuildAst(pCxt, pStmt, &pReq->ast, &pReq->astLen);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
|
||||
if (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval) ||
|
||||
(NULL != pStmt->pOptions->pOffset && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) ||
|
||||
(NULL != pStmt->pOptions->pSliding && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) {
|
||||
return pCxt->errCode;
|
||||
}
|
||||
|
||||
createSmaReq.tSma.intervalUnit = ((SValueNode*)pStmt->pOptions->pInterval)->unit;
|
||||
createSmaReq.tSma.slidingUnit = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : 0);
|
||||
strcpy(createSmaReq.tSma.indexName, pStmt->indexName);
|
||||
|
||||
SName name;
|
||||
name.type = TSDB_TABLE_NAME_T;
|
||||
name.acctId = pCxt->pParseCxt->acctId;
|
||||
strcpy(name.dbname, pCxt->pParseCxt->db);
|
||||
strcpy(name.tname, pStmt->tableName);
|
||||
STableMeta* pMeta = NULL;
|
||||
int32_t code = catalogGetTableMeta(pCxt->pParseCxt->pCatalog, pCxt->pParseCxt->pTransporter, &pCxt->pParseCxt->mgmtEpSet, &name, &pMeta);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
createSmaReq.tSma.tableUid = pMeta->uid;
|
||||
createSmaReq.tSma.interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i;
|
||||
createSmaReq.tSma.sliding = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : 0);
|
||||
code = nodesListToString(pStmt->pOptions->pFuncs, false, &createSmaReq.tSma.expr, &createSmaReq.tSma.exprLen);
|
||||
SMCreateSmaReq createSmaReq = {0};
|
||||
int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1443,15 +1519,14 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet;
|
||||
pCxt->pCmdMsg->msgType = TDMT_VND_CREATE_SMA;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSVCreateTSmaReq(NULL, &createSmaReq);
|
||||
pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_SMA;
|
||||
pCxt->pCmdMsg->msgLen = tSerializeSMCreateSmaReq(NULL, 0, &createSmaReq);
|
||||
pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen);
|
||||
if (NULL == pCxt->pCmdMsg->pMsg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
void* pBuf = pCxt->pCmdMsg->pMsg;
|
||||
tSerializeSVCreateTSmaReq(&pBuf, &createSmaReq);
|
||||
tdDestroyTSma(&createSmaReq.tSma);
|
||||
tSerializeSMCreateSmaReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createSmaReq);
|
||||
tFreeSMCreateSmaReq(&createSmaReq);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1696,24 +1771,27 @@ static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t setReslutSchema(STranslateContext* pCxt, SQuery* pQuery) {
|
||||
if (QUERY_NODE_SELECT_STMT == nodeType(pQuery->pRoot)) {
|
||||
SSelectStmt* pSelect = (SSelectStmt*)pQuery->pRoot;
|
||||
pQuery->numOfResCols = LIST_LENGTH(pSelect->pProjectionList);
|
||||
pQuery->pResSchema = calloc(pQuery->numOfResCols, sizeof(SSchema));
|
||||
if (NULL == pQuery->pResSchema) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
||||
int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema) {
|
||||
if (QUERY_NODE_SELECT_STMT == nodeType(pRoot)) {
|
||||
SSelectStmt* pSelect = (SSelectStmt*) pRoot;
|
||||
*numOfCols = LIST_LENGTH(pSelect->pProjectionList);
|
||||
*pSchema = calloc((*numOfCols), sizeof(SSchema));
|
||||
if (NULL == (*pSchema)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SNode* pNode;
|
||||
int32_t index = 0;
|
||||
FOREACH(pNode, pSelect->pProjectionList) {
|
||||
SExprNode* pExpr = (SExprNode*)pNode;
|
||||
pQuery->pResSchema[index].type = pExpr->resType.type;
|
||||
pQuery->pResSchema[index].bytes = pExpr->resType.bytes;
|
||||
strcpy(pQuery->pResSchema[index].name, pExpr->aliasName);
|
||||
(*pSchema)[index].type = pExpr->resType.type;
|
||||
(*pSchema)[index].bytes = pExpr->resType.bytes;
|
||||
(*pSchema)[index].colId = index + 1;
|
||||
strcpy((*pSchema)[index].name, pExpr->aliasName);
|
||||
index +=1;
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2297,7 +2375,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
|
|||
pQuery->haveResultSet = true;
|
||||
pQuery->directRpc = false;
|
||||
pQuery->msgType = TDMT_VND_QUERY;
|
||||
code = setReslutSchema(pCxt, pQuery);
|
||||
code = qExtractResultSchema(pQuery->pRoot, &pQuery->numOfResCols, &pQuery->pResSchema);
|
||||
break;
|
||||
case QUERY_NODE_VNODE_MODIF_STMT:
|
||||
pQuery->haveResultSet = false;
|
||||
|
|
|
@ -131,17 +131,17 @@ typedef union {
|
|||
#define ParseCTX_PARAM
|
||||
#define ParseCTX_FETCH
|
||||
#define ParseCTX_STORE
|
||||
#define YYNSTATE 427
|
||||
#define YYNSTATE 430
|
||||
#define YYNRULE 337
|
||||
#define YYNTOKEN 163
|
||||
#define YY_MAX_SHIFT 426
|
||||
#define YY_MIN_SHIFTREDUCE 659
|
||||
#define YY_MAX_SHIFTREDUCE 995
|
||||
#define YY_ERROR_ACTION 996
|
||||
#define YY_ACCEPT_ACTION 997
|
||||
#define YY_NO_ACTION 998
|
||||
#define YY_MIN_REDUCE 999
|
||||
#define YY_MAX_REDUCE 1335
|
||||
#define YY_MAX_SHIFT 429
|
||||
#define YY_MIN_SHIFTREDUCE 662
|
||||
#define YY_MAX_SHIFTREDUCE 998
|
||||
#define YY_ERROR_ACTION 999
|
||||
#define YY_ACCEPT_ACTION 1000
|
||||
#define YY_NO_ACTION 1001
|
||||
#define YY_MIN_REDUCE 1002
|
||||
#define YY_MAX_REDUCE 1338
|
||||
/************* End control #defines *******************************************/
|
||||
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
|
||||
|
||||
|
@ -208,135 +208,135 @@ typedef union {
|
|||
** yy_default[] Default action for each state.
|
||||
**
|
||||
*********** Begin parsing tables **********************************************/
|
||||
#define YY_ACTTAB_COUNT (1266)
|
||||
#define YY_ACTTAB_COUNT (1263)
|
||||
static const YYACTIONTYPE yy_action[] = {
|
||||
/* 0 */ 1042, 1201, 222, 43, 24, 168, 359, 1197, 1203, 1092,
|
||||
/* 10 */ 247, 266, 89, 31, 29, 27, 26, 25, 20, 1201,
|
||||
/* 20 */ 1098, 27, 26, 25, 1081, 1197, 1202, 1103, 31, 29,
|
||||
/* 30 */ 27, 26, 25, 358, 997, 78, 206, 866, 77, 76,
|
||||
/* 40 */ 75, 74, 73, 72, 71, 70, 69, 1088, 208, 411,
|
||||
/* 50 */ 410, 409, 408, 407, 406, 405, 404, 403, 402, 401,
|
||||
/* 60 */ 400, 399, 398, 397, 396, 395, 394, 393, 1000, 105,
|
||||
/* 70 */ 267, 1011, 878, 31, 29, 27, 26, 25, 1228, 131,
|
||||
/* 80 */ 901, 346, 111, 246, 234, 343, 1213, 1177, 272, 78,
|
||||
/* 90 */ 130, 22, 77, 76, 75, 74, 73, 72, 71, 70,
|
||||
/* 100 */ 69, 31, 29, 27, 26, 25, 1228, 1314, 208, 288,
|
||||
/* 110 */ 317, 283, 267, 343, 287, 44, 902, 286, 128, 284,
|
||||
/* 120 */ 117, 342, 285, 345, 1312, 23, 229, 1189, 896, 897,
|
||||
/* 130 */ 898, 899, 900, 904, 905, 906, 1079, 201, 1214, 1217,
|
||||
/* 140 */ 901, 769, 382, 381, 380, 773, 379, 775, 776, 378,
|
||||
/* 150 */ 778, 375, 109, 784, 372, 786, 787, 369, 366, 1148,
|
||||
/* 160 */ 1213, 846, 127, 1141, 302, 221, 125, 43, 323, 186,
|
||||
/* 170 */ 1146, 358, 1133, 30, 28, 938, 902, 844, 255, 239,
|
||||
/* 180 */ 1228, 231, 392, 846, 1099, 23, 229, 343, 896, 897,
|
||||
/* 190 */ 898, 899, 900, 904, 905, 906, 1201, 345, 358, 844,
|
||||
/* 200 */ 893, 1189, 1197, 1202, 303, 359, 331, 845, 12, 118,
|
||||
/* 210 */ 66, 61, 1214, 1217, 1253, 1213, 962, 276, 207, 1249,
|
||||
/* 220 */ 1165, 10, 122, 121, 30, 28, 1103, 120, 1314, 845,
|
||||
/* 230 */ 1314, 1, 231, 423, 846, 1228, 313, 960, 961, 963,
|
||||
/* 240 */ 964, 117, 330, 117, 1213, 1312, 242, 1312, 10, 321,
|
||||
/* 250 */ 844, 334, 345, 1168, 1170, 423, 1189, 346, 696, 12,
|
||||
/* 260 */ 695, 847, 850, 1178, 1228, 359, 62, 1214, 1217, 1253,
|
||||
/* 270 */ 66, 330, 280, 224, 1249, 112, 279, 282, 697, 327,
|
||||
/* 280 */ 845, 345, 1, 847, 850, 1189, 1103, 164, 118, 9,
|
||||
/* 290 */ 8, 59, 1213, 309, 1280, 62, 1214, 1217, 1253, 281,
|
||||
/* 300 */ 92, 93, 224, 1249, 112, 1314, 423, 327, 1095, 106,
|
||||
/* 310 */ 1070, 903, 1228, 31, 29, 27, 26, 25, 1313, 343,
|
||||
/* 320 */ 21, 1213, 1312, 1281, 392, 1267, 90, 868, 92, 345,
|
||||
/* 330 */ 907, 419, 418, 1189, 847, 850, 114, 1260, 1261, 867,
|
||||
/* 340 */ 1265, 1228, 1264, 62, 1214, 1217, 1253, 331, 343, 118,
|
||||
/* 350 */ 224, 1249, 1326, 695, 90, 1094, 1213, 864, 345, 914,
|
||||
/* 360 */ 1228, 1287, 1189, 865, 161, 1260, 326, 343, 325, 274,
|
||||
/* 370 */ 235, 1314, 62, 1214, 1217, 1253, 1228, 359, 104, 224,
|
||||
/* 380 */ 1249, 1326, 1100, 343, 117, 1213, 1105, 385, 1312, 1022,
|
||||
/* 390 */ 1310, 1090, 320, 345, 30, 28, 1189, 1189, 1103, 1021,
|
||||
/* 400 */ 1267, 333, 231, 104, 846, 1228, 1080, 62, 1214, 1217,
|
||||
/* 410 */ 1253, 1106, 343, 1148, 224, 1249, 1326, 1263, 359, 236,
|
||||
/* 420 */ 844, 1148, 345, 356, 1146, 1271, 1189, 243, 163, 12,
|
||||
/* 430 */ 1189, 331, 1146, 30, 28, 1012, 196, 1214, 1217, 1103,
|
||||
/* 440 */ 1189, 231, 1213, 846, 191, 1020, 1019, 1018, 136, 193,
|
||||
/* 450 */ 845, 134, 1, 1038, 316, 1314, 30, 28, 344, 844,
|
||||
/* 460 */ 6, 192, 1228, 389, 231, 1213, 846, 388, 117, 343,
|
||||
/* 470 */ 1017, 123, 1312, 1148, 118, 289, 423, 322, 318, 345,
|
||||
/* 480 */ 1016, 1015, 844, 1189, 1169, 1228, 1189, 1189, 1189, 845,
|
||||
/* 490 */ 390, 7, 343, 63, 1214, 1217, 1253, 1148, 869, 1086,
|
||||
/* 500 */ 1252, 1249, 345, 1045, 847, 850, 1189, 945, 1147, 387,
|
||||
/* 510 */ 386, 1189, 845, 866, 7, 423, 63, 1214, 1217, 1253,
|
||||
/* 520 */ 241, 1189, 1189, 341, 1249, 30, 28, 300, 104, 30,
|
||||
/* 530 */ 28, 64, 384, 231, 338, 846, 1105, 231, 423, 846,
|
||||
/* 540 */ 298, 1213, 1267, 847, 850, 999, 31, 29, 27, 26,
|
||||
/* 550 */ 25, 844, 288, 933, 283, 844, 1014, 287, 118, 1262,
|
||||
/* 560 */ 286, 1228, 284, 118, 1213, 285, 847, 850, 343, 87,
|
||||
/* 570 */ 86, 85, 84, 83, 82, 81, 80, 79, 345, 864,
|
||||
/* 580 */ 1033, 845, 1189, 7, 1228, 845, 248, 1, 1071, 260,
|
||||
/* 590 */ 1013, 343, 107, 1214, 1217, 937, 426, 1189, 261, 149,
|
||||
/* 600 */ 1213, 345, 291, 165, 359, 1189, 244, 423, 339, 357,
|
||||
/* 610 */ 184, 423, 305, 88, 104, 63, 1214, 1217, 1253, 415,
|
||||
/* 620 */ 1228, 183, 1105, 1250, 98, 1103, 1010, 343, 314, 332,
|
||||
/* 630 */ 1327, 1189, 1031, 1009, 1008, 847, 850, 345, 359, 847,
|
||||
/* 640 */ 850, 1189, 1142, 181, 230, 359, 60, 1007, 1006, 179,
|
||||
/* 650 */ 245, 202, 1214, 1217, 294, 1005, 158, 1004, 1213, 1103,
|
||||
/* 660 */ 1272, 933, 1229, 1213, 273, 259, 1103, 1189, 254, 253,
|
||||
/* 670 */ 252, 251, 250, 335, 1189, 1189, 1003, 853, 1228, 138,
|
||||
/* 680 */ 355, 1213, 137, 1228, 140, 343, 1213, 139, 1189, 1189,
|
||||
/* 690 */ 343, 852, 991, 992, 308, 345, 1189, 146, 1189, 1189,
|
||||
/* 700 */ 345, 1228, 310, 327, 1189, 328, 1228, 856, 343, 202,
|
||||
/* 710 */ 1214, 1217, 1002, 343, 107, 1214, 1217, 1189, 345, 9,
|
||||
/* 720 */ 8, 855, 1189, 345, 92, 228, 864, 1189, 1213, 936,
|
||||
/* 730 */ 232, 1213, 202, 1214, 1217, 1283, 1213, 202, 1214, 1217,
|
||||
/* 740 */ 31, 29, 27, 26, 25, 336, 327, 1167, 1228, 52,
|
||||
/* 750 */ 90, 1228, 1328, 1189, 167, 343, 1228, 1078, 343, 329,
|
||||
/* 760 */ 113, 1260, 1261, 343, 1265, 345, 1096, 92, 345, 1189,
|
||||
/* 770 */ 2, 119, 1189, 345, 1213, 142, 257, 1189, 141, 200,
|
||||
/* 780 */ 1214, 1217, 203, 1214, 1217, 959, 154, 194, 1214, 1217,
|
||||
/* 790 */ 249, 256, 258, 90, 1228, 262, 1213, 41, 152, 878,
|
||||
/* 800 */ 908, 343, 1213, 115, 1260, 1261, 872, 1265, 994, 995,
|
||||
/* 810 */ 263, 345, 32, 264, 389, 1189, 1228, 124, 388, 871,
|
||||
/* 820 */ 875, 58, 1228, 343, 42, 204, 1214, 1217, 1207, 343,
|
||||
/* 830 */ 1213, 54, 32, 345, 839, 265, 1213, 1189, 268, 345,
|
||||
/* 840 */ 1205, 390, 129, 1189, 275, 870, 32, 195, 1214, 1217,
|
||||
/* 850 */ 1228, 277, 68, 205, 1214, 1217, 1228, 343, 173, 1093,
|
||||
/* 860 */ 387, 386, 220, 343, 1213, 133, 351, 345, 178, 1089,
|
||||
/* 870 */ 171, 1189, 135, 345, 762, 100, 101, 1189, 95, 1091,
|
||||
/* 880 */ 96, 1225, 1214, 1217, 1228, 1087, 98, 1224, 1214, 1217,
|
||||
/* 890 */ 757, 343, 1213, 102, 790, 794, 103, 800, 1213, 799,
|
||||
/* 900 */ 307, 345, 41, 304, 145, 1189, 364, 96, 99, 97,
|
||||
/* 910 */ 306, 98, 1228, 869, 315, 1223, 1214, 1217, 1228, 343,
|
||||
/* 920 */ 96, 1284, 349, 1294, 150, 343, 312, 850, 1293, 345,
|
||||
/* 930 */ 153, 223, 1213, 1189, 319, 345, 5, 110, 1274, 1189,
|
||||
/* 940 */ 1213, 324, 157, 211, 1214, 1217, 238, 237, 311, 210,
|
||||
/* 950 */ 1214, 1217, 1228, 4, 933, 91, 858, 868, 1268, 343,
|
||||
/* 960 */ 1228, 33, 159, 160, 1311, 225, 1329, 343, 1213, 345,
|
||||
/* 970 */ 337, 340, 851, 1189, 293, 215, 166, 345, 17, 1235,
|
||||
/* 980 */ 1176, 1189, 347, 212, 1214, 1217, 348, 233, 1228, 301,
|
||||
/* 990 */ 1175, 209, 1214, 1217, 352, 343, 353, 280, 354, 175,
|
||||
/* 1000 */ 51, 279, 854, 144, 185, 345, 296, 187, 53, 1189,
|
||||
/* 1010 */ 1104, 290, 182, 216, 143, 214, 213, 422, 278, 199,
|
||||
/* 1020 */ 1214, 1217, 362, 197, 281, 198, 189, 190, 360, 1183,
|
||||
/* 1030 */ 822, 1160, 1159, 94, 1158, 1157, 1156, 1155, 1154, 40,
|
||||
/* 1040 */ 1153, 824, 39, 1152, 1151, 1150, 1149, 1044, 1182, 1173,
|
||||
/* 1050 */ 126, 1082, 708, 1043, 1041, 269, 859, 850, 270, 271,
|
||||
/* 1060 */ 1030, 1029, 1026, 1084, 67, 132, 805, 1083, 804, 1039,
|
||||
/* 1070 */ 1034, 737, 803, 1032, 1025, 1024, 1181, 736, 217, 735,
|
||||
/* 1080 */ 734, 218, 1180, 36, 1172, 45, 219, 148, 297, 3,
|
||||
/* 1090 */ 733, 65, 32, 732, 299, 14, 292, 151, 958, 15,
|
||||
/* 1100 */ 1205, 147, 162, 295, 37, 11, 156, 19, 34, 48,
|
||||
/* 1110 */ 8, 350, 894, 1171, 177, 998, 998, 998, 998, 998,
|
||||
/* 1120 */ 998, 783, 998, 998, 998, 998, 998, 998, 980, 979,
|
||||
/* 1130 */ 226, 984, 983, 227, 860, 998, 998, 998, 108, 998,
|
||||
/* 1140 */ 998, 176, 998, 998, 998, 998, 998, 155, 998, 952,
|
||||
/* 1150 */ 46, 998, 951, 47, 998, 768, 930, 929, 998, 985,
|
||||
/* 1160 */ 998, 998, 35, 998, 998, 998, 998, 998, 876, 116,
|
||||
/* 1170 */ 13, 18, 16, 170, 956, 998, 172, 174, 169, 49,
|
||||
/* 1180 */ 50, 1204, 998, 998, 54, 38, 363, 1040, 240, 367,
|
||||
/* 1190 */ 1028, 370, 373, 180, 998, 361, 998, 796, 376, 998,
|
||||
/* 1200 */ 791, 365, 728, 788, 368, 1027, 785, 998, 798, 371,
|
||||
/* 1210 */ 420, 720, 797, 779, 998, 998, 998, 727, 782, 998,
|
||||
/* 1220 */ 726, 998, 998, 725, 724, 706, 781, 374, 391, 777,
|
||||
/* 1230 */ 723, 722, 721, 377, 719, 1023, 718, 717, 413, 716,
|
||||
/* 1240 */ 383, 55, 56, 57, 425, 715, 729, 714, 713, 421,
|
||||
/* 1250 */ 712, 711, 412, 848, 188, 424, 998, 416, 417, 998,
|
||||
/* 1260 */ 998, 414, 998, 998, 998, 780,
|
||||
/* 0 */ 1045, 1204, 225, 43, 24, 170, 362, 1200, 1206, 1095,
|
||||
/* 10 */ 250, 269, 89, 31, 29, 27, 26, 25, 20, 1204,
|
||||
/* 20 */ 1101, 27, 26, 25, 1084, 1200, 1205, 1106, 31, 29,
|
||||
/* 30 */ 27, 26, 25, 361, 1000, 78, 209, 869, 77, 76,
|
||||
/* 40 */ 75, 74, 73, 72, 71, 70, 69, 1091, 211, 414,
|
||||
/* 50 */ 413, 412, 411, 410, 409, 408, 407, 406, 405, 404,
|
||||
/* 60 */ 403, 402, 401, 400, 399, 398, 397, 396, 1003, 105,
|
||||
/* 70 */ 270, 1014, 881, 31, 29, 27, 26, 25, 1231, 132,
|
||||
/* 80 */ 904, 349, 111, 249, 237, 346, 1216, 1180, 275, 78,
|
||||
/* 90 */ 131, 22, 77, 76, 75, 74, 73, 72, 71, 70,
|
||||
/* 100 */ 69, 31, 29, 27, 26, 25, 1231, 1317, 211, 291,
|
||||
/* 110 */ 320, 286, 270, 346, 290, 44, 905, 289, 129, 287,
|
||||
/* 120 */ 117, 345, 288, 348, 1315, 23, 232, 1192, 899, 900,
|
||||
/* 130 */ 901, 902, 903, 907, 908, 909, 1082, 204, 1217, 1220,
|
||||
/* 140 */ 904, 772, 385, 384, 383, 776, 382, 778, 779, 381,
|
||||
/* 150 */ 781, 378, 109, 787, 375, 789, 790, 372, 369, 1151,
|
||||
/* 160 */ 1216, 849, 128, 1144, 305, 224, 125, 43, 326, 189,
|
||||
/* 170 */ 1149, 361, 1136, 30, 28, 941, 905, 847, 258, 242,
|
||||
/* 180 */ 1231, 234, 395, 849, 1102, 23, 232, 346, 899, 900,
|
||||
/* 190 */ 901, 902, 903, 907, 908, 909, 1204, 348, 361, 847,
|
||||
/* 200 */ 896, 1192, 1200, 1205, 306, 362, 334, 848, 12, 118,
|
||||
/* 210 */ 66, 61, 1217, 1220, 1256, 1216, 965, 279, 210, 1252,
|
||||
/* 220 */ 1168, 10, 122, 121, 30, 28, 1106, 120, 1317, 848,
|
||||
/* 230 */ 1317, 1, 234, 426, 849, 1231, 316, 963, 964, 966,
|
||||
/* 240 */ 967, 117, 333, 117, 1216, 1315, 245, 1315, 10, 324,
|
||||
/* 250 */ 847, 337, 348, 1171, 1173, 426, 1192, 349, 699, 12,
|
||||
/* 260 */ 698, 850, 853, 1181, 1231, 362, 62, 1217, 1220, 1256,
|
||||
/* 270 */ 66, 333, 283, 227, 1252, 112, 282, 285, 700, 330,
|
||||
/* 280 */ 848, 348, 1, 850, 853, 1192, 1106, 166, 118, 9,
|
||||
/* 290 */ 8, 59, 1216, 312, 1283, 62, 1217, 1220, 1256, 284,
|
||||
/* 300 */ 92, 93, 227, 1252, 112, 1317, 426, 330, 1098, 106,
|
||||
/* 310 */ 1073, 906, 1231, 31, 29, 27, 26, 25, 1316, 346,
|
||||
/* 320 */ 21, 1216, 1315, 1284, 395, 1270, 90, 871, 92, 348,
|
||||
/* 330 */ 910, 422, 421, 1192, 850, 853, 114, 1263, 1264, 870,
|
||||
/* 340 */ 1268, 1231, 1267, 62, 1217, 1220, 1256, 334, 346, 118,
|
||||
/* 350 */ 227, 1252, 1329, 698, 90, 1097, 1216, 867, 348, 917,
|
||||
/* 360 */ 1231, 1290, 1192, 868, 163, 1263, 329, 346, 328, 277,
|
||||
/* 370 */ 238, 1317, 62, 1217, 1220, 1256, 1231, 362, 104, 227,
|
||||
/* 380 */ 1252, 1329, 1103, 346, 117, 1216, 1108, 388, 1315, 1025,
|
||||
/* 390 */ 1313, 1093, 323, 348, 30, 28, 1192, 1192, 1106, 1024,
|
||||
/* 400 */ 1270, 336, 234, 104, 849, 1231, 1083, 62, 1217, 1220,
|
||||
/* 410 */ 1256, 1109, 346, 1151, 227, 1252, 1329, 1266, 362, 239,
|
||||
/* 420 */ 847, 1151, 348, 359, 1149, 1274, 1192, 246, 165, 12,
|
||||
/* 430 */ 1192, 334, 1149, 30, 28, 1015, 199, 1217, 1220, 1106,
|
||||
/* 440 */ 1192, 234, 1216, 849, 194, 1023, 1022, 1021, 137, 196,
|
||||
/* 450 */ 848, 135, 1, 1041, 319, 1317, 30, 28, 347, 847,
|
||||
/* 460 */ 6, 195, 1231, 392, 234, 1216, 849, 391, 117, 346,
|
||||
/* 470 */ 1020, 123, 1315, 1151, 118, 292, 426, 325, 321, 348,
|
||||
/* 480 */ 1019, 1018, 847, 1192, 1172, 1231, 1192, 1192, 1192, 848,
|
||||
/* 490 */ 393, 7, 346, 63, 1217, 1220, 1256, 1151, 872, 1089,
|
||||
/* 500 */ 1255, 1252, 348, 1048, 850, 853, 1192, 948, 1150, 390,
|
||||
/* 510 */ 389, 1192, 848, 869, 7, 426, 63, 1217, 1220, 1256,
|
||||
/* 520 */ 244, 1192, 1192, 344, 1252, 30, 28, 303, 104, 30,
|
||||
/* 530 */ 28, 64, 387, 234, 341, 849, 1108, 234, 426, 849,
|
||||
/* 540 */ 301, 1216, 1270, 850, 853, 1002, 31, 29, 27, 26,
|
||||
/* 550 */ 25, 847, 291, 936, 286, 847, 1017, 290, 118, 1265,
|
||||
/* 560 */ 289, 1231, 287, 118, 1216, 288, 850, 853, 346, 87,
|
||||
/* 570 */ 86, 85, 84, 83, 82, 81, 80, 79, 348, 867,
|
||||
/* 580 */ 1036, 848, 1192, 7, 1231, 848, 251, 1, 1074, 263,
|
||||
/* 590 */ 1016, 346, 107, 1217, 1220, 940, 429, 1192, 264, 151,
|
||||
/* 600 */ 1216, 348, 294, 167, 362, 1192, 247, 426, 342, 360,
|
||||
/* 610 */ 187, 426, 308, 88, 104, 63, 1217, 1220, 1256, 418,
|
||||
/* 620 */ 1231, 186, 1108, 1253, 98, 1106, 1013, 346, 317, 335,
|
||||
/* 630 */ 1330, 1192, 1034, 1012, 1011, 850, 853, 348, 362, 850,
|
||||
/* 640 */ 853, 1192, 1145, 184, 233, 362, 60, 1010, 1009, 182,
|
||||
/* 650 */ 248, 205, 1217, 1220, 297, 1008, 160, 1007, 1216, 1106,
|
||||
/* 660 */ 1275, 936, 1232, 1216, 276, 262, 1106, 1192, 257, 256,
|
||||
/* 670 */ 255, 254, 253, 338, 1192, 1192, 1006, 856, 1231, 139,
|
||||
/* 680 */ 358, 1216, 138, 1231, 141, 346, 1216, 140, 1192, 1192,
|
||||
/* 690 */ 346, 855, 994, 995, 311, 348, 1192, 147, 1192, 1192,
|
||||
/* 700 */ 348, 1231, 313, 330, 1192, 331, 1231, 859, 346, 205,
|
||||
/* 710 */ 1217, 1220, 1005, 346, 107, 1217, 1220, 1192, 348, 9,
|
||||
/* 720 */ 8, 858, 1192, 348, 92, 231, 867, 1192, 1216, 939,
|
||||
/* 730 */ 235, 1216, 205, 1217, 1220, 1286, 1216, 205, 1217, 1220,
|
||||
/* 740 */ 31, 29, 27, 26, 25, 339, 330, 1170, 1231, 52,
|
||||
/* 750 */ 90, 1231, 1331, 1192, 169, 346, 1231, 1081, 346, 332,
|
||||
/* 760 */ 113, 1263, 1264, 346, 1268, 348, 1099, 92, 348, 1192,
|
||||
/* 770 */ 2, 119, 1192, 348, 1216, 143, 260, 1192, 142, 203,
|
||||
/* 780 */ 1217, 1220, 206, 1217, 1220, 962, 156, 197, 1217, 1220,
|
||||
/* 790 */ 252, 259, 261, 90, 1231, 265, 1216, 41, 154, 881,
|
||||
/* 800 */ 911, 346, 1216, 115, 1263, 1264, 875, 1268, 997, 998,
|
||||
/* 810 */ 266, 348, 32, 267, 392, 1192, 1231, 124, 391, 874,
|
||||
/* 820 */ 878, 58, 1231, 346, 127, 207, 1217, 1220, 1210, 346,
|
||||
/* 830 */ 1216, 54, 32, 348, 842, 268, 1216, 1192, 271, 348,
|
||||
/* 840 */ 1208, 393, 42, 1192, 278, 130, 32, 198, 1217, 1220,
|
||||
/* 850 */ 1231, 873, 68, 208, 1217, 1220, 1231, 346, 175, 280,
|
||||
/* 860 */ 390, 389, 223, 346, 1216, 1096, 354, 348, 181, 134,
|
||||
/* 870 */ 173, 1192, 1092, 348, 765, 136, 100, 1192, 95, 101,
|
||||
/* 880 */ 96, 1228, 1217, 1220, 1231, 1094, 98, 1227, 1217, 1220,
|
||||
/* 890 */ 760, 346, 1216, 1090, 793, 797, 102, 803, 1216, 802,
|
||||
/* 900 */ 310, 348, 41, 103, 146, 1192, 367, 96, 99, 97,
|
||||
/* 910 */ 149, 98, 1231, 307, 309, 1226, 1217, 1220, 1231, 346,
|
||||
/* 920 */ 96, 872, 318, 1297, 1287, 346, 352, 152, 853, 348,
|
||||
/* 930 */ 315, 1296, 1216, 1192, 226, 348, 5, 159, 155, 1192,
|
||||
/* 940 */ 1216, 322, 327, 214, 1217, 1220, 241, 240, 1277, 213,
|
||||
/* 950 */ 1217, 1220, 1231, 314, 4, 161, 861, 936, 91, 346,
|
||||
/* 960 */ 1231, 871, 110, 1271, 33, 162, 228, 346, 1216, 348,
|
||||
/* 970 */ 1332, 340, 854, 1192, 296, 218, 343, 348, 17, 1238,
|
||||
/* 980 */ 1179, 1192, 168, 215, 1217, 1220, 350, 1314, 1231, 304,
|
||||
/* 990 */ 351, 212, 1217, 1220, 355, 346, 1178, 283, 356, 236,
|
||||
/* 1000 */ 177, 282, 857, 145, 357, 348, 299, 179, 53, 1192,
|
||||
/* 1010 */ 51, 293, 188, 219, 144, 217, 216, 190, 281, 202,
|
||||
/* 1020 */ 1217, 1220, 1107, 365, 284, 185, 425, 200, 363, 201,
|
||||
/* 1030 */ 192, 193, 1186, 825, 1163, 1162, 94, 1161, 1160, 40,
|
||||
/* 1040 */ 1159, 1158, 39, 1157, 1156, 827, 1155, 1154, 1153, 1152,
|
||||
/* 1050 */ 1047, 1185, 1176, 126, 1085, 711, 862, 853, 1046, 1044,
|
||||
/* 1060 */ 272, 273, 274, 1033, 1032, 1029, 1087, 67, 133, 808,
|
||||
/* 1070 */ 1086, 807, 1042, 1037, 740, 806, 1035, 739, 1028, 220,
|
||||
/* 1080 */ 738, 1027, 221, 737, 222, 1184, 1183, 36, 1175, 150,
|
||||
/* 1090 */ 300, 302, 3, 736, 735, 65, 45, 32, 14, 153,
|
||||
/* 1100 */ 295, 37, 15, 158, 19, 298, 1208, 34, 11, 164,
|
||||
/* 1110 */ 48, 8, 35, 16, 148, 897, 353, 1174, 180, 1001,
|
||||
/* 1120 */ 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001,
|
||||
/* 1130 */ 983, 982, 229, 987, 986, 230, 863, 1001, 1001, 1001,
|
||||
/* 1140 */ 1001, 1001, 1001, 178, 1001, 961, 1001, 108, 1001, 157,
|
||||
/* 1150 */ 1001, 955, 46, 1001, 954, 933, 1001, 47, 1001, 1001,
|
||||
/* 1160 */ 932, 1001, 988, 1001, 1001, 1001, 1001, 1001, 1001, 366,
|
||||
/* 1170 */ 879, 13, 116, 18, 243, 172, 959, 174, 176, 1001,
|
||||
/* 1180 */ 171, 49, 50, 1001, 1207, 38, 370, 1001, 373, 794,
|
||||
/* 1190 */ 54, 376, 771, 1001, 379, 183, 1001, 364, 799, 1001,
|
||||
/* 1200 */ 1001, 1001, 368, 731, 791, 371, 1043, 1001, 788, 723,
|
||||
/* 1210 */ 1001, 428, 423, 801, 374, 786, 800, 782, 1001, 1001,
|
||||
/* 1220 */ 1001, 730, 377, 729, 728, 709, 780, 727, 380, 394,
|
||||
/* 1230 */ 785, 726, 1031, 725, 724, 417, 722, 721, 1030, 1026,
|
||||
/* 1240 */ 416, 720, 55, 56, 57, 415, 420, 732, 719, 424,
|
||||
/* 1250 */ 1001, 851, 718, 717, 716, 386, 715, 784, 191, 783,
|
||||
/* 1260 */ 714, 419, 427,
|
||||
};
|
||||
static const YYCODETYPE yy_lookahead[] = {
|
||||
/* 0 */ 0, 207, 190, 174, 221, 222, 172, 213, 214, 187,
|
||||
|
@ -423,49 +423,49 @@ static const YYCODETYPE yy_lookahead[] = {
|
|||
/* 810 */ 211, 203, 83, 193, 57, 207, 186, 174, 61, 20,
|
||||
/* 820 */ 71, 70, 186, 193, 174, 217, 218, 219, 70, 193,
|
||||
/* 830 */ 166, 80, 83, 203, 71, 204, 166, 207, 172, 203,
|
||||
/* 840 */ 82, 84, 174, 207, 168, 20, 83, 217, 218, 219,
|
||||
/* 850 */ 186, 186, 172, 217, 218, 219, 186, 193, 71, 186,
|
||||
/* 840 */ 82, 84, 174, 207, 168, 174, 83, 217, 218, 219,
|
||||
/* 850 */ 186, 20, 172, 217, 218, 219, 186, 193, 71, 186,
|
||||
/* 860 */ 103, 104, 168, 193, 166, 186, 71, 203, 71, 186,
|
||||
/* 870 */ 83, 207, 186, 203, 71, 186, 186, 207, 83, 186,
|
||||
/* 880 */ 83, 217, 218, 219, 186, 186, 83, 217, 218, 219,
|
||||
/* 890 */ 71, 193, 166, 186, 71, 71, 186, 71, 166, 71,
|
||||
/* 900 */ 204, 203, 83, 211, 171, 207, 83, 83, 71, 83,
|
||||
/* 910 */ 193, 83, 186, 20, 145, 217, 218, 219, 186, 193,
|
||||
/* 920 */ 83, 216, 144, 246, 208, 193, 207, 123, 246, 203,
|
||||
/* 930 */ 208, 207, 166, 207, 207, 203, 152, 240, 243, 207,
|
||||
/* 940 */ 166, 151, 242, 217, 218, 219, 12, 13, 140, 217,
|
||||
/* 950 */ 218, 219, 186, 139, 136, 193, 22, 20, 215, 193,
|
||||
/* 960 */ 186, 114, 239, 227, 252, 160, 257, 193, 166, 203,
|
||||
/* 970 */ 154, 156, 38, 207, 4, 35, 251, 203, 70, 223,
|
||||
/* 980 */ 208, 207, 207, 217, 218, 219, 207, 207, 186, 19,
|
||||
/* 990 */ 208, 217, 218, 219, 118, 193, 205, 57, 204, 193,
|
||||
/* 1000 */ 171, 61, 68, 33, 182, 203, 36, 172, 70, 207,
|
||||
/* 1010 */ 193, 41, 171, 73, 44, 75, 76, 168, 78, 217,
|
||||
/* 1020 */ 218, 219, 189, 180, 84, 180, 173, 164, 94, 0,
|
||||
/* 1030 */ 82, 0, 0, 114, 0, 0, 0, 0, 0, 69,
|
||||
/* 1040 */ 0, 22, 72, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 1050 */ 43, 0, 48, 0, 0, 38, 122, 123, 36, 43,
|
||||
/* 1060 */ 0, 0, 0, 0, 79, 77, 38, 0, 38, 0,
|
||||
/* 1070 */ 0, 38, 22, 0, 0, 0, 0, 38, 22, 38,
|
||||
/* 1080 */ 38, 22, 0, 121, 0, 70, 22, 116, 22, 83,
|
||||
/* 1090 */ 38, 20, 83, 38, 22, 141, 39, 71, 71, 141,
|
||||
/* 1100 */ 82, 43, 82, 38, 83, 141, 83, 83, 135, 4,
|
||||
/* 1110 */ 2, 119, 126, 0, 116, 258, 258, 258, 258, 258,
|
||||
/* 1120 */ 258, 96, 258, 258, 258, 258, 258, 258, 38, 38,
|
||||
/* 1130 */ 38, 38, 38, 38, 22, 258, 258, 258, 70, 258,
|
||||
/* 1140 */ 258, 43, 258, 258, 258, 258, 258, 70, 258, 71,
|
||||
/* 1150 */ 70, 258, 71, 70, 258, 22, 71, 71, 258, 71,
|
||||
/* 1160 */ 258, 258, 83, 258, 258, 258, 258, 258, 71, 82,
|
||||
/* 1170 */ 70, 70, 83, 71, 71, 258, 70, 70, 82, 70,
|
||||
/* 1180 */ 70, 82, 258, 258, 80, 70, 38, 0, 38, 38,
|
||||
/* 1190 */ 0, 38, 38, 82, 258, 81, 258, 22, 38, 258,
|
||||
/* 1200 */ 71, 70, 22, 71, 70, 0, 71, 258, 38, 70,
|
||||
/* 1210 */ 22, 22, 38, 71, 258, 258, 258, 38, 96, 258,
|
||||
/* 1220 */ 38, 258, 258, 38, 38, 48, 96, 70, 47, 71,
|
||||
/* 1230 */ 38, 38, 38, 70, 38, 0, 38, 38, 36, 38,
|
||||
/* 1240 */ 84, 70, 70, 70, 20, 38, 68, 38, 38, 21,
|
||||
/* 1250 */ 38, 38, 38, 22, 22, 21, 258, 38, 37, 258,
|
||||
/* 1260 */ 258, 43, 258, 258, 258, 96, 258, 258, 258, 258,
|
||||
/* 900 */ 204, 203, 83, 186, 171, 207, 83, 83, 71, 83,
|
||||
/* 910 */ 171, 83, 186, 211, 193, 217, 218, 219, 186, 193,
|
||||
/* 920 */ 83, 20, 145, 246, 216, 193, 144, 208, 123, 203,
|
||||
/* 930 */ 207, 246, 166, 207, 207, 203, 152, 242, 208, 207,
|
||||
/* 940 */ 166, 207, 151, 217, 218, 219, 12, 13, 243, 217,
|
||||
/* 950 */ 218, 219, 186, 140, 139, 239, 22, 136, 193, 193,
|
||||
/* 960 */ 186, 20, 240, 215, 114, 227, 160, 193, 166, 203,
|
||||
/* 970 */ 257, 154, 38, 207, 4, 35, 156, 203, 70, 223,
|
||||
/* 980 */ 208, 207, 251, 217, 218, 219, 207, 252, 186, 19,
|
||||
/* 990 */ 207, 217, 218, 219, 118, 193, 208, 57, 205, 207,
|
||||
/* 1000 */ 193, 61, 68, 33, 204, 203, 36, 171, 70, 207,
|
||||
/* 1010 */ 171, 41, 182, 73, 44, 75, 76, 172, 78, 217,
|
||||
/* 1020 */ 218, 219, 193, 189, 84, 171, 168, 180, 94, 180,
|
||||
/* 1030 */ 173, 164, 0, 82, 0, 0, 114, 0, 0, 69,
|
||||
/* 1040 */ 0, 0, 72, 0, 0, 22, 0, 0, 0, 0,
|
||||
/* 1050 */ 0, 0, 0, 43, 0, 48, 122, 123, 0, 0,
|
||||
/* 1060 */ 38, 36, 43, 0, 0, 0, 0, 79, 77, 38,
|
||||
/* 1070 */ 0, 38, 0, 0, 38, 22, 0, 38, 0, 22,
|
||||
/* 1080 */ 38, 0, 22, 38, 22, 0, 0, 121, 0, 116,
|
||||
/* 1090 */ 22, 22, 83, 38, 38, 20, 70, 83, 141, 71,
|
||||
/* 1100 */ 39, 83, 141, 83, 83, 38, 82, 135, 141, 82,
|
||||
/* 1110 */ 4, 2, 83, 83, 43, 126, 119, 0, 116, 258,
|
||||
/* 1120 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258,
|
||||
/* 1130 */ 38, 38, 38, 38, 38, 38, 22, 258, 258, 258,
|
||||
/* 1140 */ 258, 258, 258, 43, 258, 71, 258, 70, 258, 70,
|
||||
/* 1150 */ 258, 71, 70, 258, 71, 71, 258, 70, 258, 258,
|
||||
/* 1160 */ 71, 258, 71, 258, 258, 258, 258, 258, 258, 38,
|
||||
/* 1170 */ 71, 70, 82, 70, 38, 71, 71, 70, 70, 258,
|
||||
/* 1180 */ 82, 70, 70, 258, 82, 70, 38, 258, 38, 71,
|
||||
/* 1190 */ 80, 38, 22, 258, 38, 82, 258, 81, 22, 258,
|
||||
/* 1200 */ 258, 258, 70, 22, 71, 70, 0, 258, 71, 22,
|
||||
/* 1210 */ 258, 20, 22, 38, 70, 96, 38, 71, 258, 258,
|
||||
/* 1220 */ 258, 38, 70, 38, 38, 48, 71, 38, 70, 47,
|
||||
/* 1230 */ 96, 38, 0, 38, 38, 43, 38, 38, 0, 0,
|
||||
/* 1240 */ 36, 38, 70, 70, 70, 38, 37, 68, 38, 21,
|
||||
/* 1250 */ 258, 22, 38, 38, 38, 84, 38, 96, 22, 96,
|
||||
/* 1260 */ 38, 38, 21, 258, 258, 258, 258, 258, 258, 258,
|
||||
/* 1270 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258,
|
||||
/* 1280 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258,
|
||||
/* 1290 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258,
|
||||
|
@ -481,11 +481,11 @@ static const YYCODETYPE yy_lookahead[] = {
|
|||
/* 1390 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258,
|
||||
/* 1400 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258,
|
||||
/* 1410 */ 258, 258, 258, 258, 258, 258, 258, 258, 258, 258,
|
||||
/* 1420 */ 258, 258, 258, 258, 258, 258, 258, 258, 258,
|
||||
/* 1420 */ 258, 258, 258, 258, 258, 258,
|
||||
};
|
||||
#define YY_SHIFT_COUNT (426)
|
||||
#define YY_SHIFT_COUNT (429)
|
||||
#define YY_SHIFT_MIN (0)
|
||||
#define YY_SHIFT_MAX (1235)
|
||||
#define YY_SHIFT_MAX (1241)
|
||||
static const unsigned short int yy_shift_ofst[] = {
|
||||
/* 0 */ 426, 212, 161, 382, 382, 382, 382, 421, 382, 382,
|
||||
/* 10 */ 151, 513, 517, 444, 513, 513, 513, 513, 513, 513,
|
||||
|
@ -499,41 +499,41 @@ static const unsigned short int yy_shift_ofst[] = {
|
|||
/* 90 */ 307, 307, 307, 136, 343, 319, 17, 17, 17, 306,
|
||||
/* 100 */ 56, 56, 56, 56, 56, 68, 503, 534, 90, 215,
|
||||
/* 110 */ 335, 331, 478, 525, 417, 525, 493, 248, 591, 706,
|
||||
/* 120 */ 657, 661, 661, 706, 786, 66, 343, 799, 66, 706,
|
||||
/* 130 */ 66, 825, 17, 17, 17, 17, 17, 17, 17, 17,
|
||||
/* 140 */ 17, 17, 17, 706, 825, 786, 278, 343, 799, 893,
|
||||
/* 150 */ 769, 778, 804, 769, 778, 804, 804, 784, 790, 808,
|
||||
/* 160 */ 814, 818, 343, 937, 847, 805, 815, 816, 908, 17,
|
||||
/* 170 */ 778, 804, 804, 778, 804, 876, 343, 799, 306, 278,
|
||||
/* 180 */ 343, 938, 706, 278, 825, 1266, 1266, 1266, 1266, 0,
|
||||
/* 190 */ 545, 577, 46, 970, 16, 89, 728, 406, 757, 301,
|
||||
/* 200 */ 301, 301, 301, 301, 301, 301, 115, 288, 196, 7,
|
||||
/* 210 */ 7, 7, 7, 374, 605, 610, 701, 453, 580, 632,
|
||||
/* 220 */ 506, 541, 714, 715, 718, 647, 590, 451, 729, 74,
|
||||
/* 230 */ 749, 758, 763, 787, 795, 797, 803, 639, 653, 819,
|
||||
/* 240 */ 823, 824, 826, 828, 837, 751, 1029, 948, 1031, 1032,
|
||||
/* 250 */ 919, 1034, 1035, 1036, 1037, 1038, 1040, 1019, 1043, 1044,
|
||||
/* 260 */ 1045, 1046, 1047, 1048, 1049, 1007, 1051, 1004, 1053, 1054,
|
||||
/* 270 */ 1017, 1022, 1016, 1060, 1061, 1062, 1063, 985, 988, 1028,
|
||||
/* 280 */ 1030, 1050, 1067, 1033, 1039, 1041, 1042, 1052, 1055, 1069,
|
||||
/* 290 */ 1056, 1070, 1059, 1057, 1073, 1064, 1065, 1074, 1066, 1075,
|
||||
/* 300 */ 1072, 1071, 1076, 1082, 962, 1084, 1015, 1058, 971, 1006,
|
||||
/* 310 */ 1009, 954, 1026, 1021, 1027, 1068, 1077, 1078, 1080, 1081,
|
||||
/* 320 */ 1023, 1018, 1083, 1024, 958, 1085, 1086, 1020, 973, 1079,
|
||||
/* 330 */ 1087, 1088, 1089, 964, 1105, 1090, 1091, 1092, 1093, 1094,
|
||||
/* 340 */ 1095, 1108, 986, 1096, 1097, 1100, 1101, 1102, 1103, 1106,
|
||||
/* 350 */ 1107, 992, 1109, 1113, 1098, 998, 1110, 1104, 1099, 1111,
|
||||
/* 360 */ 1112, 1115, 1114, 1129, 1148, 1150, 1131, 1132, 1151, 1134,
|
||||
/* 370 */ 1135, 1153, 1139, 1142, 1154, 1157, 1158, 1160, 1163, 1025,
|
||||
/* 380 */ 1122, 1130, 1169, 1133, 1156, 1171, 1172, 1173, 1170, 1174,
|
||||
/* 390 */ 1175, 1177, 1181, 1178, 1180, 1179, 1182, 1185, 1186, 1192,
|
||||
/* 400 */ 1193, 1194, 1189, 1196, 1198, 1199, 1201, 1207, 1209, 1210,
|
||||
/* 410 */ 1212, 1213, 1187, 1214, 1202, 1218, 1190, 1219, 1221, 1205,
|
||||
/* 420 */ 1235, 1188, 1228, 1231, 1232, 1234, 1224,
|
||||
/* 120 */ 657, 661, 661, 706, 786, 66, 343, 799, 66, 66,
|
||||
/* 130 */ 706, 66, 831, 17, 17, 17, 17, 17, 17, 17,
|
||||
/* 140 */ 17, 17, 17, 17, 706, 831, 786, 278, 343, 799,
|
||||
/* 150 */ 278, 901, 777, 782, 805, 777, 782, 805, 805, 784,
|
||||
/* 160 */ 791, 813, 815, 821, 343, 941, 850, 806, 820, 817,
|
||||
/* 170 */ 908, 17, 782, 805, 805, 782, 805, 876, 343, 799,
|
||||
/* 180 */ 278, 306, 278, 343, 938, 706, 278, 831, 1263, 1263,
|
||||
/* 190 */ 1263, 1263, 0, 545, 577, 46, 970, 16, 89, 728,
|
||||
/* 200 */ 406, 757, 301, 301, 301, 301, 301, 301, 301, 115,
|
||||
/* 210 */ 288, 196, 7, 7, 7, 7, 374, 605, 610, 701,
|
||||
/* 220 */ 453, 580, 632, 506, 541, 714, 715, 718, 647, 590,
|
||||
/* 230 */ 451, 729, 74, 749, 758, 763, 787, 795, 797, 803,
|
||||
/* 240 */ 639, 653, 819, 823, 824, 826, 828, 837, 751, 1032,
|
||||
/* 250 */ 951, 1034, 1035, 922, 1037, 1038, 1040, 1041, 1043, 1044,
|
||||
/* 260 */ 1023, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1010, 1054,
|
||||
/* 270 */ 1007, 1058, 1059, 1022, 1025, 1019, 1063, 1064, 1065, 1066,
|
||||
/* 280 */ 988, 991, 1031, 1033, 1053, 1070, 1036, 1039, 1042, 1045,
|
||||
/* 290 */ 1055, 1056, 1072, 1057, 1073, 1060, 1061, 1076, 1062, 1067,
|
||||
/* 300 */ 1078, 1068, 1081, 1069, 1075, 1085, 1086, 966, 1088, 1026,
|
||||
/* 310 */ 1071, 973, 1009, 1014, 957, 1028, 1018, 1074, 1077, 1079,
|
||||
/* 320 */ 1080, 1082, 1083, 1020, 1024, 1087, 1021, 961, 1084, 1089,
|
||||
/* 330 */ 1027, 972, 1029, 1090, 1091, 1030, 967, 1106, 1092, 1093,
|
||||
/* 340 */ 1094, 1095, 1096, 1097, 1109, 989, 1098, 1099, 1101, 1103,
|
||||
/* 350 */ 1104, 1105, 1107, 1108, 997, 1111, 1117, 1100, 1002, 1112,
|
||||
/* 360 */ 1110, 1102, 1113, 1114, 1115, 1116, 1118, 1131, 1136, 1132,
|
||||
/* 370 */ 1133, 1148, 1135, 1137, 1150, 1144, 1146, 1153, 1152, 1155,
|
||||
/* 380 */ 1156, 1158, 1119, 1134, 1161, 1163, 1170, 1171, 1172, 1173,
|
||||
/* 390 */ 1174, 1175, 1178, 1176, 1177, 1182, 1179, 1181, 1183, 1185,
|
||||
/* 400 */ 1186, 1189, 1193, 1195, 1196, 1187, 1198, 1199, 1203, 1210,
|
||||
/* 410 */ 1214, 1215, 1216, 1218, 1222, 1206, 1207, 1204, 1192, 1232,
|
||||
/* 420 */ 1223, 1209, 1238, 1239, 1190, 1228, 1229, 1236, 1241, 1191,
|
||||
};
|
||||
#define YY_REDUCE_COUNT (188)
|
||||
#define YY_REDUCE_COUNT (191)
|
||||
#define YY_REDUCE_MIN (-217)
|
||||
#define YY_REDUCE_MAX (863)
|
||||
#define YY_REDUCE_MAX (867)
|
||||
static const short yy_reduce_ofst[] = {
|
||||
/* 0 */ -129, -6, 49, 78, 126, 155, 190, 219, 276, 299,
|
||||
/* 10 */ 135, 375, 398, 434, 492, -80, 497, 515, 520, 562,
|
||||
|
@ -547,58 +547,59 @@ static const short yy_reduce_ofst[] = {
|
|||
/* 90 */ 110, 185, 327, 578, 27, 54, 217, 287, 311, -10,
|
||||
/* 100 */ -178, -140, 204, 312, 345, 268, 412, 347, 381, 446,
|
||||
/* 110 */ 415, 495, 519, 471, 471, 471, 476, 504, 533, 575,
|
||||
/* 120 */ 589, 592, 593, 623, 599, 643, 620, 631, 650, 666,
|
||||
/* 130 */ 668, 676, 665, 673, 679, 683, 686, 689, 690, 693,
|
||||
/* 140 */ 699, 707, 710, 680, 694, 692, 733, 717, 696, 705,
|
||||
/* 150 */ 677, 716, 719, 682, 722, 724, 727, 695, 700, 697,
|
||||
/* 160 */ 723, 471, 762, 743, 736, 709, 712, 725, 756, 476,
|
||||
/* 170 */ 772, 775, 779, 782, 780, 791, 806, 794, 822, 829,
|
||||
/* 180 */ 817, 833, 835, 841, 849, 843, 845, 853, 863,
|
||||
/* 120 */ 589, 592, 593, 623, 599, 643, 620, 631, 650, 668,
|
||||
/* 130 */ 666, 671, 676, 673, 679, 683, 686, 689, 690, 693,
|
||||
/* 140 */ 699, 707, 710, 717, 680, 694, 702, 733, 721, 696,
|
||||
/* 150 */ 739, 708, 677, 719, 723, 685, 730, 727, 734, 705,
|
||||
/* 160 */ 695, 722, 716, 471, 765, 748, 738, 713, 735, 731,
|
||||
/* 170 */ 756, 476, 772, 779, 783, 788, 792, 793, 807, 800,
|
||||
/* 180 */ 836, 830, 839, 829, 834, 845, 854, 858, 847, 849,
|
||||
/* 190 */ 857, 867,
|
||||
};
|
||||
static const YYACTIONTYPE yy_default[] = {
|
||||
/* 0 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 10 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 20 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 30 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 40 */ 996, 996, 996, 996, 1049, 996, 996, 996, 996, 996,
|
||||
/* 50 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 60 */ 1047, 996, 1255, 996, 1161, 996, 996, 996, 996, 996,
|
||||
/* 70 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 80 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 1049,
|
||||
/* 90 */ 1266, 1266, 1266, 1047, 996, 996, 996, 996, 996, 1132,
|
||||
/* 100 */ 996, 996, 996, 996, 996, 996, 996, 1330, 996, 1085,
|
||||
/* 110 */ 1290, 996, 1282, 1258, 1272, 1259, 996, 1315, 1275, 996,
|
||||
/* 120 */ 1166, 1163, 1163, 996, 996, 1049, 996, 996, 1049, 996,
|
||||
/* 130 */ 1049, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 140 */ 996, 996, 996, 996, 996, 996, 1047, 996, 996, 996,
|
||||
/* 150 */ 1297, 1295, 996, 1297, 1295, 996, 996, 1309, 1305, 1288,
|
||||
/* 160 */ 1286, 1272, 996, 996, 996, 1333, 1321, 1317, 996, 996,
|
||||
/* 170 */ 1295, 996, 996, 1295, 996, 1174, 996, 996, 996, 1047,
|
||||
/* 180 */ 996, 1101, 996, 1047, 996, 1135, 1135, 1050, 1001, 996,
|
||||
/* 190 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 1227,
|
||||
/* 200 */ 1308, 1307, 1226, 1232, 1231, 1230, 996, 996, 996, 1221,
|
||||
/* 210 */ 1222, 1220, 1219, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 220 */ 996, 996, 996, 996, 1256, 996, 1318, 1322, 996, 996,
|
||||
/* 230 */ 996, 1206, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 240 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 250 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 260 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 270 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 280 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 290 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 300 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 1279,
|
||||
/* 310 */ 1289, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 320 */ 996, 1206, 996, 1306, 996, 1265, 1261, 996, 996, 1257,
|
||||
/* 330 */ 996, 996, 1316, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 340 */ 996, 1251, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 350 */ 996, 996, 996, 996, 996, 996, 996, 996, 1205, 996,
|
||||
/* 360 */ 996, 996, 996, 996, 996, 996, 1129, 996, 996, 996,
|
||||
/* 370 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 1114,
|
||||
/* 380 */ 1112, 1111, 1110, 996, 1107, 996, 996, 996, 996, 996,
|
||||
/* 390 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 400 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 410 */ 996, 996, 996, 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 420 */ 996, 996, 996, 996, 996, 996, 996,
|
||||
/* 0 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 10 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 20 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 30 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 40 */ 999, 999, 999, 999, 1052, 999, 999, 999, 999, 999,
|
||||
/* 50 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 60 */ 1050, 999, 1258, 999, 1164, 999, 999, 999, 999, 999,
|
||||
/* 70 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 80 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 1052,
|
||||
/* 90 */ 1269, 1269, 1269, 1050, 999, 999, 999, 999, 999, 1135,
|
||||
/* 100 */ 999, 999, 999, 999, 999, 999, 999, 1333, 999, 1088,
|
||||
/* 110 */ 1293, 999, 1285, 1261, 1275, 1262, 999, 1318, 1278, 999,
|
||||
/* 120 */ 1169, 1166, 1166, 999, 999, 1052, 999, 999, 1052, 1052,
|
||||
/* 130 */ 999, 1052, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 140 */ 999, 999, 999, 999, 999, 999, 999, 1050, 999, 999,
|
||||
/* 150 */ 1050, 999, 1300, 1298, 999, 1300, 1298, 999, 999, 1312,
|
||||
/* 160 */ 1308, 1291, 1289, 1275, 999, 999, 999, 1336, 1324, 1320,
|
||||
/* 170 */ 999, 999, 1298, 999, 999, 1298, 999, 1177, 999, 999,
|
||||
/* 180 */ 1050, 999, 1050, 999, 1104, 999, 1050, 999, 1138, 1138,
|
||||
/* 190 */ 1053, 1004, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 200 */ 999, 999, 1230, 1311, 1310, 1229, 1235, 1234, 1233, 999,
|
||||
/* 210 */ 999, 999, 1224, 1225, 1223, 1222, 999, 999, 999, 999,
|
||||
/* 220 */ 999, 999, 999, 999, 999, 999, 999, 1259, 999, 1321,
|
||||
/* 230 */ 1325, 999, 999, 999, 1209, 999, 999, 999, 999, 999,
|
||||
/* 240 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 250 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 260 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 270 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 280 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 290 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 300 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 310 */ 999, 999, 1282, 1292, 999, 999, 999, 999, 999, 999,
|
||||
/* 320 */ 999, 999, 999, 999, 1209, 999, 1309, 999, 1268, 1264,
|
||||
/* 330 */ 999, 999, 1260, 999, 999, 1319, 999, 999, 999, 999,
|
||||
/* 340 */ 999, 999, 999, 999, 1254, 999, 999, 999, 999, 999,
|
||||
/* 350 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 360 */ 999, 1208, 999, 999, 999, 999, 999, 999, 999, 1132,
|
||||
/* 370 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 380 */ 999, 999, 1117, 1115, 1114, 1113, 999, 1110, 999, 999,
|
||||
/* 390 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 400 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 410 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
/* 420 */ 999, 999, 999, 999, 999, 999, 999, 999, 999, 999,
|
||||
};
|
||||
/********** End of lemon-generated parsing tables *****************************/
|
||||
|
||||
|
@ -1142,9 +1143,9 @@ static const char *const yyRuleName[] = {
|
|||
/* 169 */ "func_name_list ::= func_name",
|
||||
/* 170 */ "func_name_list ::= func_name_list NK_COMMA col_name",
|
||||
/* 171 */ "func_name ::= function_name",
|
||||
/* 172 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options",
|
||||
/* 173 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP",
|
||||
/* 174 */ "cmd ::= DROP INDEX index_name ON table_name",
|
||||
/* 172 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options",
|
||||
/* 173 */ "cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP",
|
||||
/* 174 */ "cmd ::= DROP INDEX exists_opt index_name ON table_name",
|
||||
/* 175 */ "index_options ::=",
|
||||
/* 176 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt",
|
||||
/* 177 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt",
|
||||
|
@ -2042,9 +2043,9 @@ static const struct {
|
|||
{ 195, -1 }, /* (169) func_name_list ::= func_name */
|
||||
{ 195, -3 }, /* (170) func_name_list ::= func_name_list NK_COMMA col_name */
|
||||
{ 202, -1 }, /* (171) func_name ::= function_name */
|
||||
{ 163, -7 }, /* (172) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */
|
||||
{ 163, -9 }, /* (173) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */
|
||||
{ 163, -5 }, /* (174) cmd ::= DROP INDEX index_name ON table_name */
|
||||
{ 163, -8 }, /* (172) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */
|
||||
{ 163, -10 }, /* (173) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */
|
||||
{ 163, -6 }, /* (174) cmd ::= DROP INDEX exists_opt index_name ON table_name */
|
||||
{ 205, 0 }, /* (175) index_options ::= */
|
||||
{ 205, -9 }, /* (176) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */
|
||||
{ 205, -11 }, /* (177) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */
|
||||
|
@ -2840,14 +2841,14 @@ static YYACTIONTYPE yy_reduce(
|
|||
{ yylhsminor.yy140 = createFunctionNode(pCxt, &yymsp[0].minor.yy149, NULL); }
|
||||
yymsp[0].minor.yy140 = yylhsminor.yy140;
|
||||
break;
|
||||
case 172: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */
|
||||
{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy149, &yymsp[-1].minor.yy149, NULL, yymsp[0].minor.yy140); }
|
||||
case 172: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */
|
||||
{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy497, &yymsp[-3].minor.yy149, &yymsp[-1].minor.yy149, NULL, yymsp[0].minor.yy140); }
|
||||
break;
|
||||
case 173: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */
|
||||
{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy149, &yymsp[-3].minor.yy149, yymsp[-1].minor.yy136, NULL); }
|
||||
case 173: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */
|
||||
{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy497, &yymsp[-5].minor.yy149, &yymsp[-3].minor.yy149, yymsp[-1].minor.yy136, NULL); }
|
||||
break;
|
||||
case 174: /* cmd ::= DROP INDEX index_name ON table_name */
|
||||
{ pCxt->pRootNode = createDropIndexStmt(pCxt, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy149); }
|
||||
case 174: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */
|
||||
{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy497, &yymsp[-2].minor.yy149, &yymsp[0].minor.yy149); }
|
||||
break;
|
||||
case 176: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */
|
||||
{ yymsp[-8].minor.yy140 = createIndexOption(pCxt, yymsp[-6].minor.yy136, releaseRawExprNode(pCxt, yymsp[-2].minor.yy140), NULL, yymsp[0].minor.yy140); }
|
||||
|
|
|
@ -358,7 +358,6 @@ TEST_F(ParserTest, selectSemanticError) {
|
|||
ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION));
|
||||
}
|
||||
|
||||
|
||||
TEST_F(ParserTest, showUsers) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
|
@ -366,8 +365,6 @@ TEST_F(ParserTest, showUsers) {
|
|||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST_F(ParserTest, createDnode) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ protected:
|
|||
SSubmitBlk* blk = (SSubmitBlk*)(submit + 1);
|
||||
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
||||
cout << "Block:" << i << endl;
|
||||
cout << "\tuid:" << be64toh(blk->uid) << ", tid:" << ntohl(blk->tid) << ", padding:" << ntohl(blk->padding) << ", sversion:" << ntohl(blk->sversion)
|
||||
cout << "\tuid:" << be64toh(blk->uid) << ", tid:" << be64toh(blk->suid) << ", padding:" << ntohl(blk->padding) << ", sversion:" << ntohl(blk->sversion)
|
||||
<< ", dataLen:" << ntohl(blk->dataLen) << ", schemaLen:" << ntohl(blk->schemaLen) << ", numOfRows:" << ntohs(blk->numOfRows) << endl;
|
||||
blk = (SSubmitBlk*)(blk->data + ntohl(blk->dataLen));
|
||||
}
|
||||
|
|
|
@ -213,6 +213,33 @@ static SNodeptr createPrimaryKeyCol(SPhysiPlanContext* pCxt, uint64_t tableId) {
|
|||
return pCol;
|
||||
}
|
||||
|
||||
static int32_t colIdCompare(const void* pLeft, const void* pRight) {
|
||||
SColumnNode* pLeftCol = *(SColumnNode**)pLeft;
|
||||
SColumnNode* pRightCol = *(SColumnNode**)pRight;
|
||||
return pLeftCol->colId > pRightCol->colId ? 1 : -1;
|
||||
}
|
||||
|
||||
static int32_t sortScanCols(SNodeList* pScanCols) {
|
||||
SArray* pArray = taosArrayInit(LIST_LENGTH(pScanCols), POINTER_BYTES);
|
||||
if (NULL == pArray) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SNode* pCol = NULL;
|
||||
FOREACH(pCol, pScanCols) {
|
||||
taosArrayPush(pArray, &pCol);
|
||||
}
|
||||
taosArraySort(pArray, colIdCompare);
|
||||
|
||||
int32_t index = 0;
|
||||
FOREACH(pCol, pScanCols) {
|
||||
REPLACE_NODE(taosArrayGetP(pArray, index++));
|
||||
}
|
||||
taosArrayDestroy(pArray);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t createScanCols(SPhysiPlanContext* pCxt, SScanPhysiNode* pScanPhysiNode, SNodeList* pScanCols) {
|
||||
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == nodeType(pScanPhysiNode)
|
||||
|| QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN == nodeType(pScanPhysiNode)) {
|
||||
|
@ -235,6 +262,7 @@ static int32_t createScanCols(SPhysiPlanContext* pCxt, SScanPhysiNode* pScanPhys
|
|||
CHECK_ALLOC(pScanPhysiNode->pScanCols, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
// return sortScanCols(pScanPhysiNode->pScanCols);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,11 @@ protected:
|
|||
const string syntaxTreeStr = toString(query_->pRoot, false);
|
||||
|
||||
SLogicNode* pLogicNode = nullptr;
|
||||
SPlanContext cxt = { .queryId = 1, .acctId = 0, .streamQuery = streamQuery };
|
||||
SPlanContext cxt = {0};
|
||||
cxt.queryId = 1;
|
||||
cxt.acctId = 0;
|
||||
cxt.streamQuery = streamQuery;
|
||||
|
||||
setPlanContext(query_, &cxt);
|
||||
code = createLogicPlan(&cxt, &pLogicNode);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -108,6 +112,11 @@ private:
|
|||
if (QUERY_NODE_CREATE_TOPIC_STMT == nodeType(pQuery->pRoot)) {
|
||||
pCxt->pAstRoot = ((SCreateTopicStmt*)pQuery->pRoot)->pQuery;
|
||||
pCxt->topicQuery = true;
|
||||
} else if (QUERY_NODE_CREATE_INDEX_STMT == nodeType(pQuery->pRoot)) {
|
||||
SMCreateSmaReq req = {0};
|
||||
tDeserializeSMCreateSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req);
|
||||
nodesStringToNode(req.ast, &pCxt->pAstRoot);
|
||||
pCxt->streamQuery = true;
|
||||
} else {
|
||||
pCxt->pAstRoot = pQuery->pRoot;
|
||||
}
|
||||
|
@ -211,3 +220,10 @@ TEST_F(PlannerTest, stream) {
|
|||
bind("SELECT sum(c1) FROM st1");
|
||||
ASSERT_TRUE(run(true));
|
||||
}
|
||||
|
||||
TEST_F(PlannerTest, createSmaIndex) {
|
||||
setDatabase("root", "test");
|
||||
|
||||
bind("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4)) INTERVAL(10s)");
|
||||
ASSERT_TRUE(run());
|
||||
}
|
||||
|
|
|
@ -27,6 +27,12 @@ extern "C" {
|
|||
#include "syncMessage.h"
|
||||
#include "taosdef.h"
|
||||
|
||||
typedef enum EntryType {
|
||||
SYNC_RAFT_ENTRY_NOOP = 0,
|
||||
SYNC_RAFT_ENTRY_DATA = 1,
|
||||
SYNC_RAFT_ENTRY_CONFIG = 2,
|
||||
} EntryType;
|
||||
|
||||
typedef struct SSyncRaftEntry {
|
||||
uint32_t bytes;
|
||||
uint32_t msgType;
|
||||
|
@ -35,12 +41,15 @@ typedef struct SSyncRaftEntry {
|
|||
bool isWeak;
|
||||
SyncTerm term;
|
||||
SyncIndex index;
|
||||
EntryType entryType;
|
||||
uint32_t dataLen;
|
||||
char data[];
|
||||
} SSyncRaftEntry;
|
||||
|
||||
SSyncRaftEntry* syncEntryBuild(uint32_t dataLen);
|
||||
SSyncRaftEntry* syncEntryBuild2(SyncClientRequest* pMsg, SyncTerm term, SyncIndex index); // step 4
|
||||
SSyncRaftEntry* syncEntryBuild3(SyncClientRequest* pMsg, SyncTerm term, SyncIndex index, EntryType entryType);
|
||||
SSyncRaftEntry* syncEntryBuildNoop(SyncTerm term, SyncIndex index);
|
||||
void syncEntryDestory(SSyncRaftEntry* pEntry);
|
||||
char* syncEntrySerialize(const SSyncRaftEntry* pEntry, uint32_t* len); // step 5
|
||||
SSyncRaftEntry* syncEntryDeserialize(const char* buf, uint32_t len); // step 6
|
||||
|
|
|
@ -199,6 +199,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
|
|||
SSyncRaftEntry* pRollBackEntry = logStoreGetEntry(ths->pLogStore, index);
|
||||
assert(pRollBackEntry != NULL);
|
||||
|
||||
// maybe is a NOOP ENTRY
|
||||
// assert(pRollBackEntry->entryType == SYNC_RAFT_ENTRY_DATA);
|
||||
|
||||
SRpcMsg rpcMsg;
|
||||
syncEntry2OriginalRpc(pRollBackEntry, &rpcMsg);
|
||||
ths->pFsm->FpRollBackCb(ths->pFsm, &rpcMsg, pRollBackEntry->index, pRollBackEntry->isWeak, 0, ths->state);
|
||||
|
@ -217,7 +220,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
|
|||
SRpcMsg rpcMsg;
|
||||
syncEntry2OriginalRpc(pAppendEntry, &rpcMsg);
|
||||
if (ths->pFsm != NULL) {
|
||||
if (ths->pFsm->FpPreCommitCb != NULL) {
|
||||
if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->entryType == SYNC_RAFT_ENTRY_DATA) {
|
||||
ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pAppendEntry->index, pAppendEntry->isWeak, 2, ths->state);
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +245,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
|
|||
SRpcMsg rpcMsg;
|
||||
syncEntry2OriginalRpc(pAppendEntry, &rpcMsg);
|
||||
if (ths->pFsm != NULL) {
|
||||
if (ths->pFsm->FpPreCommitCb != NULL) {
|
||||
if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->entryType == SYNC_RAFT_ENTRY_DATA) {
|
||||
ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pAppendEntry->index, pAppendEntry->isWeak, 3, ths->state);
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +301,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
|
|||
SRpcMsg rpcMsg;
|
||||
syncEntry2OriginalRpc(pEntry, &rpcMsg);
|
||||
|
||||
if (ths->pFsm->FpCommitCb != NULL) {
|
||||
if (ths->pFsm->FpCommitCb != NULL && pEntry->entryType == SYNC_RAFT_ENTRY_DATA) {
|
||||
ths->pFsm->FpCommitCb(ths->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, 0, ths->state);
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
|
|||
SRpcMsg rpcMsg;
|
||||
syncEntry2OriginalRpc(pEntry, &rpcMsg);
|
||||
|
||||
if (pSyncNode->pFsm->FpCommitCb != NULL) {
|
||||
if (pSyncNode->pFsm->FpCommitCb != NULL && pEntry->entryType == SYNC_RAFT_ENTRY_DATA) {
|
||||
pSyncNode->pFsm->FpCommitCb(pSyncNode->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, 0, pSyncNode->state);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ static int32_t syncIODestroy(SSyncIO *io);
|
|||
static int32_t syncIOStartInternal(SSyncIO *io);
|
||||
static int32_t syncIOStopInternal(SSyncIO *io);
|
||||
|
||||
static void * syncIOConsumerFunc(void *param);
|
||||
static void *syncIOConsumerFunc(void *param);
|
||||
static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||
static void syncIOProcessReply(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet);
|
||||
static int32_t syncIOAuth(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey);
|
||||
|
@ -75,6 +75,7 @@ int32_t syncIOSendMsg(void *clientRpc, const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
|||
syncRpcMsgPrint2(logBuf, pMsg);
|
||||
|
||||
pMsg->handle = NULL;
|
||||
pMsg->noResp = 1;
|
||||
rpcSendRequest(clientRpc, pEpSet, pMsg, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
@ -234,9 +235,9 @@ static int32_t syncIOStopInternal(SSyncIO *io) {
|
|||
}
|
||||
|
||||
static void *syncIOConsumerFunc(void *param) {
|
||||
SSyncIO * io = param;
|
||||
SSyncIO *io = param;
|
||||
STaosQall *qall;
|
||||
SRpcMsg * pRpcMsg, rpcMsg;
|
||||
SRpcMsg *pRpcMsg, rpcMsg;
|
||||
qall = taosAllocateQall();
|
||||
|
||||
while (1) {
|
||||
|
@ -324,19 +325,21 @@ static void *syncIOConsumerFunc(void *param) {
|
|||
taosGetQitem(qall, (void **)&pRpcMsg);
|
||||
rpcFreeCont(pRpcMsg->pCont);
|
||||
|
||||
if (pRpcMsg->handle != NULL) {
|
||||
int msgSize = 32;
|
||||
memset(&rpcMsg, 0, sizeof(rpcMsg));
|
||||
rpcMsg.msgType = SYNC_RESPONSE;
|
||||
rpcMsg.pCont = rpcMallocCont(msgSize);
|
||||
rpcMsg.contLen = msgSize;
|
||||
snprintf(rpcMsg.pCont, rpcMsg.contLen, "%s", "give a reply");
|
||||
rpcMsg.handle = pRpcMsg->handle;
|
||||
rpcMsg.code = 0;
|
||||
/*
|
||||
if (pRpcMsg->handle != NULL) {
|
||||
int msgSize = 32;
|
||||
memset(&rpcMsg, 0, sizeof(rpcMsg));
|
||||
rpcMsg.msgType = SYNC_RESPONSE;
|
||||
rpcMsg.pCont = rpcMallocCont(msgSize);
|
||||
rpcMsg.contLen = msgSize;
|
||||
snprintf(rpcMsg.pCont, rpcMsg.contLen, "%s", "give a reply");
|
||||
rpcMsg.handle = pRpcMsg->handle;
|
||||
rpcMsg.code = 0;
|
||||
|
||||
syncRpcMsgPrint2((char *)"syncIOConsumerFunc rpcSendResponse --> ", &rpcMsg);
|
||||
rpcSendResponse(&rpcMsg);
|
||||
}
|
||||
syncRpcMsgPrint2((char *)"syncIOConsumerFunc rpcSendResponse --> ", &rpcMsg);
|
||||
rpcSendResponse(&rpcMsg);
|
||||
}
|
||||
*/
|
||||
|
||||
taosFreeQitem(pRpcMsg);
|
||||
}
|
||||
|
|
|
@ -37,11 +37,13 @@ static int32_t tsNodeRefId = -1;
|
|||
|
||||
// ------ local funciton ---------
|
||||
// enqueue message ----
|
||||
static void syncNodeEqPingTimer(void* param, void* tmrId);
|
||||
static void syncNodeEqElectTimer(void* param, void* tmrId);
|
||||
static void syncNodeEqHeartbeatTimer(void* param, void* tmrId);
|
||||
static void syncNodeEqPingTimer(void* param, void* tmrId);
|
||||
static void syncNodeEqElectTimer(void* param, void* tmrId);
|
||||
static void syncNodeEqHeartbeatTimer(void* param, void* tmrId);
|
||||
static int32_t syncNodeEqNoop(SSyncNode* ths);
|
||||
static int32_t syncNodeAppendNoop(SSyncNode* ths);
|
||||
|
||||
// on message ----
|
||||
// process message ----
|
||||
static int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg);
|
||||
static int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg);
|
||||
static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg);
|
||||
|
@ -669,6 +671,10 @@ void syncNodeCandidate2Leader(SSyncNode* pSyncNode) {
|
|||
assert(pSyncNode->state == TAOS_SYNC_STATE_CANDIDATE);
|
||||
assert(voteGrantedMajority(pSyncNode->pVotesGranted));
|
||||
syncNodeBecomeLeader(pSyncNode);
|
||||
|
||||
// Raft 3.6.2 Committing entries from previous terms
|
||||
syncNodeAppendNoop(pSyncNode);
|
||||
// syncNodeEqNoop(pSyncNode);
|
||||
}
|
||||
|
||||
void syncNodeFollower2Candidate(SSyncNode* pSyncNode) {
|
||||
|
@ -803,6 +809,47 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t syncNodeEqNoop(SSyncNode* ths) {
|
||||
int32_t ret = 0;
|
||||
assert(ths->state == TAOS_SYNC_STATE_LEADER);
|
||||
|
||||
SyncIndex index = ths->pLogStore->getLastIndex(ths->pLogStore) + 1;
|
||||
SyncTerm term = ths->pRaftStore->currentTerm;
|
||||
SSyncRaftEntry* pEntry = syncEntryBuildNoop(term, index);
|
||||
assert(pEntry != NULL);
|
||||
|
||||
uint32_t entryLen;
|
||||
char* serialized = syncEntrySerialize(pEntry, &entryLen);
|
||||
SyncClientRequest* pSyncMsg = syncClientRequestBuild(entryLen);
|
||||
assert(pSyncMsg->dataLen == entryLen);
|
||||
memcpy(pSyncMsg->data, serialized, entryLen);
|
||||
|
||||
SRpcMsg rpcMsg;
|
||||
syncClientRequest2RpcMsg(pSyncMsg, &rpcMsg);
|
||||
ths->FpEqMsg(ths->queue, &rpcMsg);
|
||||
|
||||
free(serialized);
|
||||
syncClientRequestDestroy(pSyncMsg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t syncNodeAppendNoop(SSyncNode* ths) {
|
||||
int32_t ret = 0;
|
||||
|
||||
SyncIndex index = ths->pLogStore->getLastIndex(ths->pLogStore) + 1;
|
||||
SyncTerm term = ths->pRaftStore->currentTerm;
|
||||
SSyncRaftEntry* pEntry = syncEntryBuildNoop(term, index);
|
||||
assert(pEntry != NULL);
|
||||
|
||||
if (ths->state == TAOS_SYNC_STATE_LEADER) {
|
||||
ths->pLogStore->appendEntry(ths->pLogStore, pEntry);
|
||||
syncNodeReplicate(ths);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// on message ----
|
||||
static int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg) {
|
||||
int32_t ret = 0;
|
||||
|
@ -851,7 +898,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg
|
|||
syncEntry2OriginalRpc(pEntry, &rpcMsg);
|
||||
|
||||
if (ths->pFsm != NULL) {
|
||||
if (ths->pFsm->FpPreCommitCb != NULL) {
|
||||
if (ths->pFsm->FpPreCommitCb != NULL && pEntry->entryType == SYNC_RAFT_ENTRY_DATA) {
|
||||
ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, 0, ths->state);
|
||||
}
|
||||
}
|
||||
|
@ -866,7 +913,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg
|
|||
syncEntry2OriginalRpc(pEntry, &rpcMsg);
|
||||
|
||||
if (ths->pFsm != NULL) {
|
||||
if (ths->pFsm->FpPreCommitCb != NULL) {
|
||||
if (ths->pFsm->FpPreCommitCb != NULL && pEntry->entryType == SYNC_RAFT_ENTRY_DATA) {
|
||||
ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, 1, ths->state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,13 @@ SSyncRaftEntry* syncEntryBuild(uint32_t dataLen) {
|
|||
|
||||
// step 4. SyncClientRequest => SSyncRaftEntry, add term, index
|
||||
SSyncRaftEntry* syncEntryBuild2(SyncClientRequest* pMsg, SyncTerm term, SyncIndex index) {
|
||||
SSyncRaftEntry* pEntry = syncEntryBuild3(pMsg, term, index, SYNC_RAFT_ENTRY_DATA);
|
||||
assert(pEntry != NULL);
|
||||
|
||||
return pEntry;
|
||||
}
|
||||
|
||||
SSyncRaftEntry* syncEntryBuild3(SyncClientRequest* pMsg, SyncTerm term, SyncIndex index, EntryType entryType) {
|
||||
SSyncRaftEntry* pEntry = syncEntryBuild(pMsg->dataLen);
|
||||
assert(pEntry != NULL);
|
||||
|
||||
|
@ -37,12 +44,23 @@ SSyncRaftEntry* syncEntryBuild2(SyncClientRequest* pMsg, SyncTerm term, SyncInde
|
|||
pEntry->isWeak = pMsg->isWeak;
|
||||
pEntry->term = term;
|
||||
pEntry->index = index;
|
||||
pEntry->entryType = entryType;
|
||||
pEntry->dataLen = pMsg->dataLen;
|
||||
memcpy(pEntry->data, pMsg->data, pMsg->dataLen);
|
||||
|
||||
return pEntry;
|
||||
}
|
||||
|
||||
SSyncRaftEntry* syncEntryBuildNoop(SyncTerm term, SyncIndex index) {
|
||||
SSyncRaftEntry* pEntry = syncEntryBuild(0);
|
||||
assert(pEntry != NULL);
|
||||
pEntry->term = term;
|
||||
pEntry->index = index;
|
||||
pEntry->entryType = SYNC_RAFT_ENTRY_NOOP;
|
||||
|
||||
return pEntry;
|
||||
}
|
||||
|
||||
void syncEntryDestory(SSyncRaftEntry* pEntry) {
|
||||
if (pEntry != NULL) {
|
||||
free(pEntry);
|
||||
|
@ -85,6 +103,7 @@ cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry) {
|
|||
cJSON_AddStringToObject(pRoot, "term", u64buf);
|
||||
snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->index);
|
||||
cJSON_AddStringToObject(pRoot, "index", u64buf);
|
||||
cJSON_AddNumberToObject(pRoot, "entryType", pEntry->entryType);
|
||||
cJSON_AddNumberToObject(pRoot, "dataLen", pEntry->dataLen);
|
||||
|
||||
char* s;
|
||||
|
|
|
@ -34,7 +34,7 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) {
|
|||
pLogStore->getLastTerm = logStoreLastTerm;
|
||||
pLogStore->updateCommitIndex = logStoreUpdateCommitIndex;
|
||||
pLogStore->getCommitIndex = logStoreGetCommitIndex;
|
||||
return pLogStore; // to avoid compiler error
|
||||
return pLogStore;
|
||||
}
|
||||
|
||||
void logStoreDestory(SSyncLogStore* pLogStore) {
|
||||
|
@ -48,18 +48,22 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) {
|
|||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
|
||||
assert(pEntry->index == logStoreLastIndex(pLogStore) + 1);
|
||||
SyncIndex lastIndex = logStoreLastIndex(pLogStore);
|
||||
assert(pEntry->index == lastIndex + 1);
|
||||
uint32_t len;
|
||||
char* serialized = syncEntrySerialize(pEntry, &len);
|
||||
assert(serialized != NULL);
|
||||
|
||||
int code;
|
||||
code = walWrite(pWal, pEntry->index, pEntry->msgType, serialized, len);
|
||||
assert(code == 0);
|
||||
int code = 0;
|
||||
/*
|
||||
code = walWrite(pWal, pEntry->index, pEntry->entryType, serialized, len);
|
||||
assert(code == 0);
|
||||
*/
|
||||
assert(walWrite(pWal, pEntry->index, pEntry->entryType, serialized, len) == 0);
|
||||
|
||||
walFsync(pWal, true);
|
||||
free(serialized);
|
||||
return code; // to avoid compiler error
|
||||
return code;
|
||||
}
|
||||
|
||||
SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
|
||||
|
@ -69,7 +73,7 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
|
|||
|
||||
if (index >= SYNC_INDEX_BEGIN && index <= logStoreLastIndex(pLogStore)) {
|
||||
SWalReadHandle* pWalHandle = walOpenReadHandle(pWal);
|
||||
walReadWithHandle(pWalHandle, index);
|
||||
assert(walReadWithHandle(pWalHandle, index) == 0);
|
||||
pEntry = syncEntryDeserialize(pWalHandle->pHead->head.body, pWalHandle->pHead->head.len);
|
||||
assert(pEntry != NULL);
|
||||
|
||||
|
@ -83,7 +87,7 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
|
|||
int32_t logStoreTruncate(SSyncLogStore* pLogStore, SyncIndex fromIndex) {
|
||||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
walRollback(pWal, fromIndex);
|
||||
assert(walRollback(pWal, fromIndex) == 0);
|
||||
return 0; // to avoid compiler error
|
||||
}
|
||||
|
||||
|
@ -107,7 +111,7 @@ SyncTerm logStoreLastTerm(SSyncLogStore* pLogStore) {
|
|||
int32_t logStoreUpdateCommitIndex(SSyncLogStore* pLogStore, SyncIndex index) {
|
||||
SSyncLogStoreData* pData = pLogStore->data;
|
||||
SWal* pWal = pData->pWal;
|
||||
walCommit(pWal, index);
|
||||
assert(walCommit(pWal, index) == 0);
|
||||
return 0; // to avoid compiler error
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ add_executable(syncEncodeTest "")
|
|||
add_executable(syncWriteTest "")
|
||||
add_executable(syncReplicateTest "")
|
||||
add_executable(syncReplicateTest2 "")
|
||||
add_executable(syncReplicateTest3 "")
|
||||
add_executable(syncReplicateLoadTest "")
|
||||
add_executable(syncRefTest "")
|
||||
add_executable(syncLogStoreCheck "")
|
||||
|
@ -183,6 +184,10 @@ target_sources(syncReplicateTest2
|
|||
PRIVATE
|
||||
"syncReplicateTest2.cpp"
|
||||
)
|
||||
target_sources(syncReplicateTest3
|
||||
PRIVATE
|
||||
"syncReplicateTest3.cpp"
|
||||
)
|
||||
target_sources(syncReplicateLoadTest
|
||||
PRIVATE
|
||||
"syncReplicateLoadTest.cpp"
|
||||
|
@ -377,6 +382,11 @@ target_include_directories(syncReplicateTest2
|
|||
"${CMAKE_SOURCE_DIR}/include/libs/sync"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||
)
|
||||
target_include_directories(syncReplicateTest3
|
||||
PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/include/libs/sync"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||
)
|
||||
target_include_directories(syncReplicateLoadTest
|
||||
PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/include/libs/sync"
|
||||
|
@ -538,6 +548,10 @@ target_link_libraries(syncReplicateTest2
|
|||
sync
|
||||
gtest_main
|
||||
)
|
||||
target_link_libraries(syncReplicateTest3
|
||||
sync
|
||||
gtest_main
|
||||
)
|
||||
target_link_libraries(syncReplicateLoadTest
|
||||
sync
|
||||
gtest_main
|
||||
|
|
|
@ -46,6 +46,20 @@ void test2() {
|
|||
}
|
||||
|
||||
void test3() {
|
||||
SyncClientRequest* pSyncMsg = syncClientRequestBuild(10);
|
||||
pSyncMsg->originalRpcType = 33;
|
||||
pSyncMsg->seqNum = 11;
|
||||
pSyncMsg->isWeak = 1;
|
||||
strcpy(pSyncMsg->data, "test3");
|
||||
|
||||
SSyncRaftEntry* pEntry = syncEntryBuild3(pSyncMsg, 100, 200, SYNC_RAFT_ENTRY_NOOP);
|
||||
syncEntryPrint(pEntry);
|
||||
|
||||
syncClientRequestDestroy(pSyncMsg);
|
||||
syncEntryDestory(pEntry);
|
||||
}
|
||||
|
||||
void test4() {
|
||||
SSyncRaftEntry* pEntry = syncEntryBuild(10);
|
||||
assert(pEntry != NULL);
|
||||
pEntry->msgType = 11;
|
||||
|
@ -54,7 +68,8 @@ void test3() {
|
|||
pEntry->isWeak = true;
|
||||
pEntry->term = 44;
|
||||
pEntry->index = 55;
|
||||
strcpy(pEntry->data, "test3");
|
||||
pEntry->entryType = SYNC_RAFT_ENTRY_CONFIG;
|
||||
strcpy(pEntry->data, "test4");
|
||||
syncEntryPrint(pEntry);
|
||||
|
||||
uint32_t len;
|
||||
|
@ -76,6 +91,7 @@ int main(int argc, char** argv) {
|
|||
test1();
|
||||
test2();
|
||||
test3();
|
||||
test4();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -178,9 +178,10 @@ int main(int argc, char **argv) {
|
|||
while (1) {
|
||||
sTrace(
|
||||
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
|
||||
"electTimerMS:%d",
|
||||
"electTimerMS:%d, commitIndex:%ld",
|
||||
pSyncNode->state, syncUtilState2String(pSyncNode->state), pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS);
|
||||
pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS,
|
||||
pSyncNode->commitIndex);
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
||||
|
|
|
@ -183,18 +183,20 @@ int main(int argc, char **argv) {
|
|||
|
||||
taosMsleep(1000);
|
||||
sTrace(
|
||||
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
|
||||
"electTimerMS:%d",
|
||||
"syncPropose sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
|
||||
"electTimerMS:%d, commitIndex:%ld",
|
||||
gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->pRaftStore->currentTerm,
|
||||
gSyncNode->electTimerLogicClock, gSyncNode->electTimerLogicClockUser, gSyncNode->electTimerMS);
|
||||
gSyncNode->electTimerLogicClock, gSyncNode->electTimerLogicClockUser, gSyncNode->electTimerMS,
|
||||
gSyncNode->commitIndex);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
sTrace(
|
||||
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
|
||||
"electTimerMS:%d",
|
||||
"electTimerMS:%d, commitIndex:%ld",
|
||||
gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->pRaftStore->currentTerm,
|
||||
gSyncNode->electTimerLogicClock, gSyncNode->electTimerLogicClockUser, gSyncNode->electTimerMS);
|
||||
gSyncNode->electTimerLogicClock, gSyncNode->electTimerLogicClockUser, gSyncNode->electTimerMS,
|
||||
gSyncNode->commitIndex);
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
||||
|
|
|
@ -185,17 +185,19 @@ int main(int argc, char **argv) {
|
|||
|
||||
sTrace(
|
||||
"syncPropose sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
|
||||
"electTimerMS:%d",
|
||||
"electTimerMS:%d, commitIndex:%ld",
|
||||
pSyncNode->state, syncUtilState2String(pSyncNode->state), pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS);
|
||||
pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS,
|
||||
pSyncNode->commitIndex);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
sTrace(
|
||||
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
|
||||
"electTimerMS:%d",
|
||||
"electTimerMS:%d, commitIndex:%ld",
|
||||
pSyncNode->state, syncUtilState2String(pSyncNode->state), pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS);
|
||||
pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS,
|
||||
pSyncNode->commitIndex);
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,217 @@
|
|||
#define ALLOW_FORBID_FUNC
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <stdio.h>
|
||||
#include "syncEnv.h"
|
||||
#include "syncIO.h"
|
||||
#include "syncInt.h"
|
||||
#include "syncMessage.h"
|
||||
#include "syncRaftEntry.h"
|
||||
#include "syncRaftLog.h"
|
||||
#include "syncRaftStore.h"
|
||||
#include "syncUtil.h"
|
||||
|
||||
void logTest() {
|
||||
sTrace("--- sync log test: trace");
|
||||
sDebug("--- sync log test: debug");
|
||||
sInfo("--- sync log test: info");
|
||||
sWarn("--- sync log test: warn");
|
||||
sError("--- sync log test: error");
|
||||
sFatal("--- sync log test: fatal");
|
||||
}
|
||||
|
||||
uint16_t ports[] = {7010, 7110, 7210, 7310, 7410};
|
||||
int32_t replicaNum = 3;
|
||||
int32_t myIndex = 0;
|
||||
|
||||
SRaftId ids[TSDB_MAX_REPLICA];
|
||||
SSyncInfo syncInfo;
|
||||
SSyncFSM *pFsm;
|
||||
SWal * pWal;
|
||||
|
||||
void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SyncIndex index, bool isWeak, int32_t code,
|
||||
ESyncState state) {
|
||||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf), "==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s \n",
|
||||
pFsm, index, isWeak, code, state, syncUtilState2String(state));
|
||||
syncRpcMsgPrint2(logBuf, (SRpcMsg *)pMsg);
|
||||
}
|
||||
|
||||
void PreCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SyncIndex index, bool isWeak, int32_t code,
|
||||
ESyncState state) {
|
||||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf),
|
||||
"==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s \n", pFsm, index, isWeak,
|
||||
code, state, syncUtilState2String(state));
|
||||
syncRpcMsgPrint2(logBuf, (SRpcMsg *)pMsg);
|
||||
}
|
||||
|
||||
void RollBackCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SyncIndex index, bool isWeak, int32_t code,
|
||||
ESyncState state) {
|
||||
char logBuf[256];
|
||||
snprintf(logBuf, sizeof(logBuf), "==callback== ==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s \n",
|
||||
pFsm, index, isWeak, code, state, syncUtilState2String(state));
|
||||
syncRpcMsgPrint2(logBuf, (SRpcMsg *)pMsg);
|
||||
}
|
||||
|
||||
void initFsm() {
|
||||
pFsm = (SSyncFSM *)malloc(sizeof(SSyncFSM));
|
||||
pFsm->FpCommitCb = CommitCb;
|
||||
pFsm->FpPreCommitCb = PreCommitCb;
|
||||
pFsm->FpRollBackCb = RollBackCb;
|
||||
}
|
||||
|
||||
int64_t syncNodeInit() {
|
||||
syncInfo.vgId = 1234;
|
||||
syncInfo.rpcClient = gSyncIO->clientRpc;
|
||||
syncInfo.FpSendMsg = syncIOSendMsg;
|
||||
syncInfo.queue = gSyncIO->pMsgQ;
|
||||
syncInfo.FpEqMsg = syncIOEqMsg;
|
||||
syncInfo.pFsm = pFsm;
|
||||
snprintf(syncInfo.path, sizeof(syncInfo.path), "./replicate2_test_%d", myIndex);
|
||||
|
||||
int code = walInit();
|
||||
assert(code == 0);
|
||||
SWalCfg walCfg;
|
||||
memset(&walCfg, 0, sizeof(SWalCfg));
|
||||
walCfg.vgId = syncInfo.vgId;
|
||||
walCfg.fsyncPeriod = 1000;
|
||||
walCfg.retentionPeriod = 1000;
|
||||
walCfg.rollPeriod = 1000;
|
||||
walCfg.retentionSize = 1000;
|
||||
walCfg.segSize = 1000;
|
||||
walCfg.level = TAOS_WAL_FSYNC;
|
||||
|
||||
char tmpdir[128];
|
||||
snprintf(tmpdir, sizeof(tmpdir), "./replicate2_test_wal_%d", myIndex);
|
||||
pWal = walOpen(tmpdir, &walCfg);
|
||||
assert(pWal != NULL);
|
||||
|
||||
syncInfo.pWal = pWal;
|
||||
|
||||
SSyncCfg *pCfg = &syncInfo.syncCfg;
|
||||
pCfg->myIndex = myIndex;
|
||||
pCfg->replicaNum = replicaNum;
|
||||
|
||||
for (int i = 0; i < replicaNum; ++i) {
|
||||
pCfg->nodeInfo[i].nodePort = ports[i];
|
||||
snprintf(pCfg->nodeInfo[i].nodeFqdn, sizeof(pCfg->nodeInfo[i].nodeFqdn), "%s", "127.0.0.1");
|
||||
// taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn);
|
||||
}
|
||||
|
||||
int64_t rid = syncStart(&syncInfo);
|
||||
assert(rid > 0);
|
||||
|
||||
SSyncNode *pSyncNode = (SSyncNode *)syncNodeAcquire(rid);
|
||||
assert(pSyncNode != NULL);
|
||||
|
||||
// pSyncNode->hbBaseLine = 500;
|
||||
// pSyncNode->electBaseLine = 1500;
|
||||
|
||||
gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing;
|
||||
gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply;
|
||||
gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote;
|
||||
gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply;
|
||||
gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries;
|
||||
gSyncIO->FpOnSyncAppendEntriesReply = pSyncNode->FpOnAppendEntriesReply;
|
||||
gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout;
|
||||
gSyncIO->FpOnSyncClientRequest = pSyncNode->FpOnClientRequest;
|
||||
gSyncIO->pSyncNode = pSyncNode;
|
||||
|
||||
syncNodeRelease(pSyncNode);
|
||||
|
||||
return rid;
|
||||
}
|
||||
|
||||
void initRaftId(SSyncNode *pSyncNode) {
|
||||
for (int i = 0; i < replicaNum; ++i) {
|
||||
ids[i] = pSyncNode->replicasId[i];
|
||||
char *s = syncUtilRaftId2Str(&ids[i]);
|
||||
printf("raftId[%d] : %s\n", i, s);
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
|
||||
SRpcMsg *step0(int i) {
|
||||
SRpcMsg *pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg));
|
||||
memset(pMsg, 0, sizeof(SRpcMsg));
|
||||
pMsg->msgType = 9999;
|
||||
pMsg->contLen = 128;
|
||||
pMsg->pCont = malloc(pMsg->contLen);
|
||||
snprintf((char *)(pMsg->pCont), pMsg->contLen, "value-%u-%d", ports[myIndex], i);
|
||||
return pMsg;
|
||||
}
|
||||
|
||||
SyncClientRequest *step1(const SRpcMsg *pMsg) {
|
||||
SyncClientRequest *pRetMsg = syncClientRequestBuild2(pMsg, 123, true);
|
||||
return pRetMsg;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// taosInitLog((char *)"syncTest.log", 100000, 10);
|
||||
tsAsyncLog = 0;
|
||||
sDebugFlag = 143 + 64;
|
||||
void logTest();
|
||||
|
||||
myIndex = 0;
|
||||
if (argc >= 2) {
|
||||
myIndex = atoi(argv[1]);
|
||||
}
|
||||
|
||||
int recordCount = 100;
|
||||
if (argc >= 3) {
|
||||
recordCount = atoi(argv[2]);
|
||||
}
|
||||
|
||||
int sleepMS = 10;
|
||||
if (argc >= 4) {
|
||||
sleepMS = atoi(argv[3]);
|
||||
}
|
||||
|
||||
int32_t ret = syncIOStart((char *)"127.0.0.1", ports[myIndex]);
|
||||
assert(ret == 0);
|
||||
|
||||
initFsm();
|
||||
|
||||
ret = syncInit();
|
||||
assert(ret == 0);
|
||||
|
||||
int64_t rid = syncNodeInit();
|
||||
assert(rid > 0);
|
||||
|
||||
SSyncNode *pSyncNode = (SSyncNode *)syncNodeAcquire(rid);
|
||||
assert(pSyncNode != NULL);
|
||||
|
||||
syncNodePrint2((char *)"", pSyncNode);
|
||||
initRaftId(pSyncNode);
|
||||
|
||||
for (int i = 0; i < recordCount; ++i) {
|
||||
// step0
|
||||
SRpcMsg *pMsg0 = step0(i);
|
||||
syncRpcMsgPrint2((char *)"==step0==", pMsg0);
|
||||
|
||||
syncPropose(rid, pMsg0, true);
|
||||
taosMsleep(sleepMS);
|
||||
|
||||
free(pMsg0);
|
||||
|
||||
sTrace(
|
||||
"syncPropose sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
|
||||
"electTimerMS:%d, commitIndex:%ld",
|
||||
pSyncNode->state, syncUtilState2String(pSyncNode->state), pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS,
|
||||
pSyncNode->commitIndex);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
sTrace(
|
||||
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
|
||||
"electTimerMS:%d, commitIndex:%ld",
|
||||
pSyncNode->state, syncUtilState2String(pSyncNode->state), pSyncNode->pRaftStore->currentTerm,
|
||||
pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser, pSyncNode->electTimerMS,
|
||||
pSyncNode->commitIndex);
|
||||
taosMsleep(1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
# ---- query
|
||||
./test.sh -f tsim/query/interval.sim
|
||||
#./test.sh -f tsim/query/interval-offset.sim
|
||||
./test.sh -f tsim/query/interval-offset.sim
|
||||
|
||||
# ---- show
|
||||
./test.sh -f tsim/show/basic.sim
|
||||
|
|
|
@ -37,9 +37,9 @@ while $dbCnt < 2
|
|||
|
||||
print =============== create super table, include all type
|
||||
print notes: after nchar show ok, modify binary to nchar
|
||||
sql create table `stable` (`timestamp` timestamp, `int` int, `binary` binary(16), `nchar` binary(16)) tags (`float` float, `Binary` binary(16), `Nchar` nchar(16))
|
||||
sql create table `Stable` (`timestamp` timestamp, `int` int, `Binary` binary(32), `Nchar` binary(32)) tags (`float` float, `binary` binary(16), `nchar` nchar(16))
|
||||
|
||||
sql create table `stable` (`timestamp` timestamp, `int` int, `binary` binary(16), `nchar` nchar(16)) tags (`float` float, `Binary` binary(16), `Nchar` nchar(16))
|
||||
sql create table `Stable` (`timestamp` timestamp, `int` int, `Binary` binary(32), `Nchar` nchar(32)) tags (`float` float, `binary` binary(16), `nchar` nchar(16))
|
||||
|
||||
sql show stables
|
||||
print rows: $rows
|
||||
print $data00 $data01
|
||||
|
@ -48,12 +48,12 @@ while $dbCnt < 2
|
|||
return -1
|
||||
endi
|
||||
if $data00 != Stable then
|
||||
if $data00 != stable then
|
||||
if $data00 != stable then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data10 != Stable then
|
||||
if $data10 != stable then
|
||||
if $data10 != Stable then
|
||||
if $data10 != stable then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
|
@ -80,7 +80,7 @@ while $dbCnt < 2
|
|||
sql insert into `Table` values(now+0s, 20, 'Table', 'Table')(now+1s, 21, 'Table', 'Table')
|
||||
sql insert into `TAble` values(now+0s, 30, 'TAble', 'TAble')(now+1s, 31, 'TAble', 'TAble')
|
||||
sql insert into `TABle` values(now+0s, 40, 'TABle', 'TABle')(now+4s, 41, 'TABle', 'TABle')
|
||||
|
||||
|
||||
print =============== query data
|
||||
sql select * from `table`
|
||||
print rows: $rows
|
||||
|
@ -95,7 +95,8 @@ while $dbCnt < 2
|
|||
if $data02 != table then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != table then
|
||||
if $data03 != table then
|
||||
print expect table, actual $data03
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -152,23 +153,23 @@ while $dbCnt < 2
|
|||
|
||||
#print =============== query data from st, but not support select * from super table, waiting fix
|
||||
#sql select count(*) from `stable`
|
||||
#print rows: $rows
|
||||
#print rows: $rows
|
||||
#print $data00 $data01 $data02 $data03
|
||||
#if $rows != 1 then
|
||||
#if $rows != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data00 != 4 then
|
||||
#endi
|
||||
#if $data00 != 4 then
|
||||
# return -1
|
||||
#endi
|
||||
#endi
|
||||
#sql select count(*) from `Stable`
|
||||
#print rows: $rows
|
||||
#print rows: $rows
|
||||
#print $data00 $data01 $data02 $data03
|
||||
#if $rows != 1 then
|
||||
#if $rows != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data00 != 4 then
|
||||
#endi
|
||||
#if $data00 != 4 then
|
||||
# return -1
|
||||
#endi
|
||||
#endi
|
||||
#sql select * from `stable`
|
||||
#if $rows != 4 then
|
||||
# return -1
|
||||
|
@ -233,12 +234,12 @@ while $dbCnt < 2
|
|||
return -1
|
||||
endi
|
||||
if $data00 != Stable then
|
||||
if $data00 != stable then
|
||||
if $data00 != stable then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data10 != Stable then
|
||||
if $data10 != stable then
|
||||
if $data10 != Stable then
|
||||
if $data10 != stable then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
|
@ -324,23 +325,23 @@ while $dbCnt < 2
|
|||
|
||||
#print =============== query data from st, but not support select * from super table, waiting fix
|
||||
#sql select count(*) from `stable`
|
||||
#print rows: $rows
|
||||
#print rows: $rows
|
||||
#print $data00 $data01 $data02 $data03
|
||||
#if $rows != 1 then
|
||||
#if $rows != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data00 != 4 then
|
||||
#endi
|
||||
#if $data00 != 4 then
|
||||
# return -1
|
||||
#endi
|
||||
#endi
|
||||
#sql select count(*) from `Stable`
|
||||
#print rows: $rows
|
||||
#print rows: $rows
|
||||
#print $data00 $data01 $data02 $data03
|
||||
#if $rows != 1 then
|
||||
#if $rows != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data00 != 4 then
|
||||
#endi
|
||||
#if $data00 != 4 then
|
||||
# return -1
|
||||
#endi
|
||||
#endi
|
||||
#sql select * from `stable`
|
||||
#if $rows != 4 then
|
||||
# return -1
|
||||
|
|
|
@ -109,7 +109,26 @@ endi
|
|||
|
||||
#print =============== select first(*)/first(column) from child table
|
||||
#sql select first(*) from ct1
|
||||
#sql select first(ts), first(c1), first(c2), first(c3) from ct1
|
||||
#print ====> select first(*) from ct1
|
||||
#print rows: $rows
|
||||
#print $data00 $data01 $data02 $data03
|
||||
|
||||
sql select first(ts), first(c1), first(c2), first(c3) from ct1
|
||||
print ====> select first(ts), first(c1), first(c2), first(c3) from ct1
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 10 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 2.00000 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 3.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== select min(column) from child table
|
||||
sql select min(c1), min(c2), min(c3) from ct1
|
||||
|
@ -216,10 +235,42 @@ endi
|
|||
# return -1
|
||||
#endi
|
||||
|
||||
print =============== select count(column) from supter table
|
||||
sql select ts, c1, c2, c3 from stb
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03
|
||||
print $data10 $data11 $data12 $data13
|
||||
print $data20 $data21 $data22 $data23
|
||||
print $data30 $data31 $data32 $data33
|
||||
print $data40 $data41 $data42 $data43
|
||||
print $data50 $data51 $data52 $data53
|
||||
print $data60 $data61 $data62 $data63
|
||||
print $data70 $data71 $data72 $data73
|
||||
print $data80 $data81 $data82 $data83
|
||||
if $rows != 9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
# The order of data from different sub tables in the super table is random,
|
||||
# so this detection may fail randomly
|
||||
if $data01 != 10 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 2.00000 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 3.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#print =============== select count(column) from supter table
|
||||
#sql select count(ts), count(c1), count(c2), count(c3) from stb
|
||||
#print rows: $rows
|
||||
#print $data00 $data01 $data02 $data03
|
||||
#if $data00 != 8 then
|
||||
#print $data10 $data11 $data12 $data13
|
||||
#print $data20 $data21 $data22 $data23
|
||||
#print $data30 $data31 $data32 $data33
|
||||
#if $data00 != 9 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data01 != 8 then
|
||||
|
@ -232,7 +283,6 @@ endi
|
|||
# return -1
|
||||
#endi
|
||||
|
||||
|
||||
#===================================================================
|
||||
#===================================================================
|
||||
|
||||
|
@ -317,7 +367,26 @@ endi
|
|||
|
||||
#print =============== select first(*)/first(column) from child table
|
||||
#sql select first(*) from ct1
|
||||
#sql select first(ts), first(c1), first(c2), first(c3) from ct1
|
||||
#print ====> select first(*) from ct1
|
||||
#print rows: $rows
|
||||
#print $data00 $data01 $data02 $data03
|
||||
|
||||
sql select first(ts), first(c1), first(c2), first(c3) from ct1
|
||||
print ====> select first(ts), first(c1), first(c2), first(c3) from ct1
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 10 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 2.00000 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 3.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== select min(column) from child table
|
||||
sql select min(c1), min(c2), min(c3) from ct1
|
||||
|
@ -424,6 +493,33 @@ endi
|
|||
# return -1
|
||||
#endi
|
||||
|
||||
print =============== select count(column) from supter table
|
||||
sql select ts, c1, c2, c3 from stb
|
||||
print rows: $rows
|
||||
print $data00 $data01 $data02 $data03
|
||||
print $data10 $data11 $data12 $data13
|
||||
print $data20 $data21 $data22 $data23
|
||||
print $data30 $data31 $data32 $data33
|
||||
print $data40 $data41 $data42 $data43
|
||||
print $data50 $data51 $data52 $data53
|
||||
print $data60 $data61 $data62 $data63
|
||||
print $data70 $data71 $data72 $data73
|
||||
print $data80 $data81 $data82 $data83
|
||||
if $rows != 9 then
|
||||
return -1
|
||||
endi
|
||||
# The order of data from different sub tables in the super table is random,
|
||||
# so this detection may fail randomly
|
||||
if $data01 != 10 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 2.00000 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 3.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#print =============== select count(column) from supter table
|
||||
#sql select count(ts), count(c1), count(c2), count(c3) from stb
|
||||
#print $data00 $data01 $data02 $data03
|
||||
|
|
|
@ -5,11 +5,9 @@ sleep 500
|
|||
sql connect
|
||||
|
||||
print =============== create database
|
||||
sql drop database d0 -x step1
|
||||
step1:
|
||||
sql create database d0
|
||||
sql show databases
|
||||
if $rows != 2 then
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -25,9 +23,11 @@ endi
|
|||
|
||||
sql create table ct1 using stb tags ( 1 )
|
||||
sql create table ct2 using stb tags ( 2 )
|
||||
sql create table ct3 using stb tags ( 3 )
|
||||
sql create table ct4 using stb tags ( 4 )
|
||||
sql show tables
|
||||
print $rows $data00 $data10 $data20
|
||||
if $rows != 2 then
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -88,13 +88,17 @@ print ===> rows4: $data40 $data41 $data42 $data43 $data44
|
|||
print ===> rows5: $data50 $data51 $data52 $data53 $data54
|
||||
print ===> rows6: $data60 $data61 $data62 $data63 $data64
|
||||
print ===> rows7: $data70 $data71 $data72 $data73 $data74
|
||||
if $rows != 8 then
|
||||
print ===> rows8: $data80 $data81 $data82 $data83 $data84
|
||||
if $rows != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != 2 then
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data70 != 1 then
|
||||
if $data70 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data80 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -128,6 +132,92 @@ endi
|
|||
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h) sliding(12h)
|
||||
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h) sliding(12h)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04 $data05
|
||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14 $data15
|
||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24 $data25
|
||||
print ===> rows3: $data30 $data31 $data32 $data33 $data34 $data35
|
||||
print ===> rows4: $data40 $data41 $data42 $data43 $data44 $data45
|
||||
print ===> rows5: $data50 $data51 $data52 $data53 $data54 $data55
|
||||
print ===> rows6: $data60 $data61 $data62 $data63 $data64 $data65
|
||||
print ===> rows7: $data70 $data71 $data72 $data73 $data74 $data75
|
||||
#if $rows != 8 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data00 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data10 != 2 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data20 != 2 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data30 != 2 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data40 != 2 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data50 != 2 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data60 != 2 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data70 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
print =============== insert data into child table ct3 (n)
|
||||
sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL );
|
||||
sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1 );
|
||||
sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2 );
|
||||
sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3 );
|
||||
sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4 );
|
||||
sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5 );
|
||||
sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6 );
|
||||
sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7 );
|
||||
sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8 );
|
||||
|
||||
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w)
|
||||
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
||||
print ===> rows3: $data30 $data31 $data32 $data33 $data34
|
||||
print ===> rows4: $data40 $data41 $data42 $data43 $data44
|
||||
#if $rows != 5 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data00 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data40 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(2w)
|
||||
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(2w)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
||||
print ===> rows3: $data30 $data31 $data32 $data33 $data34
|
||||
print ===> rows4: $data40 $data41 $data42 $data43 $data44
|
||||
#if $rows != 5 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data00 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data40 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(4w)
|
||||
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(4w)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
||||
|
@ -136,230 +226,99 @@ print ===> rows4: $data40 $data41 $data42 $data43 $data44
|
|||
print ===> rows5: $data50 $data51 $data52 $data53 $data54
|
||||
print ===> rows6: $data60 $data61 $data62 $data63 $data64
|
||||
print ===> rows7: $data70 $data71 $data72 $data73 $data74
|
||||
if $rows != 7 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data60 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sql select count(*) from car interval(1n, 10d) order by ts desc
|
||||
# tdSql.checkData(0, 1, 1)
|
||||
# tdSql.checkData(1, 1, 2)
|
||||
# tdSql.checkData(2, 1, 3)
|
||||
# tdSql.checkData(3, 1, 3)
|
||||
# tdSql.checkData(4, 1, 6)
|
||||
# tdSql.checkData(5, 1, 1)
|
||||
# tdSql.checkData(6, 1, 1)
|
||||
#
|
||||
sql select count(*) from car interval(2n, 5d)
|
||||
# tdSql.checkData(0, 1, 1)
|
||||
# tdSql.checkData(1, 1, 1)
|
||||
# tdSql.checkData(2, 1, 6)
|
||||
# tdSql.checkData(3, 1, 6)
|
||||
# tdSql.checkData(4, 1, 3)
|
||||
|
||||
sql select count(*) from car interval(2n) order by ts desc
|
||||
# tdSql.checkData(0, 1, 3)
|
||||
# tdSql.checkData(1, 1, 6)
|
||||
# tdSql.checkData(2, 1, 6)
|
||||
# tdSql.checkData(3, 1, 1)
|
||||
# tdSql.checkData(4, 1, 1)
|
||||
#
|
||||
sql select count(*) from car interval(1y, 1n)
|
||||
# tdSql.checkData(0, 1, 1)
|
||||
# tdSql.checkData(1, 1, 8)
|
||||
# tdSql.checkData(2, 1, 8)
|
||||
#
|
||||
sql select count(*) from car interval(1y, 2n)
|
||||
# tdSql.checkData(0, 1, 1)
|
||||
# tdSql.checkData(1, 1, 11)
|
||||
# tdSql.checkData(2, 1, 5)
|
||||
|
||||
sql select count(*) from car where ts > '2019-05-14 00:00:00' interval(1y, 5d)
|
||||
# tdSql.checkData(0, 1, 6)
|
||||
# tdSql.checkData(1, 1, 9)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int)
|
||||
|
||||
print ====== start create child tables and insert data
|
||||
$i = 0
|
||||
while $i < $tbNum
|
||||
$tb = $tbPrefix . $i
|
||||
sql create table $tb using $mt tags( $i )
|
||||
|
||||
$x = 0
|
||||
while $x < $rowNum
|
||||
$cc = $x * 60000
|
||||
$ms = 1601481600000 + $cc
|
||||
|
||||
sql insert into $tb values ($ms , $x )
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
$i = $i + 1
|
||||
endw
|
||||
|
||||
print =============== step2
|
||||
$i = 1
|
||||
$tb = $tbPrefix . $i
|
||||
|
||||
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m)
|
||||
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m)
|
||||
print ===> $rows $data01 $data05
|
||||
if $rows != $rowNum then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#print =============== step3
|
||||
#$cc = 4 * 60000
|
||||
#$ms = 1601481600000 + $cc
|
||||
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m)
|
||||
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m)
|
||||
#print ===> $rows $data01 $data05
|
||||
#if $rows != 5 then
|
||||
#if $rows != 8 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data00 != 1 then
|
||||
#endi
|
||||
#if $data00 != 2 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data04 != 1 then
|
||||
#endi
|
||||
#if $data70 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#endi
|
||||
|
||||
#print =============== step4
|
||||
#$cc = 40 * 60000
|
||||
#$ms = 1601481600000 + $cc
|
||||
|
||||
#$cc = 1 * 60000
|
||||
#$ms2 = 1601481600000 - $cc
|
||||
print =============== insert data into child table ct4 (y)
|
||||
sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1 )
|
||||
sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2 )
|
||||
sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3 )
|
||||
sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4 )
|
||||
sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5 )
|
||||
sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6 )
|
||||
sql insert into ct4 values ( '2022-10-28 01:01:26.000', 7 )
|
||||
sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8 )
|
||||
sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9 )
|
||||
|
||||
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m)
|
||||
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m)
|
||||
#print ===> $rows $data01 $data05
|
||||
#if $rows != 20 then
|
||||
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n)
|
||||
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
||||
print ===> rows3: $data30 $data31 $data32 $data33 $data34
|
||||
print ===> rows4: $data40 $data41 $data42 $data43 $data44
|
||||
#if $rows != 5 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data00 != 1 then
|
||||
#endi
|
||||
#if $data00 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data04 != 1 then
|
||||
#endi
|
||||
#if $data40 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#endi
|
||||
|
||||
#print =============== step5
|
||||
#$cc = 40 * 60000
|
||||
#$ms = 1601481600000 + $cc
|
||||
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n)
|
||||
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
||||
print ===> rows3: $data30 $data31 $data32 $data33 $data34
|
||||
print ===> rows4: $data40 $data41 $data42 $data43 $data44
|
||||
#if $rows != 5 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data00 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data40 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(12n)
|
||||
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(12n)
|
||||
print ===> rows: $rows
|
||||
print ===> rows0: $data00 $data01 $data02 $data03 $data04
|
||||
print ===> rows1: $data10 $data11 $data12 $data13 $data14
|
||||
print ===> rows2: $data20 $data21 $data22 $data23 $data24
|
||||
print ===> rows3: $data30 $data31 $data32 $data33 $data34
|
||||
print ===> rows4: $data40 $data41 $data42 $data43 $data44
|
||||
print ===> rows5: $data50 $data51 $data52 $data53 $data54
|
||||
print ===> rows6: $data60 $data61 $data62 $data63 $data64
|
||||
print ===> rows7: $data70 $data71 $data72 $data73 $data74
|
||||
#if $rows != 8 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data00 != 2 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data70 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
|
||||
|
||||
|
||||
#sql select count(*) from car interval(1n, 10d) order by ts desc
|
||||
#sql select count(*) from car interval(2n, 5d)
|
||||
#sql select count(*) from car interval(2n) order by ts desc
|
||||
#sql select count(*) from car interval(1y, 1n)
|
||||
#sql select count(*) from car interval(1y, 2n)
|
||||
#sql select count(*) from car where ts > '2019-05-14 00:00:00' interval(1y, 5d)
|
||||
|
||||
#$cc = 1 * 60000
|
||||
#$ms2 = 1601481600000 - $cc
|
||||
|
||||
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0)
|
||||
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0)
|
||||
#print ===> $rows $data21 $data25
|
||||
#if $rows != 42 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data20 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data24 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
#print =============== step6
|
||||
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m)
|
||||
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m)
|
||||
#print ===> $rows $data11
|
||||
#if $rows != 20 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data11 != 10 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
#print =============== step7
|
||||
#$cc = 4 * 60000
|
||||
#$ms = 1601481600000 + $cc
|
||||
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m)
|
||||
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m)
|
||||
#print ===> $rows $data11
|
||||
#if $rows != 5 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data11 != 10 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
#print =============== step8
|
||||
#$cc = 40 * 60000
|
||||
#$ms1 = 1601481600000 + $cc
|
||||
#
|
||||
#$cc = 1 * 60000
|
||||
#$ms2 = 1601481600000 - $cc
|
||||
#
|
||||
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m)
|
||||
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m)
|
||||
#print ===> $rows $data11
|
||||
#if $rows != 20 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data11 != 10 then
|
||||
# return -1
|
||||
#endi
|
||||
#
|
||||
#print =============== step9
|
||||
#$cc = 40 * 60000
|
||||
#$ms1 = 1601481600000 + $cc
|
||||
#
|
||||
#$cc = 1 * 60000
|
||||
#$ms2 = 1601481600000 - $cc
|
||||
#
|
||||
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0)
|
||||
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0)
|
||||
#print ===> $rows $data11
|
||||
#if $rows != 42 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data11 != 10 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
print =============== clear
|
||||
#sql drop database $db
|
||||
#sql show databases
|
||||
#if $rows != 0 then
|
||||
# return -1
|
||||
#endi
|
||||
|
||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -231,6 +231,10 @@ endi
|
|||
|
||||
print =============== query data
|
||||
sql select * from c1
|
||||
print rows: $rows
|
||||
print $data00 $data01
|
||||
print $data10 $data11
|
||||
print $data20 $data21
|
||||
if $rows != 3 then
|
||||
print $rows
|
||||
return -1
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "os.h"
|
||||
#include "shell.h"
|
||||
#include "tglobal.h"
|
||||
#include "tconfig.h"
|
||||
#include "shellCommand.h"
|
||||
#include "tbase64.h"
|
||||
#include "tlog.h"
|
||||
|
@ -619,20 +620,17 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
shellParseArgument(argc, argv, &args);
|
||||
|
||||
#if 0
|
||||
if (args.dump_config) {
|
||||
taosInitGlobalCfg();
|
||||
taosReadGlobalLogCfg();
|
||||
taosInitCfg(configDir, NULL, NULL, NULL, 1);
|
||||
|
||||
if (taosReadGlobalCfg() ! =0) {
|
||||
printf("TDengine read global config failed");
|
||||
SConfig *pCfg = taosGetCfg();
|
||||
if (NULL == pCfg) {
|
||||
printf("TDengine read global config failed!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
taosDumpGlobalCfg();
|
||||
cfgDumpCfg(pCfg, 0, 1);
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (args.netTestRole && args.netTestRole[0] != 0) {
|
||||
TAOS *con = NULL;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 8145dd1713ab9e7652ea621ca7e6895fd0b21d65
|
||||
Subproject commit f36b07f710d661dca88fdd70e73b5e3e16a960e0
|
Loading…
Reference in New Issue