Merge branch '3.0' of github.com:taosdata/TDengine into test/chr/TD-14699
This commit is contained in:
commit
2219575177
|
|
@ -44,7 +44,6 @@ ENDIF ()
|
||||||
|
|
||||||
IF (TD_WINDOWS)
|
IF (TD_WINDOWS)
|
||||||
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
|
||||||
SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE)
|
|
||||||
SET(COMMON_FLAGS "/W3 /D_WIN32")
|
SET(COMMON_FLAGS "/W3 /D_WIN32")
|
||||||
|
|
||||||
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
# IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ static void msg_process(TAOS_RES* msg) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
memset(buf, 0, 1024);
|
memset(buf, 0, 1024);
|
||||||
printf("topic: %s\n", tmq_get_topic_name(msg));
|
printf("topic: %s\n", tmq_get_topic_name(msg));
|
||||||
printf("vg:%d\n", tmq_get_vgroup_id(msg));
|
printf("vg: %d\n", tmq_get_vgroup_id(msg));
|
||||||
while (1) {
|
while (1) {
|
||||||
TAOS_ROW row = taos_fetch_row(msg);
|
TAOS_ROW row = taos_fetch_row(msg);
|
||||||
if (row == NULL) break;
|
if (row == NULL) break;
|
||||||
|
|
@ -140,8 +140,8 @@ int32_t create_topic() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmq_commit_cb_print(tmq_t* tmq, tmq_resp_err_t resp, tmq_topic_vgroup_list_t* offsets) {
|
void tmq_commit_cb_print(tmq_t* tmq, tmq_resp_err_t resp, tmq_topic_vgroup_list_t* offsets, void* param) {
|
||||||
printf("commit %d\n", resp);
|
printf("commit %d tmq %p offsets %p param %p\n", resp, tmq, offsets, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmq_t* build_consumer() {
|
tmq_t* build_consumer() {
|
||||||
|
|
@ -161,7 +161,7 @@ tmq_t* build_consumer() {
|
||||||
tmq_conf_set(conf, "td.connect.user", "root");
|
tmq_conf_set(conf, "td.connect.user", "root");
|
||||||
tmq_conf_set(conf, "td.connect.pass", "taosdata");
|
tmq_conf_set(conf, "td.connect.pass", "taosdata");
|
||||||
/*tmq_conf_set(conf, "td.connect.db", "abc1");*/
|
/*tmq_conf_set(conf, "td.connect.db", "abc1");*/
|
||||||
tmq_conf_set_offset_commit_cb(conf, tmq_commit_cb_print);
|
tmq_conf_set_offset_commit_cb(conf, tmq_commit_cb_print, NULL);
|
||||||
tmq_t* tmq = tmq_consumer_new(conf, NULL, 0);
|
tmq_t* tmq = tmq_consumer_new(conf, NULL, 0);
|
||||||
assert(tmq);
|
assert(tmq);
|
||||||
return tmq;
|
return tmq;
|
||||||
|
|
@ -215,12 +215,24 @@ void sync_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tmq_list_t* subList = NULL;
|
||||||
|
tmq_subscription(tmq, &subList);
|
||||||
|
char** subTopics = tmq_list_to_c_array(subList);
|
||||||
|
int32_t sz = tmq_list_get_size(subList);
|
||||||
|
printf("subscribed topics: ");
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
printf("%s, ", subTopics[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
tmq_list_destroy(subList);
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 1000);
|
TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 1000);
|
||||||
if (tmqmessage) {
|
if (tmqmessage) {
|
||||||
msg_process(tmqmessage);
|
msg_process(tmqmessage);
|
||||||
taos_free_result(tmqmessage);
|
taos_free_result(tmqmessage);
|
||||||
|
|
||||||
|
tmq_commit(tmq, NULL, 1);
|
||||||
/*if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0);*/
|
/*if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ typedef struct tmq_topic_vgroup_list_t tmq_topic_vgroup_list_t;
|
||||||
typedef struct tmq_conf_t tmq_conf_t;
|
typedef struct tmq_conf_t tmq_conf_t;
|
||||||
typedef struct tmq_list_t tmq_list_t;
|
typedef struct tmq_list_t tmq_list_t;
|
||||||
|
|
||||||
typedef void(tmq_commit_cb(tmq_t *, tmq_resp_err_t, tmq_topic_vgroup_list_t *));
|
typedef void(tmq_commit_cb(tmq_t *, tmq_resp_err_t, tmq_topic_vgroup_list_t *, void *param));
|
||||||
|
|
||||||
DLL_EXPORT tmq_list_t *tmq_list_new();
|
DLL_EXPORT tmq_list_t *tmq_list_new();
|
||||||
DLL_EXPORT int32_t tmq_list_append(tmq_list_t *, const char *);
|
DLL_EXPORT int32_t tmq_list_append(tmq_list_t *, const char *);
|
||||||
|
|
@ -253,11 +253,11 @@ typedef enum tmq_conf_res_t tmq_conf_res_t;
|
||||||
DLL_EXPORT tmq_conf_t *tmq_conf_new();
|
DLL_EXPORT tmq_conf_t *tmq_conf_new();
|
||||||
DLL_EXPORT tmq_conf_res_t tmq_conf_set(tmq_conf_t *conf, const char *key, const char *value);
|
DLL_EXPORT tmq_conf_res_t tmq_conf_set(tmq_conf_t *conf, const char *key, const char *value);
|
||||||
DLL_EXPORT void tmq_conf_destroy(tmq_conf_t *conf);
|
DLL_EXPORT void tmq_conf_destroy(tmq_conf_t *conf);
|
||||||
DLL_EXPORT void tmq_conf_set_offset_commit_cb(tmq_conf_t *conf, tmq_commit_cb *cb);
|
DLL_EXPORT void tmq_conf_set_offset_commit_cb(tmq_conf_t *conf, tmq_commit_cb *cb, void *param);
|
||||||
|
|
||||||
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
|
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
|
||||||
|
|
||||||
DLL_EXPORT char *tmq_get_topic_name(TAOS_RES *res);
|
DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res);
|
||||||
DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res);
|
DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res);
|
||||||
// TODO
|
// TODO
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ typedef int64_t tb_uid_t;
|
||||||
#define TSWINDOW_INITIALIZER ((STimeWindow){INT64_MIN, INT64_MAX})
|
#define TSWINDOW_INITIALIZER ((STimeWindow){INT64_MIN, INT64_MAX})
|
||||||
#define TSWINDOW_DESC_INITIALIZER ((STimeWindow){INT64_MAX, INT64_MIN})
|
#define TSWINDOW_DESC_INITIALIZER ((STimeWindow){INT64_MAX, INT64_MIN})
|
||||||
#define IS_TSWINDOW_SPECIFIED(win) (((win).skey != INT64_MIN) || ((win).ekey != INT64_MAX))
|
#define IS_TSWINDOW_SPECIFIED(win) (((win).skey != INT64_MIN) || ((win).ekey != INT64_MAX))
|
||||||
|
#define TSWINDOW_IS_EQUAL(t1, t2) (((t1).skey == (t2).skey) && ((t1).ekey == (t2).ekey))
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_SUPER_TABLE = 1, // super table
|
TSDB_SUPER_TABLE = 1, // super table
|
||||||
|
|
@ -71,13 +72,19 @@ typedef enum {
|
||||||
TSDB_SMA_STAT_DROPPED = 2, // sma dropped
|
TSDB_SMA_STAT_DROPPED = 2, // sma dropped
|
||||||
} ETsdbSmaStat; // bit operation
|
} ETsdbSmaStat; // bit operation
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_SMA_TYPE_BLOCK = 0, // Block-wise SMA
|
TSDB_SMA_TYPE_BLOCK = 0, // Block-wise SMA
|
||||||
TSDB_SMA_TYPE_TIME_RANGE = 1, // Time-range-wise SMA
|
TSDB_SMA_TYPE_TIME_RANGE = 1, // Time-range-wise SMA
|
||||||
TSDB_SMA_TYPE_ROLLUP = 2, // Rollup SMA
|
TSDB_SMA_TYPE_ROLLUP = 2, // Rollup SMA
|
||||||
} ETsdbSmaType;
|
} ETsdbSmaType;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TSDB_RETENTION_L0 = 0,
|
||||||
|
TSDB_RETENTION_L1 = 1,
|
||||||
|
TSDB_RETENTION_L2 = 2,
|
||||||
|
TSDB_RETENTION_MAX = 3
|
||||||
|
} ERetentionLevel;
|
||||||
|
|
||||||
extern char *qtypeStr[];
|
extern char *qtypeStr[];
|
||||||
|
|
||||||
#define TSDB_PORT_HTTP 11
|
#define TSDB_PORT_HTTP 11
|
||||||
|
|
|
||||||
|
|
@ -70,11 +70,11 @@ typedef struct SDataBlockInfo {
|
||||||
uint64_t groupId; // no need to serialize
|
uint64_t groupId; // no need to serialize
|
||||||
int16_t numOfCols;
|
int16_t numOfCols;
|
||||||
int16_t hasVarCol;
|
int16_t hasVarCol;
|
||||||
int16_t capacity;
|
int32_t capacity;
|
||||||
} SDataBlockInfo;
|
} SDataBlockInfo;
|
||||||
|
|
||||||
typedef struct SSDataBlock {
|
typedef struct SSDataBlock {
|
||||||
SColumnDataAgg* pBlockAgg;
|
SColumnDataAgg** pBlockAgg;
|
||||||
SArray* pDataBlock; // SArray<SColumnInfoData>
|
SArray* pDataBlock; // SArray<SColumnInfoData>
|
||||||
SDataBlockInfo info;
|
SDataBlockInfo info;
|
||||||
} SSDataBlock;
|
} SSDataBlock;
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ static FORCE_INLINE void colDataAppendDouble(SColumnInfoData* pColumnInfoData, u
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
||||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, const SColumnInfoData* pSource,
|
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, int32_t* capacity, const SColumnInfoData* pSource,
|
||||||
uint32_t numOfRow2);
|
uint32_t numOfRow2);
|
||||||
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows);
|
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows);
|
||||||
int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock);
|
int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock);
|
||||||
|
|
@ -225,6 +225,9 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData);
|
||||||
|
|
||||||
void blockDebugShowData(const SArray* dataBlocks);
|
void blockDebugShowData(const SArray* dataBlocks);
|
||||||
|
|
||||||
|
int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks, STSchema* pTSchema, int32_t vgId,
|
||||||
|
tb_uid_t uid, tb_uid_t suid);
|
||||||
|
|
||||||
static FORCE_INLINE int32_t blockGetEncodeSize(const SSDataBlock* pBlock) {
|
static FORCE_INLINE int32_t blockGetEncodeSize(const SSDataBlock* pBlock) {
|
||||||
return blockDataGetSerialMetaSize(pBlock) + blockDataGetSize(pBlock);
|
return blockDataGetSerialMetaSize(pBlock) + blockDataGetSize(pBlock);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,19 +64,19 @@ typedef struct {
|
||||||
col_id_t colId; // column ID(start from PRIMARYKEY_TIMESTAMP_COL_ID(1))
|
col_id_t colId; // column ID(start from PRIMARYKEY_TIMESTAMP_COL_ID(1))
|
||||||
int32_t type : 8; // column type
|
int32_t type : 8; // column type
|
||||||
int32_t bytes : 24; // column bytes (0~16M)
|
int32_t bytes : 24; // column bytes (0~16M)
|
||||||
int32_t sma : 8; // block SMA: 0, no SMA, 1, sum/min/max, 2, ...
|
int32_t flags : 8; // flags: 0 no index, 1 SCHEMA_SMA_ON, 2 SCHEMA_IDX_ON
|
||||||
int32_t offset : 24; // point offset in STpRow after the header part.
|
int32_t offset : 24; // point offset in STpRow after the header part.
|
||||||
} STColumn;
|
} STColumn;
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
#define colType(col) ((col)->type)
|
#define colType(col) ((col)->type)
|
||||||
#define colSma(col) ((col)->sma)
|
#define colFlags(col) ((col)->flags)
|
||||||
#define colColId(col) ((col)->colId)
|
#define colColId(col) ((col)->colId)
|
||||||
#define colBytes(col) ((col)->bytes)
|
#define colBytes(col) ((col)->bytes)
|
||||||
#define colOffset(col) ((col)->offset)
|
#define colOffset(col) ((col)->offset)
|
||||||
|
|
||||||
#define colSetType(col, t) (colType(col) = (t))
|
#define colSetType(col, t) (colType(col) = (t))
|
||||||
#define colSetSma(col, s) (colSma(col) = (s))
|
#define colSetFlags(col, f) (colFlags(col) = (f))
|
||||||
#define colSetColId(col, id) (colColId(col) = (id))
|
#define colSetColId(col, id) (colColId(col) = (id))
|
||||||
#define colSetBytes(col, b) (colBytes(col) = (b))
|
#define colSetBytes(col, b) (colBytes(col) = (b))
|
||||||
#define colSetOffset(col, o) (colOffset(col) = (o))
|
#define colSetOffset(col, o) (colOffset(col) = (o))
|
||||||
|
|
@ -146,7 +146,7 @@ typedef struct {
|
||||||
int32_t tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version);
|
int32_t tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version);
|
||||||
void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder);
|
void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder);
|
||||||
void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version);
|
void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version);
|
||||||
int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int8_t sma, col_id_t colId, col_bytes_t bytes);
|
int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int8_t flags, col_id_t colId, col_bytes_t bytes);
|
||||||
STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
|
STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
|
||||||
|
|
||||||
// ----------------- Semantic timestamp key definition
|
// ----------------- Semantic timestamp key definition
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,10 @@ extern char tsCompressor[];
|
||||||
extern int32_t tsDiskCfgNum;
|
extern int32_t tsDiskCfgNum;
|
||||||
extern SDiskCfg tsDiskCfg[];
|
extern SDiskCfg tsDiskCfg[];
|
||||||
|
|
||||||
|
// internal
|
||||||
|
extern int32_t tsTransPullupMs;
|
||||||
|
extern int32_t tsMaRebalanceMs;
|
||||||
|
|
||||||
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
||||||
|
|
||||||
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd, const char *envFile,
|
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd, const char *envFile,
|
||||||
|
|
|
||||||
|
|
@ -181,8 +181,8 @@ typedef struct SField {
|
||||||
} SField;
|
} SField;
|
||||||
|
|
||||||
typedef struct SRetention {
|
typedef struct SRetention {
|
||||||
int32_t freq;
|
int64_t freq;
|
||||||
int32_t keep;
|
int64_t keep;
|
||||||
int8_t freqUnit;
|
int8_t freqUnit;
|
||||||
int8_t keepUnit;
|
int8_t keepUnit;
|
||||||
} SRetention;
|
} SRetention;
|
||||||
|
|
@ -243,18 +243,9 @@ typedef struct {
|
||||||
|
|
||||||
int32_t tInitSubmitMsgIter(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
|
int32_t tInitSubmitMsgIter(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
|
||||||
int32_t tGetSubmitMsgNext(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
|
int32_t tGetSubmitMsgNext(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
|
||||||
int32_t tInitSubmitBlkIter(SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
|
int32_t tInitSubmitBlkIter(SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
|
||||||
STSRow* tGetSubmitBlkNext(SSubmitBlkIter* pIter);
|
STSRow* tGetSubmitBlkNext(SSubmitBlkIter* pIter);
|
||||||
|
|
||||||
// TODO: KEEP one suite of iterator API finally.
|
|
||||||
// 1) use tInitSubmitMsgIterEx firstly as not decrease the merge conflicts
|
|
||||||
// 2) replace tInitSubmitMsgIterEx with tInitSubmitMsgIter later
|
|
||||||
// 3) finally, rename tInitSubmitMsgIterEx to tInitSubmitMsgIter
|
|
||||||
int32_t tInitSubmitMsgIterEx(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
|
|
||||||
int32_t tGetSubmitMsgNextEx(SSubmitMsgIter* pIter, SSubmitBlk** pPBlock);
|
|
||||||
int32_t tInitSubmitBlkIterEx(SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkIter* pIter);
|
|
||||||
STSRow* tGetSubmitBlkNextEx(SSubmitBlkIter* pIter);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t index; // index of failed block in submit blocks
|
int32_t index; // index of failed block in submit blocks
|
||||||
int32_t vnode; // vnode index of failed block
|
int32_t vnode; // vnode index of failed block
|
||||||
|
|
@ -281,8 +272,10 @@ typedef struct SSchema {
|
||||||
char name[TSDB_COL_NAME_LEN];
|
char name[TSDB_COL_NAME_LEN];
|
||||||
} SSchema;
|
} SSchema;
|
||||||
|
|
||||||
|
#define IS_BSMA_ON(s) (((s)->flags & 0x01) == SCHEMA_SMA_ON)
|
||||||
|
|
||||||
#define SSCHMEA_TYPE(s) ((s)->type)
|
#define SSCHMEA_TYPE(s) ((s)->type)
|
||||||
#define SSCHMEA_SMA(s) ((s)->sma)
|
#define SSCHMEA_FLAGS(s) ((s)->flags)
|
||||||
#define SSCHMEA_COLID(s) ((s)->colId)
|
#define SSCHMEA_COLID(s) ((s)->colId)
|
||||||
#define SSCHMEA_BYTES(s) ((s)->bytes)
|
#define SSCHMEA_BYTES(s) ((s)->bytes)
|
||||||
#define SSCHMEA_NAME(s) ((s)->name)
|
#define SSCHMEA_NAME(s) ((s)->name)
|
||||||
|
|
@ -1442,32 +1435,32 @@ typedef struct {
|
||||||
SArray* lostConsumers; // SArray<int64_t>
|
SArray* lostConsumers; // SArray<int64_t>
|
||||||
SArray* removedConsumers; // SArray<int64_t>
|
SArray* removedConsumers; // SArray<int64_t>
|
||||||
SArray* newConsumers; // SArray<int64_t>
|
SArray* newConsumers; // SArray<int64_t>
|
||||||
} SMqRebSubscribe;
|
} SMqRebInfo;
|
||||||
|
|
||||||
static FORCE_INLINE SMqRebSubscribe* tNewSMqRebSubscribe(const char* key) {
|
static FORCE_INLINE SMqRebInfo* tNewSMqRebSubscribe(const char* key) {
|
||||||
SMqRebSubscribe* pRebSub = (SMqRebSubscribe*)taosMemoryCalloc(1, sizeof(SMqRebSubscribe));
|
SMqRebInfo* pRebInfo = (SMqRebInfo*)taosMemoryCalloc(1, sizeof(SMqRebInfo));
|
||||||
if (pRebSub == NULL) {
|
if (pRebInfo == NULL) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
strcpy(pRebSub->key, key);
|
strcpy(pRebInfo->key, key);
|
||||||
pRebSub->lostConsumers = taosArrayInit(0, sizeof(int64_t));
|
pRebInfo->lostConsumers = taosArrayInit(0, sizeof(int64_t));
|
||||||
if (pRebSub->lostConsumers == NULL) {
|
if (pRebInfo->lostConsumers == NULL) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
pRebSub->removedConsumers = taosArrayInit(0, sizeof(int64_t));
|
pRebInfo->removedConsumers = taosArrayInit(0, sizeof(int64_t));
|
||||||
if (pRebSub->removedConsumers == NULL) {
|
if (pRebInfo->removedConsumers == NULL) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
pRebSub->newConsumers = taosArrayInit(0, sizeof(int64_t));
|
pRebInfo->newConsumers = taosArrayInit(0, sizeof(int64_t));
|
||||||
if (pRebSub->newConsumers == NULL) {
|
if (pRebInfo->newConsumers == NULL) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
return pRebSub;
|
return pRebInfo;
|
||||||
_err:
|
_err:
|
||||||
taosArrayDestroy(pRebSub->lostConsumers);
|
taosArrayDestroy(pRebInfo->lostConsumers);
|
||||||
taosArrayDestroy(pRebSub->removedConsumers);
|
taosArrayDestroy(pRebInfo->removedConsumers);
|
||||||
taosArrayDestroy(pRebSub->newConsumers);
|
taosArrayDestroy(pRebInfo->newConsumers);
|
||||||
taosMemoryFreeClear(pRebSub);
|
taosMemoryFreeClear(pRebInfo);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1524,6 +1517,7 @@ typedef struct {
|
||||||
int32_t tEncodeSRSmaParam(SCoder* pCoder, const SRSmaParam* pRSmaParam);
|
int32_t tEncodeSRSmaParam(SCoder* pCoder, const SRSmaParam* pRSmaParam);
|
||||||
int32_t tDecodeSRSmaParam(SCoder* pCoder, SRSmaParam* pRSmaParam);
|
int32_t tDecodeSRSmaParam(SCoder* pCoder, SRSmaParam* pRSmaParam);
|
||||||
|
|
||||||
|
// TDMT_VND_CREATE_STB ==============
|
||||||
typedef struct SVCreateStbReq {
|
typedef struct SVCreateStbReq {
|
||||||
const char* name;
|
const char* name;
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
|
|
@ -1536,17 +1530,14 @@ typedef struct SVCreateStbReq {
|
||||||
int tEncodeSVCreateStbReq(SCoder* pCoder, const SVCreateStbReq* pReq);
|
int tEncodeSVCreateStbReq(SCoder* pCoder, const SVCreateStbReq* pReq);
|
||||||
int tDecodeSVCreateStbReq(SCoder* pCoder, SVCreateStbReq* pReq);
|
int tDecodeSVCreateStbReq(SCoder* pCoder, SVCreateStbReq* pReq);
|
||||||
|
|
||||||
|
// TDMT_VND_DROP_STB ==============
|
||||||
typedef struct SVDropStbReq {
|
typedef struct SVDropStbReq {
|
||||||
// data
|
const char* name;
|
||||||
#ifdef WINDOWS
|
tb_uid_t suid;
|
||||||
size_t avoidCompilationErrors;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} SVDropStbReq;
|
} SVDropStbReq;
|
||||||
|
|
||||||
typedef struct SVCreateStbRsp {
|
int32_t tEncodeSVDropStbReq(SCoder* pCoder, const SVDropStbReq* pReq);
|
||||||
int code;
|
int32_t tDecodeSVDropStbReq(SCoder* pCoder, SVDropStbReq* pReq);
|
||||||
} SVCreateStbRsp;
|
|
||||||
|
|
||||||
typedef struct SVCreateTbReq {
|
typedef struct SVCreateTbReq {
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
|
|
@ -1603,19 +1594,37 @@ int tDecodeSVCreateTbBatchRsp(SCoder* pCoder, SVCreateTbBatchRsp* pRsp);
|
||||||
int32_t tSerializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
|
int32_t tSerializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
|
||||||
int32_t tDeserializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
|
int32_t tDeserializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatchRsp* pRsp);
|
||||||
|
|
||||||
|
// TDMT_VND_DROP_TABLE =================
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t ver;
|
const char* name;
|
||||||
char* name;
|
int8_t igNotExists;
|
||||||
uint8_t type;
|
|
||||||
tb_uid_t suid;
|
|
||||||
} SVDropTbReq;
|
} SVDropTbReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int tmp; // TODO: to avoid compile error
|
int32_t code;
|
||||||
} SVDropTbRsp;
|
} SVDropTbRsp;
|
||||||
|
|
||||||
int32_t tSerializeSVDropTbReq(void** buf, SVDropTbReq* pReq);
|
typedef struct {
|
||||||
void* tDeserializeSVDropTbReq(void* buf, SVDropTbReq* pReq);
|
int32_t nReqs;
|
||||||
|
union {
|
||||||
|
SVDropTbReq* pReqs;
|
||||||
|
SArray* pArray;
|
||||||
|
};
|
||||||
|
} SVDropTbBatchReq;
|
||||||
|
|
||||||
|
int32_t tEncodeSVDropTbBatchReq(SCoder* pCoder, const SVDropTbBatchReq* pReq);
|
||||||
|
int32_t tDecodeSVDropTbBatchReq(SCoder* pCoder, SVDropTbBatchReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t nRsps;
|
||||||
|
union {
|
||||||
|
SVDropTbRsp* pRsps;
|
||||||
|
SArray* pArray;
|
||||||
|
};
|
||||||
|
} SVDropTbBatchRsp;
|
||||||
|
|
||||||
|
int32_t tEncodeSVDropTbBatchRsp(SCoder* pCoder, const SVDropTbBatchRsp* pRsp);
|
||||||
|
int32_t tDecodeSVDropTbBatchRsp(SCoder* pCoder, SVDropTbBatchRsp* pRsp);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMsgHead head;
|
SMsgHead head;
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ typedef int32_t (*GetQueueSizeFp)(SMgmtWrapper* pWrapper, int32_t vgId, EQueueTy
|
||||||
typedef int32_t (*SendReqFp)(SMgmtWrapper* pWrapper, const SEpSet* epSet, SRpcMsg* pReq);
|
typedef int32_t (*SendReqFp)(SMgmtWrapper* pWrapper, const SEpSet* epSet, SRpcMsg* pReq);
|
||||||
typedef int32_t (*SendMnodeReqFp)(SMgmtWrapper* pWrapper, SRpcMsg* pReq);
|
typedef int32_t (*SendMnodeReqFp)(SMgmtWrapper* pWrapper, SRpcMsg* pReq);
|
||||||
typedef void (*SendRspFp)(SMgmtWrapper* pWrapper, const SRpcMsg* pRsp);
|
typedef void (*SendRspFp)(SMgmtWrapper* pWrapper, const SRpcMsg* pRsp);
|
||||||
|
typedef void (*SendRedirectRspFp)(SMgmtWrapper* pWrapper, const SRpcMsg* pRsp, const SEpSet* pNewEpSet);
|
||||||
typedef void (*RegisterBrokenLinkArgFp)(SMgmtWrapper* pWrapper, SRpcMsg* pMsg);
|
typedef void (*RegisterBrokenLinkArgFp)(SMgmtWrapper* pWrapper, SRpcMsg* pMsg);
|
||||||
typedef void (*ReleaseHandleFp)(SMgmtWrapper* pWrapper, void* handle, int8_t type);
|
typedef void (*ReleaseHandleFp)(SMgmtWrapper* pWrapper, void* handle, int8_t type);
|
||||||
typedef void (*ReportStartup)(SMgmtWrapper* pWrapper, const char* name, const char* desc);
|
typedef void (*ReportStartup)(SMgmtWrapper* pWrapper, const char* name, const char* desc);
|
||||||
|
|
@ -52,6 +53,7 @@ typedef struct {
|
||||||
GetQueueSizeFp qsizeFp;
|
GetQueueSizeFp qsizeFp;
|
||||||
SendReqFp sendReqFp;
|
SendReqFp sendReqFp;
|
||||||
SendRspFp sendRspFp;
|
SendRspFp sendRspFp;
|
||||||
|
SendRedirectRspFp sendRedirectRspFp;
|
||||||
RegisterBrokenLinkArgFp registerBrokenLinkArgFp;
|
RegisterBrokenLinkArgFp registerBrokenLinkArgFp;
|
||||||
ReleaseHandleFp releaseHandleFp;
|
ReleaseHandleFp releaseHandleFp;
|
||||||
ReportStartup reportStartupFp;
|
ReportStartup reportStartupFp;
|
||||||
|
|
@ -62,6 +64,7 @@ int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pReq);
|
||||||
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype);
|
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype);
|
||||||
int32_t tmsgSendReq(const SMsgCb* pMsgCb, const SEpSet* epSet, SRpcMsg* pReq);
|
int32_t tmsgSendReq(const SMsgCb* pMsgCb, const SEpSet* epSet, SRpcMsg* pReq);
|
||||||
void tmsgSendRsp(const SRpcMsg* pRsp);
|
void tmsgSendRsp(const SRpcMsg* pRsp);
|
||||||
|
void tmsgSendRedirectRsp(const SRpcMsg* pRsp, const SEpSet* pNewEpSet);
|
||||||
void tmsgRegisterBrokenLinkArg(const SMsgCb* pMsgCb, SRpcMsg* pMsg);
|
void tmsgRegisterBrokenLinkArg(const SMsgCb* pMsgCb, SRpcMsg* pMsg);
|
||||||
void tmsgReleaseHandle(void* handle, int8_t type);
|
void tmsgReleaseHandle(void* handle, int8_t type);
|
||||||
void tmsgReportStartup(const char* name, const char* desc);
|
void tmsgReportStartup(const char* name, const char* desc);
|
||||||
|
|
|
||||||
|
|
@ -170,9 +170,9 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_UPDATE_TAG_VAL, "vnode-update-tag-val", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_UPDATE_TAG_VAL, "vnode-update-tag-val", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_TABLE_META, "vnode-table-meta", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_TABLE_META, "vnode-table-meta", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_TABLES_META, "vnode-tables-meta", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_TABLES_META, "vnode-tables-meta", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_STB, "vnode-create-stb", SVCreateTbReq, SVCreateTbRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_STB, "vnode-create-stb", SVCreateStbReq, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_STB, "vnode-alter-stb", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_STB, "vnode-alter-stb", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_STB, "vnode-drop-stb", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DROP_STB, "vnode-drop-stb", SVDropStbReq, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_MQ_CONSUME, "vnode-mq-consume", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_MQ_CONSUME, "vnode-mq-consume", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_MQ_QUERY, "vnode-mq-query", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_MQ_QUERY, "vnode-mq-query", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_MQ_CONNECT, "vnode-mq-connect", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_MQ_CONNECT, "vnode-mq-connect", NULL, NULL)
|
||||||
|
|
@ -202,6 +202,7 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_SMA, "vnode-create-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_SMA, "vnode-create-sma", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT_RSMA, "vnode-submit-rsma", SSubmitReq, SSubmitRsp)
|
||||||
|
|
||||||
// sync integration
|
// sync integration
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_TIMEOUT, "vnode-sync-timeout", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_SYNC_TIMEOUT, "vnode-sync-timeout", NULL, NULL)
|
||||||
|
|
|
||||||
|
|
@ -107,10 +107,9 @@ typedef enum {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SDB_STATUS_INIT = 0,
|
SDB_STATUS_INIT = 0,
|
||||||
SDB_STATUS_CREATING = 1,
|
SDB_STATUS_CREATING = 1,
|
||||||
SDB_STATUS_UPDATING = 2,
|
SDB_STATUS_DROPPING = 2,
|
||||||
SDB_STATUS_DROPPING = 3,
|
SDB_STATUS_DROPPED = 3,
|
||||||
SDB_STATUS_READY = 4,
|
SDB_STATUS_READY = 4,
|
||||||
SDB_STATUS_DROPPED = 5
|
|
||||||
} ESdbStatus;
|
} ESdbStatus;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,9 @@ typedef enum EFunctionType {
|
||||||
FUNCTION_TYPE_WENDTS,
|
FUNCTION_TYPE_WENDTS,
|
||||||
FUNCTION_TYPE_WDURATION,
|
FUNCTION_TYPE_WDURATION,
|
||||||
|
|
||||||
|
// internal function
|
||||||
|
FUNCTION_TYPE_SELECT_VALUE,
|
||||||
|
|
||||||
// user defined funcion
|
// user defined funcion
|
||||||
FUNCTION_TYPE_UDF = 10000
|
FUNCTION_TYPE_UDF = 10000
|
||||||
} EFunctionType;
|
} EFunctionType;
|
||||||
|
|
@ -141,6 +144,7 @@ bool fmIsScalarFunc(int32_t funcId);
|
||||||
bool fmIsNonstandardSQLFunc(int32_t funcId);
|
bool fmIsNonstandardSQLFunc(int32_t funcId);
|
||||||
bool fmIsStringFunc(int32_t funcId);
|
bool fmIsStringFunc(int32_t funcId);
|
||||||
bool fmIsDatetimeFunc(int32_t funcId);
|
bool fmIsDatetimeFunc(int32_t funcId);
|
||||||
|
bool fmIsSelectFunc(int32_t funcId);
|
||||||
bool fmIsTimelineFunc(int32_t funcId);
|
bool fmIsTimelineFunc(int32_t funcId);
|
||||||
bool fmIsTimeorderFunc(int32_t funcId);
|
bool fmIsTimeorderFunc(int32_t funcId);
|
||||||
bool fmIsPseudoColumnFunc(int32_t funcId);
|
bool fmIsPseudoColumnFunc(int32_t funcId);
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
#define _TD_INDEX_H_
|
#define _TD_INDEX_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "taoserror.h"
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
@ -41,11 +42,22 @@ typedef enum {
|
||||||
UPDATE_VALUE, // update index column value
|
UPDATE_VALUE, // update index column value
|
||||||
ADD_INDEX, // add index on specify column
|
ADD_INDEX, // add index on specify column
|
||||||
DROP_INDEX, // drop existed index
|
DROP_INDEX, // drop existed index
|
||||||
DROP_SATBLE // drop stable
|
DROP_SATBLE, // drop stable
|
||||||
|
DEFAULT // query
|
||||||
} SIndexOperOnColumn;
|
} SIndexOperOnColumn;
|
||||||
|
|
||||||
typedef enum { MUST = 0, SHOULD = 1, NOT = 2 } EIndexOperatorType;
|
typedef enum { MUST = 0, SHOULD, NOT } EIndexOperatorType;
|
||||||
typedef enum { QUERY_TERM = 0, QUERY_PREFIX = 1, QUERY_SUFFIX = 2, QUERY_REGEX = 3, QUERY_RANGE = 4 } EIndexQueryType;
|
typedef enum {
|
||||||
|
QUERY_TERM = 0,
|
||||||
|
QUERY_PREFIX,
|
||||||
|
QUERY_SUFFIX,
|
||||||
|
QUERY_REGEX,
|
||||||
|
QUERY_LESS_THAN,
|
||||||
|
QUERY_LESS_EQUAL,
|
||||||
|
QUERY_GREATER_THAN,
|
||||||
|
QUERY_GREATER_EQUAL,
|
||||||
|
QUERY_RANGE
|
||||||
|
} EIndexQueryType;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create multi query
|
* create multi query
|
||||||
|
|
@ -166,8 +178,8 @@ void indexOptsDestroy(SIndexOpts* opts);
|
||||||
* @param:
|
* @param:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SIndexTerm* indexTermCreate(int64_t suid, SIndexOperOnColumn operType, uint8_t colType, const char* colName,
|
SIndexTerm* indexTermCreate(int64_t suid, SIndexOperOnColumn operType, int8_t qType, uint8_t colType,
|
||||||
int32_t nColName, const char* colVal, int32_t nColVal);
|
const char* colName, int32_t nColName, const char* colVal, int32_t nColVal);
|
||||||
void indexTermDestroy(SIndexTerm* p);
|
void indexTermDestroy(SIndexTerm* p);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,8 @@ extern "C" {
|
||||||
#define LIST_LENGTH(l) (NULL != (l) ? (l)->length : 0)
|
#define LIST_LENGTH(l) (NULL != (l) ? (l)->length : 0)
|
||||||
|
|
||||||
#define FOREACH(node, list) \
|
#define FOREACH(node, list) \
|
||||||
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = cell->pNode, true) : (node = NULL, false)); cell = cell->pNext)
|
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); \
|
||||||
|
(NULL != cell ? (node = cell->pNode, true) : (node = NULL, false)); cell = cell->pNext)
|
||||||
|
|
||||||
#define REPLACE_NODE(newNode) cell->pNode = (SNode*)(newNode)
|
#define REPLACE_NODE(newNode) cell->pNode = (SNode*)(newNode)
|
||||||
|
|
||||||
|
|
@ -44,15 +45,25 @@ extern "C" {
|
||||||
#define ERASE_NODE(list) cell = nodesListErase((list), cell)
|
#define ERASE_NODE(list) cell = nodesListErase((list), cell)
|
||||||
|
|
||||||
#define FORBOTH(node1, list1, node2, list2) \
|
#define FORBOTH(node1, list1, node2, list2) \
|
||||||
for (SListCell* cell1 = (NULL != (list1) ? (list1)->pHead : NULL), *cell2 = (NULL != (list2) ? (list2)->pHead : NULL); \
|
for (SListCell* cell1 = (NULL != (list1) ? (list1)->pHead : NULL), \
|
||||||
(NULL == cell1 ? (node1 = NULL, false) : (node1 = cell1->pNode, true)), (NULL == cell2 ? (node2 = NULL, false) : (node2 = cell2->pNode, true)), (node1 != NULL && node2 != NULL); \
|
*cell2 = (NULL != (list2) ? (list2)->pHead : NULL); \
|
||||||
|
(NULL == cell1 ? (node1 = NULL, false) : (node1 = cell1->pNode, true)), \
|
||||||
|
(NULL == cell2 ? (node2 = NULL, false) : (node2 = cell2->pNode, true)), \
|
||||||
|
(node1 != NULL && node2 != NULL); \
|
||||||
cell1 = cell1->pNext, cell2 = cell2->pNext)
|
cell1 = cell1->pNext, cell2 = cell2->pNext)
|
||||||
|
|
||||||
#define REPLACE_LIST1_NODE(newNode) cell1->pNode = (SNode*)(newNode)
|
#define REPLACE_LIST1_NODE(newNode) cell1->pNode = (SNode*)(newNode)
|
||||||
#define REPLACE_LIST2_NODE(newNode) cell2->pNode = (SNode*)(newNode)
|
#define REPLACE_LIST2_NODE(newNode) cell2->pNode = (SNode*)(newNode)
|
||||||
|
|
||||||
#define FOREACH_FOR_REWRITE(node, list) \
|
#define FOREACH_FOR_REWRITE(node, list) \
|
||||||
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext)
|
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); \
|
||||||
|
(NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext)
|
||||||
|
|
||||||
|
#define DESTORY_LIST(list) \
|
||||||
|
do { \
|
||||||
|
nodesDestroyList(list); \
|
||||||
|
list = NULL; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
typedef enum ENodeType {
|
typedef enum ENodeType {
|
||||||
// Syntax nodes are used in parser and planner module, and some are also used in executor module, such as COLUMN,
|
// Syntax nodes are used in parser and planner module, and some are also used in executor module, such as COLUMN,
|
||||||
|
|
@ -174,6 +185,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF,
|
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF,
|
||||||
QUERY_NODE_LOGIC_PLAN_EXCHANGE,
|
QUERY_NODE_LOGIC_PLAN_EXCHANGE,
|
||||||
QUERY_NODE_LOGIC_PLAN_WINDOW,
|
QUERY_NODE_LOGIC_PLAN_WINDOW,
|
||||||
|
QUERY_NODE_LOGIC_PLAN_FILL,
|
||||||
QUERY_NODE_LOGIC_PLAN_SORT,
|
QUERY_NODE_LOGIC_PLAN_SORT,
|
||||||
QUERY_NODE_LOGIC_PLAN_PARTITION,
|
QUERY_NODE_LOGIC_PLAN_PARTITION,
|
||||||
QUERY_NODE_LOGIC_SUBPLAN,
|
QUERY_NODE_LOGIC_SUBPLAN,
|
||||||
|
|
@ -191,6 +203,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE,
|
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_SORT,
|
QUERY_NODE_PHYSICAL_PLAN_SORT,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_INTERVAL,
|
QUERY_NODE_PHYSICAL_PLAN_INTERVAL,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_FILL,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW,
|
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW,
|
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_PARTITION,
|
QUERY_NODE_PHYSICAL_PLAN_PARTITION,
|
||||||
|
|
@ -240,12 +253,7 @@ void nodesDestroyList(SNodeList* pList);
|
||||||
// Only clear the linked list structure, without releasing the elements inside
|
// Only clear the linked list structure, without releasing the elements inside
|
||||||
void nodesClearList(SNodeList* pList);
|
void nodesClearList(SNodeList* pList);
|
||||||
|
|
||||||
typedef enum EDealRes {
|
typedef enum EDealRes { DEAL_RES_CONTINUE = 1, DEAL_RES_IGNORE_CHILD, DEAL_RES_ERROR, DEAL_RES_END } EDealRes;
|
||||||
DEAL_RES_CONTINUE = 1,
|
|
||||||
DEAL_RES_IGNORE_CHILD,
|
|
||||||
DEAL_RES_ERROR,
|
|
||||||
DEAL_RES_END
|
|
||||||
} EDealRes;
|
|
||||||
|
|
||||||
typedef EDealRes (*FNodeWalker)(SNode* pNode, void* pContext);
|
typedef EDealRes (*FNodeWalker)(SNode* pNode, void* pContext);
|
||||||
void nodesWalkExpr(SNodeptr pNode, FNodeWalker walker, void* pContext);
|
void nodesWalkExpr(SNodeptr pNode, FNodeWalker walker, void* pContext);
|
||||||
|
|
@ -271,8 +279,8 @@ int32_t nodesStringToNode(const char* pStr, SNode** pNode);
|
||||||
int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen);
|
int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen);
|
||||||
int32_t nodesStringToList(const char* pStr, SNodeList** pList);
|
int32_t nodesStringToList(const char* pStr, SNodeList** pList);
|
||||||
|
|
||||||
int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len);
|
int32_t nodesNodeToSQL(SNode* pNode, char* buf, int32_t bufSize, int32_t* len);
|
||||||
char *nodesGetNameFromColumnNode(SNode *pNode);
|
char* nodesGetNameFromColumnNode(SNode* pNode);
|
||||||
int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots);
|
int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,6 @@ typedef struct SWindowLogicNode {
|
||||||
int64_t sliding;
|
int64_t sliding;
|
||||||
int8_t intervalUnit;
|
int8_t intervalUnit;
|
||||||
int8_t slidingUnit;
|
int8_t slidingUnit;
|
||||||
SFillNode* pFill;
|
|
||||||
int64_t sessionGap;
|
int64_t sessionGap;
|
||||||
SNode* pTspk;
|
SNode* pTspk;
|
||||||
SNode* pStateExpr;
|
SNode* pStateExpr;
|
||||||
|
|
@ -110,6 +109,14 @@ typedef struct SWindowLogicNode {
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
} SWindowLogicNode;
|
} SWindowLogicNode;
|
||||||
|
|
||||||
|
typedef struct SFillLogicNode {
|
||||||
|
SLogicNode node;
|
||||||
|
EFillMode mode;
|
||||||
|
SNode* pWStartTs;
|
||||||
|
SNode* pValues; // SNodeListNode
|
||||||
|
STimeWindow timeRange;
|
||||||
|
} SFillLogicNode;
|
||||||
|
|
||||||
typedef struct SSortLogicNode {
|
typedef struct SSortLogicNode {
|
||||||
SLogicNode node;
|
SLogicNode node;
|
||||||
SNodeList* pSortKeys;
|
SNodeList* pSortKeys;
|
||||||
|
|
@ -223,10 +230,12 @@ typedef struct SProjectPhysiNode {
|
||||||
typedef struct SJoinPhysiNode {
|
typedef struct SJoinPhysiNode {
|
||||||
SPhysiNode node;
|
SPhysiNode node;
|
||||||
EJoinType joinType;
|
EJoinType joinType;
|
||||||
SNode* pOnConditions; // in or out tuple ?
|
SNode* pOnConditions;
|
||||||
SNodeList* pTargets;
|
SNodeList* pTargets;
|
||||||
} SJoinPhysiNode;
|
} SJoinPhysiNode;
|
||||||
|
|
||||||
|
typedef SJoinPhysiNode SSortMergeJoinPhysiNode;
|
||||||
|
|
||||||
typedef struct SAggPhysiNode {
|
typedef struct SAggPhysiNode {
|
||||||
SPhysiNode node;
|
SPhysiNode node;
|
||||||
SNodeList* pExprs; // these are expression list of group_by_clause and parameter expression of aggregate function
|
SNodeList* pExprs; // these are expression list of group_by_clause and parameter expression of aggregate function
|
||||||
|
|
@ -263,9 +272,17 @@ typedef struct SIntervalPhysiNode {
|
||||||
int64_t sliding;
|
int64_t sliding;
|
||||||
int8_t intervalUnit;
|
int8_t intervalUnit;
|
||||||
int8_t slidingUnit;
|
int8_t slidingUnit;
|
||||||
SFillNode* pFill;
|
|
||||||
} SIntervalPhysiNode;
|
} SIntervalPhysiNode;
|
||||||
|
|
||||||
|
typedef struct SFillPhysiNode {
|
||||||
|
SPhysiNode node;
|
||||||
|
EFillMode mode;
|
||||||
|
SNode* pWStartTs; // SColumnNode
|
||||||
|
SNode* pValues; // SNodeListNode
|
||||||
|
SNodeList* pTargets;
|
||||||
|
STimeWindow timeRange;
|
||||||
|
} SFillPhysiNode;
|
||||||
|
|
||||||
typedef struct SMultiTableIntervalPhysiNode {
|
typedef struct SMultiTableIntervalPhysiNode {
|
||||||
SIntervalPhysiNode interval;
|
SIntervalPhysiNode interval;
|
||||||
SNodeList* pPartitionKeys;
|
SNodeList* pPartitionKeys;
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ typedef struct SValueNode {
|
||||||
double d;
|
double d;
|
||||||
char* p;
|
char* p;
|
||||||
} datum;
|
} datum;
|
||||||
|
int64_t typeData;
|
||||||
char unit;
|
char unit;
|
||||||
} SValueNode;
|
} SValueNode;
|
||||||
|
|
||||||
|
|
@ -211,6 +212,8 @@ typedef struct SFillNode {
|
||||||
ENodeType type; // QUERY_NODE_FILL
|
ENodeType type; // QUERY_NODE_FILL
|
||||||
EFillMode mode;
|
EFillMode mode;
|
||||||
SNode* pValues; // SNodeListNode
|
SNode* pValues; // SNodeListNode
|
||||||
|
SNode* pWStartTs; // _wstartts pseudo column
|
||||||
|
STimeWindow timeRange;
|
||||||
} SFillNode;
|
} SFillNode;
|
||||||
|
|
||||||
typedef struct SSelectStmt {
|
typedef struct SSelectStmt {
|
||||||
|
|
@ -230,6 +233,7 @@ typedef struct SSelectStmt {
|
||||||
uint8_t precision;
|
uint8_t precision;
|
||||||
bool isEmptyResult;
|
bool isEmptyResult;
|
||||||
bool hasAggFuncs;
|
bool hasAggFuncs;
|
||||||
|
bool isTimeOrderQuery;
|
||||||
} SSelectStmt;
|
} SSelectStmt;
|
||||||
|
|
||||||
typedef enum ESetOperatorType { SET_OP_TYPE_UNION_ALL = 1, SET_OP_TYPE_UNION } ESetOperatorType;
|
typedef enum ESetOperatorType { SET_OP_TYPE_UNION_ALL = 1, SET_OP_TYPE_UNION } ESetOperatorType;
|
||||||
|
|
@ -294,12 +298,13 @@ void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker wa
|
||||||
void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewriter rewriter, void* pContext);
|
void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewriter rewriter, void* pContext);
|
||||||
|
|
||||||
typedef enum ECollectColType { COLLECT_COL_TYPE_COL = 1, COLLECT_COL_TYPE_TAG, COLLECT_COL_TYPE_ALL } ECollectColType;
|
typedef enum ECollectColType { COLLECT_COL_TYPE_COL = 1, COLLECT_COL_TYPE_TAG, COLLECT_COL_TYPE_ALL } ECollectColType;
|
||||||
|
|
||||||
int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char* pTableAlias, ECollectColType type,
|
int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char* pTableAlias, ECollectColType type,
|
||||||
SNodeList** pCols);
|
SNodeList** pCols);
|
||||||
|
|
||||||
typedef bool (*FFuncClassifier)(int32_t funcId);
|
typedef bool (*FFuncClassifier)(int32_t funcId);
|
||||||
int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNodeList** pFuncs);
|
int32_t nodesCollectFuncs(SSelectStmt* pSelect, ESqlClause clause, FFuncClassifier classifier, SNodeList** pFuncs);
|
||||||
|
|
||||||
|
int32_t nodesCollectSpecialNodes(SSelectStmt* pSelect, ESqlClause clause, ENodeType type, SNodeList** pNodes);
|
||||||
|
|
||||||
bool nodesIsExprNode(const SNode* pNode);
|
bool nodesIsExprNode(const SNode* pNode);
|
||||||
|
|
||||||
|
|
@ -312,6 +317,7 @@ bool nodesIsTimeorderQuery(const SNode* pQuery);
|
||||||
bool nodesIsTimelineQuery(const SNode* pQuery);
|
bool nodesIsTimelineQuery(const SNode* pQuery);
|
||||||
|
|
||||||
void* nodesGetValueFromNode(SValueNode* pNode);
|
void* nodesGetValueFromNode(SValueNode* pNode);
|
||||||
|
int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value);
|
||||||
char* nodesGetStrValueFromNode(SValueNode* pNode);
|
char* nodesGetStrValueFromNode(SValueNode* pNode);
|
||||||
char* getFillModeString(EFillMode mode);
|
char* getFillModeString(EFillMode mode);
|
||||||
void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal);
|
void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal);
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,8 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pSyncCfg);
|
||||||
ESyncState syncGetMyRole(int64_t rid);
|
ESyncState syncGetMyRole(int64_t rid);
|
||||||
const char* syncGetMyRoleStr(int64_t rid);
|
const char* syncGetMyRoleStr(int64_t rid);
|
||||||
SyncTerm syncGetMyTerm(int64_t rid);
|
SyncTerm syncGetMyTerm(int64_t rid);
|
||||||
|
void syncGetEpSet(int64_t rid, SEpSet* pEpSet);
|
||||||
|
int32_t syncGetVgId(int64_t rid);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TAOS_SYNC_PROPOSE_SUCCESS = 0,
|
TAOS_SYNC_PROPOSE_SUCCESS = 0,
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ extern "C" {
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define wcsncasecmp _wcsnicmp
|
#define wcsncasecmp _wcsnicmp
|
||||||
#define strtok_r strtok_s
|
#define strtok_r strtok_s
|
||||||
#define snprintf _snprintf
|
// #define snprintf _snprintf
|
||||||
#define in_addr_t unsigned long
|
#define in_addr_t unsigned long
|
||||||
// #define socklen_t int
|
// #define socklen_t int
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0113)
|
#define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0113)
|
||||||
#define TSDB_CODE_CFG_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0114)
|
#define TSDB_CODE_CFG_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0114)
|
||||||
#define TSDB_CODE_REPEAT_INIT TAOS_DEF_ERROR_CODE(0, 0x0115)
|
#define TSDB_CODE_REPEAT_INIT TAOS_DEF_ERROR_CODE(0, 0x0115)
|
||||||
|
#define TSDB_CODE_DUP_KEY TAOS_DEF_ERROR_CODE(0, 0x0116)
|
||||||
|
|
||||||
#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0140)
|
#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0140)
|
||||||
#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0141)
|
#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0141)
|
||||||
|
|
@ -263,7 +264,8 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_MND_TRANS_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03D0)
|
#define TSDB_CODE_MND_TRANS_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03D0)
|
||||||
#define TSDB_CODE_MND_TRANS_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03D1)
|
#define TSDB_CODE_MND_TRANS_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03D1)
|
||||||
#define TSDB_CODE_MND_TRANS_INVALID_STAGE TAOS_DEF_ERROR_CODE(0, 0x03D2)
|
#define TSDB_CODE_MND_TRANS_INVALID_STAGE TAOS_DEF_ERROR_CODE(0, 0x03D2)
|
||||||
#define TSDB_CODE_MND_TRANS_CANT_PARALLEL TAOS_DEF_ERROR_CODE(0, 0x03D4)
|
#define TSDB_CODE_MND_TRANS_CONFLICT TAOS_DEF_ERROR_CODE(0, 0x03D3)
|
||||||
|
#define TSDB_CODE_MND_TRANS_UNKNOW_ERROR TAOS_DEF_ERROR_CODE(0, 0x03D4)
|
||||||
|
|
||||||
// mnode-mq
|
// mnode-mq
|
||||||
#define TSDB_CODE_MND_TOPIC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E0)
|
#define TSDB_CODE_MND_TOPIC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E0)
|
||||||
|
|
@ -318,6 +320,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_VND_TB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0515)
|
#define TSDB_CODE_VND_TB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0515)
|
||||||
#define TSDB_CODE_VND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0516)
|
#define TSDB_CODE_VND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0516)
|
||||||
#define TSDB_CODE_VND_HASH_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x0517)
|
#define TSDB_CODE_VND_HASH_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x0517)
|
||||||
|
#define TSDB_CODE_VND_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0518)
|
||||||
|
|
||||||
// tsdb
|
// tsdb
|
||||||
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
||||||
|
|
@ -616,9 +619,13 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_PAR_OFFSET_LESS_ZERO TAOS_DEF_ERROR_CODE(0, 0x2637)
|
#define TSDB_CODE_PAR_OFFSET_LESS_ZERO TAOS_DEF_ERROR_CODE(0, 0x2637)
|
||||||
#define TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY TAOS_DEF_ERROR_CODE(0, 0x2638)
|
#define TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY TAOS_DEF_ERROR_CODE(0, 0x2638)
|
||||||
#define TSDB_CODE_PAR_INVALID_TOPIC_QUERY TAOS_DEF_ERROR_CODE(0, 0x2639)
|
#define TSDB_CODE_PAR_INVALID_TOPIC_QUERY TAOS_DEF_ERROR_CODE(0, 0x2639)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_DROP_STABLE TAOS_DEF_ERROR_CODE(0, 0x263A)
|
||||||
|
#define TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE TAOS_DEF_ERROR_CODE(0, 0x263B)
|
||||||
|
|
||||||
//planner
|
//planner
|
||||||
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
|
||||||
|
#define TSDB_CODE_PLAN_EXPECTED_TS_EQUAL TAOS_DEF_ERROR_CODE(0, 0x2701)
|
||||||
|
#define TSDB_CODE_PLAN_NOT_SUPPORT_CROSS_JOIN TAOS_DEF_ERROR_CODE(0, 0x2702)
|
||||||
|
|
||||||
//function
|
//function
|
||||||
#define TSDB_CODE_FUNC_FUNTION_ERROR TAOS_DEF_ERROR_CODE(0, 0x2800)
|
#define TSDB_CODE_FUNC_FUNTION_ERROR TAOS_DEF_ERROR_CODE(0, 0x2800)
|
||||||
|
|
|
||||||
|
|
@ -79,17 +79,6 @@ typedef struct {
|
||||||
#define TD_CODER_CURRENT(CODER) ((CODER)->data + (CODER)->pos)
|
#define TD_CODER_CURRENT(CODER) ((CODER)->data + (CODER)->pos)
|
||||||
#define TD_CODER_MOVE_POS(CODER, MOVE) ((CODER)->pos += (MOVE))
|
#define TD_CODER_MOVE_POS(CODER, MOVE) ((CODER)->pos += (MOVE))
|
||||||
#define TD_CODER_CHECK_CAPACITY_FAILED(CODER, EXPSIZE) (((CODER)->size - (CODER)->pos) < (EXPSIZE))
|
#define TD_CODER_CHECK_CAPACITY_FAILED(CODER, EXPSIZE) (((CODER)->size - (CODER)->pos) < (EXPSIZE))
|
||||||
// #define TCODER_MALLOC(PCODER, SIZE) \
|
|
||||||
// ({ \
|
|
||||||
// void* ptr = NULL; \
|
|
||||||
// SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(*pMem) + (SIZE)); \
|
|
||||||
// if (pMem) { \
|
|
||||||
// pMem->next = (PCODER)->mList; \
|
|
||||||
// (PCODER)->mList = pMem; \
|
|
||||||
// ptr = (void*)&pMem[1]; \
|
|
||||||
// } \
|
|
||||||
// ptr; \
|
|
||||||
// })
|
|
||||||
static FORCE_INLINE void* tCoderMalloc(SCoder* pCoder, int32_t size) {
|
static FORCE_INLINE void* tCoderMalloc(SCoder* pCoder, int32_t size) {
|
||||||
void* ptr = NULL;
|
void* ptr = NULL;
|
||||||
SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(SCoderMem*) + size);
|
SCoderMem* pMem = (SCoderMem*)taosMemoryMalloc(sizeof(SCoderMem*) + size);
|
||||||
|
|
@ -102,8 +91,9 @@ static FORCE_INLINE void* tCoderMalloc(SCoder* pCoder, int32_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#define tEncodeSize(E, S, SIZE, RET) \
|
#define tEncodeSize(E, S, SIZE, RET) \
|
||||||
do{ \
|
do { \
|
||||||
SCoder coder = {0}; \
|
SCoder coder = {0}; \
|
||||||
|
RET = 0; \
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER); \
|
tCoderInit(&coder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER); \
|
||||||
if ((E)(&coder, S) == 0) { \
|
if ((E)(&coder, S) == 0) { \
|
||||||
SIZE = coder.pos; \
|
SIZE = coder.pos; \
|
||||||
|
|
@ -111,7 +101,7 @@ static FORCE_INLINE void* tCoderMalloc(SCoder* pCoder, int32_t size) {
|
||||||
RET = -1; \
|
RET = -1; \
|
||||||
} \
|
} \
|
||||||
tCoderClear(&coder); \
|
tCoderClear(&coder); \
|
||||||
}while(0)
|
} while (0)
|
||||||
// #define tEncodeSize(E, S, SIZE) \
|
// #define tEncodeSize(E, S, SIZE) \
|
||||||
// ({ \
|
// ({ \
|
||||||
// SCoder coder = {0}; \
|
// SCoder coder = {0}; \
|
||||||
|
|
|
||||||
|
|
@ -52,54 +52,6 @@ typedef struct SSkipListNode {
|
||||||
#define SL_NODE_GET_FORWARD_POINTER(n, l) (n)->forwards[(l)]
|
#define SL_NODE_GET_FORWARD_POINTER(n, l) (n)->forwards[(l)]
|
||||||
#define SL_NODE_GET_BACKWARD_POINTER(n, l) (n)->forwards[(n)->level + (l)]
|
#define SL_NODE_GET_BACKWARD_POINTER(n, l) (n)->forwards[(n)->level + (l)]
|
||||||
|
|
||||||
/*
|
|
||||||
* @version 0.3
|
|
||||||
* @date 2017/11/12
|
|
||||||
* the simple version of skip list.
|
|
||||||
*
|
|
||||||
* for multi-thread safe purpose, we employ TdThreadRwlock to guarantee to generate
|
|
||||||
* deterministic result. Later, we will remove the lock in SkipList to further enhance the performance.
|
|
||||||
* In this case, one should use the concurrent skip list (by using michael-scott algorithm) instead of
|
|
||||||
* this simple version in a multi-thread environment, to achieve higher performance of read/write operations.
|
|
||||||
*
|
|
||||||
* Note: Duplicated primary key situation.
|
|
||||||
* In case of duplicated primary key, two ways can be employed to handle this situation:
|
|
||||||
* 1. add as normal insertion without special process.
|
|
||||||
* 2. add an overflow pointer at each list node, all nodes with the same key will be added in the overflow pointer.
|
|
||||||
* In this case, the total steps of each search will be reduced significantly.
|
|
||||||
* Currently, we implement the skip list in a line with the first means, maybe refactor it soon.
|
|
||||||
*
|
|
||||||
* Memory consumption: the memory alignment causes many memory wasted. So, employ a memory
|
|
||||||
* pool will significantly reduce the total memory consumption, as well as the calloc/malloc operation costs.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
// state struct, record following information:
|
|
||||||
// number of links in each level.
|
|
||||||
// avg search steps, for latest 1000 queries
|
|
||||||
// avg search rsp time, for latest 1000 queries
|
|
||||||
// total memory size
|
|
||||||
typedef struct tSkipListState {
|
|
||||||
// in bytes, sizeof(SSkipList)+sizeof(SSkipListNode)*SSkipList->nSize
|
|
||||||
uint64_t nTotalMemSize;
|
|
||||||
uint64_t nLevelNodeCnt[MAX_SKIP_LIST_LEVEL];
|
|
||||||
uint64_t queryCount; // total query count
|
|
||||||
|
|
||||||
/*
|
|
||||||
* only record latest 1000 queries
|
|
||||||
* when the value==1000, = 0,
|
|
||||||
* nTotalStepsForQueries = 0,
|
|
||||||
* nTotalElapsedTimeForQueries = 0
|
|
||||||
*/
|
|
||||||
uint64_t nRecQueries;
|
|
||||||
uint16_t nTotalStepsForQueries;
|
|
||||||
uint64_t nTotalElapsedTimeForQueries;
|
|
||||||
|
|
||||||
uint16_t nInsertObjs;
|
|
||||||
uint16_t nTotalStepsForInsert;
|
|
||||||
uint64_t nTotalElapsedTimeForInsert;
|
|
||||||
} tSkipListState;
|
|
||||||
|
|
||||||
typedef enum { SSkipListPutSuccess = 0, SSkipListPutEarlyStop = 1, SSkipListPutSkipOne = 2 } SSkipListPutStatus;
|
typedef enum { SSkipListPutSuccess = 0, SSkipListPutEarlyStop = 1, SSkipListPutSkipOne = 2 } SSkipListPutStatus;
|
||||||
|
|
||||||
typedef struct SSkipList {
|
typedef struct SSkipList {
|
||||||
|
|
@ -115,9 +67,6 @@ typedef struct SSkipList {
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
SSkipListNode *pHead; // point to the first element
|
SSkipListNode *pHead; // point to the first element
|
||||||
SSkipListNode *pTail; // point to the last element
|
SSkipListNode *pTail; // point to the last element
|
||||||
#if SKIP_LIST_RECORD_PERFORMANCE
|
|
||||||
tSkipListState state; // skiplist state
|
|
||||||
#endif
|
|
||||||
tGenericSavedFunc *insertHandleFn;
|
tGenericSavedFunc *insertHandleFn;
|
||||||
} SSkipList;
|
} SSkipList;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,11 +46,12 @@ typedef struct SStmtTableCache {
|
||||||
void* boundTags;
|
void* boundTags;
|
||||||
} SStmtTableCache;
|
} SStmtTableCache;
|
||||||
|
|
||||||
typedef struct SQueryFields {
|
typedef struct SStmtQueryResInfo {
|
||||||
TAOS_FIELD* fields;
|
TAOS_FIELD* fields;
|
||||||
TAOS_FIELD* userFields;
|
TAOS_FIELD* userFields;
|
||||||
uint32_t numOfCols;
|
uint32_t numOfCols;
|
||||||
} SQueryFields;
|
int32_t precision;
|
||||||
|
} SStmtQueryResInfo;
|
||||||
|
|
||||||
typedef struct SStmtBindInfo {
|
typedef struct SStmtBindInfo {
|
||||||
bool needParse;
|
bool needParse;
|
||||||
|
|
@ -82,7 +83,7 @@ typedef struct SStmtSQLInfo {
|
||||||
int32_t sqlLen;
|
int32_t sqlLen;
|
||||||
SArray* nodeList;
|
SArray* nodeList;
|
||||||
SQueryPlan* pQueryPlan;
|
SQueryPlan* pQueryPlan;
|
||||||
SQueryFields fields;
|
SStmtQueryResInfo queryRes;
|
||||||
} SStmtSQLInfo;
|
} SStmtSQLInfo;
|
||||||
|
|
||||||
typedef struct STscStmt {
|
typedef struct STscStmt {
|
||||||
|
|
|
||||||
|
|
@ -74,17 +74,44 @@ int32_t stmtGetTbName(TAOS_STMT *stmt, char **tbName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t stmtBackupQueryFields(STscStmt* pStmt) {
|
int32_t stmtBackupQueryFields(STscStmt* pStmt) {
|
||||||
SQueryFields *pFields = &pStmt->sql.fields;
|
SStmtQueryResInfo *pRes = &pStmt->sql.queryRes;
|
||||||
int32_t size = pFields->numOfCols * sizeof(TAOS_FIELD);
|
pRes->numOfCols = pStmt->exec.pRequest->body.resInfo.numOfCols;
|
||||||
|
pRes->precision = pStmt->exec.pRequest->body.resInfo.precision;
|
||||||
|
|
||||||
pFields->numOfCols = pStmt->exec.pRequest->body.resInfo.numOfCols;
|
int32_t size = pRes->numOfCols * sizeof(TAOS_FIELD);
|
||||||
pFields->fields = taosMemoryMalloc(size);
|
pRes->fields = taosMemoryMalloc(size);
|
||||||
pFields->userFields = taosMemoryMalloc(size);
|
pRes->userFields = taosMemoryMalloc(size);
|
||||||
if (NULL == pFields->fields || NULL == pFields->userFields) {
|
if (NULL == pRes->fields || NULL == pRes->userFields) {
|
||||||
STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY);
|
STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
memcpy(pFields->fields, pStmt->exec.pRequest->body.resInfo.fields, size);
|
memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size);
|
||||||
memcpy(pFields->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size);
|
memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
||||||
|
SStmtQueryResInfo *pRes = &pStmt->sql.queryRes;
|
||||||
|
int32_t size = pRes->numOfCols * sizeof(TAOS_FIELD);
|
||||||
|
|
||||||
|
pStmt->exec.pRequest->body.resInfo.numOfCols = pRes->numOfCols;
|
||||||
|
pStmt->exec.pRequest->body.resInfo.precision = pRes->precision;
|
||||||
|
|
||||||
|
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
|
||||||
|
pStmt->exec.pRequest->body.resInfo.fields = taosMemoryMalloc(size);
|
||||||
|
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
|
||||||
|
STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
memcpy(pStmt->exec.pRequest->body.resInfo.fields, pRes->fields, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
|
||||||
|
pStmt->exec.pRequest->body.resInfo.userFields = taosMemoryMalloc(size);
|
||||||
|
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
|
||||||
|
STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
memcpy(pStmt->exec.pRequest->body.resInfo.userFields, pRes->userFields, size);
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -235,6 +262,8 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool freeRequest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t stmtCleanSQLInfo(STscStmt* pStmt) {
|
int32_t stmtCleanSQLInfo(STscStmt* pStmt) {
|
||||||
|
taosMemoryFree(pStmt->sql.queryRes.fields);
|
||||||
|
taosMemoryFree(pStmt->sql.queryRes.userFields);
|
||||||
taosMemoryFree(pStmt->sql.sqlStr);
|
taosMemoryFree(pStmt->sql.sqlStr);
|
||||||
qDestroyQuery(pStmt->sql.pQuery);
|
qDestroyQuery(pStmt->sql.pQuery);
|
||||||
qDestroyQueryPlan(pStmt->sql.pQueryPlan);
|
qDestroyQueryPlan(pStmt->sql.pQueryPlan);
|
||||||
|
|
@ -497,6 +526,8 @@ int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int32_t colIdx) {
|
||||||
pStmt->sql.pQueryPlan = pStmt->exec.pRequest->body.pDag;
|
pStmt->sql.pQueryPlan = pStmt->exec.pRequest->body.pDag;
|
||||||
pStmt->exec.pRequest->body.pDag = NULL;
|
pStmt->exec.pRequest->body.pDag = NULL;
|
||||||
STMT_ERR_RET(stmtBackupQueryFields(pStmt));
|
STMT_ERR_RET(stmtBackupQueryFields(pStmt));
|
||||||
|
} else {
|
||||||
|
STMT_ERR_RET(stmtRestoreQueryFields(pStmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
STMT_RET(qStmtBindParam(pStmt->sql.pQueryPlan, bind, colIdx, pStmt->exec.pRequest->requestId));
|
STMT_RET(qStmtBindParam(pStmt->sql.pQueryPlan, bind, colIdx, pStmt->exec.pRequest->requestId));
|
||||||
|
|
@ -509,7 +540,11 @@ int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int32_t colIdx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colIdx < 0) {
|
if (colIdx < 0) {
|
||||||
qBindStmtColsValue(*pDataBlock, bind, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen);
|
int32_t code = qBindStmtColsValue(*pDataBlock, bind, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen);
|
||||||
|
if (code) {
|
||||||
|
tscError("qBindStmtColsValue failed, error:%s", tstrerror(code));
|
||||||
|
STMT_ERR_RET(code);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (colIdx != (pStmt->bInfo.sBindLastIdx + 1) && colIdx != 0) {
|
if (colIdx != (pStmt->bInfo.sBindLastIdx + 1) && colIdx != 0) {
|
||||||
tscError("bind column index not in sequence");
|
tscError("bind column index not in sequence");
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ struct tmq_conf_t {
|
||||||
char* pass;
|
char* pass;
|
||||||
char* db;
|
char* db;
|
||||||
tmq_commit_cb* commitCb;
|
tmq_commit_cb* commitCb;
|
||||||
|
void* commitCbUserParam;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tmq_t {
|
struct tmq_t {
|
||||||
|
|
@ -78,7 +79,8 @@ struct tmq_t {
|
||||||
int32_t autoCommitInterval;
|
int32_t autoCommitInterval;
|
||||||
int32_t resetOffsetCfg;
|
int32_t resetOffsetCfg;
|
||||||
int64_t consumerId;
|
int64_t consumerId;
|
||||||
tmq_commit_cb* commit_cb;
|
tmq_commit_cb* commitCb;
|
||||||
|
void* commitCbUserParam;
|
||||||
|
|
||||||
// status
|
// status
|
||||||
int8_t status;
|
int8_t status;
|
||||||
|
|
@ -372,10 +374,18 @@ int32_t tmqSubscribeCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
int32_t tmqCommitCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
int32_t tmqCommitCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
SMqCommitCbParam* pParam = (SMqCommitCbParam*)param;
|
SMqCommitCbParam* pParam = (SMqCommitCbParam*)param;
|
||||||
pParam->rspErr = code == 0 ? TMQ_RESP_ERR__SUCCESS : TMQ_RESP_ERR__FAIL;
|
pParam->rspErr = code == 0 ? TMQ_RESP_ERR__SUCCESS : TMQ_RESP_ERR__FAIL;
|
||||||
if (pParam->tmq->commit_cb) {
|
if (pParam->tmq->commitCb) {
|
||||||
pParam->tmq->commit_cb(pParam->tmq, pParam->rspErr, NULL);
|
pParam->tmq->commitCb(pParam->tmq, pParam->rspErr, NULL, pParam->tmq->commitCbUserParam);
|
||||||
|
}
|
||||||
|
if (!pParam->async)
|
||||||
|
tsem_post(&pParam->rspSem);
|
||||||
|
else {
|
||||||
|
tsem_destroy(&pParam->rspSem);
|
||||||
|
/*if (pParam->pArray) {*/
|
||||||
|
/*taosArrayDestroy(pParam->pArray);*/
|
||||||
|
/*}*/
|
||||||
|
taosMemoryFree(pParam);
|
||||||
}
|
}
|
||||||
if (!pParam->async) tsem_post(&pParam->rspSem);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -384,7 +394,7 @@ tmq_resp_err_t tmq_subscription(tmq_t* tmq, tmq_list_t** topics) {
|
||||||
*topics = tmq_list_new();
|
*topics = tmq_list_new();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
for (int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) {
|
||||||
SMqClientTopic* topic = taosArrayGetP(tmq->clientTopics, i);
|
SMqClientTopic* topic = taosArrayGet(tmq->clientTopics, i);
|
||||||
tmq_list_append(*topics, topic->topicName);
|
tmq_list_append(*topics, topic->topicName);
|
||||||
}
|
}
|
||||||
return TMQ_RESP_ERR__SUCCESS;
|
return TMQ_RESP_ERR__SUCCESS;
|
||||||
|
|
@ -477,7 +487,8 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
||||||
strcpy(pTmq->groupId, conf->groupId);
|
strcpy(pTmq->groupId, conf->groupId);
|
||||||
pTmq->autoCommit = conf->autoCommit;
|
pTmq->autoCommit = conf->autoCommit;
|
||||||
pTmq->autoCommitInterval = conf->autoCommitInterval;
|
pTmq->autoCommitInterval = conf->autoCommitInterval;
|
||||||
pTmq->commit_cb = conf->commitCb;
|
pTmq->commitCb = conf->commitCb;
|
||||||
|
pTmq->commitCbUserParam = conf->commitCbUserParam;
|
||||||
pTmq->resetOffsetCfg = conf->resetOffset;
|
pTmq->resetOffsetCfg = conf->resetOffset;
|
||||||
|
|
||||||
// assign consumerId
|
// assign consumerId
|
||||||
|
|
@ -557,7 +568,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
||||||
tscError("failed to malloc request");
|
tscError("failed to malloc request");
|
||||||
}
|
}
|
||||||
|
|
||||||
SMqCommitCbParam* pParam = taosMemoryMalloc(sizeof(SMqCommitCbParam));
|
SMqCommitCbParam* pParam = taosMemoryCalloc(1, sizeof(SMqCommitCbParam));
|
||||||
if (pParam == NULL) {
|
if (pParam == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -572,6 +583,7 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
||||||
};
|
};
|
||||||
|
|
||||||
SMsgSendInfo* sendInfo = buildMsgInfoImpl(pRequest);
|
SMsgSendInfo* sendInfo = buildMsgInfoImpl(pRequest);
|
||||||
|
sendInfo->requestObjRefId = 0;
|
||||||
sendInfo->param = pParam;
|
sendInfo->param = pParam;
|
||||||
sendInfo->fp = tmqCommitCb;
|
sendInfo->fp = tmqCommitCb;
|
||||||
SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp);
|
SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp);
|
||||||
|
|
@ -582,14 +594,13 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
|
||||||
if (!async) {
|
if (!async) {
|
||||||
tsem_wait(&pParam->rspSem);
|
tsem_wait(&pParam->rspSem);
|
||||||
resp = pParam->rspErr;
|
resp = pParam->rspErr;
|
||||||
}
|
|
||||||
|
|
||||||
tsem_destroy(&pParam->rspSem);
|
tsem_destroy(&pParam->rspSem);
|
||||||
taosMemoryFree(pParam);
|
taosMemoryFree(pParam);
|
||||||
|
|
||||||
if (pArray) {
|
if (pArray) {
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
@ -688,9 +699,10 @@ FAIL:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmq_conf_set_offset_commit_cb(tmq_conf_t* conf, tmq_commit_cb* cb) {
|
void tmq_conf_set_offset_commit_cb(tmq_conf_t* conf, tmq_commit_cb* cb, void* param) {
|
||||||
//
|
//
|
||||||
conf->commitCb = cb;
|
conf->commitCb = cb;
|
||||||
|
conf->commitCbUserParam = param;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
@ -1306,10 +1318,10 @@ const char* tmq_err2str(tmq_resp_err_t err) {
|
||||||
return "fail";
|
return "fail";
|
||||||
}
|
}
|
||||||
|
|
||||||
char* tmq_get_topic_name(TAOS_RES* res) {
|
const char* tmq_get_topic_name(TAOS_RES* res) {
|
||||||
if (TD_RES_TMQ(res)) {
|
if (TD_RES_TMQ(res)) {
|
||||||
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
SMqRspObj* pRspObj = (SMqRspObj*)res;
|
||||||
return pRspObj->topic;
|
return strchr(pRspObj->topic, '.') + 1;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,13 +168,6 @@ static void doBitmapMerge(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, c
|
||||||
|
|
||||||
uint32_t total = numOfRow1 + numOfRow2;
|
uint32_t total = numOfRow1 + numOfRow2;
|
||||||
|
|
||||||
if (BitmapLen(numOfRow1) < BitmapLen(total)) {
|
|
||||||
char* tmp = taosMemoryRealloc(pColumnInfoData->nullbitmap, BitmapLen(total));
|
|
||||||
uint32_t extend = BitmapLen(total) - BitmapLen(numOfRow1);
|
|
||||||
memset(tmp + BitmapLen(numOfRow1), 0, extend);
|
|
||||||
pColumnInfoData->nullbitmap = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t remindBits = BitPos(numOfRow1);
|
uint32_t remindBits = BitPos(numOfRow1);
|
||||||
uint32_t shiftBits = 8 - remindBits;
|
uint32_t shiftBits = 8 - remindBits;
|
||||||
|
|
||||||
|
|
@ -197,22 +190,21 @@ static void doBitmapMerge(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, c
|
||||||
int32_t overCount = BitmapLen(total) - BitmapLen(numOfRow1);
|
int32_t overCount = BitmapLen(total) - BitmapLen(numOfRow1);
|
||||||
while (i < len) { // size limit of pSource->nullbitmap
|
while (i < len) { // size limit of pSource->nullbitmap
|
||||||
if (i >= 1) {
|
if (i >= 1) {
|
||||||
start[i - 1] |= (p[i] >> remindBits); //copy remind bits
|
start[i - 1] |= (p[i] >> remindBits); // copy remind bits
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= overCount) { // size limit of pColumnInfoData->nullbitmap
|
if (i >= overCount) { // size limit of pColumnInfoData->nullbitmap
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
start[i] |= (p[i] << shiftBits); //copy shift bits
|
start[i] |= (p[i] << shiftBits); // copy shift bits
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, const SColumnInfoData* pSource,
|
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, int32_t* capacity,
|
||||||
uint32_t numOfRow2) {
|
const SColumnInfoData* pSource, uint32_t numOfRow2) {
|
||||||
ASSERT(pColumnInfoData != NULL && pSource != NULL && pColumnInfoData->info.type == pSource->info.type);
|
ASSERT(pColumnInfoData != NULL && pSource != NULL && pColumnInfoData->info.type == pSource->info.type);
|
||||||
|
|
||||||
if (numOfRow2 == 0) {
|
if (numOfRow2 == 0) {
|
||||||
return numOfRow1;
|
return numOfRow1;
|
||||||
}
|
}
|
||||||
|
|
@ -221,14 +213,19 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, co
|
||||||
pColumnInfoData->hasNull = pSource->hasNull;
|
pColumnInfoData->hasNull = pSource->hasNull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t finalNumOfRows = numOfRow1 + numOfRow2;
|
||||||
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
||||||
// Handle the bitmap
|
// Handle the bitmap
|
||||||
|
if (finalNumOfRows > *capacity) {
|
||||||
char* p = taosMemoryRealloc(pColumnInfoData->varmeta.offset, sizeof(int32_t) * (numOfRow1 + numOfRow2));
|
char* p = taosMemoryRealloc(pColumnInfoData->varmeta.offset, sizeof(int32_t) * (numOfRow1 + numOfRow2));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*capacity = finalNumOfRows;
|
||||||
pColumnInfoData->varmeta.offset = (int32_t*)p;
|
pColumnInfoData->varmeta.offset = (int32_t*)p;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfRow2; ++i) {
|
for (int32_t i = 0; i < numOfRow2; ++i) {
|
||||||
if (pSource->varmeta.offset[i] == -1) {
|
if (pSource->varmeta.offset[i] == -1) {
|
||||||
pColumnInfoData->varmeta.offset[i + numOfRow1] = -1;
|
pColumnInfoData->varmeta.offset[i + numOfRow1] = -1;
|
||||||
|
|
@ -253,15 +250,27 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, co
|
||||||
memcpy(pColumnInfoData->pData + oldLen, pSource->pData, len);
|
memcpy(pColumnInfoData->pData + oldLen, pSource->pData, len);
|
||||||
pColumnInfoData->varmeta.length = len + oldLen;
|
pColumnInfoData->varmeta.length = len + oldLen;
|
||||||
} else {
|
} else {
|
||||||
doBitmapMerge(pColumnInfoData, numOfRow1, pSource, numOfRow2);
|
if (finalNumOfRows > *capacity) {
|
||||||
|
char* tmp = taosMemoryRealloc(pColumnInfoData->pData, finalNumOfRows * pColumnInfoData->info.bytes);
|
||||||
int32_t newSize = (numOfRow1 + numOfRow2) * pColumnInfoData->info.bytes;
|
|
||||||
char* tmp = taosMemoryRealloc(pColumnInfoData->pData, newSize);
|
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
return TSDB_CODE_VND_OUT_OF_MEMORY;
|
return TSDB_CODE_VND_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
pColumnInfoData->pData = tmp;
|
pColumnInfoData->pData = tmp;
|
||||||
|
|
||||||
|
if (BitmapLen(numOfRow1) < BitmapLen(finalNumOfRows)) {
|
||||||
|
char* btmp = taosMemoryRealloc(pColumnInfoData->nullbitmap, BitmapLen(finalNumOfRows));
|
||||||
|
uint32_t extend = BitmapLen(finalNumOfRows) - BitmapLen(numOfRow1);
|
||||||
|
memset(btmp + BitmapLen(numOfRow1), 0, extend);
|
||||||
|
|
||||||
|
pColumnInfoData->nullbitmap = btmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
*capacity = finalNumOfRows;
|
||||||
|
}
|
||||||
|
|
||||||
|
doBitmapMerge(pColumnInfoData, numOfRow1, pSource, numOfRow2);
|
||||||
|
|
||||||
int32_t offset = pColumnInfoData->info.bytes * numOfRow1;
|
int32_t offset = pColumnInfoData->info.bytes * numOfRow1;
|
||||||
memcpy(pColumnInfoData->pData + offset, pSource->pData, pSource->info.bytes * numOfRow2);
|
memcpy(pColumnInfoData->pData + offset, pSource->pData, pSource->info.bytes * numOfRow2);
|
||||||
}
|
}
|
||||||
|
|
@ -350,29 +359,22 @@ int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock) {
|
||||||
// if pIndexMap = NULL, merger one column by on column
|
// if pIndexMap = NULL, merger one column by on column
|
||||||
int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc, SArray* pIndexMap) {
|
int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc, SArray* pIndexMap) {
|
||||||
assert(pSrc != NULL && pDest != NULL);
|
assert(pSrc != NULL && pDest != NULL);
|
||||||
|
int32_t capacity = pDest->info.capacity;
|
||||||
|
|
||||||
int32_t numOfCols = pDest->info.numOfCols;
|
for (int32_t i = 0; i < pDest->info.numOfCols; ++i) {
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
|
||||||
int32_t mapIndex = i;
|
int32_t mapIndex = i;
|
||||||
if(pIndexMap) {
|
if (pIndexMap) {
|
||||||
mapIndex = *(int32_t*)taosArrayGet(pIndexMap, i);
|
mapIndex = *(int32_t*)taosArrayGet(pIndexMap, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
SColumnInfoData* pCol2 = taosArrayGet(pDest->pDataBlock, i);
|
SColumnInfoData* pCol2 = taosArrayGet(pDest->pDataBlock, i);
|
||||||
SColumnInfoData* pCol1 = taosArrayGet(pSrc->pDataBlock, mapIndex);
|
SColumnInfoData* pCol1 = taosArrayGet(pSrc->pDataBlock, mapIndex);
|
||||||
|
|
||||||
uint32_t oldLen = colDataGetLength(pCol2, pDest->info.rows);
|
capacity = pDest->info.capacity;
|
||||||
uint32_t newLen = colDataGetLength(pCol1, pSrc->info.rows);
|
colDataMergeCol(pCol2, pDest->info.rows, &capacity, pCol1, pSrc->info.rows);
|
||||||
|
|
||||||
int32_t newSize = oldLen + newLen;
|
|
||||||
char* tmp = taosMemoryRealloc(pCol2->pData, newSize);
|
|
||||||
if (tmp != NULL) {
|
|
||||||
pCol2->pData = tmp;
|
|
||||||
colDataMergeCol(pCol2, pDest->info.rows, pCol1, pSrc->info.rows);
|
|
||||||
} else {
|
|
||||||
return TSDB_CODE_VND_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pDest->info.capacity = capacity;
|
||||||
pDest->info.rows += pSrc->info.rows;
|
pDest->info.rows += pSrc->info.rows;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -451,7 +453,6 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd
|
||||||
// all fit in
|
// all fit in
|
||||||
*stopIndex = numOfRows - 1;
|
*stopIndex = numOfRows - 1;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int32_t rowCount) {
|
SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int32_t rowCount) {
|
||||||
|
|
@ -490,7 +491,7 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3
|
||||||
SColumnInfoData* pDstCol = taosArrayGet(pDst->pDataBlock, i);
|
SColumnInfoData* pDstCol = taosArrayGet(pDst->pDataBlock, i);
|
||||||
|
|
||||||
for (int32_t j = startIndex; j < (startIndex + rowCount); ++j) {
|
for (int32_t j = startIndex; j < (startIndex + rowCount); ++j) {
|
||||||
bool isNull = colDataIsNull(pColData, pBlock->info.rows, j, pBlock->pBlockAgg);
|
bool isNull = colDataIsNull(pColData, pBlock->info.rows, j, pBlock->pBlockAgg[i]);
|
||||||
char* p = colDataGetData(pColData, j);
|
char* p = colDataGetData(pColData, j);
|
||||||
|
|
||||||
colDataAppend(pDstCol, j - startIndex, p, isNull);
|
colDataAppend(pDstCol, j - startIndex, p, isNull);
|
||||||
|
|
@ -702,8 +703,8 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) {
|
||||||
SColumnInfoData* pColInfoData = pOrder->pColData; // TARRAY_GET_ELEM(pDataBlock->pDataBlock, pOrder->colIndex);
|
SColumnInfoData* pColInfoData = pOrder->pColData; // TARRAY_GET_ELEM(pDataBlock->pDataBlock, pOrder->colIndex);
|
||||||
|
|
||||||
if (pColInfoData->hasNull) {
|
if (pColInfoData->hasNull) {
|
||||||
bool leftNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, left, pDataBlock->pBlockAgg);
|
bool leftNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, left, NULL);
|
||||||
bool rightNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, right, pDataBlock->pBlockAgg);
|
bool rightNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, right, NULL);
|
||||||
if (leftNull && rightNull) {
|
if (leftNull && rightNull) {
|
||||||
continue; // continue to next slot
|
continue; // continue to next slot
|
||||||
}
|
}
|
||||||
|
|
@ -742,7 +743,7 @@ static int32_t doAssignOneTuple(SColumnInfoData* pDstCols, int32_t numOfRows, co
|
||||||
SColumnInfoData* pDst = &pDstCols[i];
|
SColumnInfoData* pDst = &pDstCols[i];
|
||||||
SColumnInfoData* pSrc = taosArrayGet(pSrcBlock->pDataBlock, i);
|
SColumnInfoData* pSrc = taosArrayGet(pSrcBlock->pDataBlock, i);
|
||||||
|
|
||||||
if (pSrc->hasNull && colDataIsNull(pSrc, pSrcBlock->info.rows, tupleIndex, pSrcBlock->pBlockAgg)) {
|
if (pSrc->hasNull && colDataIsNull(pSrc, pSrcBlock->info.rows, tupleIndex, pSrcBlock->pBlockAgg[i])) {
|
||||||
code = colDataAppend(pDst, numOfRows, NULL, true);
|
code = colDataAppend(pDst, numOfRows, NULL, true);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
|
|
@ -938,8 +939,9 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) {
|
||||||
copyBackToBlock(pDataBlock, pCols);
|
copyBackToBlock(pDataBlock, pCols);
|
||||||
int64_t p4 = taosGetTimestampUs();
|
int64_t p4 = taosGetTimestampUs();
|
||||||
|
|
||||||
uDebug("blockDataSort complex sort:%" PRId64 ", create:%" PRId64 ", assign:%" PRId64 ", copyback:%" PRId64 ", rows:%d\n", p1 - p0, p2 - p1,
|
uDebug("blockDataSort complex sort:%" PRId64 ", create:%" PRId64 ", assign:%" PRId64 ", copyback:%" PRId64
|
||||||
p3 - p2, p4 - p3, rows);
|
", rows:%d\n",
|
||||||
|
p1 - p0, p2 - p1, p3 - p2, p4 - p3, rows);
|
||||||
destroyTupleIndex(index);
|
destroyTupleIndex(index);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
@ -1176,7 +1178,7 @@ void* blockDataDestroy(SSDataBlock* pBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData) {
|
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData) {
|
||||||
if(pDataBlock == NULL){
|
if (pDataBlock == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1217,7 +1219,7 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize) {
|
size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize) {
|
||||||
return (int32_t) ((pageSize - blockDataGetSerialMetaSize(pBlock))/ blockDataGetSerialRowSize(pBlock));
|
return (int32_t)((pageSize - blockDataGetSerialMetaSize(pBlock)) / blockDataGetSerialRowSize(pBlock));
|
||||||
}
|
}
|
||||||
|
|
||||||
void colDataDestroy(SColumnInfoData* pColData) {
|
void colDataDestroy(SColumnInfoData* pColData) {
|
||||||
|
|
@ -1234,14 +1236,14 @@ static void doShiftBitmap(char* nullBitmap, size_t n, size_t total) {
|
||||||
int32_t len = BitmapLen(total);
|
int32_t len = BitmapLen(total);
|
||||||
|
|
||||||
int32_t newLen = BitmapLen(total - n);
|
int32_t newLen = BitmapLen(total - n);
|
||||||
if (n%8 == 0) {
|
if (n % 8 == 0) {
|
||||||
memmove(nullBitmap, nullBitmap + n/8, newLen);
|
memmove(nullBitmap, nullBitmap + n / 8, newLen);
|
||||||
} else {
|
} else {
|
||||||
int32_t tail = n % 8;
|
int32_t tail = n % 8;
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
|
|
||||||
uint8_t* p = (uint8_t*) nullBitmap;
|
uint8_t* p = (uint8_t*)nullBitmap;
|
||||||
while(i < len) {
|
while (i < len) {
|
||||||
uint8_t v = p[i];
|
uint8_t v = p[i];
|
||||||
|
|
||||||
p[i] = 0;
|
p[i] = 0;
|
||||||
|
|
@ -1268,7 +1270,7 @@ static void colDataTrimFirstNRows(SColumnInfoData* pColInfoData, size_t n, size_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t blockDataTrimFirstNRows(SSDataBlock *pBlock, size_t n) {
|
int32_t blockDataTrimFirstNRows(SSDataBlock* pBlock, size_t n) {
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -1276,7 +1278,7 @@ int32_t blockDataTrimFirstNRows(SSDataBlock *pBlock, size_t n) {
|
||||||
if (pBlock->info.rows <= n) {
|
if (pBlock->info.rows <= n) {
|
||||||
blockDataCleanup(pBlock);
|
blockDataCleanup(pBlock);
|
||||||
} else {
|
} else {
|
||||||
for(int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
|
for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) {
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
colDataTrimFirstNRows(pColInfoData, n, pBlock->info.rows);
|
colDataTrimFirstNRows(pColInfoData, n, pBlock->info.rows);
|
||||||
}
|
}
|
||||||
|
|
@ -1462,3 +1464,128 @@ void blockDebugShowData(const SArray* dataBlocks) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TODO: Assume that the final generated result it less than 3M
|
||||||
|
*
|
||||||
|
* @param pReq
|
||||||
|
* @param pDataBlocks
|
||||||
|
* @param vgId
|
||||||
|
* @param uid set as parameter temporarily // TODO: remove this parameter, and the executor should set uid in
|
||||||
|
* SDataBlock->info.uid
|
||||||
|
* @param suid // TODO: check with Liao whether suid response is reasonable
|
||||||
|
*
|
||||||
|
* TODO: colId should be set
|
||||||
|
*/
|
||||||
|
int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks, STSchema *pTSchema, int32_t vgId, tb_uid_t uid,
|
||||||
|
tb_uid_t suid) {
|
||||||
|
int32_t sz = taosArrayGetSize(pDataBlocks);
|
||||||
|
int32_t bufSize = sizeof(SSubmitReq);
|
||||||
|
for (int32_t i = 0; i < sz; ++i) {
|
||||||
|
SDataBlockInfo* pBlkInfo = &((SSDataBlock*)taosArrayGet(pDataBlocks, i))->info;
|
||||||
|
bufSize += pBlkInfo->rows * (TD_ROW_HEAD_LEN + pBlkInfo->rowSize + BitmapLen(pBlkInfo->numOfCols));
|
||||||
|
bufSize += sizeof(SSubmitBlk);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(bufSize < 3 * 1024 * 1024);
|
||||||
|
|
||||||
|
*pReq = taosMemoryCalloc(1, bufSize);
|
||||||
|
if(!(*pReq)) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
void* pDataBuf = *pReq;
|
||||||
|
|
||||||
|
int32_t msgLen = sizeof(SSubmitReq);
|
||||||
|
int32_t numOfBlks = 0;
|
||||||
|
SRowBuilder rb = {0};
|
||||||
|
tdSRowInit(&rb, 0); // TODO: use the latest version
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < sz; ++i) {
|
||||||
|
SSDataBlock* pDataBlock = taosArrayGet(pDataBlocks, i);
|
||||||
|
int32_t colNum = pDataBlock->info.numOfCols;
|
||||||
|
int32_t rows = pDataBlock->info.rows;
|
||||||
|
int32_t rowSize = pDataBlock->info.rowSize;
|
||||||
|
int64_t groupId = pDataBlock->info.groupId;
|
||||||
|
|
||||||
|
if(rb.nCols != colNum) {
|
||||||
|
tdSRowSetTpInfo(&rb, colNum, pTSchema->flen);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSubmitBlk* pSubmitBlk = POINTER_SHIFT(pDataBuf, msgLen);
|
||||||
|
pSubmitBlk->suid = suid;
|
||||||
|
pSubmitBlk->uid = uid;
|
||||||
|
pSubmitBlk->numOfRows = rows;
|
||||||
|
|
||||||
|
++numOfBlks;
|
||||||
|
|
||||||
|
msgLen += sizeof(SSubmitBlk);
|
||||||
|
int32_t dataLen = 0;
|
||||||
|
for (int32_t j = 0; j < rows; ++j) { // iterate by row
|
||||||
|
tdSRowResetBuf(&rb, POINTER_SHIFT(pDataBuf, msgLen)); // set row buf
|
||||||
|
printf("|");
|
||||||
|
bool isStartKey = false;
|
||||||
|
for (int32_t k = 0; k < colNum; ++k) { // iterate by column
|
||||||
|
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||||
|
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
|
||||||
|
switch (pColInfoData->info.type) {
|
||||||
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
|
if (!isStartKey) {
|
||||||
|
isStartKey = true;
|
||||||
|
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NORM, var, true, 0, 0);
|
||||||
|
} else {
|
||||||
|
tdAppendColValToRow(&rb, 2, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NORM, var, true, 8, k);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
|
tdAppendColValToRow(&rb, 2, TSDB_DATA_TYPE_NCHAR, TD_VTYPE_NORM, var, true, 8, k);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY
|
||||||
|
tdAppendColValToRow(&rb, 2, TSDB_DATA_TYPE_VARCHAR, TD_VTYPE_NORM, var, true, 8, k);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TSDB_DATA_TYPE_VARBINARY:
|
||||||
|
case TSDB_DATA_TYPE_DECIMAL:
|
||||||
|
case TSDB_DATA_TYPE_BLOB:
|
||||||
|
case TSDB_DATA_TYPE_MEDIUMBLOB:
|
||||||
|
printf("the column type %" PRIi16 " is defined but not implemented yet\n", pColInfoData->info.type);
|
||||||
|
TASSERT(0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (pColInfoData->info.type < TSDB_DATA_TYPE_MAX && pColInfoData->info.type > TSDB_DATA_TYPE_NULL) {
|
||||||
|
tdAppendColValToRow(&rb, 2, pColInfoData->info.type, TD_VTYPE_NORM, var, true, 8, k);
|
||||||
|
} else {
|
||||||
|
printf("the column type %" PRIi16 " is undefined\n", pColInfoData->info.type);
|
||||||
|
TASSERT(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dataLen += TD_ROW_LEN(rb.pBuf);
|
||||||
|
}
|
||||||
|
pSubmitBlk->dataLen = dataLen;
|
||||||
|
msgLen += pSubmitBlk->dataLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*pReq)->length = msgLen;
|
||||||
|
|
||||||
|
(*pReq)->header.vgId = htonl(vgId);
|
||||||
|
(*pReq)->header.contLen = htonl(msgLen);
|
||||||
|
(*pReq)->length = (*pReq)->header.contLen;
|
||||||
|
(*pReq)->numOfBlocks = htonl(numOfBlks);
|
||||||
|
SSubmitBlk* blk = (SSubmitBlk*)((*pReq) + 1);
|
||||||
|
while (numOfBlks--) {
|
||||||
|
int32_t dataLen = blk->dataLen;
|
||||||
|
blk->uid = htobe64(blk->uid);
|
||||||
|
blk->suid = htobe64(blk->suid);
|
||||||
|
blk->padding = htonl(blk->padding);
|
||||||
|
blk->sversion = htonl(blk->sversion);
|
||||||
|
blk->dataLen = htonl(blk->dataLen);
|
||||||
|
blk->schemaLen = htonl(blk->schemaLen);
|
||||||
|
blk->numOfRows = htons(blk->numOfRows);
|
||||||
|
blk = (SSubmitBlk*)(blk->data + dataLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ int tdEncodeSchema(void **buf, STSchema *pSchema) {
|
||||||
for (int i = 0; i < schemaNCols(pSchema); i++) {
|
for (int i = 0; i < schemaNCols(pSchema); i++) {
|
||||||
STColumn *pCol = schemaColAt(pSchema, i);
|
STColumn *pCol = schemaColAt(pSchema, i);
|
||||||
tlen += taosEncodeFixedI8(buf, colType(pCol));
|
tlen += taosEncodeFixedI8(buf, colType(pCol));
|
||||||
tlen += taosEncodeFixedI8(buf, colSma(pCol));
|
tlen += taosEncodeFixedI8(buf, colFlags(pCol));
|
||||||
tlen += taosEncodeFixedI16(buf, colColId(pCol));
|
tlen += taosEncodeFixedI16(buf, colColId(pCol));
|
||||||
tlen += taosEncodeFixedI16(buf, colBytes(pCol));
|
tlen += taosEncodeFixedI16(buf, colBytes(pCol));
|
||||||
}
|
}
|
||||||
|
|
@ -110,14 +110,14 @@ void *tdDecodeSchema(void *buf, STSchema **pRSchema) {
|
||||||
|
|
||||||
for (int i = 0; i < numOfCols; i++) {
|
for (int i = 0; i < numOfCols; i++) {
|
||||||
col_type_t type = 0;
|
col_type_t type = 0;
|
||||||
int8_t sma = 0;
|
int8_t flags = 0;
|
||||||
col_id_t colId = 0;
|
col_id_t colId = 0;
|
||||||
col_bytes_t bytes = 0;
|
col_bytes_t bytes = 0;
|
||||||
buf = taosDecodeFixedI8(buf, &type);
|
buf = taosDecodeFixedI8(buf, &type);
|
||||||
buf = taosDecodeFixedI8(buf, &sma);
|
buf = taosDecodeFixedI8(buf, &flags);
|
||||||
buf = taosDecodeFixedI16(buf, &colId);
|
buf = taosDecodeFixedI16(buf, &colId);
|
||||||
buf = taosDecodeFixedI32(buf, &bytes);
|
buf = taosDecodeFixedI32(buf, &bytes);
|
||||||
if (tdAddColToSchema(&schemaBuilder, type, sma, colId, bytes) < 0) {
|
if (tdAddColToSchema(&schemaBuilder, type, flags, colId, bytes) < 0) {
|
||||||
tdDestroyTSchemaBuilder(&schemaBuilder);
|
tdDestroyTSchemaBuilder(&schemaBuilder);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +153,7 @@ void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version) {
|
||||||
pBuilder->version = version;
|
pBuilder->version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int8_t sma, col_id_t colId, col_bytes_t bytes) {
|
int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int8_t flags, col_id_t colId, col_bytes_t bytes) {
|
||||||
if (!isValidDataType(type)) return -1;
|
if (!isValidDataType(type)) return -1;
|
||||||
|
|
||||||
if (pBuilder->nCols >= pBuilder->tCols) {
|
if (pBuilder->nCols >= pBuilder->tCols) {
|
||||||
|
|
@ -166,7 +166,7 @@ int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int8_t sma, col
|
||||||
STColumn *pCol = &(pBuilder->columns[pBuilder->nCols]);
|
STColumn *pCol = &(pBuilder->columns[pBuilder->nCols]);
|
||||||
colSetType(pCol, type);
|
colSetType(pCol, type);
|
||||||
colSetColId(pCol, colId);
|
colSetColId(pCol, colId);
|
||||||
colSetSma(pCol, sma);
|
colSetFlags(pCol, flags);
|
||||||
if (pBuilder->nCols == 0) {
|
if (pBuilder->nCols == 0) {
|
||||||
colSetOffset(pCol, 0);
|
colSetOffset(pCol, 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,10 @@ uint32_t tsMaxRange = 500; // max range
|
||||||
uint32_t tsCurRange = 100; // range
|
uint32_t tsCurRange = 100; // range
|
||||||
char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPRESSOR
|
char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPRESSOR
|
||||||
|
|
||||||
|
// internal
|
||||||
|
int32_t tsTransPullupMs = 6000;
|
||||||
|
int32_t tsMaRebalanceMs = 2000;
|
||||||
|
|
||||||
void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary) {
|
void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary) {
|
||||||
tstrncpy(tsDiskCfg[index].dir, v1, TSDB_FILENAME_LEN);
|
tstrncpy(tsDiskCfg[index].dir, v1, TSDB_FILENAME_LEN);
|
||||||
tsDiskCfg[index].level = level;
|
tsDiskCfg[index].level = level;
|
||||||
|
|
|
||||||
|
|
@ -34,77 +34,6 @@ int32_t tInitSubmitMsgIter(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pIter->totalLen = pMsg->length;
|
|
||||||
ASSERT(pIter->totalLen > 0);
|
|
||||||
pIter->len = 0;
|
|
||||||
pIter->pMsg = pMsg;
|
|
||||||
if (pMsg->length <= sizeof(SSubmitReq)) {
|
|
||||||
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tGetSubmitMsgNext(SSubmitMsgIter *pIter, SSubmitBlk **pPBlock) {
|
|
||||||
ASSERT(pIter->len >= 0);
|
|
||||||
|
|
||||||
if (pIter->len == 0) {
|
|
||||||
pIter->len += sizeof(SSubmitReq);
|
|
||||||
} else {
|
|
||||||
if (pIter->len >= pIter->totalLen) {
|
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSubmitBlk *pSubmitBlk = (SSubmitBlk *)POINTER_SHIFT(pIter->pMsg, pIter->len);
|
|
||||||
pIter->len += (sizeof(SSubmitBlk) + pSubmitBlk->dataLen + pSubmitBlk->schemaLen);
|
|
||||||
ASSERT(pIter->len > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pIter->len > pIter->totalLen) {
|
|
||||||
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
|
|
||||||
*pPBlock = NULL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*pPBlock = (pIter->len == pIter->totalLen) ? NULL : (SSubmitBlk *)POINTER_SHIFT(pIter->pMsg, pIter->len);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tInitSubmitBlkIter(SSubmitBlk *pBlock, SSubmitBlkIter *pIter) {
|
|
||||||
if (pBlock->dataLen <= 0) return -1;
|
|
||||||
pIter->totalLen = pBlock->dataLen;
|
|
||||||
pIter->len = 0;
|
|
||||||
pIter->row = (STSRow *)(pBlock->data + pBlock->schemaLen);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
STSRow *tGetSubmitBlkNext(SSubmitBlkIter *pIter) {
|
|
||||||
STSRow *row = pIter->row;
|
|
||||||
|
|
||||||
if (pIter->len >= pIter->totalLen) {
|
|
||||||
return NULL;
|
|
||||||
} else {
|
|
||||||
pIter->len += TD_ROW_LEN(row);
|
|
||||||
if (pIter->len < pIter->totalLen) {
|
|
||||||
pIter->row = POINTER_SHIFT(row, TD_ROW_LEN(row));
|
|
||||||
}
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: KEEP one suite of iterator API finally.
|
|
||||||
// 1) use tInitSubmitMsgIterEx firstly as not decrease the merge conflicts
|
|
||||||
// 2) replace tInitSubmitMsgIterEx with tInitSubmitMsgIter later
|
|
||||||
// 3) finally, rename tInitSubmitMsgIterEx to tInitSubmitMsgIter
|
|
||||||
|
|
||||||
int32_t tInitSubmitMsgIterEx(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
|
|
||||||
if (pMsg == NULL) {
|
|
||||||
terrno = TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pIter->totalLen = htonl(pMsg->length);
|
pIter->totalLen = htonl(pMsg->length);
|
||||||
ASSERT(pIter->totalLen > 0);
|
ASSERT(pIter->totalLen > 0);
|
||||||
pIter->len = 0;
|
pIter->len = 0;
|
||||||
|
|
@ -117,7 +46,7 @@ int32_t tInitSubmitMsgIterEx(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tGetSubmitMsgNextEx(SSubmitMsgIter *pIter, SSubmitBlk **pPBlock) {
|
int32_t tGetSubmitMsgNext(SSubmitMsgIter *pIter, SSubmitBlk **pPBlock) {
|
||||||
ASSERT(pIter->len >= 0);
|
ASSERT(pIter->len >= 0);
|
||||||
|
|
||||||
if (pIter->len == 0) {
|
if (pIter->len == 0) {
|
||||||
|
|
@ -152,7 +81,7 @@ int32_t tGetSubmitMsgNextEx(SSubmitMsgIter *pIter, SSubmitBlk **pPBlock) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tInitSubmitBlkIterEx(SSubmitMsgIter *pMsgIter, SSubmitBlk *pBlock, SSubmitBlkIter *pIter) {
|
int32_t tInitSubmitBlkIter(SSubmitMsgIter *pMsgIter, SSubmitBlk *pBlock, SSubmitBlkIter *pIter) {
|
||||||
if (pMsgIter->dataLen <= 0) return -1;
|
if (pMsgIter->dataLen <= 0) return -1;
|
||||||
pIter->totalLen = pMsgIter->dataLen;
|
pIter->totalLen = pMsgIter->dataLen;
|
||||||
pIter->len = 0;
|
pIter->len = 0;
|
||||||
|
|
@ -160,7 +89,7 @@ int32_t tInitSubmitBlkIterEx(SSubmitMsgIter *pMsgIter, SSubmitBlk *pBlock, SSubm
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
STSRow *tGetSubmitBlkNextEx(SSubmitBlkIter *pIter) {
|
STSRow *tGetSubmitBlkNext(SSubmitBlkIter *pIter) {
|
||||||
STSRow *row = pIter->row;
|
STSRow *row = pIter->row;
|
||||||
|
|
||||||
if (pIter->len >= pIter->totalLen) {
|
if (pIter->len >= pIter->totalLen) {
|
||||||
|
|
@ -490,21 +419,6 @@ int32_t tDeserializeSClientHbBatchRsp(void *buf, int32_t bufLen, SClientHbBatchR
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSVDropTbReq(void **buf, SVDropTbReq *pReq) {
|
|
||||||
int32_t tlen = 0;
|
|
||||||
tlen += taosEncodeFixedI64(buf, pReq->ver);
|
|
||||||
tlen += taosEncodeString(buf, pReq->name);
|
|
||||||
tlen += taosEncodeFixedU8(buf, pReq->type);
|
|
||||||
return tlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *tDeserializeSVDropTbReq(void *buf, SVDropTbReq *pReq) {
|
|
||||||
buf = taosDecodeFixedI64(buf, &pReq->ver);
|
|
||||||
buf = taosDecodeString(buf, &pReq->name);
|
|
||||||
buf = taosDecodeFixedU8(buf, &pReq->type);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq) {
|
int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq) {
|
||||||
SCoder encoder = {0};
|
SCoder encoder = {0};
|
||||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||||
|
|
@ -1697,8 +1611,8 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
|
||||||
if (tEncodeI32(&encoder, pReq->numOfRetensions) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->numOfRetensions) < 0) return -1;
|
||||||
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
|
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
|
||||||
SRetention *pRetension = taosArrayGet(pReq->pRetensions, i);
|
SRetention *pRetension = taosArrayGet(pReq->pRetensions, i);
|
||||||
if (tEncodeI32(&encoder, pRetension->freq) < 0) return -1;
|
if (tEncodeI64(&encoder, pRetension->freq) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pRetension->keep) < 0) return -1;
|
if (tEncodeI64(&encoder, pRetension->keep) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pRetension->freqUnit) < 0) return -1;
|
if (tEncodeI8(&encoder, pRetension->freqUnit) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pRetension->keepUnit) < 0) return -1;
|
if (tEncodeI8(&encoder, pRetension->keepUnit) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -1743,8 +1657,8 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
|
||||||
|
|
||||||
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
|
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
|
||||||
SRetention rentension = {0};
|
SRetention rentension = {0};
|
||||||
if (tDecodeI32(&decoder, &rentension.freq) < 0) return -1;
|
if (tDecodeI64(&decoder, &rentension.freq) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &rentension.keep) < 0) return -1;
|
if (tDecodeI64(&decoder, &rentension.keep) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &rentension.freqUnit) < 0) return -1;
|
if (tDecodeI8(&decoder, &rentension.freqUnit) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &rentension.keepUnit) < 0) return -1;
|
if (tDecodeI8(&decoder, &rentension.keepUnit) < 0) return -1;
|
||||||
if (taosArrayPush(pReq->pRetensions, &rentension) == NULL) {
|
if (taosArrayPush(pReq->pRetensions, &rentension) == NULL) {
|
||||||
|
|
@ -2173,8 +2087,8 @@ int32_t tSerializeSDbCfgRsp(void *buf, int32_t bufLen, const SDbCfgRsp *pRsp) {
|
||||||
if (tEncodeI32(&encoder, pRsp->numOfRetensions) < 0) return -1;
|
if (tEncodeI32(&encoder, pRsp->numOfRetensions) < 0) return -1;
|
||||||
for (int32_t i = 0; i < pRsp->numOfRetensions; ++i) {
|
for (int32_t i = 0; i < pRsp->numOfRetensions; ++i) {
|
||||||
SRetention *pRetension = taosArrayGet(pRsp->pRetensions, i);
|
SRetention *pRetension = taosArrayGet(pRsp->pRetensions, i);
|
||||||
if (tEncodeI32(&encoder, pRetension->freq) < 0) return -1;
|
if (tEncodeI64(&encoder, pRetension->freq) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pRetension->keep) < 0) return -1;
|
if (tEncodeI64(&encoder, pRetension->keep) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pRetension->freqUnit) < 0) return -1;
|
if (tEncodeI8(&encoder, pRetension->freqUnit) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pRetension->keepUnit) < 0) return -1;
|
if (tEncodeI8(&encoder, pRetension->keepUnit) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -2217,8 +2131,8 @@ int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < pRsp->numOfRetensions; ++i) {
|
for (int32_t i = 0; i < pRsp->numOfRetensions; ++i) {
|
||||||
SRetention rentension = {0};
|
SRetention rentension = {0};
|
||||||
if (tDecodeI32(&decoder, &rentension.freq) < 0) return -1;
|
if (tDecodeI64(&decoder, &rentension.freq) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &rentension.keep) < 0) return -1;
|
if (tDecodeI64(&decoder, &rentension.keep) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &rentension.freqUnit) < 0) return -1;
|
if (tDecodeI8(&decoder, &rentension.freqUnit) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &rentension.keepUnit) < 0) return -1;
|
if (tDecodeI8(&decoder, &rentension.keepUnit) < 0) return -1;
|
||||||
if (taosArrayPush(pRsp->pRetensions, &rentension) == NULL) {
|
if (taosArrayPush(pRsp->pRetensions, &rentension) == NULL) {
|
||||||
|
|
@ -2835,8 +2749,8 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
|
||||||
if (tEncodeI32(&encoder, pReq->numOfRetensions) < 0) return -1;
|
if (tEncodeI32(&encoder, pReq->numOfRetensions) < 0) return -1;
|
||||||
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
|
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
|
||||||
SRetention *pRetension = taosArrayGet(pReq->pRetensions, i);
|
SRetention *pRetension = taosArrayGet(pReq->pRetensions, i);
|
||||||
if (tEncodeI32(&encoder, pRetension->freq) < 0) return -1;
|
if (tEncodeI64(&encoder, pRetension->freq) < 0) return -1;
|
||||||
if (tEncodeI32(&encoder, pRetension->keep) < 0) return -1;
|
if (tEncodeI64(&encoder, pRetension->keep) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pRetension->freqUnit) < 0) return -1;
|
if (tEncodeI8(&encoder, pRetension->freqUnit) < 0) return -1;
|
||||||
if (tEncodeI8(&encoder, pRetension->keepUnit) < 0) return -1;
|
if (tEncodeI8(&encoder, pRetension->keepUnit) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -2892,8 +2806,8 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
|
||||||
|
|
||||||
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
|
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
|
||||||
SRetention rentension = {0};
|
SRetention rentension = {0};
|
||||||
if (tDecodeI32(&decoder, &rentension.freq) < 0) return -1;
|
if (tDecodeI64(&decoder, &rentension.freq) < 0) return -1;
|
||||||
if (tDecodeI32(&decoder, &rentension.keep) < 0) return -1;
|
if (tDecodeI64(&decoder, &rentension.keep) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &rentension.freqUnit) < 0) return -1;
|
if (tDecodeI8(&decoder, &rentension.freqUnit) < 0) return -1;
|
||||||
if (tDecodeI8(&decoder, &rentension.keepUnit) < 0) return -1;
|
if (tDecodeI8(&decoder, &rentension.keepUnit) < 0) return -1;
|
||||||
if (taosArrayPush(pReq->pRetensions, &rentension) == NULL) {
|
if (taosArrayPush(pReq->pRetensions, &rentension) == NULL) {
|
||||||
|
|
@ -3811,3 +3725,119 @@ int tDecodeSVCreateTbRsp(SCoder *pCoder, SVCreateTbRsp *pRsp) {
|
||||||
tEndDecode(pCoder);
|
tEndDecode(pCoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TDMT_VND_DROP_TABLE =================
|
||||||
|
static int32_t tEncodeSVDropTbReq(SCoder *pCoder, const SVDropTbReq *pReq) {
|
||||||
|
if (tStartEncode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeCStr(pCoder, pReq->name) < 0) return -1;
|
||||||
|
if (tEncodeI8(pCoder, pReq->igNotExists) < 0) return -1;
|
||||||
|
|
||||||
|
tEndEncode(pCoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tDecodeSVDropTbReq(SCoder *pCoder, SVDropTbReq *pReq) {
|
||||||
|
if (tStartDecode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
|
if (tDecodeCStr(pCoder, &pReq->name) < 0) return -1;
|
||||||
|
if (tDecodeI8(pCoder, &pReq->igNotExists) < 0) return -1;
|
||||||
|
|
||||||
|
tEndDecode(pCoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tEncodeSVDropTbRsp(SCoder *pCoder, const SVDropTbRsp *pReq) {
|
||||||
|
if (tStartEncode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeI32(pCoder, pReq->code) < 0) return -1;
|
||||||
|
|
||||||
|
tEndEncode(pCoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tDecodeSVDropTbRsp(SCoder *pCoder, SVDropTbRsp *pReq) {
|
||||||
|
if (tStartDecode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
|
if (tDecodeI32(pCoder, &pReq->code) < 0) return -1;
|
||||||
|
|
||||||
|
tEndDecode(pCoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tEncodeSVDropTbBatchReq(SCoder *pCoder, const SVDropTbBatchReq *pReq) {
|
||||||
|
int32_t nReqs = taosArrayGetSize(pReq->pArray);
|
||||||
|
SVDropTbReq *pDropTbReq;
|
||||||
|
|
||||||
|
if (tStartEncode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeI32v(pCoder, nReqs) < 0) return -1;
|
||||||
|
for (int iReq = 0; iReq < nReqs; iReq++) {
|
||||||
|
pDropTbReq = (SVDropTbReq *)taosArrayGet(pReq->pArray, iReq);
|
||||||
|
if (tEncodeSVDropTbReq(pCoder, pDropTbReq) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndEncode(pCoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDecodeSVDropTbBatchReq(SCoder *pCoder, SVDropTbBatchReq *pReq) {
|
||||||
|
if (tStartDecode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
|
if (tDecodeI32v(pCoder, &pReq->nReqs) < 0) return -1;
|
||||||
|
pReq->pReqs = (SVDropTbReq *)tCoderMalloc(pCoder, sizeof(SVDropTbReq) * pReq->nReqs);
|
||||||
|
if (pReq->pReqs == NULL) return -1;
|
||||||
|
for (int iReq = 0; iReq < pReq->nReqs; iReq++) {
|
||||||
|
if (tDecodeSVDropTbReq(pCoder, pReq->pReqs + iReq) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndDecode(pCoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tEncodeSVDropTbBatchRsp(SCoder *pCoder, const SVDropTbBatchRsp *pRsp) {
|
||||||
|
int32_t nRsps = taosArrayGetSize(pRsp->pArray);
|
||||||
|
if (tStartEncode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeI32v(pCoder, nRsps) < 0) return -1;
|
||||||
|
for (int iRsp = 0; iRsp < nRsps; iRsp++) {
|
||||||
|
if (tEncodeSVDropTbRsp(pCoder, (SVDropTbRsp *)taosArrayGet(pRsp->pArray, iRsp)) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndEncode(pCoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDecodeSVDropTbBatchRsp(SCoder *pCoder, SVDropTbBatchRsp *pRsp) {
|
||||||
|
if (tStartDecode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
|
if (tDecodeI32v(pCoder, &pRsp->nRsps) < 0) return -1;
|
||||||
|
pRsp->pRsps = (SVDropTbRsp *)tCoderMalloc(pCoder, sizeof(SVDropTbRsp) * pRsp->nRsps);
|
||||||
|
if (pRsp->pRsps == NULL) return -1;
|
||||||
|
for (int iRsp = 0; iRsp < pRsp->nRsps; iRsp++) {
|
||||||
|
if (tDecodeSVDropTbRsp(pCoder, pRsp->pRsps + iRsp) < 0) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tEndDecode(pCoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tEncodeSVDropStbReq(SCoder *pCoder, const SVDropStbReq *pReq) {
|
||||||
|
if (tStartEncode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
|
if (tEncodeCStr(pCoder, pReq->name) < 0) return -1;
|
||||||
|
if (tEncodeI64(pCoder, pReq->suid) < 0) return -1;
|
||||||
|
|
||||||
|
tEndEncode(pCoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDecodeSVDropStbReq(SCoder *pCoder, SVDropStbReq *pReq) {
|
||||||
|
if (tStartDecode(pCoder) < 0) return -1;
|
||||||
|
|
||||||
|
if (tDecodeCStr(pCoder, &pReq->name) < 0) return -1;
|
||||||
|
if (tDecodeI64(pCoder, &pReq->suid) < 0) return -1;
|
||||||
|
|
||||||
|
tEndDecode(pCoder);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,33 +15,83 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "tmsgcb.h"
|
#include "tmsgcb.h"
|
||||||
|
#include "taoserror.h"
|
||||||
|
|
||||||
static SMsgCb tsDefaultMsgCb;
|
static SMsgCb tsDefaultMsgCb;
|
||||||
|
|
||||||
void tmsgSetDefaultMsgCb(const SMsgCb* pMsgCb) { tsDefaultMsgCb = *pMsgCb; }
|
void tmsgSetDefaultMsgCb(const SMsgCb* pMsgCb) { tsDefaultMsgCb = *pMsgCb; }
|
||||||
|
|
||||||
int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pReq) {
|
int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pReq) {
|
||||||
return (*pMsgCb->queueFps[qtype])(pMsgCb->pWrapper, pReq);
|
PutToQueueFp fp = pMsgCb->queueFps[qtype];
|
||||||
|
if (fp != NULL) {
|
||||||
|
return (*fp)(pMsgCb->pWrapper, pReq);
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype) {
|
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype) {
|
||||||
return (*pMsgCb->qsizeFp)(pMsgCb->pWrapper, vgId, qtype);
|
GetQueueSizeFp fp = pMsgCb->qsizeFp;
|
||||||
|
if (fp != NULL) {
|
||||||
|
return (*fp)(pMsgCb->pWrapper, vgId, qtype);
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tmsgSendReq(const SMsgCb* pMsgCb, const SEpSet* epSet, SRpcMsg* pReq) {
|
int32_t tmsgSendReq(const SMsgCb* pMsgCb, const SEpSet* epSet, SRpcMsg* pReq) {
|
||||||
return (*pMsgCb->sendReqFp)(pMsgCb->pWrapper, epSet, pReq);
|
SendReqFp fp = pMsgCb->sendReqFp;
|
||||||
|
if (fp != NULL) {
|
||||||
|
return (*fp)(pMsgCb->pWrapper, epSet, pReq);
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmsgSendRsp(const SRpcMsg* pRsp) { return (*tsDefaultMsgCb.sendRspFp)(tsDefaultMsgCb.pWrapper, pRsp); }
|
void tmsgSendRsp(const SRpcMsg* pRsp) {
|
||||||
|
SendRspFp fp = tsDefaultMsgCb.sendRspFp;
|
||||||
|
if (fp != NULL) {
|
||||||
|
return (*fp)(tsDefaultMsgCb.pWrapper, pRsp);
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tmsgSendRedirectRsp(const SRpcMsg* pRsp, const SEpSet* pNewEpSet) {
|
||||||
|
SendRedirectRspFp fp = tsDefaultMsgCb.sendRedirectRspFp;
|
||||||
|
if (fp != NULL) {
|
||||||
|
(*fp)(tsDefaultMsgCb.pWrapper, pRsp, pNewEpSet);
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void tmsgRegisterBrokenLinkArg(const SMsgCb* pMsgCb, SRpcMsg* pMsg) {
|
void tmsgRegisterBrokenLinkArg(const SMsgCb* pMsgCb, SRpcMsg* pMsg) {
|
||||||
(*pMsgCb->registerBrokenLinkArgFp)(pMsgCb->pWrapper, pMsg);
|
RegisterBrokenLinkArgFp fp = pMsgCb->registerBrokenLinkArgFp;
|
||||||
|
if (fp != NULL) {
|
||||||
|
(*fp)(pMsgCb->pWrapper, pMsg);
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmsgReleaseHandle(void* handle, int8_t type) {
|
void tmsgReleaseHandle(void* handle, int8_t type) {
|
||||||
(*tsDefaultMsgCb.releaseHandleFp)(tsDefaultMsgCb.pWrapper, handle, type);
|
ReleaseHandleFp fp = tsDefaultMsgCb.releaseHandleFp;
|
||||||
|
if (fp != NULL) {
|
||||||
|
(*fp)(tsDefaultMsgCb.pWrapper, handle, type);
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmsgReportStartup(const char* name, const char* desc) {
|
void tmsgReportStartup(const char* name, const char* desc) {
|
||||||
(*tsDefaultMsgCb.reportStartupFp)(tsDefaultMsgCb.pWrapper, name, desc);
|
ReportStartup fp = tsDefaultMsgCb.reportStartupFp;
|
||||||
|
if (fp != NULL && tsDefaultMsgCb.pWrapper != NULL) {
|
||||||
|
(*fp)(tsDefaultMsgCb.pWrapper, name, desc);
|
||||||
|
} else {
|
||||||
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -72,6 +72,7 @@ static void dmProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpSe
|
||||||
NodeMsgFp msgFp = NULL;
|
NodeMsgFp msgFp = NULL;
|
||||||
uint16_t msgType = pRpc->msgType;
|
uint16_t msgType = pRpc->msgType;
|
||||||
bool needRelease = false;
|
bool needRelease = false;
|
||||||
|
bool isReq = msgType & 1U;
|
||||||
|
|
||||||
if (pEpSet && pEpSet->numOfEps > 0 && msgType == TDMT_MND_STATUS_RSP) {
|
if (pEpSet && pEpSet->numOfEps > 0 && msgType == TDMT_MND_STATUS_RSP) {
|
||||||
dmSetMnodeEpSet(pWrapper->pDnode, pEpSet);
|
dmSetMnodeEpSet(pWrapper->pDnode, pEpSet);
|
||||||
|
|
@ -85,13 +86,13 @@ static void dmProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpSe
|
||||||
if (dmBuildMsg(pMsg, pRpc) != 0) goto _OVER;
|
if (dmBuildMsg(pMsg, pRpc) != 0) goto _OVER;
|
||||||
|
|
||||||
if (pWrapper->procType == DND_PROC_SINGLE) {
|
if (pWrapper->procType == DND_PROC_SINGLE) {
|
||||||
dTrace("msg:%p, is created, type:%s handle:%p user:%s", pMsg, TMSG_INFO(msgType), pRpc->handle, pMsg->user);
|
dTrace("msg:%p, created, type:%s handle:%p user:%s", pMsg, TMSG_INFO(msgType), pRpc->handle, pMsg->user);
|
||||||
code = (*msgFp)(pWrapper, pMsg);
|
code = (*msgFp)(pWrapper, pMsg);
|
||||||
} else if (pWrapper->procType == DND_PROC_PARENT) {
|
} else if (pWrapper->procType == DND_PROC_PARENT) {
|
||||||
dTrace("msg:%p, is created and put into child queue, type:%s handle:%p user:%s", pMsg, TMSG_INFO(msgType),
|
dTrace("msg:%p, created and put into child queue, type:%s handle:%p code:0x%04x user:%s contLen:%d", pMsg,
|
||||||
pRpc->handle, pMsg->user);
|
TMSG_INFO(msgType), pRpc->handle, pMsg->rpcMsg.code & 0XFFFF, pMsg->user, pRpc->contLen);
|
||||||
code = taosProcPutToChildQ(pWrapper->procObj, pMsg, sizeof(SNodeMsg), pRpc->pCont, pRpc->contLen, pRpc->handle,
|
code = taosProcPutToChildQ(pWrapper->procObj, pMsg, sizeof(SNodeMsg), pRpc->pCont, pRpc->contLen,
|
||||||
pRpc->refId, PROC_FUNC_REQ);
|
(isReq && (pMsg->rpcMsg.code == 0)) ? pRpc->handle : NULL, pRpc->refId, PROC_FUNC_REQ);
|
||||||
} else {
|
} else {
|
||||||
dTrace("msg:%p, should not processed in child process, handle:%p user:%s", pMsg, pRpc->handle, pMsg->user);
|
dTrace("msg:%p, should not processed in child process, handle:%p user:%s", pMsg, pRpc->handle, pMsg->user);
|
||||||
ASSERT(1);
|
ASSERT(1);
|
||||||
|
|
@ -100,12 +101,13 @@ static void dmProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpSe
|
||||||
_OVER:
|
_OVER:
|
||||||
if (code == 0) {
|
if (code == 0) {
|
||||||
if (pWrapper->procType == DND_PROC_PARENT) {
|
if (pWrapper->procType == DND_PROC_PARENT) {
|
||||||
dTrace("msg:%p, is freed in parent process", pMsg);
|
dTrace("msg:%p, freed in parent process", pMsg);
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
rpcFreeCont(pRpc->pCont);
|
rpcFreeCont(pRpc->pCont);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dError("msg:%p, type:%s failed to process since 0x%04x:%s", pMsg, TMSG_INFO(msgType), code & 0XFFFF, terrstr());
|
dError("msg:%p, type:%s handle:%p failed to process since 0x%04x:%s", pMsg, TMSG_INFO(msgType), pRpc->handle,
|
||||||
|
code & 0XFFFF, terrstr());
|
||||||
if (msgType & 1U) {
|
if (msgType & 1U) {
|
||||||
if (terrno != 0) code = terrno;
|
if (terrno != 0) code = terrno;
|
||||||
if (code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_NODE_OFFLINE) {
|
if (code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_NODE_OFFLINE) {
|
||||||
|
|
@ -128,10 +130,10 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
static void dmProcessMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
SDnodeTrans * pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
tmsg_t msgType = pMsg->msgType;
|
tmsg_t msgType = pMsg->msgType;
|
||||||
bool isReq = msgType & 1u;
|
bool isReq = msgType & 1u;
|
||||||
SMsgHandle * pHandle = &pTrans->msgHandles[TMSG_INDEX(msgType)];
|
SMsgHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(msgType)];
|
||||||
SMgmtWrapper *pWrapper = pHandle->pNdWrapper;
|
SMgmtWrapper *pWrapper = pHandle->pNdWrapper;
|
||||||
|
|
||||||
if (msgType == TDMT_DND_SERVER_STATUS) {
|
if (msgType == TDMT_DND_SERVER_STATUS) {
|
||||||
|
|
@ -254,8 +256,17 @@ static void dmSendRpcRedirectRsp(SDnode *pDnode, const SRpcMsg *pReq) {
|
||||||
|
|
||||||
epSet.eps[i].port = htons(epSet.eps[i].port);
|
epSet.eps[i].port = htons(epSet.eps[i].port);
|
||||||
}
|
}
|
||||||
|
SRpcMsg resp;
|
||||||
|
SMEpSet msg = {.epSet = epSet};
|
||||||
|
int32_t len = tSerializeSMEpSet(NULL, 0, &msg);
|
||||||
|
resp.pCont = rpcMallocCont(len);
|
||||||
|
resp.contLen = len;
|
||||||
|
tSerializeSMEpSet(resp.pCont, len, &msg);
|
||||||
|
|
||||||
rpcSendRedirectRsp(pReq->handle, &epSet);
|
resp.code = TSDB_CODE_RPC_REDIRECT;
|
||||||
|
resp.handle = pReq->handle;
|
||||||
|
resp.refId = pReq->refId;
|
||||||
|
rpcSendResponse(&resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dmSendRpcRsp(SDnode *pDnode, const SRpcMsg *pRsp) {
|
static inline void dmSendRpcRsp(SDnode *pDnode, const SRpcMsg *pRsp) {
|
||||||
|
|
@ -309,6 +320,37 @@ static inline void dmSendRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void dmSendRedirectRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp, const SEpSet *pNewEpSet) {
|
||||||
|
ASSERT(pRsp->code == TSDB_CODE_RPC_REDIRECT);
|
||||||
|
ASSERT(pRsp->pCont == NULL);
|
||||||
|
if (pWrapper->procType != DND_PROC_CHILD) {
|
||||||
|
SRpcMsg resp = {0};
|
||||||
|
SMEpSet msg = {.epSet = *pNewEpSet};
|
||||||
|
int32_t len = tSerializeSMEpSet(NULL, 0, &msg);
|
||||||
|
resp.pCont = rpcMallocCont(len);
|
||||||
|
resp.contLen = len;
|
||||||
|
tSerializeSMEpSet(resp.pCont, len, &msg);
|
||||||
|
|
||||||
|
resp.code = TSDB_CODE_RPC_REDIRECT;
|
||||||
|
resp.handle = pRsp->handle;
|
||||||
|
resp.refId = pRsp->refId;
|
||||||
|
rpcSendResponse(&resp);
|
||||||
|
} else {
|
||||||
|
taosProcPutToParentQ(pWrapper->procObj, pRsp, sizeof(SRpcMsg), pRsp->pCont, pRsp->contLen, PROC_FUNC_RSP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static inline void dmSendRedirectRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp, const SEpSet *pNewEpSet) {
|
||||||
|
ASSERT(pRsp->code == TSDB_CODE_RPC_REDIRECT);
|
||||||
|
if (pWrapper->procType != DND_PROC_CHILD) {
|
||||||
|
rpcSendRedirectRsp(pRsp->handle, pNewEpSet);
|
||||||
|
} else {
|
||||||
|
taosProcPutToParentQ(pWrapper->procObj, pRsp, sizeof(SRpcMsg), pRsp->pCont, pRsp->contLen, PROC_FUNC_RSP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline void dmRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
|
static inline void dmRegisterBrokenLinkArg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
|
||||||
if (pWrapper->procType != DND_PROC_CHILD) {
|
if (pWrapper->procType != DND_PROC_CHILD) {
|
||||||
rpcRegisterBrokenLinkArg(pMsg);
|
rpcRegisterBrokenLinkArg(pMsg);
|
||||||
|
|
@ -350,29 +392,31 @@ static void dmConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t
|
||||||
|
|
||||||
static void dmConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen,
|
static void dmConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen,
|
||||||
EProcFuncType ftype) {
|
EProcFuncType ftype) {
|
||||||
|
int32_t code = pMsg->code & 0xFFFF;
|
||||||
pMsg->pCont = pCont;
|
pMsg->pCont = pCont;
|
||||||
dTrace("msg:%p, get from parent queue, ftype:%d handle:%p code:0x%04x mtype:%d, app:%p", pMsg, ftype, pMsg->handle,
|
|
||||||
pMsg->code & 0xFFFF, pMsg->msgType, pMsg->ahandle);
|
|
||||||
|
|
||||||
switch (ftype) {
|
if (ftype == PROC_FUNC_REQ) {
|
||||||
case PROC_FUNC_REGIST:
|
dTrace("msg:%p, get from parent queue, send req:%s handle:%p code:0x%04x, app:%p", pMsg, TMSG_INFO(pMsg->msgType),
|
||||||
|
pMsg->handle, code, pMsg->ahandle);
|
||||||
|
dmSendRpcReq(pWrapper->pDnode, (SEpSet *)((char *)pMsg + sizeof(SRpcMsg)), pMsg);
|
||||||
|
} else if (ftype == PROC_FUNC_RSP) {
|
||||||
|
dTrace("msg:%p, get from parent queue, rsp handle:%p code:0x%04x, app:%p", pMsg, pMsg->handle, code, pMsg->ahandle);
|
||||||
|
pMsg->refId = taosProcRemoveHandle(pWrapper->procObj, pMsg->handle);
|
||||||
|
dmSendRpcRsp(pWrapper->pDnode, pMsg);
|
||||||
|
} else if (ftype == PROC_FUNC_REGIST) {
|
||||||
|
dTrace("msg:%p, get from parent queue, regist handle:%p code:0x%04x, app:%p", pMsg, pMsg->handle, code,
|
||||||
|
pMsg->ahandle);
|
||||||
rpcRegisterBrokenLinkArg(pMsg);
|
rpcRegisterBrokenLinkArg(pMsg);
|
||||||
break;
|
} else if (ftype == PROC_FUNC_RELEASE) {
|
||||||
case PROC_FUNC_RELEASE:
|
dTrace("msg:%p, get from parent queue, release handle:%p code:0x%04x, app:%p", pMsg, pMsg->handle, code,
|
||||||
|
pMsg->ahandle);
|
||||||
taosProcRemoveHandle(pWrapper->procObj, pMsg->handle);
|
taosProcRemoveHandle(pWrapper->procObj, pMsg->handle);
|
||||||
rpcReleaseHandle(pMsg->handle, (int8_t)pMsg->code);
|
rpcReleaseHandle(pMsg->handle, (int8_t)pMsg->code);
|
||||||
rpcFreeCont(pCont);
|
rpcFreeCont(pCont);
|
||||||
break;
|
} else {
|
||||||
case PROC_FUNC_REQ:
|
dError("msg:%p, invalid ftype:%d while get from parent queue, handle:%p", pMsg, ftype, pMsg->handle);
|
||||||
dmSendRpcReq(pWrapper->pDnode, (SEpSet *)((char *)pMsg + sizeof(SRpcMsg)), pMsg);
|
|
||||||
break;
|
|
||||||
case PROC_FUNC_RSP:
|
|
||||||
pMsg->refId = taosProcRemoveHandle(pWrapper->procObj, pMsg->handle);
|
|
||||||
dmSendRpcRsp(pWrapper->pDnode, pMsg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(pMsg);
|
taosMemoryFree(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -393,6 +437,14 @@ SProcCfg dmGenProcCfg(SMgmtWrapper *pWrapper) {
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool rpcRfp(int32_t code) {
|
||||||
|
if (code == TSDB_CODE_RPC_REDIRECT) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t dmInitClient(SDnode *pDnode) {
|
static int32_t dmInitClient(SDnode *pDnode) {
|
||||||
SDnodeTrans *pTrans = &pDnode->trans;
|
SDnodeTrans *pTrans = &pDnode->trans;
|
||||||
|
|
||||||
|
|
@ -407,6 +459,7 @@ static int32_t dmInitClient(SDnode *pDnode) {
|
||||||
rpcInit.ckey = INTERNAL_CKEY;
|
rpcInit.ckey = INTERNAL_CKEY;
|
||||||
rpcInit.spi = 1;
|
rpcInit.spi = 1;
|
||||||
rpcInit.parent = pDnode;
|
rpcInit.parent = pDnode;
|
||||||
|
rpcInit.rfp = rpcRfp;
|
||||||
|
|
||||||
char pass[TSDB_PASSWORD_LEN + 1] = {0};
|
char pass[TSDB_PASSWORD_LEN + 1] = {0};
|
||||||
taosEncryptPass_c((uint8_t *)(INTERNAL_SECRET), strlen(INTERNAL_SECRET), pass);
|
taosEncryptPass_c((uint8_t *)(INTERNAL_SECRET), strlen(INTERNAL_SECRET), pass);
|
||||||
|
|
@ -464,7 +517,7 @@ static inline int32_t dmRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *s
|
||||||
SAuthReq authReq = {0};
|
SAuthReq authReq = {0};
|
||||||
tstrncpy(authReq.user, user, TSDB_USER_LEN);
|
tstrncpy(authReq.user, user, TSDB_USER_LEN);
|
||||||
int32_t contLen = tSerializeSAuthReq(NULL, 0, &authReq);
|
int32_t contLen = tSerializeSAuthReq(NULL, 0, &authReq);
|
||||||
void * pReq = rpcMallocCont(contLen);
|
void *pReq = rpcMallocCont(contLen);
|
||||||
tSerializeSAuthReq(pReq, contLen, &authReq);
|
tSerializeSAuthReq(pReq, contLen, &authReq);
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {.pCont = pReq, .contLen = contLen, .msgType = TDMT_MND_AUTH, .ahandle = (void *)9528};
|
SRpcMsg rpcMsg = {.pCont = pReq, .contLen = contLen, .msgType = TDMT_MND_AUTH, .ahandle = (void *)9528};
|
||||||
|
|
@ -538,6 +591,7 @@ SMsgCb dmGetMsgcb(SMgmtWrapper *pWrapper) {
|
||||||
SMsgCb msgCb = {
|
SMsgCb msgCb = {
|
||||||
.sendReqFp = dmSendReq,
|
.sendReqFp = dmSendReq,
|
||||||
.sendRspFp = dmSendRsp,
|
.sendRspFp = dmSendRsp,
|
||||||
|
.sendRedirectRspFp = dmSendRedirectRsp,
|
||||||
.registerBrokenLinkArgFp = dmRegisterBrokenLinkArg,
|
.registerBrokenLinkArgFp = dmRegisterBrokenLinkArg,
|
||||||
.releaseHandleFp = dmReleaseHandle,
|
.releaseHandleFp = dmReleaseHandle,
|
||||||
.reportStartupFp = dmReportStartupByWrapper,
|
.reportStartupFp = dmReportStartupByWrapper,
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,9 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||||
pCfg->tsdbCfg.keep2 = 3650;
|
pCfg->tsdbCfg.keep2 = 3650;
|
||||||
pCfg->tsdbCfg.keep0 = 3650;
|
pCfg->tsdbCfg.keep0 = 3650;
|
||||||
pCfg->tsdbCfg.keep1 = 3650;
|
pCfg->tsdbCfg.keep1 = 3650;
|
||||||
pCfg->tsdbCfg.retentions = pCreate->pRetensions;
|
for (size_t i = 0; i < taosArrayGetSize(pCreate->pRetensions); ++i) {
|
||||||
|
memcpy(&pCfg->tsdbCfg.retentions[i], taosArrayGet(pCreate->pRetensions, i), sizeof(SRetention));
|
||||||
|
}
|
||||||
pCfg->walCfg.vgId = pCreate->vgId;
|
pCfg->walCfg.vgId = pCreate->vgId;
|
||||||
pCfg->hashBegin = pCreate->hashBegin;
|
pCfg->hashBegin = pCreate->hashBegin;
|
||||||
pCfg->hashEnd = pCreate->hashEnd;
|
pCfg->hashEnd = pCreate->hashEnd;
|
||||||
|
|
@ -282,6 +284,7 @@ void vmInitMsgHandle(SMgmtWrapper *pWrapper) {
|
||||||
dmSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA, vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_CREATE_SMA, vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dmSetMsgHandle(pWrapper, TDMT_VND_CANCEL_SMA, vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_CANCEL_SMA, vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dmSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA, vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_DROP_SMA, vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
|
dmSetMsgHandle(pWrapper, TDMT_VND_SUBMIT_RSMA, vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_VG_CHANGE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_MQ_VG_CHANGE, (NodeMsgFp)vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
dmSetMsgHandle(pWrapper, TDMT_VND_CONSUME, vmProcessFetchMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_CONSUME, vmProcessFetchMsg, DEFAULT_HANDLE);
|
||||||
dmSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY, vmProcessWriteMsg, DEFAULT_HANDLE);
|
dmSetMsgHandle(pWrapper, TDMT_VND_TASK_DEPLOY, vmProcessWriteMsg, DEFAULT_HANDLE);
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
||||||
// sync integration response
|
// sync integration response
|
||||||
for (int i = 0; i < taosArrayGetSize(pArray); i++) {
|
for (int i = 0; i < taosArrayGetSize(pArray); i++) {
|
||||||
SNodeMsg *pMsg;
|
SNodeMsg *pMsg;
|
||||||
SRpcMsg * pRpc;
|
SRpcMsg *pRpc;
|
||||||
|
|
||||||
pMsg = *(SNodeMsg **)taosArrayGet(pArray, i);
|
pMsg = *(SNodeMsg **)taosArrayGet(pArray, i);
|
||||||
pRpc = &pMsg->rpcMsg;
|
pRpc = &pMsg->rpcMsg;
|
||||||
|
|
@ -149,8 +149,15 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
||||||
|
|
||||||
int32_t ret = syncPropose(vnodeGetSyncHandle(pVnode->pImpl), pRpc, false);
|
int32_t ret = syncPropose(vnodeGetSyncHandle(pVnode->pImpl), pRpc, false);
|
||||||
if (ret == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
if (ret == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
||||||
rsp.code = TSDB_CODE_SYN_NOT_LEADER;
|
// rsp.code = TSDB_CODE_SYN_NOT_LEADER;
|
||||||
tmsgSendRsp(&rsp);
|
// tmsgSendRsp(&rsp);
|
||||||
|
dTrace("syncPropose not leader redirect, vgId:%d ", syncGetVgId(vnodeGetSyncHandle(pVnode->pImpl)));
|
||||||
|
rsp.code = TSDB_CODE_RPC_REDIRECT;
|
||||||
|
SEpSet newEpSet;
|
||||||
|
syncGetEpSet(vnodeGetSyncHandle(pVnode->pImpl), &newEpSet);
|
||||||
|
newEpSet.inUse = (newEpSet.inUse + 1) % newEpSet.numOfEps;
|
||||||
|
tmsgSendRedirectRsp(&rsp, &newEpSet);
|
||||||
|
|
||||||
} else if (ret == TAOS_SYNC_PROPOSE_OTHER_ERROR) {
|
} else if (ret == TAOS_SYNC_PROPOSE_OTHER_ERROR) {
|
||||||
rsp.code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
rsp.code = TSDB_CODE_SYN_INTERNAL_ERROR;
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
|
|
@ -175,7 +182,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
||||||
|
|
||||||
static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
SVnodeObj *pVnode = pInfo->ahandle;
|
SVnodeObj *pVnode = pInfo->ahandle;
|
||||||
SNodeMsg * pMsg = NULL;
|
SNodeMsg *pMsg = NULL;
|
||||||
SRpcMsg rsp;
|
SRpcMsg rsp;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||||
|
|
@ -218,7 +225,7 @@ static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
||||||
|
|
||||||
static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
SVnodeObj *pVnode = pInfo->ahandle;
|
SVnodeObj *pVnode = pInfo->ahandle;
|
||||||
SNodeMsg * pMsg = NULL;
|
SNodeMsg *pMsg = NULL;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||||
taosGetQitem(qall, (void **)&pMsg);
|
taosGetQitem(qall, (void **)&pMsg);
|
||||||
|
|
@ -231,7 +238,7 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
|
||||||
|
|
||||||
static void vmProcessMergeQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
static void vmProcessMergeQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||||
SVnodeObj *pVnode = pInfo->ahandle;
|
SVnodeObj *pVnode = pInfo->ahandle;
|
||||||
SNodeMsg * pMsg = NULL;
|
SNodeMsg *pMsg = NULL;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||||
taosGetQitem(qall, (void **)&pMsg);
|
taosGetQitem(qall, (void **)&pMsg);
|
||||||
|
|
@ -248,7 +255,7 @@ static void vmProcessMergeQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueType qtype) {
|
static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueType qtype) {
|
||||||
SRpcMsg * pRpc = &pMsg->rpcMsg;
|
SRpcMsg *pRpc = &pMsg->rpcMsg;
|
||||||
SMsgHead *pHead = pRpc->pCont;
|
SMsgHead *pHead = pRpc->pCont;
|
||||||
pHead->contLen = ntohl(pHead->contLen);
|
pHead->contLen = ntohl(pHead->contLen);
|
||||||
pHead->vgId = ntohl(pHead->vgId);
|
pHead->vgId = ntohl(pHead->vgId);
|
||||||
|
|
@ -262,23 +269,23 @@ static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueTyp
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
switch (qtype) {
|
switch (qtype) {
|
||||||
case QUERY_QUEUE:
|
case QUERY_QUEUE:
|
||||||
dTrace("msg:%p, will be written into vnode-query queue", pMsg);
|
dTrace("msg:%p, type:%s will be written into vnode-query queue", pMsg, TMSG_INFO(pRpc->msgType));
|
||||||
taosWriteQitem(pVnode->pQueryQ, pMsg);
|
taosWriteQitem(pVnode->pQueryQ, pMsg);
|
||||||
break;
|
break;
|
||||||
case FETCH_QUEUE:
|
case FETCH_QUEUE:
|
||||||
dTrace("msg:%p, will be written into vnode-fetch queue", pMsg);
|
dTrace("msg:%p, type:%s will be written into vnode-fetch queue", pMsg, TMSG_INFO(pRpc->msgType));
|
||||||
taosWriteQitem(pVnode->pFetchQ, pMsg);
|
taosWriteQitem(pVnode->pFetchQ, pMsg);
|
||||||
break;
|
break;
|
||||||
case WRITE_QUEUE:
|
case WRITE_QUEUE:
|
||||||
dTrace("msg:%p, will be written into vnode-write queue", pMsg);
|
dTrace("msg:%p, type:%s will be written into vnode-write queue", pMsg, TMSG_INFO(pRpc->msgType));
|
||||||
taosWriteQitem(pVnode->pWriteQ, pMsg);
|
taosWriteQitem(pVnode->pWriteQ, pMsg);
|
||||||
break;
|
break;
|
||||||
case SYNC_QUEUE:
|
case SYNC_QUEUE:
|
||||||
dTrace("msg:%p, will be written into vnode-sync queue", pMsg);
|
dTrace("msg:%p, type:%s will be written into vnode-sync queue", pMsg, TMSG_INFO(pRpc->msgType));
|
||||||
taosWriteQitem(pVnode->pSyncQ, pMsg);
|
taosWriteQitem(pVnode->pSyncQ, pMsg);
|
||||||
break;
|
break;
|
||||||
case MERGE_QUEUE:
|
case MERGE_QUEUE:
|
||||||
dTrace("msg:%p, will be written into vnode-merge queue", pMsg);
|
dTrace("msg:%p, type:%s will be written into vnode-merge queue", pMsg, TMSG_INFO(pRpc->msgType));
|
||||||
taosWriteQitem(pVnode->pMergeQ, pMsg);
|
taosWriteQitem(pVnode->pMergeQ, pMsg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -317,7 +324,7 @@ int32_t vmProcessMergeMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
int32_t vmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
SVnodesMgmt * pMgmt = pWrapper->pMgmt;
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
SSingleWorker *pWorker = &pMgmt->mgmtWorker;
|
SSingleWorker *pWorker = &pMgmt->mgmtWorker;
|
||||||
dTrace("msg:%p, will be written to vnode-mgmt queue, worker:%s", pMsg, pWorker->name);
|
dTrace("msg:%p, will be written to vnode-mgmt queue, worker:%s", pMsg, pWorker->name);
|
||||||
taosWriteQitem(pWorker->queue, pMsg);
|
taosWriteQitem(pWorker->queue, pMsg);
|
||||||
|
|
@ -325,7 +332,7 @@ int32_t vmProcessMgmtMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vmProcessMonitorMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
int32_t vmProcessMonitorMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
SVnodesMgmt * pMgmt = pWrapper->pMgmt;
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
SSingleWorker *pWorker = &pMgmt->monitorWorker;
|
SSingleWorker *pWorker = &pMgmt->monitorWorker;
|
||||||
|
|
||||||
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
||||||
|
|
@ -335,7 +342,7 @@ int32_t vmProcessMonitorMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
|
||||||
|
|
||||||
static int32_t vmPutRpcMsgToQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, EQueueType qtype) {
|
static int32_t vmPutRpcMsgToQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, EQueueType qtype) {
|
||||||
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
SVnodesMgmt *pMgmt = pWrapper->pMgmt;
|
||||||
SMsgHead * pHead = pRpc->pCont;
|
SMsgHead *pHead = pRpc->pCont;
|
||||||
|
|
||||||
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId);
|
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId);
|
||||||
if (pVnode == NULL) return -1;
|
if (pVnode == NULL) return -1;
|
||||||
|
|
|
||||||
|
|
@ -57,11 +57,11 @@ typedef enum {
|
||||||
TRN_STAGE_PREPARE = 0,
|
TRN_STAGE_PREPARE = 0,
|
||||||
TRN_STAGE_REDO_LOG = 1,
|
TRN_STAGE_REDO_LOG = 1,
|
||||||
TRN_STAGE_REDO_ACTION = 2,
|
TRN_STAGE_REDO_ACTION = 2,
|
||||||
TRN_STAGE_COMMIT = 3,
|
TRN_STAGE_ROLLBACK = 3,
|
||||||
TRN_STAGE_COMMIT_LOG = 4,
|
TRN_STAGE_UNDO_ACTION = 4,
|
||||||
TRN_STAGE_UNDO_ACTION = 5,
|
TRN_STAGE_UNDO_LOG = 5,
|
||||||
TRN_STAGE_UNDO_LOG = 6,
|
TRN_STAGE_COMMIT = 6,
|
||||||
TRN_STAGE_ROLLBACK = 7,
|
TRN_STAGE_COMMIT_LOG = 7,
|
||||||
TRN_STAGE_FINISHED = 8
|
TRN_STAGE_FINISHED = 8
|
||||||
} ETrnStage;
|
} ETrnStage;
|
||||||
|
|
||||||
|
|
@ -72,6 +72,7 @@ typedef enum {
|
||||||
TRN_TYPE_DROP_USER = 1003,
|
TRN_TYPE_DROP_USER = 1003,
|
||||||
TRN_TYPE_CREATE_FUNC = 1004,
|
TRN_TYPE_CREATE_FUNC = 1004,
|
||||||
TRN_TYPE_DROP_FUNC = 1005,
|
TRN_TYPE_DROP_FUNC = 1005,
|
||||||
|
|
||||||
TRN_TYPE_CREATE_SNODE = 1006,
|
TRN_TYPE_CREATE_SNODE = 1006,
|
||||||
TRN_TYPE_DROP_SNODE = 1007,
|
TRN_TYPE_DROP_SNODE = 1007,
|
||||||
TRN_TYPE_CREATE_QNODE = 1008,
|
TRN_TYPE_CREATE_QNODE = 1008,
|
||||||
|
|
@ -91,10 +92,12 @@ typedef enum {
|
||||||
TRN_TYPE_CONSUMER_LOST = 1022,
|
TRN_TYPE_CONSUMER_LOST = 1022,
|
||||||
TRN_TYPE_CONSUMER_RECOVER = 1023,
|
TRN_TYPE_CONSUMER_RECOVER = 1023,
|
||||||
TRN_TYPE_BASIC_SCOPE_END,
|
TRN_TYPE_BASIC_SCOPE_END,
|
||||||
|
|
||||||
TRN_TYPE_GLOBAL_SCOPE = 2000,
|
TRN_TYPE_GLOBAL_SCOPE = 2000,
|
||||||
TRN_TYPE_CREATE_DNODE = 2001,
|
TRN_TYPE_CREATE_DNODE = 2001,
|
||||||
TRN_TYPE_DROP_DNODE = 2002,
|
TRN_TYPE_DROP_DNODE = 2002,
|
||||||
TRN_TYPE_GLOBAL_SCOPE_END,
|
TRN_TYPE_GLOBAL_SCOPE_END,
|
||||||
|
|
||||||
TRN_TYPE_DB_SCOPE = 3000,
|
TRN_TYPE_DB_SCOPE = 3000,
|
||||||
TRN_TYPE_CREATE_DB = 3001,
|
TRN_TYPE_CREATE_DB = 3001,
|
||||||
TRN_TYPE_ALTER_DB = 3002,
|
TRN_TYPE_ALTER_DB = 3002,
|
||||||
|
|
@ -102,6 +105,7 @@ typedef enum {
|
||||||
TRN_TYPE_SPLIT_VGROUP = 3004,
|
TRN_TYPE_SPLIT_VGROUP = 3004,
|
||||||
TRN_TYPE_MERGE_VGROUP = 3015,
|
TRN_TYPE_MERGE_VGROUP = 3015,
|
||||||
TRN_TYPE_DB_SCOPE_END,
|
TRN_TYPE_DB_SCOPE_END,
|
||||||
|
|
||||||
TRN_TYPE_STB_SCOPE = 4000,
|
TRN_TYPE_STB_SCOPE = 4000,
|
||||||
TRN_TYPE_CREATE_STB = 4001,
|
TRN_TYPE_CREATE_STB = 4001,
|
||||||
TRN_TYPE_ALTER_STB = 4002,
|
TRN_TYPE_ALTER_STB = 4002,
|
||||||
|
|
@ -131,7 +135,7 @@ typedef struct {
|
||||||
int32_t id;
|
int32_t id;
|
||||||
ETrnStage stage;
|
ETrnStage stage;
|
||||||
ETrnPolicy policy;
|
ETrnPolicy policy;
|
||||||
ETrnType transType;
|
ETrnType type;
|
||||||
int32_t code;
|
int32_t code;
|
||||||
int32_t failedTimes;
|
int32_t failedTimes;
|
||||||
void* rpcHandle;
|
void* rpcHandle;
|
||||||
|
|
@ -517,6 +521,7 @@ void* tDecodeSMqConsumerEp(const void* buf, SMqConsumerEp* pEp);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
|
int64_t dbUid;
|
||||||
int32_t vgNum;
|
int32_t vgNum;
|
||||||
int8_t subType;
|
int8_t subType;
|
||||||
int8_t withTbName;
|
int8_t withTbName;
|
||||||
|
|
@ -553,9 +558,8 @@ int32_t tEncodeSMqSubActionLogObj(void** buf, const SMqSubActionLogO
|
||||||
void* tDecodeSMqSubActionLogObj(const void* buf, SMqSubActionLogObj* pLog);
|
void* tDecodeSMqSubActionLogObj(const void* buf, SMqSubActionLogObj* pLog);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const SMqSubscribeObj* pOldSub;
|
int32_t oldConsumerNum;
|
||||||
const SMqTopicObj* pTopic;
|
const SMqRebInfo* pRebInfo;
|
||||||
const SMqRebSubscribe* pRebInfo;
|
|
||||||
} SMqRebInputObj;
|
} SMqRebInputObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ typedef int32_t (*MndInitFp)(SMnode *pMnode);
|
||||||
typedef void (*MndCleanupFp)(SMnode *pMnode);
|
typedef void (*MndCleanupFp)(SMnode *pMnode);
|
||||||
typedef int32_t (*ShowRetrieveFp)(SNodeMsg *pMsg, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
typedef int32_t (*ShowRetrieveFp)(SNodeMsg *pMsg, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
typedef void (*ShowFreeIterFp)(SMnode *pMnode, void *pIter);
|
typedef void (*ShowFreeIterFp)(SMnode *pMnode, void *pIter);
|
||||||
typedef struct SQWorkerMgmt SQHandle;
|
typedef struct SQWorker SQHandle;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ void mndReleaseTopic(SMnode *pMnode, SMqTopicObj *pTopic);
|
||||||
SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic);
|
SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic);
|
||||||
SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw);
|
SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw);
|
||||||
|
|
||||||
|
int32_t mndDropTopicByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@ typedef void (*TransCbFp)(SMnode *pMnode, void *param, int32_t paramLen);
|
||||||
|
|
||||||
int32_t mndInitTrans(SMnode *pMnode);
|
int32_t mndInitTrans(SMnode *pMnode);
|
||||||
void mndCleanupTrans(SMnode *pMnode);
|
void mndCleanupTrans(SMnode *pMnode);
|
||||||
|
STrans *mndAcquireTrans(SMnode *pMnode, int32_t transId);
|
||||||
|
void mndReleaseTrans(SMnode *pMnode, STrans *pTrans);
|
||||||
|
|
||||||
STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnType type, const SRpcMsg *pReq);
|
STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnType type, const SRpcMsg *pReq);
|
||||||
void mndTransDrop(STrans *pTrans);
|
void mndTransDrop(STrans *pTrans);
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,12 @@ extern "C" {
|
||||||
|
|
||||||
int32_t mndInitUser(SMnode *pMnode);
|
int32_t mndInitUser(SMnode *pMnode);
|
||||||
void mndCleanupUser(SMnode *pMnode);
|
void mndCleanupUser(SMnode *pMnode);
|
||||||
SUserObj *mndAcquireUser(SMnode *pMnode, char *userName);
|
SUserObj *mndAcquireUser(SMnode *pMnode, const char *userName);
|
||||||
void mndReleaseUser(SMnode *pMnode, SUserObj *pUser);
|
void mndReleaseUser(SMnode *pMnode, SUserObj *pUser);
|
||||||
|
|
||||||
|
// for trans test
|
||||||
|
SSdbRaw *mndUserActionEncode(SUserObj *pUser);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -134,15 +134,15 @@ FAIL:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SMqRebSubscribe *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) {
|
static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) {
|
||||||
SMqRebSubscribe *pRebSub = taosHashGet(pHash, key, strlen(key) + 1);
|
SMqRebInfo *pRebSub = taosHashGet(pHash, key, strlen(key) + 1);
|
||||||
if (pRebSub == NULL) {
|
if (pRebSub == NULL) {
|
||||||
pRebSub = tNewSMqRebSubscribe(key);
|
pRebSub = tNewSMqRebSubscribe(key);
|
||||||
if (pRebSub == NULL) {
|
if (pRebSub == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
taosHashPut(pHash, key, strlen(key) + 1, pRebSub, sizeof(SMqRebSubscribe));
|
taosHashPut(pHash, key, strlen(key) + 1, pRebSub, sizeof(SMqRebInfo));
|
||||||
}
|
}
|
||||||
return pRebSub;
|
return pRebSub;
|
||||||
}
|
}
|
||||||
|
|
@ -189,7 +189,7 @@ static int32_t mndProcessMqTimerMsg(SNodeMsg *pMsg) {
|
||||||
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
||||||
char *removedTopic = taosArrayGetP(pConsumer->currentTopics, i);
|
char *removedTopic = taosArrayGetP(pConsumer->currentTopics, i);
|
||||||
mndMakeSubscribeKey(key, pConsumer->cgroup, removedTopic);
|
mndMakeSubscribeKey(key, pConsumer->cgroup, removedTopic);
|
||||||
SMqRebSubscribe *pRebSub = mndGetOrCreateRebSub(pRebMsg->rebSubHash, key);
|
SMqRebInfo *pRebSub = mndGetOrCreateRebSub(pRebMsg->rebSubHash, key);
|
||||||
taosArrayPush(pRebSub->removedConsumers, &pConsumer->consumerId);
|
taosArrayPush(pRebSub->removedConsumers, &pConsumer->consumerId);
|
||||||
}
|
}
|
||||||
taosRUnLockLatch(&pConsumer->lock);
|
taosRUnLockLatch(&pConsumer->lock);
|
||||||
|
|
@ -200,7 +200,7 @@ static int32_t mndProcessMqTimerMsg(SNodeMsg *pMsg) {
|
||||||
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
||||||
char *newTopic = taosArrayGetP(pConsumer->rebNewTopics, i);
|
char *newTopic = taosArrayGetP(pConsumer->rebNewTopics, i);
|
||||||
mndMakeSubscribeKey(key, pConsumer->cgroup, newTopic);
|
mndMakeSubscribeKey(key, pConsumer->cgroup, newTopic);
|
||||||
SMqRebSubscribe *pRebSub = mndGetOrCreateRebSub(pRebMsg->rebSubHash, key);
|
SMqRebInfo *pRebSub = mndGetOrCreateRebSub(pRebMsg->rebSubHash, key);
|
||||||
taosArrayPush(pRebSub->newConsumers, &pConsumer->consumerId);
|
taosArrayPush(pRebSub->newConsumers, &pConsumer->consumerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,7 +209,7 @@ static int32_t mndProcessMqTimerMsg(SNodeMsg *pMsg) {
|
||||||
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
char key[TSDB_SUBSCRIBE_KEY_LEN];
|
||||||
char *removedTopic = taosArrayGetP(pConsumer->rebRemovedTopics, i);
|
char *removedTopic = taosArrayGetP(pConsumer->rebRemovedTopics, i);
|
||||||
mndMakeSubscribeKey(key, pConsumer->cgroup, removedTopic);
|
mndMakeSubscribeKey(key, pConsumer->cgroup, removedTopic);
|
||||||
SMqRebSubscribe *pRebSub = mndGetOrCreateRebSub(pRebMsg->rebSubHash, key);
|
SMqRebInfo *pRebSub = mndGetOrCreateRebSub(pRebMsg->rebSubHash, key);
|
||||||
taosArrayPush(pRebSub->removedConsumers, &pConsumer->consumerId);
|
taosArrayPush(pRebSub->removedConsumers, &pConsumer->consumerId);
|
||||||
}
|
}
|
||||||
taosRUnLockLatch(&pConsumer->lock);
|
taosRUnLockLatch(&pConsumer->lock);
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,8 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
|
||||||
for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) {
|
for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) {
|
||||||
TASSERT(taosArrayGetSize(pDb->cfg.pRetensions) == pDb->cfg.numOfRetensions);
|
TASSERT(taosArrayGetSize(pDb->cfg.pRetensions) == pDb->cfg.numOfRetensions);
|
||||||
SRetention *pRetension = taosArrayGet(pDb->cfg.pRetensions, i);
|
SRetention *pRetension = taosArrayGet(pDb->cfg.pRetensions, i);
|
||||||
SDB_SET_INT32(pRaw, dataPos, pRetension->freq, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pRetension->freq, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pRetension->keep, _OVER)
|
SDB_SET_INT64(pRaw, dataPos, pRetension->keep, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pRetension->freqUnit, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pRetension->freqUnit, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pRetension->keepUnit, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pRetension->keepUnit, _OVER)
|
||||||
}
|
}
|
||||||
|
|
@ -180,8 +180,8 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
|
||||||
if (pDb->cfg.pRetensions == NULL) goto _OVER;
|
if (pDb->cfg.pRetensions == NULL) goto _OVER;
|
||||||
for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) {
|
for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) {
|
||||||
SRetention retension = {0};
|
SRetention retension = {0};
|
||||||
SDB_GET_INT32(pRaw, dataPos, &retension.freq, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &retension.freq, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &retension.keep, _OVER)
|
SDB_GET_INT64(pRaw, dataPos, &retension.keep, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &retension.freqUnit, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &retension.freqUnit, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &retension.keepUnit, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &retension.keepUnit, _OVER)
|
||||||
if (taosArrayPush(pDb->cfg.pRetensions, &retension) == NULL) {
|
if (taosArrayPush(pDb->cfg.pRetensions, &retension) == NULL) {
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ int32_t tEncodeSMqConsumerEp(void **buf, const SMqConsumerEp *pConsumerEp) {
|
||||||
|
|
||||||
void *tDecodeSMqConsumerEp(const void *buf, SMqConsumerEp *pConsumerEp) {
|
void *tDecodeSMqConsumerEp(const void *buf, SMqConsumerEp *pConsumerEp) {
|
||||||
buf = taosDecodeFixedI64(buf, &pConsumerEp->consumerId);
|
buf = taosDecodeFixedI64(buf, &pConsumerEp->consumerId);
|
||||||
buf = taosDecodeArray(buf, &pConsumerEp->vgs, (FDecode)tDecodeSMqVgEp, sizeof(SMqSubVgEp));
|
buf = taosDecodeArray(buf, &pConsumerEp->vgs, (FDecode)tDecodeSMqVgEp, sizeof(SMqVgEp));
|
||||||
#if 0
|
#if 0
|
||||||
int32_t sz;
|
int32_t sz;
|
||||||
buf = taosDecodeFixedI32(buf, &sz);
|
buf = taosDecodeFixedI32(buf, &sz);
|
||||||
|
|
@ -277,6 +277,7 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
|
||||||
memcpy(pSubNew->key, pSub->key, TSDB_SUBSCRIBE_KEY_LEN);
|
memcpy(pSubNew->key, pSub->key, TSDB_SUBSCRIBE_KEY_LEN);
|
||||||
taosInitRWLatch(&pSubNew->lock);
|
taosInitRWLatch(&pSubNew->lock);
|
||||||
|
|
||||||
|
pSubNew->dbUid = pSub->dbUid;
|
||||||
pSubNew->subType = pSub->subType;
|
pSubNew->subType = pSub->subType;
|
||||||
pSubNew->withTbName = pSub->withTbName;
|
pSubNew->withTbName = pSub->withTbName;
|
||||||
pSubNew->withSchema = pSub->withSchema;
|
pSubNew->withSchema = pSub->withSchema;
|
||||||
|
|
@ -310,6 +311,7 @@ void tDeleteSubscribeObj(SMqSubscribeObj *pSub) {
|
||||||
int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
|
int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
tlen += taosEncodeString(buf, pSub->key);
|
tlen += taosEncodeString(buf, pSub->key);
|
||||||
|
tlen += taosEncodeFixedI64(buf, pSub->dbUid);
|
||||||
tlen += taosEncodeFixedI32(buf, pSub->vgNum);
|
tlen += taosEncodeFixedI32(buf, pSub->vgNum);
|
||||||
tlen += taosEncodeFixedI8(buf, pSub->subType);
|
tlen += taosEncodeFixedI8(buf, pSub->subType);
|
||||||
tlen += taosEncodeFixedI8(buf, pSub->withTbName);
|
tlen += taosEncodeFixedI8(buf, pSub->withTbName);
|
||||||
|
|
@ -336,6 +338,7 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
|
||||||
void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) {
|
void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) {
|
||||||
//
|
//
|
||||||
buf = taosDecodeStringTo(buf, pSub->key);
|
buf = taosDecodeStringTo(buf, pSub->key);
|
||||||
|
buf = taosDecodeFixedI64(buf, &pSub->dbUid);
|
||||||
buf = taosDecodeFixedI32(buf, &pSub->vgNum);
|
buf = taosDecodeFixedI32(buf, &pSub->vgNum);
|
||||||
buf = taosDecodeFixedI8(buf, &pSub->subType);
|
buf = taosDecodeFixedI8(buf, &pSub->subType);
|
||||||
buf = taosDecodeFixedI8(buf, &pSub->withTbName);
|
buf = taosDecodeFixedI8(buf, &pSub->withTbName);
|
||||||
|
|
|
||||||
|
|
@ -625,7 +625,7 @@ static int32_t mndRetrieveMnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
||||||
colDataAppend(pColInfo, numOfRows, b1, false);
|
colDataAppend(pColInfo, numOfRows, b1, false);
|
||||||
|
|
||||||
const char *roles = syncStr(pObj->role);
|
const char *roles = syncStr(pObj->role);
|
||||||
char *b2 = taosMemoryCalloc(1, strlen(roles) + VARSTR_HEADER_SIZE);
|
char *b2 = taosMemoryCalloc(1, 12 + VARSTR_HEADER_SIZE);
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(b2, roles, pShow->pMeta->pSchemas[cols].bytes);
|
STR_WITH_MAXSIZE_TO_VARSTR(b2, roles, pShow->pMeta->pSchemas[cols].bytes);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
|
|
|
||||||
|
|
@ -429,16 +429,22 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
||||||
|
|
||||||
static void *mndBuildVDropStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int32_t *pContLen) {
|
static void *mndBuildVDropStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int32_t *pContLen) {
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
|
SVDropStbReq req = {0};
|
||||||
|
int32_t contLen = 0;
|
||||||
|
int32_t ret = 0;
|
||||||
|
SMsgHead *pHead = NULL;
|
||||||
|
SCoder coder = {0};
|
||||||
|
|
||||||
tNameFromString(&name, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
tNameFromString(&name, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
|
|
||||||
SVDropTbReq req = {0};
|
|
||||||
req.ver = 0;
|
|
||||||
req.name = (char *)tNameGetTableName(&name);
|
req.name = (char *)tNameGetTableName(&name);
|
||||||
req.type = TD_SUPER_TABLE;
|
|
||||||
req.suid = pStb->uid;
|
req.suid = pStb->uid;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSVDropTbReq(NULL, &req) + sizeof(SMsgHead);
|
tEncodeSize(tEncodeSVDropStbReq, &req, contLen, ret);
|
||||||
SMsgHead *pHead = taosMemoryMalloc(contLen);
|
if (ret < 0) return NULL;
|
||||||
|
|
||||||
|
contLen += sizeof(SMsgHead);
|
||||||
|
pHead = taosMemoryMalloc(contLen);
|
||||||
if (pHead == NULL) {
|
if (pHead == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -448,7 +454,10 @@ static void *mndBuildVDropStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb,
|
||||||
pHead->vgId = htonl(pVgroup->vgId);
|
pHead->vgId = htonl(pVgroup->vgId);
|
||||||
|
|
||||||
void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
|
void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead));
|
||||||
tSerializeSVDropTbReq(&pBuf, &req);
|
|
||||||
|
tCoderInit(&coder, TD_LITTLE_ENDIAN, pBuf, contLen - sizeof(SMsgHead), TD_ENCODER);
|
||||||
|
tEncodeSVDropStbReq(&coder, &req);
|
||||||
|
tCoderClear(&coder);
|
||||||
|
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
return pHead;
|
return pHead;
|
||||||
|
|
@ -670,8 +679,8 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
|
||||||
memcpy(stbObj.pAst2, pCreate->pAst2, stbObj.ast2Len);
|
memcpy(stbObj.pAst2, pCreate->pAst2, stbObj.ast2Len);
|
||||||
}
|
}
|
||||||
|
|
||||||
stbObj.pColumns = taosMemoryMalloc(stbObj.numOfColumns * sizeof(SSchema));
|
stbObj.pColumns = taosMemoryCalloc(1, stbObj.numOfColumns * sizeof(SSchema));
|
||||||
stbObj.pTags = taosMemoryMalloc(stbObj.numOfTags * sizeof(SSchema));
|
stbObj.pTags = taosMemoryCalloc(1, stbObj.numOfTags * sizeof(SSchema));
|
||||||
if (stbObj.pColumns == NULL || stbObj.pTags == NULL) {
|
if (stbObj.pColumns == NULL || stbObj.pTags == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -722,7 +731,6 @@ _OVER:
|
||||||
static int32_t mndProcessMCreateStbReq(SNodeMsg *pReq) {
|
static int32_t mndProcessMCreateStbReq(SNodeMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->pNode;
|
SMnode *pMnode = pReq->pNode;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
SStbObj *pTopicStb = NULL;
|
|
||||||
SStbObj *pStb = NULL;
|
SStbObj *pStb = NULL;
|
||||||
SDbObj *pDb = NULL;
|
SDbObj *pDb = NULL;
|
||||||
SUserObj *pUser = NULL;
|
SUserObj *pUser = NULL;
|
||||||
|
|
@ -753,12 +761,6 @@ static int32_t mndProcessMCreateStbReq(SNodeMsg *pReq) {
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTopicStb = mndAcquireStb(pMnode, createReq.name);
|
|
||||||
if (pTopicStb != NULL) {
|
|
||||||
terrno = TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC;
|
|
||||||
goto _OVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
pDb = mndAcquireDbByStb(pMnode, createReq.name);
|
pDb = mndAcquireDbByStb(pMnode, createReq.name);
|
||||||
if (pDb == NULL) {
|
if (pDb == NULL) {
|
||||||
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||||
|
|
@ -776,7 +778,7 @@ static int32_t mndProcessMCreateStbReq(SNodeMsg *pReq) {
|
||||||
|
|
||||||
int32_t numOfStbs = -1;
|
int32_t numOfStbs = -1;
|
||||||
mndGetNumOfStbs(pMnode, pDb->name, &numOfStbs);
|
mndGetNumOfStbs(pMnode, pDb->name, &numOfStbs);
|
||||||
if (pDb->cfg.numOfStables == 1 && numOfStbs != 0 ) {
|
if (pDb->cfg.numOfStables == 1 && numOfStbs != 0) {
|
||||||
terrno = TSDB_CODE_MND_SINGLE_STB_MODE_DB;
|
terrno = TSDB_CODE_MND_SINGLE_STB_MODE_DB;
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
@ -790,7 +792,6 @@ _OVER:
|
||||||
}
|
}
|
||||||
|
|
||||||
mndReleaseStb(pMnode, pStb);
|
mndReleaseStb(pMnode, pStb);
|
||||||
mndReleaseStb(pMnode, pTopicStb);
|
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndReleaseUser(pMnode, pUser);
|
mndReleaseUser(pMnode, pUser);
|
||||||
tFreeSMCreateStbReq(&createReq);
|
tFreeSMCreateStbReq(&createReq);
|
||||||
|
|
@ -1102,7 +1103,7 @@ static int32_t mndSetAlterStbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD
|
||||||
SSdbRaw *pRedoRaw = mndStbActionEncode(pStb);
|
SSdbRaw *pRedoRaw = mndStbActionEncode(pStb);
|
||||||
if (pRedoRaw == NULL) return -1;
|
if (pRedoRaw == NULL) return -1;
|
||||||
if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) return -1;
|
if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) return -1;
|
||||||
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_UPDATING) != 0) return -1;
|
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY) != 0) return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ static SMqSubscribeObj *mndCreateSub(SMnode *pMnode, const SMqTopicObj *pTopic,
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
pSub->dbUid = pTopic->dbUid;
|
||||||
pSub->subType = pTopic->subType;
|
pSub->subType = pTopic->subType;
|
||||||
pSub->withTbName = pTopic->withTbName;
|
pSub->withTbName = pTopic->withTbName;
|
||||||
pSub->withSchema = pTopic->withSchema;
|
pSub->withSchema = pTopic->withSchema;
|
||||||
|
|
@ -144,6 +145,10 @@ static int32_t mndPersistSubChangeVgReq(SMnode *pMnode, STrans *pTrans, const SM
|
||||||
|
|
||||||
int32_t vgId = pRebVg->pVgEp->vgId;
|
int32_t vgId = pRebVg->pVgEp->vgId;
|
||||||
SVgObj *pVgObj = mndAcquireVgroup(pMnode, vgId);
|
SVgObj *pVgObj = mndAcquireVgroup(pMnode, vgId);
|
||||||
|
if (pVgObj == NULL) {
|
||||||
|
taosMemoryFree(buf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
STransAction action = {0};
|
STransAction action = {0};
|
||||||
action.epSet = mndGetVgroupEpset(pMnode, pVgObj);
|
action.epSet = mndGetVgroupEpset(pMnode, pVgObj);
|
||||||
|
|
@ -170,27 +175,20 @@ static int32_t mndSplitSubscribeKey(const char *key, char *topic, char *cgroup)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SMqRebSubscribe *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) {
|
static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) {
|
||||||
SMqRebSubscribe *pRebSub = taosHashGet(pHash, key, strlen(key) + 1);
|
SMqRebInfo *pRebSub = taosHashGet(pHash, key, strlen(key) + 1);
|
||||||
if (pRebSub == NULL) {
|
if (pRebSub == NULL) {
|
||||||
pRebSub = tNewSMqRebSubscribe(key);
|
pRebSub = tNewSMqRebSubscribe(key);
|
||||||
if (pRebSub == NULL) {
|
if (pRebSub == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
taosHashPut(pHash, key, strlen(key) + 1, pRebSub, sizeof(SMqRebSubscribe));
|
taosHashPut(pHash, key, strlen(key) + 1, pRebSub, sizeof(SMqRebInfo));
|
||||||
}
|
}
|
||||||
return pRebSub;
|
return pRebSub;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) {
|
static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) {
|
||||||
if (pInput->pTopic != NULL) {
|
|
||||||
// create subscribe
|
|
||||||
pOutput->pSub = mndCreateSub(pMnode, pInput->pTopic, pInput->pRebInfo->key);
|
|
||||||
ASSERT(taosHashGetSize(pOutput->pSub->consumerHash) == 0);
|
|
||||||
} else {
|
|
||||||
pOutput->pSub = tCloneSubscribeObj(pInput->pOldSub);
|
|
||||||
}
|
|
||||||
int32_t totalVgNum = pOutput->pSub->vgNum;
|
int32_t totalVgNum = pOutput->pSub->vgNum;
|
||||||
|
|
||||||
mInfo("mq rebalance subscription: %s, vgNum: %d", pOutput->pSub->key, pOutput->pSub->vgNum);
|
mInfo("mq rebalance subscription: %s, vgNum: %d", pOutput->pSub->key, pOutput->pSub->vgNum);
|
||||||
|
|
@ -241,12 +239,8 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. calc vg number of each consumer
|
// 3. calc vg number of each consumer
|
||||||
int32_t oldSz = 0;
|
int32_t afterRebConsumerNum = pInput->oldConsumerNum + taosArrayGetSize(pInput->pRebInfo->newConsumers) -
|
||||||
if (pInput->pOldSub) {
|
taosArrayGetSize(pInput->pRebInfo->removedConsumers);
|
||||||
oldSz = taosHashGetSize(pInput->pOldSub->consumerHash);
|
|
||||||
}
|
|
||||||
int32_t afterRebConsumerNum =
|
|
||||||
oldSz + taosArrayGetSize(pInput->pRebInfo->newConsumers) - taosArrayGetSize(pInput->pRebInfo->removedConsumers);
|
|
||||||
int32_t minVgCnt = 0;
|
int32_t minVgCnt = 0;
|
||||||
int32_t imbConsumerNum = 0;
|
int32_t imbConsumerNum = 0;
|
||||||
// calc num
|
// calc num
|
||||||
|
|
@ -484,22 +478,34 @@ static int32_t mndProcessRebalanceReq(SNodeMsg *pMsg) {
|
||||||
rebOutput.touchedConsumers = taosArrayInit(0, sizeof(void *));
|
rebOutput.touchedConsumers = taosArrayInit(0, sizeof(void *));
|
||||||
rebOutput.rebVgs = taosArrayInit(0, sizeof(SMqRebOutputVg));
|
rebOutput.rebVgs = taosArrayInit(0, sizeof(SMqRebOutputVg));
|
||||||
|
|
||||||
SMqRebSubscribe *pRebSub = (SMqRebSubscribe *)pIter;
|
SMqRebInfo *pRebInfo = (SMqRebInfo *)pIter;
|
||||||
SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, pRebSub->key);
|
SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, pRebInfo->key);
|
||||||
|
|
||||||
|
rebInput.pRebInfo = pRebInfo;
|
||||||
|
|
||||||
if (pSub == NULL) {
|
if (pSub == NULL) {
|
||||||
// split sub key and extract topic
|
// split sub key and extract topic
|
||||||
char topic[TSDB_TOPIC_FNAME_LEN];
|
char topic[TSDB_TOPIC_FNAME_LEN];
|
||||||
char cgroup[TSDB_CGROUP_LEN];
|
char cgroup[TSDB_CGROUP_LEN];
|
||||||
mndSplitSubscribeKey(pRebSub->key, topic, cgroup);
|
mndSplitSubscribeKey(pRebInfo->key, topic, cgroup);
|
||||||
SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic);
|
SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic);
|
||||||
ASSERT(pTopic);
|
ASSERT(pTopic);
|
||||||
taosRLockLatch(&pTopic->lock);
|
taosRLockLatch(&pTopic->lock);
|
||||||
rebInput.pTopic = pTopic;
|
|
||||||
}
|
|
||||||
|
|
||||||
rebInput.pRebInfo = pRebSub;
|
rebOutput.pSub = mndCreateSub(pMnode, pTopic, pRebInfo->key);
|
||||||
rebInput.pOldSub = pSub;
|
ASSERT(taosHashGetSize(rebOutput.pSub->consumerHash) == 0);
|
||||||
|
|
||||||
|
taosRUnLockLatch(&pTopic->lock);
|
||||||
|
mndReleaseTopic(pMnode, pTopic);
|
||||||
|
|
||||||
|
rebInput.oldConsumerNum = 0;
|
||||||
|
} else {
|
||||||
|
taosRLockLatch(&pSub->lock);
|
||||||
|
rebInput.oldConsumerNum = taosHashGetSize(pSub->consumerHash);
|
||||||
|
rebOutput.pSub = tCloneSubscribeObj(pSub);
|
||||||
|
taosRUnLockLatch(&pSub->lock);
|
||||||
|
mndReleaseSubscribe(pMnode, pSub);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO replace assert with error check
|
// TODO replace assert with error check
|
||||||
ASSERT(mndDoRebalance(pMnode, &rebInput, &rebOutput) == 0);
|
ASSERT(mndDoRebalance(pMnode, &rebInput, &rebOutput) == 0);
|
||||||
|
|
@ -509,14 +515,8 @@ static int32_t mndProcessRebalanceReq(SNodeMsg *pMsg) {
|
||||||
/*ASSERT(taosArrayGetSize(rebOutput.rebVgs) != 0);*/
|
/*ASSERT(taosArrayGetSize(rebOutput.rebVgs) != 0);*/
|
||||||
|
|
||||||
// TODO replace assert with error check
|
// TODO replace assert with error check
|
||||||
ASSERT(mndPersistRebResult(pMnode, pMsg, &rebOutput) == 0);
|
if (mndPersistRebResult(pMnode, pMsg, &rebOutput) < 0) {
|
||||||
|
mError("persist rebalance output error, possibly vnode splitted or dropped");
|
||||||
if (rebInput.pTopic) {
|
|
||||||
SMqTopicObj *pTopic = (SMqTopicObj *)rebInput.pTopic;
|
|
||||||
taosRUnLockLatch(&pTopic->lock);
|
|
||||||
mndReleaseTopic(pMnode, pTopic);
|
|
||||||
} else {
|
|
||||||
mndReleaseSubscribe(pMnode, pSub);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -587,7 +587,7 @@ static SSdbRow *mndSubActionDecode(SSdbRaw *pRaw) {
|
||||||
int32_t dataPos = 0;
|
int32_t dataPos = 0;
|
||||||
int32_t tlen;
|
int32_t tlen;
|
||||||
SDB_GET_INT32(pRaw, dataPos, &tlen, SUB_DECODE_OVER);
|
SDB_GET_INT32(pRaw, dataPos, &tlen, SUB_DECODE_OVER);
|
||||||
buf = taosMemoryMalloc(tlen + 1);
|
buf = taosMemoryMalloc(tlen);
|
||||||
if (buf == NULL) goto SUB_DECODE_OVER;
|
if (buf == NULL) goto SUB_DECODE_OVER;
|
||||||
SDB_GET_BINARY(pRaw, dataPos, buf, tlen, SUB_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, buf, tlen, SUB_DECODE_OVER);
|
||||||
SDB_GET_RESERVE(pRaw, dataPos, MND_SUBSCRIBE_RESERVE_SIZE, SUB_DECODE_OVER);
|
SDB_GET_RESERVE(pRaw, dataPos, MND_SUBSCRIBE_RESERVE_SIZE, SUB_DECODE_OVER);
|
||||||
|
|
@ -673,3 +673,36 @@ static int32_t mndProcessSubscribeInternalRsp(SNodeMsg *pRsp) {
|
||||||
mndTransProcessRsp(pRsp);
|
mndTransProcessRsp(pRsp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndSetDropSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj *pSub) {
|
||||||
|
SSdbRaw *pCommitRaw = mndSubActionEncode(pSub);
|
||||||
|
if (pCommitRaw == NULL) return -1;
|
||||||
|
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1;
|
||||||
|
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED) != 0) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndDropSubByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||||
|
int32_t code = -1;
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
|
||||||
|
void *pIter = NULL;
|
||||||
|
SMqSubscribeObj *pSub = NULL;
|
||||||
|
while (1) {
|
||||||
|
pIter = sdbFetch(pSdb, SDB_SUBSCRIBE, pIter, (void **)&pSub);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
|
if (pSub->dbUid != pDb->uid) {
|
||||||
|
sdbRelease(pSdb, pSub);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndSetDropSubCommitLogs(pMnode, pTrans, pSub) < 0) {
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = 0;
|
||||||
|
END:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ static int32_t mndProcessDropTopicInRsp(SNodeMsg *pRsp);
|
||||||
static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter);
|
||||||
|
|
||||||
|
static int32_t mndSetDropTopicCommitLogs(SMnode *pMnode, STrans *pTrans, SMqTopicObj *pTopic);
|
||||||
|
|
||||||
int32_t mndInitTopic(SMnode *pMnode) {
|
int32_t mndInitTopic(SMnode *pMnode) {
|
||||||
SSdbTable table = {.sdbType = SDB_TOPIC,
|
SSdbTable table = {.sdbType = SDB_TOPIC,
|
||||||
.keyType = SDB_KEY_BINARY,
|
.keyType = SDB_KEY_BINARY,
|
||||||
|
|
@ -553,7 +555,41 @@ static int32_t mndRetrieveTopic(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndSetDropTopicCommitLogs(SMnode *pMnode, STrans *pTrans, SMqTopicObj *pTopic) {
|
||||||
|
SSdbRaw *pCommitRaw = mndTopicActionEncode(pTopic);
|
||||||
|
if (pCommitRaw == NULL) return -1;
|
||||||
|
if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1;
|
||||||
|
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED) != 0) return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter) {
|
static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
sdbCancelFetch(pSdb, pIter);
|
sdbCancelFetch(pSdb, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t mndDropTopicByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
|
||||||
|
int32_t code = -1;
|
||||||
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
|
||||||
|
void *pIter = NULL;
|
||||||
|
SMqTopicObj *pTopic = NULL;
|
||||||
|
while (1) {
|
||||||
|
pIter = sdbFetch(pSdb, SDB_TOPIC, pIter, (void **)&pTopic);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
|
||||||
|
if (pTopic->dbUid != pDb->uid) {
|
||||||
|
sdbRelease(pSdb, pTopic);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mndSetDropTopicCommitLogs(pMnode, pTrans, pTopic) < 0) {
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = 0;
|
||||||
|
END:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@
|
||||||
#include "mndSync.h"
|
#include "mndSync.h"
|
||||||
#include "mndUser.h"
|
#include "mndUser.h"
|
||||||
|
|
||||||
#define MND_TRANS_VER_NUMBER 1
|
#define TRANS_VER_NUMBER 1
|
||||||
#define MND_TRANS_ARRAY_SIZE 8
|
#define TRANS_ARRAY_SIZE 8
|
||||||
#define MND_TRANS_RESERVE_SIZE 64
|
#define TRANS_RESERVE_SIZE 64
|
||||||
|
|
||||||
static SSdbRaw *mndTransActionEncode(STrans *pTrans);
|
static SSdbRaw *mndTransActionEncode(STrans *pTrans);
|
||||||
static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw);
|
static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw);
|
||||||
|
|
@ -63,13 +63,15 @@ static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
static void mndCancelGetNextTrans(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextTrans(SMnode *pMnode, void *pIter);
|
||||||
|
|
||||||
int32_t mndInitTrans(SMnode *pMnode) {
|
int32_t mndInitTrans(SMnode *pMnode) {
|
||||||
SSdbTable table = {.sdbType = SDB_TRANS,
|
SSdbTable table = {
|
||||||
|
.sdbType = SDB_TRANS,
|
||||||
.keyType = SDB_KEY_INT32,
|
.keyType = SDB_KEY_INT32,
|
||||||
.encodeFp = (SdbEncodeFp)mndTransActionEncode,
|
.encodeFp = (SdbEncodeFp)mndTransActionEncode,
|
||||||
.decodeFp = (SdbDecodeFp)mndTransActionDecode,
|
.decodeFp = (SdbDecodeFp)mndTransActionDecode,
|
||||||
.insertFp = (SdbInsertFp)mndTransActionInsert,
|
.insertFp = (SdbInsertFp)mndTransActionInsert,
|
||||||
.updateFp = (SdbUpdateFp)mndTransActionUpdate,
|
.updateFp = (SdbUpdateFp)mndTransActionUpdate,
|
||||||
.deleteFp = (SdbDeleteFp)mndTransActionDelete};
|
.deleteFp = (SdbDeleteFp)mndTransActionDelete,
|
||||||
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_TRANS_TIMER, mndProcessTransReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_TRANS_TIMER, mndProcessTransReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_KILL_TRANS, mndProcessKillTransReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_KILL_TRANS, mndProcessKillTransReq);
|
||||||
|
|
@ -84,7 +86,7 @@ void mndCleanupTrans(SMnode *pMnode) {}
|
||||||
static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
int32_t rawDataLen = sizeof(STrans) + MND_TRANS_RESERVE_SIZE;
|
int32_t rawDataLen = sizeof(STrans) + TRANS_RESERVE_SIZE;
|
||||||
int32_t redoLogNum = taosArrayGetSize(pTrans->redoLogs);
|
int32_t redoLogNum = taosArrayGetSize(pTrans->redoLogs);
|
||||||
int32_t undoLogNum = taosArrayGetSize(pTrans->undoLogs);
|
int32_t undoLogNum = taosArrayGetSize(pTrans->undoLogs);
|
||||||
int32_t commitLogNum = taosArrayGetSize(pTrans->commitLogs);
|
int32_t commitLogNum = taosArrayGetSize(pTrans->commitLogs);
|
||||||
|
|
@ -116,78 +118,89 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
||||||
rawDataLen += (sizeof(STransAction) + pAction->contLen);
|
rawDataLen += (sizeof(STransAction) + pAction->contLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_TRANS, MND_TRANS_VER_NUMBER, rawDataLen);
|
SSdbRaw *pRaw = sdbAllocRaw(SDB_TRANS, TRANS_VER_NUMBER, rawDataLen);
|
||||||
if (pRaw == NULL) {
|
if (pRaw == NULL) {
|
||||||
mError("trans:%d, failed to alloc raw since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to alloc raw since %s", pTrans->id, terrstr());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dataPos = 0;
|
int32_t dataPos = 0;
|
||||||
SDB_SET_INT32(pRaw, dataPos, pTrans->id, TRANS_ENCODE_OVER)
|
SDB_SET_INT32(pRaw, dataPos, pTrans->id, _OVER)
|
||||||
SDB_SET_INT16(pRaw, dataPos, pTrans->policy, TRANS_ENCODE_OVER)
|
|
||||||
SDB_SET_INT16(pRaw, dataPos, pTrans->stage, TRANS_ENCODE_OVER)
|
ETrnStage stage = pTrans->stage;
|
||||||
SDB_SET_INT16(pRaw, dataPos, pTrans->transType, TRANS_ENCODE_OVER)
|
if (stage == TRN_STAGE_REDO_LOG || stage == TRN_STAGE_REDO_ACTION) {
|
||||||
SDB_SET_INT64(pRaw, dataPos, pTrans->createdTime, TRANS_ENCODE_OVER)
|
stage = TRN_STAGE_PREPARE;
|
||||||
SDB_SET_INT64(pRaw, dataPos, pTrans->dbUid, TRANS_ENCODE_OVER)
|
} else if (stage == TRN_STAGE_UNDO_ACTION || stage == TRN_STAGE_UNDO_LOG) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname, TSDB_DB_FNAME_LEN, TRANS_ENCODE_OVER)
|
stage = TRN_STAGE_ROLLBACK;
|
||||||
SDB_SET_INT32(pRaw, dataPos, redoLogNum, TRANS_ENCODE_OVER)
|
} else if (stage == TRN_STAGE_COMMIT_LOG || stage == TRN_STAGE_FINISHED) {
|
||||||
SDB_SET_INT32(pRaw, dataPos, undoLogNum, TRANS_ENCODE_OVER)
|
stage = TRN_STAGE_COMMIT;
|
||||||
SDB_SET_INT32(pRaw, dataPos, commitLogNum, TRANS_ENCODE_OVER)
|
} else {
|
||||||
SDB_SET_INT32(pRaw, dataPos, redoActionNum, TRANS_ENCODE_OVER)
|
}
|
||||||
SDB_SET_INT32(pRaw, dataPos, undoActionNum, TRANS_ENCODE_OVER)
|
|
||||||
|
SDB_SET_INT16(pRaw, dataPos, stage, _OVER)
|
||||||
|
SDB_SET_INT16(pRaw, dataPos, pTrans->policy, _OVER)
|
||||||
|
SDB_SET_INT16(pRaw, dataPos, pTrans->type, _OVER)
|
||||||
|
SDB_SET_INT64(pRaw, dataPos, pTrans->createdTime, _OVER)
|
||||||
|
SDB_SET_INT64(pRaw, dataPos, pTrans->dbUid, _OVER)
|
||||||
|
SDB_SET_BINARY(pRaw, dataPos, pTrans->dbname, TSDB_DB_FNAME_LEN, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, redoLogNum, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, undoLogNum, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, commitLogNum, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, redoActionNum, _OVER)
|
||||||
|
SDB_SET_INT32(pRaw, dataPos, undoActionNum, _OVER)
|
||||||
|
|
||||||
for (int32_t i = 0; i < redoLogNum; ++i) {
|
for (int32_t i = 0; i < redoLogNum; ++i) {
|
||||||
SSdbRaw *pTmp = taosArrayGetP(pTrans->redoLogs, i);
|
SSdbRaw *pTmp = taosArrayGetP(pTrans->redoLogs, i);
|
||||||
int32_t len = sdbGetRawTotalSize(pTmp);
|
int32_t len = sdbGetRawTotalSize(pTmp);
|
||||||
SDB_SET_INT32(pRaw, dataPos, len, TRANS_ENCODE_OVER)
|
SDB_SET_INT32(pRaw, dataPos, len, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, (void *)pTmp, len, TRANS_ENCODE_OVER)
|
SDB_SET_BINARY(pRaw, dataPos, (void *)pTmp, len, _OVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < undoLogNum; ++i) {
|
for (int32_t i = 0; i < undoLogNum; ++i) {
|
||||||
SSdbRaw *pTmp = taosArrayGetP(pTrans->undoLogs, i);
|
SSdbRaw *pTmp = taosArrayGetP(pTrans->undoLogs, i);
|
||||||
int32_t len = sdbGetRawTotalSize(pTmp);
|
int32_t len = sdbGetRawTotalSize(pTmp);
|
||||||
SDB_SET_INT32(pRaw, dataPos, len, TRANS_ENCODE_OVER)
|
SDB_SET_INT32(pRaw, dataPos, len, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, (void *)pTmp, len, TRANS_ENCODE_OVER)
|
SDB_SET_BINARY(pRaw, dataPos, (void *)pTmp, len, _OVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < commitLogNum; ++i) {
|
for (int32_t i = 0; i < commitLogNum; ++i) {
|
||||||
SSdbRaw *pTmp = taosArrayGetP(pTrans->commitLogs, i);
|
SSdbRaw *pTmp = taosArrayGetP(pTrans->commitLogs, i);
|
||||||
int32_t len = sdbGetRawTotalSize(pTmp);
|
int32_t len = sdbGetRawTotalSize(pTmp);
|
||||||
SDB_SET_INT32(pRaw, dataPos, len, TRANS_ENCODE_OVER)
|
SDB_SET_INT32(pRaw, dataPos, len, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, (void *)pTmp, len, TRANS_ENCODE_OVER)
|
SDB_SET_BINARY(pRaw, dataPos, (void *)pTmp, len, _OVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < redoActionNum; ++i) {
|
for (int32_t i = 0; i < redoActionNum; ++i) {
|
||||||
STransAction *pAction = taosArrayGet(pTrans->redoActions, i);
|
STransAction *pAction = taosArrayGet(pTrans->redoActions, i);
|
||||||
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), TRANS_ENCODE_OVER)
|
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
|
||||||
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, TRANS_ENCODE_OVER)
|
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, TRANS_ENCODE_OVER)
|
SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, TRANS_ENCODE_OVER)
|
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, TRANS_ENCODE_OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < undoActionNum; ++i) {
|
for (int32_t i = 0; i < undoActionNum; ++i) {
|
||||||
STransAction *pAction = taosArrayGet(pTrans->undoActions, i);
|
STransAction *pAction = taosArrayGet(pTrans->undoActions, i);
|
||||||
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), TRANS_ENCODE_OVER)
|
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
|
||||||
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, TRANS_ENCODE_OVER)
|
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, TRANS_ENCODE_OVER)
|
SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, TRANS_ENCODE_OVER)
|
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pCont, pAction->contLen, TRANS_ENCODE_OVER)
|
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pCont, pAction->contLen, _OVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDB_SET_INT32(pRaw, dataPos, pTrans->startFunc, TRANS_ENCODE_OVER)
|
SDB_SET_INT32(pRaw, dataPos, pTrans->startFunc, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pTrans->stopFunc, TRANS_ENCODE_OVER)
|
SDB_SET_INT32(pRaw, dataPos, pTrans->stopFunc, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pTrans->paramLen, TRANS_ENCODE_OVER)
|
SDB_SET_INT32(pRaw, dataPos, pTrans->paramLen, _OVER)
|
||||||
if (pTrans->param != NULL) {
|
if (pTrans->param != NULL) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pTrans->param, pTrans->paramLen, TRANS_ENCODE_OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pTrans->param, pTrans->paramLen, _OVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDB_SET_RESERVE(pRaw, dataPos, MND_TRANS_RESERVE_SIZE, TRANS_ENCODE_OVER)
|
SDB_SET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER)
|
||||||
SDB_SET_DATALEN(pRaw, dataPos, TRANS_ENCODE_OVER)
|
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
|
||||||
TRANS_ENCODE_OVER:
|
_OVER:
|
||||||
if (terrno != 0) {
|
if (terrno != 0) {
|
||||||
mError("trans:%d, failed to encode to raw:%p len:%d since %s", pTrans->id, pRaw, dataPos, terrstr());
|
mError("trans:%d, failed to encode to raw:%p len:%d since %s", pTrans->id, pRaw, dataPos, terrstr());
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
|
|
@ -214,38 +227,38 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
int32_t dataPos = 0;
|
int32_t dataPos = 0;
|
||||||
STransAction action = {0};
|
STransAction action = {0};
|
||||||
|
|
||||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto TRANS_DECODE_OVER;
|
if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER;
|
||||||
|
|
||||||
if (sver != MND_TRANS_VER_NUMBER) {
|
if (sver != TRANS_VER_NUMBER) {
|
||||||
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||||
goto TRANS_DECODE_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRow = sdbAllocRow(sizeof(STrans));
|
pRow = sdbAllocRow(sizeof(STrans));
|
||||||
if (pRow == NULL) goto TRANS_DECODE_OVER;
|
if (pRow == NULL) goto _OVER;
|
||||||
|
|
||||||
pTrans = sdbGetRowObj(pRow);
|
pTrans = sdbGetRowObj(pRow);
|
||||||
if (pTrans == NULL) goto TRANS_DECODE_OVER;
|
if (pTrans == NULL) goto _OVER;
|
||||||
|
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pTrans->id, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pTrans->id, _OVER)
|
||||||
|
|
||||||
int16_t type = 0;
|
|
||||||
int16_t policy = 0;
|
|
||||||
int16_t stage = 0;
|
int16_t stage = 0;
|
||||||
SDB_GET_INT16(pRaw, dataPos, &policy, TRANS_DECODE_OVER)
|
int16_t policy = 0;
|
||||||
SDB_GET_INT16(pRaw, dataPos, &stage, TRANS_DECODE_OVER)
|
int16_t type = 0;
|
||||||
SDB_GET_INT16(pRaw, dataPos, &type, TRANS_DECODE_OVER)
|
SDB_GET_INT16(pRaw, dataPos, &stage, _OVER)
|
||||||
pTrans->policy = policy;
|
SDB_GET_INT16(pRaw, dataPos, &policy, _OVER)
|
||||||
|
SDB_GET_INT16(pRaw, dataPos, &type, _OVER)
|
||||||
pTrans->stage = stage;
|
pTrans->stage = stage;
|
||||||
pTrans->transType = type;
|
pTrans->policy = policy;
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pTrans->createdTime, TRANS_DECODE_OVER)
|
pTrans->type = type;
|
||||||
SDB_GET_INT64(pRaw, dataPos, &pTrans->dbUid, TRANS_DECODE_OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pTrans->createdTime, _OVER)
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname, TSDB_DB_FNAME_LEN, TRANS_DECODE_OVER)
|
SDB_GET_INT64(pRaw, dataPos, &pTrans->dbUid, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &redoLogNum, TRANS_DECODE_OVER)
|
SDB_GET_BINARY(pRaw, dataPos, pTrans->dbname, TSDB_DB_FNAME_LEN, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &undoLogNum, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &redoLogNum, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &commitLogNum, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &undoLogNum, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &redoActionNum, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &commitLogNum, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &undoActionNum, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &redoActionNum, _OVER)
|
||||||
|
SDB_GET_INT32(pRaw, dataPos, &undoActionNum, _OVER)
|
||||||
|
|
||||||
pTrans->redoLogs = taosArrayInit(redoLogNum, sizeof(void *));
|
pTrans->redoLogs = taosArrayInit(redoLogNum, sizeof(void *));
|
||||||
pTrans->undoLogs = taosArrayInit(undoLogNum, sizeof(void *));
|
pTrans->undoLogs = taosArrayInit(undoLogNum, sizeof(void *));
|
||||||
|
|
@ -253,79 +266,79 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
pTrans->redoActions = taosArrayInit(redoActionNum, sizeof(STransAction));
|
pTrans->redoActions = taosArrayInit(redoActionNum, sizeof(STransAction));
|
||||||
pTrans->undoActions = taosArrayInit(undoActionNum, sizeof(STransAction));
|
pTrans->undoActions = taosArrayInit(undoActionNum, sizeof(STransAction));
|
||||||
|
|
||||||
if (pTrans->redoLogs == NULL) goto TRANS_DECODE_OVER;
|
if (pTrans->redoLogs == NULL) goto _OVER;
|
||||||
if (pTrans->undoLogs == NULL) goto TRANS_DECODE_OVER;
|
if (pTrans->undoLogs == NULL) goto _OVER;
|
||||||
if (pTrans->commitLogs == NULL) goto TRANS_DECODE_OVER;
|
if (pTrans->commitLogs == NULL) goto _OVER;
|
||||||
if (pTrans->redoActions == NULL) goto TRANS_DECODE_OVER;
|
if (pTrans->redoActions == NULL) goto _OVER;
|
||||||
if (pTrans->undoActions == NULL) goto TRANS_DECODE_OVER;
|
if (pTrans->undoActions == NULL) goto _OVER;
|
||||||
|
|
||||||
for (int32_t i = 0; i < redoLogNum; ++i) {
|
for (int32_t i = 0; i < redoLogNum; ++i) {
|
||||||
SDB_GET_INT32(pRaw, dataPos, &dataLen, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
|
||||||
pData = taosMemoryMalloc(dataLen);
|
pData = taosMemoryMalloc(dataLen);
|
||||||
if (pData == NULL) goto TRANS_DECODE_OVER;
|
if (pData == NULL) goto _OVER;
|
||||||
mTrace("raw:%p, is created", pData);
|
mTrace("raw:%p, is created", pData);
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pData, dataLen, TRANS_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, pData, dataLen, _OVER);
|
||||||
if (taosArrayPush(pTrans->redoLogs, &pData) == NULL) goto TRANS_DECODE_OVER;
|
if (taosArrayPush(pTrans->redoLogs, &pData) == NULL) goto _OVER;
|
||||||
pData = NULL;
|
pData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < undoLogNum; ++i) {
|
for (int32_t i = 0; i < undoLogNum; ++i) {
|
||||||
SDB_GET_INT32(pRaw, dataPos, &dataLen, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
|
||||||
pData = taosMemoryMalloc(dataLen);
|
pData = taosMemoryMalloc(dataLen);
|
||||||
if (pData == NULL) goto TRANS_DECODE_OVER;
|
if (pData == NULL) goto _OVER;
|
||||||
mTrace("raw:%p, is created", pData);
|
mTrace("raw:%p, is created", pData);
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pData, dataLen, TRANS_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, pData, dataLen, _OVER);
|
||||||
if (taosArrayPush(pTrans->undoLogs, &pData) == NULL) goto TRANS_DECODE_OVER;
|
if (taosArrayPush(pTrans->undoLogs, &pData) == NULL) goto _OVER;
|
||||||
pData = NULL;
|
pData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < commitLogNum; ++i) {
|
for (int32_t i = 0; i < commitLogNum; ++i) {
|
||||||
SDB_GET_INT32(pRaw, dataPos, &dataLen, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
|
||||||
pData = taosMemoryMalloc(dataLen);
|
pData = taosMemoryMalloc(dataLen);
|
||||||
if (pData == NULL) goto TRANS_DECODE_OVER;
|
if (pData == NULL) goto _OVER;
|
||||||
mTrace("raw:%p, is created", pData);
|
mTrace("raw:%p, is created", pData);
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pData, dataLen, TRANS_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, pData, dataLen, _OVER);
|
||||||
if (taosArrayPush(pTrans->commitLogs, &pData) == NULL) goto TRANS_DECODE_OVER;
|
if (taosArrayPush(pTrans->commitLogs, &pData) == NULL) goto _OVER;
|
||||||
pData = NULL;
|
pData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < redoActionNum; ++i) {
|
for (int32_t i = 0; i < redoActionNum; ++i) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), TRANS_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
|
||||||
SDB_GET_INT16(pRaw, dataPos, &action.msgType, TRANS_DECODE_OVER)
|
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &action.contLen, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &action.contLen, _OVER)
|
||||||
action.pCont = taosMemoryMalloc(action.contLen);
|
action.pCont = taosMemoryMalloc(action.contLen);
|
||||||
if (action.pCont == NULL) goto TRANS_DECODE_OVER;
|
if (action.pCont == NULL) goto _OVER;
|
||||||
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, TRANS_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, _OVER);
|
||||||
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto TRANS_DECODE_OVER;
|
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
||||||
action.pCont = NULL;
|
action.pCont = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < undoActionNum; ++i) {
|
for (int32_t i = 0; i < undoActionNum; ++i) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), TRANS_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
|
||||||
SDB_GET_INT16(pRaw, dataPos, &action.msgType, TRANS_DECODE_OVER)
|
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &action.contLen, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &action.contLen, _OVER)
|
||||||
action.pCont = taosMemoryMalloc(action.contLen);
|
action.pCont = taosMemoryMalloc(action.contLen);
|
||||||
if (action.pCont == NULL) goto TRANS_DECODE_OVER;
|
if (action.pCont == NULL) goto _OVER;
|
||||||
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, TRANS_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, _OVER);
|
||||||
if (taosArrayPush(pTrans->undoActions, &action) == NULL) goto TRANS_DECODE_OVER;
|
if (taosArrayPush(pTrans->undoActions, &action) == NULL) goto _OVER;
|
||||||
action.pCont = NULL;
|
action.pCont = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pTrans->startFunc, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pTrans->startFunc, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pTrans->stopFunc, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pTrans->stopFunc, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &pTrans->paramLen, TRANS_DECODE_OVER)
|
SDB_GET_INT32(pRaw, dataPos, &pTrans->paramLen, _OVER)
|
||||||
if (pTrans->paramLen != 0) {
|
if (pTrans->paramLen != 0) {
|
||||||
pTrans->param = taosMemoryMalloc(pTrans->paramLen);
|
pTrans->param = taosMemoryMalloc(pTrans->paramLen);
|
||||||
SDB_GET_BINARY(pRaw, dataPos, pTrans->param, pTrans->paramLen, TRANS_DECODE_OVER);
|
SDB_GET_BINARY(pRaw, dataPos, pTrans->param, pTrans->paramLen, _OVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDB_GET_RESERVE(pRaw, dataPos, MND_TRANS_RESERVE_SIZE, TRANS_DECODE_OVER)
|
SDB_GET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER)
|
||||||
|
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
|
|
||||||
TRANS_DECODE_OVER:
|
_OVER:
|
||||||
if (terrno != 0) {
|
if (terrno != 0) {
|
||||||
mError("trans:%d, failed to parse from raw:%p since %s", pTrans->id, pRaw, terrstr());
|
mError("trans:%d, failed to parse from raw:%p since %s", pTrans->id, pRaw, terrstr());
|
||||||
mndTransDropData(pTrans);
|
mndTransDropData(pTrans);
|
||||||
|
|
@ -400,6 +413,16 @@ static const char *mndTransType(ETrnType type) {
|
||||||
return "subscribe";
|
return "subscribe";
|
||||||
case TRN_TYPE_REBALANCE:
|
case TRN_TYPE_REBALANCE:
|
||||||
return "rebalance";
|
return "rebalance";
|
||||||
|
case TRN_TYPE_COMMIT_OFFSET:
|
||||||
|
return "commit-offset";
|
||||||
|
case TRN_TYPE_CREATE_STREAM:
|
||||||
|
return "create-stream";
|
||||||
|
case TRN_TYPE_DROP_STREAM:
|
||||||
|
return "drop-stream";
|
||||||
|
case TRN_TYPE_CONSUMER_LOST:
|
||||||
|
return "consumer-lost";
|
||||||
|
case TRN_TYPE_CONSUMER_RECOVER:
|
||||||
|
return "consumer-recover";
|
||||||
case TRN_TYPE_CREATE_DNODE:
|
case TRN_TYPE_CREATE_DNODE:
|
||||||
return "create-qnode";
|
return "create-qnode";
|
||||||
case TRN_TYPE_DROP_DNODE:
|
case TRN_TYPE_DROP_DNODE:
|
||||||
|
|
@ -453,7 +476,6 @@ static TransCbFp mndTransGetCbFp(ETrnFuncType ftype) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans) {
|
static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans) {
|
||||||
// pTrans->stage = TRN_STAGE_PREPARE;
|
|
||||||
mTrace("trans:%d, perform insert action, row:%p stage:%s", pTrans->id, pTrans, mndTransStr(pTrans->stage));
|
mTrace("trans:%d, perform insert action, row:%p stage:%s", pTrans->id, pTrans, mndTransStr(pTrans->stage));
|
||||||
|
|
||||||
if (pTrans->startFunc > 0) {
|
if (pTrans->startFunc > 0) {
|
||||||
|
|
@ -515,16 +537,15 @@ static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pOld, STrans *pNew) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static STrans *mndAcquireTrans(SMnode *pMnode, int32_t transId) {
|
STrans *mndAcquireTrans(SMnode *pMnode, int32_t transId) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
STrans *pTrans = sdbAcquire(pMnode->pSdb, SDB_TRANS, &transId);
|
||||||
STrans *pTrans = sdbAcquire(pSdb, SDB_TRANS, &transId);
|
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
terrno = TSDB_CODE_MND_TRANS_NOT_EXIST;
|
terrno = TSDB_CODE_MND_TRANS_NOT_EXIST;
|
||||||
}
|
}
|
||||||
return pTrans;
|
return pTrans;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndReleaseTrans(SMnode *pMnode, STrans *pTrans) {
|
void mndReleaseTrans(SMnode *pMnode, STrans *pTrans) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
sdbRelease(pSdb, pTrans);
|
sdbRelease(pSdb, pTrans);
|
||||||
}
|
}
|
||||||
|
|
@ -540,16 +561,16 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnType type, const S
|
||||||
pTrans->id = sdbGetMaxId(pMnode->pSdb, SDB_TRANS);
|
pTrans->id = sdbGetMaxId(pMnode->pSdb, SDB_TRANS);
|
||||||
pTrans->stage = TRN_STAGE_PREPARE;
|
pTrans->stage = TRN_STAGE_PREPARE;
|
||||||
pTrans->policy = policy;
|
pTrans->policy = policy;
|
||||||
pTrans->transType = type;
|
pTrans->type = type;
|
||||||
pTrans->createdTime = taosGetTimestampMs();
|
pTrans->createdTime = taosGetTimestampMs();
|
||||||
pTrans->rpcHandle = pReq->handle;
|
pTrans->rpcHandle = pReq->handle;
|
||||||
pTrans->rpcAHandle = pReq->ahandle;
|
pTrans->rpcAHandle = pReq->ahandle;
|
||||||
pTrans->rpcRefId = pReq->refId;
|
pTrans->rpcRefId = pReq->refId;
|
||||||
pTrans->redoLogs = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(void *));
|
pTrans->redoLogs = taosArrayInit(TRANS_ARRAY_SIZE, sizeof(void *));
|
||||||
pTrans->undoLogs = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(void *));
|
pTrans->undoLogs = taosArrayInit(TRANS_ARRAY_SIZE, sizeof(void *));
|
||||||
pTrans->commitLogs = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(void *));
|
pTrans->commitLogs = taosArrayInit(TRANS_ARRAY_SIZE, sizeof(void *));
|
||||||
pTrans->redoActions = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(STransAction));
|
pTrans->redoActions = taosArrayInit(TRANS_ARRAY_SIZE, sizeof(STransAction));
|
||||||
pTrans->undoActions = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(STransAction));
|
pTrans->undoActions = taosArrayInit(TRANS_ARRAY_SIZE, sizeof(STransAction));
|
||||||
|
|
||||||
if (pTrans->redoLogs == NULL || pTrans->undoLogs == NULL || pTrans->commitLogs == NULL ||
|
if (pTrans->redoLogs == NULL || pTrans->undoLogs == NULL || pTrans->commitLogs == NULL ||
|
||||||
pTrans->redoActions == NULL || pTrans->undoActions == NULL) {
|
pTrans->redoActions == NULL || pTrans->undoActions == NULL) {
|
||||||
|
|
@ -558,7 +579,7 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnType type, const S
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDebug("trans:%d, local var is created, data:%p", pTrans->id, pTrans);
|
mDebug("trans:%d, local object is created, data:%p", pTrans->id, pTrans);
|
||||||
return pTrans;
|
return pTrans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -585,14 +606,14 @@ static void mndTransDropActions(SArray *pArray) {
|
||||||
void mndTransDrop(STrans *pTrans) {
|
void mndTransDrop(STrans *pTrans) {
|
||||||
if (pTrans != NULL) {
|
if (pTrans != NULL) {
|
||||||
mndTransDropData(pTrans);
|
mndTransDropData(pTrans);
|
||||||
mDebug("trans:%d, local var is freed, data:%p", pTrans->id, pTrans);
|
mDebug("trans:%d, local object is freed, data:%p", pTrans->id, pTrans);
|
||||||
taosMemoryFreeClear(pTrans);
|
taosMemoryFreeClear(pTrans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndTransAppendLog(SArray *pArray, SSdbRaw *pRaw) {
|
static int32_t mndTransAppendLog(SArray *pArray, SSdbRaw *pRaw) {
|
||||||
if (pArray == NULL || pRaw == NULL) {
|
if (pArray == NULL || pRaw == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -674,27 +695,27 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mndIsBasicTrans(STrans *pTrans) {
|
static bool mndIsBasicTrans(STrans *pTrans) {
|
||||||
return pTrans->stage > TRN_TYPE_BASIC_SCOPE && pTrans->stage < TRN_TYPE_BASIC_SCOPE_END;
|
return pTrans->type > TRN_TYPE_BASIC_SCOPE && pTrans->type < TRN_TYPE_BASIC_SCOPE_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mndIsGlobalTrans(STrans *pTrans) {
|
static bool mndIsGlobalTrans(STrans *pTrans) {
|
||||||
return pTrans->stage > TRN_TYPE_GLOBAL_SCOPE && pTrans->stage < TRN_TYPE_GLOBAL_SCOPE_END;
|
return pTrans->type > TRN_TYPE_GLOBAL_SCOPE && pTrans->type < TRN_TYPE_GLOBAL_SCOPE_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mndIsDbTrans(STrans *pTrans) {
|
static bool mndIsDbTrans(STrans *pTrans) {
|
||||||
return pTrans->stage > TRN_TYPE_DB_SCOPE && pTrans->stage < TRN_TYPE_DB_SCOPE_END;
|
return pTrans->type > TRN_TYPE_DB_SCOPE && pTrans->type < TRN_TYPE_DB_SCOPE_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mndIsStbTrans(STrans *pTrans) {
|
static bool mndIsStbTrans(STrans *pTrans) {
|
||||||
return pTrans->stage > TRN_TYPE_STB_SCOPE && pTrans->stage < TRN_TYPE_STB_SCOPE_END;
|
return pTrans->type > TRN_TYPE_STB_SCOPE && pTrans->type < TRN_TYPE_STB_SCOPE_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndCheckTransCanBeStartedInParallel(SMnode *pMnode, STrans *pNewTrans) {
|
static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNewTrans) {
|
||||||
if (mndIsBasicTrans(pNewTrans)) return 0;
|
|
||||||
|
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
int32_t code = 0;
|
bool conflict = false;
|
||||||
|
|
||||||
|
if (mndIsBasicTrans(pNewTrans)) return conflict;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter = sdbFetch(pMnode->pSdb, SDB_TRANS, pIter, (void **)&pTrans);
|
pIter = sdbFetch(pMnode->pSdb, SDB_TRANS, pIter, (void **)&pTrans);
|
||||||
|
|
@ -703,42 +724,35 @@ static int32_t mndCheckTransCanBeStartedInParallel(SMnode *pMnode, STrans *pNewT
|
||||||
if (mndIsGlobalTrans(pNewTrans)) {
|
if (mndIsGlobalTrans(pNewTrans)) {
|
||||||
if (mndIsDbTrans(pTrans) || mndIsStbTrans(pTrans)) {
|
if (mndIsDbTrans(pTrans) || mndIsStbTrans(pTrans)) {
|
||||||
mError("trans:%d, can't execute since trans:%d in progress db:%s", pNewTrans->id, pTrans->id, pTrans->dbname);
|
mError("trans:%d, can't execute since trans:%d in progress db:%s", pNewTrans->id, pTrans->id, pTrans->dbname);
|
||||||
code = -1;
|
conflict = true;
|
||||||
break;
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndIsDbTrans(pNewTrans)) {
|
else if (mndIsDbTrans(pNewTrans)) {
|
||||||
if (mndIsBasicTrans(pTrans)) continue;
|
|
||||||
if (mndIsGlobalTrans(pTrans)) {
|
if (mndIsGlobalTrans(pTrans)) {
|
||||||
mError("trans:%d, can't execute since trans:%d in progress", pNewTrans->id, pTrans->id);
|
mError("trans:%d, can't execute since trans:%d in progress", pNewTrans->id, pTrans->id);
|
||||||
code = -1;
|
conflict = true;
|
||||||
break;
|
} else if (mndIsDbTrans(pTrans) || mndIsStbTrans(pTrans)) {
|
||||||
}
|
|
||||||
if (mndIsDbTrans(pTrans) || mndIsStbTrans(pTrans)) {
|
|
||||||
if (pNewTrans->dbUid == pTrans->dbUid) {
|
if (pNewTrans->dbUid == pTrans->dbUid) {
|
||||||
mError("trans:%d, can't execute since trans:%d in progress db:%s", pNewTrans->id, pTrans->id, pTrans->dbname);
|
mError("trans:%d, can't execute since trans:%d in progress db:%s", pNewTrans->id, pTrans->id, pTrans->dbname);
|
||||||
code = -1;
|
conflict = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mndIsStbTrans(pNewTrans)) {
|
else if (mndIsStbTrans(pNewTrans)) {
|
||||||
if (mndIsBasicTrans(pTrans)) continue;
|
|
||||||
if (mndIsGlobalTrans(pTrans)) {
|
if (mndIsGlobalTrans(pTrans)) {
|
||||||
mError("trans:%d, can't execute since trans:%d in progress", pNewTrans->id, pTrans->id);
|
mError("trans:%d, can't execute since trans:%d in progress", pNewTrans->id, pTrans->id);
|
||||||
code = -1;
|
conflict = true;
|
||||||
break;
|
} else if (mndIsDbTrans(pTrans)) {
|
||||||
}
|
|
||||||
if (mndIsDbTrans(pTrans)) {
|
|
||||||
if (pNewTrans->dbUid == pTrans->dbUid) {
|
if (pNewTrans->dbUid == pTrans->dbUid) {
|
||||||
mError("trans:%d, can't execute since trans:%d in progress db:%s", pNewTrans->id, pTrans->id, pTrans->dbname);
|
mError("trans:%d, can't execute since trans:%d in progress db:%s", pNewTrans->id, pTrans->id, pTrans->dbname);
|
||||||
code = -1;
|
conflict = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}
|
}
|
||||||
if (mndIsStbTrans(pTrans)) continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pMnode->pSdb, pTrans);
|
sdbRelease(pMnode->pSdb, pTrans);
|
||||||
|
|
@ -746,12 +760,12 @@ static int32_t mndCheckTransCanBeStartedInParallel(SMnode *pMnode, STrans *pNewT
|
||||||
|
|
||||||
sdbCancelFetch(pMnode->pSdb, pIter);
|
sdbCancelFetch(pMnode->pSdb, pIter);
|
||||||
sdbRelease(pMnode->pSdb, pTrans);
|
sdbRelease(pMnode->pSdb, pTrans);
|
||||||
return code;
|
return conflict;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
||||||
if (mndCheckTransCanBeStartedInParallel(pMnode, pTrans) != 0) {
|
if (mndCheckTransConflict(pMnode, pTrans)) {
|
||||||
terrno = TSDB_CODE_MND_TRANS_CANT_PARALLEL;
|
terrno = TSDB_CODE_MND_TRANS_CONFLICT;
|
||||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -806,6 +820,7 @@ static int32_t mndTransRollback(SMnode *pMnode, STrans *pTrans) {
|
||||||
|
|
||||||
static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
||||||
bool sendRsp = false;
|
bool sendRsp = false;
|
||||||
|
int32_t code = pTrans->code;
|
||||||
|
|
||||||
if (pTrans->stage == TRN_STAGE_FINISHED) {
|
if (pTrans->stage == TRN_STAGE_FINISHED) {
|
||||||
sendRsp = true;
|
sendRsp = true;
|
||||||
|
|
@ -814,12 +829,12 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
||||||
if (pTrans->policy == TRN_POLICY_ROLLBACK) {
|
if (pTrans->policy == TRN_POLICY_ROLLBACK) {
|
||||||
if (pTrans->stage == TRN_STAGE_UNDO_LOG || pTrans->stage == TRN_STAGE_UNDO_ACTION ||
|
if (pTrans->stage == TRN_STAGE_UNDO_LOG || pTrans->stage == TRN_STAGE_UNDO_ACTION ||
|
||||||
pTrans->stage == TRN_STAGE_ROLLBACK) {
|
pTrans->stage == TRN_STAGE_ROLLBACK) {
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_TRANS_UNKNOW_ERROR;
|
||||||
sendRsp = true;
|
sendRsp = true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (pTrans->policy == TRN_POLICY_RETRY) {
|
|
||||||
if (pTrans->stage == TRN_STAGE_REDO_ACTION && pTrans->failedTimes > 0) {
|
if (pTrans->stage == TRN_STAGE_REDO_ACTION && pTrans->failedTimes > 0) {
|
||||||
|
if (code == 0) code = TSDB_CODE_MND_TRANS_UNKNOW_ERROR;
|
||||||
sendRsp = true;
|
sendRsp = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -831,14 +846,16 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
||||||
}
|
}
|
||||||
taosMemoryFree(pTrans->rpcRsp);
|
taosMemoryFree(pTrans->rpcRsp);
|
||||||
|
|
||||||
mDebug("trans:%d, send rsp, code:0x%04x stage:%d app:%p", pTrans->id, pTrans->code & 0xFFFF, pTrans->stage,
|
mDebug("trans:%d, send rsp, code:0x%04x stage:%d app:%p", pTrans->id, code & 0xFFFF, pTrans->stage,
|
||||||
pTrans->rpcAHandle);
|
pTrans->rpcAHandle);
|
||||||
SRpcMsg rspMsg = {.handle = pTrans->rpcHandle,
|
SRpcMsg rspMsg = {
|
||||||
.code = pTrans->code,
|
.handle = pTrans->rpcHandle,
|
||||||
.ahandle = pTrans->rpcAHandle,
|
.ahandle = pTrans->rpcAHandle,
|
||||||
.refId = pTrans->rpcRefId,
|
.refId = pTrans->rpcRefId,
|
||||||
|
.code = code,
|
||||||
.pCont = rpcCont,
|
.pCont = rpcCont,
|
||||||
.contLen = pTrans->rpcRspLen};
|
.contLen = pTrans->rpcRspLen,
|
||||||
|
};
|
||||||
tmsgSendRsp(&rspMsg);
|
tmsgSendRsp(&rspMsg);
|
||||||
pTrans->rpcHandle = NULL;
|
pTrans->rpcHandle = NULL;
|
||||||
pTrans->rpcRsp = NULL;
|
pTrans->rpcRsp = NULL;
|
||||||
|
|
@ -855,7 +872,7 @@ void mndTransProcessRsp(SNodeMsg *pRsp) {
|
||||||
STrans *pTrans = mndAcquireTrans(pMnode, transId);
|
STrans *pTrans = mndAcquireTrans(pMnode, transId);
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
mError("trans:%d, failed to get transId from vnode rsp since %s", transId, terrstr());
|
mError("trans:%d, failed to get transId from vnode rsp since %s", transId, terrstr());
|
||||||
goto HANDLE_ACTION_RSP_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray *pArray = NULL;
|
SArray *pArray = NULL;
|
||||||
|
|
@ -865,18 +882,18 @@ void mndTransProcessRsp(SNodeMsg *pRsp) {
|
||||||
pArray = pTrans->undoActions;
|
pArray = pTrans->undoActions;
|
||||||
} else {
|
} else {
|
||||||
mError("trans:%d, invalid trans stage:%d while recv action rsp", pTrans->id, pTrans->stage);
|
mError("trans:%d, invalid trans stage:%d while recv action rsp", pTrans->id, pTrans->stage);
|
||||||
goto HANDLE_ACTION_RSP_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pArray == NULL) {
|
if (pArray == NULL) {
|
||||||
mError("trans:%d, invalid trans stage:%d", transId, pTrans->stage);
|
mError("trans:%d, invalid trans stage:%d", transId, pTrans->stage);
|
||||||
goto HANDLE_ACTION_RSP_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t actionNum = taosArrayGetSize(pTrans->redoActions);
|
int32_t actionNum = taosArrayGetSize(pTrans->redoActions);
|
||||||
if (action < 0 || action >= actionNum) {
|
if (action < 0 || action >= actionNum) {
|
||||||
mError("trans:%d, invalid action:%d", transId, action);
|
mError("trans:%d, invalid action:%d", transId, action);
|
||||||
goto HANDLE_ACTION_RSP_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
STransAction *pAction = taosArrayGet(pArray, action);
|
STransAction *pAction = taosArrayGet(pArray, action);
|
||||||
|
|
@ -892,7 +909,7 @@ void mndTransProcessRsp(SNodeMsg *pRsp) {
|
||||||
pAction->acceptableCode);
|
pAction->acceptableCode);
|
||||||
mndTransExecute(pMnode, pTrans);
|
mndTransExecute(pMnode, pTrans);
|
||||||
|
|
||||||
HANDLE_ACTION_RSP_OVER:
|
_OVER:
|
||||||
mndReleaseTrans(pMnode, pTrans);
|
mndReleaseTrans(pMnode, pTrans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -902,27 +919,41 @@ static int32_t mndTransExecuteLogs(SMnode *pMnode, SArray *pArray) {
|
||||||
|
|
||||||
if (arraySize == 0) return 0;
|
if (arraySize == 0) return 0;
|
||||||
|
|
||||||
|
int32_t code = 0;
|
||||||
for (int32_t i = 0; i < arraySize; ++i) {
|
for (int32_t i = 0; i < arraySize; ++i) {
|
||||||
SSdbRaw *pRaw = taosArrayGetP(pArray, i);
|
SSdbRaw *pRaw = taosArrayGetP(pArray, i);
|
||||||
int32_t code = sdbWriteWithoutFree(pSdb, pRaw);
|
if (sdbWriteWithoutFree(pSdb, pRaw) != 0) {
|
||||||
if (code != 0) {
|
code = ((terrno != 0) ? terrno : -1);
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
terrno = code;
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndTransExecuteRedoLogs(SMnode *pMnode, STrans *pTrans) {
|
static int32_t mndTransExecuteRedoLogs(SMnode *pMnode, STrans *pTrans) {
|
||||||
return mndTransExecuteLogs(pMnode, pTrans->redoLogs);
|
int32_t code = mndTransExecuteLogs(pMnode, pTrans->redoLogs);
|
||||||
|
if (code != 0) {
|
||||||
|
mError("failed to execute redoLogs since %s", terrstr());
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndTransExecuteUndoLogs(SMnode *pMnode, STrans *pTrans) {
|
static int32_t mndTransExecuteUndoLogs(SMnode *pMnode, STrans *pTrans) {
|
||||||
return mndTransExecuteLogs(pMnode, pTrans->undoLogs);
|
int32_t code = mndTransExecuteLogs(pMnode, pTrans->undoLogs);
|
||||||
|
if (code != 0) {
|
||||||
|
mError("failed to execute undoLogs since %s, return success", terrstr());
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0; // return success in any case
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndTransExecuteCommitLogs(SMnode *pMnode, STrans *pTrans) {
|
static int32_t mndTransExecuteCommitLogs(SMnode *pMnode, STrans *pTrans) {
|
||||||
return mndTransExecuteLogs(pMnode, pTrans->commitLogs);
|
int32_t code = mndTransExecuteLogs(pMnode, pTrans->commitLogs);
|
||||||
|
if (code != 0) {
|
||||||
|
mError("failed to execute commitLogs since %s", terrstr());
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray) {
|
static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray) {
|
||||||
|
|
@ -966,6 +997,7 @@ static int32_t mndTransSendActionMsg(SMnode *pMnode, STrans *pTrans, SArray *pAr
|
||||||
pAction->msgReceived = 0;
|
pAction->msgReceived = 0;
|
||||||
pAction->errCode = 0;
|
pAction->errCode = 0;
|
||||||
} else {
|
} else {
|
||||||
|
if (terrno == TSDB_CODE_INVALID_PTR) rpcFreeCont(rpcMsg.pCont);
|
||||||
mError("trans:%d, action:%d not send since %s", pTrans->id, action, terrstr());
|
mError("trans:%d, action:%d not send since %s", pTrans->id, action, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -1012,11 +1044,19 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndTransExecuteRedoActions(SMnode *pMnode, STrans *pTrans) {
|
static int32_t mndTransExecuteRedoActions(SMnode *pMnode, STrans *pTrans) {
|
||||||
return mndTransExecuteActions(pMnode, pTrans, pTrans->redoActions);
|
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->redoActions);
|
||||||
|
if (code != 0) {
|
||||||
|
mError("failed to execute redoActions since %s", terrstr());
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndTransExecuteUndoActions(SMnode *pMnode, STrans *pTrans) {
|
static int32_t mndTransExecuteUndoActions(SMnode *pMnode, STrans *pTrans) {
|
||||||
return mndTransExecuteActions(pMnode, pTrans, pTrans->undoActions);
|
int32_t code = mndTransExecuteActions(pMnode, pTrans, pTrans->undoActions);
|
||||||
|
if (code != 0) {
|
||||||
|
mError("failed to execute undoActions since %s", terrstr());
|
||||||
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mndTransPerformPrepareStage(SMnode *pMnode, STrans *pTrans) {
|
static bool mndTransPerformPrepareStage(SMnode *pMnode, STrans *pTrans) {
|
||||||
|
|
@ -1083,8 +1123,8 @@ static bool mndTransPerformCommitStage(SMnode *pMnode, STrans *pTrans) {
|
||||||
} else {
|
} else {
|
||||||
pTrans->code = terrno;
|
pTrans->code = terrno;
|
||||||
if (pTrans->policy == TRN_POLICY_ROLLBACK) {
|
if (pTrans->policy == TRN_POLICY_ROLLBACK) {
|
||||||
pTrans->stage = TRN_STAGE_REDO_ACTION;
|
pTrans->stage = TRN_STAGE_UNDO_ACTION;
|
||||||
mError("trans:%d, stage from commit to redoAction since %s, failedTimes:%d", pTrans->id, terrstr(),
|
mError("trans:%d, stage from commit to undoAction since %s, failedTimes:%d", pTrans->id, terrstr(),
|
||||||
pTrans->failedTimes);
|
pTrans->failedTimes);
|
||||||
continueExec = true;
|
continueExec = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1109,7 +1149,7 @@ static bool mndTransPerformCommitLogStage(SMnode *pMnode, STrans *pTrans) {
|
||||||
} else {
|
} else {
|
||||||
pTrans->code = terrno;
|
pTrans->code = terrno;
|
||||||
pTrans->failedTimes++;
|
pTrans->failedTimes++;
|
||||||
mError("trans:%d, stage keep on commitLog since %s", pTrans->id, terrstr());
|
mError("trans:%d, stage keep on commitLog since %s, failedTimes:%d", pTrans->id, terrstr(), pTrans->failedTimes);
|
||||||
continueExec = false;
|
continueExec = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1145,7 +1185,7 @@ static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans) {
|
||||||
continueExec = false;
|
continueExec = false;
|
||||||
} else {
|
} else {
|
||||||
pTrans->failedTimes++;
|
pTrans->failedTimes++;
|
||||||
mError("trans:%d, stage keep on undoAction since %s", pTrans->id, terrstr());
|
mError("trans:%d, stage keep on undoAction since %s, failedTimes:%d", pTrans->id, terrstr(), pTrans->failedTimes);
|
||||||
continueExec = false;
|
continueExec = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1162,7 +1202,7 @@ static bool mndTransPerformRollbackStage(SMnode *pMnode, STrans *pTrans) {
|
||||||
continueExec = true;
|
continueExec = true;
|
||||||
} else {
|
} else {
|
||||||
pTrans->failedTimes++;
|
pTrans->failedTimes++;
|
||||||
mError("trans:%d, stage keep on rollback since %s", pTrans->id, terrstr());
|
mError("trans:%d, stage keep on rollback since %s, failedTimes:%d", pTrans->id, terrstr(), pTrans->failedTimes);
|
||||||
continueExec = false;
|
continueExec = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1281,19 +1321,19 @@ static int32_t mndProcessKillTransReq(SNodeMsg *pReq) {
|
||||||
|
|
||||||
if (tDeserializeSKillTransReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &killReq) != 0) {
|
if (tDeserializeSKillTransReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &killReq) != 0) {
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
terrno = TSDB_CODE_INVALID_MSG;
|
||||||
goto KILL_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo("trans:%d, start to kill", killReq.transId);
|
mInfo("trans:%d, start to kill", killReq.transId);
|
||||||
|
|
||||||
pUser = mndAcquireUser(pMnode, pReq->user);
|
pUser = mndAcquireUser(pMnode, pReq->user);
|
||||||
if (pUser == NULL) {
|
if (pUser == NULL) {
|
||||||
goto KILL_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pUser->superUser) {
|
if (!pUser->superUser) {
|
||||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||||
goto KILL_OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTrans = mndAcquireTrans(pMnode, killReq.transId);
|
pTrans = mndAcquireTrans(pMnode, killReq.transId);
|
||||||
|
|
@ -1305,7 +1345,7 @@ static int32_t mndProcessKillTransReq(SNodeMsg *pReq) {
|
||||||
|
|
||||||
code = mndKillTrans(pMnode, pTrans);
|
code = mndKillTrans(pMnode, pTrans);
|
||||||
|
|
||||||
KILL_OVER:
|
_OVER:
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
mError("trans:%d, failed to kill since %s", killReq.transId, terrstr());
|
mError("trans:%d, failed to kill since %s", killReq.transId, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -1360,10 +1400,10 @@ static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)dbname, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)dbname, false);
|
||||||
|
|
||||||
char transType[TSDB_TRANS_TYPE_LEN + VARSTR_HEADER_SIZE] = {0};
|
char type[TSDB_TRANS_TYPE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndTransType(pTrans->transType), pShow->pMeta->pSchemas[cols].bytes);
|
STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndTransType(pTrans->type), pShow->pMeta->pSchemas[cols].bytes);
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)transType, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)type, false);
|
||||||
|
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||||
colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false);
|
colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#define USER_RESERVE_SIZE 64
|
#define USER_RESERVE_SIZE 64
|
||||||
|
|
||||||
static int32_t mndCreateDefaultUsers(SMnode *pMnode);
|
static int32_t mndCreateDefaultUsers(SMnode *pMnode);
|
||||||
static SSdbRaw *mndUserActionEncode(SUserObj *pUser);
|
|
||||||
static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw);
|
static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw);
|
||||||
static int32_t mndUserActionInsert(SSdb *pSdb, SUserObj *pUser);
|
static int32_t mndUserActionInsert(SSdb *pSdb, SUserObj *pUser);
|
||||||
static int32_t mndUserActionDelete(SSdb *pSdb, SUserObj *pUser);
|
static int32_t mndUserActionDelete(SSdb *pSdb, SUserObj *pUser);
|
||||||
|
|
@ -90,7 +89,7 @@ static int32_t mndCreateDefaultUsers(SMnode *pMnode) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
|
SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
int32_t numOfReadDbs = taosHashGetSize(pUser->readDbs);
|
int32_t numOfReadDbs = taosHashGetSize(pUser->readDbs);
|
||||||
|
|
@ -238,7 +237,7 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SUserObj *mndAcquireUser(SMnode *pMnode, char *userName) {
|
SUserObj *mndAcquireUser(SMnode *pMnode, const char *userName) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
SUserObj *pUser = sdbAcquire(pSdb, SDB_USER, userName);
|
SUserObj *pUser = sdbAcquire(pSdb, SDB_USER, userName);
|
||||||
if (pUser == NULL) {
|
if (pUser == NULL) {
|
||||||
|
|
@ -276,9 +275,6 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
|
||||||
}
|
}
|
||||||
sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY);
|
sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY);
|
||||||
|
|
||||||
char *param = strdup("====> test code to be deleted later <=====");
|
|
||||||
mndTransSetCb(pTrans, TEST_TRANS_START_FUNC, TEST_TRANS_STOP_FUNC, param, strlen(param) + 1);
|
|
||||||
|
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,6 @@
|
||||||
#include "mndUser.h"
|
#include "mndUser.h"
|
||||||
#include "mndVgroup.h"
|
#include "mndVgroup.h"
|
||||||
|
|
||||||
#define MQ_TIMER_MS 2000
|
|
||||||
#define TRNAS_TIMER_MS 6000
|
|
||||||
|
|
||||||
static void *mndBuildTimerMsg(int32_t *pContLen) {
|
static void *mndBuildTimerMsg(int32_t *pContLen) {
|
||||||
SMTimerReq timerReq = {0};
|
SMTimerReq timerReq = {0};
|
||||||
|
|
||||||
|
|
@ -68,7 +65,7 @@ static void mndPullupTrans(void *param, void *tmrId) {
|
||||||
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTmrReset(mndPullupTrans, TRNAS_TIMER_MS, pMnode, pMnode->timer, &pMnode->transTimer);
|
taosTmrReset(mndPullupTrans, tsTransPullupMs, pMnode, pMnode->timer, &pMnode->transTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndCalMqRebalance(void *param, void *tmrId) {
|
static void mndCalMqRebalance(void *param, void *tmrId) {
|
||||||
|
|
@ -84,7 +81,7 @@ static void mndCalMqRebalance(void *param, void *tmrId) {
|
||||||
tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg);
|
tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTmrReset(mndCalMqRebalance, MQ_TIMER_MS, pMnode, pMnode->timer, &pMnode->mqTimer);
|
taosTmrReset(mndCalMqRebalance, tsMaRebalanceMs, pMnode, pMnode->timer, &pMnode->mqTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndPullupTelem(void *param, void *tmrId) {
|
static void mndPullupTelem(void *param, void *tmrId) {
|
||||||
|
|
@ -106,12 +103,12 @@ static int32_t mndInitTimer(SMnode *pMnode) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosTmrReset(mndPullupTrans, TRNAS_TIMER_MS, pMnode, pMnode->timer, &pMnode->transTimer)) {
|
if (taosTmrReset(mndPullupTrans, tsTransPullupMs, pMnode, pMnode->timer, &pMnode->transTimer)) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosTmrReset(mndCalMqRebalance, MQ_TIMER_MS, pMnode, pMnode->timer, &pMnode->mqTimer)) {
|
if (taosTmrReset(mndCalMqRebalance, tsMaRebalanceMs, pMnode, pMnode->timer, &pMnode->mqTimer)) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,31 @@
|
||||||
|
|
||||||
class MndTestSdb : public ::testing::Test {
|
class MndTestSdb : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
static void SetUpTestSuite() {}
|
static void SetUpTestSuite() {
|
||||||
static void TearDownTestSuite() {}
|
dDebugFlag = 143;
|
||||||
|
vDebugFlag = 0;
|
||||||
|
mDebugFlag = 143;
|
||||||
|
cDebugFlag = 0;
|
||||||
|
jniDebugFlag = 0;
|
||||||
|
tmrDebugFlag = 135;
|
||||||
|
uDebugFlag = 135;
|
||||||
|
rpcDebugFlag = 143;
|
||||||
|
qDebugFlag = 0;
|
||||||
|
wDebugFlag = 0;
|
||||||
|
sDebugFlag = 0;
|
||||||
|
tsdbDebugFlag = 0;
|
||||||
|
tsLogEmbedded = 1;
|
||||||
|
tsAsyncLog = 0;
|
||||||
|
|
||||||
|
const char *path = "/tmp/td";
|
||||||
|
taosRemoveDir(path);
|
||||||
|
taosMkDir(path);
|
||||||
|
tstrncpy(tsLogDir, path, PATH_MAX);
|
||||||
|
if (taosInitLog("taosdlog", 1) != 0) {
|
||||||
|
printf("failed to init log file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void TearDownTestSuite() { taosCloseLog(); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void SetUp() override {}
|
void SetUp() override {}
|
||||||
|
|
@ -26,6 +49,8 @@ class MndTestSdb : public ::testing::Test {
|
||||||
typedef struct SMnode {
|
typedef struct SMnode {
|
||||||
int32_t v100;
|
int32_t v100;
|
||||||
int32_t v200;
|
int32_t v200;
|
||||||
|
int32_t insertTimes;
|
||||||
|
int32_t deleteTimes;
|
||||||
SSdb *pSdb;
|
SSdb *pSdb;
|
||||||
} SMnode;
|
} SMnode;
|
||||||
|
|
||||||
|
|
@ -80,6 +105,48 @@ SSdbRaw *strEncode(SStrObj *pObj) {
|
||||||
return pRaw;
|
return pRaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SSdbRaw *i32Encode(SI32Obj *pObj) {
|
||||||
|
int32_t dataPos = 0;
|
||||||
|
SSdbRaw *pRaw = sdbAllocRaw(SDB_VGROUP, 2, sizeof(SI32Obj));
|
||||||
|
|
||||||
|
sdbSetRawInt32(pRaw, dataPos, pObj->key);
|
||||||
|
dataPos += sizeof(pObj->key);
|
||||||
|
sdbSetRawInt8(pRaw, dataPos, pObj->v8);
|
||||||
|
dataPos += sizeof(pObj->v8);
|
||||||
|
sdbSetRawInt16(pRaw, dataPos, pObj->v16);
|
||||||
|
dataPos += sizeof(pObj->v16);
|
||||||
|
sdbSetRawInt32(pRaw, dataPos, pObj->v32);
|
||||||
|
dataPos += sizeof(pObj->v32);
|
||||||
|
sdbSetRawInt64(pRaw, dataPos, pObj->v64);
|
||||||
|
dataPos += sizeof(pObj->v64);
|
||||||
|
sdbSetRawBinary(pRaw, dataPos, pObj->vstr, sizeof(pObj->vstr));
|
||||||
|
dataPos += sizeof(pObj->vstr);
|
||||||
|
sdbSetRawDataLen(pRaw, dataPos);
|
||||||
|
|
||||||
|
return pRaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSdbRaw *i64Encode(SI64Obj *pObj) {
|
||||||
|
int32_t dataPos = 0;
|
||||||
|
SSdbRaw *pRaw = sdbAllocRaw(SDB_CONSUMER, 3, sizeof(SI64Obj));
|
||||||
|
|
||||||
|
sdbSetRawInt64(pRaw, dataPos, pObj->key);
|
||||||
|
dataPos += sizeof(pObj->key);
|
||||||
|
sdbSetRawInt8(pRaw, dataPos, pObj->v8);
|
||||||
|
dataPos += sizeof(pObj->v8);
|
||||||
|
sdbSetRawInt16(pRaw, dataPos, pObj->v16);
|
||||||
|
dataPos += sizeof(pObj->v16);
|
||||||
|
sdbSetRawInt32(pRaw, dataPos, pObj->v32);
|
||||||
|
dataPos += sizeof(pObj->v32);
|
||||||
|
sdbSetRawInt64(pRaw, dataPos, pObj->v64);
|
||||||
|
dataPos += sizeof(pObj->v64);
|
||||||
|
sdbSetRawBinary(pRaw, dataPos, pObj->vstr, sizeof(pObj->vstr));
|
||||||
|
dataPos += sizeof(pObj->vstr);
|
||||||
|
sdbSetRawDataLen(pRaw, dataPos);
|
||||||
|
|
||||||
|
return pRaw;
|
||||||
|
}
|
||||||
|
|
||||||
SSdbRow *strDecode(SSdbRaw *pRaw) {
|
SSdbRow *strDecode(SSdbRaw *pRaw) {
|
||||||
int8_t sver = 0;
|
int8_t sver = 0;
|
||||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) return NULL;
|
if (sdbGetRawSoftVer(pRaw, &sver) != 0) return NULL;
|
||||||
|
|
@ -108,9 +175,103 @@ SSdbRow *strDecode(SSdbRaw *pRaw) {
|
||||||
return pRow;
|
return pRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t strInsert(SSdb *pSdb, SStrObj *pObj) { return 0; }
|
SSdbRow *i32Decode(SSdbRaw *pRaw) {
|
||||||
|
int8_t sver = 0;
|
||||||
|
if (sdbGetRawSoftVer(pRaw, &sver) != 0) return NULL;
|
||||||
|
if (sver != 2) return NULL;
|
||||||
|
|
||||||
int32_t strDelete(SSdb *pSdb, SStrObj *pObj, bool callFunc) { return 0; }
|
SSdbRow *pRow = sdbAllocRow(sizeof(SI32Obj));
|
||||||
|
if (pRow == NULL) return NULL;
|
||||||
|
|
||||||
|
SI32Obj *pObj = (SI32Obj *)sdbGetRowObj(pRow);
|
||||||
|
if (pObj == NULL) return NULL;
|
||||||
|
|
||||||
|
int32_t dataPos = 0;
|
||||||
|
sdbGetRawInt32(pRaw, dataPos, &pObj->key);
|
||||||
|
dataPos += sizeof(pObj->key);
|
||||||
|
sdbGetRawInt8(pRaw, dataPos, &pObj->v8);
|
||||||
|
dataPos += sizeof(pObj->v8);
|
||||||
|
sdbGetRawInt16(pRaw, dataPos, &pObj->v16);
|
||||||
|
dataPos += sizeof(pObj->v16);
|
||||||
|
sdbGetRawInt32(pRaw, dataPos, &pObj->v32);
|
||||||
|
dataPos += sizeof(pObj->v32);
|
||||||
|
sdbGetRawInt64(pRaw, dataPos, &pObj->v64);
|
||||||
|
dataPos += sizeof(pObj->v64);
|
||||||
|
sdbGetRawBinary(pRaw, dataPos, pObj->vstr, sizeof(pObj->vstr));
|
||||||
|
dataPos += sizeof(pObj->vstr);
|
||||||
|
|
||||||
|
return pRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSdbRow *i64Decode(SSdbRaw *pRaw) {
|
||||||
|
int8_t sver = 0;
|
||||||
|
if (sdbGetRawSoftVer(pRaw, &sver) != 0) return NULL;
|
||||||
|
if (sver != 3) return NULL;
|
||||||
|
|
||||||
|
SSdbRow *pRow = sdbAllocRow(sizeof(SI64Obj));
|
||||||
|
if (pRow == NULL) return NULL;
|
||||||
|
|
||||||
|
SI64Obj *pObj = (SI64Obj *)sdbGetRowObj(pRow);
|
||||||
|
if (pObj == NULL) return NULL;
|
||||||
|
|
||||||
|
int32_t dataPos = 0;
|
||||||
|
sdbGetRawInt64(pRaw, dataPos, &pObj->key);
|
||||||
|
dataPos += sizeof(pObj->key);
|
||||||
|
sdbGetRawInt8(pRaw, dataPos, &pObj->v8);
|
||||||
|
dataPos += sizeof(pObj->v8);
|
||||||
|
sdbGetRawInt16(pRaw, dataPos, &pObj->v16);
|
||||||
|
dataPos += sizeof(pObj->v16);
|
||||||
|
sdbGetRawInt32(pRaw, dataPos, &pObj->v32);
|
||||||
|
dataPos += sizeof(pObj->v32);
|
||||||
|
sdbGetRawInt64(pRaw, dataPos, &pObj->v64);
|
||||||
|
dataPos += sizeof(pObj->v64);
|
||||||
|
sdbGetRawBinary(pRaw, dataPos, pObj->vstr, sizeof(pObj->vstr));
|
||||||
|
dataPos += sizeof(pObj->vstr);
|
||||||
|
|
||||||
|
return pRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t strInsert(SSdb *pSdb, SStrObj *pObj) {
|
||||||
|
SMnode *pMnode = pSdb->pMnode;
|
||||||
|
pMnode->insertTimes++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t i32Insert(SSdb *pSdb, SI32Obj *pObj) {
|
||||||
|
SMnode *pMnode = pSdb->pMnode;
|
||||||
|
pMnode->insertTimes++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t i64Insert(SSdb *pSdb, SI64Obj *pObj) {
|
||||||
|
SMnode *pMnode = pSdb->pMnode;
|
||||||
|
pMnode->insertTimes++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t strDelete(SSdb *pSdb, SStrObj *pObj, bool callFunc) {
|
||||||
|
if (callFunc) {
|
||||||
|
SMnode *pMnode = pSdb->pMnode;
|
||||||
|
pMnode->deleteTimes++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t i32Delete(SSdb *pSdb, SI32Obj *pObj, bool callFunc) {
|
||||||
|
if (callFunc) {
|
||||||
|
SMnode *pMnode = pSdb->pMnode;
|
||||||
|
pMnode->deleteTimes++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t i64Delete(SSdb *pSdb, SI64Obj *pObj, bool callFunc) {
|
||||||
|
if (callFunc) {
|
||||||
|
SMnode *pMnode = pSdb->pMnode;
|
||||||
|
pMnode->deleteTimes++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t strUpdate(SSdb *pSdb, SStrObj *pOld, SStrObj *pNew) {
|
int32_t strUpdate(SSdb *pSdb, SStrObj *pOld, SStrObj *pNew) {
|
||||||
pOld->v8 = pNew->v8;
|
pOld->v8 = pNew->v8;
|
||||||
|
|
@ -121,6 +282,24 @@ int32_t strUpdate(SSdb *pSdb, SStrObj *pOld, SStrObj *pNew) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t i32Update(SSdb *pSdb, SI32Obj *pOld, SI32Obj *pNew) {
|
||||||
|
pOld->v8 = pNew->v8;
|
||||||
|
pOld->v16 = pNew->v16;
|
||||||
|
pOld->v32 = pNew->v32;
|
||||||
|
pOld->v64 = pNew->v64;
|
||||||
|
strcpy(pOld->vstr, pNew->vstr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t i64Update(SSdb *pSdb, SI64Obj *pOld, SI64Obj *pNew) {
|
||||||
|
pOld->v8 = pNew->v8;
|
||||||
|
pOld->v16 = pNew->v16;
|
||||||
|
pOld->v32 = pNew->v32;
|
||||||
|
pOld->v64 = pNew->v64;
|
||||||
|
strcpy(pOld->vstr, pNew->vstr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void strSetDefault(SStrObj *pObj, int32_t index) {
|
void strSetDefault(SStrObj *pObj, int32_t index) {
|
||||||
memset(pObj, 0, sizeof(SStrObj));
|
memset(pObj, 0, sizeof(SStrObj));
|
||||||
snprintf(pObj->key, sizeof(pObj->key), "k%d", index * 1000);
|
snprintf(pObj->key, sizeof(pObj->key), "k%d", index * 1000);
|
||||||
|
|
@ -131,6 +310,26 @@ void strSetDefault(SStrObj *pObj, int32_t index) {
|
||||||
snprintf(pObj->vstr, sizeof(pObj->vstr), "v%d", index * 1000);
|
snprintf(pObj->vstr, sizeof(pObj->vstr), "v%d", index * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void i32SetDefault(SI32Obj *pObj, int32_t index) {
|
||||||
|
memset(pObj, 0, sizeof(SI32Obj));
|
||||||
|
pObj->key = index;
|
||||||
|
pObj->v8 = index;
|
||||||
|
pObj->v16 = index;
|
||||||
|
pObj->v32 = index * 1000;
|
||||||
|
pObj->v64 = index * 1000;
|
||||||
|
snprintf(pObj->vstr, sizeof(pObj->vstr), "v%d", index * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void i64SetDefault(SI64Obj *pObj, int32_t index) {
|
||||||
|
memset(pObj, 0, sizeof(SI64Obj));
|
||||||
|
pObj->key = index;
|
||||||
|
pObj->v8 = index;
|
||||||
|
pObj->v16 = index;
|
||||||
|
pObj->v32 = index * 1000;
|
||||||
|
pObj->v64 = index * 1000;
|
||||||
|
snprintf(pObj->vstr, sizeof(pObj->vstr), "v%d", index * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t strDefault(SMnode *pMnode) {
|
int32_t strDefault(SMnode *pMnode) {
|
||||||
SStrObj strObj;
|
SStrObj strObj;
|
||||||
SSdbRaw *pRaw = NULL;
|
SSdbRaw *pRaw = NULL;
|
||||||
|
|
@ -144,6 +343,8 @@ int32_t strDefault(SMnode *pMnode) {
|
||||||
pRaw = strEncode(&strObj);
|
pRaw = strEncode(&strObj);
|
||||||
sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||||
if (sdbWriteWithoutFree(pMnode->pSdb, pRaw) != 0) return -1;
|
if (sdbWriteWithoutFree(pMnode->pSdb, pRaw) != 0) return -1;
|
||||||
|
|
||||||
|
EXPECT_EQ(sdbGetRawTotalSize(pRaw), 79);
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -151,28 +352,32 @@ int32_t strDefault(SMnode *pMnode) {
|
||||||
|
|
||||||
bool sdbTraverseSucc1(SMnode *pMnode, SStrObj *pObj, int32_t *p1, int32_t *p2, int32_t *p3) {
|
bool sdbTraverseSucc1(SMnode *pMnode, SStrObj *pObj, int32_t *p1, int32_t *p2, int32_t *p3) {
|
||||||
if (pObj->v8 == 1) {
|
if (pObj->v8 == 1) {
|
||||||
*p1 = *p2 + *p3 + pObj->v8;
|
*p1 += *p2 + *p3 + pObj->v8;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sdbTraverseSucc2(SMnode *pMnode, SStrObj *pObj, int32_t *p1, int32_t *p2, int32_t *p3) {
|
bool sdbTraverseSucc2(SMnode *pMnode, SStrObj *pObj, int32_t *p1, int32_t *p2, int32_t *p3) {
|
||||||
*p1 = *p2 + *p3 + pObj->v8;
|
*p1 += *p2 + *p3 + pObj->v8;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sdbTraverseFail(SMnode *pMnode, SStrObj *pObj, int32_t *p1, int32_t *p2, int32_t *p3) {
|
bool sdbTraverseFail(SMnode *pMnode, SStrObj *pObj, int32_t *p1, int32_t *p2, int32_t *p3) {
|
||||||
*p1 = *p2 + *p3;
|
*p1 += *p2 + *p3;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MndTestSdb, 01_Write) {
|
TEST_F(MndTestSdb, 01_Write_Str) {
|
||||||
void *pIter;
|
void *pIter = NULL;
|
||||||
int32_t num;
|
int32_t num = 0;
|
||||||
SStrObj *pObj;
|
SStrObj *pObj = NULL;
|
||||||
SMnode mnode;
|
SMnode mnode = {0};
|
||||||
SSdb *pSdb;
|
SSdb *pSdb = NULL;
|
||||||
SSdbOpt opt = {0};
|
SSdbOpt opt = {0};
|
||||||
|
SStrObj strObj = {0};
|
||||||
|
SI32Obj i32Obj = {0};
|
||||||
|
SI64Obj i64Obj = {0};
|
||||||
|
SSdbRaw *pRaw = NULL;
|
||||||
int32_t p1 = 0;
|
int32_t p1 = 0;
|
||||||
int32_t p2 = 111;
|
int32_t p2 = 111;
|
||||||
int32_t p3 = 222;
|
int32_t p3 = 222;
|
||||||
|
|
@ -183,42 +388,64 @@ TEST_F(MndTestSdb, 01_Write) {
|
||||||
opt.path = "/tmp/mnode_test_sdb";
|
opt.path = "/tmp/mnode_test_sdb";
|
||||||
taosRemoveDir(opt.path);
|
taosRemoveDir(opt.path);
|
||||||
|
|
||||||
SSdbTable strTable = {
|
SSdbTable strTable1;
|
||||||
SDB_USER,
|
memset(&strTable1, 0, sizeof(SSdbTable));
|
||||||
SDB_KEY_BINARY,
|
strTable1.sdbType = SDB_USER;
|
||||||
(SdbDeployFp)strDefault,
|
strTable1.keyType = SDB_KEY_BINARY;
|
||||||
(SdbEncodeFp)strEncode,
|
strTable1.deployFp = (SdbDeployFp)strDefault;
|
||||||
(SdbDecodeFp)strDecode,
|
strTable1.encodeFp = (SdbEncodeFp)strEncode;
|
||||||
(SdbInsertFp)strInsert,
|
strTable1.decodeFp = (SdbDecodeFp)strDecode;
|
||||||
(SdbUpdateFp)strUpdate,
|
strTable1.insertFp = (SdbInsertFp)strInsert;
|
||||||
(SdbDeleteFp)strDelete,
|
strTable1.updateFp = (SdbUpdateFp)strUpdate;
|
||||||
};
|
strTable1.deleteFp = (SdbDeleteFp)strDelete;
|
||||||
|
|
||||||
|
SSdbTable strTable2;
|
||||||
|
memset(&strTable2, 0, sizeof(SSdbTable));
|
||||||
|
strTable2.sdbType = SDB_VGROUP;
|
||||||
|
strTable2.keyType = SDB_KEY_INT32;
|
||||||
|
strTable2.encodeFp = (SdbEncodeFp)i32Encode;
|
||||||
|
strTable2.decodeFp = (SdbDecodeFp)i32Decode;
|
||||||
|
strTable2.insertFp = (SdbInsertFp)i32Insert;
|
||||||
|
strTable2.updateFp = (SdbUpdateFp)i32Update;
|
||||||
|
strTable2.deleteFp = (SdbDeleteFp)i32Delete;
|
||||||
|
|
||||||
|
SSdbTable strTable3;
|
||||||
|
memset(&strTable3, 0, sizeof(SSdbTable));
|
||||||
|
strTable3.sdbType = SDB_CONSUMER;
|
||||||
|
strTable3.keyType = SDB_KEY_INT64;
|
||||||
|
strTable3.encodeFp = (SdbEncodeFp)i64Encode;
|
||||||
|
strTable3.decodeFp = (SdbDecodeFp)i64Decode;
|
||||||
|
strTable3.insertFp = (SdbInsertFp)i64Insert;
|
||||||
|
strTable3.updateFp = (SdbUpdateFp)i64Update;
|
||||||
|
strTable3.deleteFp = (SdbDeleteFp)i64Delete;
|
||||||
|
|
||||||
pSdb = sdbInit(&opt);
|
pSdb = sdbInit(&opt);
|
||||||
mnode.pSdb = pSdb;
|
mnode.pSdb = pSdb;
|
||||||
|
|
||||||
ASSERT_NE(pSdb, nullptr);
|
ASSERT_NE(pSdb, nullptr);
|
||||||
ASSERT_EQ(sdbSetTable(pSdb, strTable), 0);
|
ASSERT_EQ(sdbSetTable(pSdb, strTable1), 0);
|
||||||
|
ASSERT_EQ(sdbSetTable(pSdb, strTable2), 0);
|
||||||
|
ASSERT_EQ(sdbSetTable(pSdb, strTable3), 0);
|
||||||
ASSERT_EQ(sdbDeploy(pSdb), 0);
|
ASSERT_EQ(sdbDeploy(pSdb), 0);
|
||||||
#if 0
|
|
||||||
pObj = (SStrObj *)sdbAcquire(pSdb, SDB_USER, "k1000");
|
pObj = (SStrObj *)sdbAcquire(pSdb, SDB_USER, "k1000");
|
||||||
ASSERT_NE(pObj, nullptr);
|
ASSERT_NE(pObj, nullptr);
|
||||||
EXPECT_STREQ(pObj->key, "k1000");
|
EXPECT_STREQ(pObj->key, "k1000");
|
||||||
EXPECT_STREQ(pObj->vstr, "v1000");
|
EXPECT_STREQ(pObj->vstr, "v1000");
|
||||||
EXPECT_EQ(pObj->v8, 1);
|
ASSERT_EQ(pObj->v8, 1);
|
||||||
EXPECT_EQ(pObj->v16, 1);
|
ASSERT_EQ(pObj->v16, 1);
|
||||||
EXPECT_EQ(pObj->v32, 1000);
|
ASSERT_EQ(pObj->v32, 1000);
|
||||||
EXPECT_EQ(pObj->v64, 1000);
|
ASSERT_EQ(pObj->v64, 1000);
|
||||||
sdbRelease(pSdb, pObj);
|
sdbRelease(pSdb, pObj);
|
||||||
|
|
||||||
pObj = (SStrObj *)sdbAcquire(pSdb, SDB_USER, "k2000");
|
pObj = (SStrObj *)sdbAcquire(pSdb, SDB_USER, "k2000");
|
||||||
ASSERT_NE(pObj, nullptr);
|
ASSERT_NE(pObj, nullptr);
|
||||||
EXPECT_STREQ(pObj->key, "k2000");
|
EXPECT_STREQ(pObj->key, "k2000");
|
||||||
EXPECT_STREQ(pObj->vstr, "v2000");
|
EXPECT_STREQ(pObj->vstr, "v2000");
|
||||||
EXPECT_EQ(pObj->v8, 2);
|
ASSERT_EQ(pObj->v8, 2);
|
||||||
EXPECT_EQ(pObj->v16, 2);
|
ASSERT_EQ(pObj->v16, 2);
|
||||||
EXPECT_EQ(pObj->v32, 2000);
|
ASSERT_EQ(pObj->v32, 2000);
|
||||||
EXPECT_EQ(pObj->v64, 2000);
|
ASSERT_EQ(pObj->v64, 2000);
|
||||||
sdbRelease(pSdb, pObj);
|
sdbRelease(pSdb, pObj);
|
||||||
|
|
||||||
pObj = (SStrObj *)sdbAcquire(pSdb, SDB_USER, "k200");
|
pObj = (SStrObj *)sdbAcquire(pSdb, SDB_USER, "k200");
|
||||||
|
|
@ -233,7 +460,7 @@ TEST_F(MndTestSdb, 01_Write) {
|
||||||
num++;
|
num++;
|
||||||
sdbRelease(pSdb, pObj);
|
sdbRelease(pSdb, pObj);
|
||||||
} while (1);
|
} while (1);
|
||||||
EXPECT_EQ(num, 2);
|
ASSERT_EQ(num, 2);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
pIter = sdbFetch(pSdb, SDB_USER, pIter, (void **)&pObj);
|
pIter = sdbFetch(pSdb, SDB_USER, pIter, (void **)&pObj);
|
||||||
|
|
@ -248,51 +475,254 @@ TEST_F(MndTestSdb, 01_Write) {
|
||||||
p1 = 0;
|
p1 = 0;
|
||||||
p2 = 111;
|
p2 = 111;
|
||||||
p3 = 222;
|
p3 = 222;
|
||||||
sdbTraverse(pSdb, SDB_USER, (sdbTraverseFp)sdbTraverseSucc2, &p1, &p2, &p3);
|
sdbTraverse(pSdb, SDB_USER, (sdbTraverseFp)sdbTraverseSucc1, &p1, &p2, &p3);
|
||||||
EXPECT_EQ(p1, 334);
|
ASSERT_EQ(p1, 334);
|
||||||
|
|
||||||
p1 = 0;
|
p1 = 0;
|
||||||
p2 = 111;
|
p2 = 111;
|
||||||
p3 = 222;
|
p3 = 222;
|
||||||
sdbTraverse(pSdb, SDB_USER, (sdbTraverseFp)sdbTraverseSucc2, &p1, &p2, &p3);
|
sdbTraverse(pSdb, SDB_USER, (sdbTraverseFp)sdbTraverseSucc2, &p1, &p2, &p3);
|
||||||
EXPECT_EQ(p1, 669);
|
ASSERT_EQ(p1, 669);
|
||||||
|
|
||||||
p1 = 0;
|
p1 = 0;
|
||||||
p2 = 111;
|
p2 = 111;
|
||||||
p3 = 222;
|
p3 = 222;
|
||||||
sdbTraverse(pSdb, SDB_USER, (sdbTraverseFp)sdbTraverseFail, &p1, &p2, &p3);
|
sdbTraverse(pSdb, SDB_USER, (sdbTraverseFp)sdbTraverseFail, &p1, &p2, &p3);
|
||||||
EXPECT_EQ(p1, 333);
|
ASSERT_EQ(p1, 333);
|
||||||
|
|
||||||
EXPECT_EQ(sdbGetSize(pSdb, SDB_USER), 2);
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_USER), 2);
|
||||||
EXPECT_EQ(sdbGetMaxId(pSdb, SDB_USER), -1);
|
ASSERT_EQ(sdbGetMaxId(pSdb, SDB_USER), -1);
|
||||||
EXPECT_EQ(sdbGetTableVer(pSdb, SDB_USER), 2);
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_USER), 2 );
|
||||||
EXPECT_EQ(sdbUpdateVer(pSdb, 0), 2);
|
ASSERT_EQ(sdbUpdateVer(pSdb, 0), -1);
|
||||||
EXPECT_EQ(sdbUpdateVer(pSdb, 1), 3);
|
ASSERT_EQ(sdbUpdateVer(pSdb, 1), 0);
|
||||||
EXPECT_EQ(sdbUpdateVer(pSdb, -1), 2);
|
ASSERT_EQ(sdbUpdateVer(pSdb, -1), -1);
|
||||||
|
ASSERT_EQ(mnode.insertTimes, 2);
|
||||||
|
ASSERT_EQ(mnode.deleteTimes, 0);
|
||||||
|
|
||||||
|
{
|
||||||
// insert, call func
|
// insert, call func
|
||||||
|
strSetDefault(&strObj, 3);
|
||||||
|
pRaw = strEncode(&strObj);
|
||||||
|
sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||||
|
ASSERT_EQ(sdbWrite(pSdb, pRaw), 0);
|
||||||
|
pObj = (SStrObj *)sdbAcquire(pSdb, SDB_USER, "k3000");
|
||||||
|
ASSERT_NE(pObj, nullptr);
|
||||||
|
EXPECT_STREQ(pObj->key, "k3000");
|
||||||
|
EXPECT_STREQ(pObj->vstr, "v3000");
|
||||||
|
ASSERT_EQ(pObj->v8, 3);
|
||||||
|
ASSERT_EQ(pObj->v16, 3);
|
||||||
|
ASSERT_EQ(pObj->v32, 3000);
|
||||||
|
ASSERT_EQ(pObj->v64, 3000);
|
||||||
|
sdbRelease(pSdb, pObj);
|
||||||
|
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_USER), 3);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_USER), 3);
|
||||||
|
ASSERT_EQ(sdbGetMaxId(pSdb, SDB_USER), -1);
|
||||||
|
|
||||||
// update, call func
|
// update, call func
|
||||||
|
strSetDefault(&strObj, 3);
|
||||||
|
strObj.v8 = 4;
|
||||||
|
pRaw = strEncode(&strObj);
|
||||||
|
sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||||
|
ASSERT_EQ(sdbWrite(pSdb, pRaw), 0);
|
||||||
|
pObj = (SStrObj *)sdbAcquire(pSdb, SDB_USER, "k3000");
|
||||||
|
ASSERT_NE(pObj, nullptr);
|
||||||
|
EXPECT_STREQ(pObj->key, "k3000");
|
||||||
|
EXPECT_STREQ(pObj->vstr, "v3000");
|
||||||
|
ASSERT_EQ(pObj->v8, 4);
|
||||||
|
ASSERT_EQ(pObj->v16, 3);
|
||||||
|
ASSERT_EQ(pObj->v32, 3000);
|
||||||
|
ASSERT_EQ(pObj->v64, 3000);
|
||||||
|
sdbRelease(pSdb, pObj);
|
||||||
|
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_USER), 3);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_USER), 4);
|
||||||
|
ASSERT_EQ(sdbUpdateVer(pSdb, 0), -1);
|
||||||
|
ASSERT_EQ(sdbUpdateVer(pSdb, 1), 0);
|
||||||
|
ASSERT_EQ(sdbUpdateVer(pSdb, -1), -1);
|
||||||
|
ASSERT_EQ(mnode.insertTimes, 3);
|
||||||
|
ASSERT_EQ(mnode.deleteTimes, 0);
|
||||||
|
|
||||||
// delete, call func 2
|
// delete, call func 2
|
||||||
|
strSetDefault(&strObj, 3);
|
||||||
|
strObj.v16 = 4;
|
||||||
|
pRaw = strEncode(&strObj);
|
||||||
|
sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED);
|
||||||
|
ASSERT_EQ(sdbWrite(pSdb, pRaw), 0);
|
||||||
|
pObj = (SStrObj *)sdbAcquire(pSdb, SDB_USER, "k3000");
|
||||||
|
ASSERT_EQ(pObj, nullptr);
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_USER), 2);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_USER), 5);
|
||||||
|
ASSERT_EQ(mnode.insertTimes, 3);
|
||||||
|
ASSERT_EQ(mnode.deleteTimes, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int32_t key = 4;
|
||||||
|
i32SetDefault(&i32Obj, key);
|
||||||
|
pRaw = i32Encode(&i32Obj);
|
||||||
|
sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||||
|
ASSERT_EQ(sdbWrite(pSdb, pRaw), 0);
|
||||||
|
SI32Obj *pI32Obj = (SI32Obj *)sdbAcquire(pSdb, SDB_VGROUP, &key);
|
||||||
|
ASSERT_NE(pI32Obj, nullptr);
|
||||||
|
ASSERT_EQ(pI32Obj->key, key);
|
||||||
|
ASSERT_EQ(pI32Obj->v8, 4);
|
||||||
|
ASSERT_EQ(pI32Obj->v16, 4);
|
||||||
|
ASSERT_EQ(pI32Obj->v32, 4000);
|
||||||
|
ASSERT_EQ(pI32Obj->v64, 4000);
|
||||||
|
sdbRelease(pSdb, pI32Obj);
|
||||||
|
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_VGROUP), 1);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_VGROUP), 1);
|
||||||
|
ASSERT_EQ(sdbGetMaxId(pSdb, SDB_VGROUP), 5);
|
||||||
|
|
||||||
|
i32SetDefault(&i32Obj, key);
|
||||||
|
i32Obj.v8 = 5;
|
||||||
|
pRaw = i32Encode(&i32Obj);
|
||||||
|
sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||||
|
ASSERT_EQ(sdbWrite(pSdb, pRaw), 0);
|
||||||
|
pI32Obj = (SI32Obj *)sdbAcquire(pSdb, SDB_VGROUP, &key);
|
||||||
|
ASSERT_NE(pI32Obj, nullptr);
|
||||||
|
ASSERT_EQ(pI32Obj->key, key);
|
||||||
|
ASSERT_EQ(pI32Obj->v8, 5);
|
||||||
|
ASSERT_EQ(pI32Obj->v16, 4);
|
||||||
|
ASSERT_EQ(pI32Obj->v32, 4000);
|
||||||
|
ASSERT_EQ(pI32Obj->v64, 4000);
|
||||||
|
sdbRelease(pSdb, pI32Obj);
|
||||||
|
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_VGROUP), 1);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_VGROUP), 2);
|
||||||
|
ASSERT_EQ(mnode.insertTimes, 4);
|
||||||
|
ASSERT_EQ(mnode.deleteTimes, 1);
|
||||||
|
|
||||||
|
// delete, call func 2
|
||||||
|
key = 4;
|
||||||
|
i32SetDefault(&i32Obj, key);
|
||||||
|
pRaw = i32Encode(&i32Obj);
|
||||||
|
sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED);
|
||||||
|
ASSERT_EQ(sdbWrite(pSdb, pRaw), 0);
|
||||||
|
pI32Obj = (SI32Obj *)sdbAcquire(pSdb, SDB_VGROUP, &key);
|
||||||
|
ASSERT_EQ(pI32Obj, nullptr);
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_VGROUP), 0);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_VGROUP), 3);
|
||||||
|
ASSERT_EQ(sdbGetMaxId(pSdb, SDB_VGROUP), 5);
|
||||||
|
ASSERT_EQ(mnode.insertTimes, 4);
|
||||||
|
ASSERT_EQ(mnode.deleteTimes, 2);
|
||||||
|
|
||||||
|
key = 6;
|
||||||
|
i32SetDefault(&i32Obj, key);
|
||||||
|
pRaw = i32Encode(&i32Obj);
|
||||||
|
sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||||
|
ASSERT_EQ(sdbWrite(pSdb, pRaw), 0);
|
||||||
|
pI32Obj = (SI32Obj *)sdbAcquire(pSdb, SDB_VGROUP, &key);
|
||||||
|
ASSERT_NE(pI32Obj, nullptr);
|
||||||
|
ASSERT_EQ(pI32Obj->key, key);
|
||||||
|
ASSERT_EQ(pI32Obj->v8, 6);
|
||||||
|
ASSERT_EQ(pI32Obj->v16, 6);
|
||||||
|
ASSERT_EQ(pI32Obj->v32, 6000);
|
||||||
|
ASSERT_EQ(pI32Obj->v64, 6000);
|
||||||
|
sdbRelease(pSdb, pI32Obj);
|
||||||
|
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_VGROUP), 1);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_VGROUP), 4);
|
||||||
|
ASSERT_EQ(sdbGetMaxId(pSdb, SDB_VGROUP), 7);
|
||||||
|
ASSERT_EQ(mnode.insertTimes, 5);
|
||||||
|
ASSERT_EQ(mnode.deleteTimes, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int64_t key = 4;
|
||||||
|
i64SetDefault(&i64Obj, key);
|
||||||
|
pRaw = i64Encode(&i64Obj);
|
||||||
|
sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||||
|
ASSERT_EQ(sdbWrite(pSdb, pRaw), 0);
|
||||||
|
SI64Obj *pI64Obj = (SI64Obj *)sdbAcquire(pSdb, SDB_CONSUMER, &key);
|
||||||
|
ASSERT_NE(pI64Obj, nullptr);
|
||||||
|
ASSERT_EQ(pI64Obj->key, key);
|
||||||
|
ASSERT_EQ(pI64Obj->v8, 4);
|
||||||
|
ASSERT_EQ(pI64Obj->v16, 4);
|
||||||
|
ASSERT_EQ(pI64Obj->v32, 4000);
|
||||||
|
ASSERT_EQ(pI64Obj->v64, 4000);
|
||||||
|
sdbRelease(pSdb, pI64Obj);
|
||||||
|
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_CONSUMER), 1);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_CONSUMER), 1);
|
||||||
|
ASSERT_EQ(sdbGetMaxId(pSdb, SDB_CONSUMER), -1);
|
||||||
|
|
||||||
|
i64SetDefault(&i64Obj, key);
|
||||||
|
i64Obj.v8 = 5;
|
||||||
|
pRaw = i64Encode(&i64Obj);
|
||||||
|
sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||||
|
ASSERT_EQ(sdbWrite(pSdb, pRaw), 0);
|
||||||
|
pI64Obj = (SI64Obj *)sdbAcquire(pSdb, SDB_CONSUMER, &key);
|
||||||
|
ASSERT_NE(pI64Obj, nullptr);
|
||||||
|
ASSERT_EQ(pI64Obj->key, key);
|
||||||
|
ASSERT_EQ(pI64Obj->v8, 5);
|
||||||
|
ASSERT_EQ(pI64Obj->v16, 4);
|
||||||
|
ASSERT_EQ(pI64Obj->v32, 4000);
|
||||||
|
ASSERT_EQ(pI64Obj->v64, 4000);
|
||||||
|
sdbRelease(pSdb, pI64Obj);
|
||||||
|
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_CONSUMER), 1);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_CONSUMER), 2);
|
||||||
|
ASSERT_EQ(mnode.insertTimes, 6);
|
||||||
|
ASSERT_EQ(mnode.deleteTimes, 2);
|
||||||
|
|
||||||
|
// delete, call func 2
|
||||||
|
key = 4;
|
||||||
|
i64SetDefault(&i64Obj, key);
|
||||||
|
pRaw = i64Encode(&i64Obj);
|
||||||
|
sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED);
|
||||||
|
ASSERT_EQ(sdbWrite(pSdb, pRaw), 0);
|
||||||
|
pObj = (SStrObj *)sdbAcquire(pSdb, SDB_CONSUMER, &key);
|
||||||
|
ASSERT_EQ(pObj, nullptr);
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_CONSUMER), 0);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_CONSUMER), 3);
|
||||||
|
ASSERT_EQ(sdbGetMaxId(pSdb, SDB_CONSUMER), -1);
|
||||||
|
ASSERT_EQ(mnode.insertTimes, 6);
|
||||||
|
ASSERT_EQ(mnode.deleteTimes, 3);
|
||||||
|
|
||||||
|
key = 7;
|
||||||
|
i64SetDefault(&i64Obj, key);
|
||||||
|
pRaw = i64Encode(&i64Obj);
|
||||||
|
sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||||
|
ASSERT_EQ(sdbWrite(pSdb, pRaw), 0);
|
||||||
|
pI64Obj = (SI64Obj *)sdbAcquire(pSdb, SDB_CONSUMER, &key);
|
||||||
|
ASSERT_NE(pI64Obj, nullptr);
|
||||||
|
ASSERT_EQ(pI64Obj->key, key);
|
||||||
|
ASSERT_EQ(pI64Obj->v8, 7);
|
||||||
|
ASSERT_EQ(pI64Obj->v16, 7);
|
||||||
|
ASSERT_EQ(pI64Obj->v32, 7000);
|
||||||
|
ASSERT_EQ(pI64Obj->v64, 7000);
|
||||||
|
sdbRelease(pSdb, pI64Obj);
|
||||||
|
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_CONSUMER), 1);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_CONSUMER), 4);
|
||||||
|
ASSERT_EQ(sdbGetMaxId(pSdb, SDB_CONSUMER), -1);
|
||||||
|
ASSERT_EQ(mnode.insertTimes, 7);
|
||||||
|
ASSERT_EQ(mnode.deleteTimes, 3);
|
||||||
|
}
|
||||||
|
|
||||||
// write version
|
// write version
|
||||||
|
ASSERT_EQ(sdbUpdateVer(pSdb, 1), 0);
|
||||||
// sdb Write ver
|
ASSERT_EQ(sdbUpdateVer(pSdb, 1), 1);
|
||||||
|
|
||||||
// sdbRead
|
|
||||||
#endif
|
|
||||||
ASSERT_EQ(sdbWriteFile(pSdb), 0);
|
ASSERT_EQ(sdbWriteFile(pSdb), 0);
|
||||||
|
ASSERT_EQ(sdbWriteFile(pSdb), 0);
|
||||||
|
|
||||||
sdbCleanup(pSdb);
|
sdbCleanup(pSdb);
|
||||||
|
ASSERT_EQ(mnode.insertTimes, 7);
|
||||||
|
ASSERT_EQ(mnode.deleteTimes, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MndTestSdb, 01_Read) {
|
TEST_F(MndTestSdb, 01_Read_Str) {
|
||||||
void *pIter;
|
void *pIter = NULL;
|
||||||
int32_t num;
|
int32_t num = 0;
|
||||||
SStrObj *pObj;
|
SStrObj *pObj = NULL;
|
||||||
SMnode mnode;
|
SMnode mnode = {0};
|
||||||
SSdb *pSdb;
|
SSdb *pSdb = NULL;
|
||||||
SSdbOpt opt = {0};
|
SSdbOpt opt = {0};
|
||||||
|
SStrObj strObj = {0};
|
||||||
|
SSdbRaw *pRaw = NULL;
|
||||||
int32_t p1 = 0;
|
int32_t p1 = 0;
|
||||||
int32_t p2 = 111;
|
int32_t p2 = 111;
|
||||||
int32_t p3 = 222;
|
int32_t p3 = 222;
|
||||||
|
|
@ -301,22 +731,174 @@ TEST_F(MndTestSdb, 01_Read) {
|
||||||
mnode.v200 = 200;
|
mnode.v200 = 200;
|
||||||
opt.pMnode = &mnode;
|
opt.pMnode = &mnode;
|
||||||
opt.path = "/tmp/mnode_test_sdb";
|
opt.path = "/tmp/mnode_test_sdb";
|
||||||
taosRemoveDir(opt.path);
|
|
||||||
|
|
||||||
SSdbTable strTable = {
|
SSdbTable strTable1;
|
||||||
SDB_USER,
|
memset(&strTable1, 0, sizeof(SSdbTable));
|
||||||
SDB_KEY_BINARY,
|
strTable1.sdbType = SDB_USER;
|
||||||
(SdbDeployFp)strDefault,
|
strTable1.keyType = SDB_KEY_BINARY;
|
||||||
(SdbEncodeFp)strEncode,
|
strTable1.deployFp = (SdbDeployFp)strDefault;
|
||||||
(SdbDecodeFp)strDecode,
|
strTable1.encodeFp = (SdbEncodeFp)strEncode;
|
||||||
(SdbInsertFp)strInsert,
|
strTable1.decodeFp = (SdbDecodeFp)strDecode;
|
||||||
(SdbUpdateFp)strUpdate,
|
strTable1.insertFp = (SdbInsertFp)strInsert;
|
||||||
(SdbDeleteFp)strDelete,
|
strTable1.updateFp = (SdbUpdateFp)strUpdate;
|
||||||
};
|
strTable1.deleteFp = (SdbDeleteFp)strDelete;
|
||||||
|
|
||||||
|
SSdbTable strTable2;
|
||||||
|
memset(&strTable2, 0, sizeof(SSdbTable));
|
||||||
|
strTable2.sdbType = SDB_VGROUP;
|
||||||
|
strTable2.keyType = SDB_KEY_INT32;
|
||||||
|
strTable2.encodeFp = (SdbEncodeFp)i32Encode;
|
||||||
|
strTable2.decodeFp = (SdbDecodeFp)i32Decode;
|
||||||
|
strTable2.insertFp = (SdbInsertFp)i32Insert;
|
||||||
|
strTable2.updateFp = (SdbUpdateFp)i32Update;
|
||||||
|
strTable2.deleteFp = (SdbDeleteFp)i32Delete;
|
||||||
|
|
||||||
|
SSdbTable strTable3;
|
||||||
|
memset(&strTable3, 0, sizeof(SSdbTable));
|
||||||
|
strTable3.sdbType = SDB_CONSUMER;
|
||||||
|
strTable3.keyType = SDB_KEY_INT64;
|
||||||
|
strTable3.encodeFp = (SdbEncodeFp)i64Encode;
|
||||||
|
strTable3.decodeFp = (SdbDecodeFp)i64Decode;
|
||||||
|
strTable3.insertFp = (SdbInsertFp)i64Insert;
|
||||||
|
strTable3.updateFp = (SdbUpdateFp)i64Update;
|
||||||
|
strTable3.deleteFp = (SdbDeleteFp)i64Delete;
|
||||||
|
|
||||||
pSdb = sdbInit(&opt);
|
pSdb = sdbInit(&opt);
|
||||||
mnode.pSdb = pSdb;
|
mnode.pSdb = pSdb;
|
||||||
|
ASSERT_NE(pSdb, nullptr);
|
||||||
|
ASSERT_NE(pSdb, nullptr);
|
||||||
|
ASSERT_EQ(sdbSetTable(pSdb, strTable1), 0);
|
||||||
|
ASSERT_EQ(sdbSetTable(pSdb, strTable2), 0);
|
||||||
|
ASSERT_EQ(sdbSetTable(pSdb, strTable3), 0);
|
||||||
ASSERT_EQ(sdbReadFile(pSdb), 0);
|
ASSERT_EQ(sdbReadFile(pSdb), 0);
|
||||||
|
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_USER), 2);
|
||||||
|
ASSERT_EQ(sdbGetMaxId(pSdb, SDB_USER), -1);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_USER), 5);
|
||||||
|
ASSERT_EQ(sdbUpdateVer(pSdb, 0), 1);
|
||||||
|
ASSERT_EQ(mnode.insertTimes, 4);
|
||||||
|
ASSERT_EQ(mnode.deleteTimes, 0);
|
||||||
|
|
||||||
|
pObj = (SStrObj *)sdbAcquire(pSdb, SDB_USER, "k1000");
|
||||||
|
ASSERT_NE(pObj, nullptr);
|
||||||
|
EXPECT_STREQ(pObj->key, "k1000");
|
||||||
|
EXPECT_STREQ(pObj->vstr, "v1000");
|
||||||
|
ASSERT_EQ(pObj->v8, 1);
|
||||||
|
ASSERT_EQ(pObj->v16, 1);
|
||||||
|
ASSERT_EQ(pObj->v32, 1000);
|
||||||
|
ASSERT_EQ(pObj->v64, 1000);
|
||||||
|
sdbRelease(pSdb, pObj);
|
||||||
|
|
||||||
|
pObj = (SStrObj *)sdbAcquire(pSdb, SDB_USER, "k2000");
|
||||||
|
ASSERT_NE(pObj, nullptr);
|
||||||
|
EXPECT_STREQ(pObj->key, "k2000");
|
||||||
|
EXPECT_STREQ(pObj->vstr, "v2000");
|
||||||
|
ASSERT_EQ(pObj->v8, 2);
|
||||||
|
ASSERT_EQ(pObj->v16, 2);
|
||||||
|
ASSERT_EQ(pObj->v32, 2000);
|
||||||
|
ASSERT_EQ(pObj->v64, 2000);
|
||||||
|
sdbRelease(pSdb, pObj);
|
||||||
|
|
||||||
|
pObj = (SStrObj *)sdbAcquire(pSdb, SDB_USER, "k200");
|
||||||
|
ASSERT_EQ(pObj, nullptr);
|
||||||
|
|
||||||
|
pIter = NULL;
|
||||||
|
num = 0;
|
||||||
|
do {
|
||||||
|
pIter = sdbFetch(pSdb, SDB_USER, pIter, (void **)&pObj);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
ASSERT_NE(pObj, nullptr);
|
||||||
|
num++;
|
||||||
|
sdbRelease(pSdb, pObj);
|
||||||
|
} while (1);
|
||||||
|
ASSERT_EQ(num, 2);
|
||||||
|
|
||||||
|
do {
|
||||||
|
pIter = sdbFetch(pSdb, SDB_USER, pIter, (void **)&pObj);
|
||||||
|
if (pIter == NULL) break;
|
||||||
|
if (strcmp(pObj->key, "k1000") == 0) {
|
||||||
|
sdbCancelFetch(pSdb, pIter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (1);
|
||||||
|
EXPECT_STREQ(pObj->key, "k1000");
|
||||||
|
|
||||||
|
p1 = 0;
|
||||||
|
p2 = 111;
|
||||||
|
p3 = 222;
|
||||||
|
sdbTraverse(pSdb, SDB_USER, (sdbTraverseFp)sdbTraverseSucc1, &p1, &p2, &p3);
|
||||||
|
ASSERT_EQ(p1, 334);
|
||||||
|
|
||||||
|
p1 = 0;
|
||||||
|
p2 = 111;
|
||||||
|
p3 = 222;
|
||||||
|
sdbTraverse(pSdb, SDB_USER, (sdbTraverseFp)sdbTraverseSucc2, &p1, &p2, &p3);
|
||||||
|
ASSERT_EQ(p1, 669);
|
||||||
|
|
||||||
|
p1 = 0;
|
||||||
|
p2 = 111;
|
||||||
|
p3 = 222;
|
||||||
|
sdbTraverse(pSdb, SDB_USER, (sdbTraverseFp)sdbTraverseFail, &p1, &p2, &p3);
|
||||||
|
ASSERT_EQ(p1, 333);
|
||||||
|
|
||||||
|
int32_t i32key = 6;
|
||||||
|
SI32Obj *pI32Obj = (SI32Obj *)sdbAcquire(pSdb, SDB_VGROUP, &i32key);
|
||||||
|
ASSERT_NE(pI32Obj, nullptr);
|
||||||
|
ASSERT_EQ(pI32Obj->key, 6);
|
||||||
|
ASSERT_EQ(pI32Obj->v8, 6);
|
||||||
|
ASSERT_EQ(pI32Obj->v16, 6);
|
||||||
|
ASSERT_EQ(pI32Obj->v32, 6000);
|
||||||
|
ASSERT_EQ(pI32Obj->v64, 6000);
|
||||||
|
sdbRelease(pSdb, pI32Obj);
|
||||||
|
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_VGROUP), 1);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_VGROUP), 4);
|
||||||
|
ASSERT_EQ(sdbGetMaxId(pSdb, SDB_VGROUP), 7);
|
||||||
|
|
||||||
|
int64_t i64key = 7;
|
||||||
|
SI64Obj *pI64Obj = (SI64Obj *)sdbAcquire(pSdb, SDB_CONSUMER, &i64key);
|
||||||
|
ASSERT_NE(pI64Obj, nullptr);
|
||||||
|
ASSERT_EQ(pI64Obj->key, 7);
|
||||||
|
ASSERT_EQ(pI64Obj->v8, 7);
|
||||||
|
ASSERT_EQ(pI64Obj->v16, 7);
|
||||||
|
ASSERT_EQ(pI64Obj->v32, 7000);
|
||||||
|
ASSERT_EQ(pI64Obj->v64, 7000);
|
||||||
|
sdbRelease(pSdb, pI64Obj);
|
||||||
|
|
||||||
|
ASSERT_EQ(sdbGetSize(pSdb, SDB_CONSUMER), 1);
|
||||||
|
ASSERT_EQ(sdbGetTableVer(pSdb, SDB_CONSUMER), 4);
|
||||||
|
|
||||||
|
ASSERT_EQ(mnode.insertTimes, 4);
|
||||||
|
ASSERT_EQ(mnode.deleteTimes, 0);
|
||||||
|
|
||||||
|
{
|
||||||
|
SI32Obj i32Obj = {0};
|
||||||
|
int32_t key = 6;
|
||||||
|
i32SetDefault(&i32Obj, key);
|
||||||
|
pRaw = i32Encode(&i32Obj);
|
||||||
|
sdbSetRawStatus(pRaw, SDB_STATUS_DROPPING);
|
||||||
|
ASSERT_EQ(sdbWrite(pSdb, pRaw), 0);
|
||||||
|
pI32Obj = (SI32Obj *)sdbAcquire(pSdb, SDB_VGROUP, &key);
|
||||||
|
ASSERT_EQ(pI32Obj, nullptr);
|
||||||
|
int32_t code = terrno;
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SDB_OBJ_DROPPING);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
SI32Obj i32Obj = {0};
|
||||||
|
int32_t key = 8;
|
||||||
|
i32SetDefault(&i32Obj, key);
|
||||||
|
pRaw = i32Encode(&i32Obj);
|
||||||
|
EXPECT_NE(sdbSetRawStatus(pRaw, SDB_STATUS_INIT), 0);
|
||||||
|
sdbSetRawStatus(pRaw, SDB_STATUS_CREATING);
|
||||||
|
ASSERT_EQ(sdbWrite(pSdb, pRaw), 0);
|
||||||
|
pI32Obj = (SI32Obj *)sdbAcquire(pSdb, SDB_VGROUP, &key);
|
||||||
|
ASSERT_EQ(pI32Obj, nullptr);
|
||||||
|
int32_t code = terrno;
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SDB_OBJ_CREATING);
|
||||||
|
}
|
||||||
|
|
||||||
sdbCleanup(pSdb);
|
sdbCleanup(pSdb);
|
||||||
|
ASSERT_EQ(mnode.insertTimes, 5);
|
||||||
|
ASSERT_EQ(mnode.deleteTimes, 5);
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,37 @@
|
||||||
aux_source_directory(. MNODE_TRANS_TEST_SRC)
|
add_executable(transTest1 "")
|
||||||
add_executable(transTest ${MNODE_TRANS_TEST_SRC})
|
target_sources(transTest1
|
||||||
|
PRIVATE
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/trans1.cpp"
|
||||||
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
transTest
|
transTest1
|
||||||
PUBLIC sut
|
PUBLIC sut
|
||||||
)
|
)
|
||||||
|
target_include_directories(
|
||||||
add_test(
|
transTest1
|
||||||
NAME transTest
|
PUBLIC "${TD_SOURCE_DIR}/include/dnode/mnode"
|
||||||
COMMAND transTest
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../inc"
|
||||||
|
)
|
||||||
|
add_test(
|
||||||
|
NAME transTest1
|
||||||
|
COMMAND transTest1
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(transTest2 "")
|
||||||
|
target_sources(transTest2
|
||||||
|
PRIVATE
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/trans2.cpp"
|
||||||
|
)
|
||||||
|
target_link_libraries(
|
||||||
|
transTest2
|
||||||
|
PUBLIC dnode mnode gtest_main
|
||||||
|
)
|
||||||
|
target_include_directories(
|
||||||
|
transTest2
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/dnode/mnode"
|
||||||
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../inc"
|
||||||
|
)
|
||||||
|
add_test(
|
||||||
|
NAME transTest2
|
||||||
|
COMMAND transTest2
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,10 @@
|
||||||
|
|
||||||
#include "sut.h"
|
#include "sut.h"
|
||||||
|
|
||||||
class MndTestTrans : public ::testing::Test {
|
class MndTestTrans1 : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
static void SetUpTestSuite() {
|
static void SetUpTestSuite() {
|
||||||
test.Init("/tmp/mnode_test_trans", 9013);
|
test.Init("/tmp/mnode_test_trans1", 9013);
|
||||||
const char* fqdn = "localhost";
|
const char* fqdn = "localhost";
|
||||||
const char* firstEp = "localhost:9013";
|
const char* firstEp = "localhost:9013";
|
||||||
server2.Start("/tmp/mnode_test_trans2", fqdn, 9020, firstEp);
|
server2.Start("/tmp/mnode_test_trans2", fqdn, 9020, firstEp);
|
||||||
|
|
@ -26,7 +26,7 @@ class MndTestTrans : public ::testing::Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void KillThenRestartServer() {
|
static void KillThenRestartServer() {
|
||||||
char file[PATH_MAX] = "/tmp/mnode_test_trans/mnode/data/sdb.data";
|
char file[PATH_MAX] = "/tmp/mnode_test_trans1/mnode/data/sdb.data";
|
||||||
TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ);
|
TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ);
|
||||||
int32_t size = 3 * 1024 * 1024;
|
int32_t size = 3 * 1024 * 1024;
|
||||||
void* buffer = taosMemoryMalloc(size);
|
void* buffer = taosMemoryMalloc(size);
|
||||||
|
|
@ -60,10 +60,10 @@ class MndTestTrans : public ::testing::Test {
|
||||||
void TearDown() override {}
|
void TearDown() override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
Testbase MndTestTrans::test;
|
Testbase MndTestTrans1::test;
|
||||||
TestServer MndTestTrans::server2;
|
TestServer MndTestTrans1::server2;
|
||||||
|
|
||||||
TEST_F(MndTestTrans, 00_Create_User_Crash) {
|
TEST_F(MndTestTrans1, 00_Create_User_Crash) {
|
||||||
{
|
{
|
||||||
test.SendShowReq(TSDB_MGMT_TABLE_TRANS, "trans", "");
|
test.SendShowReq(TSDB_MGMT_TABLE_TRANS, "trans", "");
|
||||||
EXPECT_EQ(test.GetShowRows(), 0);
|
EXPECT_EQ(test.GetShowRows(), 0);
|
||||||
|
|
@ -83,7 +83,7 @@ TEST_F(MndTestTrans, 00_Create_User_Crash) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MndTestTrans, 01_Create_User_Crash) {
|
TEST_F(MndTestTrans1, 01_Create_User_Crash) {
|
||||||
{
|
{
|
||||||
SCreateUserReq createReq = {0};
|
SCreateUserReq createReq = {0};
|
||||||
strcpy(createReq.user, "u1");
|
strcpy(createReq.user, "u1");
|
||||||
|
|
@ -107,7 +107,7 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
|
||||||
EXPECT_EQ(test.GetShowRows(), 2);
|
EXPECT_EQ(test.GetShowRows(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
|
TEST_F(MndTestTrans1, 02_Create_Qnode1_Crash) {
|
||||||
{
|
{
|
||||||
SMCreateQnodeReq createReq = {0};
|
SMCreateQnodeReq createReq = {0};
|
||||||
createReq.dnodeId = 1;
|
createReq.dnodeId = 1;
|
||||||
|
|
@ -142,7 +142,7 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
|
TEST_F(MndTestTrans1, 03_Create_Qnode2_Crash) {
|
||||||
{
|
{
|
||||||
SCreateDnodeReq createReq = {0};
|
SCreateDnodeReq createReq = {0};
|
||||||
strcpy(createReq.fqdn, "localhost");
|
strcpy(createReq.fqdn, "localhost");
|
||||||
|
|
@ -0,0 +1,308 @@
|
||||||
|
/**
|
||||||
|
* @file trans.cpp
|
||||||
|
* @author slguan (slguan@taosdata.com)
|
||||||
|
* @brief MNODE module trans tests
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2022-05-02
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2022
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "mndTrans.h"
|
||||||
|
#include "mndUser.h"
|
||||||
|
#include "tcache.h"
|
||||||
|
|
||||||
|
void reportStartup(SMgmtWrapper *pWrapper, const char *name, const char *desc) {}
|
||||||
|
|
||||||
|
class MndTestTrans2 : public ::testing::Test {
|
||||||
|
protected:
|
||||||
|
static void InitLog() {
|
||||||
|
dDebugFlag = 143;
|
||||||
|
vDebugFlag = 0;
|
||||||
|
mDebugFlag = 207;
|
||||||
|
cDebugFlag = 0;
|
||||||
|
jniDebugFlag = 0;
|
||||||
|
tmrDebugFlag = 135;
|
||||||
|
uDebugFlag = 135;
|
||||||
|
rpcDebugFlag = 143;
|
||||||
|
qDebugFlag = 0;
|
||||||
|
wDebugFlag = 0;
|
||||||
|
sDebugFlag = 0;
|
||||||
|
tsdbDebugFlag = 0;
|
||||||
|
tsLogEmbedded = 1;
|
||||||
|
tsAsyncLog = 0;
|
||||||
|
|
||||||
|
const char *logpath = "/tmp/td";
|
||||||
|
taosRemoveDir(logpath);
|
||||||
|
taosMkDir(logpath);
|
||||||
|
tstrncpy(tsLogDir, logpath, PATH_MAX);
|
||||||
|
if (taosInitLog("taosdlog", 1) != 0) {
|
||||||
|
printf("failed to init log file\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void InitMnode() {
|
||||||
|
static SMsgCb msgCb = {0};
|
||||||
|
msgCb.reportStartupFp = reportStartup;
|
||||||
|
msgCb.pWrapper = (SMgmtWrapper *)(&msgCb); // hack
|
||||||
|
tmsgSetDefaultMsgCb(&msgCb);
|
||||||
|
|
||||||
|
SMnodeOpt opt = {0};
|
||||||
|
opt.deploy = 1;
|
||||||
|
opt.replica = 1;
|
||||||
|
opt.replicas[0].id = 1;
|
||||||
|
opt.replicas[0].port = 9040;
|
||||||
|
strcpy(opt.replicas[0].fqdn, "localhost");
|
||||||
|
opt.msgCb = msgCb;
|
||||||
|
|
||||||
|
tsTransPullupMs = 1000;
|
||||||
|
|
||||||
|
const char *mnodepath = "/tmp/mnode_test_trans";
|
||||||
|
taosRemoveDir(mnodepath);
|
||||||
|
pMnode = mndOpen(mnodepath, &opt);
|
||||||
|
mndStart(pMnode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetUpTestSuite() {
|
||||||
|
InitLog();
|
||||||
|
walInit();
|
||||||
|
InitMnode();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TearDownTestSuite() {
|
||||||
|
mndStop(pMnode);
|
||||||
|
mndClose(pMnode);
|
||||||
|
walCleanUp();
|
||||||
|
taosCloseLog();
|
||||||
|
taosStopCacheRefreshWorker();
|
||||||
|
}
|
||||||
|
|
||||||
|
static SMnode *pMnode;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void SetUp() override {}
|
||||||
|
void TearDown() override {}
|
||||||
|
|
||||||
|
int32_t CreateUserLog(const char *acct, const char *user) {
|
||||||
|
SUserObj userObj = {0};
|
||||||
|
taosEncryptPass_c((uint8_t *)"taosdata", strlen("taosdata"), userObj.pass);
|
||||||
|
tstrncpy(userObj.user, user, TSDB_USER_LEN);
|
||||||
|
tstrncpy(userObj.acct, acct, TSDB_USER_LEN);
|
||||||
|
userObj.createdTime = taosGetTimestampMs();
|
||||||
|
userObj.updateTime = userObj.createdTime;
|
||||||
|
userObj.superUser = 1;
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {0};
|
||||||
|
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_USER, &rpcMsg);
|
||||||
|
SSdbRaw *pRedoRaw = mndUserActionEncode(&userObj);
|
||||||
|
mndTransAppendRedolog(pTrans, pRedoRaw);
|
||||||
|
sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY);
|
||||||
|
|
||||||
|
SSdbRaw *pUndoRaw = mndUserActionEncode(&userObj);
|
||||||
|
mndTransAppendUndolog(pTrans, pUndoRaw);
|
||||||
|
sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED);
|
||||||
|
|
||||||
|
char *param = strdup("====> test log <=====");
|
||||||
|
mndTransSetCb(pTrans, TEST_TRANS_START_FUNC, TEST_TRANS_STOP_FUNC, param, strlen(param) + 1);
|
||||||
|
|
||||||
|
int32_t code = mndTransPrepare(pMnode, pTrans);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t CreateUserAction(const char *acct, const char *user, bool hasUndoAction, ETrnPolicy policy) {
|
||||||
|
SUserObj userObj = {0};
|
||||||
|
taosEncryptPass_c((uint8_t *)"taosdata", strlen("taosdata"), userObj.pass);
|
||||||
|
tstrncpy(userObj.user, user, TSDB_USER_LEN);
|
||||||
|
tstrncpy(userObj.acct, acct, TSDB_USER_LEN);
|
||||||
|
userObj.createdTime = taosGetTimestampMs();
|
||||||
|
userObj.updateTime = userObj.createdTime;
|
||||||
|
userObj.superUser = 1;
|
||||||
|
|
||||||
|
SRpcMsg rpcMsg = {0};
|
||||||
|
STrans *pTrans = mndTransCreate(pMnode, policy, TRN_TYPE_CREATE_USER, &rpcMsg);
|
||||||
|
SSdbRaw *pRedoRaw = mndUserActionEncode(&userObj);
|
||||||
|
mndTransAppendRedolog(pTrans, pRedoRaw);
|
||||||
|
sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY);
|
||||||
|
|
||||||
|
SSdbRaw *pUndoRaw = mndUserActionEncode(&userObj);
|
||||||
|
mndTransAppendUndolog(pTrans, pUndoRaw);
|
||||||
|
sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED);
|
||||||
|
|
||||||
|
char *param = strdup("====> test action <=====");
|
||||||
|
mndTransSetCb(pTrans, TEST_TRANS_START_FUNC, TEST_TRANS_STOP_FUNC, param, strlen(param) + 1);
|
||||||
|
|
||||||
|
{
|
||||||
|
STransAction action = {0};
|
||||||
|
action.epSet.inUse = 0;
|
||||||
|
action.epSet.numOfEps = 1;
|
||||||
|
action.epSet.eps[0].port = 9040;
|
||||||
|
strcpy(action.epSet.eps[0].fqdn, "localhost");
|
||||||
|
|
||||||
|
int32_t contLen = 1024;
|
||||||
|
void *pReq = taosMemoryCalloc(1, contLen);
|
||||||
|
strcpy((char *)pReq, "hello world redo");
|
||||||
|
action.pCont = pReq;
|
||||||
|
action.contLen = contLen;
|
||||||
|
action.msgType = TDMT_DND_CREATE_MNODE;
|
||||||
|
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
||||||
|
mndTransAppendRedoAction(pTrans, &action);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasUndoAction) {
|
||||||
|
STransAction action = {0};
|
||||||
|
action.epSet.inUse = 0;
|
||||||
|
action.epSet.numOfEps = 1;
|
||||||
|
action.epSet.eps[0].port = 9040;
|
||||||
|
strcpy(action.epSet.eps[0].fqdn, "localhost");
|
||||||
|
|
||||||
|
int32_t contLen = 1024;
|
||||||
|
void *pReq = taosMemoryCalloc(1, contLen);
|
||||||
|
strcpy((char *)pReq, "hello world undo");
|
||||||
|
action.pCont = pReq;
|
||||||
|
action.contLen = contLen;
|
||||||
|
action.msgType = TDMT_DND_CREATE_MNODE;
|
||||||
|
action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED;
|
||||||
|
mndTransAppendUndoAction(pTrans, &action);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t code = mndTransPrepare(pMnode, pTrans);
|
||||||
|
mndTransDrop(pTrans);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SMnode *MndTestTrans2::pMnode;
|
||||||
|
|
||||||
|
TEST_F(MndTestTrans2, 01_Log) {
|
||||||
|
const char *acct = "root";
|
||||||
|
const char *acct_invalid = "root1";
|
||||||
|
const char *user1 = "log1";
|
||||||
|
const char *user2 = "log2";
|
||||||
|
SUserObj *pUser1 = NULL;
|
||||||
|
SUserObj *pUser2 = NULL;
|
||||||
|
|
||||||
|
ASSERT_NE(pMnode, nullptr);
|
||||||
|
|
||||||
|
EXPECT_EQ(CreateUserLog(acct, user1), 0);
|
||||||
|
pUser1 = mndAcquireUser(pMnode, user1);
|
||||||
|
ASSERT_NE(pUser1, nullptr);
|
||||||
|
|
||||||
|
// failed to create user and rollback
|
||||||
|
EXPECT_EQ(CreateUserLog(acct_invalid, user2), 0);
|
||||||
|
pUser2 = mndAcquireUser(pMnode, user2);
|
||||||
|
ASSERT_EQ(pUser2, nullptr);
|
||||||
|
|
||||||
|
mndTransPullup(pMnode);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(MndTestTrans2, 02_Action) {
|
||||||
|
const char *acct = "root";
|
||||||
|
const char *acct_invalid = "root1";
|
||||||
|
const char *user1 = "action1";
|
||||||
|
const char *user2 = "action2";
|
||||||
|
SUserObj *pUser1 = NULL;
|
||||||
|
SUserObj *pUser2 = NULL;
|
||||||
|
STrans *pTrans = NULL;
|
||||||
|
int32_t transId = 0;
|
||||||
|
int32_t action = 0;
|
||||||
|
|
||||||
|
ASSERT_NE(pMnode, nullptr);
|
||||||
|
|
||||||
|
// failed to create user and rollback
|
||||||
|
EXPECT_EQ(CreateUserAction(acct, user1, false, TRN_POLICY_ROLLBACK), 0);
|
||||||
|
pUser1 = mndAcquireUser(pMnode, user1);
|
||||||
|
ASSERT_EQ(pUser1, nullptr);
|
||||||
|
mndReleaseUser(pMnode, pUser1);
|
||||||
|
|
||||||
|
// create user, and fake a response
|
||||||
|
{
|
||||||
|
EXPECT_EQ(CreateUserAction(acct, user1, true, TRN_POLICY_ROLLBACK), 0);
|
||||||
|
pUser1 = mndAcquireUser(pMnode, user1);
|
||||||
|
ASSERT_NE(pUser1, nullptr);
|
||||||
|
mndReleaseUser(pMnode, pUser1);
|
||||||
|
|
||||||
|
transId = 4;
|
||||||
|
pTrans = mndAcquireTrans(pMnode, transId);
|
||||||
|
EXPECT_EQ(pTrans->code, TSDB_CODE_INVALID_PTR);
|
||||||
|
EXPECT_EQ(pTrans->stage, TRN_STAGE_UNDO_ACTION);
|
||||||
|
EXPECT_EQ(pTrans->failedTimes, 1);
|
||||||
|
|
||||||
|
STransAction *pAction = (STransAction *)taosArrayGet(pTrans->undoActions, action);
|
||||||
|
pAction->msgSent = 1;
|
||||||
|
|
||||||
|
SNodeMsg rspMsg = {0};
|
||||||
|
rspMsg.pNode = pMnode;
|
||||||
|
int64_t signature = transId;
|
||||||
|
signature = (signature << 32);
|
||||||
|
signature += action;
|
||||||
|
rspMsg.rpcMsg.ahandle = (void *)signature;
|
||||||
|
mndTransProcessRsp(&rspMsg);
|
||||||
|
mndReleaseTrans(pMnode, pTrans);
|
||||||
|
|
||||||
|
pUser1 = mndAcquireUser(pMnode, user1);
|
||||||
|
ASSERT_EQ(pUser1, nullptr);
|
||||||
|
mndReleaseUser(pMnode, pUser1);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
EXPECT_EQ(CreateUserAction(acct, user1, false, TRN_POLICY_RETRY), 0);
|
||||||
|
pUser1 = mndAcquireUser(pMnode, user1);
|
||||||
|
ASSERT_NE(pUser1, nullptr);
|
||||||
|
mndReleaseUser(pMnode, pUser1);
|
||||||
|
|
||||||
|
{
|
||||||
|
transId = 5;
|
||||||
|
pTrans = mndAcquireTrans(pMnode, transId);
|
||||||
|
EXPECT_EQ(pTrans->code, TSDB_CODE_INVALID_PTR);
|
||||||
|
EXPECT_EQ(pTrans->stage, TRN_STAGE_REDO_ACTION);
|
||||||
|
EXPECT_EQ(pTrans->failedTimes, 1);
|
||||||
|
|
||||||
|
STransAction *pAction = (STransAction *)taosArrayGet(pTrans->redoActions, action);
|
||||||
|
pAction->msgSent = 1;
|
||||||
|
|
||||||
|
SNodeMsg rspMsg = {0};
|
||||||
|
rspMsg.pNode = pMnode;
|
||||||
|
int64_t signature = transId;
|
||||||
|
signature = (signature << 32);
|
||||||
|
signature += action;
|
||||||
|
rspMsg.rpcMsg.ahandle = (void *)signature;
|
||||||
|
rspMsg.rpcMsg.code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
||||||
|
mndTransProcessRsp(&rspMsg);
|
||||||
|
mndReleaseTrans(pMnode, pTrans);
|
||||||
|
|
||||||
|
pUser1 = mndAcquireUser(pMnode, user1);
|
||||||
|
ASSERT_NE(pUser1, nullptr);
|
||||||
|
mndReleaseUser(pMnode, pUser1);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
transId = 5;
|
||||||
|
pTrans = mndAcquireTrans(pMnode, transId);
|
||||||
|
EXPECT_EQ(pTrans->code, TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
||||||
|
EXPECT_EQ(pTrans->stage, TRN_STAGE_REDO_ACTION);
|
||||||
|
EXPECT_EQ(pTrans->failedTimes, 2);
|
||||||
|
|
||||||
|
STransAction *pAction = (STransAction *)taosArrayGet(pTrans->redoActions, action);
|
||||||
|
pAction->msgSent = 1;
|
||||||
|
|
||||||
|
SNodeMsg rspMsg = {0};
|
||||||
|
rspMsg.pNode = pMnode;
|
||||||
|
int64_t signature = transId;
|
||||||
|
signature = (signature << 32);
|
||||||
|
signature += action;
|
||||||
|
rspMsg.rpcMsg.ahandle = (void *)signature;
|
||||||
|
mndTransProcessRsp(&rspMsg);
|
||||||
|
mndReleaseTrans(pMnode, pTrans);
|
||||||
|
|
||||||
|
pUser1 = mndAcquireUser(pMnode, user1);
|
||||||
|
ASSERT_NE(pUser1, nullptr);
|
||||||
|
mndReleaseUser(pMnode, pUser1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -31,8 +31,6 @@ extern "C" {
|
||||||
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }}
|
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }}
|
||||||
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
|
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
|
||||||
|
|
||||||
#define SDB_MAX_SIZE (32 * 1024)
|
|
||||||
|
|
||||||
typedef struct SSdbRaw {
|
typedef struct SSdbRaw {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
int8_t status;
|
int8_t status;
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,12 @@ SSdb *sdbInit(SSdbOpt *pOption) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char path[PATH_MAX + 100];
|
char path[PATH_MAX + 100] = {0};
|
||||||
snprintf(path, PATH_MAX + 100, "%s%sdata", pOption->path, TD_DIRSEP);
|
snprintf(path, sizeof(path), "%s%sdata", pOption->path, TD_DIRSEP);
|
||||||
pSdb->currDir = strdup(path);
|
pSdb->currDir = strdup(path);
|
||||||
snprintf(path, PATH_MAX + 100, "%s%ssync", pOption->path, TD_DIRSEP);
|
snprintf(path, sizeof(path), "%s%ssync", pOption->path, TD_DIRSEP);
|
||||||
pSdb->syncDir = strdup(path);
|
pSdb->syncDir = strdup(path);
|
||||||
snprintf(path, PATH_MAX + 100, "%s%stmp", pOption->path, TD_DIRSEP);
|
snprintf(path, sizeof(path), "%s%stmp", pOption->path, TD_DIRSEP);
|
||||||
pSdb->tmpDir = strdup(path);
|
pSdb->tmpDir = strdup(path);
|
||||||
if (pSdb->currDir == NULL || pSdb->currDir == NULL || pSdb->currDir == NULL) {
|
if (pSdb->currDir == NULL || pSdb->currDir == NULL || pSdb->currDir == NULL) {
|
||||||
sdbCleanup(pSdb);
|
sdbCleanup(pSdb);
|
||||||
|
|
@ -50,7 +50,7 @@ SSdb *sdbInit(SSdbOpt *pOption) {
|
||||||
for (ESdbType i = 0; i < SDB_MAX; ++i) {
|
for (ESdbType i = 0; i < SDB_MAX; ++i) {
|
||||||
taosInitRWLatch(&pSdb->locks[i]);
|
taosInitRWLatch(&pSdb->locks[i]);
|
||||||
pSdb->maxId[i] = 0;
|
pSdb->maxId[i] = 0;
|
||||||
pSdb->tableVer[i] = -1;
|
pSdb->tableVer[i] = 0;
|
||||||
pSdb->keyTypes[i] = SDB_KEY_INT32;
|
pSdb->keyTypes[i] = SDB_KEY_INT32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ void sdbCleanup(SSdb *pSdb) {
|
||||||
taosHashClear(hash);
|
taosHashClear(hash);
|
||||||
taosHashCleanup(hash);
|
taosHashCleanup(hash);
|
||||||
pSdb->hashObjs[i] = NULL;
|
pSdb->hashObjs[i] = NULL;
|
||||||
mDebug("sdb table:%d is cleaned up", i);
|
mDebug("sdb table:%s is cleaned up", sdbTableName(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(pSdb);
|
taosMemoryFree(pSdb);
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < SDB_TABLE_SIZE; ++i) {
|
for (int32_t i = 0; i < SDB_TABLE_SIZE; ++i) {
|
||||||
int64_t maxId = -1;
|
int64_t maxId = 0;
|
||||||
ret = taosReadFile(pFile, &maxId, sizeof(int64_t));
|
ret = taosReadFile(pFile, &maxId, sizeof(int64_t));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
|
@ -66,7 +66,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < SDB_TABLE_SIZE; ++i) {
|
for (int32_t i = 0; i < SDB_TABLE_SIZE; ++i) {
|
||||||
int64_t ver = -1;
|
int64_t ver = 0;
|
||||||
ret = taosReadFile(pFile, &ver, sizeof(int64_t));
|
ret = taosReadFile(pFile, &ver, sizeof(int64_t));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
|
@ -102,7 +102,7 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < SDB_TABLE_SIZE; ++i) {
|
for (int32_t i = 0; i < SDB_TABLE_SIZE; ++i) {
|
||||||
int64_t maxId = -1;
|
int64_t maxId = 0;
|
||||||
if (i < SDB_MAX) {
|
if (i < SDB_MAX) {
|
||||||
maxId = pSdb->maxId[i];
|
maxId = pSdb->maxId[i];
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +113,7 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < SDB_TABLE_SIZE; ++i) {
|
for (int32_t i = 0; i < SDB_TABLE_SIZE; ++i) {
|
||||||
int64_t ver = -1;
|
int64_t ver = 0;
|
||||||
if (i < SDB_MAX) {
|
if (i < SDB_MAX) {
|
||||||
ver = pSdb->tableVer[i];
|
ver = pSdb->tableVer[i];
|
||||||
}
|
}
|
||||||
|
|
@ -165,6 +165,9 @@ int32_t sdbReadFile(SSdb *pSdb) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t tableVer[SDB_MAX] = {0};
|
||||||
|
memcpy(tableVer, pSdb->tableVer, sizeof(tableVer));
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
readLen = sizeof(SSdbRaw);
|
readLen = sizeof(SSdbRaw);
|
||||||
ret = taosReadFile(pFile, pRaw, readLen);
|
ret = taosReadFile(pFile, pRaw, readLen);
|
||||||
|
|
@ -206,15 +209,16 @@ int32_t sdbReadFile(SSdb *pSdb) {
|
||||||
code = sdbWriteWithoutFree(pSdb, pRaw);
|
code = sdbWriteWithoutFree(pSdb, pRaw);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
mError("failed to read file:%s since %s", file, terrstr());
|
mError("failed to read file:%s since %s", file, terrstr());
|
||||||
goto PARSE_SDB_DATA_ERROR;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
pSdb->lastCommitVer = pSdb->curVer;
|
pSdb->lastCommitVer = pSdb->curVer;
|
||||||
|
memcpy(pSdb->tableVer, tableVer, sizeof(tableVer));
|
||||||
mDebug("read file:%s successfully, ver:%" PRId64, file, pSdb->lastCommitVer);
|
mDebug("read file:%s successfully, ver:%" PRId64, file, pSdb->lastCommitVer);
|
||||||
|
|
||||||
PARSE_SDB_DATA_ERROR:
|
_OVER:
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
|
|
||||||
|
|
@ -259,7 +263,13 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
SSdbRow **ppRow = taosHashIterate(hash, NULL);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
SSdbRow *pRow = *ppRow;
|
SSdbRow *pRow = *ppRow;
|
||||||
if (pRow == NULL || pRow->status != SDB_STATUS_READY) {
|
if (pRow == NULL) {
|
||||||
|
ppRow = taosHashIterate(hash, ppRow);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pRow->status != SDB_STATUS_READY && pRow->status != SDB_STATUS_DROPPING) {
|
||||||
|
sdbPrintOper(pSdb, pRow, "not-write");
|
||||||
ppRow = taosHashIterate(hash, ppRow);
|
ppRow = taosHashIterate(hash, ppRow);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "sdbInt.h"
|
#include "sdbInt.h"
|
||||||
|
|
||||||
static void sdbCheck(SSdb *pSdb, SSdbRow *pRow);
|
static void sdbCheckRow(SSdb *pSdb, SSdbRow *pRow);
|
||||||
|
|
||||||
const char *sdbTableName(ESdbType type) {
|
const char *sdbTableName(ESdbType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
@ -65,12 +65,10 @@ const char *sdbTableName(ESdbType type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *sdbStatusStr(ESdbStatus status) {
|
static const char *sdbStatusName(ESdbStatus status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case SDB_STATUS_CREATING:
|
case SDB_STATUS_CREATING:
|
||||||
return "creating";
|
return "creating";
|
||||||
case SDB_STATUS_UPDATING:
|
|
||||||
return "updating";
|
|
||||||
case SDB_STATUS_DROPPING:
|
case SDB_STATUS_DROPPING:
|
||||||
return "dropping";
|
return "dropping";
|
||||||
case SDB_STATUS_READY:
|
case SDB_STATUS_READY:
|
||||||
|
|
@ -89,13 +87,13 @@ void sdbPrintOper(SSdb *pSdb, SSdbRow *pRow, const char *oper) {
|
||||||
|
|
||||||
if (keyType == SDB_KEY_BINARY) {
|
if (keyType == SDB_KEY_BINARY) {
|
||||||
mTrace("%s:%s, ref:%d oper:%s row:%p status:%s", sdbTableName(pRow->type), (char *)pRow->pObj, pRow->refCount, oper,
|
mTrace("%s:%s, ref:%d oper:%s row:%p status:%s", sdbTableName(pRow->type), (char *)pRow->pObj, pRow->refCount, oper,
|
||||||
pRow->pObj, sdbStatusStr(pRow->status));
|
pRow->pObj, sdbStatusName(pRow->status));
|
||||||
} else if (keyType == SDB_KEY_INT32) {
|
} else if (keyType == SDB_KEY_INT32) {
|
||||||
mTrace("%s:%d, ref:%d oper:%s row:%p status:%s", sdbTableName(pRow->type), *(int32_t *)pRow->pObj, pRow->refCount,
|
mTrace("%s:%d, ref:%d oper:%s row:%p status:%s", sdbTableName(pRow->type), *(int32_t *)pRow->pObj, pRow->refCount,
|
||||||
oper, pRow->pObj, sdbStatusStr(pRow->status));
|
oper, pRow->pObj, sdbStatusName(pRow->status));
|
||||||
} else if (keyType == SDB_KEY_INT64) {
|
} else if (keyType == SDB_KEY_INT64) {
|
||||||
mTrace("%s:%" PRId64 ", ref:%d oper:%s row:%p status:%s", sdbTableName(pRow->type), *(int64_t *)pRow->pObj,
|
mTrace("%s:%" PRId64 ", ref:%d oper:%s row:%p status:%s", sdbTableName(pRow->type), *(int64_t *)pRow->pObj,
|
||||||
pRow->refCount, oper, pRow->pObj, sdbStatusStr(pRow->status));
|
pRow->refCount, oper, pRow->pObj, sdbStatusName(pRow->status));
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +114,7 @@ static SHashObj *sdbGetHash(SSdb *pSdb, int32_t type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sdbGetkeySize(SSdb *pSdb, ESdbType type, const void *pKey) {
|
static int32_t sdbGetkeySize(SSdb *pSdb, ESdbType type, const void *pKey) {
|
||||||
int32_t keySize;
|
int32_t keySize = 0;
|
||||||
EKeyType keyType = pSdb->keyTypes[type];
|
EKeyType keyType = pSdb->keyTypes[type];
|
||||||
|
|
||||||
if (keyType == SDB_KEY_INT32) {
|
if (keyType == SDB_KEY_INT32) {
|
||||||
|
|
@ -149,7 +147,7 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
if (taosHashPut(hash, pRow->pObj, keySize, &pRow, sizeof(void *)) != 0) {
|
if (taosHashPut(hash, pRow->pObj, keySize, &pRow, sizeof(void *)) != 0) {
|
||||||
taosWUnLockLatch(pLock);
|
taosWUnLockLatch(pLock);
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
terrno = TSDB_CODE_SDB_OBJ_ALREADY_THERE;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,18 +181,18 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
|
|
||||||
static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pNewRow, int32_t keySize) {
|
static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *pNewRow, int32_t keySize) {
|
||||||
SRWLatch *pLock = &pSdb->locks[pNewRow->type];
|
SRWLatch *pLock = &pSdb->locks[pNewRow->type];
|
||||||
taosRLockLatch(pLock);
|
taosWLockLatch(pLock);
|
||||||
|
|
||||||
SSdbRow **ppOldRow = taosHashGet(hash, pNewRow->pObj, keySize);
|
SSdbRow **ppOldRow = taosHashGet(hash, pNewRow->pObj, keySize);
|
||||||
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
if (ppOldRow == NULL || *ppOldRow == NULL) {
|
||||||
taosRUnLockLatch(pLock);
|
taosWUnLockLatch(pLock);
|
||||||
return sdbInsertRow(pSdb, hash, pRaw, pNewRow, keySize);
|
return sdbInsertRow(pSdb, hash, pRaw, pNewRow, keySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSdbRow *pOldRow = *ppOldRow;
|
SSdbRow *pOldRow = *ppOldRow;
|
||||||
pOldRow->status = pRaw->status;
|
pOldRow->status = pRaw->status;
|
||||||
sdbPrintOper(pSdb, pOldRow, "update");
|
sdbPrintOper(pSdb, pOldRow, "update");
|
||||||
taosRUnLockLatch(pLock);
|
taosWUnLockLatch(pLock);
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SdbUpdateFp updateFp = pSdb->updateFps[pNewRow->type];
|
SdbUpdateFp updateFp = pSdb->updateFps[pNewRow->type];
|
||||||
|
|
@ -230,8 +228,7 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
||||||
pSdb->tableVer[pOldRow->type]++;
|
pSdb->tableVer[pOldRow->type]++;
|
||||||
sdbFreeRow(pSdb, pRow, false);
|
sdbFreeRow(pSdb, pRow, false);
|
||||||
|
|
||||||
sdbCheck(pSdb, pOldRow);
|
sdbCheckRow(pSdb, pOldRow);
|
||||||
// sdbRelease(pSdb, pOldRow->pObj);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,7 +251,6 @@ int32_t sdbWriteWithoutFree(SSdb *pSdb, SSdbRaw *pRaw) {
|
||||||
case SDB_STATUS_CREATING:
|
case SDB_STATUS_CREATING:
|
||||||
code = sdbInsertRow(pSdb, hash, pRaw, pRow, keySize);
|
code = sdbInsertRow(pSdb, hash, pRaw, pRow, keySize);
|
||||||
break;
|
break;
|
||||||
case SDB_STATUS_UPDATING:
|
|
||||||
case SDB_STATUS_READY:
|
case SDB_STATUS_READY:
|
||||||
case SDB_STATUS_DROPPING:
|
case SDB_STATUS_DROPPING:
|
||||||
code = sdbUpdateRow(pSdb, hash, pRaw, pRow, keySize);
|
code = sdbUpdateRow(pSdb, hash, pRaw, pRow, keySize);
|
||||||
|
|
@ -295,7 +291,6 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, const void *pKey) {
|
||||||
SSdbRow *pRow = *ppRow;
|
SSdbRow *pRow = *ppRow;
|
||||||
switch (pRow->status) {
|
switch (pRow->status) {
|
||||||
case SDB_STATUS_READY:
|
case SDB_STATUS_READY:
|
||||||
case SDB_STATUS_UPDATING:
|
|
||||||
atomic_add_fetch_32(&pRow->refCount, 1);
|
atomic_add_fetch_32(&pRow->refCount, 1);
|
||||||
pRet = pRow->pObj;
|
pRet = pRow->pObj;
|
||||||
sdbPrintOper(pSdb, pRow, "acquire");
|
sdbPrintOper(pSdb, pRow, "acquire");
|
||||||
|
|
@ -315,9 +310,9 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, const void *pKey) {
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdbCheck(SSdb *pSdb, SSdbRow *pRow) {
|
static void sdbCheckRow(SSdb *pSdb, SSdbRow *pRow) {
|
||||||
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
||||||
taosRLockLatch(pLock);
|
taosWLockLatch(pLock);
|
||||||
|
|
||||||
int32_t ref = atomic_load_32(&pRow->refCount);
|
int32_t ref = atomic_load_32(&pRow->refCount);
|
||||||
sdbPrintOper(pSdb, pRow, "check");
|
sdbPrintOper(pSdb, pRow, "check");
|
||||||
|
|
@ -325,7 +320,7 @@ static void sdbCheck(SSdb *pSdb, SSdbRow *pRow) {
|
||||||
sdbFreeRow(pSdb, pRow, true);
|
sdbFreeRow(pSdb, pRow, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(pLock);
|
taosWUnLockLatch(pLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdbRelease(SSdb *pSdb, void *pObj) {
|
void sdbRelease(SSdb *pSdb, void *pObj) {
|
||||||
|
|
@ -335,7 +330,7 @@ void sdbRelease(SSdb *pSdb, void *pObj) {
|
||||||
if (pRow->type >= SDB_MAX) return;
|
if (pRow->type >= SDB_MAX) return;
|
||||||
|
|
||||||
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
SRWLatch *pLock = &pSdb->locks[pRow->type];
|
||||||
taosRLockLatch(pLock);
|
taosWLockLatch(pLock);
|
||||||
|
|
||||||
int32_t ref = atomic_sub_fetch_32(&pRow->refCount, 1);
|
int32_t ref = atomic_sub_fetch_32(&pRow->refCount, 1);
|
||||||
sdbPrintOper(pSdb, pRow, "release");
|
sdbPrintOper(pSdb, pRow, "release");
|
||||||
|
|
@ -343,7 +338,7 @@ void sdbRelease(SSdb *pSdb, void *pObj) {
|
||||||
sdbFreeRow(pSdb, pRow, true);
|
sdbFreeRow(pSdb, pRow, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(pLock);
|
taosWUnLockLatch(pLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
||||||
|
|
@ -355,16 +350,6 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
|
||||||
SRWLatch *pLock = &pSdb->locks[type];
|
SRWLatch *pLock = &pSdb->locks[type];
|
||||||
taosRLockLatch(pLock);
|
taosRLockLatch(pLock);
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (pIter != NULL) {
|
|
||||||
SSdbRow *pLastRow = *(SSdbRow **)pIter;
|
|
||||||
int32_t ref = atomic_load_32(&pLastRow->refCount);
|
|
||||||
if (ref <= 0 && pLastRow->status == SDB_STATUS_DROPPED) {
|
|
||||||
sdbFreeRow(pSdb, pLastRow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SSdbRow **ppRow = taosHashIterate(hash, pIter);
|
SSdbRow **ppRow = taosHashIterate(hash, pIter);
|
||||||
while (ppRow != NULL) {
|
while (ppRow != NULL) {
|
||||||
SSdbRow *pRow = *ppRow;
|
SSdbRow *pRow = *ppRow;
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,11 @@ int32_t sdbSetRawStatus(SSdbRaw *pRaw, ESdbStatus status) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status == SDB_STATUS_INIT) {
|
||||||
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
pRaw->status = status;
|
pRaw->status = status;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct SQWorkerMgmt SQHandle;
|
typedef struct SQWorker SQHandle;
|
||||||
|
|
||||||
typedef struct SQnode {
|
typedef struct SQnode {
|
||||||
int32_t qndId;
|
int32_t qndId;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ target_sources(
|
||||||
"src/vnd/vnodeBufPool.c"
|
"src/vnd/vnodeBufPool.c"
|
||||||
"src/vnd/vnodeCfg.c"
|
"src/vnd/vnodeCfg.c"
|
||||||
"src/vnd/vnodeCommit.c"
|
"src/vnd/vnodeCommit.c"
|
||||||
"src/vnd/vnodeInt.c"
|
|
||||||
"src/vnd/vnodeQuery.c"
|
"src/vnd/vnodeQuery.c"
|
||||||
"src/vnd/vnodeStateMgr.c"
|
"src/vnd/vnodeStateMgr.c"
|
||||||
"src/vnd/vnodeModule.c"
|
"src/vnd/vnodeModule.c"
|
||||||
|
|
@ -33,7 +32,6 @@ target_sources(
|
||||||
"src/tsdb/tsdbMemTable.c"
|
"src/tsdb/tsdbMemTable.c"
|
||||||
"src/tsdb/tsdbRead.c"
|
"src/tsdb/tsdbRead.c"
|
||||||
"src/tsdb/tsdbReadImpl.c"
|
"src/tsdb/tsdbReadImpl.c"
|
||||||
"src/tsdb/tsdbScan.c"
|
|
||||||
"src/tsdb/tsdbSma.c"
|
"src/tsdb/tsdbSma.c"
|
||||||
"src/tsdb/tsdbWrite.c"
|
"src/tsdb/tsdbWrite.c"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "trow.h"
|
#include "trow.h"
|
||||||
|
|
||||||
#include "tdbInt.h"
|
#include "tdb.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
@ -57,9 +57,6 @@ int vnodeProcessCMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||||
int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||||
int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
int vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
||||||
int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
||||||
int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg);
|
|
||||||
int32_t vnodeCompact(SVnode *pVnode);
|
|
||||||
int32_t vnodeSync(SVnode *pVnode);
|
|
||||||
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
||||||
int vnodeValidateTableHash(SVnode *pVnode, char *tableFName);
|
int vnodeValidateTableHash(SVnode *pVnode, char *tableFName);
|
||||||
|
|
||||||
|
|
@ -111,7 +108,7 @@ int32_t tsdbQuerySTableByTagCond(void *pMeta, uint64_t uid, TSKEY skey, con
|
||||||
int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT *pHandle);
|
int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT *pHandle);
|
||||||
bool tsdbNextDataBlock(tsdbReaderT pTsdbReadHandle);
|
bool tsdbNextDataBlock(tsdbReaderT pTsdbReadHandle);
|
||||||
void tsdbRetrieveDataBlockInfo(tsdbReaderT *pTsdbReadHandle, SDataBlockInfo *pBlockInfo);
|
void tsdbRetrieveDataBlockInfo(tsdbReaderT *pTsdbReadHandle, SDataBlockInfo *pBlockInfo);
|
||||||
int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT *pTsdbReadHandle, SColumnDataAgg **pBlockStatis);
|
int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT *pTsdbReadHandle, SColumnDataAgg ***pBlockStatis, bool* allHave);
|
||||||
SArray *tsdbRetrieveDataBlock(tsdbReaderT *pTsdbReadHandle, SArray *pColumnIdList);
|
SArray *tsdbRetrieveDataBlock(tsdbReaderT *pTsdbReadHandle, SArray *pColumnIdList);
|
||||||
void tsdbResetReadHandle(tsdbReaderT queryHandle, SQueryTableDataCond *pCond);
|
void tsdbResetReadHandle(tsdbReaderT queryHandle, SQueryTableDataCond *pCond);
|
||||||
void tsdbDestroyTableGroup(STableGroupInfo *pGroupList);
|
void tsdbDestroyTableGroup(STableGroupInfo *pGroupList);
|
||||||
|
|
@ -146,9 +143,19 @@ struct STsdbCfg {
|
||||||
int32_t keep0;
|
int32_t keep0;
|
||||||
int32_t keep1;
|
int32_t keep1;
|
||||||
int32_t keep2;
|
int32_t keep2;
|
||||||
SArray *retentions;
|
// TODO: save to tsdb cfg file
|
||||||
|
int8_t type; // ETsdbType
|
||||||
|
SRetention retentions[TSDB_RETENTION_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TSDB_TYPE_TSDB = 0, // TSDB
|
||||||
|
TSDB_TYPE_TSMA = 1, // TSMA
|
||||||
|
TSDB_TYPE_RSMA_L0 = 2, // RSMA Level 0
|
||||||
|
TSDB_TYPE_RSMA_L1 = 3, // RSMA Level 1
|
||||||
|
TSDB_TYPE_RSMA_L2 = 4, // RSMA Level 2
|
||||||
|
} ETsdbType;
|
||||||
|
|
||||||
struct SVnodeCfg {
|
struct SVnodeCfg {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
char dbname[TSDB_DB_NAME_LEN];
|
char dbname[TSDB_DB_NAME_LEN];
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ int metaEncodeEntry(SCoder* pCoder, const SMetaEntry* pME);
|
||||||
int metaDecodeEntry(SCoder* pCoder, SMetaEntry* pME);
|
int metaDecodeEntry(SCoder* pCoder, SMetaEntry* pME);
|
||||||
|
|
||||||
// metaTable ==================
|
// metaTable ==================
|
||||||
int metaDropSTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq);
|
|
||||||
|
|
||||||
// metaQuery ==================
|
// metaQuery ==================
|
||||||
int metaGetTableEntryByVersion(SMetaReader* pReader, int64_t version, tb_uid_t uid);
|
int metaGetTableEntryByVersion(SMetaReader* pReader, int64_t version, tb_uid_t uid);
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ typedef struct STable STable;
|
||||||
|
|
||||||
int tsdbMemTableCreate(STsdb *pTsdb, STsdbMemTable **ppMemTable);
|
int tsdbMemTableCreate(STsdb *pTsdb, STsdbMemTable **ppMemTable);
|
||||||
void tsdbMemTableDestroy(STsdb *pTsdb, STsdbMemTable *pMemTable);
|
void tsdbMemTableDestroy(STsdb *pTsdb, STsdbMemTable *pMemTable);
|
||||||
int tsdbInsertTableData(STsdb *pTsdb, SSubmitBlk *pBlock, int32_t *pAffectedRows);
|
int tsdbInsertTableData(STsdb *pTsdb, SSubmitMsgIter *pMsgIter, SSubmitBlk *pBlock, int32_t *pAffectedRows);
|
||||||
int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey, int maxRowsToRead, SDataCols *pCols,
|
int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey, int maxRowsToRead, SDataCols *pCols,
|
||||||
TKEY *filterKeys, int nFilterKeys, bool keepDup, SMergeInfo *pMergeInfo);
|
TKEY *filterKeys, int nFilterKeys, bool keepDup, SMergeInfo *pMergeInfo);
|
||||||
|
|
||||||
|
|
@ -72,8 +72,8 @@ struct STsdb {
|
||||||
char *path;
|
char *path;
|
||||||
SVnode *pVnode;
|
SVnode *pVnode;
|
||||||
bool repoLocked;
|
bool repoLocked;
|
||||||
|
int8_t level; // retention level
|
||||||
TdThreadMutex mutex;
|
TdThreadMutex mutex;
|
||||||
STsdbCfg config;
|
|
||||||
STsdbMemTable *mem;
|
STsdbMemTable *mem;
|
||||||
STsdbMemTable *imem;
|
STsdbMemTable *imem;
|
||||||
SRtn rtn;
|
SRtn rtn;
|
||||||
|
|
@ -185,7 +185,8 @@ struct STsdbFS {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define REPO_ID(r) TD_VID((r)->pVnode)
|
#define REPO_ID(r) TD_VID((r)->pVnode)
|
||||||
#define REPO_CFG(r) (&(r)->config)
|
#define REPO_CFG(r) (&(r)->pVnode->config.tsdbCfg)
|
||||||
|
#define REPO_LEVEL(r) ((r)->level)
|
||||||
#define REPO_FS(r) ((r)->fs)
|
#define REPO_FS(r) ((r)->fs)
|
||||||
#define REPO_META(r) ((r)->pVnode->pMeta)
|
#define REPO_META(r) ((r)->pVnode->pMeta)
|
||||||
#define REPO_TFS(r) ((r)->pVnode->pTfs)
|
#define REPO_TFS(r) ((r)->pVnode->pTfs)
|
||||||
|
|
@ -534,23 +535,6 @@ static FORCE_INLINE int tsdbGetFidLevel(int fid, SRtn *pRtn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tsdbDBDef
|
|
||||||
// typedef struct SDBFile SDBFile;
|
|
||||||
// typedef DB_ENV* TDBEnv;
|
|
||||||
|
|
||||||
// struct SDBFile {
|
|
||||||
// int32_t fid;
|
|
||||||
// DB* pDB;
|
|
||||||
// char* path;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// int32_t tsdbOpenDBF(TDBEnv pEnv, SDBFile* pDBF);
|
|
||||||
// void tsdbCloseDBF(SDBFile* pDBF);
|
|
||||||
// int32_t tsdbOpenBDBEnv(DB_ENV** ppEnv, const char* path);
|
|
||||||
// void tsdbCloseBDBEnv(DB_ENV* pEnv);
|
|
||||||
// int32_t tsdbSaveSmaToDB(SDBFile* pDBF, void* key, uint32_t keySize, void* data, uint32_t dataSize);
|
|
||||||
// void* tsdbGetSmaDataByKey(SDBFile* pDBF, void* key, uint32_t keySize, uint32_t* valueSize);
|
|
||||||
|
|
||||||
// tsdbFile
|
// tsdbFile
|
||||||
#define TSDB_FILE_HEAD_SIZE 512
|
#define TSDB_FILE_HEAD_SIZE 512
|
||||||
#define TSDB_FILE_DELIMITER 0xF00AFA0F
|
#define TSDB_FILE_DELIMITER 0xF00AFA0F
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ static FORCE_INLINE int32_t tsdbUidStoreInit(STbUidStore **pStore) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#include "tcompare.h"
|
#include "tcompare.h"
|
||||||
#include "tcompression.h"
|
#include "tcompression.h"
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
#include "tdbInt.h"
|
#include "tdb.h"
|
||||||
#include "tencode.h"
|
#include "tencode.h"
|
||||||
#include "tfs.h"
|
#include "tfs.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
|
@ -52,12 +52,15 @@ typedef struct STsdb STsdb;
|
||||||
typedef struct STQ STQ;
|
typedef struct STQ STQ;
|
||||||
typedef struct SVState SVState;
|
typedef struct SVState SVState;
|
||||||
typedef struct SVBufPool SVBufPool;
|
typedef struct SVBufPool SVBufPool;
|
||||||
typedef struct SQWorkerMgmt SQHandle;
|
typedef struct SQWorker SQHandle;
|
||||||
|
|
||||||
#define VNODE_META_DIR "meta"
|
#define VNODE_META_DIR "meta"
|
||||||
#define VNODE_TSDB_DIR "tsdb"
|
#define VNODE_TSDB_DIR "tsdb"
|
||||||
#define VNODE_TQ_DIR "tq"
|
#define VNODE_TQ_DIR "tq"
|
||||||
#define VNODE_WAL_DIR "wal"
|
#define VNODE_WAL_DIR "wal"
|
||||||
|
#define VNODE_TSMA_DIR "tsma"
|
||||||
|
#define VNODE_RSMA1_DIR "rsma1"
|
||||||
|
#define VNODE_RSMA2_DIR "rsma2"
|
||||||
|
|
||||||
// vnd.h
|
// vnd.h
|
||||||
void* vnodeBufPoolMalloc(SVBufPool* pPool, int size);
|
void* vnodeBufPoolMalloc(SVBufPool* pPool, int size);
|
||||||
|
|
@ -72,6 +75,7 @@ int metaClose(SMeta* pMeta);
|
||||||
int metaBegin(SMeta* pMeta);
|
int metaBegin(SMeta* pMeta);
|
||||||
int metaCommit(SMeta* pMeta);
|
int metaCommit(SMeta* pMeta);
|
||||||
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||||
|
int metaDropSTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq);
|
||||||
int metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq);
|
int metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq);
|
||||||
SSchemaWrapper* metaGetTableSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, bool isinline);
|
SSchemaWrapper* metaGetTableSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, bool isinline);
|
||||||
STSchema* metaGetTbTSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver);
|
STSchema* metaGetTbTSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver);
|
||||||
|
|
@ -87,7 +91,7 @@ int32_t metaCreateTSma(SMeta* pMeta, SSmaCfg* pCfg);
|
||||||
int32_t metaDropTSma(SMeta* pMeta, int64_t indexUid);
|
int32_t metaDropTSma(SMeta* pMeta, int64_t indexUid);
|
||||||
|
|
||||||
// tsdb
|
// tsdb
|
||||||
int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb);
|
int tsdbOpen(SVnode* pVnode, int8_t type);
|
||||||
int tsdbClose(STsdb* pTsdb);
|
int tsdbClose(STsdb* pTsdb);
|
||||||
int tsdbBegin(STsdb* pTsdb);
|
int tsdbBegin(STsdb* pTsdb);
|
||||||
int tsdbCommit(STsdb* pTsdb);
|
int tsdbCommit(STsdb* pTsdb);
|
||||||
|
|
@ -95,7 +99,7 @@ int32_t tsdbUpdateSmaWindow(STsdb* pTsdb, SSubmitReq* pMsg, int64_t version
|
||||||
int32_t tsdbCreateTSma(STsdb* pTsdb, char* pMsg);
|
int32_t tsdbCreateTSma(STsdb* pTsdb, char* pMsg);
|
||||||
int32_t tsdbInsertTSmaData(STsdb* pTsdb, int64_t indexUid, const char* msg);
|
int32_t tsdbInsertTSmaData(STsdb* pTsdb, int64_t indexUid, const char* msg);
|
||||||
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
||||||
tsdbReaderT* tsdbQueryTablesT(STsdb* tsdb, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
tsdbReaderT* tsdbQueryTables(SVnode* pVnode, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
||||||
uint64_t taskId);
|
uint64_t taskId);
|
||||||
tsdbReaderT tsdbQueryCacheLastT(STsdb* tsdb, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
tsdbReaderT tsdbQueryCacheLastT(STsdb* tsdb, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
||||||
void* pMemRef);
|
void* pMemRef);
|
||||||
|
|
@ -119,7 +123,8 @@ int32_t tsdbFetchTbUidList(STsdb* pTsdb, STbUidStore** ppStore, tb_uid_t suid, t
|
||||||
int32_t tsdbUpdateTbUidList(STsdb* pTsdb, STbUidStore* pUidStore);
|
int32_t tsdbUpdateTbUidList(STsdb* pTsdb, STbUidStore* pUidStore);
|
||||||
void tsdbUidStoreDestory(STbUidStore* pStore);
|
void tsdbUidStoreDestory(STbUidStore* pStore);
|
||||||
void* tsdbUidStoreFree(STbUidStore* pStore);
|
void* tsdbUidStoreFree(STbUidStore* pStore);
|
||||||
int32_t tsdbTriggerRSma(STsdb* pTsdb, SMeta* pMeta, void* pMsg, int32_t inputType);
|
int32_t tsdbTriggerRSma(STsdb* pTsdb, void* pMsg, int32_t inputType);
|
||||||
|
int32_t tsdbProcessSubmitReq(STsdb* pTsdb, int64_t version, void* pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t streamType; // sma or other
|
int8_t streamType; // sma or other
|
||||||
|
|
@ -160,6 +165,8 @@ struct SVnode {
|
||||||
SVBufPool* onRecycle;
|
SVBufPool* onRecycle;
|
||||||
SMeta* pMeta;
|
SMeta* pMeta;
|
||||||
STsdb* pTsdb;
|
STsdb* pTsdb;
|
||||||
|
STsdb* pRSma1;
|
||||||
|
STsdb* pRSma2;
|
||||||
SWal* pWal;
|
SWal* pWal;
|
||||||
STQ* pTq;
|
STQ* pTq;
|
||||||
SSink* pSink;
|
SSink* pSink;
|
||||||
|
|
@ -168,15 +175,25 @@ struct SVnode {
|
||||||
SQHandle* pQuery;
|
SQHandle* pQuery;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define VND_TSDB(vnd) ((vnd)->pTsdb)
|
||||||
|
#define VND_RSMA0(vnd) ((vnd)->pTsdb)
|
||||||
|
#define VND_RSMA1(vnd) ((vnd)->pRSma1)
|
||||||
|
#define VND_RSMA2(vnd) ((vnd)->pRSma2)
|
||||||
|
|
||||||
struct STbUidStore {
|
struct STbUidStore {
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
|
tb_uid_t uid; // TODO: just for debugging, remove when uid provided in SSDataBlock
|
||||||
SArray* tbUids;
|
SArray* tbUids;
|
||||||
SHashObj* uidHash;
|
SHashObj* uidHash;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TD_VID(PVNODE) (PVNODE)->config.vgId
|
#define TD_VID(PVNODE) (PVNODE)->config.vgId
|
||||||
|
|
||||||
// typedef struct STbDdlH STbDdlH;
|
|
||||||
|
static FORCE_INLINE bool vnodeIsRollup(SVnode* pVnode) {
|
||||||
|
SRetention* pRetention = &(pVnode->config.tsdbCfg.retentions[0]);
|
||||||
|
return (pRetention->freq > 0 && pRetention->keep > 0);
|
||||||
|
}
|
||||||
|
|
||||||
// sma
|
// sma
|
||||||
void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data);
|
void smaHandleRes(void* pVnode, int64_t smaId, const SArray* data);
|
||||||
|
|
|
||||||
|
|
@ -47,66 +47,66 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
||||||
// open env
|
// open env
|
||||||
ret = tdbEnvOpen(pMeta->path, pVnode->config.szPage, pVnode->config.szCache, &pMeta->pEnv);
|
ret = tdbEnvOpen(pMeta->path, pVnode->config.szPage, pVnode->config.szCache, &pMeta->pEnv);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
metaError("vgId: %d failed to open meta env since %s", TD_VID(pVnode), tstrerror(terrno));
|
metaError("vgId:%d failed to open meta env since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open pTbDb
|
// open pTbDb
|
||||||
ret = tdbDbOpen("table.db", sizeof(STbDbKey), -1, tbDbKeyCmpr, pMeta->pEnv, &pMeta->pTbDb);
|
ret = tdbDbOpen("table.db", sizeof(STbDbKey), -1, tbDbKeyCmpr, pMeta->pEnv, &pMeta->pTbDb);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
metaError("vgId: %d failed to open meta table db since %s", TD_VID(pVnode), tstrerror(terrno));
|
metaError("vgId:%d failed to open meta table db since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open pSkmDb
|
// open pSkmDb
|
||||||
ret = tdbDbOpen("schema.db", sizeof(SSkmDbKey), -1, skmDbKeyCmpr, pMeta->pEnv, &pMeta->pSkmDb);
|
ret = tdbDbOpen("schema.db", sizeof(SSkmDbKey), -1, skmDbKeyCmpr, pMeta->pEnv, &pMeta->pSkmDb);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
metaError("vgId: %d failed to open meta schema db since %s", TD_VID(pVnode), tstrerror(terrno));
|
metaError("vgId:%d failed to open meta schema db since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open pUidIdx
|
// open pUidIdx
|
||||||
ret = tdbDbOpen("uid.idx", sizeof(tb_uid_t), sizeof(int64_t), uidIdxKeyCmpr, pMeta->pEnv, &pMeta->pUidIdx);
|
ret = tdbDbOpen("uid.idx", sizeof(tb_uid_t), sizeof(int64_t), uidIdxKeyCmpr, pMeta->pEnv, &pMeta->pUidIdx);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
metaError("vgId: %d failed to open meta uid idx since %s", TD_VID(pVnode), tstrerror(terrno));
|
metaError("vgId:%d failed to open meta uid idx since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open pNameIdx
|
// open pNameIdx
|
||||||
ret = tdbDbOpen("name.idx", -1, sizeof(tb_uid_t), NULL, pMeta->pEnv, &pMeta->pNameIdx);
|
ret = tdbDbOpen("name.idx", -1, sizeof(tb_uid_t), NULL, pMeta->pEnv, &pMeta->pNameIdx);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
metaError("vgId: %d failed to open meta name index since %s", TD_VID(pVnode), tstrerror(terrno));
|
metaError("vgId:%d failed to open meta name index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open pCtbIdx
|
// open pCtbIdx
|
||||||
ret = tdbDbOpen("ctb.idx", sizeof(SCtbIdxKey), 0, ctbIdxKeyCmpr, pMeta->pEnv, &pMeta->pCtbIdx);
|
ret = tdbDbOpen("ctb.idx", sizeof(SCtbIdxKey), 0, ctbIdxKeyCmpr, pMeta->pEnv, &pMeta->pCtbIdx);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
metaError("vgId: %d failed to open meta child table index since %s", TD_VID(pVnode), tstrerror(terrno));
|
metaError("vgId:%d failed to open meta child table index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open pTagIdx
|
// open pTagIdx
|
||||||
ret = tdbDbOpen("tag.idx", -1, 0, tagIdxKeyCmpr, pMeta->pEnv, &pMeta->pTagIdx);
|
ret = tdbDbOpen("tag.idx", -1, 0, tagIdxKeyCmpr, pMeta->pEnv, &pMeta->pTagIdx);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
metaError("vgId: %d failed to open meta tag index since %s", TD_VID(pVnode), tstrerror(terrno));
|
metaError("vgId:%d failed to open meta tag index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open pTtlIdx
|
// open pTtlIdx
|
||||||
ret = tdbDbOpen("ttl.idx", sizeof(STtlIdxKey), 0, ttlIdxKeyCmpr, pMeta->pEnv, &pMeta->pTtlIdx);
|
ret = tdbDbOpen("ttl.idx", sizeof(STtlIdxKey), 0, ttlIdxKeyCmpr, pMeta->pEnv, &pMeta->pTtlIdx);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
metaError("vgId: %d failed to open meta ttl index since %s", TD_VID(pVnode), tstrerror(terrno));
|
metaError("vgId:%d failed to open meta ttl index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open index
|
// open index
|
||||||
if (metaOpenIdx(pMeta) < 0) {
|
if (metaOpenIdx(pMeta) < 0) {
|
||||||
metaError("vgId: %d failed to open meta index since %s", TD_VID(pVnode), tstrerror(terrno));
|
metaError("vgId:%d failed to open meta index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
metaDebug("vgId: %d meta is opened", TD_VID(pVnode));
|
metaDebug("vgId:%d meta is opened", TD_VID(pVnode));
|
||||||
|
|
||||||
*ppMeta = pMeta;
|
*ppMeta = pMeta;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags) {
|
||||||
|
|
||||||
void metaReaderClear(SMetaReader *pReader) {
|
void metaReaderClear(SMetaReader *pReader) {
|
||||||
tCoderClear(&pReader->coder);
|
tCoderClear(&pReader->coder);
|
||||||
TDB_FREE(pReader->pBuf);
|
tdbFree(pReader->pBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaGetTableEntryByVersion(SMetaReader *pReader, int64_t version, tb_uid_t uid) {
|
int metaGetTableEntryByVersion(SMetaReader *pReader, int64_t version, tb_uid_t uid) {
|
||||||
|
|
@ -96,15 +96,17 @@ SMTbCursor *metaOpenTbCursor(SMeta *pMeta) {
|
||||||
|
|
||||||
metaReaderInit(&pTbCur->mr, pMeta, 0);
|
metaReaderInit(&pTbCur->mr, pMeta, 0);
|
||||||
|
|
||||||
tdbDbcOpen(pMeta->pUidIdx, &pTbCur->pDbc);
|
tdbDbcOpen(pMeta->pUidIdx, &pTbCur->pDbc, NULL);
|
||||||
|
|
||||||
|
tdbDbcMoveToFirst(pTbCur->pDbc);
|
||||||
|
|
||||||
return pTbCur;
|
return pTbCur;
|
||||||
}
|
}
|
||||||
|
|
||||||
void metaCloseTbCursor(SMTbCursor *pTbCur) {
|
void metaCloseTbCursor(SMTbCursor *pTbCur) {
|
||||||
if (pTbCur) {
|
if (pTbCur) {
|
||||||
TDB_FREE(pTbCur->pKey);
|
tdbFree(pTbCur->pKey);
|
||||||
TDB_FREE(pTbCur->pVal);
|
tdbFree(pTbCur->pVal);
|
||||||
metaReaderClear(&pTbCur->mr);
|
metaReaderClear(&pTbCur->mr);
|
||||||
if (pTbCur->pDbc) {
|
if (pTbCur->pDbc) {
|
||||||
tdbDbcClose(pTbCur->pDbc);
|
tdbDbcClose(pTbCur->pDbc);
|
||||||
|
|
@ -119,7 +121,7 @@ int metaTbCursorNext(SMTbCursor *pTbCur) {
|
||||||
STbCfg tbCfg;
|
STbCfg tbCfg;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ret = tdbDbNext(pTbCur->pDbc, &pTbCur->pKey, &pTbCur->kLen, &pTbCur->pVal, &pTbCur->vLen);
|
ret = tdbDbcNext(pTbCur->pDbc, &pTbCur->pKey, &pTbCur->kLen, &pTbCur->pVal, &pTbCur->vLen);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -169,7 +171,7 @@ SSchemaWrapper *metaGetTableSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver, boo
|
||||||
|
|
||||||
pSW->pSchema = pSchema;
|
pSW->pSchema = pSchema;
|
||||||
|
|
||||||
TDB_FREE(pVal);
|
tdbFree(pVal);
|
||||||
|
|
||||||
return pSW;
|
return pSW;
|
||||||
}
|
}
|
||||||
|
|
@ -185,7 +187,9 @@ struct SMCtbCursor {
|
||||||
|
|
||||||
SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) {
|
SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) {
|
||||||
SMCtbCursor *pCtbCur = NULL;
|
SMCtbCursor *pCtbCur = NULL;
|
||||||
|
SCtbIdxKey ctbIdxKey;
|
||||||
int ret;
|
int ret;
|
||||||
|
int c;
|
||||||
|
|
||||||
pCtbCur = (SMCtbCursor *)taosMemoryCalloc(1, sizeof(*pCtbCur));
|
pCtbCur = (SMCtbCursor *)taosMemoryCalloc(1, sizeof(*pCtbCur));
|
||||||
if (pCtbCur == NULL) {
|
if (pCtbCur == NULL) {
|
||||||
|
|
@ -193,12 +197,20 @@ SMCtbCursor *metaOpenCtbCursor(SMeta *pMeta, tb_uid_t uid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pCtbCur->suid = uid;
|
pCtbCur->suid = uid;
|
||||||
ret = tdbDbcOpen(pMeta->pCtbIdx, &pCtbCur->pCur);
|
ret = tdbDbcOpen(pMeta->pCtbIdx, &pCtbCur->pCur, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
taosMemoryFree(pCtbCur);
|
taosMemoryFree(pCtbCur);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// move to the suid
|
||||||
|
ctbIdxKey.suid = uid;
|
||||||
|
ctbIdxKey.uid = INT64_MIN;
|
||||||
|
tdbDbcMoveTo(pCtbCur->pCur, &ctbIdxKey, sizeof(ctbIdxKey), &c);
|
||||||
|
if (c > 0) {
|
||||||
|
tdbDbcMoveToNext(pCtbCur->pCur);
|
||||||
|
}
|
||||||
|
|
||||||
return pCtbCur;
|
return pCtbCur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,8 +219,8 @@ void metaCloseCtbCurosr(SMCtbCursor *pCtbCur) {
|
||||||
if (pCtbCur->pCur) {
|
if (pCtbCur->pCur) {
|
||||||
tdbDbcClose(pCtbCur->pCur);
|
tdbDbcClose(pCtbCur->pCur);
|
||||||
|
|
||||||
TDB_FREE(pCtbCur->pKey);
|
tdbFree(pCtbCur->pKey);
|
||||||
TDB_FREE(pCtbCur->pVal);
|
tdbFree(pCtbCur->pVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFree(pCtbCur);
|
taosMemoryFree(pCtbCur);
|
||||||
|
|
@ -219,12 +231,15 @@ tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur) {
|
||||||
int ret;
|
int ret;
|
||||||
SCtbIdxKey *pCtbIdxKey;
|
SCtbIdxKey *pCtbIdxKey;
|
||||||
|
|
||||||
ret = tdbDbNext(pCtbCur->pCur, &pCtbCur->pKey, &pCtbCur->kLen, &pCtbCur->pVal, &pCtbCur->vLen);
|
ret = tdbDbcNext(pCtbCur->pCur, &pCtbCur->pKey, &pCtbCur->kLen, &pCtbCur->pVal, &pCtbCur->vLen);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCtbIdxKey = pCtbCur->pKey;
|
pCtbIdxKey = pCtbCur->pKey;
|
||||||
|
if (pCtbIdxKey->suid > pCtbCur->suid) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return pCtbIdxKey->uid;
|
return pCtbIdxKey->uid;
|
||||||
}
|
}
|
||||||
|
|
@ -283,7 +298,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// TODO: lock during iterate?
|
// TODO: lock during iterate?
|
||||||
if (tdbDbNext(pCur->pCur, &pCur->pKey, &pCur->kLen, NULL, &pCur->vLen) == 0) {
|
if (tdbDbcNext(pCur->pCur, &pCur->pKey, &pCur->kLen, NULL, &pCur->vLen) == 0) {
|
||||||
pSmaIdxKey = pCur->pKey;
|
pSmaIdxKey = pCur->pKey;
|
||||||
ASSERT(pSmaIdxKey != NULL);
|
ASSERT(pSmaIdxKey != NULL);
|
||||||
|
|
||||||
|
|
@ -297,7 +312,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
|
||||||
++pSW->number;
|
++pSW->number;
|
||||||
STSma *tptr = (STSma *)taosMemoryRealloc(pSW->tSma, pSW->number * sizeof(STSma));
|
STSma *tptr = (STSma *)taosMemoryRealloc(pSW->tSma, pSW->number * sizeof(STSma));
|
||||||
if (tptr == NULL) {
|
if (tptr == NULL) {
|
||||||
TDB_FREE(pSmaVal);
|
tdbFree(pSmaVal);
|
||||||
metaCloseSmaCursor(pCur);
|
metaCloseSmaCursor(pCur);
|
||||||
tdDestroyTSmaWrapper(pSW);
|
tdDestroyTSmaWrapper(pSW);
|
||||||
taosMemoryFreeClear(pSW);
|
taosMemoryFreeClear(pSW);
|
||||||
|
|
@ -306,13 +321,13 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
|
||||||
pSW->tSma = tptr;
|
pSW->tSma = tptr;
|
||||||
pBuf = pSmaVal;
|
pBuf = pSmaVal;
|
||||||
if (tDecodeTSma(pBuf, pSW->tSma + pSW->number - 1) == NULL) {
|
if (tDecodeTSma(pBuf, pSW->tSma + pSW->number - 1) == NULL) {
|
||||||
TDB_FREE(pSmaVal);
|
tdbFree(pSmaVal);
|
||||||
metaCloseSmaCursor(pCur);
|
metaCloseSmaCursor(pCur);
|
||||||
tdDestroyTSmaWrapper(pSW);
|
tdDestroyTSmaWrapper(pSW);
|
||||||
taosMemoryFreeClear(pSW);
|
taosMemoryFreeClear(pSW);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
TDB_FREE(pSmaVal);
|
tdbFree(pSmaVal);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -354,7 +369,7 @@ SArray *metaGetSmaTbUids(SMeta *pMeta, bool isDup) {
|
||||||
tb_uid_t uid = 0;
|
tb_uid_t uid = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
// TODO: lock during iterate?
|
// TODO: lock during iterate?
|
||||||
if (tdbDbNext(pCur->pCur, &pCur->pKey, &pCur->kLen, NULL, &pCur->vLen) == 0) {
|
if (tdbDbcNext(pCur->pCur, &pCur->pKey, &pCur->kLen, NULL, &pCur->vLen) == 0) {
|
||||||
ASSERT(pSmaIdxKey != NULL);
|
ASSERT(pSmaIdxKey != NULL);
|
||||||
pSmaIdxKey = pCur->pKey;
|
pSmaIdxKey = pCur->pKey;
|
||||||
|
|
||||||
|
|
@ -425,11 +440,11 @@ void *metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid, bool isDecode) {
|
||||||
if (tDecodeTSma(pBuf, pCfg) == NULL) {
|
if (tDecodeTSma(pBuf, pCfg) == NULL) {
|
||||||
tdDestroyTSma(pCfg);
|
tdDestroyTSma(pCfg);
|
||||||
taosMemoryFree(pCfg);
|
taosMemoryFree(pCfg);
|
||||||
TDB_FREE(pVal);
|
tdbFree(pVal);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TDB_FREE(pVal);
|
tdbFree(pVal);
|
||||||
return pCfg;
|
return pCfg;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,7 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg, STbDdlH *pHandle) {
|
||||||
pVal = pBuf = buf;
|
pVal = pBuf = buf;
|
||||||
metaEncodeTbInfo(&pBuf, pTbCfg);
|
metaEncodeTbInfo(&pBuf, pTbCfg);
|
||||||
vLen = POINTER_DISTANCE(pBuf, buf);
|
vLen = POINTER_DISTANCE(pBuf, buf);
|
||||||
ret = tdbDbInsert(pMetaDb->pTbDB, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
ret = tdbDbPut(pMetaDb->pTbDB, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -311,7 +311,7 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg, STbDdlH *pHandle) {
|
||||||
pVal = pBuf = buf;
|
pVal = pBuf = buf;
|
||||||
metaEncodeSchemaEx(&pBuf, &schemaWrapper);
|
metaEncodeSchemaEx(&pBuf, &schemaWrapper);
|
||||||
vLen = POINTER_DISTANCE(pBuf, buf);
|
vLen = POINTER_DISTANCE(pBuf, buf);
|
||||||
ret = tdbDbInsert(pMetaDb->pSchemaDB, pKey, kLen, pVal, vLen, &pMeta->pDB->txn);
|
ret = tdbDbPut(pMetaDb->pSchemaDB, pKey, kLen, pVal, vLen, &pMeta->pDB->txn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -325,7 +325,7 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg, STbDdlH *pHandle) {
|
||||||
kLen = nameLen + 1 + sizeof(uid);
|
kLen = nameLen + 1 + sizeof(uid);
|
||||||
pVal = NULL;
|
pVal = NULL;
|
||||||
vLen = 0;
|
vLen = 0;
|
||||||
ret = tdbDbInsert(pMetaDb->pNameIdx, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
ret = tdbDbPut(pMetaDb->pNameIdx, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +336,7 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg, STbDdlH *pHandle) {
|
||||||
kLen = sizeof(uid);
|
kLen = sizeof(uid);
|
||||||
pVal = NULL;
|
pVal = NULL;
|
||||||
vLen = 0;
|
vLen = 0;
|
||||||
ret = tdbDbInsert(pMetaDb->pStbIdx, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
ret = tdbDbPut(pMetaDb->pStbIdx, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -347,7 +347,7 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg, STbDdlH *pHandle) {
|
||||||
kLen = sizeof(ctbIdxKey);
|
kLen = sizeof(ctbIdxKey);
|
||||||
pVal = NULL;
|
pVal = NULL;
|
||||||
vLen = 0;
|
vLen = 0;
|
||||||
ret = tdbDbInsert(pMetaDb->pCtbIdx, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
ret = tdbDbPut(pMetaDb->pCtbIdx, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -362,7 +362,7 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg, STbDdlH *pHandle) {
|
||||||
kLen = sizeof(uid);
|
kLen = sizeof(uid);
|
||||||
pVal = NULL;
|
pVal = NULL;
|
||||||
vLen = 0;
|
vLen = 0;
|
||||||
ret = tdbDbInsert(pMetaDb->pNtbIdx, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
ret = tdbDbPut(pMetaDb->pNtbIdx, pKey, kLen, pVal, vLen, &pMetaDb->txn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -407,7 +407,7 @@ static SSchemaWrapper *metaGetTableSchemaImpl(SMeta *pMeta, tb_uid_t uid, int32_
|
||||||
pSchemaWrapper = taosMemoryMalloc(sizeof(*pSchemaWrapper));
|
pSchemaWrapper = taosMemoryMalloc(sizeof(*pSchemaWrapper));
|
||||||
metaDecodeSchemaEx(pBuf, pSchemaWrapper, isGetEx);
|
metaDecodeSchemaEx(pBuf, pSchemaWrapper, isGetEx);
|
||||||
|
|
||||||
TDB_FREE(pVal);
|
tdbFree(pVal);
|
||||||
|
|
||||||
return pSchemaWrapper;
|
return pSchemaWrapper;
|
||||||
}
|
}
|
||||||
|
|
@ -438,7 +438,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// TODO: lock during iterate?
|
// TODO: lock during iterate?
|
||||||
if (tdbDbNext(pCur->pCur, &pCur->pKey, &pCur->kLen, NULL, &pCur->vLen) == 0) {
|
if (tdbDbcNext(pCur->pCur, &pCur->pKey, &pCur->kLen, NULL, &pCur->vLen) == 0) {
|
||||||
pSmaIdxKey = pCur->pKey;
|
pSmaIdxKey = pCur->pKey;
|
||||||
ASSERT(pSmaIdxKey != NULL);
|
ASSERT(pSmaIdxKey != NULL);
|
||||||
|
|
||||||
|
|
@ -450,7 +450,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pSW == NULL) && ((pSW = taosMemoryCalloc(1, sizeof(*pSW))) == NULL)) {
|
if ((pSW == NULL) && ((pSW = taosMemoryCalloc(1, sizeof(*pSW))) == NULL)) {
|
||||||
TDB_FREE(pSmaVal);
|
tdbFree(pSmaVal);
|
||||||
metaCloseSmaCursor(pCur);
|
metaCloseSmaCursor(pCur);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -458,7 +458,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
|
||||||
++pSW->number;
|
++pSW->number;
|
||||||
STSma *tptr = (STSma *)taosMemoryRealloc(pSW->tSma, pSW->number * sizeof(STSma));
|
STSma *tptr = (STSma *)taosMemoryRealloc(pSW->tSma, pSW->number * sizeof(STSma));
|
||||||
if (tptr == NULL) {
|
if (tptr == NULL) {
|
||||||
TDB_FREE(pSmaVal);
|
tdbFree(pSmaVal);
|
||||||
metaCloseSmaCursor(pCur);
|
metaCloseSmaCursor(pCur);
|
||||||
tdDestroyTSmaWrapper(pSW);
|
tdDestroyTSmaWrapper(pSW);
|
||||||
taosMemoryFreeClear(pSW);
|
taosMemoryFreeClear(pSW);
|
||||||
|
|
@ -467,13 +467,13 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
|
||||||
pSW->tSma = tptr;
|
pSW->tSma = tptr;
|
||||||
pBuf = pSmaVal;
|
pBuf = pSmaVal;
|
||||||
if (tDecodeTSma(pBuf, pSW->tSma + pSW->number - 1) == NULL) {
|
if (tDecodeTSma(pBuf, pSW->tSma + pSW->number - 1) == NULL) {
|
||||||
TDB_FREE(pSmaVal);
|
tdbFree(pSmaVal);
|
||||||
metaCloseSmaCursor(pCur);
|
metaCloseSmaCursor(pCur);
|
||||||
tdDestroyTSmaWrapper(pSW);
|
tdDestroyTSmaWrapper(pSW);
|
||||||
taosMemoryFreeClear(pSW);
|
taosMemoryFreeClear(pSW);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
TDB_FREE(pSmaVal);
|
tdbFree(pSmaVal);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -530,7 +530,7 @@ int metaSaveSmaToDB(SMeta *pMeta, STSma *pSmaCfg) {
|
||||||
int32_t kLen = sizeof(pSmaCfg->indexUid);
|
int32_t kLen = sizeof(pSmaCfg->indexUid);
|
||||||
int32_t vLen = POINTER_DISTANCE(qBuf, pBuf);
|
int32_t vLen = POINTER_DISTANCE(qBuf, pBuf);
|
||||||
|
|
||||||
ret = tdbDbInsert(pMeta->pDB->pSmaDB, key, kLen, val, vLen, &pMetaDb->txn);
|
ret = tdbDbPut(pMeta->pDB->pSmaDB, key, kLen, val, vLen, &pMetaDb->txn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
taosMemoryFreeClear(pBuf);
|
taosMemoryFreeClear(pBuf);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -545,7 +545,7 @@ int metaSaveSmaToDB(SMeta *pMeta, STSma *pSmaCfg) {
|
||||||
val = NULL;
|
val = NULL;
|
||||||
vLen = 0;
|
vLen = 0;
|
||||||
|
|
||||||
ret = tdbDbInsert(pMeta->pDB->pSmaIdx, key, kLen, val, vLen, &pMetaDb->txn);
|
ret = tdbDbPut(pMeta->pDB->pSmaIdx, key, kLen, val, vLen, &pMetaDb->txn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
taosMemoryFreeClear(pBuf);
|
taosMemoryFreeClear(pBuf);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -613,7 +613,7 @@ int64_t metaSmaCursorNext(SMSmaCursor *pCur) {
|
||||||
void *pBuf;
|
void *pBuf;
|
||||||
SSmaIdxKey *smaIdxKey;
|
SSmaIdxKey *smaIdxKey;
|
||||||
|
|
||||||
ret = tdbDbNext(pCur->pCur, &pCur->pKey, &pCur->kLen, &pCur->pVal, &pCur->vLen);
|
ret = tdbDbcNext(pCur->pCur, &pCur->pKey, &pCur->kLen, &pCur->pVal, &pCur->vLen);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,19 +61,58 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
|
|
||||||
if (metaHandleEntry(pMeta, &me) < 0) goto _err;
|
if (metaHandleEntry(pMeta, &me) < 0) goto _err;
|
||||||
|
|
||||||
metaDebug("vgId: %d super table is created, name:%s uid: %" PRId64, TD_VID(pMeta->pVnode), pReq->name, pReq->suid);
|
metaDebug("vgId:%d super table is created, name:%s uid: %" PRId64, TD_VID(pMeta->pVnode), pReq->name, pReq->suid);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
metaError("vgId: %d failed to create super table: %s uid: %" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
|
metaError("vgId:%d failed to create super table: %s uid: %" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
|
||||||
pReq->suid, tstrerror(terrno));
|
pReq->suid, tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
|
int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
|
||||||
// TODO
|
SMetaReader mr = {0};
|
||||||
|
|
||||||
|
// validate req
|
||||||
|
metaReaderInit(&mr, pMeta, 0);
|
||||||
|
if (metaGetTableEntryByUid(&mr, pReq->suid) < 0) {
|
||||||
|
terrno = TSDB_CODE_VND_TABLE_NOT_EXIST;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// do drop
|
||||||
|
// drop from pTbDb
|
||||||
|
// drop from pSkmDb
|
||||||
|
// drop from pUidIdx
|
||||||
|
// drop from pNameIdx
|
||||||
|
// {
|
||||||
|
// TDBC *pDbc1 = NULL;
|
||||||
|
// void *pKey = NULL;
|
||||||
|
// void *pVal = NULL;
|
||||||
|
// int kLen = 0;
|
||||||
|
// int vLen = 0;
|
||||||
|
// int ret = 0;
|
||||||
|
|
||||||
|
// // drop from pCtbIdx
|
||||||
|
// ret = tdbDbcOpen(pMeta->pCtbIdx, &pDbc1);
|
||||||
|
// tdbDbcMoveTo(pDbc1, &pReq->suid, sizeof(pReq->suid), NULL /*cmpr*/, 0 /*TDB_FORWARD_SEARCH*/);
|
||||||
|
// tdbDbcGet(pDbc1, &pKey, &kLen, &pVal, vLen);
|
||||||
|
// tdbDbcDrop(pDbc1);
|
||||||
|
// // drop from pTagIdx
|
||||||
|
// // drop from pTtlIdx
|
||||||
|
// }
|
||||||
|
|
||||||
|
// clear and return
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
metaError("vgId:%d super table %s uid:%" PRId64 " is dropped", TD_VID(pMeta->pVnode), pReq->name, pReq->suid);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
metaReaderClear(&mr);
|
||||||
|
metaError("vgId:%d failed to drop super table %s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name,
|
||||||
|
pReq->suid, tstrerror(terrno));
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
|
int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
|
||||||
|
|
@ -179,7 +218,7 @@ static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
tCoderClear(&coder);
|
tCoderClear(&coder);
|
||||||
|
|
||||||
// write to table.db
|
// write to table.db
|
||||||
if (tdbDbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, &pMeta->txn) < 0) {
|
if (tdbDbPut(pMeta->pTbDb, pKey, kLen, pVal, vLen, &pMeta->txn) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,11 +231,11 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
return tdbDbInsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &pME->version, sizeof(int64_t), &pMeta->txn);
|
return tdbDbPut(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &pME->version, sizeof(int64_t), &pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
return tdbDbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), &pMeta->txn);
|
return tdbDbPut(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), &pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
|
|
@ -219,12 +258,12 @@ static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
ttlKey.dtime = ctime + ttlDays * 24 * 60 * 60;
|
ttlKey.dtime = ctime + ttlDays * 24 * 60 * 60;
|
||||||
ttlKey.uid = pME->uid;
|
ttlKey.uid = pME->uid;
|
||||||
|
|
||||||
return tdbDbInsert(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), NULL, 0, &pMeta->txn);
|
return tdbDbPut(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), NULL, 0, &pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
SCtbIdxKey ctbIdxKey = {.suid = pME->ctbEntry.suid, .uid = pME->uid};
|
SCtbIdxKey ctbIdxKey = {.suid = pME->ctbEntry.suid, .uid = pME->uid};
|
||||||
return tdbDbInsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), NULL, 0, &pMeta->txn);
|
return tdbDbPut(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), NULL, 0, &pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
|
|
@ -265,7 +304,7 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
tCoderInit(&coder, TD_LITTLE_ENDIAN, pVal, vLen, TD_ENCODER);
|
tCoderInit(&coder, TD_LITTLE_ENDIAN, pVal, vLen, TD_ENCODER);
|
||||||
tEncodeSSchemaWrapper(&coder, pSW);
|
tEncodeSSchemaWrapper(&coder, pSW);
|
||||||
|
|
||||||
if (tdbDbInsert(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), pVal, vLen, &pMeta->txn) < 0) {
|
if (tdbDbPut(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), pVal, vLen, &pMeta->txn) < 0) {
|
||||||
rcode = -1;
|
rcode = -1;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,48 @@ void tqClose(STQ* pTq) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tdSRowDemo() {
|
||||||
|
#define DEMO_N_COLS 3
|
||||||
|
|
||||||
|
int16_t schemaVersion = 0;
|
||||||
|
int32_t numOfCols = DEMO_N_COLS; // ts + int
|
||||||
|
SRowBuilder rb = {0};
|
||||||
|
|
||||||
|
SSchema schema[DEMO_N_COLS] = {
|
||||||
|
{.type = TSDB_DATA_TYPE_TIMESTAMP, .colId = 1, .name = "ts", .bytes = 8, .flags = SCHEMA_SMA_ON},
|
||||||
|
{.type = TSDB_DATA_TYPE_INT, .colId = 2, .name = "c1", .bytes = 4, .flags = SCHEMA_SMA_ON},
|
||||||
|
{.type = TSDB_DATA_TYPE_INT, .colId = 3, .name = "c2", .bytes = 4, .flags = SCHEMA_SMA_ON}};
|
||||||
|
|
||||||
|
SSchema* pSchema = schema;
|
||||||
|
STSchema* pTSChema = tdGetSTSChemaFromSSChema(&pSchema, numOfCols);
|
||||||
|
|
||||||
|
tdSRowInit(&rb, schemaVersion);
|
||||||
|
tdSRowSetTpInfo(&rb, numOfCols, pTSChema->flen);
|
||||||
|
int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSChema);
|
||||||
|
void* row = taosMemoryCalloc(1, maxLen); // make sure the buffer is enough
|
||||||
|
|
||||||
|
// set row buf
|
||||||
|
tdSRowResetBuf(&rb, row);
|
||||||
|
|
||||||
|
for (int32_t idx = 0; idx < pTSChema->numOfCols; ++idx) {
|
||||||
|
STColumn* pColumn = pTSChema->columns + idx;
|
||||||
|
if (idx == 0) {
|
||||||
|
int64_t tsKey = 1651234567;
|
||||||
|
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, &tsKey, true, pColumn->offset, idx);
|
||||||
|
} else if (idx == 1) {
|
||||||
|
int32_t val1 = 10;
|
||||||
|
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, &val1, true, pColumn->offset, idx);
|
||||||
|
} else {
|
||||||
|
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NONE, NULL, true, pColumn->offset, idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// print
|
||||||
|
tdSRowPrint(row, pTSChema, __func__);
|
||||||
|
|
||||||
|
taosMemoryFree(pTSChema);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) {
|
int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) {
|
||||||
if (msgType != TDMT_VND_SUBMIT) return 0;
|
if (msgType != TDMT_VND_SUBMIT) return 0;
|
||||||
void* pIter = NULL;
|
void* pIter = NULL;
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,9 @@ int32_t tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t
|
||||||
// pMsg->numOfBlocks = htonl(pMsg->numOfBlocks);
|
// pMsg->numOfBlocks = htonl(pMsg->numOfBlocks);
|
||||||
|
|
||||||
// iterate and convert
|
// iterate and convert
|
||||||
if (tInitSubmitMsgIterEx(pMsg, &pReadHandle->msgIter) < 0) return -1;
|
if (tInitSubmitMsgIter(pMsg, &pReadHandle->msgIter) < 0) return -1;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (tGetSubmitMsgNextEx(&pReadHandle->msgIter, &pReadHandle->pBlock) < 0) return -1;
|
if (tGetSubmitMsgNext(&pReadHandle->msgIter, &pReadHandle->pBlock) < 0) return -1;
|
||||||
if (pReadHandle->pBlock == NULL) break;
|
if (pReadHandle->pBlock == NULL) break;
|
||||||
|
|
||||||
// pReadHandle->pBlock->uid = htobe64(pReadHandle->pBlock->uid);
|
// pReadHandle->pBlock->uid = htobe64(pReadHandle->pBlock->uid);
|
||||||
|
|
@ -50,7 +50,7 @@ int32_t tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t
|
||||||
// pReadHandle->pBlock->numOfRows = htons(pReadHandle->pBlock->numOfRows);
|
// pReadHandle->pBlock->numOfRows = htons(pReadHandle->pBlock->numOfRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tInitSubmitMsgIterEx(pMsg, &pReadHandle->msgIter) < 0) return -1;
|
if (tInitSubmitMsgIter(pMsg, &pReadHandle->msgIter) < 0) return -1;
|
||||||
pReadHandle->ver = ver;
|
pReadHandle->ver = ver;
|
||||||
memset(&pReadHandle->blkIter, 0, sizeof(SSubmitBlkIter));
|
memset(&pReadHandle->blkIter, 0, sizeof(SSubmitBlkIter));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -58,7 +58,7 @@ int32_t tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t
|
||||||
|
|
||||||
bool tqNextDataBlock(STqReadHandle* pHandle) {
|
bool tqNextDataBlock(STqReadHandle* pHandle) {
|
||||||
while (1) {
|
while (1) {
|
||||||
if (tGetSubmitMsgNextEx(&pHandle->msgIter, &pHandle->pBlock) < 0) {
|
if (tGetSubmitMsgNext(&pHandle->msgIter, &pHandle->pBlock) < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pHandle->pBlock == NULL) return false;
|
if (pHandle->pBlock == NULL) return false;
|
||||||
|
|
@ -91,16 +91,8 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
|
||||||
int32_t sversion = 0;
|
int32_t sversion = 0;
|
||||||
if (pHandle->sver != sversion) {
|
if (pHandle->sver != sversion) {
|
||||||
pHandle->pSchema = metaGetTbTSchema(pHandle->pVnodeMeta, pHandle->msgIter.uid, sversion);
|
pHandle->pSchema = metaGetTbTSchema(pHandle->pVnodeMeta, pHandle->msgIter.uid, sversion);
|
||||||
#if 0
|
|
||||||
tb_uid_t quid;
|
// this interface use suid instead of uid
|
||||||
STbCfg* pTbCfg = metaGetTbInfoByUid(pHandle->pVnodeMeta, pHandle->msgIter.uid);
|
|
||||||
if (pTbCfg->type == META_CHILD_TABLE) {
|
|
||||||
quid = pTbCfg->ctbCfg.suid;
|
|
||||||
} else {
|
|
||||||
quid = pHandle->msgIter.uid;
|
|
||||||
}
|
|
||||||
pHandle->pSchemaWrapper = metaGetTableSchema(pHandle->pVnodeMeta, quid, sversion, true);
|
|
||||||
#endif
|
|
||||||
pHandle->pSchemaWrapper = metaGetTableSchema(pHandle->pVnodeMeta, pHandle->msgIter.suid, sversion, true);
|
pHandle->pSchemaWrapper = metaGetTableSchema(pHandle->pVnodeMeta, pHandle->msgIter.suid, sversion, true);
|
||||||
pHandle->sver = sversion;
|
pHandle->sver = sversion;
|
||||||
}
|
}
|
||||||
|
|
@ -177,8 +169,8 @@ int32_t tqRetrieveDataBlock(SArray** ppCols, STqReadHandle* pHandle, uint64_t* p
|
||||||
tdSTSRowIterInit(&iter, pTschema);
|
tdSTSRowIterInit(&iter, pTschema);
|
||||||
STSRow* row;
|
STSRow* row;
|
||||||
int32_t curRow = 0;
|
int32_t curRow = 0;
|
||||||
tInitSubmitBlkIterEx(&pHandle->msgIter, pHandle->pBlock, &pHandle->blkIter);
|
tInitSubmitBlkIter(&pHandle->msgIter, pHandle->pBlock, &pHandle->blkIter);
|
||||||
while ((row = tGetSubmitBlkNextEx(&pHandle->blkIter)) != NULL) {
|
while ((row = tGetSubmitBlkNext(&pHandle->blkIter)) != NULL) {
|
||||||
tdSTSRowIterReset(&iter, row);
|
tdSTSRowIterReset(&iter, row);
|
||||||
// get all wanted col of that block
|
// get all wanted col of that block
|
||||||
for (int32_t i = 0; i < colActual; i++) {
|
for (int32_t i = 0; i < colActual; i++) {
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ typedef struct {
|
||||||
#define TSDB_COMMIT_BUF(ch) TSDB_READ_BUF(&((ch)->readh))
|
#define TSDB_COMMIT_BUF(ch) TSDB_READ_BUF(&((ch)->readh))
|
||||||
#define TSDB_COMMIT_COMP_BUF(ch) TSDB_READ_COMP_BUF(&((ch)->readh))
|
#define TSDB_COMMIT_COMP_BUF(ch) TSDB_READ_COMP_BUF(&((ch)->readh))
|
||||||
#define TSDB_COMMIT_EXBUF(ch) TSDB_READ_EXBUF(&((ch)->readh))
|
#define TSDB_COMMIT_EXBUF(ch) TSDB_READ_EXBUF(&((ch)->readh))
|
||||||
#define TSDB_COMMIT_DEFAULT_ROWS(ch) TSDB_DEFAULT_BLOCK_ROWS(TSDB_COMMIT_REPO(ch)->config.maxRows)
|
#define TSDB_COMMIT_DEFAULT_ROWS(ch) TSDB_DEFAULT_BLOCK_ROWS(TSDB_COMMIT_REPO(ch)->pVnode->config.tsdbCfg.maxRows)
|
||||||
#define TSDB_COMMIT_TXN_VERSION(ch) FS_TXN_VERSION(REPO_FS(TSDB_COMMIT_REPO(ch)))
|
#define TSDB_COMMIT_TXN_VERSION(ch) FS_TXN_VERSION(REPO_FS(TSDB_COMMIT_REPO(ch)))
|
||||||
|
|
||||||
static void tsdbStartCommit(STsdb *pRepo);
|
static void tsdbStartCommit(STsdb *pRepo);
|
||||||
|
|
@ -922,7 +922,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
||||||
STColumn *pColumn = pSchema->columns + ncol;
|
STColumn *pColumn = pSchema->columns + ncol;
|
||||||
SDataCol *pDataCol = pDataCols->cols + ncol;
|
SDataCol *pDataCol = pDataCols->cols + ncol;
|
||||||
SBlockCol *pBlockCol = pBlockData->cols + nColsNotAllNull;
|
SBlockCol *pBlockCol = pBlockData->cols + nColsNotAllNull;
|
||||||
SAggrBlkCol *pAggrBlkCol = (SAggrBlkCol *)pAggrBlkData + nColsNotAllNull;
|
SAggrBlkCol *pAggrBlkCol = (SAggrBlkCol *)pAggrBlkData + nColsOfBlockSma;
|
||||||
|
|
||||||
if (isAllRowsNull(pDataCol)) { // all data to commit are NULL, just ignore it
|
if (isAllRowsNull(pDataCol)) { // all data to commit are NULL, just ignore it
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -935,7 +935,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
||||||
pBlockCol->type = pDataCol->type;
|
pBlockCol->type = pDataCol->type;
|
||||||
pAggrBlkCol->colId = pDataCol->colId;
|
pAggrBlkCol->colId = pDataCol->colId;
|
||||||
|
|
||||||
if (isSuper && pColumn->sma && tDataTypes[pDataCol->type].statisFunc) {
|
if (isSuper && IS_BSMA_ON(pColumn) && tDataTypes[pDataCol->type].statisFunc) {
|
||||||
#if 0
|
#if 0
|
||||||
(*tDataTypes[pDataCol->type].statisFunc)(pDataCol->pData, rowsToWrite, &(pBlockCol->min), &(pBlockCol->max),
|
(*tDataTypes[pDataCol->type].statisFunc)(pDataCol->pData, rowsToWrite, &(pBlockCol->min), &(pBlockCol->max),
|
||||||
&(pBlockCol->sum), &(pBlockCol->minIndex), &(pBlockCol->maxIndex),
|
&(pBlockCol->sum), &(pBlockCol->minIndex), &(pBlockCol->maxIndex),
|
||||||
|
|
@ -951,6 +951,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
||||||
} else {
|
} else {
|
||||||
TD_SET_COL_ROWS_MISC(pBlockCol);
|
TD_SET_COL_ROWS_MISC(pBlockCol);
|
||||||
}
|
}
|
||||||
|
++nColsOfBlockSma;
|
||||||
} else if (tdIsBitmapBlkNorm(pDataCol->pBitmap, rowsToWrite, pDataCols->bitmapMode)) {
|
} else if (tdIsBitmapBlkNorm(pDataCol->pBitmap, rowsToWrite, pDataCols->bitmapMode)) {
|
||||||
// check if all rows normal
|
// check if all rows normal
|
||||||
TD_SET_COL_ROWS_NORM(pBlockCol);
|
TD_SET_COL_ROWS_NORM(pBlockCol);
|
||||||
|
|
@ -959,10 +960,6 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
||||||
}
|
}
|
||||||
|
|
||||||
++nColsNotAllNull;
|
++nColsNotAllNull;
|
||||||
|
|
||||||
if (isSuper && pColumn->sma) {
|
|
||||||
++nColsOfBlockSma;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(nColsNotAllNull >= 0 && nColsNotAllNull <= pDataCols->numOfCols);
|
ASSERT(nColsNotAllNull >= 0 && nColsNotAllNull <= pDataCols->numOfCols);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
|
|
||||||
|
extern const char *TSDB_LEVEL_DNAME[];
|
||||||
|
|
||||||
typedef enum { TSDB_TXN_TEMP_FILE = 0, TSDB_TXN_CURR_FILE } TSDB_TXN_FILE_T;
|
typedef enum { TSDB_TXN_TEMP_FILE = 0, TSDB_TXN_CURR_FILE } TSDB_TXN_FILE_T;
|
||||||
static const char *tsdbTxnFname[] = {"current.t", "current"};
|
static const char *tsdbTxnFname[] = {"current.t", "current"};
|
||||||
#define TSDB_MAX_FSETS(keep, days) ((keep) / (days) + 3)
|
#define TSDB_MAX_FSETS(keep, days) ((keep) / (days) + 3)
|
||||||
|
|
@ -35,12 +37,12 @@ static void tsdbScanAndTryFixDFilesHeader(STsdb *pRepo, int32_t *nExpired);
|
||||||
// static int tsdbProcessExpiredFS(STsdb *pRepo);
|
// static int tsdbProcessExpiredFS(STsdb *pRepo);
|
||||||
// static int tsdbCreateMeta(STsdb *pRepo);
|
// static int tsdbCreateMeta(STsdb *pRepo);
|
||||||
|
|
||||||
static void tsdbGetRootDir(int repoid, char dirName[]) {
|
static void tsdbGetRootDir(int repoid, int8_t level, char dirName[]) {
|
||||||
snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb", repoid);
|
snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/%s", repoid, TSDB_LEVEL_DNAME[level]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tsdbGetDataDir(int repoid, char dirName[]) {
|
static void tsdbGetDataDir(int repoid, int8_t level, char dirName[]) {
|
||||||
snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/data", repoid);
|
snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/%s/data", repoid, TSDB_LEVEL_DNAME[level]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For backward compatibility
|
// For backward compatibility
|
||||||
|
|
@ -588,8 +590,8 @@ static int tsdbComparFidFSet(const void *arg1, const void *arg2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tsdbGetTxnFname(STsdb *pRepo, TSDB_TXN_FILE_T ftype, char fname[]) {
|
static void tsdbGetTxnFname(STsdb *pRepo, TSDB_TXN_FILE_T ftype, char fname[]) {
|
||||||
snprintf(fname, TSDB_FILENAME_LEN, "%s/vnode/vnode%d/tsdb/%s", tfsGetPrimaryPath(REPO_TFS(pRepo)), REPO_ID(pRepo),
|
snprintf(fname, TSDB_FILENAME_LEN, "%s/vnode/vnode%d/%s/%s", tfsGetPrimaryPath(REPO_TFS(pRepo)), REPO_ID(pRepo),
|
||||||
tsdbTxnFname[ftype]);
|
TSDB_LEVEL_DNAME[REPO_LEVEL(pRepo)], tsdbTxnFname[ftype]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsdbOpenFSFromCurrent(STsdb *pRepo) {
|
static int tsdbOpenFSFromCurrent(STsdb *pRepo) {
|
||||||
|
|
@ -719,7 +721,7 @@ static int tsdbScanRootDir(STsdb *pRepo) {
|
||||||
STsdbFS *pfs = REPO_FS(pRepo);
|
STsdbFS *pfs = REPO_FS(pRepo);
|
||||||
const STfsFile *pf;
|
const STfsFile *pf;
|
||||||
|
|
||||||
tsdbGetRootDir(REPO_ID(pRepo), rootDir);
|
tsdbGetRootDir(REPO_ID(pRepo), REPO_LEVEL(pRepo), rootDir);
|
||||||
STfsDir *tdir = tfsOpendir(REPO_TFS(pRepo), rootDir);
|
STfsDir *tdir = tfsOpendir(REPO_TFS(pRepo), rootDir);
|
||||||
if (tdir == NULL) {
|
if (tdir == NULL) {
|
||||||
tsdbError("vgId:%d failed to open directory %s since %s", REPO_ID(pRepo), rootDir, tstrerror(terrno));
|
tsdbError("vgId:%d failed to open directory %s since %s", REPO_ID(pRepo), rootDir, tstrerror(terrno));
|
||||||
|
|
@ -753,7 +755,7 @@ static int tsdbScanDataDir(STsdb *pRepo) {
|
||||||
STsdbFS *pfs = REPO_FS(pRepo);
|
STsdbFS *pfs = REPO_FS(pRepo);
|
||||||
const STfsFile *pf;
|
const STfsFile *pf;
|
||||||
|
|
||||||
tsdbGetDataDir(REPO_ID(pRepo), dataDir);
|
tsdbGetDataDir(REPO_ID(pRepo), REPO_LEVEL(pRepo), dataDir);
|
||||||
STfsDir *tdir = tfsOpendir(REPO_TFS(pRepo), dataDir);
|
STfsDir *tdir = tfsOpendir(REPO_TFS(pRepo), dataDir);
|
||||||
if (tdir == NULL) {
|
if (tdir == NULL) {
|
||||||
tsdbError("vgId:%d failed to open directory %s since %s", REPO_ID(pRepo), dataDir, tstrerror(terrno));
|
tsdbError("vgId:%d failed to open directory %s since %s", REPO_ID(pRepo), dataDir, tstrerror(terrno));
|
||||||
|
|
@ -801,7 +803,7 @@ static int tsdbRestoreDFileSet(STsdb *pRepo) {
|
||||||
regex_t regex;
|
regex_t regex;
|
||||||
STsdbFS *pfs = REPO_FS(pRepo);
|
STsdbFS *pfs = REPO_FS(pRepo);
|
||||||
|
|
||||||
tsdbGetDataDir(REPO_ID(pRepo), dataDir);
|
tsdbGetDataDir(REPO_ID(pRepo), REPO_LEVEL(pRepo), dataDir);
|
||||||
|
|
||||||
// Resource allocation and init
|
// Resource allocation and init
|
||||||
regcomp(®ex, pattern, REG_EXTENDED);
|
regcomp(®ex, pattern, REG_EXTENDED);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,13 @@ static const char *TSDB_FNAME_SUFFIX[] = {
|
||||||
"rsma", // TSDB_FILE_RSMA
|
"rsma", // TSDB_FILE_RSMA
|
||||||
};
|
};
|
||||||
|
|
||||||
static void tsdbGetFilename(int vid, int fid, uint32_t ver, TSDB_FILE_T ftype, char *fname);
|
const char *TSDB_LEVEL_DNAME[] = {
|
||||||
|
"tsdb",
|
||||||
|
"rsma1",
|
||||||
|
"rsma2",
|
||||||
|
};
|
||||||
|
|
||||||
|
static void tsdbGetFilename(int vid, int fid, uint32_t ver, TSDB_FILE_T ftype, const char* dname, char *fname);
|
||||||
// static int tsdbRollBackMFile(SMFile *pMFile);
|
// static int tsdbRollBackMFile(SMFile *pMFile);
|
||||||
static int tsdbEncodeDFInfo(void **buf, SDFInfo *pInfo);
|
static int tsdbEncodeDFInfo(void **buf, SDFInfo *pInfo);
|
||||||
static void *tsdbDecodeDFInfo(void *buf, SDFInfo *pInfo);
|
static void *tsdbDecodeDFInfo(void *buf, SDFInfo *pInfo);
|
||||||
|
|
@ -45,7 +51,7 @@ void tsdbInitDFile(STsdb *pRepo, SDFile *pDFile, SDiskID did, int fid, uint32_t
|
||||||
pDFile->info.magic = TSDB_FILE_INIT_MAGIC;
|
pDFile->info.magic = TSDB_FILE_INIT_MAGIC;
|
||||||
pDFile->info.fver = tsdbGetDFSVersion(ftype);
|
pDFile->info.fver = tsdbGetDFSVersion(ftype);
|
||||||
|
|
||||||
tsdbGetFilename(REPO_ID(pRepo), fid, ver, ftype, fname);
|
tsdbGetFilename(REPO_ID(pRepo), fid, ver, ftype, TSDB_LEVEL_DNAME[pRepo->level], fname);
|
||||||
tfsInitFile(REPO_TFS(pRepo), &(pDFile->f), did, fname);
|
tfsInitFile(REPO_TFS(pRepo), &(pDFile->f), did, fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -431,14 +437,15 @@ int tsdbParseDFilename(const char *fname, int *vid, int *fid, TSDB_FILE_T *ftype
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tsdbGetFilename(int vid, int fid, uint32_t ver, TSDB_FILE_T ftype, char *fname) {
|
static void tsdbGetFilename(int vid, int fid, uint32_t ver, TSDB_FILE_T ftype, const char *dname, char *fname) {
|
||||||
ASSERT(ftype != TSDB_FILE_MAX);
|
ASSERT(ftype != TSDB_FILE_MAX);
|
||||||
|
|
||||||
if (ftype < TSDB_FILE_MAX) {
|
if (ftype < TSDB_FILE_MAX) {
|
||||||
if (ver == 0) {
|
if (ver == 0) {
|
||||||
snprintf(fname, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/data/v%df%d.%s", vid, vid, fid, TSDB_FNAME_SUFFIX[ftype]);
|
snprintf(fname, TSDB_FILENAME_LEN, "vnode/vnode%d/%s/data/v%df%d.%s", vid, dname, vid, fid,
|
||||||
|
TSDB_FNAME_SUFFIX[ftype]);
|
||||||
} else {
|
} else {
|
||||||
snprintf(fname, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/data/v%df%d.%s-ver%" PRIu32, vid, vid, fid,
|
snprintf(fname, TSDB_FILENAME_LEN, "vnode/vnode%d/%s/data/v%df%d.%s-ver%" PRIu32, vid, dname, vid, fid,
|
||||||
TSDB_FNAME_SUFFIX[ftype], ver);
|
TSDB_FNAME_SUFFIX[ftype], ver);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -190,35 +190,7 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tdScanAndConvertSubmitMsg(SSubmitReq *pMsg) {
|
int tsdbInsertTableData(STsdb *pTsdb, SSubmitMsgIter *pMsgIter, SSubmitBlk *pBlock, int32_t *pAffectedRows) {
|
||||||
ASSERT(pMsg != NULL);
|
|
||||||
SSubmitMsgIter msgIter = {0};
|
|
||||||
SSubmitBlk *pBlock = NULL;
|
|
||||||
SSubmitBlkIter blkIter = {0};
|
|
||||||
STSRow *row = NULL;
|
|
||||||
|
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
|
||||||
pMsg->length = htonl(pMsg->length);
|
|
||||||
pMsg->numOfBlocks = htonl(pMsg->numOfBlocks);
|
|
||||||
|
|
||||||
if (tInitSubmitMsgIter(pMsg, &msgIter) < 0) return -1;
|
|
||||||
while (true) {
|
|
||||||
if (tGetSubmitMsgNext(&msgIter, &pBlock) < 0) return -1;
|
|
||||||
if (pBlock == NULL) break;
|
|
||||||
|
|
||||||
pBlock->uid = htobe64(pBlock->uid);
|
|
||||||
pBlock->suid = htobe64(pBlock->suid);
|
|
||||||
pBlock->sversion = htonl(pBlock->sversion);
|
|
||||||
pBlock->dataLen = htonl(pBlock->dataLen);
|
|
||||||
pBlock->schemaLen = htonl(pBlock->schemaLen);
|
|
||||||
pBlock->numOfRows = htons(pBlock->numOfRows);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (terrno != TSDB_CODE_SUCCESS) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tsdbInsertTableData(STsdb *pTsdb, SSubmitBlk *pBlock, int32_t *pAffectedRows) {
|
|
||||||
// STsdbMeta *pMeta = pRepo->tsdbMeta;
|
// STsdbMeta *pMeta = pRepo->tsdbMeta;
|
||||||
// int32_t points = 0;
|
// int32_t points = 0;
|
||||||
// STable *pTable = NULL;
|
// STable *pTable = NULL;
|
||||||
|
|
@ -232,15 +204,15 @@ int tsdbInsertTableData(STsdb *pTsdb, SSubmitBlk *pBlock, int32_t *pAffectedRows
|
||||||
SSubmitBlk *pBlkCopy;
|
SSubmitBlk *pBlkCopy;
|
||||||
|
|
||||||
// create container is nedd
|
// create container is nedd
|
||||||
tptr = taosHashGet(pMemTable->pHashIdx, &(pBlock->uid), sizeof(pBlock->uid));
|
tptr = taosHashGet(pMemTable->pHashIdx, &(pMsgIter->uid), sizeof(pMsgIter->uid));
|
||||||
if (tptr == NULL) {
|
if (tptr == NULL) {
|
||||||
pTbData = tsdbNewTbData(pBlock->uid);
|
pTbData = tsdbNewTbData(pMsgIter->uid);
|
||||||
if (pTbData == NULL) {
|
if (pTbData == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put into hash
|
// Put into hash
|
||||||
taosHashPut(pMemTable->pHashIdx, &(pBlock->uid), sizeof(pBlock->uid), &(pTbData), sizeof(pTbData));
|
taosHashPut(pMemTable->pHashIdx, &(pMsgIter->uid), sizeof(pMsgIter->uid), &(pTbData), sizeof(pTbData));
|
||||||
|
|
||||||
// Put into skiplist
|
// Put into skiplist
|
||||||
tSkipListPut(pMemTable->pSlIdx, pTbData);
|
tSkipListPut(pMemTable->pSlIdx, pTbData);
|
||||||
|
|
@ -249,10 +221,10 @@ int tsdbInsertTableData(STsdb *pTsdb, SSubmitBlk *pBlock, int32_t *pAffectedRows
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy data to buffer pool
|
// copy data to buffer pool
|
||||||
pBlkCopy = (SSubmitBlk *)vnodeBufPoolMalloc(pTsdb->mem->pPool, pBlock->dataLen + sizeof(*pBlock));
|
pBlkCopy = (SSubmitBlk *)vnodeBufPoolMalloc(pTsdb->mem->pPool, pMsgIter->dataLen + sizeof(*pBlock));
|
||||||
memcpy(pBlkCopy, pBlock, pBlock->dataLen + sizeof(*pBlock));
|
memcpy(pBlkCopy, pBlock, pMsgIter->dataLen + sizeof(*pBlock));
|
||||||
|
|
||||||
tInitSubmitBlkIter(pBlkCopy, &blkIter);
|
tInitSubmitBlkIter(pMsgIter, pBlkCopy, &blkIter);
|
||||||
if (blkIter.row == NULL) return 0;
|
if (blkIter.row == NULL) return 0;
|
||||||
keyMin = TD_ROW_KEY(blkIter.row);
|
keyMin = TD_ROW_KEY(blkIter.row);
|
||||||
|
|
||||||
|
|
@ -261,15 +233,15 @@ int tsdbInsertTableData(STsdb *pTsdb, SSubmitBlk *pBlock, int32_t *pAffectedRows
|
||||||
// Set statistics
|
// Set statistics
|
||||||
keyMax = TD_ROW_KEY(blkIter.row);
|
keyMax = TD_ROW_KEY(blkIter.row);
|
||||||
|
|
||||||
pTbData->nrows += pBlock->numOfRows;
|
pTbData->nrows += pMsgIter->numOfRows;
|
||||||
if (pTbData->keyMin > keyMin) pTbData->keyMin = keyMin;
|
if (pTbData->keyMin > keyMin) pTbData->keyMin = keyMin;
|
||||||
if (pTbData->keyMax < keyMax) pTbData->keyMax = keyMax;
|
if (pTbData->keyMax < keyMax) pTbData->keyMax = keyMax;
|
||||||
|
|
||||||
pMemTable->nRow += pBlock->numOfRows;
|
pMemTable->nRow += pMsgIter->numOfRows;
|
||||||
if (pMemTable->keyMin > keyMin) pMemTable->keyMin = keyMin;
|
if (pMemTable->keyMin > keyMin) pMemTable->keyMin = keyMin;
|
||||||
if (pMemTable->keyMax < keyMax) pMemTable->keyMax = keyMax;
|
if (pMemTable->keyMax < keyMax) pMemTable->keyMax = keyMax;
|
||||||
|
|
||||||
(*pAffectedRows) += pBlock->numOfRows;
|
(*pAffectedRows) += pMsgIter->numOfRows;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,44 @@
|
||||||
|
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
|
|
||||||
int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb) {
|
static int tsdbOpenImpl(SVnode *pVnode, int8_t type, STsdb **ppTsdb, const char *dir, int8_t level);
|
||||||
|
|
||||||
|
int tsdbOpen(SVnode *pVnode, int8_t type) {
|
||||||
|
switch (type) {
|
||||||
|
case TSDB_TYPE_TSDB:
|
||||||
|
return tsdbOpenImpl(pVnode, type, &VND_TSDB(pVnode), VNODE_TSDB_DIR, TSDB_RETENTION_L0);
|
||||||
|
case TSDB_TYPE_TSMA:
|
||||||
|
ASSERT(0);
|
||||||
|
break;
|
||||||
|
case TSDB_TYPE_RSMA_L0:
|
||||||
|
return tsdbOpenImpl(pVnode, type, &VND_RSMA0(pVnode), VNODE_TSDB_DIR, TSDB_RETENTION_L0);
|
||||||
|
case TSDB_TYPE_RSMA_L1:
|
||||||
|
return tsdbOpenImpl(pVnode, type, &VND_RSMA1(pVnode), VNODE_RSMA1_DIR, TSDB_RETENTION_L1);
|
||||||
|
case TSDB_TYPE_RSMA_L2:
|
||||||
|
return tsdbOpenImpl(pVnode, type, &VND_RSMA2(pVnode), VNODE_RSMA2_DIR, TSDB_RETENTION_L2);
|
||||||
|
default:
|
||||||
|
ASSERT(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
*
|
||||||
|
* @param pVnode
|
||||||
|
* @param type
|
||||||
|
* @param ppTsdb
|
||||||
|
* @param dir
|
||||||
|
* @param level retention level
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
int tsdbOpenImpl(SVnode *pVnode, int8_t type, STsdb **ppTsdb, const char *dir, int8_t level) {
|
||||||
STsdb *pTsdb = NULL;
|
STsdb *pTsdb = NULL;
|
||||||
int slen = 0;
|
int slen = 0;
|
||||||
|
|
||||||
*ppTsdb = NULL;
|
*ppTsdb = NULL;
|
||||||
slen = strlen(tfsGetPrimaryPath(pVnode->pTfs)) + strlen(pVnode->path) + strlen(VNODE_TSDB_DIR) + 3;
|
slen = strlen(tfsGetPrimaryPath(pVnode->pTfs)) + strlen(pVnode->path) + strlen(dir) + 3;
|
||||||
|
|
||||||
// create handle
|
// create handle
|
||||||
pTsdb = (STsdb *)taosMemoryCalloc(1, sizeof(*pTsdb) + slen);
|
pTsdb = (STsdb *)taosMemoryCalloc(1, sizeof(*pTsdb) + slen);
|
||||||
|
|
@ -31,12 +63,12 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb) {
|
||||||
|
|
||||||
pTsdb->path = (char *)&pTsdb[1];
|
pTsdb->path = (char *)&pTsdb[1];
|
||||||
sprintf(pTsdb->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
sprintf(pTsdb->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
|
||||||
VNODE_TSDB_DIR);
|
dir);
|
||||||
pTsdb->pVnode = pVnode;
|
pTsdb->pVnode = pVnode;
|
||||||
|
pTsdb->level = level;
|
||||||
pTsdb->repoLocked = false;
|
pTsdb->repoLocked = false;
|
||||||
tdbMutexInit(&pTsdb->mutex, NULL);
|
taosThreadMutexInit(&pTsdb->mutex, NULL);
|
||||||
pTsdb->config = pVnode->config.tsdbCfg;
|
pTsdb->fs = tsdbNewFS(REPO_CFG(pTsdb));
|
||||||
pTsdb->fs = tsdbNewFS(&pTsdb->config);
|
|
||||||
|
|
||||||
// create dir (TODO: use tfsMkdir)
|
// create dir (TODO: use tfsMkdir)
|
||||||
taosMkDir(pTsdb->path);
|
taosMkDir(pTsdb->path);
|
||||||
|
|
@ -46,7 +78,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbDebug("vgId: %d tsdb is opened", TD_VID(pVnode));
|
tsdbDebug("vgId:%d tsdb is opened for %s", TD_VID(pVnode), pTsdb->path);
|
||||||
|
|
||||||
*ppTsdb = pTsdb;
|
*ppTsdb = pTsdb;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -58,6 +90,7 @@ _err:
|
||||||
|
|
||||||
int tsdbClose(STsdb *pTsdb) {
|
int tsdbClose(STsdb *pTsdb) {
|
||||||
if (pTsdb) {
|
if (pTsdb) {
|
||||||
|
// TODO: destroy mem/imem
|
||||||
tsdbCloseFS(pTsdb);
|
tsdbCloseFS(pTsdb);
|
||||||
tsdbFreeFS(pTsdb->fs);
|
tsdbFreeFS(pTsdb->fs);
|
||||||
taosMemoryFree(pTsdb);
|
taosMemoryFree(pTsdb);
|
||||||
|
|
|
||||||
|
|
@ -97,12 +97,20 @@ typedef struct SIOCostSummary {
|
||||||
int64_t headFileLoadTime;
|
int64_t headFileLoadTime;
|
||||||
} SIOCostSummary;
|
} SIOCostSummary;
|
||||||
|
|
||||||
|
typedef struct SBlockLoadSuppInfo {
|
||||||
|
SColumnDataAgg* pstatis;
|
||||||
|
SColumnDataAgg** plist;
|
||||||
|
SArray* defaultLoadColumn; // default load column
|
||||||
|
int32_t* slotIds; // colId to slotId
|
||||||
|
} SBlockLoadSuppInfo;
|
||||||
|
|
||||||
typedef struct STsdbReadHandle {
|
typedef struct STsdbReadHandle {
|
||||||
STsdb* pTsdb;
|
STsdb* pTsdb;
|
||||||
SQueryFilePos cur; // current position
|
SQueryFilePos cur; // current position
|
||||||
int16_t order;
|
int16_t order;
|
||||||
STimeWindow window; // the primary query time window that applies to all queries
|
STimeWindow window; // the primary query time window that applies to all queries
|
||||||
SColumnDataAgg* statis; // query level statistics, only one table block statistics info exists at any time
|
// SColumnDataAgg* statis; // query level statistics, only one table block statistics info exists at any time
|
||||||
|
// SColumnDataAgg** pstatis;// the ptr array list to return to caller
|
||||||
int32_t numOfBlocks;
|
int32_t numOfBlocks;
|
||||||
SArray* pColumns; // column list, SColumnInfoData array list
|
SArray* pColumns; // column list, SColumnInfoData array list
|
||||||
bool locateStart;
|
bool locateStart;
|
||||||
|
|
@ -123,13 +131,13 @@ typedef struct STsdbReadHandle {
|
||||||
STableBlockInfo* pDataBlockInfo;
|
STableBlockInfo* pDataBlockInfo;
|
||||||
SDataCols* pDataCols; // in order to hold current file data block
|
SDataCols* pDataCols; // in order to hold current file data block
|
||||||
int32_t allocSize; // allocated data block size
|
int32_t allocSize; // allocated data block size
|
||||||
SArray* defaultLoadColumn; // default load column
|
|
||||||
SDataBlockLoadInfo dataBlockLoadInfo; /* record current block load information */
|
SDataBlockLoadInfo dataBlockLoadInfo; /* record current block load information */
|
||||||
SLoadCompBlockInfo compBlockLoadInfo; /* record current compblock information in SQueryAttr */
|
SLoadCompBlockInfo compBlockLoadInfo; /* record current compblock information in SQueryAttr */
|
||||||
|
SBlockLoadSuppInfo suppInfo;
|
||||||
SArray* prev; // previous row which is before than time window
|
SArray* prev; // previous row which is before than time window
|
||||||
SArray* next; // next row which is after the query time window
|
SArray* next; // next row which is after the query time window
|
||||||
SIOCostSummary cost;
|
SIOCostSummary cost;
|
||||||
|
STSchema* pSchema;
|
||||||
} STsdbReadHandle;
|
} STsdbReadHandle;
|
||||||
|
|
||||||
typedef struct STableGroupSupporter {
|
typedef struct STableGroupSupporter {
|
||||||
|
|
@ -147,7 +155,6 @@ static int32_t checkForCachedLast(STsdbReadHandle* pTsdbReadHandle);
|
||||||
|
|
||||||
static void changeQueryHandleForInterpQuery(tsdbReaderT pHandle);
|
static void changeQueryHandleForInterpQuery(tsdbReaderT pHandle);
|
||||||
static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInfo* pCheckInfo, SBlock* pBlock);
|
static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInfo* pCheckInfo, SBlock* pBlock);
|
||||||
static int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
|
|
||||||
static int32_t tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int maxRowsToRead, STimeWindow* win,
|
static int32_t tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int maxRowsToRead, STimeWindow* win,
|
||||||
STsdbReadHandle* pTsdbReadHandle);
|
STsdbReadHandle* pTsdbReadHandle);
|
||||||
static int32_t tsdbCheckInfoCompar(const void* key1, const void* key2);
|
static int32_t tsdbCheckInfoCompar(const void* key1, const void* key2);
|
||||||
|
|
@ -156,6 +163,8 @@ static int32_t tsdbCheckInfoCompar(const void* key1, const void* key2);
|
||||||
// static void* destroyTableCheckInfo(SArray* pTableCheckInfo);
|
// static void* destroyTableCheckInfo(SArray* pTableCheckInfo);
|
||||||
static bool tsdbGetExternalRow(tsdbReaderT pHandle);
|
static bool tsdbGetExternalRow(tsdbReaderT pHandle);
|
||||||
|
|
||||||
|
static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* retentions);
|
||||||
|
|
||||||
static void tsdbInitDataBlockLoadInfo(SDataBlockLoadInfo* pBlockLoadInfo) {
|
static void tsdbInitDataBlockLoadInfo(SDataBlockLoadInfo* pBlockLoadInfo) {
|
||||||
pBlockLoadInfo->slot = -1;
|
pBlockLoadInfo->slot = -1;
|
||||||
pBlockLoadInfo->uid = 0;
|
pBlockLoadInfo->uid = 0;
|
||||||
|
|
@ -311,7 +320,7 @@ static bool emptyQueryTimewindow(STsdbReadHandle* pTsdbReadHandle) {
|
||||||
// Update the query time window according to the data time to live(TTL) information, in order to avoid to return
|
// Update the query time window according to the data time to live(TTL) information, in order to avoid to return
|
||||||
// the expired data to client, even it is queried already.
|
// the expired data to client, even it is queried already.
|
||||||
static int64_t getEarliestValidTimestamp(STsdb* pTsdb) {
|
static int64_t getEarliestValidTimestamp(STsdb* pTsdb) {
|
||||||
STsdbCfg* pCfg = &pTsdb->config;
|
STsdbCfg* pCfg = REPO_CFG(pTsdb);
|
||||||
|
|
||||||
int64_t now = taosGetTimestamp(pCfg->precision);
|
int64_t now = taosGetTimestamp(pCfg->precision);
|
||||||
return now - (tsTickPerDay[pCfg->precision] * pCfg->keep2) + 1; // needs to add one tick
|
return now - (tsTickPerDay[pCfg->precision] * pCfg->keep2) + 1; // needs to add one tick
|
||||||
|
|
@ -342,15 +351,52 @@ static void setQueryTimewindow(STsdbReadHandle* pTsdbReadHandle, SQueryTableData
|
||||||
pTsdbReadHandle->window.ekey, pTsdbReadHandle->idStr);
|
pTsdbReadHandle->window.ekey, pTsdbReadHandle->idStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
|
int nQUERY = 0;
|
||||||
|
#endif
|
||||||
|
static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* retentions) {
|
||||||
|
if (vnodeIsRollup(pVnode)) {
|
||||||
|
int level = 0;
|
||||||
|
#if 1
|
||||||
|
int64_t now = taosGetTimestamp(pVnode->config.tsdbCfg.precision);
|
||||||
|
for (int i = 0; i < TSDB_RETENTION_MAX; ++i) {
|
||||||
|
SRetention* pRetention = retentions + i;
|
||||||
|
if (pRetention->keep <= 0 || (now - pRetention->keep) >= winSKey) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
|
++nQUERY;
|
||||||
|
if(nQUERY%3 == 0) {
|
||||||
|
level = 2;
|
||||||
|
} else if(nQUERY%2 == 0) {
|
||||||
|
level = 1;
|
||||||
|
} else {
|
||||||
|
level = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (level == TSDB_RETENTION_L0) {
|
||||||
|
return VND_RSMA0(pVnode);
|
||||||
|
} else if (level == TSDB_RETENTION_L1) {
|
||||||
|
return VND_RSMA1(pVnode);
|
||||||
|
} else {
|
||||||
|
return VND_RSMA2(pVnode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pVnode->pTsdb;
|
||||||
|
}
|
||||||
|
|
||||||
static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, SQueryTableDataCond* pCond, uint64_t qId, uint64_t taskId) {
|
static STsdbReadHandle* tsdbQueryTablesImpl(SVnode* pVnode, SQueryTableDataCond* pCond, uint64_t qId, uint64_t taskId) {
|
||||||
STsdbReadHandle* pReadHandle = taosMemoryCalloc(1, sizeof(STsdbReadHandle));
|
STsdbReadHandle* pReadHandle = taosMemoryCalloc(1, sizeof(STsdbReadHandle));
|
||||||
if (pReadHandle == NULL) {
|
if (pReadHandle == NULL) {
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STsdb* pTsdb = getTsdbByRetentions(pVnode, pCond->twindow.skey, pVnode->config.tsdbCfg.retentions);
|
||||||
|
|
||||||
pReadHandle->order = pCond->order;
|
pReadHandle->order = pCond->order;
|
||||||
pReadHandle->pTsdb = tsdb;
|
pReadHandle->pTsdb = pTsdb;
|
||||||
pReadHandle->type = TSDB_QUERY_TYPE_ALL;
|
pReadHandle->type = TSDB_QUERY_TYPE_ALL;
|
||||||
pReadHandle->cur.fid = INT32_MIN;
|
pReadHandle->cur.fid = INT32_MIN;
|
||||||
pReadHandle->cur.win = TSWINDOW_INITIALIZER;
|
pReadHandle->cur.win = TSWINDOW_INITIALIZER;
|
||||||
|
|
@ -368,7 +414,7 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, SQueryTableDataCond* pC
|
||||||
snprintf(buf, tListLen(buf), "TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, qId);
|
snprintf(buf, tListLen(buf), "TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, qId);
|
||||||
pReadHandle->idStr = strdup(buf);
|
pReadHandle->idStr = strdup(buf);
|
||||||
|
|
||||||
if (tsdbInitReadH(&pReadHandle->rhelper, (STsdb*)tsdb) != 0) {
|
if (tsdbInitReadH(&pReadHandle->rhelper, pReadHandle->pTsdb) != 0) {
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -377,8 +423,8 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, SQueryTableDataCond* pC
|
||||||
|
|
||||||
if (pCond->numOfCols > 0) {
|
if (pCond->numOfCols > 0) {
|
||||||
// allocate buffer in order to load data blocks from file
|
// allocate buffer in order to load data blocks from file
|
||||||
pReadHandle->statis = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnDataAgg));
|
pReadHandle->suppInfo.pstatis = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnDataAgg));
|
||||||
if (pReadHandle->statis == NULL) {
|
if (pReadHandle->suppInfo.pstatis == NULL) {
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -398,13 +444,16 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, SQueryTableDataCond* pC
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(pReadHandle->pColumns, &colInfo);
|
taosArrayPush(pReadHandle->pColumns, &colInfo);
|
||||||
pReadHandle->statis[i].colId = colInfo.info.colId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pReadHandle->defaultLoadColumn = getDefaultLoadColumns(pReadHandle, true);
|
pReadHandle->suppInfo.defaultLoadColumn = getDefaultLoadColumns(pReadHandle, true);
|
||||||
|
pReadHandle->suppInfo.slotIds =
|
||||||
|
taosMemoryMalloc(sizeof(int32_t) * taosArrayGetSize(pReadHandle->suppInfo.defaultLoadColumn));
|
||||||
|
pReadHandle->suppInfo.plist =
|
||||||
|
taosMemoryCalloc(taosArrayGetSize(pReadHandle->suppInfo.defaultLoadColumn), POINTER_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
pReadHandle->pDataCols = tdNewDataCols(1000, pReadHandle->pTsdb->config.maxRows);
|
pReadHandle->pDataCols = tdNewDataCols(1000, pVnode->config.tsdbCfg.maxRows);
|
||||||
if (pReadHandle->pDataCols == NULL) {
|
if (pReadHandle->pDataCols == NULL) {
|
||||||
tsdbError("%p failed to malloc buf for pDataCols, %s", pReadHandle, pReadHandle->idStr);
|
tsdbError("%p failed to malloc buf for pDataCols, %s", pReadHandle, pReadHandle->idStr);
|
||||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
|
|
@ -422,9 +471,9 @@ _end:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbReaderT* tsdbQueryTablesT(STsdb* tsdb, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
tsdbReaderT* tsdbQueryTables(SVnode* pVnode, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
||||||
uint64_t taskId) {
|
uint64_t taskId) {
|
||||||
STsdbReadHandle* pTsdbReadHandle = tsdbQueryTablesImpl(tsdb, pCond, qId, taskId);
|
STsdbReadHandle* pTsdbReadHandle = tsdbQueryTablesImpl(pVnode, pCond, qId, taskId);
|
||||||
if (pTsdbReadHandle == NULL) {
|
if (pTsdbReadHandle == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -441,6 +490,29 @@ tsdbReaderT* tsdbQueryTablesT(STsdb* tsdb, SQueryTableDataCond* pCond, STableGro
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STableCheckInfo* pCheckInfo = taosArrayGet(pTsdbReadHandle->pTableCheckInfo, 0);
|
||||||
|
|
||||||
|
pTsdbReadHandle->pSchema = metaGetTbTSchema(pVnode->pMeta, pCheckInfo->tableId, 0);
|
||||||
|
int32_t numOfCols = taosArrayGetSize(pTsdbReadHandle->suppInfo.defaultLoadColumn);
|
||||||
|
int16_t* ids = pTsdbReadHandle->suppInfo.defaultLoadColumn->pData;
|
||||||
|
|
||||||
|
STSchema* pSchema = pTsdbReadHandle->pSchema;
|
||||||
|
|
||||||
|
int32_t i = 0, j = 0;
|
||||||
|
while (i < numOfCols && j < pSchema->numOfCols) {
|
||||||
|
if (ids[i] == pSchema->columns[j].colId) {
|
||||||
|
pTsdbReadHandle->suppInfo.slotIds[i] = j;
|
||||||
|
i++;
|
||||||
|
j++;
|
||||||
|
} else if (ids[i] > pSchema->columns[j].colId) {
|
||||||
|
j++;
|
||||||
|
} else {
|
||||||
|
// tsdbCleanupReadHandle(pTsdbReadHandle);
|
||||||
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tsdbDebug("%p total numOfTable:%" PRIzu " in this query, group %" PRIzu " %s", pTsdbReadHandle,
|
tsdbDebug("%p total numOfTable:%" PRIzu " in this query, group %" PRIzu " %s", pTsdbReadHandle,
|
||||||
taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo), taosArrayGetSize(groupList->pGroupList),
|
taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo), taosArrayGetSize(groupList->pGroupList),
|
||||||
pTsdbReadHandle->idStr);
|
pTsdbReadHandle->idStr);
|
||||||
|
|
@ -477,7 +549,8 @@ void tsdbResetReadHandle(tsdbReaderT queryHandle, SQueryTableDataCond* pCond) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate buffer in order to load data blocks from file
|
// allocate buffer in order to load data blocks from file
|
||||||
memset(pTsdbReadHandle->statis, 0, sizeof(SColumnDataAgg));
|
memset(pTsdbReadHandle->suppInfo.pstatis, 0, sizeof(SColumnDataAgg));
|
||||||
|
memset(pTsdbReadHandle->suppInfo.plist, 0, POINTER_BYTES);
|
||||||
|
|
||||||
tsdbInitDataBlockLoadInfo(&pTsdbReadHandle->dataBlockLoadInfo);
|
tsdbInitDataBlockLoadInfo(&pTsdbReadHandle->dataBlockLoadInfo);
|
||||||
tsdbInitCompBlockLoadInfo(&pTsdbReadHandle->compBlockLoadInfo);
|
tsdbInitCompBlockLoadInfo(&pTsdbReadHandle->compBlockLoadInfo);
|
||||||
|
|
@ -505,7 +578,8 @@ void tsdbResetQueryHandleForNewTable(tsdbReaderT queryHandle, SQueryTableDataCon
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate buffer in order to load data blocks from file
|
// allocate buffer in order to load data blocks from file
|
||||||
memset(pTsdbReadHandle->statis, 0, sizeof(SColumnDataAgg));
|
memset(pTsdbReadHandle->suppInfo.pstatis, 0, sizeof(SColumnDataAgg));
|
||||||
|
memset(pTsdbReadHandle->suppInfo.plist, 0, POINTER_BYTES);
|
||||||
|
|
||||||
tsdbInitDataBlockLoadInfo(&pTsdbReadHandle->dataBlockLoadInfo);
|
tsdbInitDataBlockLoadInfo(&pTsdbReadHandle->dataBlockLoadInfo);
|
||||||
tsdbInitCompBlockLoadInfo(&pTsdbReadHandle->compBlockLoadInfo);
|
tsdbInitCompBlockLoadInfo(&pTsdbReadHandle->compBlockLoadInfo);
|
||||||
|
|
@ -526,7 +600,7 @@ void tsdbResetQueryHandleForNewTable(tsdbReaderT queryHandle, SQueryTableDataCon
|
||||||
// pTsdbReadHandle->next = doFreeColumnInfoData(pTsdbReadHandle->next);
|
// pTsdbReadHandle->next = doFreeColumnInfoData(pTsdbReadHandle->next);
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbReaderT tsdbQueryLastRow(STsdb* tsdb, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
tsdbReaderT tsdbQueryLastRow(SVnode* pVnode, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId,
|
||||||
uint64_t taskId) {
|
uint64_t taskId) {
|
||||||
pCond->twindow = updateLastrowForEachGroup(groupList);
|
pCond->twindow = updateLastrowForEachGroup(groupList);
|
||||||
|
|
||||||
|
|
@ -535,7 +609,7 @@ tsdbReaderT tsdbQueryLastRow(STsdb* tsdb, SQueryTableDataCond* pCond, STableGrou
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbQueryTablesT(tsdb, pCond, groupList, qId, taskId);
|
STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbQueryTables(pVnode, pCond, groupList, qId, taskId);
|
||||||
if (pTsdbReadHandle == NULL) {
|
if (pTsdbReadHandle == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -618,7 +692,7 @@ static STableGroupInfo* trimTableGroup(STimeWindow* window, STableGroupInfo* pGr
|
||||||
return pNew;
|
return pNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbReaderT tsdbQueryRowsInExternalWindow(STsdb* tsdb, SQueryTableDataCond* pCond, STableGroupInfo* groupList,
|
tsdbReaderT tsdbQueryRowsInExternalWindow(SVnode* pVnode, SQueryTableDataCond* pCond, STableGroupInfo* groupList,
|
||||||
uint64_t qId, uint64_t taskId) {
|
uint64_t qId, uint64_t taskId) {
|
||||||
STableGroupInfo* pNew = trimTableGroup(&pCond->twindow, groupList);
|
STableGroupInfo* pNew = trimTableGroup(&pCond->twindow, groupList);
|
||||||
|
|
||||||
|
|
@ -634,7 +708,7 @@ tsdbReaderT tsdbQueryRowsInExternalWindow(STsdb* tsdb, SQueryTableDataCond* pCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbQueryTablesT(tsdb, pCond, pNew, qId, taskId);
|
STsdbReadHandle* pTsdbReadHandle = (STsdbReadHandle*)tsdbQueryTables(pVnode, pCond, pNew, qId, taskId);
|
||||||
pTsdbReadHandle->loadExternalRow = true;
|
pTsdbReadHandle->loadExternalRow = true;
|
||||||
pTsdbReadHandle->currentLoadExternalRows = true;
|
pTsdbReadHandle->currentLoadExternalRows = true;
|
||||||
|
|
||||||
|
|
@ -889,7 +963,7 @@ static bool moveToNextRowInMem(STableCheckInfo* pCheckInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hasMoreDataInCache(STsdbReadHandle* pHandle) {
|
static bool hasMoreDataInCache(STsdbReadHandle* pHandle) {
|
||||||
STsdbCfg* pCfg = &pHandle->pTsdb->config;
|
STsdbCfg* pCfg = REPO_CFG(pHandle->pTsdb);
|
||||||
size_t size = taosArrayGetSize(pHandle->pTableCheckInfo);
|
size_t size = taosArrayGetSize(pHandle->pTableCheckInfo);
|
||||||
assert(pHandle->activeIndex < size && pHandle->activeIndex >= 0 && size >= 1);
|
assert(pHandle->activeIndex < size && pHandle->activeIndex >= 0 && size >= 1);
|
||||||
pHandle->cur.fid = INT32_MIN;
|
pHandle->cur.fid = INT32_MIN;
|
||||||
|
|
@ -986,7 +1060,7 @@ static int32_t loadBlockInfo(STsdbReadHandle* pTsdbReadHandle, int32_t index, in
|
||||||
pCheckInfo->numOfBlocks = 0;
|
pCheckInfo->numOfBlocks = 0;
|
||||||
|
|
||||||
STable table = {.uid = pCheckInfo->tableId, .tid = pCheckInfo->tableId};
|
STable table = {.uid = pCheckInfo->tableId, .tid = pCheckInfo->tableId};
|
||||||
table.pSchema = metaGetTbTSchema(REPO_META(pTsdbReadHandle->pTsdb), pCheckInfo->tableId, 0);
|
table.pSchema = pTsdbReadHandle->pSchema;
|
||||||
|
|
||||||
if (tsdbSetReadTable(&pTsdbReadHandle->rhelper, &table) != TSDB_CODE_SUCCESS) {
|
if (tsdbSetReadTable(&pTsdbReadHandle->rhelper, &table) != TSDB_CODE_SUCCESS) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
|
@ -1091,29 +1165,28 @@ static int32_t doLoadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBl
|
||||||
int32_t slotIndex) {
|
int32_t slotIndex) {
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
|
|
||||||
STSchema* pSchema = metaGetTbTSchema(REPO_META(pTsdbReadHandle->pTsdb), pCheckInfo->tableId, 0);
|
int32_t code = tdInitDataCols(pTsdbReadHandle->pDataCols, pTsdbReadHandle->pSchema);
|
||||||
int32_t code = tdInitDataCols(pTsdbReadHandle->pDataCols, pSchema);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("%p failed to malloc buf for pDataCols, %s", pTsdbReadHandle, pTsdbReadHandle->idStr);
|
tsdbError("%p failed to malloc buf for pDataCols, %s", pTsdbReadHandle, pTsdbReadHandle->idStr);
|
||||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tdInitDataCols(pTsdbReadHandle->rhelper.pDCols[0], pSchema);
|
code = tdInitDataCols(pTsdbReadHandle->rhelper.pDCols[0], pTsdbReadHandle->pSchema);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("%p failed to malloc buf for rhelper.pDataCols[0], %s", pTsdbReadHandle, pTsdbReadHandle->idStr);
|
tsdbError("%p failed to malloc buf for rhelper.pDataCols[0], %s", pTsdbReadHandle, pTsdbReadHandle->idStr);
|
||||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tdInitDataCols(pTsdbReadHandle->rhelper.pDCols[1], pSchema);
|
code = tdInitDataCols(pTsdbReadHandle->rhelper.pDCols[1], pTsdbReadHandle->pSchema);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tsdbError("%p failed to malloc buf for rhelper.pDataCols[1], %s", pTsdbReadHandle, pTsdbReadHandle->idStr);
|
tsdbError("%p failed to malloc buf for rhelper.pDataCols[1], %s", pTsdbReadHandle, pTsdbReadHandle->idStr);
|
||||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t* colIds = pTsdbReadHandle->defaultLoadColumn->pData;
|
int16_t* colIds = pTsdbReadHandle->suppInfo.defaultLoadColumn->pData;
|
||||||
|
|
||||||
int32_t ret = tsdbLoadBlockDataCols(&(pTsdbReadHandle->rhelper), pBlock, pCheckInfo->pCompInfo, colIds,
|
int32_t ret = tsdbLoadBlockDataCols(&(pTsdbReadHandle->rhelper), pBlock, pCheckInfo->pCompInfo, colIds,
|
||||||
(int)(QH_GET_NUM_OF_COLS(pTsdbReadHandle)), true);
|
(int)(QH_GET_NUM_OF_COLS(pTsdbReadHandle)), true);
|
||||||
|
|
@ -1169,7 +1242,7 @@ static void copyAllRemainRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle,
|
||||||
|
|
||||||
static int32_t handleDataMergeIfNeeded(STsdbReadHandle* pTsdbReadHandle, SBlock* pBlock, STableCheckInfo* pCheckInfo) {
|
static int32_t handleDataMergeIfNeeded(STsdbReadHandle* pTsdbReadHandle, SBlock* pBlock, STableCheckInfo* pCheckInfo) {
|
||||||
SQueryFilePos* cur = &pTsdbReadHandle->cur;
|
SQueryFilePos* cur = &pTsdbReadHandle->cur;
|
||||||
STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config;
|
STsdbCfg* pCfg = REPO_CFG(pTsdbReadHandle->pTsdb);
|
||||||
SDataBlockInfo binfo = GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlock);
|
SDataBlockInfo binfo = GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlock);
|
||||||
TSKEY key;
|
TSKEY key;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
@ -1263,6 +1336,8 @@ static int32_t handleDataMergeIfNeeded(STsdbReadHandle* pTsdbReadHandle, SBlock*
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
|
||||||
|
|
||||||
static int32_t loadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBlock, STableCheckInfo* pCheckInfo,
|
static int32_t loadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBlock, STableCheckInfo* pCheckInfo,
|
||||||
bool* exists) {
|
bool* exists) {
|
||||||
SQueryFilePos* cur = &pTsdbReadHandle->cur;
|
SQueryFilePos* cur = &pTsdbReadHandle->cur;
|
||||||
|
|
@ -1756,7 +1831,7 @@ int32_t getEndPosInDataBlock(STsdbReadHandle* pTsdbReadHandle, SDataBlockInfo* p
|
||||||
static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInfo* pCheckInfo, SBlock* pBlock) {
|
static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInfo* pCheckInfo, SBlock* pBlock) {
|
||||||
SQueryFilePos* cur = &pTsdbReadHandle->cur;
|
SQueryFilePos* cur = &pTsdbReadHandle->cur;
|
||||||
SDataBlockInfo blockInfo = GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlock);
|
SDataBlockInfo blockInfo = GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlock);
|
||||||
STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config;
|
STsdbCfg* pCfg = REPO_CFG(pTsdbReadHandle->pTsdb);
|
||||||
|
|
||||||
initTableMemIterator(pTsdbReadHandle, pCheckInfo);
|
initTableMemIterator(pTsdbReadHandle, pCheckInfo);
|
||||||
|
|
||||||
|
|
@ -2200,7 +2275,7 @@ static int32_t getFirstFileDataBlock(STsdbReadHandle* pTsdbReadHandle, bool* exi
|
||||||
int32_t numOfBlocks = 0;
|
int32_t numOfBlocks = 0;
|
||||||
int32_t numOfTables = (int32_t)taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo);
|
int32_t numOfTables = (int32_t)taosArrayGetSize(pTsdbReadHandle->pTableCheckInfo);
|
||||||
|
|
||||||
STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config;
|
STsdbCfg* pCfg = REPO_CFG(pTsdbReadHandle->pTsdb);
|
||||||
STimeWindow win = TSWINDOW_INITIALIZER;
|
STimeWindow win = TSWINDOW_INITIALIZER;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
@ -2306,7 +2381,7 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* queryHandle, STableBlockDistInfo*
|
||||||
|
|
||||||
// find the start data block in file
|
// find the start data block in file
|
||||||
pTsdbReadHandle->locateStart = true;
|
pTsdbReadHandle->locateStart = true;
|
||||||
STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config;
|
STsdbCfg* pCfg = REPO_CFG(pTsdbReadHandle->pTsdb);
|
||||||
int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->days, pCfg->precision);
|
int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->days, pCfg->precision);
|
||||||
|
|
||||||
tsdbRLockFS(pFileHandle);
|
tsdbRLockFS(pFileHandle);
|
||||||
|
|
@ -2407,7 +2482,7 @@ static int32_t getDataBlocksInFiles(STsdbReadHandle* pTsdbReadHandle, bool* exis
|
||||||
// find the start data block in file
|
// find the start data block in file
|
||||||
if (!pTsdbReadHandle->locateStart) {
|
if (!pTsdbReadHandle->locateStart) {
|
||||||
pTsdbReadHandle->locateStart = true;
|
pTsdbReadHandle->locateStart = true;
|
||||||
STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config;
|
STsdbCfg* pCfg = REPO_CFG(pTsdbReadHandle->pTsdb);
|
||||||
int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->days, pCfg->precision);
|
int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->days, pCfg->precision);
|
||||||
|
|
||||||
tsdbRLockFS(pFileHandle);
|
tsdbRLockFS(pFileHandle);
|
||||||
|
|
@ -2498,7 +2573,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
|
||||||
STsdbReadHandle* pTsdbReadHandle) {
|
STsdbReadHandle* pTsdbReadHandle) {
|
||||||
int numOfRows = 0;
|
int numOfRows = 0;
|
||||||
int32_t numOfCols = (int32_t)taosArrayGetSize(pTsdbReadHandle->pColumns);
|
int32_t numOfCols = (int32_t)taosArrayGetSize(pTsdbReadHandle->pColumns);
|
||||||
STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config;
|
STsdbCfg* pCfg = REPO_CFG(pTsdbReadHandle->pTsdb);
|
||||||
win->skey = TSKEY_INITIAL_VAL;
|
win->skey = TSKEY_INITIAL_VAL;
|
||||||
|
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
|
|
@ -3239,8 +3314,9 @@ void tsdbRetrieveDataBlockInfo(tsdbReaderT* pTsdbReadHandle, SDataBlockInfo* pDa
|
||||||
/*
|
/*
|
||||||
* return null for mixed data block, if not a complete file data block, the statistics value will always return NULL
|
* return null for mixed data block, if not a complete file data block, the statistics value will always return NULL
|
||||||
*/
|
*/
|
||||||
int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SColumnDataAgg** pBlockStatis) {
|
int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SColumnDataAgg*** pBlockStatis, bool* allHave) {
|
||||||
STsdbReadHandle* pHandle = (STsdbReadHandle*)pTsdbReadHandle;
|
STsdbReadHandle* pHandle = (STsdbReadHandle*)pTsdbReadHandle;
|
||||||
|
*allHave = false;
|
||||||
|
|
||||||
SQueryFilePos* c = &pHandle->cur;
|
SQueryFilePos* c = &pHandle->cur;
|
||||||
if (c->mixBlock) {
|
if (c->mixBlock) {
|
||||||
|
|
@ -3269,35 +3345,47 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SColumnDat
|
||||||
tsdbDebug("vgId:%d succeed to load block statis part for uid %" PRIu64, REPO_ID(pHandle->pTsdb),
|
tsdbDebug("vgId:%d succeed to load block statis part for uid %" PRIu64, REPO_ID(pHandle->pTsdb),
|
||||||
TSDB_READ_TABLE_UID(&pHandle->rhelper));
|
TSDB_READ_TABLE_UID(&pHandle->rhelper));
|
||||||
|
|
||||||
int16_t* colIds = pHandle->defaultLoadColumn->pData;
|
int16_t* colIds = pHandle->suppInfo.defaultLoadColumn->pData;
|
||||||
|
|
||||||
size_t numOfCols = QH_GET_NUM_OF_COLS(pHandle);
|
size_t numOfCols = QH_GET_NUM_OF_COLS(pHandle);
|
||||||
memset(pHandle->statis, 0, numOfCols * sizeof(SColumnDataAgg));
|
memset(pHandle->suppInfo.plist, 0, numOfCols * POINTER_BYTES);
|
||||||
|
memset(pHandle->suppInfo.pstatis, 0, numOfCols * sizeof(SColumnDataAgg));
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
pHandle->statis[i].colId = colIds[i];
|
pHandle->suppInfo.pstatis[i].colId = colIds[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbGetBlockStatis(&pHandle->rhelper, pHandle->statis, (int)numOfCols, pBlockInfo->compBlock);
|
*allHave = true;
|
||||||
|
tsdbGetBlockStatis(&pHandle->rhelper, pHandle->suppInfo.pstatis, (int)numOfCols, pBlockInfo->compBlock);
|
||||||
|
|
||||||
// always load the first primary timestamp column data
|
// always load the first primary timestamp column data
|
||||||
SColumnDataAgg* pPrimaryColStatis = &pHandle->statis[0];
|
SColumnDataAgg* pPrimaryColStatis = &pHandle->suppInfo.pstatis[0];
|
||||||
assert(pPrimaryColStatis->colId == PRIMARYKEY_TIMESTAMP_COL_ID);
|
assert(pPrimaryColStatis->colId == PRIMARYKEY_TIMESTAMP_COL_ID);
|
||||||
|
|
||||||
pPrimaryColStatis->numOfNull = 0;
|
pPrimaryColStatis->numOfNull = 0;
|
||||||
pPrimaryColStatis->min = pBlockInfo->compBlock->keyFirst;
|
pPrimaryColStatis->min = pBlockInfo->compBlock->keyFirst;
|
||||||
pPrimaryColStatis->max = pBlockInfo->compBlock->keyLast;
|
pPrimaryColStatis->max = pBlockInfo->compBlock->keyLast;
|
||||||
|
pHandle->suppInfo.plist[0] = &pHandle->suppInfo.pstatis[0];
|
||||||
|
|
||||||
// update the number of NULL data rows
|
// update the number of NULL data rows
|
||||||
|
int32_t* slotIds = pHandle->suppInfo.slotIds;
|
||||||
for (int32_t i = 1; i < numOfCols; ++i) {
|
for (int32_t i = 1; i < numOfCols; ++i) {
|
||||||
if (pHandle->statis[i].numOfNull == -1) { // set the column data are all NULL
|
ASSERT(colIds[i] == pHandle->pSchema->columns[slotIds[i]].colId);
|
||||||
pHandle->statis[i].numOfNull = pBlockInfo->compBlock->numOfRows;
|
if (IS_BSMA_ON(&(pHandle->pSchema->columns[slotIds[i]]))) {
|
||||||
|
if (pHandle->suppInfo.pstatis[i].numOfNull == -1) { // set the column data are all NULL
|
||||||
|
pHandle->suppInfo.pstatis[i].numOfNull = pBlockInfo->compBlock->numOfRows;
|
||||||
|
} else {
|
||||||
|
pHandle->suppInfo.plist[i] = &pHandle->suppInfo.pstatis[i];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*allHave = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t elapsed = taosGetTimestampUs() - stime;
|
int64_t elapsed = taosGetTimestampUs() - stime;
|
||||||
pHandle->cost.statisInfoLoadTime += elapsed;
|
pHandle->cost.statisInfoLoadTime += elapsed;
|
||||||
|
|
||||||
*pBlockStatis = pHandle->statis;
|
*pBlockStatis = pHandle->suppInfo.plist;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3799,9 +3887,10 @@ void tsdbCleanupReadHandle(tsdbReaderT queryHandle) {
|
||||||
|
|
||||||
pTsdbReadHandle->pColumns = doFreeColumnInfoData(pTsdbReadHandle->pColumns);
|
pTsdbReadHandle->pColumns = doFreeColumnInfoData(pTsdbReadHandle->pColumns);
|
||||||
|
|
||||||
taosArrayDestroy(pTsdbReadHandle->defaultLoadColumn);
|
taosArrayDestroy(pTsdbReadHandle->suppInfo.defaultLoadColumn);
|
||||||
taosMemoryFreeClear(pTsdbReadHandle->pDataBlockInfo);
|
taosMemoryFreeClear(pTsdbReadHandle->pDataBlockInfo);
|
||||||
taosMemoryFreeClear(pTsdbReadHandle->statis);
|
taosMemoryFreeClear(pTsdbReadHandle->suppInfo.pstatis);
|
||||||
|
taosMemoryFreeClear(pTsdbReadHandle->suppInfo.plist);
|
||||||
|
|
||||||
if (!emptyQueryTimewindow(pTsdbReadHandle)) {
|
if (!emptyQueryTimewindow(pTsdbReadHandle)) {
|
||||||
// tsdbMayUnTakeMemSnapshot(pTsdbReadHandle);
|
// tsdbMayUnTakeMemSnapshot(pTsdbReadHandle);
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,8 @@ int tsdbLoadBlockInfo(SReadH *pReadh, void *pTarget) {
|
||||||
|
|
||||||
int tsdbLoadBlockData(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo) {
|
int tsdbLoadBlockData(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo) {
|
||||||
ASSERT(pBlock->numOfSubBlocks > 0);
|
ASSERT(pBlock->numOfSubBlocks > 0);
|
||||||
int8_t update = pReadh->pRepo->config.update;
|
STsdbCfg *pCfg = REPO_CFG(pReadh->pRepo);
|
||||||
|
int8_t update = pCfg->update;
|
||||||
|
|
||||||
SBlock *iBlock = pBlock;
|
SBlock *iBlock = pBlock;
|
||||||
if (pBlock->numOfSubBlocks > 1) {
|
if (pBlock->numOfSubBlocks > 1) {
|
||||||
|
|
@ -279,7 +280,7 @@ int tsdbLoadBlockData(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo) {
|
||||||
int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo, const int16_t *colIds, int numOfColsIds,
|
int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo, const int16_t *colIds, int numOfColsIds,
|
||||||
bool mergeBitmap) {
|
bool mergeBitmap) {
|
||||||
ASSERT(pBlock->numOfSubBlocks > 0);
|
ASSERT(pBlock->numOfSubBlocks > 0);
|
||||||
int8_t update = pReadh->pRepo->config.update;
|
int8_t update = pReadh->pRepo->pVnode->config.tsdbCfg.update;
|
||||||
|
|
||||||
SBlock *iBlock = pBlock;
|
SBlock *iBlock = pBlock;
|
||||||
if (pBlock->numOfSubBlocks > 1) {
|
if (pBlock->numOfSubBlocks > 1) {
|
||||||
|
|
@ -471,7 +472,7 @@ void tsdbGetBlockStatis(SReadH *pReadh, SColumnDataAgg *pStatis, int numOfCols,
|
||||||
SAggrBlkData *pAggrBlkData = pReadh->pAggrBlkData;
|
SAggrBlkData *pAggrBlkData = pReadh->pAggrBlkData;
|
||||||
|
|
||||||
for (int i = 0, j = 0; i < numOfCols;) {
|
for (int i = 0, j = 0; i < numOfCols;) {
|
||||||
if (j >= pBlock->numOfCols) {
|
if (j >= pBlock->numOfBSma) {
|
||||||
pStatis[i].numOfNull = -1;
|
pStatis[i].numOfNull = -1;
|
||||||
++i;
|
++i;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -103,10 +103,9 @@ typedef struct {
|
||||||
STSma *pSma; // cache schema
|
STSma *pSma; // cache schema
|
||||||
} SSmaStatItem;
|
} SSmaStatItem;
|
||||||
|
|
||||||
#define RSMA_MAX_LEVEL 2
|
|
||||||
#define RSMA_TASK_INFO_HASH_SLOT 8
|
#define RSMA_TASK_INFO_HASH_SLOT 8
|
||||||
struct SRSmaInfo {
|
struct SRSmaInfo {
|
||||||
void *taskInfo[RSMA_MAX_LEVEL]; // qTaskInfo_t
|
void *taskInfo[TSDB_RETENTION_L2]; // qTaskInfo_t
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SSmaStat {
|
struct SSmaStat {
|
||||||
|
|
@ -128,7 +127,7 @@ static FORCE_INLINE void tsdbFreeTaskHandle(qTaskInfo_t *taskHandle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE void *tsdbFreeRSmaInfo(SRSmaInfo *pInfo) {
|
static FORCE_INLINE void *tsdbFreeRSmaInfo(SRSmaInfo *pInfo) {
|
||||||
for (int32_t i = 0; i < RSMA_MAX_LEVEL; ++i) {
|
for (int32_t i = 0; i < TSDB_RETENTION_MAX; ++i) {
|
||||||
if (pInfo->taskInfo[i]) {
|
if (pInfo->taskInfo[i]) {
|
||||||
tsdbFreeTaskHandle(pInfo->taskInfo[i]);
|
tsdbFreeTaskHandle(pInfo->taskInfo[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -175,6 +174,9 @@ static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, const char *msg);
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tsdbUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid);
|
static FORCE_INLINE int32_t tsdbUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid);
|
||||||
static FORCE_INLINE int32_t tsdbUpdateTbUidListImpl(STsdb *pTsdb, tb_uid_t *suid, SArray *tbUids);
|
static FORCE_INLINE int32_t tsdbUpdateTbUidListImpl(STsdb *pTsdb, tb_uid_t *suid, SArray *tbUids);
|
||||||
|
static FORCE_INLINE int32_t tsdbExecuteRSmaImpl(STsdb *pTsdb, const void *pMsg, int32_t inputType,
|
||||||
|
qTaskInfo_t *taskInfo, STSchema *pTSchema, tb_uid_t suid, tb_uid_t uid,
|
||||||
|
int8_t level);
|
||||||
// mgmt interface
|
// mgmt interface
|
||||||
static int32_t tsdbDropTSmaDataImpl(STsdb *pTsdb, int64_t indexUid);
|
static int32_t tsdbDropTSmaDataImpl(STsdb *pTsdb, int64_t indexUid);
|
||||||
|
|
||||||
|
|
@ -224,7 +226,7 @@ static FORCE_INLINE int32_t tsdbUnLockSma(SSmaEnv *pEnv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static SPoolMem *openPool() {
|
static SPoolMem *openPool() {
|
||||||
SPoolMem *pPool = (SPoolMem *)tdbOsMalloc(sizeof(*pPool));
|
SPoolMem *pPool = (SPoolMem *)taosMemoryMalloc(sizeof(*pPool));
|
||||||
|
|
||||||
pPool->prev = pPool->next = pPool;
|
pPool->prev = pPool->next = pPool;
|
||||||
pPool->size = 0;
|
pPool->size = 0;
|
||||||
|
|
@ -246,7 +248,7 @@ static void clearPool(SPoolMem *pPool) {
|
||||||
pMem->prev->next = pMem->next;
|
pMem->prev->next = pMem->next;
|
||||||
pPool->size -= pMem->size;
|
pPool->size -= pMem->size;
|
||||||
|
|
||||||
tdbOsFree(pMem);
|
taosMemoryFree(pMem);
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
assert(pPool->size == 0);
|
assert(pPool->size == 0);
|
||||||
|
|
@ -255,7 +257,7 @@ static void clearPool(SPoolMem *pPool) {
|
||||||
static void closePool(SPoolMem *pPool) {
|
static void closePool(SPoolMem *pPool) {
|
||||||
if (pPool) {
|
if (pPool) {
|
||||||
clearPool(pPool);
|
clearPool(pPool);
|
||||||
tdbOsFree(pPool);
|
taosMemoryFree(pPool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -264,7 +266,7 @@ static void *poolMalloc(void *arg, size_t size) {
|
||||||
SPoolMem *pPool = (SPoolMem *)arg;
|
SPoolMem *pPool = (SPoolMem *)arg;
|
||||||
SPoolMem *pMem;
|
SPoolMem *pMem;
|
||||||
|
|
||||||
pMem = (SPoolMem *)tdbOsMalloc(sizeof(*pMem) + size);
|
pMem = (SPoolMem *)taosMemoryMalloc(sizeof(*pMem) + size);
|
||||||
if (!pMem) {
|
if (!pMem) {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
@ -291,7 +293,7 @@ static void poolFree(void *arg, void *ptr) {
|
||||||
pMem->prev->next = pMem->next;
|
pMem->prev->next = pMem->next;
|
||||||
pPool->size -= pMem->size;
|
pPool->size -= pMem->size;
|
||||||
|
|
||||||
tdbOsFree(pMem);
|
taosMemoryFree(pMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbInitSma(STsdb *pTsdb) {
|
int32_t tsdbInitSma(STsdb *pTsdb) {
|
||||||
|
|
@ -703,25 +705,25 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
|
||||||
SInterval interval = {0};
|
SInterval interval = {0};
|
||||||
TSKEY lastWinSKey = INT64_MIN;
|
TSKEY lastWinSKey = INT64_MIN;
|
||||||
|
|
||||||
if (tInitSubmitMsgIterEx(pMsg, &msgIter) != TSDB_CODE_SUCCESS) {
|
if (tInitSubmitMsgIter(pMsg, &msgIter) != TSDB_CODE_SUCCESS) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
tGetSubmitMsgNextEx(&msgIter, &pBlock);
|
tGetSubmitMsgNext(&msgIter, &pBlock);
|
||||||
if (!pBlock) break;
|
if (!pBlock) break;
|
||||||
|
|
||||||
STSmaWrapper *pSW = NULL;
|
STSmaWrapper *pSW = NULL;
|
||||||
STSma *pTSma = NULL;
|
STSma *pTSma = NULL;
|
||||||
|
|
||||||
SSubmitBlkIter blkIter = {0};
|
SSubmitBlkIter blkIter = {0};
|
||||||
if (tInitSubmitBlkIterEx(&msgIter, pBlock, &blkIter) != TSDB_CODE_SUCCESS) {
|
if (tInitSubmitBlkIter(&msgIter, pBlock, &blkIter) != TSDB_CODE_SUCCESS) {
|
||||||
pSW = tdFreeTSmaWrapper(pSW);
|
pSW = tdFreeTSmaWrapper(pSW);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
STSRow *row = tGetSubmitBlkNextEx(&blkIter);
|
STSRow *row = tGetSubmitBlkNext(&blkIter);
|
||||||
if (!row) {
|
if (!row) {
|
||||||
tdFreeTSmaWrapper(pSW);
|
tdFreeTSmaWrapper(pSW);
|
||||||
break;
|
break;
|
||||||
|
|
@ -1882,8 +1884,10 @@ int32_t tsdbFetchTbUidList(STsdb *pTsdb, STbUidStore **ppStore, tb_uid_t suid, t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASSERT(ppStore != NULL);
|
||||||
|
|
||||||
if (!(*ppStore)) {
|
if (!(*ppStore)) {
|
||||||
if (tsdbUidStoreInit((STbUidStore **)ppStore) != 0) {
|
if (tsdbUidStoreInit(ppStore) != 0) {
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1967,87 +1971,101 @@ static int32_t tsdbFetchSubmitReqSuids(SSubmitReq *pMsg, STbUidStore *pStore) {
|
||||||
|
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
if (tInitSubmitMsgIterEx(pMsg, &msgIter) < 0) return -1;
|
if (tInitSubmitMsgIter(pMsg, &msgIter) < 0) return -1;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (tGetSubmitMsgNextEx(&msgIter, &pBlock) < 0) return -1;
|
if (tGetSubmitMsgNext(&msgIter, &pBlock) < 0) return -1;
|
||||||
|
|
||||||
if (!pBlock) break;
|
if (!pBlock) break;
|
||||||
tsdbUidStorePut(pStore, msgIter.suid, NULL);
|
tsdbUidStorePut(pStore, msgIter.suid, NULL);
|
||||||
|
pStore->uid = msgIter.uid; // TODO: remove, just for debugging
|
||||||
}
|
}
|
||||||
|
|
||||||
if (terrno != TSDB_CODE_SUCCESS) return -1;
|
if (terrno != TSDB_CODE_SUCCESS) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbExecuteRSma(STsdb *pTsdb, SMeta *pMeta, const void *pMsg, int32_t inputType, tb_uid_t *suid) {
|
static FORCE_INLINE int32_t tsdbExecuteRSmaImpl(STsdb *pTsdb, const void *pMsg, int32_t inputType,
|
||||||
|
qTaskInfo_t *taskInfo, STSchema *pTSchema, tb_uid_t suid, tb_uid_t uid,
|
||||||
|
int8_t level) {
|
||||||
|
SArray *pResult = NULL;
|
||||||
|
tsdbDebug("vgId:%d execute rsma %" PRIi8 " task for qTaskInfo:%p suid:%" PRIu64, REPO_ID(pTsdb), level, taskInfo,
|
||||||
|
suid);
|
||||||
|
|
||||||
|
qSetStreamInput(taskInfo, pMsg, inputType);
|
||||||
|
while (1) {
|
||||||
|
SSDataBlock *output = NULL;
|
||||||
|
uint64_t ts;
|
||||||
|
if (qExecTask(taskInfo, &output, &ts) < 0) {
|
||||||
|
ASSERT(false);
|
||||||
|
}
|
||||||
|
if (!output) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!pResult) {
|
||||||
|
pResult = taosArrayInit(0, sizeof(SSDataBlock));
|
||||||
|
if (!pResult) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayPush(pResult, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosArrayGetSize(pResult) > 0) {
|
||||||
|
blockDebugShowData(pResult);
|
||||||
|
STsdb *sinkTsdb = (level == TSDB_RETENTION_L1 ? pTsdb->pVnode->pRSma1 : pTsdb->pVnode->pRSma2);
|
||||||
|
SSubmitReq *pReq = NULL;
|
||||||
|
if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, TD_VID(pTsdb->pVnode), uid, suid) != 0) {
|
||||||
|
taosArrayDestroy(pResult);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
if (tsdbProcessSubmitReq(sinkTsdb, INT64_MAX, pReq) != 0) {
|
||||||
|
taosArrayDestroy(pResult);
|
||||||
|
taosMemoryFreeClear(pReq);
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
taosMemoryFreeClear(pReq);
|
||||||
|
} else {
|
||||||
|
tsdbWarn("vgId:%d no rsma % " PRIi8 " data generated since %s", REPO_ID(pTsdb), level, tstrerror(terrno));
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pResult);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbExecuteRSma(STsdb *pTsdb, const void *pMsg, int32_t inputType, tb_uid_t suid, tb_uid_t uid) {
|
||||||
SSmaEnv *pEnv = REPO_RSMA_ENV(pTsdb);
|
SSmaEnv *pEnv = REPO_RSMA_ENV(pTsdb);
|
||||||
if (!pEnv) {
|
if (!pEnv) {
|
||||||
// only applicable when rsma env exists
|
// only applicable when rsma env exists
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASSERT(uid != 0); // TODO: remove later
|
||||||
|
|
||||||
SSmaStat *pStat = SMA_ENV_STAT(pEnv);
|
SSmaStat *pStat = SMA_ENV_STAT(pEnv);
|
||||||
SRSmaInfo *pRSmaInfo = NULL;
|
SRSmaInfo *pRSmaInfo = NULL;
|
||||||
|
|
||||||
pRSmaInfo = taosHashGet(SMA_STAT_INFO_HASH(pStat), suid, sizeof(tb_uid_t));
|
pRSmaInfo = taosHashGet(SMA_STAT_INFO_HASH(pStat), &suid, sizeof(tb_uid_t));
|
||||||
|
|
||||||
if (!pRSmaInfo || !(pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) {
|
if (!pRSmaInfo || !(pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) {
|
||||||
tsdbDebug("vgId:%d no rsma info for suid:%" PRIu64, REPO_ID(pTsdb), *suid);
|
tsdbDebug("vgId:%d no rsma info for suid:%" PRIu64, REPO_ID(pTsdb), suid);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray *pResult = NULL;
|
|
||||||
|
|
||||||
pResult = taosArrayInit(0, sizeof(SSDataBlock));
|
|
||||||
if (!pResult) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inputType == STREAM_DATA_TYPE_SUBMIT_BLOCK) {
|
if (inputType == STREAM_DATA_TYPE_SUBMIT_BLOCK) {
|
||||||
if (pRSmaInfo->taskInfo[0]) {
|
// TODO: use the proper schema instead of 0, and cache STSchema in cache
|
||||||
tsdbDebug("vgId:%d execute rsma task for qTaskInfo:%p suid:%" PRIu64, REPO_ID(pTsdb), pRSmaInfo->taskInfo[0],
|
STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, suid, 0);
|
||||||
*suid);
|
tsdbExecuteRSmaImpl(pTsdb, pMsg, inputType, pRSmaInfo->taskInfo[0], pTSchema, suid, uid, TSDB_RETENTION_L1);
|
||||||
qSetStreamInput(pRSmaInfo->taskInfo[0], pMsg, inputType);
|
tsdbExecuteRSmaImpl(pTsdb, pMsg, inputType, pRSmaInfo->taskInfo[1], pTSchema, suid, uid, TSDB_RETENTION_L2);
|
||||||
while (1) {
|
taosMemoryFree(pTSchema);
|
||||||
SSDataBlock *output;
|
|
||||||
uint64_t ts;
|
|
||||||
if (qExecTask(pRSmaInfo->taskInfo[0], &output, &ts) < 0) {
|
|
||||||
ASSERT(false);
|
|
||||||
}
|
|
||||||
if (!output) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
taosArrayPush(pResult, output);
|
|
||||||
}
|
|
||||||
if (taosArrayGetSize(pResult) > 0) {
|
|
||||||
blockDebugShowData(pResult);
|
|
||||||
} else {
|
|
||||||
tsdbWarn("vgId:%d no sma data generated since %s", REPO_ID(pTsdb), tstrerror(terrno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (pRSmaInfo->taskInfo[1]) {
|
|
||||||
// qSetStreamInput(pRSmaInfo->taskInfo[1], pMsg, inputType);
|
|
||||||
// while (1) {
|
|
||||||
// SSDataBlock *output;
|
|
||||||
// uint64_t ts;
|
|
||||||
// if (qExecTask(pRSmaInfo->taskInfo[1], &output, &ts) < 0) {
|
|
||||||
// ASSERT(false);
|
|
||||||
// }
|
|
||||||
// if (!output) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// taosArrayPush(pResult, output);
|
|
||||||
// }
|
|
||||||
// blockDebugShowData(pResult);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbTriggerRSma(STsdb *pTsdb, SMeta *pMeta, void *pMsg, int32_t inputType) {
|
int32_t tsdbTriggerRSma(STsdb *pTsdb, void *pMsg, int32_t inputType) {
|
||||||
SSmaEnv *pEnv = REPO_RSMA_ENV(pTsdb);
|
SSmaEnv *pEnv = REPO_RSMA_ENV(pTsdb);
|
||||||
if (!pEnv) {
|
if (!pEnv) {
|
||||||
// only applicable when rsma env exists
|
// only applicable when rsma env exists
|
||||||
|
|
@ -2059,12 +2077,12 @@ int32_t tsdbTriggerRSma(STsdb *pTsdb, SMeta *pMeta, void *pMsg, int32_t inputTyp
|
||||||
tsdbFetchSubmitReqSuids(pMsg, &uidStore);
|
tsdbFetchSubmitReqSuids(pMsg, &uidStore);
|
||||||
|
|
||||||
if (uidStore.suid != 0) {
|
if (uidStore.suid != 0) {
|
||||||
tsdbExecuteRSma(pTsdb, pMeta, pMsg, inputType, &uidStore.suid);
|
tsdbExecuteRSma(pTsdb, pMsg, inputType, uidStore.suid, uidStore.uid);
|
||||||
|
|
||||||
void *pIter = taosHashIterate(uidStore.uidHash, NULL);
|
void *pIter = taosHashIterate(uidStore.uidHash, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
tb_uid_t *pTbSuid = (tb_uid_t *)taosHashGetKey(pIter, NULL);
|
tb_uid_t *pTbSuid = (tb_uid_t *)taosHashGetKey(pIter, NULL);
|
||||||
tsdbExecuteRSma(pTsdb, pMeta, pMsg, inputType, pTbSuid);
|
tsdbExecuteRSma(pTsdb, pMsg, inputType, *pTbSuid, 0);
|
||||||
pIter = taosHashIterate(uidStore.uidHash, pIter);
|
pIter = taosHashIterate(uidStore.uidHash, pIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,11 +56,11 @@ static inline int tsdbSmaKeyCmpr(const void *arg1, int len1, const void *arg2, i
|
||||||
|
|
||||||
static int32_t tsdbOpenDBDb(TDB **ppDB, TENV *pEnv, const char *pFName) {
|
static int32_t tsdbOpenDBDb(TDB **ppDB, TENV *pEnv, const char *pFName) {
|
||||||
int ret;
|
int ret;
|
||||||
FKeyComparator compFunc;
|
tdb_cmpr_fn_t compFunc;
|
||||||
|
|
||||||
// Create a database
|
// Create a database
|
||||||
compFunc = tsdbSmaKeyCmpr;
|
compFunc = tsdbSmaKeyCmpr;
|
||||||
ret = tdbDbOpen(pFName, TDB_VARIANT_LEN, TDB_VARIANT_LEN, compFunc, pEnv, ppDB);
|
ret = tdbDbOpen(pFName, -1, -1, compFunc, pEnv, ppDB);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -97,7 +97,7 @@ int32_t tsdbCloseDBF(SDBFile *pDBF) {
|
||||||
int32_t tsdbSaveSmaToDB(SDBFile *pDBF, void *pKey, int32_t keyLen, void *pVal, int32_t valLen, TXN *txn) {
|
int32_t tsdbSaveSmaToDB(SDBFile *pDBF, void *pKey, int32_t keyLen, void *pVal, int32_t valLen, TXN *txn) {
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
|
|
||||||
ret = tdbDbInsert(pDBF->pDB, pKey, keyLen, pVal, valLen, txn);
|
ret = tdbDbPut(pDBF->pDB, pKey, keyLen, pVal, valLen, txn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tsdbError("Failed to create insert sma data into db, ret = %d", ret);
|
tsdbError("Failed to create insert sma data into db, ret = %d", ret);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,11 @@ int tsdbInsertData(STsdb *pTsdb, int64_t version, SSubmitReq *pMsg, SSubmitRsp *
|
||||||
while (true) {
|
while (true) {
|
||||||
tGetSubmitMsgNext(&msgIter, &pBlock);
|
tGetSubmitMsgNext(&msgIter, &pBlock);
|
||||||
if (pBlock == NULL) break;
|
if (pBlock == NULL) break;
|
||||||
if (tsdbInsertTableData(pTsdb, pBlock, &affectedrows) < 0) {
|
if (tsdbInsertTableData(pTsdb, &msgIter, pBlock, &affectedrows) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
numOfRows += pBlock->numOfRows;
|
numOfRows += msgIter.numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pRsp != NULL) {
|
if (pRsp != NULL) {
|
||||||
|
|
@ -60,25 +60,26 @@ static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) {
|
||||||
SSubmitBlk *pBlock = NULL;
|
SSubmitBlk *pBlock = NULL;
|
||||||
SSubmitBlkIter blkIter = {0};
|
SSubmitBlkIter blkIter = {0};
|
||||||
STSRow *row = NULL;
|
STSRow *row = NULL;
|
||||||
TSKEY now = taosGetTimestamp(pTsdb->config.precision);
|
STsdbCfg *pCfg = REPO_CFG(pTsdb);
|
||||||
TSKEY minKey = now - tsTickPerDay[pTsdb->config.precision] * pTsdb->config.keep2;
|
TSKEY now = taosGetTimestamp(pCfg->precision);
|
||||||
TSKEY maxKey = now + tsTickPerDay[pTsdb->config.precision] * pTsdb->config.days;
|
TSKEY minKey = now - tsTickPerDay[pCfg->precision] * pCfg->keep2;
|
||||||
|
TSKEY maxKey = now + tsTickPerDay[pCfg->precision] * pCfg->days;
|
||||||
|
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
pMsg->length = htonl(pMsg->length);
|
// pMsg->length = htonl(pMsg->length);
|
||||||
pMsg->numOfBlocks = htonl(pMsg->numOfBlocks);
|
// pMsg->numOfBlocks = htonl(pMsg->numOfBlocks);
|
||||||
|
|
||||||
if (tInitSubmitMsgIter(pMsg, &msgIter) < 0) return -1;
|
if (tInitSubmitMsgIter(pMsg, &msgIter) < 0) return -1;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (tGetSubmitMsgNext(&msgIter, &pBlock) < 0) return -1;
|
if (tGetSubmitMsgNext(&msgIter, &pBlock) < 0) return -1;
|
||||||
if (pBlock == NULL) break;
|
if (pBlock == NULL) break;
|
||||||
|
|
||||||
pBlock->uid = htobe64(pBlock->uid);
|
// pBlock->uid = htobe64(pBlock->uid);
|
||||||
pBlock->suid = htobe64(pBlock->suid);
|
// pBlock->suid = htobe64(pBlock->suid);
|
||||||
pBlock->sversion = htonl(pBlock->sversion);
|
// pBlock->sversion = htonl(pBlock->sversion);
|
||||||
pBlock->dataLen = htonl(pBlock->dataLen);
|
// pBlock->dataLen = htonl(pBlock->dataLen);
|
||||||
pBlock->schemaLen = htonl(pBlock->schemaLen);
|
// pBlock->schemaLen = htonl(pBlock->schemaLen);
|
||||||
pBlock->numOfRows = htons(pBlock->numOfRows);
|
// pBlock->numOfRows = htons(pBlock->numOfRows);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (pBlock->tid <= 0 || pBlock->tid >= pMeta->maxTables) {
|
if (pBlock->tid <= 0 || pBlock->tid >= pMeta->maxTables) {
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,26 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
|
||||||
if (tjsonAddIntegerToObject(pJson, "keep0", pCfg->tsdbCfg.keep0) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "keep0", pCfg->tsdbCfg.keep0) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1;
|
||||||
|
if (pCfg->tsdbCfg.retentions[0].freq > 0) {
|
||||||
|
int32_t nRetention = 1;
|
||||||
|
if (pCfg->tsdbCfg.retentions[1].freq > 0) {
|
||||||
|
++nRetention;
|
||||||
|
if (pCfg->tsdbCfg.retentions[2].freq > 0) {
|
||||||
|
++nRetention;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SJson *pNodeRetentions = tjsonCreateArray();
|
||||||
|
tjsonAddItemToObject(pJson, "retentions", pNodeRetentions);
|
||||||
|
for (int32_t i = 0; i < nRetention; ++i) {
|
||||||
|
SJson *pNodeRetention = tjsonCreateObject();
|
||||||
|
const SRetention *pRetention = pCfg->tsdbCfg.retentions + i;
|
||||||
|
tjsonAddIntegerToObject(pNodeRetention, "freq", pRetention->freq);
|
||||||
|
tjsonAddIntegerToObject(pNodeRetention, "freqUnit", pRetention->freqUnit);
|
||||||
|
tjsonAddIntegerToObject(pNodeRetention, "keep", pRetention->keep);
|
||||||
|
tjsonAddIntegerToObject(pNodeRetention, "keepUnit", pRetention->keepUnit);
|
||||||
|
tjsonAddItemToArray(pNodeRetentions, pNodeRetention);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (tjsonAddIntegerToObject(pJson, "wal.vgId", pCfg->walCfg.vgId) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "wal.vgId", pCfg->walCfg.vgId) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod) < 0) return -1;
|
||||||
if (tjsonAddIntegerToObject(pJson, "wal.retentionPeriod", pCfg->walCfg.retentionPeriod) < 0) return -1;
|
if (tjsonAddIntegerToObject(pJson, "wal.retentionPeriod", pCfg->walCfg.retentionPeriod) < 0) return -1;
|
||||||
|
|
@ -113,6 +133,19 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
||||||
if (tjsonGetNumberValue(pJson, "keep0", pCfg->tsdbCfg.keep0) < 0) return -1;
|
if (tjsonGetNumberValue(pJson, "keep0", pCfg->tsdbCfg.keep0) < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1;
|
if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1;
|
if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1;
|
||||||
|
SJson *pNodeRetentions = tjsonGetObjectItem(pJson, "retentions");
|
||||||
|
int32_t nRetention = tjsonGetArraySize(pNodeRetentions);
|
||||||
|
if (nRetention > TSDB_RETENTION_MAX) {
|
||||||
|
nRetention = TSDB_RETENTION_MAX;
|
||||||
|
}
|
||||||
|
for (int32_t i = 0; i < nRetention; ++i) {
|
||||||
|
SJson *pNodeRetention = tjsonGetArrayItem(pNodeRetentions, i);
|
||||||
|
ASSERT(pNodeRetention != NULL);
|
||||||
|
tjsonGetNumberValue(pNodeRetention, "freq", (pCfg->tsdbCfg.retentions)[i].freq);
|
||||||
|
tjsonGetNumberValue(pNodeRetention, "freqUnit", (pCfg->tsdbCfg.retentions)[i].freqUnit);
|
||||||
|
tjsonGetNumberValue(pNodeRetention, "keep", (pCfg->tsdbCfg.retentions)[i].keep);
|
||||||
|
tjsonGetNumberValue(pNodeRetention, "keepUnit", (pCfg->tsdbCfg.retentions)[i].keepUnit);
|
||||||
|
}
|
||||||
if (tjsonGetNumberValue(pJson, "wal.vgId", pCfg->walCfg.vgId) < 0) return -1;
|
if (tjsonGetNumberValue(pJson, "wal.vgId", pCfg->walCfg.vgId) < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod) < 0) return -1;
|
if (tjsonGetNumberValue(pJson, "wal.fsyncPeriod", pCfg->walCfg.fsyncPeriod) < 0) return -1;
|
||||||
if (tjsonGetNumberValue(pJson, "wal.retentionPeriod", pCfg->walCfg.retentionPeriod) < 0) return -1;
|
if (tjsonGetNumberValue(pJson, "wal.retentionPeriod", pCfg->walCfg.retentionPeriod) < 0) return -1;
|
||||||
|
|
|
||||||
|
|
@ -42,16 +42,33 @@ int vnodeBegin(SVnode *pVnode) {
|
||||||
|
|
||||||
// begin meta
|
// begin meta
|
||||||
if (metaBegin(pVnode->pMeta) < 0) {
|
if (metaBegin(pVnode->pMeta) < 0) {
|
||||||
vError("vgId: %d failed to begin meta since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to begin meta since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// begin tsdb
|
// begin tsdb
|
||||||
if (tsdbBegin(pVnode->pTsdb) < 0) {
|
if (vnodeIsRollup(pVnode)) {
|
||||||
vError("vgId: %d failed to begin tsdb since %s", TD_VID(pVnode), tstrerror(terrno));
|
if (tsdbBegin(VND_RSMA0(pVnode)) < 0) {
|
||||||
|
vError("vgId:%d failed to begin rsma0 since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tsdbBegin(VND_RSMA1(pVnode)) < 0) {
|
||||||
|
vError("vgId:%d failed to begin rsma1 since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsdbBegin(VND_RSMA2(pVnode)) < 0) {
|
||||||
|
vError("vgId:%d failed to begin rsma2 since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (tsdbBegin(pVnode->pTsdb) < 0) {
|
||||||
|
vError("vgId:%d failed to begin tsdb since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,7 +110,7 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) {
|
||||||
// free info binary
|
// free info binary
|
||||||
taosMemoryFree(data);
|
taosMemoryFree(data);
|
||||||
|
|
||||||
vInfo("vgId: %d vnode info is saved, fname: %s", pInfo->config.vgId, fname);
|
vInfo("vgId:%d vnode info is saved, fname: %s", pInfo->config.vgId, fname);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
@ -115,7 +132,7 @@ int vnodeCommitInfo(const char *dir, const SVnodeInfo *pInfo) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vInfo("vgId: %d vnode info is committed", pInfo->config.vgId);
|
vInfo("vgId:%d vnode info is committed", pInfo->config.vgId);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -190,7 +207,7 @@ int vnodeSyncCommit(SVnode *pVnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int vnodeCommit(SVnode *pVnode) {
|
int vnodeCommit(SVnode *pVnode) {
|
||||||
SVnodeInfo info;
|
SVnodeInfo info = {0};
|
||||||
char dir[TSDB_FILENAME_LEN];
|
char dir[TSDB_FILENAME_LEN];
|
||||||
|
|
||||||
vInfo("vgId:%d start to commit, version: %" PRId64, TD_VID(pVnode), pVnode->state.applied);
|
vInfo("vgId:%d start to commit, version: %" PRId64, TD_VID(pVnode), pVnode->state.applied);
|
||||||
|
|
@ -212,10 +229,28 @@ int vnodeCommit(SVnode *pVnode) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(vnodeIsRollup(pVnode)) {
|
||||||
|
if (tsdbCommit(VND_RSMA0(pVnode)) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (tsdbCommit(VND_RSMA1(pVnode)) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (tsdbCommit(VND_RSMA2(pVnode)) < 0) {
|
||||||
|
ASSERT(0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (tsdbCommit(pVnode->pTsdb) < 0) {
|
if (tsdbCommit(pVnode->pTsdb) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (tqCommit(pVnode->pTq) < 0) {
|
if (tqCommit(pVnode->pTq) < 0) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,13 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
|
||||||
|
|
||||||
// check config
|
// check config
|
||||||
if (vnodeCheckCfg(pCfg) < 0) {
|
if (vnodeCheckCfg(pCfg) < 0) {
|
||||||
vError("vgId: %d failed to create vnode since: %s", pCfg->vgId, tstrerror(terrno));
|
vError("vgId:%d failed to create vnode since: %s", pCfg->vgId, tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create vnode env
|
// create vnode env
|
||||||
if (tfsMkdir(pTfs, path) < 0) {
|
if (tfsMkdir(pTfs, path) < 0) {
|
||||||
vError("vgId: %d failed to create vnode since: %s", pCfg->vgId, tstrerror(terrno));
|
vError("vgId:%d failed to create vnode since: %s", pCfg->vgId, tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,11 +39,11 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
|
||||||
info.state.applied = -1;
|
info.state.applied = -1;
|
||||||
|
|
||||||
if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir, &info) < 0) {
|
if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir, &info) < 0) {
|
||||||
vError("vgId: %d failed to save vnode config since %s", pCfg->vgId, tstrerror(terrno));
|
vError("vgId:%d failed to save vnode config since %s", pCfg->vgId, tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vInfo("vgId: %d vnode is created", pCfg->vgId);
|
vInfo("vgId:%d vnode is created", pCfg->vgId);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -70,7 +70,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
pVnode = (SVnode *)taosMemoryCalloc(1, sizeof(*pVnode) + strlen(path) + 1);
|
pVnode = (SVnode *)taosMemoryCalloc(1, sizeof(*pVnode) + strlen(path) + 1);
|
||||||
if (pVnode == NULL) {
|
if (pVnode == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
vError("vgId: %d failed to open vnode since %s", info.config.vgId, tstrerror(terrno));
|
vError("vgId:%d failed to open vnode since %s", info.config.vgId, tstrerror(terrno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,27 +85,44 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
|
|
||||||
// open buffer pool
|
// open buffer pool
|
||||||
if (vnodeOpenBufPool(pVnode, pVnode->config.isHeap ? 0 : pVnode->config.szBuf / 3) < 0) {
|
if (vnodeOpenBufPool(pVnode, pVnode->config.isHeap ? 0 : pVnode->config.szBuf / 3) < 0) {
|
||||||
vError("vgId: %d failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open meta
|
// open meta
|
||||||
if (metaOpen(pVnode, &pVnode->pMeta) < 0) {
|
if (metaOpen(pVnode, &pVnode->pMeta) < 0) {
|
||||||
vError("vgId: %d failed to open vnode meta since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open vnode meta since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open tsdb
|
// open tsdb
|
||||||
if (tsdbOpen(pVnode, &pVnode->pTsdb) < 0) {
|
if (vnodeIsRollup(pVnode)) {
|
||||||
vError("vgId: %d failed to open vnode tsdb since %s", TD_VID(pVnode), tstrerror(terrno));
|
if (tsdbOpen(pVnode, TSDB_TYPE_RSMA_L0) < 0) {
|
||||||
|
vError("vgId:%d failed to open vnode rsma0 since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tsdbOpen(pVnode, TSDB_TYPE_RSMA_L1) < 0) {
|
||||||
|
vError("vgId:%d failed to open vnode rsma1 since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsdbOpen(pVnode, TSDB_TYPE_RSMA_L2) < 0) {
|
||||||
|
vError("vgId:%d failed to open vnode rsma2 since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (tsdbOpen(pVnode, TSDB_TYPE_TSDB) < 0) {
|
||||||
|
vError("vgId:%d failed to open vnode tsdb since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// open wal
|
// open wal
|
||||||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
|
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
|
||||||
pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
|
pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
|
||||||
if (pVnode->pWal == NULL) {
|
if (pVnode->pWal == NULL) {
|
||||||
vError("vgId: %d failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,25 +130,25 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
|
||||||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
|
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
|
||||||
pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal);
|
pVnode->pTq = tqOpen(tdir, pVnode, pVnode->pWal);
|
||||||
if (pVnode->pTq == NULL) {
|
if (pVnode->pTq == NULL) {
|
||||||
vError("vgId: %d failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open vnode tq since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open query
|
// open query
|
||||||
if (vnodeQueryOpen(pVnode)) {
|
if (vnodeQueryOpen(pVnode)) {
|
||||||
vError("vgId: %d failed to open vnode query since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open vnode query since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// vnode begin
|
// vnode begin
|
||||||
if (vnodeBegin(pVnode) < 0) {
|
if (vnodeBegin(pVnode) < 0) {
|
||||||
vError("vgId: %d failed to begin since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to begin since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open sync
|
// open sync
|
||||||
if (vnodeSyncOpen(pVnode, dir)) {
|
if (vnodeSyncOpen(pVnode, dir)) {
|
||||||
vError("vgId: %d failed to open sync since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to open sync since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,6 +160,8 @@ _err:
|
||||||
if (pVnode->pWal) walClose(pVnode->pWal);
|
if (pVnode->pWal) walClose(pVnode->pWal);
|
||||||
if (pVnode->pTsdb) tsdbClose(pVnode->pTsdb);
|
if (pVnode->pTsdb) tsdbClose(pVnode->pTsdb);
|
||||||
if (pVnode->pMeta) metaClose(pVnode->pMeta);
|
if (pVnode->pMeta) metaClose(pVnode->pMeta);
|
||||||
|
tsdbClose(VND_RSMA1(pVnode));
|
||||||
|
tsdbClose(VND_RSMA2(pVnode));
|
||||||
tsem_destroy(&(pVnode->canCommit));
|
tsem_destroy(&(pVnode->canCommit));
|
||||||
taosMemoryFree(pVnode);
|
taosMemoryFree(pVnode);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -155,7 +174,9 @@ void vnodeClose(SVnode *pVnode) {
|
||||||
vnodeQueryClose(pVnode);
|
vnodeQueryClose(pVnode);
|
||||||
walClose(pVnode->pWal);
|
walClose(pVnode->pWal);
|
||||||
tqClose(pVnode->pTq);
|
tqClose(pVnode->pTq);
|
||||||
tsdbClose(pVnode->pTsdb);
|
tsdbClose(VND_TSDB(pVnode));
|
||||||
|
tsdbClose(VND_RSMA1(pVnode));
|
||||||
|
tsdbClose(VND_RSMA2(pVnode));
|
||||||
metaClose(pVnode->pMeta);
|
metaClose(pVnode->pMeta);
|
||||||
vnodeCloseBufPool(pVnode);
|
vnodeCloseBufPool(pVnode);
|
||||||
// destroy handle
|
// destroy handle
|
||||||
|
|
|
||||||
|
|
@ -150,11 +150,6 @@ void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrapper of tsdb read interface
|
// wrapper of tsdb read interface
|
||||||
// TODO: use FORCE_INLINE if possible later
|
|
||||||
tsdbReaderT *tsdbQueryTables(SVnode *pVnode, SQueryTableDataCond *pCond, STableGroupInfo *tableInfoGroup, uint64_t qId,
|
|
||||||
uint64_t taskId) {
|
|
||||||
return tsdbQueryTablesT(pVnode->pTsdb, pCond, tableInfoGroup, qId, taskId);
|
|
||||||
}
|
|
||||||
tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STableGroupInfo *groupList, uint64_t qId,
|
tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STableGroupInfo *groupList, uint64_t qId,
|
||||||
void *pMemRef) {
|
void *pMemRef) {
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@
|
||||||
|
|
||||||
static int vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp);
|
static int vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessAlterStbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp);
|
static int vnodeProcessAlterStbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessDropStbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp);
|
static int vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp);
|
static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessAlterTbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp);
|
static int vnodeProcessAlterTbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessDropTbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp);
|
static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
|
|
||||||
int vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs, int64_t *version) {
|
int vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs, int64_t *version) {
|
||||||
|
|
@ -52,7 +52,7 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
|
||||||
int len;
|
int len;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
vTrace("vgId: %d start to process write request %s, version %" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType),
|
vTrace("vgId:%d start to process write request %s, version %" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType),
|
||||||
version);
|
version);
|
||||||
|
|
||||||
pVnode->state.applied = version;
|
pVnode->state.applied = version;
|
||||||
|
|
@ -62,7 +62,7 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
|
||||||
len = pMsg->contLen - sizeof(SMsgHead);
|
len = pMsg->contLen - sizeof(SMsgHead);
|
||||||
|
|
||||||
if (tqPushMsg(pVnode->pTq, pMsg->pCont, pMsg->contLen, pMsg->msgType, version) < 0) {
|
if (tqPushMsg(pVnode->pTq, pMsg->pCont, pMsg->contLen, pMsg->msgType, version) < 0) {
|
||||||
vError("vgId: %d failed to push msg to TQ since %s", TD_VID(pVnode), tstrerror(terrno));
|
vError("vgId:%d failed to push msg to TQ since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
|
||||||
if (vnodeProcessAlterStbReq(pVnode, pReq, len, pRsp) < 0) goto _err;
|
if (vnodeProcessAlterStbReq(pVnode, pReq, len, pRsp) < 0) goto _err;
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_DROP_STB:
|
case TDMT_VND_DROP_STB:
|
||||||
if (vnodeProcessDropStbReq(pVnode, pReq, len, pRsp) < 0) goto _err;
|
if (vnodeProcessDropStbReq(pVnode, version, pReq, len, pRsp) < 0) goto _err;
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_CREATE_TABLE:
|
case TDMT_VND_CREATE_TABLE:
|
||||||
if (vnodeProcessCreateTbReq(pVnode, version, pReq, len, pRsp) < 0) goto _err;
|
if (vnodeProcessCreateTbReq(pVnode, version, pReq, len, pRsp) < 0) goto _err;
|
||||||
|
|
@ -84,7 +84,7 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
|
||||||
if (vnodeProcessAlterTbReq(pVnode, pReq, len, pRsp) < 0) goto _err;
|
if (vnodeProcessAlterTbReq(pVnode, pReq, len, pRsp) < 0) goto _err;
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_DROP_TABLE:
|
case TDMT_VND_DROP_TABLE:
|
||||||
if (vnodeProcessDropTbReq(pVnode, pReq, len, pRsp) < 0) goto _err;
|
if (vnodeProcessDropTbReq(pVnode, version, pReq, len, pRsp) < 0) goto _err;
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_CREATE_SMA: { // timeRangeSMA
|
case TDMT_VND_CREATE_SMA: { // timeRangeSMA
|
||||||
if (tsdbCreateTSma(pVnode->pTsdb, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) {
|
if (tsdbCreateTSma(pVnode->pTsdb, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) {
|
||||||
|
|
@ -119,7 +119,7 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
vDebug("vgId: %d process %s request success, version: %" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType), version);
|
vDebug("vgId:%d process %s request success, version: %" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType), version);
|
||||||
|
|
||||||
// commit if need
|
// commit if need
|
||||||
if (vnodeShouldCommit(pVnode)) {
|
if (vnodeShouldCommit(pVnode)) {
|
||||||
|
|
@ -134,7 +134,7 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
vDebug("vgId: %d process %s request failed since %s, version: %" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType),
|
vDebug("vgId:%d process %s request failed since %s, version: %" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType),
|
||||||
tstrerror(terrno), version);
|
tstrerror(terrno), version);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -409,9 +409,32 @@ static int vnodeProcessAlterStbReq(SVnode *pVnode, void *pReq, int32_t len, SRpc
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeProcessDropStbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
// TODO
|
SVDropStbReq req = {0};
|
||||||
// ASSERT(0);
|
int rcode = TSDB_CODE_SUCCESS;
|
||||||
|
SCoder coder = {0};
|
||||||
|
|
||||||
|
pRsp->msgType = TDMT_VND_CREATE_STB_RSP;
|
||||||
|
pRsp->pCont = NULL;
|
||||||
|
pRsp->contLen = 0;
|
||||||
|
|
||||||
|
// decode request
|
||||||
|
tCoderInit(&coder, TD_LITTLE_ENDIAN, pReq, len, TD_DECODER);
|
||||||
|
if (tDecodeSVDropStbReq(&coder, &req) < 0) {
|
||||||
|
rcode = TSDB_CODE_INVALID_MSG;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// process request
|
||||||
|
// if (metaDropSTable(pVnode->pMeta, version, &req) < 0) {
|
||||||
|
// rcode = terrno;
|
||||||
|
// goto _exit;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return rsp
|
||||||
|
_exit:
|
||||||
|
pRsp->code = rcode;
|
||||||
|
tCoderClear(&coder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -421,9 +444,15 @@ static int vnodeProcessAlterTbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcM
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeProcessDropTbReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
// TODO
|
SVDropTbReq req = {0};
|
||||||
ASSERT(0);
|
SVDropTbReq rsp = {0};
|
||||||
|
|
||||||
|
// decode req
|
||||||
|
|
||||||
|
// process req
|
||||||
|
|
||||||
|
// return rsp
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -432,7 +461,7 @@ static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
SSubmitRsp rsp = {0};
|
SSubmitRsp rsp = {0};
|
||||||
|
|
||||||
pRsp->code = 0;
|
pRsp->code = 0;
|
||||||
tsdbTriggerRSma(pVnode->pTsdb, pVnode->pMeta, pReq, STREAM_DATA_TYPE_SUBMIT_BLOCK);
|
|
||||||
// handle the request
|
// handle the request
|
||||||
if (tsdbInsertData(pVnode->pTsdb, version, pSubmitReq, &rsp) < 0) {
|
if (tsdbInsertData(pVnode->pTsdb, version, pSubmitReq, &rsp) < 0) {
|
||||||
pRsp->code = terrno;
|
pRsp->code = terrno;
|
||||||
|
|
@ -441,12 +470,28 @@ static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
|
|
||||||
// pRsp->msgType = TDMT_VND_SUBMIT_RSP;
|
// pRsp->msgType = TDMT_VND_SUBMIT_RSP;
|
||||||
// vnodeProcessSubmitReq(pVnode, ptr, pRsp);
|
// vnodeProcessSubmitReq(pVnode, ptr, pRsp);
|
||||||
// tsdbTriggerRSma(pVnode->pTsdb, pVnode->pMeta, pReq, STREAM_DATA_TYPE_SUBMIT_BLOCK);
|
|
||||||
|
|
||||||
// encode the response (TODO)
|
// encode the response (TODO)
|
||||||
pRsp->pCont = rpcMallocCont(sizeof(SSubmitRsp));
|
pRsp->pCont = rpcMallocCont(sizeof(SSubmitRsp));
|
||||||
memcpy(pRsp->pCont, &rsp, sizeof(rsp));
|
memcpy(pRsp->pCont, &rsp, sizeof(rsp));
|
||||||
pRsp->contLen = sizeof(SSubmitRsp);
|
pRsp->contLen = sizeof(SSubmitRsp);
|
||||||
|
|
||||||
|
tsdbTriggerRSma(pVnode->pTsdb, pReq, STREAM_DATA_TYPE_SUBMIT_BLOCK);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tsdbProcessSubmitReq(STsdb *pTsdb, int64_t version, void *pReq) {
|
||||||
|
if(!pReq) {
|
||||||
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSubmitReq *pSubmitReq = (SSubmitReq *)pReq;
|
||||||
|
|
||||||
|
if (tsdbInsertData(pTsdb, version, pSubmitReq, NULL) < 0) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,10 +56,9 @@ extern "C" {
|
||||||
#define EXPLAIN_ROWS_FORMAT "rows=%" PRIu64
|
#define EXPLAIN_ROWS_FORMAT "rows=%" PRIu64
|
||||||
#define EXPLAIN_COLUMNS_FORMAT "columns=%d"
|
#define EXPLAIN_COLUMNS_FORMAT "columns=%d"
|
||||||
#define EXPLAIN_WIDTH_FORMAT "width=%d"
|
#define EXPLAIN_WIDTH_FORMAT "width=%d"
|
||||||
|
#define EXPLAIN_TABLE_SCAN_FORMAT "order=[asc|%d desc|%d]"
|
||||||
#define EXPLAIN_GROUPS_FORMAT "groups=%d"
|
#define EXPLAIN_GROUPS_FORMAT "groups=%d"
|
||||||
#define EXPLAIN_WIDTH_FORMAT "width=%d"
|
#define EXPLAIN_WIDTH_FORMAT "width=%d"
|
||||||
#define EXPLAIN_LOOPS_FORMAT "loops=%d"
|
|
||||||
#define EXPLAIN_REVERSE_FORMAT "reverse=%d"
|
|
||||||
#define EXPLAIN_FUNCTIONS_FORMAT "functions=%d"
|
#define EXPLAIN_FUNCTIONS_FORMAT "functions=%d"
|
||||||
#define EXPLAIN_EXECINFO_FORMAT "cost=%" PRIu64 "..%" PRIu64 " rows=%" PRIu64
|
#define EXPLAIN_EXECINFO_FORMAT "cost=%" PRIu64 "..%" PRIu64 " rows=%" PRIu64
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,13 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "query.h"
|
|
||||||
#include "plannodes.h"
|
|
||||||
#include "commandInt.h"
|
#include "commandInt.h"
|
||||||
|
#include "plannodes.h"
|
||||||
|
#include "query.h"
|
||||||
|
|
||||||
int32_t qExplainGenerateResNode(SPhysiNode *pNode, SExplainGroup *group, SExplainResNode **pRes);
|
int32_t qExplainGenerateResNode(SPhysiNode *pNode, SExplainGroup *group, SExplainResNode **pRes);
|
||||||
int32_t qExplainAppendGroupResRows(void *pCtx, int32_t groupId, int32_t level);
|
int32_t qExplainAppendGroupResRows(void *pCtx, int32_t groupId, int32_t level);
|
||||||
|
|
||||||
|
|
||||||
void qExplainFreeResNode(SExplainResNode *resNode) {
|
void qExplainFreeResNode(SExplainResNode *resNode) {
|
||||||
if (NULL == resNode) {
|
if (NULL == resNode) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -28,10 +27,8 @@ void qExplainFreeResNode(SExplainResNode *resNode) {
|
||||||
|
|
||||||
taosMemoryFreeClear(resNode->pExecInfo);
|
taosMemoryFreeClear(resNode->pExecInfo);
|
||||||
|
|
||||||
SNode* node = NULL;
|
SNode *node = NULL;
|
||||||
FOREACH(node, resNode->pChildren) {
|
FOREACH(node, resNode->pChildren) { qExplainFreeResNode((SExplainResNode *)node); }
|
||||||
qExplainFreeResNode((SExplainResNode *)node);
|
|
||||||
}
|
|
||||||
nodesClearList(resNode->pChildren);
|
nodesClearList(resNode->pChildren);
|
||||||
|
|
||||||
taosMemoryFreeClear(resNode);
|
taosMemoryFreeClear(resNode);
|
||||||
|
|
@ -120,47 +117,47 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:{
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: {
|
||||||
STableScanPhysiNode *pTblScanNode = (STableScanPhysiNode *)pNode;
|
STableScanPhysiNode *pTblScanNode = (STableScanPhysiNode *)pNode;
|
||||||
pPhysiChildren = pTblScanNode->scan.node.pChildren;
|
pPhysiChildren = pTblScanNode->scan.node.pChildren;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:{
|
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: {
|
||||||
SSystemTableScanPhysiNode *pSTblScanNode = (SSystemTableScanPhysiNode *)pNode;
|
SSystemTableScanPhysiNode *pSTblScanNode = (SSystemTableScanPhysiNode *)pNode;
|
||||||
pPhysiChildren = pSTblScanNode->scan.node.pChildren;
|
pPhysiChildren = pSTblScanNode->scan.node.pChildren;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_PROJECT:{
|
case QUERY_NODE_PHYSICAL_PLAN_PROJECT: {
|
||||||
SProjectPhysiNode *pPrjNode = (SProjectPhysiNode *)pNode;
|
SProjectPhysiNode *pPrjNode = (SProjectPhysiNode *)pNode;
|
||||||
pPhysiChildren = pPrjNode->node.pChildren;
|
pPhysiChildren = pPrjNode->node.pChildren;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_JOIN:{
|
case QUERY_NODE_PHYSICAL_PLAN_JOIN: {
|
||||||
SJoinPhysiNode *pJoinNode = (SJoinPhysiNode *)pNode;
|
SJoinPhysiNode *pJoinNode = (SJoinPhysiNode *)pNode;
|
||||||
pPhysiChildren = pJoinNode->node.pChildren;
|
pPhysiChildren = pJoinNode->node.pChildren;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_AGG:{
|
case QUERY_NODE_PHYSICAL_PLAN_AGG: {
|
||||||
SAggPhysiNode *pAggNode = (SAggPhysiNode *)pNode;
|
SAggPhysiNode *pAggNode = (SAggPhysiNode *)pNode;
|
||||||
pPhysiChildren = pAggNode->node.pChildren;
|
pPhysiChildren = pAggNode->node.pChildren;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:{
|
case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE: {
|
||||||
SExchangePhysiNode *pExchNode = (SExchangePhysiNode *)pNode;
|
SExchangePhysiNode *pExchNode = (SExchangePhysiNode *)pNode;
|
||||||
pPhysiChildren = pExchNode->node.pChildren;
|
pPhysiChildren = pExchNode->node.pChildren;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SORT:{
|
case QUERY_NODE_PHYSICAL_PLAN_SORT: {
|
||||||
SSortPhysiNode *pSortNode = (SSortPhysiNode *)pNode;
|
SSortPhysiNode *pSortNode = (SSortPhysiNode *)pNode;
|
||||||
pPhysiChildren = pSortNode->node.pChildren;
|
pPhysiChildren = pSortNode->node.pChildren;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:{
|
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL: {
|
||||||
SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode;
|
SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode;
|
||||||
pPhysiChildren = pIntNode->window.node.pChildren;
|
pPhysiChildren = pIntNode->window.node.pChildren;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW:{
|
case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW: {
|
||||||
SSessionWinodwPhysiNode *pSessNode = (SSessionWinodwPhysiNode *)pNode;
|
SSessionWinodwPhysiNode *pSessNode = (SSessionWinodwPhysiNode *)pNode;
|
||||||
pPhysiChildren = pSessNode->window.node.pChildren;
|
pPhysiChildren = pSessNode->window.node.pChildren;
|
||||||
break;
|
break;
|
||||||
|
|
@ -178,7 +175,7 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* node = NULL;
|
SNode *node = NULL;
|
||||||
SExplainResNode *pResNode = NULL;
|
SExplainResNode *pResNode = NULL;
|
||||||
FOREACH(node, pPhysiChildren) {
|
FOREACH(node, pPhysiChildren) {
|
||||||
QRY_ERR_RET(qExplainGenerateResNode((SPhysiNode *)node, group, &pResNode));
|
QRY_ERR_RET(qExplainGenerateResNode((SPhysiNode *)node, group, &pResNode));
|
||||||
|
|
@ -293,7 +290,6 @@ int32_t qExplainBufAppendVerboseExecInfo(SArray *pExecInfo, char *tbuf, int32_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t level) {
|
int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t level) {
|
||||||
SQueryExplainRowInfo row = {0};
|
SQueryExplainRowInfo row = {0};
|
||||||
row.buf = taosMemoryMalloc(len);
|
row.buf = taosMemoryMalloc(len);
|
||||||
|
|
@ -316,8 +312,8 @@ int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t getIntervalPrecision(SIntervalPhysiNode* pIntNode) {
|
static uint8_t getIntervalPrecision(SIntervalPhysiNode *pIntNode) {
|
||||||
return ((SColumnNode*)pIntNode->window.pTspk)->node.resType.precision;
|
return ((SColumnNode *)pIntNode->window.pTspk)->node.resType.precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) {
|
int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) {
|
||||||
|
|
@ -325,7 +321,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
bool isVerboseLine = false;
|
bool isVerboseLine = false;
|
||||||
char *tbuf = ctx->tbuf;
|
char *tbuf = ctx->tbuf;
|
||||||
bool verbose = ctx->verbose;
|
bool verbose = ctx->verbose;
|
||||||
SPhysiNode* pNode = pResNode->pNode;
|
SPhysiNode *pNode = pResNode->pNode;
|
||||||
if (NULL == pNode) {
|
if (NULL == pNode) {
|
||||||
qError("pyhsical node in explain res node is NULL");
|
qError("pyhsical node in explain res node is NULL");
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
|
|
@ -350,7 +346,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, nodesGetOutputNumFromSlotList(pTagScanNode->node.pOutputDataBlockDesc->pSlots));
|
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT,
|
||||||
|
nodesGetOutputNumFromSlotList(pTagScanNode->node.pOutputDataBlockDesc->pSlots));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pTagScanNode->node.pOutputDataBlockDesc->outputRowSize);
|
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pTagScanNode->node.pOutputDataBlockDesc->outputRowSize);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
|
|
@ -367,7 +364,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:{
|
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: {
|
||||||
STableScanPhysiNode *pTblScanNode = (STableScanPhysiNode *)pNode;
|
STableScanPhysiNode *pTblScanNode = (STableScanPhysiNode *)pNode;
|
||||||
EXPLAIN_ROW_NEW(level, EXPLAIN_TBL_SCAN_FORMAT, pTblScanNode->scan.tableName.tname);
|
EXPLAIN_ROW_NEW(level, EXPLAIN_TBL_SCAN_FORMAT, pTblScanNode->scan.tableName.tname);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
||||||
|
|
@ -379,32 +376,36 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pTblScanNode->scan.node.pOutputDataBlockDesc->totalRowSize);
|
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pTblScanNode->scan.node.pOutputDataBlockDesc->totalRowSize);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
||||||
|
EXPLAIN_ROW_APPEND(EXPLAIN_TABLE_SCAN_FORMAT, pTblScanNode->scanSeq[0], pTblScanNode->scanSeq[1]);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_RIGHT_PARENTHESIS_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_RIGHT_PARENTHESIS_FORMAT);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level));
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, nodesGetOutputNumFromSlotList(pTblScanNode->scan.node.pOutputDataBlockDesc->pSlots));
|
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT,
|
||||||
|
nodesGetOutputNumFromSlotList(pTblScanNode->scan.node.pOutputDataBlockDesc->pSlots));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pTblScanNode->scan.node.pOutputDataBlockDesc->outputRowSize);
|
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pTblScanNode->scan.node.pOutputDataBlockDesc->outputRowSize);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
|
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIMERANGE_FORMAT, pTblScanNode->scanRange.skey, pTblScanNode->scanRange.ekey);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIMERANGE_FORMAT, pTblScanNode->scanRange.skey,
|
||||||
|
pTblScanNode->scanRange.ekey);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
|
|
||||||
if (pTblScanNode->scan.node.pConditions) {
|
if (pTblScanNode->scan.node.pConditions) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
||||||
QRY_ERR_RET(nodesNodeToSQL(pTblScanNode->scan.node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
QRY_ERR_RET(nodesNodeToSQL(pTblScanNode->scan.node.pConditions, tbuf + VARSTR_HEADER_SIZE,
|
||||||
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:{
|
case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: {
|
||||||
SSystemTableScanPhysiNode *pSTblScanNode = (SSystemTableScanPhysiNode *)pNode;
|
SSystemTableScanPhysiNode *pSTblScanNode = (SSystemTableScanPhysiNode *)pNode;
|
||||||
EXPLAIN_ROW_NEW(level, EXPLAIN_SYSTBL_SCAN_FORMAT, pSTblScanNode->scan.tableName.tname);
|
EXPLAIN_ROW_NEW(level, EXPLAIN_SYSTBL_SCAN_FORMAT, pSTblScanNode->scan.tableName.tname);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
||||||
|
|
@ -422,7 +423,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, nodesGetOutputNumFromSlotList(pSTblScanNode->scan.node.pOutputDataBlockDesc->pSlots));
|
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT,
|
||||||
|
nodesGetOutputNumFromSlotList(pSTblScanNode->scan.node.pOutputDataBlockDesc->pSlots));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pSTblScanNode->scan.node.pOutputDataBlockDesc->outputRowSize);
|
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pSTblScanNode->scan.node.pOutputDataBlockDesc->outputRowSize);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
|
|
@ -430,15 +432,15 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (pSTblScanNode->scan.node.pConditions) {
|
if (pSTblScanNode->scan.node.pConditions) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
||||||
QRY_ERR_RET(nodesNodeToSQL(pSTblScanNode->scan.node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
QRY_ERR_RET(nodesNodeToSQL(pSTblScanNode->scan.node.pConditions, tbuf + VARSTR_HEADER_SIZE,
|
||||||
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_PROJECT:{
|
case QUERY_NODE_PHYSICAL_PLAN_PROJECT: {
|
||||||
SProjectPhysiNode *pPrjNode = (SProjectPhysiNode *)pNode;
|
SProjectPhysiNode *pPrjNode = (SProjectPhysiNode *)pNode;
|
||||||
EXPLAIN_ROW_NEW(level, EXPLAIN_PROJECTION_FORMAT);
|
EXPLAIN_ROW_NEW(level, EXPLAIN_PROJECTION_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
||||||
|
|
@ -455,7 +457,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, nodesGetOutputNumFromSlotList(pPrjNode->node.pOutputDataBlockDesc->pSlots));
|
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT,
|
||||||
|
nodesGetOutputNumFromSlotList(pPrjNode->node.pOutputDataBlockDesc->pSlots));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pPrjNode->node.pOutputDataBlockDesc->outputRowSize);
|
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pPrjNode->node.pOutputDataBlockDesc->outputRowSize);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
|
|
@ -463,14 +466,15 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (pPrjNode->node.pConditions) {
|
if (pPrjNode->node.pConditions) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
||||||
QRY_ERR_RET(nodesNodeToSQL(pPrjNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
QRY_ERR_RET(nodesNodeToSQL(pPrjNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE,
|
||||||
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_JOIN:{
|
case QUERY_NODE_PHYSICAL_PLAN_JOIN: {
|
||||||
SJoinPhysiNode *pJoinNode = (SJoinPhysiNode *)pNode;
|
SJoinPhysiNode *pJoinNode = (SJoinPhysiNode *)pNode;
|
||||||
EXPLAIN_ROW_NEW(level, EXPLAIN_JOIN_FORMAT, EXPLAIN_JOIN_STRING(pJoinNode->joinType));
|
EXPLAIN_ROW_NEW(level, EXPLAIN_JOIN_FORMAT, EXPLAIN_JOIN_STRING(pJoinNode->joinType));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
||||||
|
|
@ -487,7 +491,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, nodesGetOutputNumFromSlotList(pJoinNode->node.pOutputDataBlockDesc->pSlots));
|
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT,
|
||||||
|
nodesGetOutputNumFromSlotList(pJoinNode->node.pOutputDataBlockDesc->pSlots));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pJoinNode->node.pOutputDataBlockDesc->outputRowSize);
|
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pJoinNode->node.pOutputDataBlockDesc->outputRowSize);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
|
|
@ -495,19 +500,21 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (pJoinNode->node.pConditions) {
|
if (pJoinNode->node.pConditions) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
||||||
QRY_ERR_RET(nodesNodeToSQL(pJoinNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
QRY_ERR_RET(nodesNodeToSQL(pJoinNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE,
|
||||||
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_ON_CONDITIONS_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_ON_CONDITIONS_FORMAT);
|
||||||
QRY_ERR_RET(nodesNodeToSQL(pJoinNode->pOnConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
QRY_ERR_RET(
|
||||||
|
nodesNodeToSQL(pJoinNode->pOnConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_AGG:{
|
case QUERY_NODE_PHYSICAL_PLAN_AGG: {
|
||||||
SAggPhysiNode *pAggNode = (SAggPhysiNode *)pNode;
|
SAggPhysiNode *pAggNode = (SAggPhysiNode *)pNode;
|
||||||
EXPLAIN_ROW_NEW(level, EXPLAIN_AGG_FORMAT);
|
EXPLAIN_ROW_NEW(level, EXPLAIN_AGG_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
||||||
|
|
@ -528,7 +535,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, nodesGetOutputNumFromSlotList(pAggNode->node.pOutputDataBlockDesc->pSlots));
|
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT,
|
||||||
|
nodesGetOutputNumFromSlotList(pAggNode->node.pOutputDataBlockDesc->pSlots));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pAggNode->node.pOutputDataBlockDesc->outputRowSize);
|
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pAggNode->node.pOutputDataBlockDesc->outputRowSize);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
|
|
@ -536,14 +544,15 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (pAggNode->node.pConditions) {
|
if (pAggNode->node.pConditions) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
||||||
QRY_ERR_RET(nodesNodeToSQL(pAggNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
QRY_ERR_RET(nodesNodeToSQL(pAggNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE,
|
||||||
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:{
|
case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE: {
|
||||||
SExchangePhysiNode *pExchNode = (SExchangePhysiNode *)pNode;
|
SExchangePhysiNode *pExchNode = (SExchangePhysiNode *)pNode;
|
||||||
SExplainGroup *group = taosHashGet(ctx->groupHash, &pExchNode->srcGroupId, sizeof(pExchNode->srcGroupId));
|
SExplainGroup *group = taosHashGet(ctx->groupHash, &pExchNode->srcGroupId, sizeof(pExchNode->srcGroupId));
|
||||||
if (NULL == group) {
|
if (NULL == group) {
|
||||||
|
|
@ -564,7 +573,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, nodesGetOutputNumFromSlotList(pExchNode->node.pOutputDataBlockDesc->pSlots));
|
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT,
|
||||||
|
nodesGetOutputNumFromSlotList(pExchNode->node.pOutputDataBlockDesc->pSlots));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pExchNode->node.pOutputDataBlockDesc->outputRowSize);
|
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pExchNode->node.pOutputDataBlockDesc->outputRowSize);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
|
|
@ -572,7 +582,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (pExchNode->node.pConditions) {
|
if (pExchNode->node.pConditions) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
||||||
QRY_ERR_RET(nodesNodeToSQL(pExchNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
QRY_ERR_RET(nodesNodeToSQL(pExchNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE,
|
||||||
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
|
|
@ -581,7 +592,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
QRY_ERR_RET(qExplainAppendGroupResRows(ctx, pExchNode->srcGroupId, level + 1));
|
QRY_ERR_RET(qExplainAppendGroupResRows(ctx, pExchNode->srcGroupId, level + 1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SORT:{
|
case QUERY_NODE_PHYSICAL_PLAN_SORT: {
|
||||||
SSortPhysiNode *pSortNode = (SSortPhysiNode *)pNode;
|
SSortPhysiNode *pSortNode = (SSortPhysiNode *)pNode;
|
||||||
EXPLAIN_ROW_NEW(level, EXPLAIN_SORT_FORMAT);
|
EXPLAIN_ROW_NEW(level, EXPLAIN_SORT_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
||||||
|
|
@ -598,7 +609,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, nodesGetOutputNumFromSlotList(pSortNode->node.pOutputDataBlockDesc->pSlots));
|
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT,
|
||||||
|
nodesGetOutputNumFromSlotList(pSortNode->node.pOutputDataBlockDesc->pSlots));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pSortNode->node.pOutputDataBlockDesc->outputRowSize);
|
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pSortNode->node.pOutputDataBlockDesc->outputRowSize);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
|
|
@ -606,14 +618,15 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (pSortNode->node.pConditions) {
|
if (pSortNode->node.pConditions) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
||||||
QRY_ERR_RET(nodesNodeToSQL(pSortNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
QRY_ERR_RET(nodesNodeToSQL(pSortNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE,
|
||||||
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:{
|
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL: {
|
||||||
SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode;
|
SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode;
|
||||||
EXPLAIN_ROW_NEW(level, EXPLAIN_INTERVAL_FORMAT, nodesGetNameFromColumnNode(pIntNode->window.pTspk));
|
EXPLAIN_ROW_NEW(level, EXPLAIN_INTERVAL_FORMAT, nodesGetNameFromColumnNode(pIntNode->window.pTspk));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
||||||
|
|
@ -629,34 +642,32 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, nodesGetOutputNumFromSlotList(pIntNode->window.node.pOutputDataBlockDesc->pSlots));
|
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT,
|
||||||
|
nodesGetOutputNumFromSlotList(pIntNode->window.node.pOutputDataBlockDesc->pSlots));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pIntNode->window.node.pOutputDataBlockDesc->outputRowSize);
|
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pIntNode->window.node.pOutputDataBlockDesc->outputRowSize);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
uint8_t precision = getIntervalPrecision(pIntNode);
|
uint8_t precision = getIntervalPrecision(pIntNode);
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT, INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, precision),
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIME_WINDOWS_FORMAT,
|
||||||
|
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, precision),
|
||||||
pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(precision),
|
pIntNode->intervalUnit, pIntNode->offset, getPrecisionUnit(precision),
|
||||||
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, precision), pIntNode->slidingUnit);
|
INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, precision),
|
||||||
|
pIntNode->slidingUnit);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
|
|
||||||
if (pIntNode->pFill) {
|
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILL_FORMAT, getFillModeString(pIntNode->pFill->mode));
|
|
||||||
EXPLAIN_ROW_END();
|
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pIntNode->window.node.pConditions) {
|
if (pIntNode->window.node.pConditions) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
||||||
QRY_ERR_RET(nodesNodeToSQL(pIntNode->window.node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
QRY_ERR_RET(nodesNodeToSQL(pIntNode->window.node.pConditions, tbuf + VARSTR_HEADER_SIZE,
|
||||||
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW:{
|
case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW: {
|
||||||
SSessionWinodwPhysiNode *pSessNode = (SSessionWinodwPhysiNode *)pNode;
|
SSessionWinodwPhysiNode *pSessNode = (SSessionWinodwPhysiNode *)pNode;
|
||||||
EXPLAIN_ROW_NEW(level, EXPLAIN_SESSION_FORMAT);
|
EXPLAIN_ROW_NEW(level, EXPLAIN_SESSION_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
||||||
|
|
@ -671,10 +682,10 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level));
|
||||||
|
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, nodesGetOutputNumFromSlotList(pSessNode->window.node.pOutputDataBlockDesc->pSlots));
|
EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT,
|
||||||
|
nodesGetOutputNumFromSlotList(pSessNode->window.node.pOutputDataBlockDesc->pSlots));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT);
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pSessNode->window.node.pOutputDataBlockDesc->outputRowSize);
|
EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pSessNode->window.node.pOutputDataBlockDesc->outputRowSize);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
|
|
@ -686,7 +697,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
|
|
||||||
if (pSessNode->window.node.pConditions) {
|
if (pSessNode->window.node.pConditions) {
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT);
|
||||||
QRY_ERR_RET(nodesNodeToSQL(pSessNode->window.node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
QRY_ERR_RET(nodesNodeToSQL(pSessNode->window.node.pConditions, tbuf + VARSTR_HEADER_SIZE,
|
||||||
|
TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen));
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
}
|
}
|
||||||
|
|
@ -701,7 +713,6 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t qExplainResNodeToRows(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) {
|
int32_t qExplainResNodeToRows(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) {
|
||||||
if (NULL == pResNode) {
|
if (NULL == pResNode) {
|
||||||
qError("explain res node is NULL");
|
qError("explain res node is NULL");
|
||||||
|
|
@ -711,10 +722,8 @@ int32_t qExplainResNodeToRows(SExplainResNode *pResNode, SExplainCtx *ctx, int32
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
QRY_ERR_RET(qExplainResNodeToRowsImpl(pResNode, ctx, level));
|
QRY_ERR_RET(qExplainResNodeToRowsImpl(pResNode, ctx, level));
|
||||||
|
|
||||||
SNode* pNode = NULL;
|
SNode *pNode = NULL;
|
||||||
FOREACH(pNode, pResNode->pChildren) {
|
FOREACH(pNode, pResNode->pChildren) { QRY_ERR_RET(qExplainResNodeToRows((SExplainResNode *)pNode, ctx, level + 1)); }
|
||||||
QRY_ERR_RET(qExplainResNodeToRows((SExplainResNode *)pNode, ctx, level + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -733,7 +742,8 @@ int32_t qExplainAppendGroupResRows(void *pCtx, int32_t groupId, int32_t level) {
|
||||||
QRY_ERR_RET(qExplainGenerateResNode(group->plan->pNode, group, &node));
|
QRY_ERR_RET(qExplainGenerateResNode(group->plan->pNode, group, &node));
|
||||||
|
|
||||||
if ((EXPLAIN_MODE_ANALYZE == ctx->mode) && (group->physiPlanNum != group->physiPlanExecNum)) {
|
if ((EXPLAIN_MODE_ANALYZE == ctx->mode) && (group->physiPlanNum != group->physiPlanExecNum)) {
|
||||||
qError("physiPlanNum %d mismatch with physiExecNum %d in group %d", group->physiPlanNum, group->physiPlanExecNum, groupId);
|
qError("physiPlanNum %d mismatch with physiExecNum %d in group %d", group->physiPlanNum, group->physiPlanExecNum,
|
||||||
|
groupId);
|
||||||
QRY_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
QRY_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -746,7 +756,6 @@ _return:
|
||||||
QRY_RET(code);
|
QRY_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
|
int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
|
||||||
SExplainCtx *pCtx = (SExplainCtx *)ctx;
|
SExplainCtx *pCtx = (SExplainCtx *)ctx;
|
||||||
int32_t rowNum = taosArrayGetSize(pCtx->rows);
|
int32_t rowNum = taosArrayGetSize(pCtx->rows);
|
||||||
|
|
@ -756,7 +765,8 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t colNum = 1;
|
int32_t colNum = 1;
|
||||||
int32_t rspSize = sizeof(SRetrieveTableRsp) + sizeof(int32_t) + sizeof(uint64_t) + sizeof(int32_t) * colNum + sizeof(int32_t) * rowNum + pCtx->dataSize;
|
int32_t rspSize = sizeof(SRetrieveTableRsp) + sizeof(int32_t) + sizeof(uint64_t) + sizeof(int32_t) * colNum +
|
||||||
|
sizeof(int32_t) * rowNum + pCtx->dataSize;
|
||||||
SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)taosMemoryCalloc(1, rspSize);
|
SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)taosMemoryCalloc(1, rspSize);
|
||||||
if (NULL == rsp) {
|
if (NULL == rsp) {
|
||||||
qError("malloc SRetrieveTableRsp failed, size:%d", rspSize);
|
qError("malloc SRetrieveTableRsp failed, size:%d", rspSize);
|
||||||
|
|
@ -767,13 +777,14 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
|
||||||
rsp->numOfRows = htonl(rowNum);
|
rsp->numOfRows = htonl(rowNum);
|
||||||
|
|
||||||
// payload length
|
// payload length
|
||||||
*(int32_t *)rsp->data = sizeof(int32_t) + sizeof(uint64_t) + sizeof(int32_t) * colNum + sizeof(int32_t) * rowNum + pCtx->dataSize;
|
*(int32_t *)rsp->data =
|
||||||
|
sizeof(int32_t) + sizeof(uint64_t) + sizeof(int32_t) * colNum + sizeof(int32_t) * rowNum + pCtx->dataSize;
|
||||||
|
|
||||||
// group id
|
// group id
|
||||||
*(uint64_t*)(rsp->data + sizeof(int32_t)) = 0;
|
*(uint64_t *)(rsp->data + sizeof(int32_t)) = 0;
|
||||||
|
|
||||||
// column length
|
// column length
|
||||||
int32_t* colLength = (int32_t *)(rsp->data + sizeof(int32_t) + sizeof(uint64_t));
|
int32_t *colLength = (int32_t *)(rsp->data + sizeof(int32_t) + sizeof(uint64_t));
|
||||||
|
|
||||||
// varchar column offset segment
|
// varchar column offset segment
|
||||||
int32_t *offset = (int32_t *)((char *)colLength + sizeof(int32_t));
|
int32_t *offset = (int32_t *)((char *)colLength + sizeof(int32_t));
|
||||||
|
|
@ -781,7 +792,7 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
|
||||||
// varchar data real payload
|
// varchar data real payload
|
||||||
char *data = (char *)(offset + rowNum);
|
char *data = (char *)(offset + rowNum);
|
||||||
|
|
||||||
char* start = data;
|
char *start = data;
|
||||||
for (int32_t i = 0; i < rowNum; ++i) {
|
for (int32_t i = 0; i < rowNum; ++i) {
|
||||||
SQueryExplainRowInfo *row = taosArrayGet(pCtx->rows, i);
|
SQueryExplainRowInfo *row = taosArrayGet(pCtx->rows, i);
|
||||||
offset[i] = data - start;
|
offset[i] = data - start;
|
||||||
|
|
@ -816,13 +827,15 @@ int32_t qExplainPrepareCtx(SQueryPlan *pDag, SExplainCtx **pCtx) {
|
||||||
QRY_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
QRY_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHashObj *groupHash = taosHashInit(EXPLAIN_MAX_GROUP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
SHashObj *groupHash =
|
||||||
|
taosHashInit(EXPLAIN_MAX_GROUP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||||
if (NULL == groupHash) {
|
if (NULL == groupHash) {
|
||||||
qError("groupHash %d failed", EXPLAIN_MAX_GROUP_NUM);
|
qError("groupHash %d failed", EXPLAIN_MAX_GROUP_NUM);
|
||||||
QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRY_ERR_JRET(qExplainInitCtx(&ctx, groupHash, pDag->explainInfo.verbose, pDag->explainInfo.ratio, pDag->explainInfo.mode));
|
QRY_ERR_JRET(
|
||||||
|
qExplainInitCtx(&ctx, groupHash, pDag->explainInfo.verbose, pDag->explainInfo.ratio, pDag->explainInfo.mode));
|
||||||
|
|
||||||
for (int32_t i = 0; i < levelNum; ++i) {
|
for (int32_t i = 0; i < levelNum; ++i) {
|
||||||
plans = (SNodeListNode *)nodesListGetNode(pDag->pSubplans, i);
|
plans = (SNodeListNode *)nodesListGetNode(pDag->pSubplans, i);
|
||||||
|
|
@ -936,7 +949,8 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, i
|
||||||
|
|
||||||
group->physiPlanExecNum = pRspMsg->numOfPlans;
|
group->physiPlanExecNum = pRspMsg->numOfPlans;
|
||||||
} else if (taosArrayGetSize(group->nodeExecInfo) >= group->nodeNum) {
|
} else if (taosArrayGetSize(group->nodeExecInfo) >= group->nodeNum) {
|
||||||
qError("group execInfo already full, size:%d, nodeNum:%d", (int32_t)taosArrayGetSize(group->nodeExecInfo), group->nodeNum);
|
qError("group execInfo already full, size:%d, nodeNum:%d", (int32_t)taosArrayGetSize(group->nodeExecInfo),
|
||||||
|
group->nodeNum);
|
||||||
taosMemoryFreeClear(pRspMsg->subplanInfo);
|
taosMemoryFreeClear(pRspMsg->subplanInfo);
|
||||||
taosWUnLockLatch(&group->lock);
|
taosWUnLockLatch(&group->lock);
|
||||||
|
|
||||||
|
|
@ -944,7 +958,8 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, i
|
||||||
}
|
}
|
||||||
|
|
||||||
if (group->physiPlanExecNum != pRspMsg->numOfPlans) {
|
if (group->physiPlanExecNum != pRspMsg->numOfPlans) {
|
||||||
qError("physiPlanExecNum %d mismatch with others %d in group %d", pRspMsg->numOfPlans, group->physiPlanExecNum, groupId);
|
qError("physiPlanExecNum %d mismatch with others %d in group %d", pRspMsg->numOfPlans, group->physiPlanExecNum,
|
||||||
|
groupId);
|
||||||
taosMemoryFreeClear(pRspMsg->subplanInfo);
|
taosMemoryFreeClear(pRspMsg->subplanInfo);
|
||||||
taosWUnLockLatch(&group->lock);
|
taosWUnLockLatch(&group->lock);
|
||||||
|
|
||||||
|
|
@ -968,7 +983,6 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, i
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp) {
|
int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SExplainCtx *pCtx = NULL;
|
SExplainCtx *pCtx = NULL;
|
||||||
|
|
@ -1005,6 +1019,3 @@ int32_t qExecExplainEnd(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp) {
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ add_library(executor STATIC ${EXECUTOR_SRC})
|
||||||
# )
|
# )
|
||||||
|
|
||||||
target_link_libraries(executor
|
target_link_libraries(executor
|
||||||
PRIVATE os util common function parser planner qcom vnode scalar nodes
|
PRIVATE os util common function parser planner qcom vnode scalar nodes index
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ typedef struct SResKeyPos {
|
||||||
} SResKeyPos;
|
} SResKeyPos;
|
||||||
|
|
||||||
typedef struct SResultRowInfo {
|
typedef struct SResultRowInfo {
|
||||||
SResultRowPosition *pPosition;
|
SResultRowPosition *pPosition; // todo remove this
|
||||||
int32_t size; // number of result set
|
int32_t size; // number of result set
|
||||||
int32_t capacity; // max capacity
|
int32_t capacity; // max capacity
|
||||||
SResultRowPosition cur;
|
SResultRowPosition cur;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,12 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char* pData;
|
||||||
|
bool isNull;
|
||||||
|
int16_t type;
|
||||||
|
int32_t bytes;
|
||||||
|
} SGroupKeys, SStateKeys;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ extern "C" {
|
||||||
#include "tpagedbuf.h"
|
#include "tpagedbuf.h"
|
||||||
|
|
||||||
#include "vnode.h"
|
#include "vnode.h"
|
||||||
|
#include "executorInt.h"
|
||||||
|
|
||||||
typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order);
|
typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order);
|
||||||
|
|
||||||
|
|
@ -118,6 +119,17 @@ typedef struct SLimit {
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
} SLimit;
|
} SLimit;
|
||||||
|
|
||||||
|
typedef struct SFileBlockLoadRecorder {
|
||||||
|
uint64_t totalRows;
|
||||||
|
uint64_t totalCheckedRows;
|
||||||
|
uint32_t totalBlocks;
|
||||||
|
uint32_t loadBlocks;
|
||||||
|
uint32_t loadBlockStatis;
|
||||||
|
uint32_t skipBlocks;
|
||||||
|
uint32_t filterOutBlocks;
|
||||||
|
uint64_t elapsedTime;
|
||||||
|
} SFileBlockLoadRecorder;
|
||||||
|
|
||||||
typedef struct STaskCostInfo {
|
typedef struct STaskCostInfo {
|
||||||
int64_t created;
|
int64_t created;
|
||||||
int64_t start;
|
int64_t start;
|
||||||
|
|
@ -131,14 +143,10 @@ typedef struct STaskCostInfo {
|
||||||
uint64_t loadDataInCacheSize;
|
uint64_t loadDataInCacheSize;
|
||||||
|
|
||||||
uint64_t loadDataTime;
|
uint64_t loadDataTime;
|
||||||
uint64_t totalRows;
|
|
||||||
uint64_t totalCheckedRows;
|
SFileBlockLoadRecorder* pRecoder;
|
||||||
uint32_t totalBlocks;
|
|
||||||
uint32_t loadBlocks;
|
|
||||||
uint32_t loadBlockStatis;
|
|
||||||
uint32_t skipBlocks;
|
|
||||||
uint32_t filterOutBlocks;
|
|
||||||
uint64_t elapsedTime;
|
uint64_t elapsedTime;
|
||||||
|
|
||||||
uint64_t firstStageMergeTime;
|
uint64_t firstStageMergeTime;
|
||||||
uint64_t winInfoSize;
|
uint64_t winInfoSize;
|
||||||
uint64_t tableInfoSize;
|
uint64_t tableInfoSize;
|
||||||
|
|
@ -196,7 +204,7 @@ typedef bool (*__optr_decode_fn_t)(struct SOperatorInfo* pOperator, struct SAggS
|
||||||
struct SOptrBasicInfo* pInfo, char* result, int32_t length);
|
struct SOptrBasicInfo* pInfo, char* result, int32_t length);
|
||||||
|
|
||||||
typedef int32_t (*__optr_open_fn_t)(struct SOperatorInfo* pOptr);
|
typedef int32_t (*__optr_open_fn_t)(struct SOperatorInfo* pOptr);
|
||||||
typedef SSDataBlock* (*__optr_fn_t)(struct SOperatorInfo* pOptr, bool* newgroup);
|
typedef SSDataBlock* (*__optr_fn_t)(struct SOperatorInfo* pOptr);
|
||||||
typedef void (*__optr_close_fn_t)(void* param, int32_t num);
|
typedef void (*__optr_close_fn_t)(void* param, int32_t num);
|
||||||
typedef int32_t (*__optr_get_explain_fn_t)(struct SOperatorInfo* pOptr, void** pOptrExplain);
|
typedef int32_t (*__optr_get_explain_fn_t)(struct SOperatorInfo* pOptr, void** pOptrExplain);
|
||||||
|
|
||||||
|
|
@ -267,7 +275,7 @@ typedef struct SOperatorFpSet {
|
||||||
|
|
||||||
typedef struct SOperatorInfo {
|
typedef struct SOperatorInfo {
|
||||||
uint8_t operatorType;
|
uint8_t operatorType;
|
||||||
bool blockingOptr; // block operator or not
|
bool blocking; // block operator or not
|
||||||
uint8_t status; // denote if current operator is completed
|
uint8_t status; // denote if current operator is completed
|
||||||
int32_t numOfOutput; // number of columns of the current operator results
|
int32_t numOfOutput; // number of columns of the current operator results
|
||||||
char* name; // name, used to show the query execution plan
|
char* name; // name, used to show the query execution plan
|
||||||
|
|
@ -332,17 +340,14 @@ typedef struct SScanInfo {
|
||||||
|
|
||||||
typedef struct STableScanInfo {
|
typedef struct STableScanInfo {
|
||||||
void* dataReader;
|
void* dataReader;
|
||||||
|
SFileBlockLoadRecorder readRecorder;
|
||||||
int32_t numOfBlocks; // extract basic running information.
|
|
||||||
int32_t numOfSkipped;
|
|
||||||
int32_t numOfBlockStatis;
|
|
||||||
int64_t numOfRows;
|
int64_t numOfRows;
|
||||||
int64_t elapsedTime;
|
int64_t elapsedTime;
|
||||||
int32_t prevGroupId; // previous table group id
|
// int32_t prevGroupId; // previous table group id
|
||||||
SScanInfo scanInfo;
|
SScanInfo scanInfo;
|
||||||
int32_t current;
|
int32_t scanTimes;
|
||||||
SNode* pFilterNode; // filter operator info
|
SNode* pFilterNode; // filter info, which is push down by optimizer
|
||||||
SqlFunctionCtx* pCtx; // next operator query context
|
SqlFunctionCtx* pCtx; // which belongs to the direct upstream operator operator query context
|
||||||
SResultRowInfo* pResultRowInfo;
|
SResultRowInfo* pResultRowInfo;
|
||||||
int32_t* rowCellInfoOffset;
|
int32_t* rowCellInfoOffset;
|
||||||
SExprInfo* pExpr;
|
SExprInfo* pExpr;
|
||||||
|
|
@ -375,6 +380,7 @@ typedef struct SStreamBlockScanInfo {
|
||||||
uint64_t numOfExec; // execution times
|
uint64_t numOfExec; // execution times
|
||||||
void* readerHandle; // stream block reader handle
|
void* readerHandle; // stream block reader handle
|
||||||
SArray* pColMatchInfo; //
|
SArray* pColMatchInfo; //
|
||||||
|
SNode* pCondition;
|
||||||
} SStreamBlockScanInfo;
|
} SStreamBlockScanInfo;
|
||||||
|
|
||||||
typedef struct SSysTableScanInfo {
|
typedef struct SSysTableScanInfo {
|
||||||
|
|
@ -395,7 +401,6 @@ typedef struct SSysTableScanInfo {
|
||||||
SArray* scanCols; // SArray<int16_t> scan column id list
|
SArray* scanCols; // SArray<int16_t> scan column id list
|
||||||
SName name;
|
SName name;
|
||||||
SSDataBlock* pRes;
|
SSDataBlock* pRes;
|
||||||
int32_t capacity;
|
|
||||||
int64_t numOfBlocks; // extract basic running information.
|
int64_t numOfBlocks; // extract basic running information.
|
||||||
SLoadRemoteDataInfo loadInfo;
|
SLoadRemoteDataInfo loadInfo;
|
||||||
} SSysTableScanInfo;
|
} SSysTableScanInfo;
|
||||||
|
|
@ -423,7 +428,7 @@ typedef struct STimeWindowSupp {
|
||||||
SColumnInfoData timeWindowData; // query time window info for scalar function execution.
|
SColumnInfoData timeWindowData; // query time window info for scalar function execution.
|
||||||
} STimeWindowAggSupp;
|
} STimeWindowAggSupp;
|
||||||
|
|
||||||
typedef struct STableIntervalOperatorInfo {
|
typedef struct SIntervalAggOperatorInfo {
|
||||||
SOptrBasicInfo binfo; // basic info
|
SOptrBasicInfo binfo; // basic info
|
||||||
SGroupResInfo groupResInfo; // multiple results build supporter
|
SGroupResInfo groupResInfo; // multiple results build supporter
|
||||||
SInterval interval; // interval info
|
SInterval interval; // interval info
|
||||||
|
|
@ -438,7 +443,7 @@ typedef struct STableIntervalOperatorInfo {
|
||||||
SArray* pUpdatedWindow; // updated time window due to the input data block from the downstream operator.
|
SArray* pUpdatedWindow; // updated time window due to the input data block from the downstream operator.
|
||||||
STimeWindowAggSupp twAggSup;
|
STimeWindowAggSupp twAggSup;
|
||||||
struct SFillInfo* pFillInfo; // fill info
|
struct SFillInfo* pFillInfo; // fill info
|
||||||
} STableIntervalOperatorInfo;
|
} SIntervalAggOperatorInfo;
|
||||||
|
|
||||||
typedef struct SAggOperatorInfo {
|
typedef struct SAggOperatorInfo {
|
||||||
SOptrBasicInfo binfo;
|
SOptrBasicInfo binfo;
|
||||||
|
|
@ -477,16 +482,8 @@ typedef struct SFillOperatorInfo {
|
||||||
void** p;
|
void** p;
|
||||||
SSDataBlock* existNewGroupBlock;
|
SSDataBlock* existNewGroupBlock;
|
||||||
bool multigroupResult;
|
bool multigroupResult;
|
||||||
SInterval intervalInfo;
|
|
||||||
} SFillOperatorInfo;
|
} SFillOperatorInfo;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char* pData;
|
|
||||||
bool isNull;
|
|
||||||
int16_t type;
|
|
||||||
int32_t bytes;
|
|
||||||
} SGroupKeys, SStateKeys;
|
|
||||||
|
|
||||||
typedef struct SGroupbyOperatorInfo {
|
typedef struct SGroupbyOperatorInfo {
|
||||||
SOptrBasicInfo binfo;
|
SOptrBasicInfo binfo;
|
||||||
SArray* pGroupCols; // group by columns, SArray<SColumn>
|
SArray* pGroupCols; // group by columns, SArray<SColumn>
|
||||||
|
|
@ -539,6 +536,7 @@ typedef struct SSessionAggOperatorInfo {
|
||||||
SWindowRowsSup winSup;
|
SWindowRowsSup winSup;
|
||||||
bool reptScan; // next round scan
|
bool reptScan; // next round scan
|
||||||
int64_t gap; // session window gap
|
int64_t gap; // session window gap
|
||||||
|
int32_t tsSlotId; // primary timestamp slot id
|
||||||
STimeWindowAggSupp twAggSup;
|
STimeWindowAggSupp twAggSup;
|
||||||
} SSessionAggOperatorInfo;
|
} SSessionAggOperatorInfo;
|
||||||
|
|
||||||
|
|
@ -556,6 +554,7 @@ typedef struct SStateWindowOperatorInfo {
|
||||||
int32_t colIndex; // start row index
|
int32_t colIndex; // start row index
|
||||||
bool hasKey;
|
bool hasKey;
|
||||||
SStateKeys stateKey;
|
SStateKeys stateKey;
|
||||||
|
int32_t tsSlotId; // primary timestamp column slot id
|
||||||
STimeWindowAggSupp twAggSup;
|
STimeWindowAggSupp twAggSup;
|
||||||
// bool reptScan;
|
// bool reptScan;
|
||||||
} SStateWindowOperatorInfo;
|
} SStateWindowOperatorInfo;
|
||||||
|
|
@ -612,6 +611,9 @@ typedef struct SJoinOperatorInfo {
|
||||||
SNode *pOnCondition;
|
SNode *pOnCondition;
|
||||||
} SJoinOperatorInfo;
|
} SJoinOperatorInfo;
|
||||||
|
|
||||||
|
#define OPTR_IS_OPENED(_optr) (((_optr)->status & OP_OPENED) == OP_OPENED)
|
||||||
|
#define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED)
|
||||||
|
|
||||||
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t streamFn,
|
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t streamFn,
|
||||||
__optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode,
|
__optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode,
|
||||||
__optr_decode_fn_t decode, __optr_get_explain_fn_t explain);
|
__optr_decode_fn_t decode, __optr_get_explain_fn_t explain);
|
||||||
|
|
@ -622,8 +624,8 @@ int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t
|
||||||
int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols,
|
int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResultBlock, size_t keyBufSize, const char* pkey);
|
SSDataBlock* pResultBlock, size_t keyBufSize, const char* pkey);
|
||||||
void initResultSizeInfo(SOperatorInfo* pOperator, int32_t numOfRows);
|
void initResultSizeInfo(SOperatorInfo* pOperator, int32_t numOfRows);
|
||||||
void doBuildResultDatablock(SSDataBlock* pBlock, SGroupResInfo* pGroupResInfo, SExprInfo* pExprInfo,
|
void doBuildResultDatablock(SOptrBasicInfo *pbInfo, SGroupResInfo* pGroupResInfo, SExprInfo* pExprInfo, SDiskbasedBuf* pBuf);
|
||||||
SDiskbasedBuf* pBuf, int32_t* rowCellOffset, SqlFunctionCtx* pCtx);
|
|
||||||
void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbasedBuf* pBuf,
|
void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbasedBuf* pBuf,
|
||||||
SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset);
|
SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset);
|
||||||
void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset,
|
void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset,
|
||||||
|
|
@ -641,6 +643,16 @@ void doSetOperatorCompleted(SOperatorInfo* pOperator);
|
||||||
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock);
|
void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock);
|
||||||
SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset);
|
SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset);
|
||||||
void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray* pCols);
|
void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray* pCols);
|
||||||
|
void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow);
|
||||||
|
void cleanupAggSup(SAggSupporter* pAggSup);
|
||||||
|
void destroyBasicOperatorInfo(void* param, int32_t numOfOutput);
|
||||||
|
|
||||||
|
void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput,
|
||||||
|
int32_t* rowCellInfoOffset);
|
||||||
|
|
||||||
|
SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo,
|
||||||
|
char* pData, int16_t bytes, bool masterscan, uint64_t groupId,
|
||||||
|
SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup);
|
||||||
|
|
||||||
SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
|
|
@ -662,27 +674,30 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
||||||
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
||||||
STimeWindowAggSupp *pTwAggSupp, const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo);
|
STimeWindowAggSupp *pTwAggSupp, const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
|
|
||||||
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
||||||
STimeWindowAggSupp *pTwAggSupp, const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo);
|
STimeWindowAggSupp *pTwAggSupp, const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResBlock, int64_t gap, STimeWindowAggSupp *pTwAggSupp, SExecTaskInfo* pTaskInfo);
|
SSDataBlock* pResBlock, int64_t gap, int32_t tsSlotId, STimeWindowAggSupp* pTwAggSupp,
|
||||||
|
SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResultBlock, SArray* pGroupColList, SNode* pCondition,
|
SSDataBlock* pResultBlock, SArray* pGroupColList, SNode* pCondition,
|
||||||
SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo,
|
SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo,
|
||||||
const STableGroupInfo* pTableGroupInfo);
|
const STableGroupInfo* pTableGroupInfo);
|
||||||
SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock* pResBlock, SArray* pColList,
|
SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock* pResBlock, SArray* pColList,
|
||||||
SArray* pTableIdList, SExecTaskInfo* pTaskInfo);
|
SArray* pTableIdList, SExecTaskInfo* pTaskInfo, SNode* pConditions);
|
||||||
|
|
||||||
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols,
|
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols,
|
||||||
SInterval* pInterval, SSDataBlock* pResBlock, int32_t fillType, char* fillVal,
|
SInterval* pInterval, STimeWindow* pWindow, SSDataBlock* pResBlock, int32_t fillType, SNodeListNode* fillVal,
|
||||||
bool multigroupResult, SExecTaskInfo* pTaskInfo);
|
bool multigroupResult, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols,
|
SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols,
|
||||||
SSDataBlock* pResBlock, STimeWindowAggSupp *pTwAggSupp, SExecTaskInfo* pTaskInfo);
|
SSDataBlock* pResBlock, STimeWindowAggSupp *pTwAggSupp, int32_t tsSlotId, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResultBlock, SArray* pGroupColList, SExecTaskInfo* pTaskInfo,
|
SSDataBlock* pResultBlock, SArray* pGroupColList, SExecTaskInfo* pTaskInfo,
|
||||||
const STableGroupInfo* pTableGroupInfo);
|
const STableGroupInfo* pTableGroupInfo);
|
||||||
|
|
||||||
SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo);
|
SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
|
|
@ -703,7 +718,7 @@ void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlo
|
||||||
void finalizeQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
void finalizeQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
||||||
void copyTsColoum(SSDataBlock* pRes, SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
void copyTsColoum(SSDataBlock* pRes, SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
||||||
|
|
||||||
STableQueryInfo* createTableQueryInfo(void* buf, bool groupbyColumn, STimeWindow win);
|
STableQueryInfo* createTableQueryInfo(void* buf, STimeWindow win);
|
||||||
|
|
||||||
bool isTaskKilled(SExecTaskInfo* pTaskInfo);
|
bool isTaskKilled(SExecTaskInfo* pTaskInfo);
|
||||||
int32_t checkForQueryBuf(size_t numOfTables);
|
int32_t checkForQueryBuf(size_t numOfTables);
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,12 @@ extern "C" {
|
||||||
struct SSDataBlock;
|
struct SSDataBlock;
|
||||||
|
|
||||||
typedef struct SFillColInfo {
|
typedef struct SFillColInfo {
|
||||||
// STColumn col; // column info
|
SExprInfo *pExpr;
|
||||||
SResSchema col;
|
// SResSchema schema;
|
||||||
int16_t functionId; // sql function id
|
// int16_t functionId; // sql function id
|
||||||
int16_t flag; // column flag: TAG COLUMN|NORMAL COLUMN
|
int16_t flag; // column flag: TAG COLUMN|NORMAL COLUMN
|
||||||
int16_t tagIndex; // index of current tag in SFillTagColInfo array list
|
int16_t tagIndex; // index of current tag in SFillTagColInfo array list
|
||||||
int32_t offset;
|
SVariant fillVal;
|
||||||
union {int64_t i; double d;} val;
|
|
||||||
} SFillColInfo;
|
} SFillColInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -56,9 +55,10 @@ typedef struct SFillInfo {
|
||||||
int32_t numOfCols; // number of columns, including the tags columns
|
int32_t numOfCols; // number of columns, including the tags columns
|
||||||
int32_t rowSize; // size of each row
|
int32_t rowSize; // size of each row
|
||||||
SInterval interval;
|
SInterval interval;
|
||||||
char * prevValues; // previous row of data, to generate the interpolation results
|
|
||||||
char * nextValues; // next row of data
|
SArray *prev;
|
||||||
char** pData; // original result data block involved in filling data
|
SArray *next;
|
||||||
|
SSDataBlock *pSrcBlock;
|
||||||
int32_t alloc; // data buffer size in rows
|
int32_t alloc; // data buffer size in rows
|
||||||
|
|
||||||
SFillColInfo* pFillCol; // column info for fill operations
|
SFillColInfo* pFillCol; // column info for fill operations
|
||||||
|
|
@ -72,7 +72,7 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, int64_t ekey, int32_t
|
||||||
void taosFillSetStartInfo(struct SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey);
|
void taosFillSetStartInfo(struct SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey);
|
||||||
void taosResetFillInfo(struct SFillInfo* pFillInfo, TSKEY startTimestamp);
|
void taosResetFillInfo(struct SFillInfo* pFillInfo, TSKEY startTimestamp);
|
||||||
void taosFillSetInputDataBlock(struct SFillInfo* pFillInfo, const struct SSDataBlock* pInput);
|
void taosFillSetInputDataBlock(struct SFillInfo* pFillInfo, const struct SSDataBlock* pInput);
|
||||||
struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const struct SValueNode* val);
|
struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const struct SNodeListNode* val);
|
||||||
bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
|
bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
|
||||||
|
|
||||||
SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
|
SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
|
||||||
|
|
@ -80,7 +80,7 @@ SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int3
|
||||||
struct SFillColInfo* pCol, const char* id);
|
struct SFillColInfo* pCol, const char* id);
|
||||||
|
|
||||||
void* taosDestroyFillInfo(struct SFillInfo *pFillInfo);
|
void* taosDestroyFillInfo(struct SFillInfo *pFillInfo);
|
||||||
int64_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, void** output, int32_t capacity);
|
int64_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, SSDataBlock* p, int32_t capacity);
|
||||||
int64_t getFillInfoStart(struct SFillInfo *pFillInfo);
|
int64_t getFillInfoStart(struct SFillInfo *pFillInfo);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,14 +154,12 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
|
||||||
|
|
||||||
qDebug("%s execTask is launched", GET_TASKID(pTaskInfo));
|
qDebug("%s execTask is launched", GET_TASKID(pTaskInfo));
|
||||||
|
|
||||||
bool newgroup = false;
|
|
||||||
publishOperatorProfEvent(pTaskInfo->pRoot, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(pTaskInfo->pRoot, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
int64_t st = 0;
|
|
||||||
|
|
||||||
st = taosGetTimestampUs();
|
|
||||||
*pRes = pTaskInfo->pRoot->fpSet.getNextFn(pTaskInfo->pRoot, &newgroup);
|
|
||||||
|
|
||||||
|
int64_t st = taosGetTimestampUs();
|
||||||
|
*pRes = pTaskInfo->pRoot->fpSet.getNextFn(pTaskInfo->pRoot);
|
||||||
uint64_t el = (taosGetTimestampUs() - st);
|
uint64_t el = (taosGetTimestampUs() - st);
|
||||||
|
|
||||||
pTaskInfo->cost.elapsedTime += el;
|
pTaskInfo->cost.elapsedTime += el;
|
||||||
|
|
||||||
publishOperatorProfEvent(pTaskInfo->pRoot, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(pTaskInfo->pRoot, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -77,7 +77,7 @@ static bool groupKeyCompare(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlo
|
||||||
SColumn* pCol = taosArrayGet(pGroupCols, i);
|
SColumn* pCol = taosArrayGet(pGroupCols, i);
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pCol->slotId);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pCol->slotId);
|
||||||
if (pBlock->pBlockAgg != NULL) {
|
if (pBlock->pBlockAgg != NULL) {
|
||||||
pColAgg = &pBlock->pBlockAgg[pCol->slotId]; // TODO is agg data matched?
|
pColAgg = pBlock->pBlockAgg[pCol->slotId]; // TODO is agg data matched?
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNull = colDataIsNull(pColInfoData, pBlock->info.rows, rowIndex, pColAgg);
|
bool isNull = colDataIsNull(pColInfoData, pBlock->info.rows, rowIndex, pColAgg);
|
||||||
|
|
@ -118,7 +118,7 @@ static void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSData
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pCol->slotId);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pCol->slotId);
|
||||||
|
|
||||||
if (pBlock->pBlockAgg != NULL) {
|
if (pBlock->pBlockAgg != NULL) {
|
||||||
pColAgg = &pBlock->pBlockAgg[pCol->slotId]; // TODO is agg data matched?
|
pColAgg = pBlock->pBlockAgg[pCol->slotId]; // TODO is agg data matched?
|
||||||
}
|
}
|
||||||
|
|
||||||
SGroupKeys* pkey = taosArrayGet(pGroupColVals, i);
|
SGroupKeys* pkey = taosArrayGet(pGroupColVals, i);
|
||||||
|
|
@ -256,7 +256,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgroup) {
|
static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -265,7 +265,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
|
||||||
SSDataBlock* pRes = pInfo->binfo.pRes;
|
SSDataBlock* pRes = pInfo->binfo.pRes;
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
if (pOperator->status == OP_RES_TO_RETURN) {
|
||||||
doBuildResultDatablock(pRes, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset, pInfo->binfo.pCtx);
|
doBuildResultDatablock(&pInfo->binfo, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf);
|
||||||
if (pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
if (pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
}
|
}
|
||||||
|
|
@ -277,7 +277,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream, newgroup);
|
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -311,7 +311,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
|
||||||
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, false);
|
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, false);
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
doBuildResultDatablock(pRes, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf, pInfo->binfo.rowCellInfoOffset, pInfo->binfo.pCtx);
|
doBuildResultDatablock(&pInfo->binfo, &pInfo->groupResInfo, pOperator->pExpr, pInfo->aggSup.pResultBuf);
|
||||||
doFilter(pInfo->pCondition, pRes);
|
doFilter(pInfo->pCondition, pRes);
|
||||||
|
|
||||||
bool hasRemain = hasRemainDataInCurrentGroup(&pInfo->groupResInfo);
|
bool hasRemain = hasRemainDataInCurrentGroup(&pInfo->groupResInfo);
|
||||||
|
|
@ -353,7 +353,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
|
||||||
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8);
|
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8);
|
||||||
|
|
||||||
pOperator->name = "GroupbyAggOperator";
|
pOperator->name = "GroupbyAggOperator";
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blocking = true;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
// pOperator->operatorType = OP_Groupby;
|
// pOperator->operatorType = OP_Groupby;
|
||||||
pOperator->pExpr = pExprInfo;
|
pOperator->pExpr = pExprInfo;
|
||||||
|
|
@ -537,11 +537,12 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
pInfo->pageIndex += 1;
|
pInfo->pageIndex += 1;
|
||||||
|
|
||||||
|
blockDataUpdateTsWindow(pInfo->binfo.pRes);
|
||||||
pInfo->binfo.pRes->info.groupId = pGroupInfo->groupId;
|
pInfo->binfo.pRes->info.groupId = pGroupInfo->groupId;
|
||||||
return pInfo->binfo.pRes;
|
return pInfo->binfo.pRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* hashPartition(SOperatorInfo* pOperator, bool* newgroup) {
|
static SSDataBlock* hashPartition(SOperatorInfo* pOperator) {
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -558,7 +559,7 @@ static SSDataBlock* hashPartition(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC);
|
||||||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream, newgroup);
|
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||||
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC);
|
||||||
if (pBlock == NULL) {
|
if (pBlock == NULL) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -611,7 +612,7 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
||||||
}
|
}
|
||||||
|
|
||||||
pOperator->name = "PartitionOperator";
|
pOperator->name = "PartitionOperator";
|
||||||
pOperator->blockingOptr = true;
|
pOperator->blocking = true;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_PARTITION;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_PARTITION;
|
||||||
pInfo->binfo.pRes = pResultBlock;
|
pInfo->binfo.pRes = pResultBlock;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@
|
||||||
|
|
||||||
#include "indexoperator.h"
|
#include "indexoperator.h"
|
||||||
#include "executorimpl.h"
|
#include "executorimpl.h"
|
||||||
|
#include "index.h"
|
||||||
#include "nodes.h"
|
#include "nodes.h"
|
||||||
|
#include "tdatablock.h"
|
||||||
|
|
||||||
typedef struct SIFCtx {
|
typedef struct SIFCtx {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
|
@ -48,36 +50,125 @@ typedef struct SIFCtx {
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
typedef struct SIFParam {
|
typedef struct SIFParam {
|
||||||
SArray * result;
|
|
||||||
SHashObj *pFilter;
|
SHashObj *pFilter;
|
||||||
|
|
||||||
|
SArray *result;
|
||||||
|
char * condValue;
|
||||||
|
|
||||||
|
uint8_t colValType;
|
||||||
|
col_id_t colId;
|
||||||
|
int64_t suid; // add later
|
||||||
|
char dbName[TSDB_DB_NAME_LEN];
|
||||||
|
char colName[TSDB_COL_NAME_LEN];
|
||||||
} SIFParam;
|
} SIFParam;
|
||||||
|
|
||||||
typedef int32_t (*sif_func_t)(SNode *left, SNode *rigth, SIFParam *output);
|
static int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) {
|
||||||
|
if (src == OP_TYPE_GREATER_THAN) {
|
||||||
|
*dst = QUERY_GREATER_THAN;
|
||||||
|
} else if (src == OP_TYPE_GREATER_EQUAL) {
|
||||||
|
*dst = QUERY_GREATER_EQUAL;
|
||||||
|
} else if (src == OP_TYPE_LOWER_THAN) {
|
||||||
|
*dst = QUERY_LESS_THAN;
|
||||||
|
} else if (src == OP_TYPE_LOWER_EQUAL) {
|
||||||
|
*dst = QUERY_LESS_EQUAL;
|
||||||
|
} else if (src == OP_TYPE_EQUAL) {
|
||||||
|
*dst = QUERY_TERM;
|
||||||
|
} else if (src == OP_TYPE_LIKE || src == OP_TYPE_MATCH || src == OP_TYPE_NMATCH) {
|
||||||
|
*dst = QUERY_REGEX;
|
||||||
|
} else {
|
||||||
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef int32_t (*sif_func_t)(SIFParam *left, SIFParam *rigth, SIFParam *output);
|
||||||
// construct tag filter operator later
|
// construct tag filter operator later
|
||||||
static void destroyTagFilterOperatorInfo(void *param) { STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param; }
|
static void destroyTagFilterOperatorInfo(void *param) {
|
||||||
|
STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param;
|
||||||
|
}
|
||||||
|
|
||||||
static void sifFreeParam(SIFParam *param) {
|
static void sifFreeParam(SIFParam *param) {
|
||||||
if (param == NULL) return;
|
if (param == NULL) return;
|
||||||
|
|
||||||
taosArrayDestroy(param->result);
|
taosArrayDestroy(param->result);
|
||||||
|
taosMemoryFree(param->condValue);
|
||||||
|
taosHashCleanup(param->pFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sifGetOperParamNum(EOperatorType ty) {
|
static int32_t sifGetOperParamNum(EOperatorType ty) {
|
||||||
if (OP_TYPE_IS_NULL == ty || OP_TYPE_IS_NOT_NULL == ty || OP_TYPE_IS_TRUE == ty || OP_TYPE_IS_NOT_TRUE == ty || OP_TYPE_IS_FALSE == ty ||
|
if (OP_TYPE_IS_NULL == ty || OP_TYPE_IS_NOT_NULL == ty || OP_TYPE_IS_TRUE == ty || OP_TYPE_IS_NOT_TRUE == ty ||
|
||||||
OP_TYPE_IS_NOT_FALSE == ty || OP_TYPE_IS_UNKNOWN == ty || OP_TYPE_IS_NOT_UNKNOWN == ty || OP_TYPE_MINUS == ty) {
|
OP_TYPE_IS_FALSE == ty || OP_TYPE_IS_NOT_FALSE == ty || OP_TYPE_IS_UNKNOWN == ty ||
|
||||||
|
OP_TYPE_IS_NOT_UNKNOWN == ty || OP_TYPE_MINUS == ty) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
static int32_t sifValidateColumn(SColumnNode *cn) {
|
||||||
|
// add more check
|
||||||
|
if (cn == NULL) {
|
||||||
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
|
}
|
||||||
|
if (cn->colType != COLUMN_TYPE_TAG) {
|
||||||
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sifGetValueFromNode(SNode *node, char **value) {
|
||||||
|
// covert data From snode;
|
||||||
|
SValueNode *vn = (SValueNode *)node;
|
||||||
|
|
||||||
|
char * pData = nodesGetValueFromNode(vn);
|
||||||
|
SDataType *pType = &vn->node.resType;
|
||||||
|
int32_t type = pType->type;
|
||||||
|
int32_t valLen = 0;
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
int32_t dataLen = varDataTLen(pData);
|
||||||
|
if (type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
if (*pData == TSDB_DATA_TYPE_NULL) {
|
||||||
|
dataLen = 0;
|
||||||
|
} else if (*pData == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
dataLen = varDataTLen(pData + CHAR_BYTES);
|
||||||
|
} else if (*pData == TSDB_DATA_TYPE_BIGINT || *pData == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
|
dataLen = LONG_BYTES;
|
||||||
|
} else if (*pData == TSDB_DATA_TYPE_BOOL) {
|
||||||
|
dataLen = CHAR_BYTES;
|
||||||
|
}
|
||||||
|
dataLen += CHAR_BYTES;
|
||||||
|
}
|
||||||
|
valLen = dataLen;
|
||||||
|
} else {
|
||||||
|
valLen = pType->bytes;
|
||||||
|
}
|
||||||
|
char *tv = taosMemoryCalloc(1, valLen + 1);
|
||||||
|
if (tv == NULL) {
|
||||||
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(tv, pData, valLen);
|
||||||
|
*value = tv;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
||||||
switch (nodeType(node)) {
|
switch (nodeType(node)) {
|
||||||
case QUERY_NODE_VALUE: {
|
case QUERY_NODE_VALUE: {
|
||||||
SValueNode *vn = (SValueNode *)node;
|
SValueNode *vn = (SValueNode *)node;
|
||||||
|
SIF_ERR_RET(sifGetValueFromNode(node, ¶m->condValue));
|
||||||
|
param->colId = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_COLUMN: {
|
case QUERY_NODE_COLUMN: {
|
||||||
SColumnNode *cn = (SColumnNode *)node;
|
SColumnNode *cn = (SColumnNode *)node;
|
||||||
|
/*only support tag column*/
|
||||||
|
SIF_ERR_RET(sifValidateColumn(cn));
|
||||||
|
|
||||||
|
param->colId = cn->colId;
|
||||||
|
param->colValType = cn->node.resType.type;
|
||||||
|
memcpy(param->dbName, cn->dbName, sizeof(cn->dbName));
|
||||||
|
memcpy(param->colName, cn->colName, sizeof(cn->colName));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_NODE_LIST: {
|
case QUERY_NODE_NODE_LIST: {
|
||||||
|
|
@ -86,7 +177,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
||||||
qError("invalid length for node:%p, length: %d", node, LIST_LENGTH(nl->pNodeList));
|
qError("invalid length for node:%p, length: %d", node, LIST_LENGTH(nl->pNodeList));
|
||||||
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
SIF_ERR_RET(scalarGenerateSetFromList((void **)¶m->pFilter, node, nl->dataType.type));
|
||||||
if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) {
|
if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) {
|
||||||
taosHashCleanup(param->pFilter);
|
taosHashCleanup(param->pFilter);
|
||||||
qError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param));
|
qError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param));
|
||||||
|
|
@ -160,58 +251,75 @@ static int32_t sifExecFunction(SFunctionNode *node, SIFCtx *ctx, SIFParam *outpu
|
||||||
qError("index-filter not support buildin function");
|
qError("index-filter not support buildin function");
|
||||||
return TSDB_CODE_QRY_INVALID_INPUT;
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFParam *output) {
|
||||||
|
SIndexTerm *tm = indexTermCreate(left->suid, DEFAULT, operType, left->colValType, left->colName,
|
||||||
|
strlen(left->colName), right->condValue, strlen(right->condValue));
|
||||||
|
if (tm == NULL) {
|
||||||
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
SIndexMultiTermQuery *mtm = indexMultiTermQueryCreate(MUST);
|
||||||
|
|
||||||
static int32_t sifLessThanFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
EIndexQueryType qtype = 0;
|
||||||
// impl later
|
SIF_ERR_RET(sifGetFuncFromSql(operType, &qtype));
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
indexMultiTermQueryAdd(mtm, tm, qtype);
|
||||||
static int32_t sifLessEqualFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
int ret = indexSearch(NULL, mtm, output->result);
|
||||||
// impl later
|
indexMultiTermQueryDestroy(mtm);
|
||||||
return TSDB_CODE_SUCCESS;
|
return ret;
|
||||||
}
|
|
||||||
static int32_t sifGreaterThanFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
|
||||||
// impl later
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
static int32_t sifGreaterEqualFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
|
||||||
// impl later
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sifEqualFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
static int32_t sifLessThanFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
// impl later
|
int id = OP_TYPE_LOWER_THAN;
|
||||||
return TSDB_CODE_SUCCESS;
|
return sifDoIndex(left, right, id, output);
|
||||||
}
|
}
|
||||||
static int32_t sifNotEqualFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
static int32_t sifLessEqualFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
// impl later
|
int id = OP_TYPE_LOWER_EQUAL;
|
||||||
return TSDB_CODE_SUCCESS;
|
return sifDoIndex(left, right, id, output);
|
||||||
}
|
|
||||||
static int32_t sifInFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
|
||||||
// impl later
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
static int32_t sifNotInFunc(SNode *left, SNode *right, SIFParam *output) {
|
|
||||||
// impl later
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
static int32_t sifLikeFunc(SNode *left, SNode *right, SIFParam *output) {
|
|
||||||
// impl later
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
static int32_t sifNotLikeFunc(SNode *left, SNode *right, SIFParam *output) {
|
|
||||||
// impl later
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sifMatchFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
static int32_t sifGreaterThanFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
// impl later
|
int id = OP_TYPE_GREATER_THAN;
|
||||||
return TSDB_CODE_SUCCESS;
|
return sifDoIndex(left, right, id, output);
|
||||||
}
|
}
|
||||||
static int32_t sifNotMatchFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
static int32_t sifGreaterEqualFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
// impl later
|
int id = OP_TYPE_GREATER_EQUAL;
|
||||||
return TSDB_CODE_SUCCESS;
|
return sifDoIndex(left, right, id, output);
|
||||||
}
|
}
|
||||||
static int32_t sifDefaultFunc(SNode *left, SNode *rigth, SIFParam *output) {
|
|
||||||
|
static int32_t sifEqualFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
|
int id = OP_TYPE_EQUAL;
|
||||||
|
return sifDoIndex(left, right, id, output);
|
||||||
|
}
|
||||||
|
static int32_t sifNotEqualFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
|
int id = OP_TYPE_NOT_EQUAL;
|
||||||
|
return sifDoIndex(left, right, id, output);
|
||||||
|
}
|
||||||
|
static int32_t sifInFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
|
int id = OP_TYPE_IN;
|
||||||
|
return sifDoIndex(left, right, id, output);
|
||||||
|
}
|
||||||
|
static int32_t sifNotInFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
|
int id = OP_TYPE_NOT_IN;
|
||||||
|
return sifDoIndex(left, right, id, output);
|
||||||
|
}
|
||||||
|
static int32_t sifLikeFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
|
int id = OP_TYPE_LIKE;
|
||||||
|
return sifDoIndex(left, right, id, output);
|
||||||
|
}
|
||||||
|
static int32_t sifNotLikeFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
|
int id = OP_TYPE_NOT_LIKE;
|
||||||
|
return sifDoIndex(left, right, id, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t sifMatchFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
|
int id = OP_TYPE_MATCH;
|
||||||
|
return sifDoIndex(left, right, id, output);
|
||||||
|
}
|
||||||
|
static int32_t sifNotMatchFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
|
int id = OP_TYPE_NMATCH;
|
||||||
|
return sifDoIndex(left, right, id, output);
|
||||||
|
}
|
||||||
|
static int32_t sifDefaultFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
// add more except
|
// add more except
|
||||||
return TSDB_CODE_QRY_INVALID_INPUT;
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
|
@ -250,16 +358,17 @@ static sif_func_t sifGetOperFn(int32_t funcId) {
|
||||||
}
|
}
|
||||||
static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
|
static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SIFParam *params = NULL;
|
|
||||||
SIF_ERR_RET(sifInitOperParams(¶ms, node, ctx));
|
|
||||||
|
|
||||||
int32_t nParam = sifGetOperParamNum(node->opType);
|
int32_t nParam = sifGetOperParamNum(node->opType);
|
||||||
if (nParam <= 1) {
|
if (nParam <= 1) {
|
||||||
SIF_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
SIF_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SIFParam *params = NULL;
|
||||||
|
SIF_ERR_RET(sifInitOperParams(¶ms, node, ctx));
|
||||||
|
|
||||||
sif_func_t operFn = sifGetOperFn(node->opType);
|
sif_func_t operFn = sifGetOperFn(node->opType);
|
||||||
|
|
||||||
return operFn(node->pLeft, node->pRight, output);
|
return operFn(¶ms[0], nParam > 1 ? ¶ms[1] : NULL, output);
|
||||||
_return:
|
_return:
|
||||||
taosMemoryFree(params);
|
taosMemoryFree(params);
|
||||||
SIF_RET(code);
|
SIF_RET(code);
|
||||||
|
|
@ -267,7 +376,8 @@ _return:
|
||||||
|
|
||||||
static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *output) {
|
static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||||
if (NULL == node->pParameterList || node->pParameterList->length <= 0) {
|
if (NULL == node->pParameterList || node->pParameterList->length <= 0) {
|
||||||
qError("invalid logic parameter list, list:%p, paramNum:%d", node->pParameterList, node->pParameterList ? node->pParameterList->length : 0);
|
qError("invalid logic parameter list, list:%p, paramNum:%d", node->pParameterList,
|
||||||
|
node->pParameterList ? node->pParameterList->length : 0);
|
||||||
return TSDB_CODE_QRY_INVALID_INPUT;
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -331,7 +441,6 @@ static EDealRes sifWalkOper(SNode *pNode, void *context) {
|
||||||
if (ctx->code) {
|
if (ctx->code) {
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
|
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
|
||||||
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
|
|
@ -341,7 +450,8 @@ static EDealRes sifWalkOper(SNode *pNode, void *context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EDealRes sifCalcWalker(SNode *node, void *context) {
|
EDealRes sifCalcWalker(SNode *node, void *context) {
|
||||||
if (QUERY_NODE_VALUE == nodeType(node) || QUERY_NODE_NODE_LIST == nodeType(node) || QUERY_NODE_COLUMN == nodeType(node)) {
|
if (QUERY_NODE_VALUE == nodeType(node) || QUERY_NODE_NODE_LIST == nodeType(node) ||
|
||||||
|
QUERY_NODE_COLUMN == nodeType(node)) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
SIFCtx *ctx = (SIFCtx *)context;
|
SIFCtx *ctx = (SIFCtx *)context;
|
||||||
|
|
@ -382,22 +492,22 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
|
||||||
qError("index-filter failed to taosHashInit");
|
qError("index-filter failed to taosHashInit");
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodesWalkExprPostOrder(pNode, sifCalcWalker, &ctx);
|
nodesWalkExprPostOrder(pNode, sifCalcWalker, &ctx);
|
||||||
if (ctx.code != TSDB_CODE_SUCCESS) {
|
SIF_ERR_RET(ctx.code);
|
||||||
return ctx.code;
|
|
||||||
}
|
|
||||||
if (pDst) {
|
if (pDst) {
|
||||||
SIFParam *res = (SIFParam *)taosHashGet(ctx.pRes, (void *)&pNode, POINTER_BYTES);
|
SIFParam *res = (SIFParam *)taosHashGet(ctx.pRes, (void *)&pNode, POINTER_BYTES);
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
qError("no valid res in hash, node:(%p), type(%d)", (void *)&pNode, nodeType(pNode));
|
qError("no valid res in hash, node:(%p), type(%d)", (void *)&pNode, nodeType(pNode));
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
SIF_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||||
}
|
}
|
||||||
taosArrayAddAll(pDst->result, res->result);
|
taosArrayAddAll(pDst->result, res->result);
|
||||||
|
|
||||||
sifFreeParam(res);
|
sifFreeParam(res);
|
||||||
taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES);
|
taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
SIF_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doFilterTag(const SNode *pFilterNode, SArray *result) {
|
int32_t doFilterTag(const SNode *pFilterNode, SArray *result) {
|
||||||
|
|
@ -407,28 +517,21 @@ int32_t doFilterTag(const SNode *pFilterNode, SArray *result) {
|
||||||
|
|
||||||
SFilterInfo *filter = NULL;
|
SFilterInfo *filter = NULL;
|
||||||
// todo move to the initialization function
|
// todo move to the initialization function
|
||||||
int32_t code = filterInitFromNode((SNode *)pFilterNode, &filter, 0);
|
SIF_ERR_RET(filterInitFromNode((SNode *)pFilterNode, &filter, 0));
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
SIFParam param = {0};
|
SIFParam param = {0};
|
||||||
code = sifCalculate((SNode *)pFilterNode, ¶m);
|
SIF_ERR_RET(sifCalculate((SNode *)pFilterNode, ¶m));
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayAddAll(result, param.result);
|
taosArrayAddAll(result, param.result);
|
||||||
sifFreeParam(¶m);
|
sifFreeParam(¶m);
|
||||||
|
SIF_RET(TSDB_CODE_SUCCESS);
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SIdxFltStatus idxGetFltStatus(SNode *pFilterNode) {
|
SIdxFltStatus idxGetFltStatus(SNode *pFilterNode) {
|
||||||
if (pFilterNode == NULL) {
|
if (pFilterNode == NULL) {
|
||||||
return SFLT_NOT_INDEX;
|
return SFLT_NOT_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl later
|
// impl later
|
||||||
return SFLT_ACCURATE_INDEX;
|
return SFLT_ACCURATE_INDEX;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/ttime.h"
|
#include "ttime.h"
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
#include "functionMgt.h"
|
#include "functionMgt.h"
|
||||||
|
|
@ -36,10 +36,10 @@
|
||||||
#define SET_REVERSE_SCAN_FLAG(_info) ((_info)->scanFlag = REVERSE_SCAN)
|
#define SET_REVERSE_SCAN_FLAG(_info) ((_info)->scanFlag = REVERSE_SCAN)
|
||||||
#define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC))
|
#define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC))
|
||||||
|
|
||||||
int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo);
|
static int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity);
|
||||||
|
static int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size, const char* dbName);
|
||||||
|
|
||||||
int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size, const char* dbName);
|
static void switchCtxOrder(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
|
||||||
void switchCtxOrder(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
|
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
SWITCH_ORDER(pCtx[i].order);
|
SWITCH_ORDER(pCtx[i].order);
|
||||||
}
|
}
|
||||||
|
|
@ -158,11 +158,11 @@ static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockIn
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) {
|
static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) {
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
STableScanInfo* pInfo = pOperator->info;
|
STableScanInfo* pInfo = pOperator->info;
|
||||||
|
|
||||||
STaskCostInfo* pCost = &pTaskInfo->cost;
|
SFileBlockLoadRecorder* pCost = &pTableScanInfo->readRecorder;
|
||||||
|
|
||||||
pCost->totalBlocks += 1;
|
pCost->totalBlocks += 1;
|
||||||
pCost->totalRows += pBlock->info.rows;
|
pCost->totalRows += pBlock->info.rows;
|
||||||
|
|
@ -188,14 +188,18 @@ int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo,
|
||||||
} else if (*status == FUNC_DATA_REQUIRED_STATIS_LOAD) {
|
} else if (*status == FUNC_DATA_REQUIRED_STATIS_LOAD) {
|
||||||
pCost->loadBlockStatis += 1;
|
pCost->loadBlockStatis += 1;
|
||||||
|
|
||||||
SColumnDataAgg* pColAgg = NULL;
|
bool allColumnsHaveAgg = true;
|
||||||
tsdbRetrieveDataBlockStatisInfo(pTableScanInfo->dataReader, &pColAgg);
|
SColumnDataAgg** pColAgg = NULL;
|
||||||
|
tsdbRetrieveDataBlockStatisInfo(pTableScanInfo->dataReader, &pColAgg, &allColumnsHaveAgg);
|
||||||
|
|
||||||
if (pColAgg != NULL) {
|
if (allColumnsHaveAgg == true) {
|
||||||
int32_t numOfCols = pBlock->info.numOfCols;
|
int32_t numOfCols = pBlock->info.numOfCols;
|
||||||
|
|
||||||
// todo create this buffer during creating operator
|
// todo create this buffer during creating operator
|
||||||
pBlock->pBlockAgg = taosMemoryCalloc(numOfCols, sizeof(SColumnDataAgg));
|
if (pBlock->pBlockAgg == NULL) {
|
||||||
|
pBlock->pBlockAgg = taosMemoryCalloc(numOfCols, POINTER_BYTES);
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SColMatchInfo* pColMatchInfo = taosArrayGet(pTableScanInfo->pColMatchInfo, i);
|
SColMatchInfo* pColMatchInfo = taosArrayGet(pTableScanInfo->pColMatchInfo, i);
|
||||||
if (!pColMatchInfo->output) {
|
if (!pColMatchInfo->output) {
|
||||||
|
|
@ -232,6 +236,7 @@ int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
relocateColumnData(pBlock, pTableScanInfo->pColMatchInfo, pCols);
|
relocateColumnData(pBlock, pTableScanInfo->pColMatchInfo, pCols);
|
||||||
|
// todo record the filter time cost
|
||||||
doFilter(pTableScanInfo->pFilterNode, pBlock);
|
doFilter(pTableScanInfo->pFilterNode, pBlock);
|
||||||
if (pBlock->info.rows == 0) {
|
if (pBlock->info.rows == 0) {
|
||||||
pCost->filterOutBlocks += 1;
|
pCost->filterOutBlocks += 1;
|
||||||
|
|
@ -253,18 +258,15 @@ static void prepareForDescendingScan(STableScanInfo* pTableScanInfo, SqlFunction
|
||||||
pTableScanInfo->cond.order = TSDB_ORDER_DESC;
|
pTableScanInfo->cond.order = TSDB_ORDER_DESC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
|
static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
|
||||||
STableScanInfo* pTableScanInfo = pOperator->info;
|
STableScanInfo* pTableScanInfo = pOperator->info;
|
||||||
|
|
||||||
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
||||||
*newgroup = false;
|
|
||||||
|
|
||||||
while (tsdbNextDataBlock(pTableScanInfo->dataReader)) {
|
while (tsdbNextDataBlock(pTableScanInfo->dataReader)) {
|
||||||
if (isTaskKilled(pOperator->pTaskInfo)) {
|
if (isTaskKilled(pOperator->pTaskInfo)) {
|
||||||
longjmp(pOperator->pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED);
|
longjmp(pOperator->pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableScanInfo->numOfBlocks += 1;
|
|
||||||
tsdbRetrieveDataBlockInfo(pTableScanInfo->dataReader, &pBlock->info);
|
tsdbRetrieveDataBlockInfo(pTableScanInfo->dataReader, &pBlock->info);
|
||||||
|
|
||||||
uint32_t status = 0;
|
uint32_t status = 0;
|
||||||
|
|
@ -285,7 +287,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
||||||
STableScanInfo* pTableScanInfo = pOperator->info;
|
STableScanInfo* pTableScanInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
|
|
@ -294,17 +296,16 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*newgroup = false;
|
// do the ascending order traverse in the first place.
|
||||||
|
while (pTableScanInfo->scanTimes < pTableScanInfo->scanInfo.numOfAsc) {
|
||||||
while (pTableScanInfo->current < pTableScanInfo->scanInfo.numOfAsc) {
|
SSDataBlock* p = doTableScanImpl(pOperator);
|
||||||
SSDataBlock* p = doTableScanImpl(pOperator, newgroup);
|
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableScanInfo->current += 1;
|
pTableScanInfo->scanTimes += 1;
|
||||||
|
|
||||||
if (pTableScanInfo->current < pTableScanInfo->scanInfo.numOfAsc) {
|
if (pTableScanInfo->scanTimes < pTableScanInfo->scanInfo.numOfAsc) {
|
||||||
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
||||||
pTableScanInfo->scanFlag = REPEAT_SCAN;
|
pTableScanInfo->scanFlag = REPEAT_SCAN;
|
||||||
|
|
||||||
|
|
@ -319,7 +320,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t total = pTableScanInfo->scanInfo.numOfAsc + pTableScanInfo->scanInfo.numOfDesc;
|
int32_t total = pTableScanInfo->scanInfo.numOfAsc + pTableScanInfo->scanInfo.numOfDesc;
|
||||||
if (pTableScanInfo->current < total) {
|
if (pTableScanInfo->scanTimes < total) {
|
||||||
if (pTableScanInfo->cond.order == TSDB_ORDER_ASC) {
|
if (pTableScanInfo->cond.order == TSDB_ORDER_ASC) {
|
||||||
prepareForDescendingScan(pTableScanInfo, pTableScanInfo->pCtx, pTableScanInfo->numOfOutput);
|
prepareForDescendingScan(pTableScanInfo, pTableScanInfo->pCtx, pTableScanInfo->numOfOutput);
|
||||||
tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond);
|
tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond);
|
||||||
|
|
@ -329,21 +330,20 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
qDebug("%s start to descending order scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64,
|
qDebug("%s start to descending order scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64,
|
||||||
GET_TASKID(pTaskInfo), pWin->skey, pWin->ekey);
|
GET_TASKID(pTaskInfo), pWin->skey, pWin->ekey);
|
||||||
|
|
||||||
while (pTableScanInfo->current < total) {
|
while (pTableScanInfo->scanTimes < total) {
|
||||||
SSDataBlock* p = doTableScanImpl(pOperator, newgroup);
|
SSDataBlock* p = doTableScanImpl(pOperator);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableScanInfo->current += 1;
|
pTableScanInfo->scanTimes += 1;
|
||||||
|
|
||||||
if (pTableScanInfo->current < pTableScanInfo->scanInfo.numOfAsc) {
|
if (pTableScanInfo->scanTimes < pTableScanInfo->scanInfo.numOfAsc) {
|
||||||
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
||||||
pTableScanInfo->scanFlag = REPEAT_SCAN;
|
pTableScanInfo->scanFlag = REPEAT_SCAN;
|
||||||
|
|
||||||
qDebug("%s start to repeat descending order scan data blocks due to query func required, qrange:%" PRId64
|
qDebug("%s start to repeat descending order scan data blocks due to query func required, qrange:%" PRId64
|
||||||
"-%" PRId64,
|
"-%" PRId64, GET_TASKID(pTaskInfo), pTaskInfo->window.skey, pTaskInfo->window.ekey);
|
||||||
GET_TASKID(pTaskInfo), pTaskInfo->window.skey, pTaskInfo->window.ekey);
|
|
||||||
|
|
||||||
// do prepare for the next round table scan operation
|
// do prepare for the next round table scan operation
|
||||||
tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond);
|
tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond);
|
||||||
|
|
@ -378,52 +378,53 @@ SOperatorInfo* createTableScanOperatorInfo(void* pDataReader, SQueryTableDataCon
|
||||||
pInfo->pResBlock = pResBlock;
|
pInfo->pResBlock = pResBlock;
|
||||||
pInfo->pFilterNode = pCondition;
|
pInfo->pFilterNode = pCondition;
|
||||||
pInfo->dataReader = pDataReader;
|
pInfo->dataReader = pDataReader;
|
||||||
pInfo->current = 0;
|
|
||||||
pInfo->scanFlag = MAIN_SCAN;
|
pInfo->scanFlag = MAIN_SCAN;
|
||||||
pInfo->pColMatchInfo = pColMatchInfo;
|
pInfo->pColMatchInfo = pColMatchInfo;
|
||||||
|
|
||||||
pOperator->name = "TableScanOperator";
|
pOperator->name = "TableScanOperator"; // for dubug purpose
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blocking = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->fpSet.getNextFn = doTableScan;
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScan, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
static int32_t cost = 0;
|
static int32_t cost = 0;
|
||||||
pOperator->cost.openCost = ++cost;
|
|
||||||
|
// for non-blocking operator, the open cost is always 0
|
||||||
|
pOperator->cost.openCost = 0;
|
||||||
pOperator->cost.totalCost = ++cost;
|
pOperator->cost.totalCost = ++cost;
|
||||||
pOperator->resultInfo.totalRows = ++cost;
|
pOperator->resultInfo.totalRows = ++cost;
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle) {
|
SOperatorInfo* createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo* pTaskInfo) {
|
||||||
STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo));
|
STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo));
|
||||||
|
|
||||||
pInfo->dataReader = pTsdbReadHandle;
|
|
||||||
pInfo->current = 0;
|
|
||||||
pInfo->prevGroupId = -1;
|
|
||||||
|
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
|
|
||||||
|
pInfo->dataReader = pReadHandle;
|
||||||
|
// pInfo->prevGroupId = -1;
|
||||||
|
|
||||||
pOperator->name = "TableSeqScanOperator";
|
pOperator->name = "TableSeqScanOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blocking = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->fpSet.getNextFn = doTableScanImpl;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScanImpl, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doBlockInfoScan(SOperatorInfo* pOperator, bool* newgroup) {
|
static SSDataBlock* doBlockInfoScan(SOperatorInfo* pOperator) {
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableScanInfo* pTableScanInfo = pOperator->info;
|
STableScanInfo* pTableScanInfo = pOperator->info;
|
||||||
*newgroup = false;
|
|
||||||
|
|
||||||
STableBlockDistInfo tableBlockDist = {0};
|
STableBlockDistInfo tableBlockDist = {0};
|
||||||
tableBlockDist.numOfTables = 1; // TODO set the correct number of tables
|
tableBlockDist.numOfTables = 1; // TODO set the correct number of tables
|
||||||
|
|
@ -483,7 +484,7 @@ SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo*
|
||||||
|
|
||||||
pOperator->name = "DataBlockInfoScanOperator";
|
pOperator->name = "DataBlockInfoScanOperator";
|
||||||
// pOperator->operatorType = OP_TableBlockInfoScan;
|
// pOperator->operatorType = OP_TableBlockInfoScan;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blocking = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->fpSet._openFn = operatorDummyOpenFn;
|
pOperator->fpSet._openFn = operatorDummyOpenFn;
|
||||||
pOperator->fpSet.getNextFn = doBlockInfoScan;
|
pOperator->fpSet.getNextFn = doBlockInfoScan;
|
||||||
|
|
@ -510,10 +511,11 @@ static void doClearBufferedBlocks(SStreamBlockScanInfo* pInfo) {
|
||||||
taosArrayClear(pInfo->pBlockLists);
|
taosArrayClear(pInfo->pBlockLists);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator, bool* newgroup) {
|
static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
|
||||||
// NOTE: this operator does never check if current status is done or not
|
// NOTE: this operator does never check if current status is done or not
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
SStreamBlockScanInfo* pInfo = pOperator->info;
|
SStreamBlockScanInfo* pInfo = pOperator->info;
|
||||||
|
int32_t rows = 0;
|
||||||
|
|
||||||
pTaskInfo->code = pOperator->fpSet._openFn(pOperator);
|
pTaskInfo->code = pOperator->fpSet._openFn(pOperator);
|
||||||
if (pTaskInfo->code != TSDB_CODE_SUCCESS || pOperator->status == OP_EXEC_DONE) {
|
if (pTaskInfo->code != TSDB_CODE_SUCCESS || pOperator->status == OP_EXEC_DONE) {
|
||||||
|
|
@ -580,6 +582,8 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator, bool* newgroup)
|
||||||
pTaskInfo->code = terrno;
|
pTaskInfo->code = terrno;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
rows = pBlockInfo->rows;
|
||||||
|
doFilter(pInfo->pCondition, pInfo->pRes);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -588,16 +592,16 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator, bool* newgroup)
|
||||||
pInfo->numOfExec++;
|
pInfo->numOfExec++;
|
||||||
pInfo->numOfRows += pBlockInfo->rows;
|
pInfo->numOfRows += pBlockInfo->rows;
|
||||||
|
|
||||||
if (pBlockInfo->rows == 0) {
|
if (rows == 0) {
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes;
|
return (rows == 0) ? NULL : pInfo->pRes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock* pResBlock, SArray* pColList,
|
SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock* pResBlock, SArray* pColList,
|
||||||
SArray* pTableIdList, SExecTaskInfo* pTaskInfo) {
|
SArray* pTableIdList, SExecTaskInfo* pTaskInfo, SNode* pCondition) {
|
||||||
SStreamBlockScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamBlockScanInfo));
|
SStreamBlockScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamBlockScanInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
|
|
@ -635,10 +639,11 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock*
|
||||||
|
|
||||||
pInfo->readerHandle = streamReadHandle;
|
pInfo->readerHandle = streamReadHandle;
|
||||||
pInfo->pRes = pResBlock;
|
pInfo->pRes = pResBlock;
|
||||||
|
pInfo->pCondition = pCondition;
|
||||||
|
|
||||||
pOperator->name = "StreamBlockScanOperator";
|
pOperator->name = "StreamBlockScanOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blocking = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->numOfOutput = pResBlock->info.numOfCols;
|
pOperator->numOfOutput = pResBlock->info.numOfCols;
|
||||||
|
|
@ -647,6 +652,8 @@ SOperatorInfo* createStreamScanOperatorInfo(void* streamReadHandle, SSDataBlock*
|
||||||
pOperator->fpSet.closeFn = operatorDummyCloseFn;
|
pOperator->fpSet.closeFn = operatorDummyCloseFn;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
|
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamBlockScan, NULL, NULL, operatorDummyCloseFn, NULL, NULL, NULL);
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -668,14 +675,12 @@ EDealRes getDBNameFromConditionWalker(SNode* pNode, void* pContext) {
|
||||||
switch (nType) {
|
switch (nType) {
|
||||||
case QUERY_NODE_OPERATOR: {
|
case QUERY_NODE_OPERATOR: {
|
||||||
SOperatorNode* node = (SOperatorNode*)pNode;
|
SOperatorNode* node = (SOperatorNode*)pNode;
|
||||||
|
|
||||||
if (OP_TYPE_EQUAL == node->opType) {
|
if (OP_TYPE_EQUAL == node->opType) {
|
||||||
*(int32_t*)pContext = 1;
|
*(int32_t*)pContext = 1;
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(int32_t*)pContext = 0;
|
*(int32_t*)pContext = 0;
|
||||||
|
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_COLUMN: {
|
case QUERY_NODE_COLUMN: {
|
||||||
|
|
@ -706,19 +711,17 @@ EDealRes getDBNameFromConditionWalker(SNode* pNode, void* pContext) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void getDBNameFromCondition(SNode* pCondition, char* dbName) {
|
static void getDBNameFromCondition(SNode* pCondition, const char* dbName) {
|
||||||
if (NULL == pCondition) {
|
if (NULL == pCondition) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
nodesWalkExpr(pCondition, getDBNameFromConditionWalker, (char*) dbName);
|
||||||
nodesWalkExpr(pCondition, getDBNameFromConditionWalker, dbName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t loadSysTableContentCb(void* param, const SDataBuf* pMsg, int32_t code) {
|
static int32_t loadSysTableCallback(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
SOperatorInfo* operator=(SOperatorInfo*) param;
|
SOperatorInfo* operator=(SOperatorInfo*) param;
|
||||||
SSysTableScanInfo* pScanResInfo = (SSysTableScanInfo*)operator->info;
|
SSysTableScanInfo* pScanResInfo = (SSysTableScanInfo*)operator->info;
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
|
@ -743,6 +746,7 @@ static SSDataBlock* doFilterResult(SSysTableScanInfo* pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SFilterInfo* filter = NULL;
|
SFilterInfo* filter = NULL;
|
||||||
|
|
||||||
int32_t code = filterInitFromNode(pInfo->pCondition, &filter, 0);
|
int32_t code = filterInitFromNode(pInfo->pCondition, &filter, 0);
|
||||||
|
|
||||||
SFilterColumnParam param1 = {.numOfCols = pInfo->pRes->info.numOfCols, .pDataBlock = pInfo->pRes->pDataBlock};
|
SFilterColumnParam param1 = {.numOfCols = pInfo->pRes->info.numOfCols, .pDataBlock = pInfo->pRes->pDataBlock};
|
||||||
|
|
@ -792,66 +796,36 @@ static SSDataBlock* doFilterResult(SSysTableScanInfo* pInfo) {
|
||||||
|
|
||||||
static SSDataBlock* buildSysTableMetaBlock() {
|
static SSDataBlock* buildSysTableMetaBlock() {
|
||||||
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
|
||||||
pBlock->info.numOfCols = 10;
|
|
||||||
pBlock->info.hasVarCol = true;
|
size_t size = 0;
|
||||||
|
const SSysTableMeta *pMeta = NULL;
|
||||||
|
getInfosDbMeta(&pMeta, &size);
|
||||||
|
|
||||||
|
int32_t index = 0;
|
||||||
|
for(int32_t i = 0; i < size; ++i) {
|
||||||
|
if(strcmp(pMeta[i].name, TSDB_INS_TABLE_USER_TABLES) == 0) {
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pBlock->pDataBlock = taosArrayInit(pBlock->info.numOfCols, sizeof(SColumnInfoData));
|
pBlock->pDataBlock = taosArrayInit(pBlock->info.numOfCols, sizeof(SColumnInfoData));
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < pMeta[index].colNum; ++i) {
|
||||||
SColumnInfoData colInfoData = {0};
|
SColumnInfoData colInfoData = {0};
|
||||||
colInfoData.info.colId = 1;
|
colInfoData.info.colId = i + 1;
|
||||||
colInfoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
colInfoData.info.type = pMeta[index].schema[i].type;
|
||||||
colInfoData.info.bytes = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
colInfoData.info.bytes = pMeta[index].schema[i].bytes;
|
||||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
||||||
|
}
|
||||||
|
|
||||||
colInfoData.info.colId = 2;
|
pBlock->info.numOfCols = pMeta[index].colNum;
|
||||||
colInfoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
pBlock->info.hasVarCol = true;
|
||||||
colInfoData.info.bytes = (TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
|
||||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
|
||||||
|
|
||||||
colInfoData.info.colId = 3;
|
|
||||||
colInfoData.info.type = TSDB_DATA_TYPE_TIMESTAMP;
|
|
||||||
colInfoData.info.bytes = 8;
|
|
||||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
|
||||||
|
|
||||||
colInfoData.info.colId = 4;
|
|
||||||
colInfoData.info.type = TSDB_DATA_TYPE_INT;
|
|
||||||
colInfoData.info.bytes = 4;
|
|
||||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
|
||||||
|
|
||||||
colInfoData.info.colId = 5;
|
|
||||||
colInfoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
|
||||||
colInfoData.info.bytes = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE;
|
|
||||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
|
||||||
|
|
||||||
colInfoData.info.colId = 6;
|
|
||||||
colInfoData.info.type = TSDB_DATA_TYPE_BIGINT;
|
|
||||||
colInfoData.info.bytes = 8;
|
|
||||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
|
||||||
|
|
||||||
colInfoData.info.colId = 7;
|
|
||||||
colInfoData.info.type = TSDB_DATA_TYPE_INT;
|
|
||||||
colInfoData.info.bytes = 4;
|
|
||||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
|
||||||
|
|
||||||
colInfoData.info.colId = 8;
|
|
||||||
colInfoData.info.type = TSDB_DATA_TYPE_INT;
|
|
||||||
colInfoData.info.bytes = 4;
|
|
||||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
|
||||||
|
|
||||||
colInfoData.info.colId = 9;
|
|
||||||
colInfoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
|
||||||
colInfoData.info.bytes = 512 + VARSTR_HEADER_SIZE;
|
|
||||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
|
||||||
|
|
||||||
colInfoData.info.colId = 10;
|
|
||||||
colInfoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
|
||||||
colInfoData.info.bytes = 20 + VARSTR_HEADER_SIZE;
|
|
||||||
taosArrayPush(pBlock->pDataBlock, &colInfoData);
|
|
||||||
|
|
||||||
return pBlock;
|
return pBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
|
||||||
// build message and send to mnode to fetch the content of system tables.
|
// build message and send to mnode to fetch the content of system tables.
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
SSysTableScanInfo* pInfo = pOperator->info;
|
SSysTableScanInfo* pInfo = pOperator->info;
|
||||||
|
|
@ -865,7 +839,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildSysDbTableInfo(pInfo);
|
buildSysDbTableInfo(pInfo, pOperator->resultInfo.capacity);
|
||||||
|
|
||||||
doFilterResult(pInfo);
|
doFilterResult(pInfo);
|
||||||
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
|
||||||
|
|
@ -893,7 +867,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
varDataSetLen(dbname, strlen(varDataVal(dbname)));
|
varDataSetLen(dbname, strlen(varDataVal(dbname)));
|
||||||
|
|
||||||
SSDataBlock* p = buildSysTableMetaBlock();
|
SSDataBlock* p = buildSysTableMetaBlock();
|
||||||
blockDataEnsureCapacity(p, pInfo->capacity);
|
blockDataEnsureCapacity(p, pOperator->resultInfo.capacity);
|
||||||
|
|
||||||
char n[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char n[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
while (metaTbCursorNext(pInfo->pCur) == 0) {
|
while (metaTbCursorNext(pInfo->pCur) == 0) {
|
||||||
|
|
@ -974,7 +948,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
pColInfoData = taosArrayGet(p->pDataBlock, 9);
|
pColInfoData = taosArrayGet(p->pDataBlock, 9);
|
||||||
colDataAppend(pColInfoData, numOfRows, str, false);
|
colDataAppend(pColInfoData, numOfRows, str, false);
|
||||||
|
|
||||||
if (++numOfRows >= pInfo->capacity) {
|
if (++numOfRows >= pOperator->resultInfo.capacity) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1019,7 +993,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
pMsgSendInfo->msgInfo.pData = buf1;
|
pMsgSendInfo->msgInfo.pData = buf1;
|
||||||
pMsgSendInfo->msgInfo.len = contLen;
|
pMsgSendInfo->msgInfo.len = contLen;
|
||||||
pMsgSendInfo->msgType = TDMT_MND_SYSTABLE_RETRIEVE;
|
pMsgSendInfo->msgType = TDMT_MND_SYSTABLE_RETRIEVE;
|
||||||
pMsgSendInfo->fp = loadSysTableContentCb;
|
pMsgSendInfo->fp = loadSysTableCallback;
|
||||||
|
|
||||||
int64_t transporterId = 0;
|
int64_t transporterId = 0;
|
||||||
int32_t code = asyncSendMsgToServer(pInfo->pTransporter, &pInfo->epSet, &transporterId, pMsgSendInfo);
|
int32_t code = asyncSendMsgToServer(pInfo->pTransporter, &pInfo->epSet, &transporterId, pMsgSendInfo);
|
||||||
|
|
@ -1057,9 +1031,9 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo) {
|
int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity) {
|
||||||
SSDataBlock* p = buildSysTableMetaBlock();
|
SSDataBlock* p = buildSysTableMetaBlock();
|
||||||
blockDataEnsureCapacity(p, pInfo->capacity);
|
blockDataEnsureCapacity(p, capacity);
|
||||||
|
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
const SSysTableMeta* pSysDbTableMeta = NULL;
|
const SSysTableMeta* pSysDbTableMeta = NULL;
|
||||||
|
|
@ -1133,15 +1107,16 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSDataBlock* pRe
|
||||||
pInfo->accountId = accountId;
|
pInfo->accountId = accountId;
|
||||||
pInfo->showRewrite = showRewrite;
|
pInfo->showRewrite = showRewrite;
|
||||||
pInfo->pRes = pResBlock;
|
pInfo->pRes = pResBlock;
|
||||||
pInfo->capacity = 4096;
|
|
||||||
pInfo->pCondition = pCondition;
|
pInfo->pCondition = pCondition;
|
||||||
pInfo->scanCols = colList;
|
pInfo->scanCols = colList;
|
||||||
|
|
||||||
|
initResultSizeInfo(pOperator, 4096);
|
||||||
|
|
||||||
tNameAssign(&pInfo->name, pName);
|
tNameAssign(&pInfo->name, pName);
|
||||||
const char* name = tNameGetTableName(&pInfo->name);
|
const char* name = tNameGetTableName(&pInfo->name);
|
||||||
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
pInfo->readHandle = *(SReadHandle*) readHandle;
|
pInfo->readHandle = *(SReadHandle*) readHandle;
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pInfo->capacity);
|
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
} else {
|
} else {
|
||||||
tsem_init(&pInfo->ready, 0, 0);
|
tsem_init(&pInfo->ready, 0, 0);
|
||||||
pInfo->epSet = epset;
|
pInfo->epSet = epset;
|
||||||
|
|
@ -1172,7 +1147,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSDataBlock* pRe
|
||||||
|
|
||||||
pOperator->name = "SysTableScanOperator";
|
pOperator->name = "SysTableScanOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blocking = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->numOfOutput = pResBlock->info.numOfCols;
|
pOperator->numOfOutput = pResBlock->info.numOfCols;
|
||||||
|
|
@ -1183,9 +1158,8 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSDataBlock* pRe
|
||||||
return pOperator;
|
return pOperator;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doTagScan(SOperatorInfo* pOperator, bool* newgroup) {
|
static SSDataBlock* doTagScan(SOperatorInfo* pOperator) {
|
||||||
#if 0
|
#if 0
|
||||||
SOperatorInfo* pOperator = (SOperatorInfo*) param;
|
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -1319,29 +1293,29 @@ static void destroyTagScanOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
pInfo->pRes = blockDataDestroy(pInfo->pRes);
|
pInfo->pRes = blockDataDestroy(pInfo->pRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createTagScanOperatorInfo(void* pReaderHandle, SExprInfo* pExpr, int32_t numOfOutput,
|
SOperatorInfo* createTagScanOperatorInfo(void* readHandle, SExprInfo* pExpr, int32_t numOfOutput, SExecTaskInfo* pTaskInfo) {
|
||||||
SExecTaskInfo* pTaskInfo) {
|
|
||||||
STagScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STagScanInfo));
|
STagScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STagScanInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->pReader = pReaderHandle;
|
pInfo->pReader = readHandle;
|
||||||
pInfo->curPos = 0;
|
pInfo->curPos = 0;
|
||||||
pOperator->name = "TagScanOperator";
|
pOperator->name = "TagScanOperator";
|
||||||
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN;
|
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN;
|
||||||
pOperator->blockingOptr = false;
|
pOperator->blocking = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
|
|
||||||
pOperator->fpSet =
|
|
||||||
createOperatorFpSet(operatorDummyOpenFn, doTagScan, NULL, NULL, destroyTagScanOperatorInfo, NULL, NULL, NULL);
|
|
||||||
pOperator->pExpr = pExpr;
|
pOperator->pExpr = pExpr;
|
||||||
pOperator->numOfOutput = numOfOutput;
|
pOperator->numOfOutput = numOfOutput;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
|
pOperator->fpSet =
|
||||||
|
createOperatorFpSet(operatorDummyOpenFn, doTagScan, NULL, NULL, destroyTagScanOperatorInfo, NULL, NULL, NULL);
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
taosMemoryFree(pInfo);
|
taosMemoryFree(pInfo);
|
||||||
taosMemoryFree(pOperator);
|
taosMemoryFree(pOperator);
|
||||||
|
|
|
||||||
|
|
@ -13,20 +13,21 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "function.h"
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "querynodes.h"
|
|
||||||
|
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "tmsg.h"
|
#include "tmsg.h"
|
||||||
#include "ttypes.h"
|
#include "ttypes.h"
|
||||||
|
|
||||||
#include "tfill.h"
|
|
||||||
#include "function.h"
|
|
||||||
#include "tcommon.h"
|
#include "tcommon.h"
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
|
#include "function.h"
|
||||||
|
#include "tdatablock.h"
|
||||||
|
#include "executorInt.h"
|
||||||
|
#include "querynodes.h"
|
||||||
|
#include "tfill.h"
|
||||||
|
|
||||||
#define FILL_IS_ASC_FILL(_f) ((_f)->order == TSDB_ORDER_ASC)
|
#define FILL_IS_ASC_FILL(_f) ((_f)->order == TSDB_ORDER_ASC)
|
||||||
#define DO_INTERPOLATION(_v1, _v2, _k1, _k2, _k) ((_v1) + ((_v2) - (_v1)) * (((double)(_k)) - ((double)(_k1))) / (((double)(_k2)) - ((double)(_k1))))
|
#define DO_INTERPOLATION(_v1, _v2, _k1, _k2, _k) ((_v1) + ((_v2) - (_v1)) * (((double)(_k)) - ((double)(_k1))) / (((double)(_k2)) - ((double)(_k1))))
|
||||||
|
|
||||||
|
|
@ -37,168 +38,208 @@ static void setTagsValue(SFillInfo* pFillInfo, void** data, int32_t genRows) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* val1 = elePtrAt(data[j], pCol->col.bytes, genRows);
|
SResSchema* pSchema = &pCol->pExpr->base.resSchema;
|
||||||
|
char* val1 = elePtrAt(data[j], pSchema->bytes, genRows);
|
||||||
|
|
||||||
assert(pCol->tagIndex >= 0 && pCol->tagIndex < pFillInfo->numOfTags);
|
assert(pCol->tagIndex >= 0 && pCol->tagIndex < pFillInfo->numOfTags);
|
||||||
SFillTagColInfo* pTag = &pFillInfo->pTags[pCol->tagIndex];
|
SFillTagColInfo* pTag = &pFillInfo->pTags[pCol->tagIndex];
|
||||||
|
assignVal(val1, pTag->tagVal, pSchema->bytes, pSchema->type);
|
||||||
// assert (pTag->col.colId == pCol->col.colId);
|
|
||||||
assignVal(val1, pTag->tagVal, pCol->col.bytes, pCol->col.type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setNullValueForRow(SFillInfo* pFillInfo, void** data, int32_t numOfCol, int32_t rowIndex) {
|
static void setNullRow(SSDataBlock* pBlock, int32_t numOfCol, int32_t rowIndex) {
|
||||||
// the first are always the timestamp column, so start from the second column.
|
// the first are always the timestamp column, so start from the second column.
|
||||||
for (int32_t i = 1; i < numOfCol; ++i) {
|
for (int32_t i = 1; i < pBlock->info.numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SColumnInfoData* p = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
colDataAppendNULL(p, rowIndex);
|
||||||
char* output = elePtrAt(data[i], pCol->col.bytes, rowIndex);
|
|
||||||
setNull(output, pCol->col.type, pCol->col.bytes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doFillOneRowResult(SFillInfo* pFillInfo, void** data, char** srcData, int64_t ts, bool outOfBound) {
|
#define GET_DEST_SLOT_ID(_p) ((_p)->pExpr->base.resSchema.slotId)
|
||||||
char* prev = pFillInfo->prevValues;
|
#define GET_SRC_SLOT_ID(_p) ((_p)->pExpr->base.pParam[0].pCol->slotId)
|
||||||
char* next = pFillInfo->nextValues;
|
|
||||||
|
|
||||||
|
static void doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey);
|
||||||
|
|
||||||
|
static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock *pBlock, SSDataBlock* pSrcBlock, int64_t ts, bool outOfBound) {
|
||||||
SPoint point1, point2, point;
|
SPoint point1, point2, point;
|
||||||
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order);
|
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order);
|
||||||
|
|
||||||
// set the primary timestamp column value
|
// set the primary timestamp column value
|
||||||
int32_t index = pFillInfo->numOfCurrent;
|
int32_t index = pFillInfo->numOfCurrent;
|
||||||
char* val = elePtrAt(data[0], TSDB_KEYSIZE, index);
|
SColumnInfoData *pCol0 = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
|
char* val = colDataGetData(pCol0, index);
|
||||||
|
|
||||||
*(TSKEY*) val = pFillInfo->currentKey;
|
*(TSKEY*) val = pFillInfo->currentKey;
|
||||||
|
|
||||||
// set the other values
|
// set the other values
|
||||||
if (pFillInfo->type == TSDB_FILL_PREV) {
|
if (pFillInfo->type == TSDB_FILL_PREV) {
|
||||||
char* p = FILL_IS_ASC_FILL(pFillInfo) ? prev : next;
|
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev : pFillInfo->next;
|
||||||
|
|
||||||
if (p != NULL) {
|
|
||||||
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* output = elePtrAt(data[i], pCol->col.bytes, index);
|
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||||
// assignVal(output, p + pCol->offset, pCol->col.bytes, pCol->col.type);
|
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
||||||
}
|
doSetVal(pDstColInfoData, index, pKey);
|
||||||
} else { // no prev value yet, set the value for NULL
|
|
||||||
setNullValueForRow(pFillInfo, data, pFillInfo->numOfCols, index);
|
|
||||||
}
|
}
|
||||||
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
|
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
|
||||||
char* p = FILL_IS_ASC_FILL(pFillInfo)? next : prev;
|
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->next : pFillInfo->prev;
|
||||||
|
|
||||||
if (p != NULL) {
|
|
||||||
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* output = elePtrAt(data[i], pCol->col.bytes, index);
|
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||||
// assignVal(output, p + pCol->offset, pCol->col.bytes, pCol->col.type);
|
SColumnInfoData* pDstColInfoData = taosArrayGet(pBlock->pDataBlock, GET_DEST_SLOT_ID(pCol));
|
||||||
}
|
doSetVal(pDstColInfoData, index, pKey);
|
||||||
} else { // no prev value yet, set the value for NULL
|
|
||||||
setNullValueForRow(pFillInfo, data, pFillInfo->numOfCols, index);
|
|
||||||
}
|
}
|
||||||
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
|
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
|
||||||
// TODO : linear interpolation supports NULL value
|
// TODO : linear interpolation supports NULL value
|
||||||
if (prev != NULL && !outOfBound) {
|
if (outOfBound) {
|
||||||
|
setNullRow(pBlock, pFillInfo->numOfCols, index);
|
||||||
|
} else {
|
||||||
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t type = pCol->col.type;
|
int32_t srcSlotId = GET_SRC_SLOT_ID(pCol);
|
||||||
int16_t bytes = pCol->col.bytes;
|
|
||||||
|
|
||||||
char *val1 = elePtrAt(data[i], pCol->col.bytes, index);
|
int32_t dstSlotId = GET_DEST_SLOT_ID(pCol);
|
||||||
if (type == TSDB_DATA_TYPE_BINARY|| type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_BOOL) {
|
SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId);
|
||||||
setNull(val1, pCol->col.type, bytes);
|
|
||||||
|
int16_t type = pCol->pExpr->base.resSchema.type;
|
||||||
|
SGroupKeys* pKey = taosArrayGet(pFillInfo->prev, i);
|
||||||
|
if (IS_VAR_DATA_TYPE(type) || type == TSDB_DATA_TYPE_BOOL || pKey->isNull) {
|
||||||
|
colDataAppendNULL(pDstCol, index);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
point1 = (SPoint){.key = *(TSKEY*)(prev), .val = prev + pCol->offset};
|
SGroupKeys* pKey1 = taosArrayGet(pFillInfo->prev, 0);
|
||||||
point2 = (SPoint){.key = ts, .val = srcData[i] + pFillInfo->index * bytes};
|
int64_t prevTs = *(int64_t*)pKey1->pData;
|
||||||
point = (SPoint){.key = pFillInfo->currentKey, .val = val1};
|
|
||||||
|
SColumnInfoData* pSrcCol = taosArrayGet(pSrcBlock->pDataBlock, srcSlotId);
|
||||||
|
char* data = colDataGetData(pSrcCol, pFillInfo->index);
|
||||||
|
|
||||||
|
point1 = (SPoint){.key = prevTs, .val = pKey->pData};
|
||||||
|
point2 = (SPoint){.key = ts, .val = data};
|
||||||
|
|
||||||
|
int64_t out = 0;
|
||||||
|
point = (SPoint){.key = pFillInfo->currentKey, .val = &out};
|
||||||
taosGetLinearInterpolationVal(&point, type, &point1, &point2, type);
|
taosGetLinearInterpolationVal(&point, type, &point1, &point2, type);
|
||||||
|
|
||||||
|
colDataAppend(pDstCol, index, (const char*)&out, false);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
setNullValueForRow(pFillInfo, data, pFillInfo->numOfCols, index);
|
|
||||||
}
|
}
|
||||||
} else { // fill the default value */
|
} else if (pFillInfo->type == TSDB_FILL_NULL) { // fill with NULL
|
||||||
|
setNullRow(pBlock, pFillInfo->numOfCols, index);
|
||||||
|
} else { // fill with user specified value for each column
|
||||||
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
if (TSDB_COL_IS_TAG(pCol->flag)/* || IS_VAR_DATA_TYPE(pCol->col.type)*/) {
|
if (TSDB_COL_IS_TAG(pCol->flag)/* || IS_VAR_DATA_TYPE(pCol->schema.type)*/) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* val1 = elePtrAt(data[i], pCol->col.bytes, index);
|
SVariant* pVar = &pFillInfo->pFillCol[i].fillVal;
|
||||||
assignVal(val1, (char*)&pCol->val, pCol->col.bytes, pCol->col.type);
|
|
||||||
|
SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
if (pDst->info.type == TSDB_DATA_TYPE_FLOAT) {
|
||||||
|
float v = 0;
|
||||||
|
GET_TYPED_DATA(v, float, pVar->nType, &pVar->i);
|
||||||
|
colDataAppend(pDst, index, (char*)&v, false);
|
||||||
|
} else if (pDst->info.type == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
|
double v = 0;
|
||||||
|
GET_TYPED_DATA(v, double, pVar->nType, &pVar->i);
|
||||||
|
colDataAppend(pDst, index, (char*)&v, false);
|
||||||
|
} else if (IS_SIGNED_NUMERIC_TYPE(pDst->info.type)) {
|
||||||
|
int64_t v = 0;
|
||||||
|
GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i);
|
||||||
|
colDataAppend(pDst, index, (char*)&v, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setTagsValue(pFillInfo, data, index);
|
// setTagsValue(pFillInfo, data, index);
|
||||||
pFillInfo->currentKey = taosTimeAdd(pFillInfo->currentKey, pFillInfo->interval.sliding * step, pFillInfo->interval.slidingUnit,
|
SInterval* pInterval = &pFillInfo->interval;
|
||||||
pFillInfo->interval.precision);
|
pFillInfo->currentKey = taosTimeAdd(pFillInfo->currentKey, pInterval->sliding * step, pInterval->slidingUnit, pInterval->precision);
|
||||||
pFillInfo->numOfCurrent++;
|
pFillInfo->numOfCurrent++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initBeforeAfterDataBuf(SFillInfo* pFillInfo, char** next) {
|
void doSetVal(SColumnInfoData* pDstCol, int32_t rowIndex, const SGroupKeys* pKey) {
|
||||||
if (*next != NULL) {
|
if (pKey->isNull) {
|
||||||
|
colDataAppendNULL(pDstCol, rowIndex);
|
||||||
|
} else {
|
||||||
|
colDataAppend(pDstCol, rowIndex, pKey->pData, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void initBeforeAfterDataBuf(SFillInfo* pFillInfo) {
|
||||||
|
if (taosArrayGetSize(pFillInfo->next) > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*next = taosMemoryCalloc(1, pFillInfo->rowSize);
|
for (int i = 0; i < pFillInfo->numOfCols; i++) {
|
||||||
for (int i = 1; i < pFillInfo->numOfCols; i++) {
|
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
setNull(*next + pCol->offset, pCol->col.type, pCol->col.bytes);
|
|
||||||
|
SGroupKeys key = {0};
|
||||||
|
SResSchema* pSchema = &pCol->pExpr->base.resSchema;
|
||||||
|
key.pData = taosMemoryMalloc(pSchema->bytes);
|
||||||
|
key.isNull = true;
|
||||||
|
key.bytes = pSchema->bytes;
|
||||||
|
key.type = pSchema->type;
|
||||||
|
|
||||||
|
taosArrayPush(pFillInfo->next, &key);
|
||||||
|
|
||||||
|
key.pData = taosMemoryMalloc(pSchema->bytes);
|
||||||
|
taosArrayPush(pFillInfo->prev, &key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, char** srcData, char* buf) {
|
static void saveColData(SArray* rowBuf, int32_t columnIndex, const char* src, bool isNull);
|
||||||
int32_t rowIndex = pFillInfo->index;
|
|
||||||
|
static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SArray* pRow) {
|
||||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
int32_t srcSlotId = GET_SRC_SLOT_ID(&pFillInfo->pFillCol[i]);
|
||||||
memcpy(buf + pCol->offset, srcData[i] + rowIndex * pCol->col.bytes, pCol->col.bytes);
|
|
||||||
|
SColumnInfoData* pSrcCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, srcSlotId);
|
||||||
|
|
||||||
|
bool isNull = colDataIsNull_s(pSrcCol, rowIndex);
|
||||||
|
char* p = colDataGetData(pSrcCol, rowIndex);
|
||||||
|
saveColData(pRow, i, p, isNull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t fillResultImpl(SFillInfo* pFillInfo, void** data, int32_t outputRows) {
|
static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t outputRows) {
|
||||||
pFillInfo->numOfCurrent = 0;
|
pFillInfo->numOfCurrent = 0;
|
||||||
|
|
||||||
char** srcData = pFillInfo->pData;
|
// todo make sure the first column is always the primary timestamp column?
|
||||||
char** prev = &pFillInfo->prevValues;
|
SColumnInfoData* pTsCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, 0);
|
||||||
char** next = &pFillInfo->nextValues;
|
|
||||||
|
|
||||||
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order);
|
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order);
|
||||||
|
bool ascFill = FILL_IS_ASC_FILL(pFillInfo);
|
||||||
|
|
||||||
if (FILL_IS_ASC_FILL(pFillInfo)) {
|
#if 0
|
||||||
assert(pFillInfo->currentKey >= pFillInfo->start);
|
ASSERT(ascFill && (pFillInfo->currentKey >= pFillInfo->start) || (!ascFill && (pFillInfo->currentKey <= pFillInfo->start)));
|
||||||
} else {
|
#endif
|
||||||
assert(pFillInfo->currentKey <= pFillInfo->start);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (pFillInfo->numOfCurrent < outputRows) {
|
while (pFillInfo->numOfCurrent < outputRows) {
|
||||||
int64_t ts = ((int64_t*)pFillInfo->pData[0])[pFillInfo->index];
|
int64_t ts = ((int64_t*)pTsCol->pData)[pFillInfo->index];
|
||||||
|
|
||||||
// set the next value for interpolation
|
// set the next value for interpolation
|
||||||
if ((pFillInfo->currentKey < ts && FILL_IS_ASC_FILL(pFillInfo)) ||
|
if ((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) {
|
||||||
(pFillInfo->currentKey > ts && !FILL_IS_ASC_FILL(pFillInfo))) {
|
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pFillInfo->next);
|
||||||
initBeforeAfterDataBuf(pFillInfo, next);
|
|
||||||
copyCurrentRowIntoBuf(pFillInfo, srcData, *next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((pFillInfo->currentKey < ts && FILL_IS_ASC_FILL(pFillInfo)) || (pFillInfo->currentKey > ts && !FILL_IS_ASC_FILL(pFillInfo))) &&
|
if (((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) && pFillInfo->numOfCurrent < outputRows) {
|
||||||
pFillInfo->numOfCurrent < outputRows) {
|
// fill the gap between two input rows
|
||||||
|
while (((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) && pFillInfo->numOfCurrent < outputRows) {
|
||||||
// fill the gap between two actual input rows
|
doFillOneRowResult(pFillInfo, pBlock, pFillInfo->pSrcBlock, ts, false);
|
||||||
while (((pFillInfo->currentKey < ts && FILL_IS_ASC_FILL(pFillInfo)) ||
|
|
||||||
(pFillInfo->currentKey > ts && !FILL_IS_ASC_FILL(pFillInfo))) &&
|
|
||||||
pFillInfo->numOfCurrent < outputRows) {
|
|
||||||
doFillOneRowResult(pFillInfo, data, srcData, ts, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// output buffer is full, abort
|
// output buffer is full, abort
|
||||||
|
|
@ -208,61 +249,66 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, void** data, int32_t outputR
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(pFillInfo->currentKey == ts);
|
assert(pFillInfo->currentKey == ts);
|
||||||
initBeforeAfterDataBuf(pFillInfo, prev);
|
|
||||||
if (pFillInfo->type == TSDB_FILL_NEXT && (pFillInfo->index + 1) < pFillInfo->numOfRows) {
|
if (pFillInfo->type == TSDB_FILL_NEXT && (pFillInfo->index + 1) < pFillInfo->numOfRows) {
|
||||||
initBeforeAfterDataBuf(pFillInfo, next);
|
|
||||||
++pFillInfo->index;
|
++pFillInfo->index;
|
||||||
copyCurrentRowIntoBuf(pFillInfo, srcData, *next);
|
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pFillInfo->next);
|
||||||
--pFillInfo->index;
|
--pFillInfo->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign rows to dst buffer
|
// assign rows to dst buffer
|
||||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||||
if (TSDB_COL_IS_TAG(pCol->flag)/* || IS_VAR_DATA_TYPE(pCol->col.type)*/) {
|
if (TSDB_COL_IS_TAG(pCol->flag)/* || IS_VAR_DATA_TYPE(pCol->schema.type)*/) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* output = elePtrAt(data[i], pCol->col.bytes, pFillInfo->numOfCurrent);
|
int32_t srcSlotId = GET_SRC_SLOT_ID(pCol);
|
||||||
char* src = elePtrAt(srcData[i], pCol->col.bytes, pFillInfo->index);
|
int32_t dstSlotId = GET_DEST_SLOT_ID(pCol);
|
||||||
|
|
||||||
if (i == 0 || (pCol->functionId != FUNCTION_COUNT && !isNull(src, pCol->col.type)) ||
|
SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, dstSlotId);
|
||||||
(pCol->functionId == FUNCTION_COUNT && GET_INT64_VAL(src) != 0)) {
|
SColumnInfoData* pSrc = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, srcSlotId);
|
||||||
assignVal(output, src, pCol->col.bytes, pCol->col.type);
|
|
||||||
memcpy(*prev + pCol->offset, src, pCol->col.bytes);
|
char* src = colDataGetData(pSrc, pFillInfo->index);
|
||||||
|
if (i == 0 || (/*pCol->functionId != FUNCTION_COUNT &&*/ !colDataIsNull_s(pSrc, pFillInfo->index)) /*||
|
||||||
|
(pCol->functionId == FUNCTION_COUNT && GET_INT64_VAL(src) != 0)*/) {
|
||||||
|
bool isNull = colDataIsNull_s(pSrc, pFillInfo->index);
|
||||||
|
colDataAppend(pDst, pFillInfo->numOfCurrent, src, isNull);
|
||||||
|
saveColData(pFillInfo->prev, i, src, isNull);
|
||||||
} else { // i > 0 and data is null , do interpolation
|
} else { // i > 0 and data is null , do interpolation
|
||||||
if (pFillInfo->type == TSDB_FILL_PREV) {
|
if (pFillInfo->type == TSDB_FILL_PREV) {
|
||||||
assignVal(output, *prev + pCol->offset, pCol->col.bytes, pCol->col.type);
|
SGroupKeys *pKey = taosArrayGet(pFillInfo->prev, i);
|
||||||
|
doSetVal(pDst, pFillInfo->numOfCurrent, pKey);
|
||||||
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
|
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
|
||||||
assignVal(output, src, pCol->col.bytes, pCol->col.type);
|
bool isNull = colDataIsNull_s(pSrc, pFillInfo->index);
|
||||||
memcpy(*prev + pCol->offset, src, pCol->col.bytes);
|
colDataAppend(pDst, pFillInfo->numOfCurrent, src, isNull);
|
||||||
|
saveColData(pFillInfo->prev, i, src, isNull);
|
||||||
|
} else if (pFillInfo->type == TSDB_FILL_NULL) {
|
||||||
|
colDataAppendNULL(pDst, pFillInfo->numOfCurrent);
|
||||||
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
|
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
|
||||||
if (*next) {
|
SGroupKeys *pKey = taosArrayGet(pFillInfo->next, i);
|
||||||
assignVal(output, *next + pCol->offset, pCol->col.bytes, pCol->col.type);
|
doSetVal(pDst, pFillInfo->numOfCurrent, pKey);
|
||||||
} else {
|
} else {
|
||||||
setNull(output, pCol->col.type, pCol->col.bytes);
|
SVariant* pVar = &pFillInfo->pFillCol[i].fillVal;
|
||||||
}
|
colDataAppend(pDst, pFillInfo->numOfCurrent, (char*)&pVar->i, false);
|
||||||
} else {
|
|
||||||
assignVal(output, (char*)&pCol->val, pCol->col.bytes, pCol->col.type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the tag value for final result
|
// set the tag value for final result
|
||||||
setTagsValue(pFillInfo, data, pFillInfo->numOfCurrent);
|
// setTagsValue(pFillInfo, data, pFillInfo->numOfCurrent);
|
||||||
|
SInterval *pInterval = &pFillInfo->interval;
|
||||||
|
pFillInfo->currentKey = taosTimeAdd(pFillInfo->currentKey, pInterval->sliding * step, pInterval->slidingUnit, pInterval->precision);
|
||||||
|
|
||||||
pFillInfo->currentKey = taosTimeAdd(pFillInfo->currentKey, pFillInfo->interval.sliding * step,
|
|
||||||
pFillInfo->interval.slidingUnit, pFillInfo->interval.precision);
|
|
||||||
pFillInfo->index += 1;
|
pFillInfo->index += 1;
|
||||||
pFillInfo->numOfCurrent += 1;
|
pFillInfo->numOfCurrent += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pFillInfo->index >= pFillInfo->numOfRows || pFillInfo->numOfCurrent >= outputRows) {
|
if (pFillInfo->index >= pFillInfo->numOfRows || pFillInfo->numOfCurrent >= outputRows) {
|
||||||
/* the raw data block is exhausted, next value does not exists */
|
/* the raw data block is exhausted, next value does not exists */
|
||||||
if (pFillInfo->index >= pFillInfo->numOfRows) {
|
// if (pFillInfo->index >= pFillInfo->numOfRows) {
|
||||||
taosMemoryFreeClear(*next);
|
// taosMemoryFreeClear(*next);
|
||||||
}
|
// }
|
||||||
|
|
||||||
pFillInfo->numOfTotal += pFillInfo->numOfCurrent;
|
pFillInfo->numOfTotal += pFillInfo->numOfCurrent;
|
||||||
return pFillInfo->numOfCurrent;
|
return pFillInfo->numOfCurrent;
|
||||||
}
|
}
|
||||||
|
|
@ -271,14 +317,24 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, void** data, int32_t outputR
|
||||||
return pFillInfo->numOfCurrent;
|
return pFillInfo->numOfCurrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t appendFilledResult(SFillInfo* pFillInfo, void** output, int64_t resultCapacity) {
|
static void saveColData(SArray* rowBuf, int32_t columnIndex, const char* src, bool isNull) {
|
||||||
|
SGroupKeys *pKey = taosArrayGet(rowBuf, columnIndex);
|
||||||
|
if (isNull) {
|
||||||
|
pKey->isNull = true;
|
||||||
|
} else {
|
||||||
|
memcpy(pKey->pData, src, pKey->bytes);
|
||||||
|
pKey->isNull = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64_t appendFilledResult(SFillInfo* pFillInfo, SSDataBlock* pBlock, int64_t resultCapacity) {
|
||||||
/*
|
/*
|
||||||
* These data are generated according to fill strategy, since the current timestamp is out of the time window of
|
* These data are generated according to fill strategy, since the current timestamp is out of the time window of
|
||||||
* real result set. Note that we need to keep the direct previous result rows, to generated the filled data.
|
* real result set. Note that we need to keep the direct previous result rows, to generated the filled data.
|
||||||
*/
|
*/
|
||||||
pFillInfo->numOfCurrent = 0;
|
pFillInfo->numOfCurrent = 0;
|
||||||
while (pFillInfo->numOfCurrent < resultCapacity) {
|
while (pFillInfo->numOfCurrent < resultCapacity) {
|
||||||
doFillOneRowResult(pFillInfo, output, pFillInfo->pData, pFillInfo->start, true);
|
doFillOneRowResult(pFillInfo, pBlock, pFillInfo->pSrcBlock, pFillInfo->start, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFillInfo->numOfTotal += pFillInfo->numOfCurrent;
|
pFillInfo->numOfTotal += pFillInfo->numOfCurrent;
|
||||||
|
|
@ -295,15 +351,15 @@ static int32_t setTagColumnInfo(SFillInfo* pFillInfo, int32_t numOfCols, int32_t
|
||||||
int32_t k = 0;
|
int32_t k = 0;
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
SFillColInfo* pColInfo = &pFillInfo->pFillCol[i];
|
SFillColInfo* pColInfo = &pFillInfo->pFillCol[i];
|
||||||
pFillInfo->pData[i] = NULL;
|
SResSchema* pSchema = &pColInfo->pExpr->base.resSchema;
|
||||||
|
|
||||||
if (TSDB_COL_IS_TAG(pColInfo->flag) || pColInfo->col.type == TSDB_DATA_TYPE_BINARY) {
|
if (TSDB_COL_IS_TAG(pColInfo->flag) || pSchema->type == TSDB_DATA_TYPE_BINARY) {
|
||||||
numOfTags += 1;
|
numOfTags += 1;
|
||||||
|
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
int32_t index = -1;
|
int32_t index = -1;
|
||||||
for (int32_t j = 0; j < k; ++j) {
|
for (int32_t j = 0; j < k; ++j) {
|
||||||
if (pFillInfo->pTags[j].col.colId == pColInfo->col.slotId) {
|
if (pFillInfo->pTags[j].col.colId == pSchema->slotId) {
|
||||||
exists = true;
|
exists = true;
|
||||||
index = j;
|
index = j;
|
||||||
break;
|
break;
|
||||||
|
|
@ -311,12 +367,12 @@ static int32_t setTagColumnInfo(SFillInfo* pFillInfo, int32_t numOfCols, int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
SSchema* pSchema = &pFillInfo->pTags[k].col;
|
SSchema* pSchema1 = &pFillInfo->pTags[k].col;
|
||||||
pSchema->colId = pColInfo->col.slotId;
|
pSchema1->colId = pSchema->slotId;
|
||||||
pSchema->type = pColInfo->col.type;
|
pSchema1->type = pSchema->type;
|
||||||
pSchema->bytes = pColInfo->col.bytes;
|
pSchema1->bytes = pSchema->bytes;
|
||||||
|
|
||||||
pFillInfo->pTags[k].tagVal = taosMemoryCalloc(1, pColInfo->col.bytes);
|
pFillInfo->pTags[k].tagVal = taosMemoryCalloc(1, pSchema->bytes);
|
||||||
pColInfo->tagIndex = k;
|
pColInfo->tagIndex = k;
|
||||||
|
|
||||||
k += 1;
|
k += 1;
|
||||||
|
|
@ -325,7 +381,7 @@ static int32_t setTagColumnInfo(SFillInfo* pFillInfo, int32_t numOfCols, int32_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rowsize += pColInfo->col.bytes;
|
rowsize += pSchema->bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFillInfo->numOfTags = numOfTags;
|
pFillInfo->numOfTags = numOfTags;
|
||||||
|
|
@ -355,7 +411,6 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
|
||||||
}
|
}
|
||||||
|
|
||||||
taosResetFillInfo(pFillInfo, skey);
|
taosResetFillInfo(pFillInfo, skey);
|
||||||
|
|
||||||
pFillInfo->order = order;
|
pFillInfo->order = order;
|
||||||
|
|
||||||
switch(fillType) {
|
switch(fillType) {
|
||||||
|
|
@ -364,6 +419,7 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
|
||||||
case FILL_MODE_NULL: pFillInfo->type = TSDB_FILL_NULL; break;
|
case FILL_MODE_NULL: pFillInfo->type = TSDB_FILL_NULL; break;
|
||||||
case FILL_MODE_LINEAR: pFillInfo->type = TSDB_FILL_LINEAR;break;
|
case FILL_MODE_LINEAR: pFillInfo->type = TSDB_FILL_LINEAR;break;
|
||||||
case FILL_MODE_NEXT: pFillInfo->type = TSDB_FILL_NEXT; break;
|
case FILL_MODE_NEXT: pFillInfo->type = TSDB_FILL_NEXT; break;
|
||||||
|
case FILL_MODE_VALUE: pFillInfo->type = TSDB_FILL_SET_VALUE; break;
|
||||||
default:
|
default:
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -376,7 +432,6 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
|
||||||
pFillInfo->alloc = capacity;
|
pFillInfo->alloc = capacity;
|
||||||
pFillInfo->id = id;
|
pFillInfo->id = id;
|
||||||
pFillInfo->interval = *pInterval;
|
pFillInfo->interval = *pInterval;
|
||||||
pFillInfo->pData = taosMemoryMalloc(POINTER_BYTES * numOfCols);
|
|
||||||
|
|
||||||
// if (numOfTags > 0) {
|
// if (numOfTags > 0) {
|
||||||
pFillInfo->pTags = taosMemoryCalloc(numOfCols, sizeof(SFillTagColInfo));
|
pFillInfo->pTags = taosMemoryCalloc(numOfCols, sizeof(SFillTagColInfo));
|
||||||
|
|
@ -385,6 +440,11 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
pFillInfo->next = taosArrayInit(numOfCols, sizeof(SGroupKeys));
|
||||||
|
pFillInfo->prev = taosArrayInit(numOfCols, sizeof(SGroupKeys));
|
||||||
|
|
||||||
|
initBeforeAfterDataBuf(pFillInfo);
|
||||||
|
|
||||||
pFillInfo->rowSize = setTagColumnInfo(pFillInfo, pFillInfo->numOfCols, pFillInfo->alloc);
|
pFillInfo->rowSize = setTagColumnInfo(pFillInfo, pFillInfo->numOfCols, pFillInfo->alloc);
|
||||||
assert(pFillInfo->rowSize > 0);
|
assert(pFillInfo->rowSize > 0);
|
||||||
return pFillInfo;
|
return pFillInfo;
|
||||||
|
|
@ -405,18 +465,15 @@ void* taosDestroyFillInfo(SFillInfo* pFillInfo) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(pFillInfo->prevValues);
|
taosArrayDestroy(pFillInfo->prev);
|
||||||
taosMemoryFreeClear(pFillInfo->nextValues);
|
taosArrayDestroy(pFillInfo->next);
|
||||||
|
|
||||||
for(int32_t i = 0; i < pFillInfo->numOfTags; ++i) {
|
for(int32_t i = 0; i < pFillInfo->numOfTags; ++i) {
|
||||||
taosMemoryFreeClear(pFillInfo->pTags[i].tagVal);
|
taosMemoryFreeClear(pFillInfo->pTags[i].tagVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(pFillInfo->pTags);
|
taosMemoryFreeClear(pFillInfo->pTags);
|
||||||
|
|
||||||
taosMemoryFreeClear(pFillInfo->pData);
|
|
||||||
taosMemoryFreeClear(pFillInfo->pFillCol);
|
taosMemoryFreeClear(pFillInfo->pFillCol);
|
||||||
|
|
||||||
taosMemoryFreeClear(pFillInfo);
|
taosMemoryFreeClear(pFillInfo);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -436,18 +493,7 @@ void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosFillSetInputDataBlock(SFillInfo* pFillInfo, const SSDataBlock* pInput) {
|
void taosFillSetInputDataBlock(SFillInfo* pFillInfo, const SSDataBlock* pInput) {
|
||||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
pFillInfo->pSrcBlock = (SSDataBlock*) pInput;
|
||||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
|
||||||
|
|
||||||
SColumnInfoData* pColData = taosArrayGet(pInput->pDataBlock, i);
|
|
||||||
pFillInfo->pData[i] = pColData->pData;
|
|
||||||
|
|
||||||
if (TSDB_COL_IS_TAG(pCol->flag)) { // copy the tag value to tag value buffer
|
|
||||||
SFillTagColInfo* pTag = &pFillInfo->pTags[pCol->tagIndex];
|
|
||||||
assert (pTag->col.colId == pCol->col.slotId);
|
|
||||||
memcpy(pTag->tagVal, pColData->pData, pCol->col.bytes); // TODO not memcpy??
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosFillHasMoreResults(SFillInfo* pFillInfo) {
|
bool taosFillHasMoreResults(SFillInfo* pFillInfo) {
|
||||||
|
|
@ -465,8 +511,9 @@ bool taosFillHasMoreResults(SFillInfo* pFillInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t maxNumOfRows) {
|
int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t maxNumOfRows) {
|
||||||
int64_t* tsList = (int64_t*) pFillInfo->pData[0];
|
SColumnInfoData* pCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, 0);
|
||||||
|
|
||||||
|
int64_t* tsList = (int64_t*) pCol->pData;
|
||||||
int32_t numOfRows = taosNumOfRemainRows(pFillInfo);
|
int32_t numOfRows = taosNumOfRemainRows(pFillInfo);
|
||||||
|
|
||||||
TSKEY ekey1 = ekey;
|
TSKEY ekey1 = ekey;
|
||||||
|
|
@ -513,7 +560,7 @@ int32_t taosGetLinearInterpolationVal(SPoint* point, int32_t outputType, SPoint*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t taosFillResultDataBlock(SFillInfo* pFillInfo, void** output, int32_t capacity) {
|
int64_t taosFillResultDataBlock(SFillInfo* pFillInfo, SSDataBlock* p, int32_t capacity) {
|
||||||
int32_t remain = taosNumOfRemainRows(pFillInfo);
|
int32_t remain = taosNumOfRemainRows(pFillInfo);
|
||||||
|
|
||||||
int64_t numOfRes = getNumOfResultsAfterFillGap(pFillInfo, pFillInfo->end, capacity);
|
int64_t numOfRes = getNumOfResultsAfterFillGap(pFillInfo, pFillInfo->end, capacity);
|
||||||
|
|
@ -521,9 +568,9 @@ int64_t taosFillResultDataBlock(SFillInfo* pFillInfo, void** output, int32_t cap
|
||||||
|
|
||||||
// no data existed for fill operation now, append result according to the fill strategy
|
// no data existed for fill operation now, append result according to the fill strategy
|
||||||
if (remain == 0) {
|
if (remain == 0) {
|
||||||
appendFilledResult(pFillInfo, output, numOfRes);
|
appendFilledResult(pFillInfo, p, numOfRes);
|
||||||
} else {
|
} else {
|
||||||
fillResultImpl(pFillInfo, output, (int32_t) numOfRes);
|
fillResultImpl(pFillInfo, p, (int32_t) numOfRes);
|
||||||
assert(numOfRes == pFillInfo->numOfCurrent);
|
assert(numOfRes == pFillInfo->numOfCurrent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -538,28 +585,30 @@ int64_t getFillInfoStart(struct SFillInfo *pFillInfo) {
|
||||||
return pFillInfo->start;
|
return pFillInfo->start;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const struct SValueNode* val) {
|
SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const struct SNodeListNode* pValNode) {
|
||||||
int32_t offset = 0;
|
SFillColInfo* pFillCol = taosMemoryCalloc(numOfOutput, sizeof(SFillColInfo));
|
||||||
|
|
||||||
struct SFillColInfo* pFillCol = taosMemoryCalloc(numOfOutput, sizeof(SFillColInfo));
|
|
||||||
if (pFillCol == NULL) {
|
if (pFillCol == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t len = (pValNode != NULL)? LIST_LENGTH(pValNode->pNodeList):0;
|
||||||
for(int32_t i = 0; i < numOfOutput; ++i) {
|
for(int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
SExprInfo* pExprInfo = &pExpr[i];
|
SExprInfo* pExprInfo = &pExpr[i];
|
||||||
|
pFillCol[i].pExpr = pExprInfo;
|
||||||
pFillCol[i].col = pExprInfo->base.resSchema;
|
|
||||||
pFillCol[i].offset = offset;
|
|
||||||
pFillCol[i].tagIndex = -2;
|
pFillCol[i].tagIndex = -2;
|
||||||
|
|
||||||
|
// todo refactor
|
||||||
|
if (len > 0) {
|
||||||
|
// if the user specified value is less than the column, alway use the last one as the fill value
|
||||||
|
int32_t index = (i >= len)? (len - 1):i;
|
||||||
|
|
||||||
|
SValueNode* pv = (SValueNode*)nodesListGetNode(pValNode->pNodeList, index);
|
||||||
|
valueNodeToVariant(pv, &pFillCol[i].fillVal);
|
||||||
|
}
|
||||||
|
|
||||||
if (pExprInfo->base.numOfParams > 0) {
|
if (pExprInfo->base.numOfParams > 0) {
|
||||||
pFillCol[i].flag = pExprInfo->base.pParam[0].pCol->flag; // always be the normal column for table query
|
pFillCol[i].flag = pExprInfo->base.pParam[0].pCol->flag; // always be the normal column for table query
|
||||||
}
|
}
|
||||||
// pFillCol[i].functionId = pExprInfo->pExpr->_function.functionId;
|
|
||||||
// pFillCol[i].val.d = *val;
|
|
||||||
|
|
||||||
offset += pExprInfo->base.resSchema.bytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pFillCol;
|
return pFillCol;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -374,18 +374,17 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
|
||||||
|
|
||||||
for(int32_t i = 0; i < pInfo->size; ++i) {
|
for(int32_t i = 0; i < pInfo->size; ++i) {
|
||||||
SBlockOrderInfo* pOrder = TARRAY_GET_ELEM(pInfo, i);
|
SBlockOrderInfo* pOrder = TARRAY_GET_ELEM(pInfo, i);
|
||||||
|
|
||||||
SColumnInfoData* pLeftColInfoData = TARRAY_GET_ELEM(pLeftBlock->pDataBlock, pOrder->slotId);
|
SColumnInfoData* pLeftColInfoData = TARRAY_GET_ELEM(pLeftBlock->pDataBlock, pOrder->slotId);
|
||||||
|
|
||||||
bool leftNull = false;
|
bool leftNull = false;
|
||||||
if (pLeftColInfoData->hasNull) {
|
if (pLeftColInfoData->hasNull) {
|
||||||
leftNull = colDataIsNull(pLeftColInfoData, pLeftBlock->info.rows, pLeftSource->src.rowIndex, pLeftBlock->pBlockAgg);
|
leftNull = colDataIsNull(pLeftColInfoData, pLeftBlock->info.rows, pLeftSource->src.rowIndex, pLeftBlock->pBlockAgg[pOrder->slotId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
SColumnInfoData* pRightColInfoData = TARRAY_GET_ELEM(pRightBlock->pDataBlock, pOrder->slotId);
|
SColumnInfoData* pRightColInfoData = TARRAY_GET_ELEM(pRightBlock->pDataBlock, pOrder->slotId);
|
||||||
bool rightNull = false;
|
bool rightNull = false;
|
||||||
if (pRightColInfoData->hasNull) {
|
if (pRightColInfoData->hasNull) {
|
||||||
rightNull = colDataIsNull(pRightColInfoData, pRightBlock->info.rows, pRightSource->src.rowIndex, pRightBlock->pBlockAgg);
|
rightNull = colDataIsNull(pRightColInfoData, pRightBlock->info.rows, pRightSource->src.rowIndex, pRightBlock->pBlockAgg[pOrder->slotId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftNull && rightNull) {
|
if (leftNull && rightNull) {
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue