2021-09-22 05:21:07 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can use, redistribute, and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3
|
|
|
|
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2021-09-22 12:29:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _TD_VNODE_H_
|
|
|
|
|
#define _TD_VNODE_H_
|
|
|
|
|
|
2021-11-09 05:24:22 +00:00
|
|
|
#include "os.h"
|
2022-03-21 11:08:25 +00:00
|
|
|
#include "tmsgcb.h"
|
2022-03-29 10:58:15 +00:00
|
|
|
#include "tqueue.h"
|
|
|
|
|
#include "trpc.h"
|
2021-11-09 05:24:22 +00:00
|
|
|
|
2022-04-19 09:07:42 +00:00
|
|
|
#include "sync.h"
|
2021-11-11 03:41:16 +00:00
|
|
|
#include "tarray.h"
|
2022-01-19 06:04:01 +00:00
|
|
|
#include "tfs.h"
|
2021-11-24 08:29:02 +00:00
|
|
|
#include "wal.h"
|
2021-11-01 11:49:44 +00:00
|
|
|
|
2022-04-14 02:01:04 +00:00
|
|
|
#include "tcommon.h"
|
|
|
|
|
#include "tfs.h"
|
2022-07-23 07:32:18 +00:00
|
|
|
#include "tgrant.h"
|
2022-04-08 06:09:15 +00:00
|
|
|
#include "tmsg.h"
|
|
|
|
|
#include "trow.h"
|
|
|
|
|
|
2022-04-28 07:02:49 +00:00
|
|
|
#include "tdb.h"
|
2022-04-24 06:19:12 +00:00
|
|
|
|
2021-09-22 12:29:24 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
2022-05-01 16:30:47 +00:00
|
|
|
|
2022-04-14 02:01:04 +00:00
|
|
|
// vnode
|
2022-07-04 06:47:41 +00:00
|
|
|
typedef struct SVnode SVnode;
|
|
|
|
|
typedef struct STsdbCfg STsdbCfg; // todo: remove
|
|
|
|
|
typedef struct SVnodeCfg SVnodeCfg;
|
|
|
|
|
typedef struct SVSnapReader SVSnapReader;
|
|
|
|
|
typedef struct SVSnapWriter SVSnapWriter;
|
2022-04-14 02:10:56 +00:00
|
|
|
|
2022-04-19 01:57:46 +00:00
|
|
|
extern const SVnodeCfg vnodeCfgDefault;
|
|
|
|
|
|
2022-05-20 02:30:48 +00:00
|
|
|
int32_t vnodeInit(int32_t nthreads);
|
2022-04-14 02:01:04 +00:00
|
|
|
void vnodeCleanup();
|
2022-05-20 02:30:48 +00:00
|
|
|
int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs);
|
2022-10-20 08:47:03 +00:00
|
|
|
int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs);
|
2022-04-16 07:04:25 +00:00
|
|
|
void vnodeDestroy(const char *path, STfs *pTfs);
|
2022-04-16 07:16:10 +00:00
|
|
|
SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb);
|
2022-07-12 06:46:52 +00:00
|
|
|
void vnodePreClose(SVnode *pVnode);
|
2022-04-14 02:01:04 +00:00
|
|
|
void vnodeClose(SVnode *pVnode);
|
2022-07-06 07:15:55 +00:00
|
|
|
|
2022-04-25 07:39:52 +00:00
|
|
|
int32_t vnodeStart(SVnode *pVnode);
|
|
|
|
|
void vnodeStop(SVnode *pVnode);
|
2022-04-19 09:07:42 +00:00
|
|
|
int64_t vnodeGetSyncHandle(SVnode *pVnode);
|
2022-04-20 11:30:18 +00:00
|
|
|
void vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnapshot);
|
2022-04-27 07:17:15 +00:00
|
|
|
void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId);
|
2022-06-01 07:06:12 +00:00
|
|
|
int32_t vnodeProcessCreateTSma(SVnode *pVnode, void *pCont, uint32_t contLen);
|
2022-06-20 02:38:08 +00:00
|
|
|
int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list);
|
2022-09-28 14:07:16 +00:00
|
|
|
|
2022-06-20 02:38:08 +00:00
|
|
|
int32_t vnodeGetCtbIdList(SVnode *pVnode, int64_t suid, SArray *list);
|
2022-09-28 14:07:16 +00:00
|
|
|
int32_t vnodeGetCtbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bool (*filter)(void *arg), void *arg);
|
2022-08-25 08:22:55 +00:00
|
|
|
int32_t vnodeGetStbIdList(SVnode *pVnode, int64_t suid, SArray *list);
|
2022-07-07 09:16:12 +00:00
|
|
|
void *vnodeGetIdx(SVnode *pVnode);
|
|
|
|
|
void *vnodeGetIvtIdx(SVnode *pVnode);
|
2022-04-19 09:07:42 +00:00
|
|
|
|
2022-08-01 10:01:44 +00:00
|
|
|
int32_t vnodeGetCtbNum(SVnode *pVnode, int64_t suid, int64_t *num);
|
|
|
|
|
int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num);
|
|
|
|
|
int32_t vnodeGetAllCtbNum(SVnode *pVnode, int64_t *num);
|
|
|
|
|
|
2022-10-11 10:22:29 +00:00
|
|
|
void vnodeResetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
2022-07-06 07:15:55 +00:00
|
|
|
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
|
|
|
|
|
int32_t vnodeValidateTableHash(SVnode *pVnode, char *tableFName);
|
|
|
|
|
|
|
|
|
|
int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
|
|
|
|
int32_t vnodePreprocessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
|
|
|
|
|
|
|
|
|
int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp);
|
|
|
|
|
int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
|
|
|
|
int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
|
|
|
|
int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo);
|
|
|
|
|
void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs);
|
|
|
|
|
void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs);
|
2022-06-08 06:44:42 +00:00
|
|
|
|
2022-04-14 02:01:04 +00:00
|
|
|
// meta
|
2022-04-24 05:38:56 +00:00
|
|
|
typedef struct SMeta SMeta; // todo: remove
|
|
|
|
|
typedef struct SMetaReader SMetaReader;
|
|
|
|
|
typedef struct SMetaEntry SMetaEntry;
|
|
|
|
|
|
2022-10-10 07:04:33 +00:00
|
|
|
#define META_READER_NOLOCK 0x1
|
|
|
|
|
|
2022-05-12 11:21:44 +00:00
|
|
|
void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags);
|
2022-10-12 09:44:42 +00:00
|
|
|
void metaReaderReleaseLock(SMetaReader *pReader);
|
2022-05-12 11:21:44 +00:00
|
|
|
void metaReaderClear(SMetaReader *pReader);
|
2022-05-20 02:30:48 +00:00
|
|
|
int32_t metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid);
|
2022-09-28 08:30:40 +00:00
|
|
|
int metaGetTableEntryByName(SMetaReader *pReader, const char *name);
|
2022-08-17 06:45:31 +00:00
|
|
|
int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHashObj *tags);
|
2022-10-05 10:32:30 +00:00
|
|
|
int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList, SHashObj *tags);
|
2022-05-20 02:30:48 +00:00
|
|
|
int32_t metaReadNext(SMetaReader *pReader);
|
2022-08-12 03:33:53 +00:00
|
|
|
const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal);
|
2022-08-02 14:23:33 +00:00
|
|
|
int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName);
|
2022-11-27 05:50:36 +00:00
|
|
|
int metaGetTableSzNameByUid(void *meta, uint64_t uid, char *tbName);
|
2022-10-05 10:32:30 +00:00
|
|
|
int metaGetTableUidByName(void *meta, char *tbName, int64_t *uid);
|
2022-09-30 01:31:19 +00:00
|
|
|
int metaGetTableTypeByName(void *meta, char *tbName, ETableType *tbType);
|
2022-08-25 08:22:55 +00:00
|
|
|
bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid);
|
2022-11-25 15:00:14 +00:00
|
|
|
tb_uid_t metaGetTableEntryUidByName(SMeta* pMeta, const char* name);
|
|
|
|
|
int64_t metaGetTbNum(SMeta* pMeta);
|
2022-04-14 02:10:56 +00:00
|
|
|
|
2022-11-18 03:53:33 +00:00
|
|
|
typedef struct {
|
|
|
|
|
int64_t uid;
|
|
|
|
|
int64_t ctbNum;
|
|
|
|
|
} SMetaStbStats;
|
|
|
|
|
int32_t metaGetStbStats(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo);
|
|
|
|
|
|
2022-05-31 10:34:17 +00:00
|
|
|
typedef struct SMetaFltParam {
|
|
|
|
|
tb_uid_t suid;
|
|
|
|
|
int16_t cid;
|
|
|
|
|
int16_t type;
|
2022-07-30 02:30:58 +00:00
|
|
|
void *val;
|
2022-05-31 10:34:17 +00:00
|
|
|
bool reverse;
|
|
|
|
|
int (*filterFunc)(void *a, void *b, int16_t type);
|
|
|
|
|
|
|
|
|
|
} SMetaFltParam;
|
|
|
|
|
|
2022-10-19 09:54:06 +00:00
|
|
|
// TODO, refactor later
|
2022-07-23 07:32:18 +00:00
|
|
|
int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *results);
|
2022-10-19 09:54:06 +00:00
|
|
|
int32_t metaFilterCreateTime(SMeta *pMeta, SMetaFltParam *parm, SArray *pUids);
|
|
|
|
|
int32_t metaFilterTableName(SMeta *pMeta, SMetaFltParam *param, SArray *pUids);
|
|
|
|
|
int32_t metaFilterTtl(SMeta *pMeta, SMetaFltParam *param, SArray *pUids);
|
2022-05-31 10:34:17 +00:00
|
|
|
|
2022-04-24 06:19:12 +00:00
|
|
|
#if 1 // refact APIs below (TODO)
|
2022-04-14 02:10:56 +00:00
|
|
|
typedef SVCreateTbReq STbCfg;
|
|
|
|
|
typedef SVCreateTSmaReq SSmaCfg;
|
|
|
|
|
|
2022-04-24 05:38:56 +00:00
|
|
|
typedef struct SMTbCursor SMTbCursor;
|
|
|
|
|
|
2022-04-14 02:53:10 +00:00
|
|
|
SMTbCursor *metaOpenTbCursor(SMeta *pMeta);
|
|
|
|
|
void metaCloseTbCursor(SMTbCursor *pTbCur);
|
2022-05-20 02:30:48 +00:00
|
|
|
int32_t metaTbCursorNext(SMTbCursor *pTbCur);
|
2022-04-24 05:38:56 +00:00
|
|
|
#endif
|
2022-04-08 06:09:15 +00:00
|
|
|
|
2022-04-14 02:01:04 +00:00
|
|
|
// tsdb
|
2022-04-28 13:22:40 +00:00
|
|
|
// typedef struct STsdb STsdb;
|
2022-06-16 09:18:30 +00:00
|
|
|
typedef struct STsdbReader STsdbReader;
|
2022-04-14 02:10:56 +00:00
|
|
|
|
2022-09-08 10:36:08 +00:00
|
|
|
#define TSDB_DEFAULT_STT_FILE 8
|
|
|
|
|
#define TSDB_DEFAULT_PAGE_SIZE 4096
|
2022-09-08 08:56:29 +00:00
|
|
|
|
2022-07-25 03:18:30 +00:00
|
|
|
#define TIMEWINDOW_RANGE_CONTAINED 1
|
|
|
|
|
#define TIMEWINDOW_RANGE_EXTERNAL 2
|
2022-04-14 02:53:10 +00:00
|
|
|
|
2022-08-26 07:27:19 +00:00
|
|
|
#define CACHESCAN_RETRIEVE_TYPE_ALL 0x1
|
|
|
|
|
#define CACHESCAN_RETRIEVE_TYPE_SINGLE 0x2
|
|
|
|
|
#define CACHESCAN_RETRIEVE_LAST_ROW 0x4
|
|
|
|
|
#define CACHESCAN_RETRIEVE_LAST 0x8
|
2022-06-28 07:22:32 +00:00
|
|
|
|
2022-10-29 10:27:22 +00:00
|
|
|
int32_t tsdbSetTableList(STsdbReader *pReader, const void *pTableList, int32_t num);
|
|
|
|
|
int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, void *pTableList, int32_t numOfTables,
|
|
|
|
|
STsdbReader **ppReader, const char *idstr);
|
2022-10-28 10:05:19 +00:00
|
|
|
|
2022-08-15 02:50:09 +00:00
|
|
|
void tsdbReaderClose(STsdbReader *pReader);
|
|
|
|
|
bool tsdbNextDataBlock(STsdbReader *pReader);
|
2022-10-28 11:56:32 +00:00
|
|
|
bool tsdbTableNextDataBlock(STsdbReader *pReader, uint64_t uid);
|
2022-11-03 05:22:23 +00:00
|
|
|
void tsdbRetrieveDataBlockInfo(const STsdbReader *pReader, int32_t *rows, uint64_t *uid, STimeWindow *pWindow);
|
2022-08-15 02:50:09 +00:00
|
|
|
int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SColumnDataAgg ***pBlockStatis, bool *allHave);
|
|
|
|
|
SArray *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList);
|
|
|
|
|
int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond);
|
|
|
|
|
int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo);
|
|
|
|
|
int64_t tsdbGetNumOfRowsInMemTable(STsdbReader *pHandle);
|
|
|
|
|
void *tsdbGetIdx(SMeta *pMeta);
|
|
|
|
|
void *tsdbGetIvtIdx(SMeta *pMeta);
|
2022-08-01 08:52:37 +00:00
|
|
|
uint64_t getReaderMaxVersion(STsdbReader *pReader);
|
2022-06-28 15:24:20 +00:00
|
|
|
|
2022-10-29 10:27:22 +00:00
|
|
|
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
|
|
|
|
uint64_t suid, void **pReader);
|
2022-08-26 07:27:19 +00:00
|
|
|
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids);
|
2022-10-01 05:49:22 +00:00
|
|
|
void *tsdbCacherowsReaderClose(void *pReader);
|
2022-07-11 12:16:48 +00:00
|
|
|
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
|
|
|
|
|
|
|
|
|
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
|
|
|
|
|
size_t tsdbCacheGetCapacity(SVnode *pVnode);
|
2022-09-01 08:41:08 +00:00
|
|
|
size_t tsdbCacheGetUsage(SVnode *pVnode);
|
2022-04-14 02:01:04 +00:00
|
|
|
|
|
|
|
|
// tq
|
2022-08-30 02:07:33 +00:00
|
|
|
typedef struct SMetaTableInfo {
|
2022-08-04 07:01:59 +00:00
|
|
|
int64_t suid;
|
|
|
|
|
int64_t uid;
|
|
|
|
|
SSchemaWrapper *schema;
|
2022-08-09 11:06:24 +00:00
|
|
|
char tbName[TSDB_TABLE_NAME_LEN];
|
2022-08-30 02:07:33 +00:00
|
|
|
} SMetaTableInfo;
|
2022-08-04 07:01:59 +00:00
|
|
|
|
2022-08-30 02:07:33 +00:00
|
|
|
typedef struct SIdInfo {
|
|
|
|
|
int64_t version;
|
|
|
|
|
int32_t index;
|
|
|
|
|
} SIdInfo;
|
2022-08-09 11:06:24 +00:00
|
|
|
|
2022-08-04 07:01:59 +00:00
|
|
|
typedef struct SSnapContext {
|
|
|
|
|
SMeta *pMeta;
|
|
|
|
|
int64_t snapVersion;
|
|
|
|
|
TBC *pCur;
|
|
|
|
|
int64_t suid;
|
|
|
|
|
int8_t subType;
|
|
|
|
|
SHashObj *idVersion;
|
|
|
|
|
SHashObj *suidInfo;
|
2022-08-09 11:06:24 +00:00
|
|
|
SArray *idList;
|
|
|
|
|
int32_t index;
|
2022-08-05 13:12:18 +00:00
|
|
|
bool withMeta;
|
2022-08-30 02:07:33 +00:00
|
|
|
bool queryMetaOrData; // true-get meta, false-get data
|
|
|
|
|
} SSnapContext;
|
2022-04-14 02:10:56 +00:00
|
|
|
|
2022-07-07 09:16:12 +00:00
|
|
|
typedef struct STqReader {
|
|
|
|
|
int64_t ver;
|
|
|
|
|
const SSubmitReq *pMsg;
|
|
|
|
|
SSubmitBlk *pBlock;
|
|
|
|
|
SSubmitMsgIter msgIter;
|
|
|
|
|
SSubmitBlkIter blkIter;
|
2022-04-14 02:10:56 +00:00
|
|
|
|
2022-07-07 09:16:12 +00:00
|
|
|
SWalReader *pWalReader;
|
2022-04-14 02:10:56 +00:00
|
|
|
|
2022-07-07 09:16:12 +00:00
|
|
|
SMeta *pVnodeMeta;
|
|
|
|
|
SHashObj *tbIdHash;
|
|
|
|
|
SArray *pColIdList; // SArray<int16_t>
|
2022-05-20 09:07:53 +00:00
|
|
|
|
2022-07-07 09:16:12 +00:00
|
|
|
int32_t cachedSchemaVer;
|
|
|
|
|
int64_t cachedSchemaSuid;
|
|
|
|
|
SSchemaWrapper *pSchemaWrapper;
|
|
|
|
|
STSchema *pSchema;
|
|
|
|
|
} STqReader;
|
|
|
|
|
|
|
|
|
|
STqReader *tqOpenReader(SVnode *pVnode);
|
|
|
|
|
void tqCloseReader(STqReader *);
|
|
|
|
|
|
|
|
|
|
void tqReaderSetColIdList(STqReader *pReader, SArray *pColIdList);
|
|
|
|
|
int32_t tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList);
|
|
|
|
|
int32_t tqReaderAddTbUidList(STqReader *pReader, const SArray *tbUidList);
|
|
|
|
|
int32_t tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList);
|
|
|
|
|
|
2022-07-08 09:48:34 +00:00
|
|
|
int32_t tqSeekVer(STqReader *pReader, int64_t ver);
|
|
|
|
|
int32_t tqNextBlock(STqReader *pReader, SFetchRet *ret);
|
|
|
|
|
|
2022-09-28 02:38:49 +00:00
|
|
|
int32_t tqReaderSetDataMsg(STqReader *pReader, const SSubmitReq *pMsg, int64_t ver);
|
2022-07-07 09:16:12 +00:00
|
|
|
bool tqNextDataBlock(STqReader *pReader);
|
|
|
|
|
bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids);
|
|
|
|
|
int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReader *pReader);
|
2022-11-21 07:32:27 +00:00
|
|
|
int32_t tqRetrieveTaosxBlock(STqReader *pReader, SArray *blocks, SArray *schemas);
|
2022-04-14 02:01:04 +00:00
|
|
|
|
2022-11-03 05:22:23 +00:00
|
|
|
int32_t vnodeEnqueueStreamMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
2022-08-02 14:23:33 +00:00
|
|
|
|
2022-06-01 11:06:58 +00:00
|
|
|
// sma
|
|
|
|
|
int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days);
|
|
|
|
|
|
2022-07-04 06:47:41 +00:00
|
|
|
// SVSnapReader
|
2022-07-04 07:00:21 +00:00
|
|
|
int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader);
|
2022-07-04 06:47:41 +00:00
|
|
|
int32_t vnodeSnapReaderClose(SVSnapReader *pReader);
|
2022-07-04 12:04:40 +00:00
|
|
|
int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData);
|
|
|
|
|
// SVSnapWriter
|
2022-07-05 11:19:37 +00:00
|
|
|
int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter);
|
2022-07-16 10:19:54 +00:00
|
|
|
int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *pSnapshot);
|
2022-07-05 11:19:37 +00:00
|
|
|
int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData);
|
2022-04-08 06:09:15 +00:00
|
|
|
|
2022-08-30 02:07:33 +00:00
|
|
|
int32_t buildSnapContext(SMeta *pMeta, int64_t snapVersion, int64_t suid, int8_t subType, bool withMeta,
|
|
|
|
|
SSnapContext **ctxRet);
|
|
|
|
|
int32_t getMetafromSnapShot(SSnapContext *ctx, void **pBuf, int32_t *contLen, int16_t *type, int64_t *uid);
|
|
|
|
|
SMetaTableInfo getUidfromSnapShot(SSnapContext *ctx);
|
|
|
|
|
int32_t setForSnapShot(SSnapContext *ctx, int64_t uid);
|
|
|
|
|
int32_t destroySnapContext(SSnapContext *ctx);
|
2022-08-04 07:01:59 +00:00
|
|
|
|
2022-04-14 02:01:04 +00:00
|
|
|
// structs
|
|
|
|
|
struct STsdbCfg {
|
2022-05-08 09:09:00 +00:00
|
|
|
int8_t precision;
|
|
|
|
|
int8_t update;
|
|
|
|
|
int8_t compression;
|
|
|
|
|
int8_t slLevel;
|
|
|
|
|
int32_t minRows;
|
|
|
|
|
int32_t maxRows;
|
|
|
|
|
int32_t days; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
|
|
|
|
int32_t keep0; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
|
|
|
|
int32_t keep1; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
|
|
|
|
int32_t keep2; // just for save config, don't use in tsdbRead/tsdbCommit/..., and use STsdbKeepCfg in STsdb instead
|
2022-05-07 14:33:19 +00:00
|
|
|
SRetention retentions[TSDB_RETENTION_MAX];
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-01 10:01:44 +00:00
|
|
|
typedef struct {
|
|
|
|
|
int64_t numOfSTables;
|
|
|
|
|
int64_t numOfCTables;
|
|
|
|
|
int64_t numOfNTables;
|
2022-08-25 08:22:55 +00:00
|
|
|
int64_t numOfNTimeSeries;
|
2022-08-01 10:01:44 +00:00
|
|
|
int64_t numOfTimeSeries;
|
2022-08-30 02:07:33 +00:00
|
|
|
int64_t itvTimeSeries;
|
2022-08-01 10:01:44 +00:00
|
|
|
int64_t pointsWritten;
|
|
|
|
|
int64_t totalStorage;
|
|
|
|
|
int64_t compStorage;
|
|
|
|
|
} SVnodeStats;
|
|
|
|
|
|
2022-04-14 02:01:04 +00:00
|
|
|
struct SVnodeCfg {
|
2022-08-01 10:01:44 +00:00
|
|
|
int32_t vgId;
|
|
|
|
|
char dbname[TSDB_DB_FNAME_LEN];
|
|
|
|
|
uint64_t dbId;
|
|
|
|
|
int32_t cacheLastSize;
|
|
|
|
|
int32_t szPage;
|
|
|
|
|
int32_t szCache;
|
|
|
|
|
uint64_t szBuf;
|
|
|
|
|
bool isHeap;
|
|
|
|
|
bool isWeak;
|
|
|
|
|
int8_t cacheLast;
|
|
|
|
|
int8_t isTsma;
|
|
|
|
|
int8_t isRsma;
|
|
|
|
|
int8_t hashMethod;
|
|
|
|
|
int8_t standby;
|
|
|
|
|
STsdbCfg tsdbCfg;
|
|
|
|
|
SWalCfg walCfg;
|
|
|
|
|
SSyncCfg syncCfg;
|
|
|
|
|
SVnodeStats vndStats;
|
|
|
|
|
uint32_t hashBegin;
|
|
|
|
|
uint32_t hashEnd;
|
2022-09-08 08:56:29 +00:00
|
|
|
int16_t sttTrigger;
|
2022-09-02 09:12:08 +00:00
|
|
|
int16_t hashPrefix;
|
|
|
|
|
int16_t hashSuffix;
|
2022-09-08 10:36:08 +00:00
|
|
|
int32_t tsdbPageSize;
|
2022-04-14 02:01:04 +00:00
|
|
|
};
|
2021-11-07 07:58:32 +00:00
|
|
|
|
2022-04-14 02:01:04 +00:00
|
|
|
typedef struct {
|
|
|
|
|
uint64_t uid;
|
2022-06-25 05:52:52 +00:00
|
|
|
uint64_t groupId;
|
2022-04-14 02:01:04 +00:00
|
|
|
} STableKeyInfo;
|
2021-12-21 08:15:38 +00:00
|
|
|
|
2022-07-23 07:32:18 +00:00
|
|
|
#define TABLE_ROLLUP_ON ((int8_t)0x1)
|
|
|
|
|
#define TABLE_IS_ROLLUP(FLG) (((FLG) & (TABLE_ROLLUP_ON)) != 0)
|
2022-06-27 06:47:14 +00:00
|
|
|
#define TABLE_SET_ROLLUP(FLG) ((FLG) |= TABLE_ROLLUP_ON)
|
2022-04-24 05:38:56 +00:00
|
|
|
struct SMetaEntry {
|
2022-05-23 07:47:49 +00:00
|
|
|
int64_t version;
|
|
|
|
|
int8_t type;
|
2022-06-27 06:47:14 +00:00
|
|
|
int8_t flags; // TODO: need refactor?
|
2022-05-23 07:47:49 +00:00
|
|
|
tb_uid_t uid;
|
2022-07-07 09:16:12 +00:00
|
|
|
char *name;
|
2022-04-24 05:38:56 +00:00
|
|
|
union {
|
|
|
|
|
struct {
|
2022-05-26 08:29:52 +00:00
|
|
|
SSchemaWrapper schemaRow;
|
2022-04-24 05:38:56 +00:00
|
|
|
SSchemaWrapper schemaTag;
|
2022-06-27 06:47:14 +00:00
|
|
|
SRSmaParam rsmaParam;
|
2022-04-24 05:38:56 +00:00
|
|
|
} stbEntry;
|
|
|
|
|
struct {
|
2022-05-23 07:47:49 +00:00
|
|
|
int64_t ctime;
|
|
|
|
|
int32_t ttlDays;
|
2022-06-16 12:45:00 +00:00
|
|
|
int32_t commentLen;
|
2022-07-07 09:16:12 +00:00
|
|
|
char *comment;
|
2022-05-23 07:47:49 +00:00
|
|
|
tb_uid_t suid;
|
|
|
|
|
uint8_t *pTags;
|
2022-04-24 05:38:56 +00:00
|
|
|
} ctbEntry;
|
|
|
|
|
struct {
|
|
|
|
|
int64_t ctime;
|
|
|
|
|
int32_t ttlDays;
|
2022-06-16 12:45:00 +00:00
|
|
|
int32_t commentLen;
|
2022-07-07 09:16:12 +00:00
|
|
|
char *comment;
|
2022-05-16 06:17:56 +00:00
|
|
|
int32_t ncid; // next column id
|
2022-05-26 08:29:52 +00:00
|
|
|
SSchemaWrapper schemaRow;
|
2022-04-24 05:38:56 +00:00
|
|
|
} ntbEntry;
|
2022-05-15 12:17:20 +00:00
|
|
|
struct {
|
2022-05-15 14:03:02 +00:00
|
|
|
STSma *tsma;
|
2022-05-15 12:17:20 +00:00
|
|
|
} smaEntry;
|
2022-04-24 05:38:56 +00:00
|
|
|
};
|
2022-05-16 12:13:59 +00:00
|
|
|
|
|
|
|
|
uint8_t *pBuf;
|
2022-04-24 05:38:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SMetaReader {
|
|
|
|
|
int32_t flags;
|
2022-07-07 09:16:12 +00:00
|
|
|
SMeta *pMeta;
|
2022-05-07 10:03:06 +00:00
|
|
|
SDecoder coder;
|
2022-04-24 05:38:56 +00:00
|
|
|
SMetaEntry me;
|
2022-07-07 09:16:12 +00:00
|
|
|
void *pBuf;
|
2022-05-20 02:30:48 +00:00
|
|
|
int32_t szBuf;
|
2022-04-24 05:38:56 +00:00
|
|
|
};
|
|
|
|
|
|
2022-04-24 06:19:12 +00:00
|
|
|
struct SMTbCursor {
|
2022-07-07 09:16:12 +00:00
|
|
|
TBC *pDbc;
|
|
|
|
|
void *pKey;
|
|
|
|
|
void *pVal;
|
2022-05-20 02:30:48 +00:00
|
|
|
int32_t kLen;
|
|
|
|
|
int32_t vLen;
|
2022-04-24 06:19:12 +00:00
|
|
|
SMetaReader mr;
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-22 12:29:24 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-09-29 11:26:11 +00:00
|
|
|
#endif /*_TD_VNODE_H_*/
|