refact
This commit is contained in:
parent
416e6354e9
commit
9001468b21
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tbuffer.h"
|
#include "tbuffer.h"
|
||||||
|
#include "tdataformat.h"
|
||||||
#include "tdef.h"
|
#include "tdef.h"
|
||||||
#include "tschema.h"
|
#include "tschema.h"
|
||||||
|
|
||||||
|
@ -91,8 +92,8 @@ typedef struct {
|
||||||
} SRowBuilder;
|
} SRowBuilder;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SSchema *pSchema;
|
STSchema *pSchema;
|
||||||
SRow * pRow;
|
SRow * pRow;
|
||||||
} SRowReader;
|
} SRowReader;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -25,7 +25,8 @@ extern "C" {
|
||||||
|
|
||||||
typedef uint16_t col_id_t;
|
typedef uint16_t col_id_t;
|
||||||
|
|
||||||
typedef struct SColumn {
|
#if 0
|
||||||
|
typedef struct STColumn {
|
||||||
/// column name
|
/// column name
|
||||||
char *cname;
|
char *cname;
|
||||||
union {
|
union {
|
||||||
|
@ -45,9 +46,9 @@ typedef struct SColumn {
|
||||||
};
|
};
|
||||||
/// comment about the column
|
/// comment about the column
|
||||||
char *comment;
|
char *comment;
|
||||||
} SColumn;
|
} STColumn;
|
||||||
|
|
||||||
typedef struct SSchema {
|
typedef struct STSchema {
|
||||||
/// schema version
|
/// schema version
|
||||||
uint16_t sver;
|
uint16_t sver;
|
||||||
/// number of columns
|
/// number of columns
|
||||||
|
@ -58,20 +59,22 @@ typedef struct SSchema {
|
||||||
SArray *smaArray;
|
SArray *smaArray;
|
||||||
};
|
};
|
||||||
/// column info
|
/// column info
|
||||||
SColumn cols[];
|
STColumn cols[];
|
||||||
} SSchema;
|
} STSchema;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
SSchema *pSchema;
|
STSchema *pSchema;
|
||||||
} SShemaBuilder;
|
} STShemaBuilder;
|
||||||
|
|
||||||
#define tSchemaBuilderInit(target, capacity) \
|
#define tSchemaBuilderInit(target, capacity) \
|
||||||
{ .size = (capacity), .pSchema = (target) }
|
{ .size = (capacity), .pSchema = (target) }
|
||||||
void tSchemaBuilderSetSver(SShemaBuilder *pSchemaBuilder, uint16_t sver);
|
void tSchemaBuilderSetSver(STShemaBuilder *pSchemaBuilder, uint16_t sver);
|
||||||
void tSchemaBuilderSetSMA(bool sma, SArray *smaArray);
|
void tSchemaBuilderSetSMA(bool sma, SArray *smaArray);
|
||||||
int tSchemaBuilderPutColumn(char *cname, bool sma, uint8_t type, col_id_t cid, uint32_t bytes, char *comment);
|
int tSchemaBuilderPutColumn(char *cname, bool sma, uint8_t type, col_id_t cid, uint32_t bytes, char *comment);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TD_META_IMPL_H_
|
|
||||||
#define _TD_META_IMPL_H_
|
|
||||||
|
|
||||||
#include "os.h"
|
|
||||||
|
|
||||||
#include "taosmsg.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
typedef uint64_t tb_uid_t;
|
|
||||||
|
|
||||||
/* ------------------------ SMetaOptions ------------------------ */
|
|
||||||
struct SMetaOptions {
|
|
||||||
size_t lruCacheSize; // LRU cache size
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ------------------------ STbOptions ------------------------ */
|
|
||||||
#define META_NORMAL_TABLE ((uint8_t)1)
|
|
||||||
#define META_SUPER_TABLE ((uint8_t)2)
|
|
||||||
#define META_CHILD_TABLE ((uint8_t)3)
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
} SSMAOptions;
|
|
||||||
|
|
||||||
// super table options
|
|
||||||
typedef struct {
|
|
||||||
tb_uid_t uid;
|
|
||||||
STSchema* pSchema;
|
|
||||||
STSchema* pTagSchema;
|
|
||||||
} SSTbOptions;
|
|
||||||
|
|
||||||
// child table options
|
|
||||||
typedef struct {
|
|
||||||
tb_uid_t suid;
|
|
||||||
SKVRow tags;
|
|
||||||
} SCTbOptions;
|
|
||||||
|
|
||||||
// normal table options
|
|
||||||
typedef struct {
|
|
||||||
STSchema* pSchame;
|
|
||||||
} SNTbOptions;
|
|
||||||
|
|
||||||
struct STbOptions {
|
|
||||||
uint8_t type;
|
|
||||||
char* name;
|
|
||||||
uint32_t ttl; // time to live in (SECONDS)
|
|
||||||
SSMAOptions bsma; // Block-wise sma
|
|
||||||
union {
|
|
||||||
SSTbOptions stbOptions;
|
|
||||||
SNTbOptions ntbOptions;
|
|
||||||
SCTbOptions ctbOptions;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*_TD_META_IMPL_H_*/
|
|
|
@ -16,38 +16,75 @@
|
||||||
#ifndef _TD_META_H_
|
#ifndef _TD_META_H_
|
||||||
#define _TD_META_H_
|
#define _TD_META_H_
|
||||||
|
|
||||||
#include "impl/metaImpl.h"
|
#include "os.h"
|
||||||
|
#include "trow.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Types exported
|
// Types exported
|
||||||
typedef struct SMeta SMeta;
|
typedef uint64_t tb_uid_t;
|
||||||
typedef struct SMetaOptions SMetaOptions;
|
typedef struct SMeta SMeta;
|
||||||
typedef struct STbOptions STbOptions;
|
|
||||||
|
typedef struct SMetaCfg {
|
||||||
|
/// LRU cache size
|
||||||
|
uint64_t lruSize;
|
||||||
|
} SMetaCfg;
|
||||||
|
|
||||||
|
typedef struct STbCfg {
|
||||||
|
/// name of the table
|
||||||
|
char *name;
|
||||||
|
/// time to live of the table
|
||||||
|
uint32_t ttl;
|
||||||
|
/// type of table
|
||||||
|
uint8_t type;
|
||||||
|
union {
|
||||||
|
/// super table configurations
|
||||||
|
struct {
|
||||||
|
/// super table UID
|
||||||
|
tb_uid_t suid;
|
||||||
|
/// row schema
|
||||||
|
STSchema *pSchema;
|
||||||
|
/// tag schema
|
||||||
|
STSchema *pTagSchema;
|
||||||
|
} stbCfg;
|
||||||
|
|
||||||
|
/// normal table configuration
|
||||||
|
struct {
|
||||||
|
/// row schema
|
||||||
|
STSchema *pSchema;
|
||||||
|
} ntbCfg;
|
||||||
|
/// child table configuration
|
||||||
|
struct {
|
||||||
|
/// super table UID
|
||||||
|
tb_uid_t suid;
|
||||||
|
SRow * pTag;
|
||||||
|
} ctbCfg;
|
||||||
|
};
|
||||||
|
} STbCfg;
|
||||||
|
|
||||||
// SMeta operations
|
// SMeta operations
|
||||||
SMeta *metaOpen(const char *path, const SMetaOptions *pOptions);
|
SMeta *metaOpen(const char *path, const SMetaCfg *pOptions);
|
||||||
void metaClose(SMeta *pMeta);
|
void metaClose(SMeta *pMeta);
|
||||||
void metaRemove(const char *path);
|
void metaRemove(const char *path);
|
||||||
int metaCreateTable(SMeta *pMeta, const STbOptions *pTbOptions);
|
int metaCreateTable(SMeta *pMeta, const STbCfg *pTbOptions);
|
||||||
int metaDropTable(SMeta *pMeta, tb_uid_t uid);
|
int metaDropTable(SMeta *pMeta, tb_uid_t uid);
|
||||||
int metaCommit(SMeta *pMeta);
|
int metaCommit(SMeta *pMeta);
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
void metaOptionsInit(SMetaOptions *pOptions);
|
void metaOptionsInit(SMetaCfg *pOptions);
|
||||||
void metaOptionsClear(SMetaOptions *pOptions);
|
void metaOptionsClear(SMetaCfg *pOptions);
|
||||||
|
|
||||||
// STableOpts
|
// STableOpts
|
||||||
#define META_TABLE_OPTS_DECLARE(name) STableOpts name = {0}
|
// #define META_TABLE_OPTS_DECLARE(name) STableOpts name = {0}
|
||||||
void metaNormalTableOptsInit(STbOptions *pTbOptions, const char *name, const STSchema *pSchema);
|
// void metaNormalTableOptsInit(STbCfg *pTbOptions, const char *name, const STSchema *pSchema);
|
||||||
void metaSuperTableOptsInit(STbOptions *pTbOptions, const char *name, tb_uid_t uid, const STSchema *pSchema,
|
// void metaSuperTableOptsInit(STbCfg *pTbOptions, const char *name, tb_uid_t uid, const STSchema *pSchema,
|
||||||
const STSchema *pTagSchema);
|
// const STSchema *pTagSchema);
|
||||||
void metaChildTableOptsInit(STbOptions *pTbOptions, const char *name, tb_uid_t suid, const SKVRow tags);
|
// void metaChildTableOptsInit(STbCfg *pTbOptions, const char *name, tb_uid_t suid, const SKVRow tags);
|
||||||
void metaTableOptsClear(STbOptions *pTbOptions);
|
// void metaTableOptsClear(STbCfg *pTbOptions);
|
||||||
uint64_t metaEncodeTbOptions(void **pBuf, STbOptions *pTbOptions);
|
// uint64_t metaEncodeTbOptions(void **pBuf, STbCfg *pTbOptions);
|
||||||
STbOptions *metaDecodeTbOptions(void *pBuf, size_t size, bool endian);
|
// STbCfg * metaDecodeTbOptions(void *pBuf, size_t size, bool endian);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ------------------------ TYPES EXPOSED ------------------------ */
|
/* ------------------------ TYPES EXPOSED ------------------------ */
|
||||||
typedef struct SVnode SVnode;
|
typedef struct SVnode SVnode;
|
||||||
typedef struct SVnodeOptions SVnodeOptions;
|
typedef struct SVnodeCfg SVnodeCfg;
|
||||||
|
|
||||||
/* ------------------------ SVnode ------------------------ */
|
/* ------------------------ SVnode ------------------------ */
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +40,7 @@ typedef struct SVnodeOptions SVnodeOptions;
|
||||||
* @param pVnodeOptions options of the vnode
|
* @param pVnodeOptions options of the vnode
|
||||||
* @return SVnode* The vnode object
|
* @return SVnode* The vnode object
|
||||||
*/
|
*/
|
||||||
SVnode *vnodeOpen(const char *path, const SVnodeOptions *pVnodeOptions);
|
SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeOptions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Close a VNODE
|
* @brief Close a VNODE
|
||||||
|
@ -85,23 +85,23 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||||
*/
|
*/
|
||||||
int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
|
||||||
|
|
||||||
/* ------------------------ SVnodeOptions ------------------------ */
|
/* ------------------------ SVnodeCfg ------------------------ */
|
||||||
/**
|
/**
|
||||||
* @brief Initialize VNODE options.
|
* @brief Initialize VNODE options.
|
||||||
*
|
*
|
||||||
* @param pOptions The options object to be initialized. It should not be NULL.
|
* @param pOptions The options object to be initialized. It should not be NULL.
|
||||||
*/
|
*/
|
||||||
void vnodeOptionsInit(SVnodeOptions *pOptions);
|
void vnodeOptionsInit(SVnodeCfg *pOptions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clear VNODE options.
|
* @brief Clear VNODE options.
|
||||||
*
|
*
|
||||||
* @param pOptions Options to clear.
|
* @param pOptions Options to clear.
|
||||||
*/
|
*/
|
||||||
void vnodeOptionsClear(SVnodeOptions *pOptions);
|
void vnodeOptionsClear(SVnodeCfg *pOptions);
|
||||||
|
|
||||||
/* ------------------------ STRUCT DEFINITIONS ------------------------ */
|
/* ------------------------ STRUCT DEFINITIONS ------------------------ */
|
||||||
struct SVnodeOptions {
|
struct SVnodeCfg {
|
||||||
/**
|
/**
|
||||||
* @brief write buffer size in BYTES
|
* @brief write buffer size in BYTES
|
||||||
*
|
*
|
||||||
|
@ -137,7 +137,7 @@ struct SVnodeOptions {
|
||||||
* @brief META options
|
* @brief META options
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SMetaOptions metaOptions;
|
SMetaCfg metaOptions;
|
||||||
// STqOptions tqOptions; // TODO
|
// STqOptions tqOptions; // TODO
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -148,27 +148,27 @@ struct SVnodeOptions {
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
|
|
||||||
typedef struct {
|
// typedef struct {
|
||||||
char db[TSDB_FULL_DB_NAME_LEN];
|
// char db[TSDB_FULL_DB_NAME_LEN];
|
||||||
int32_t cacheBlockSize; // MB
|
// int32_t cacheBlockSize; // MB
|
||||||
int32_t totalBlocks;
|
// int32_t totalBlocks;
|
||||||
int32_t daysPerFile;
|
// int32_t daysPerFile;
|
||||||
int32_t daysToKeep0;
|
// int32_t daysToKeep0;
|
||||||
int32_t daysToKeep1;
|
// int32_t daysToKeep1;
|
||||||
int32_t daysToKeep2;
|
// int32_t daysToKeep2;
|
||||||
int32_t minRowsPerFileBlock;
|
// int32_t minRowsPerFileBlock;
|
||||||
int32_t maxRowsPerFileBlock;
|
// int32_t maxRowsPerFileBlock;
|
||||||
int8_t precision; // time resolution
|
// int8_t precision; // time resolution
|
||||||
int8_t compression;
|
// int8_t compression;
|
||||||
int8_t cacheLastRow;
|
// int8_t cacheLastRow;
|
||||||
int8_t update;
|
// int8_t update;
|
||||||
int8_t quorum;
|
// int8_t quorum;
|
||||||
int8_t replica;
|
// int8_t replica;
|
||||||
int8_t selfIndex;
|
// int8_t selfIndex;
|
||||||
int8_t walLevel;
|
// int8_t walLevel;
|
||||||
int32_t fsyncPeriod; // millisecond
|
// int32_t fsyncPeriod; // millisecond
|
||||||
SReplica replicas[TSDB_MAX_REPLICA];
|
// SReplica replicas[TSDB_MAX_REPLICA];
|
||||||
} SVnodeCfg;
|
// } SVnodeCfg;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VN_MSG_TYPE_WRITE = 1,
|
VN_MSG_TYPE_WRITE = 1,
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dnodeVnodes.h"
|
#include "dnodeVnodes.h"
|
||||||
#include "dnodeTransport.h"
|
|
||||||
#include "cJSON.h"
|
#include "cJSON.h"
|
||||||
|
#include "dnodeTransport.h"
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
#include "tlockfree.h"
|
#include "tlockfree.h"
|
||||||
#include "tqueue.h"
|
#include "tqueue.h"
|
||||||
|
@ -30,7 +30,7 @@ typedef struct {
|
||||||
int32_t refCount;
|
int32_t refCount;
|
||||||
int8_t dropped;
|
int8_t dropped;
|
||||||
int8_t accessState;
|
int8_t accessState;
|
||||||
SVnode *pImpl;
|
SVnode * pImpl;
|
||||||
taos_queue pWriteQ;
|
taos_queue pWriteQ;
|
||||||
taos_queue pSyncQ;
|
taos_queue pSyncQ;
|
||||||
taos_queue pApplyQ;
|
taos_queue pApplyQ;
|
||||||
|
@ -48,14 +48,14 @@ typedef struct {
|
||||||
} SVThread;
|
} SVThread;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
SHashObj *hash;
|
SHashObj * hash;
|
||||||
SWorkerPool mgmtPool;
|
SWorkerPool mgmtPool;
|
||||||
SWorkerPool queryPool;
|
SWorkerPool queryPool;
|
||||||
SWorkerPool fetchPool;
|
SWorkerPool fetchPool;
|
||||||
SMWorkerPool syncPool;
|
SMWorkerPool syncPool;
|
||||||
SMWorkerPool writePool;
|
SMWorkerPool writePool;
|
||||||
taos_queue pMgmtQ;
|
taos_queue pMgmtQ;
|
||||||
SSteps *pSteps;
|
SSteps * pSteps;
|
||||||
int32_t openVnodes;
|
int32_t openVnodes;
|
||||||
int32_t totalVnodes;
|
int32_t totalVnodes;
|
||||||
SRWLatch latch;
|
SRWLatch latch;
|
||||||
|
@ -169,7 +169,7 @@ static SVnodeObj **dnodeGetVnodesFromHash(int32_t *numOfVnodes) {
|
||||||
void *pIter = taosHashIterate(tsVnodes.hash, NULL);
|
void *pIter = taosHashIterate(tsVnodes.hash, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SVnodeObj **ppVnode = pIter;
|
SVnodeObj **ppVnode = pIter;
|
||||||
SVnodeObj *pVnode = *ppVnode;
|
SVnodeObj * pVnode = *ppVnode;
|
||||||
if (pVnode) {
|
if (pVnode) {
|
||||||
num++;
|
num++;
|
||||||
if (num < size) {
|
if (num < size) {
|
||||||
|
@ -191,14 +191,14 @@ static int32_t dnodeGetVnodesFromFile(SVnodeObj **ppVnodes, int32_t *numOfVnodes
|
||||||
int32_t code = TSDB_CODE_DND_PARSE_VNODE_FILE_ERROR;
|
int32_t code = TSDB_CODE_DND_PARSE_VNODE_FILE_ERROR;
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 30000;
|
int32_t maxLen = 30000;
|
||||||
char *content = calloc(1, maxLen + 1);
|
char * content = calloc(1, maxLen + 1);
|
||||||
cJSON *root = NULL;
|
cJSON * root = NULL;
|
||||||
FILE *fp = NULL;
|
FILE * fp = NULL;
|
||||||
char file[PATH_MAX + 20] = {0};
|
char file[PATH_MAX + 20] = {0};
|
||||||
SVnodeObj *pVnodes = NULL;
|
SVnodeObj *pVnodes = NULL;
|
||||||
|
|
||||||
snprintf(file, PATH_MAX + 20, "%s/vnodes.json", tsVnodeDir);
|
snprintf(file, PATH_MAX + 20, "%s/vnodes.json", tsVnodeDir);
|
||||||
|
|
||||||
fp = fopen(file, "r");
|
fp = fopen(file, "r");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
dDebug("file %s not exist", file);
|
dDebug("file %s not exist", file);
|
||||||
|
@ -238,7 +238,7 @@ static int32_t dnodeGetVnodesFromFile(SVnodeObj **ppVnodes, int32_t *numOfVnodes
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < vnodesNum; ++i) {
|
for (int32_t i = 0; i < vnodesNum; ++i) {
|
||||||
cJSON *vnode = cJSON_GetArrayItem(vnodes, i);
|
cJSON * vnode = cJSON_GetArrayItem(vnodes, i);
|
||||||
SVnodeObj *pVnode = &pVnodes[i];
|
SVnodeObj *pVnode = &pVnodes[i];
|
||||||
|
|
||||||
cJSON *vgId = cJSON_GetObjectItem(vnode, "vgId");
|
cJSON *vgId = cJSON_GetObjectItem(vnode, "vgId");
|
||||||
|
@ -281,7 +281,7 @@ static int32_t dnodeWriteVnodesToFile() {
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
int32_t maxLen = 30000;
|
int32_t maxLen = 30000;
|
||||||
char *content = calloc(1, maxLen + 1);
|
char * content = calloc(1, maxLen + 1);
|
||||||
int32_t numOfVnodes = 0;
|
int32_t numOfVnodes = 0;
|
||||||
SVnodeObj **pVnodes = dnodeGetVnodesFromHash(&numOfVnodes);
|
SVnodeObj **pVnodes = dnodeGetVnodesFromHash(&numOfVnodes);
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ static int32_t dnodeCreateVnode(int32_t vgId, SVnodeCfg *pCfg) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
char path[PATH_MAX + 20] = {0};
|
char path[PATH_MAX + 20] = {0};
|
||||||
snprintf(path, sizeof(path),"%s/vnode%d", tsVnodeDir, vgId);
|
snprintf(path, sizeof(path), "%s/vnode%d", tsVnodeDir, vgId);
|
||||||
SVnode *pImpl = vnodeCreate(vgId, path, pCfg);
|
SVnode *pImpl = vnodeCreate(vgId, path, pCfg);
|
||||||
|
|
||||||
if (pImpl == NULL) {
|
if (pImpl == NULL) {
|
||||||
|
@ -375,7 +375,7 @@ static void *dnodeOpenVnodeFunc(void *param) {
|
||||||
dnodeReportStartup("open-vnodes", stepDesc);
|
dnodeReportStartup("open-vnodes", stepDesc);
|
||||||
|
|
||||||
char path[PATH_MAX + 20] = {0};
|
char path[PATH_MAX + 20] = {0};
|
||||||
snprintf(path, sizeof(path),"%s/vnode%d", tsVnodeDir, pVnode->vgId);
|
snprintf(path, sizeof(path), "%s/vnode%d", tsVnodeDir, pVnode->vgId);
|
||||||
SVnode *pImpl = vnodeOpen(path, NULL);
|
SVnode *pImpl = vnodeOpen(path, NULL);
|
||||||
if (pImpl == NULL) {
|
if (pImpl == NULL) {
|
||||||
dError("vgId:%d, failed to open vnode by thread:%d", pVnode->vgId, pThread->threadIndex);
|
dError("vgId:%d, failed to open vnode by thread:%d", pVnode->vgId, pThread->threadIndex);
|
||||||
|
@ -481,6 +481,7 @@ static int32_t dnodeParseCreateVnodeReq(SRpcMsg *rpcMsg, int32_t *vgId, SVnodeCf
|
||||||
SCreateVnodeMsg *pCreate = rpcMsg->pCont;
|
SCreateVnodeMsg *pCreate = rpcMsg->pCont;
|
||||||
*vgId = htonl(pCreate->vgId);
|
*vgId = htonl(pCreate->vgId);
|
||||||
|
|
||||||
|
#if 0
|
||||||
tstrncpy(pCfg->db, pCreate->db, TSDB_FULL_DB_NAME_LEN);
|
tstrncpy(pCfg->db, pCreate->db, TSDB_FULL_DB_NAME_LEN);
|
||||||
pCfg->cacheBlockSize = htonl(pCreate->cacheBlockSize);
|
pCfg->cacheBlockSize = htonl(pCreate->cacheBlockSize);
|
||||||
pCfg->totalBlocks = htonl(pCreate->totalBlocks);
|
pCfg->totalBlocks = htonl(pCreate->totalBlocks);
|
||||||
|
@ -503,6 +504,7 @@ static int32_t dnodeParseCreateVnodeReq(SRpcMsg *rpcMsg, int32_t *vgId, SVnodeCf
|
||||||
pCfg->replicas[i].port = htons(pCreate->replicas[i].port);
|
pCfg->replicas[i].port = htons(pCreate->replicas[i].port);
|
||||||
tstrncpy(pCfg->replicas[i].fqdn, pCreate->replicas[i].fqdn, TSDB_FQDN_LEN);
|
tstrncpy(pCfg->replicas[i].fqdn, pCreate->replicas[i].fqdn, TSDB_FQDN_LEN);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -668,7 +670,7 @@ static void dnodeProcessVnodeMgmtQueue(void *unused, SRpcMsg *pMsg) {
|
||||||
break;
|
break;
|
||||||
case TSDB_MSG_TYPE_AUTH_VNODE_IN:
|
case TSDB_MSG_TYPE_AUTH_VNODE_IN:
|
||||||
code = vnodeProcessAuthVnodeReq(pMsg);
|
code = vnodeProcessAuthVnodeReq(pMsg);
|
||||||
break;
|
break;
|
||||||
case TSDB_MSG_TYPE_SYNC_VNODE_IN:
|
case TSDB_MSG_TYPE_SYNC_VNODE_IN:
|
||||||
code = vnodeProcessSyncVnodeReq(pMsg);
|
code = vnodeProcessSyncVnodeReq(pMsg);
|
||||||
break;
|
break;
|
||||||
|
@ -696,7 +698,7 @@ static void dnodeProcessVnodeFetchQueue(SVnodeObj *pVnode, SVnodeMsg *pMsg) {
|
||||||
|
|
||||||
static void dnodeProcessVnodeWriteQueue(SVnodeObj *pVnode, taos_qall qall, int32_t numOfMsgs) {
|
static void dnodeProcessVnodeWriteQueue(SVnodeObj *pVnode, taos_qall qall, int32_t numOfMsgs) {
|
||||||
SVnodeMsg *pMsg = vnodeInitMsg(numOfMsgs);
|
SVnodeMsg *pMsg = vnodeInitMsg(numOfMsgs);
|
||||||
SRpcMsg *pRpcMsg = NULL;
|
SRpcMsg * pRpcMsg = NULL;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||||
taosGetQitem(qall, (void **)&pRpcMsg);
|
taosGetQitem(qall, (void **)&pRpcMsg);
|
||||||
|
@ -1008,7 +1010,7 @@ void dnodeGetVnodeLoads(SVnodeLoads *pLoads) {
|
||||||
pLoads->num = taosHashGetSize(tsVnodes.hash);
|
pLoads->num = taosHashGetSize(tsVnodes.hash);
|
||||||
|
|
||||||
int32_t v = 0;
|
int32_t v = 0;
|
||||||
void *pIter = taosHashIterate(tsVnodes.hash, NULL);
|
void * pIter = taosHashIterate(tsVnodes.hash, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SVnodeObj **ppVnode = pIter;
|
SVnodeObj **ppVnode = pIter;
|
||||||
if (ppVnode == NULL) continue;
|
if (ppVnode == NULL) continue;
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_VNODE_OPTIONS_H_
|
#ifndef _TD_VNODE_CFG_H_
|
||||||
#define _TD_VNODE_OPTIONS_H_
|
#define _TD_VNODE_CFG_H_
|
||||||
|
|
||||||
#include "vnode.h"
|
#include "vnode.h"
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern const SVnodeOptions defaultVnodeOptions;
|
extern const SVnodeCfg defaultVnodeOptions;
|
||||||
|
|
||||||
int vnodeValidateOptions(const SVnodeOptions *);
|
int vnodeValidateOptions(const SVnodeCfg *);
|
||||||
void vnodeOptionsCopy(SVnodeOptions *pDest, const SVnodeOptions *pSrc);
|
void vnodeOptionsCopy(SVnodeCfg *pDest, const SVnodeCfg *pSrc);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_VNODE_OPTIONS_H_*/
|
#endif /*_TD_VNODE_CFG_H_*/
|
|
@ -25,7 +25,7 @@
|
||||||
#include "vnodeBufferPool.h"
|
#include "vnodeBufferPool.h"
|
||||||
#include "vnodeCommit.h"
|
#include "vnodeCommit.h"
|
||||||
#include "vnodeFileSystem.h"
|
#include "vnodeFileSystem.h"
|
||||||
#include "vnodeOptions.h"
|
#include "vnodeCfg.h"
|
||||||
#include "vnodeStateMgr.h"
|
#include "vnodeStateMgr.h"
|
||||||
#include "vnodeSync.h"
|
#include "vnodeSync.h"
|
||||||
|
|
||||||
|
@ -34,16 +34,16 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct SVnode {
|
struct SVnode {
|
||||||
char* path;
|
char* path;
|
||||||
SVnodeOptions options;
|
SVnodeCfg config;
|
||||||
SVState state;
|
SVState state;
|
||||||
SVBufPool* pBufPool;
|
SVBufPool* pBufPool;
|
||||||
SMeta* pMeta;
|
SMeta* pMeta;
|
||||||
STsdb* pTsdb;
|
STsdb* pTsdb;
|
||||||
STQ* pTq;
|
STQ* pTq;
|
||||||
SWal* pWal;
|
SWal* pWal;
|
||||||
SVnodeSync* pSync;
|
SVnodeSync* pSync;
|
||||||
SVnodeFS* pFs;
|
SVnodeFS* pFs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -84,8 +84,8 @@ int vnodeOpenBufPool(SVnode *pVnode) {
|
||||||
tdListInit(&(pVnode->pBufPool->free), 0);
|
tdListInit(&(pVnode->pBufPool->free), 0);
|
||||||
tdListInit(&(pVnode->pBufPool->incycle), 0);
|
tdListInit(&(pVnode->pBufPool->incycle), 0);
|
||||||
|
|
||||||
capacity = pVnode->options.wsize / VNODE_BUF_POOL_SHARDS;
|
capacity = pVnode->config.wsize / VNODE_BUF_POOL_SHARDS;
|
||||||
if (pVnode->options.isHeapAllocator) {
|
if (pVnode->config.isHeapAllocator) {
|
||||||
type = E_V_HEAP_ALLOCATOR;
|
type = E_V_HEAP_ALLOCATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,20 +15,20 @@
|
||||||
|
|
||||||
#include "vnodeDef.h"
|
#include "vnodeDef.h"
|
||||||
|
|
||||||
const SVnodeOptions defaultVnodeOptions = {0}; /* TODO */
|
const SVnodeCfg defaultVnodeOptions = {0}; /* TODO */
|
||||||
|
|
||||||
void vnodeOptionsInit(SVnodeOptions *pVnodeOptions) { /* TODO */
|
void vnodeOptionsInit(SVnodeCfg *pVnodeOptions) { /* TODO */
|
||||||
vnodeOptionsCopy(pVnodeOptions, &defaultVnodeOptions);
|
vnodeOptionsCopy(pVnodeOptions, &defaultVnodeOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeOptionsClear(SVnodeOptions *pVnodeOptions) { /* TODO */
|
void vnodeOptionsClear(SVnodeCfg *pVnodeOptions) { /* TODO */
|
||||||
}
|
}
|
||||||
|
|
||||||
int vnodeValidateOptions(const SVnodeOptions *pVnodeOptions) {
|
int vnodeValidateOptions(const SVnodeCfg *pVnodeOptions) {
|
||||||
// TODO
|
// TODO
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeOptionsCopy(SVnodeOptions *pDest, const SVnodeOptions *pSrc) {
|
void vnodeOptionsCopy(SVnodeCfg *pDest, const SVnodeCfg *pSrc) {
|
||||||
memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeOptions));
|
memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeCfg));
|
||||||
}
|
}
|
|
@ -15,27 +15,27 @@
|
||||||
|
|
||||||
#include "vnodeDef.h"
|
#include "vnodeDef.h"
|
||||||
|
|
||||||
static SVnode *vnodeNew(const char *path, const SVnodeOptions *pVnodeOptions);
|
static SVnode *vnodeNew(const char *path, const SVnodeCfg *pVnodeCfg);
|
||||||
static void vnodeFree(SVnode *pVnode);
|
static void vnodeFree(SVnode *pVnode);
|
||||||
static int vnodeOpenImpl(SVnode *pVnode);
|
static int vnodeOpenImpl(SVnode *pVnode);
|
||||||
static void vnodeCloseImpl(SVnode *pVnode);
|
static void vnodeCloseImpl(SVnode *pVnode);
|
||||||
|
|
||||||
SVnode *vnodeOpen(const char *path, const SVnodeOptions *pVnodeOptions) {
|
SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) {
|
||||||
SVnode *pVnode = NULL;
|
SVnode *pVnode = NULL;
|
||||||
|
|
||||||
// Set default options
|
// Set default options
|
||||||
if (pVnodeOptions == NULL) {
|
if (pVnodeCfg == NULL) {
|
||||||
pVnodeOptions = &defaultVnodeOptions;
|
pVnodeCfg = &defaultVnodeOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate options
|
// Validate options
|
||||||
if (vnodeValidateOptions(pVnodeOptions) < 0) {
|
if (vnodeValidateOptions(pVnodeCfg) < 0) {
|
||||||
// TODO
|
// TODO
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the handle
|
// Create the handle
|
||||||
pVnode = vnodeNew(path, pVnodeOptions);
|
pVnode = vnodeNew(path, pVnodeCfg);
|
||||||
if (pVnode == NULL) {
|
if (pVnode == NULL) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -62,7 +62,7 @@ void vnodeClose(SVnode *pVnode) {
|
||||||
void vnodeDestroy(const char *path) { taosRemoveDir(path); }
|
void vnodeDestroy(const char *path) { taosRemoveDir(path); }
|
||||||
|
|
||||||
/* ------------------------ STATIC METHODS ------------------------ */
|
/* ------------------------ STATIC METHODS ------------------------ */
|
||||||
static SVnode *vnodeNew(const char *path, const SVnodeOptions *pVnodeOptions) {
|
static SVnode *vnodeNew(const char *path, const SVnodeCfg *pVnodeCfg) {
|
||||||
SVnode *pVnode = NULL;
|
SVnode *pVnode = NULL;
|
||||||
|
|
||||||
pVnode = (SVnode *)calloc(1, sizeof(*pVnode));
|
pVnode = (SVnode *)calloc(1, sizeof(*pVnode));
|
||||||
|
@ -72,7 +72,7 @@ static SVnode *vnodeNew(const char *path, const SVnodeOptions *pVnodeOptions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pVnode->path = strdup(path);
|
pVnode->path = strdup(path);
|
||||||
vnodeOptionsCopy(&(pVnode->options), pVnodeOptions);
|
vnodeOptionsCopy(&(pVnode->config), pVnodeCfg);
|
||||||
|
|
||||||
return pVnode;
|
return pVnode;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
|
||||||
|
|
||||||
// Open meta
|
// Open meta
|
||||||
sprintf(dir, "%s/meta", pVnode->path);
|
sprintf(dir, "%s/meta", pVnode->path);
|
||||||
pVnode->pMeta = metaOpen(dir, &(pVnode->options.metaOptions));
|
pVnode->pMeta = metaOpen(dir, &(pVnode->config.metaOptions));
|
||||||
if (pVnode->pMeta == NULL) {
|
if (pVnode->pMeta == NULL) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -102,7 +102,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
|
||||||
|
|
||||||
// Open tsdb
|
// Open tsdb
|
||||||
sprintf(dir, "%s/tsdb", pVnode->path);
|
sprintf(dir, "%s/tsdb", pVnode->path);
|
||||||
pVnode->pTsdb = tsdbOpen(dir, &(pVnode->options.tsdbOptions));
|
pVnode->pTsdb = tsdbOpen(dir, &(pVnode->config.tsdbOptions));
|
||||||
if (pVnode->pTsdb == NULL) {
|
if (pVnode->pTsdb == NULL) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_META_OPTIONS_H_
|
#ifndef _TD_META_CFG_H_
|
||||||
#define _TD_META_OPTIONS_H_
|
#define _TD_META_CFG_H_
|
||||||
|
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern const SMetaOptions defaultMetaOptions;
|
extern const SMetaCfg defaultMetaOptions;
|
||||||
|
|
||||||
int metaValidateOptions(const SMetaOptions *);
|
int metaValidateOptions(const SMetaCfg *);
|
||||||
void metaOptionsCopy(SMetaOptions *pDest, const SMetaOptions *pSrc);
|
void metaOptionsCopy(SMetaCfg *pDest, const SMetaCfg *pSrc);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_META_OPTIONS_H_*/
|
#endif /*_TD_META_CFG_H_*/
|
|
@ -34,7 +34,7 @@ typedef struct {
|
||||||
|
|
||||||
int metaOpenDB(SMeta *pMeta);
|
int metaOpenDB(SMeta *pMeta);
|
||||||
void metaCloseDB(SMeta *pMeta);
|
void metaCloseDB(SMeta *pMeta);
|
||||||
int metaSaveTableToDB(SMeta *pMeta, const STbOptions *pTbOptions);
|
int metaSaveTableToDB(SMeta *pMeta, const STbCfg *pTbOptions);
|
||||||
int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid);
|
int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
|
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
#include "metaCache.h"
|
#include "metaCache.h"
|
||||||
|
#include "metaCfg.h"
|
||||||
#include "metaDB.h"
|
#include "metaDB.h"
|
||||||
#include "metaIdx.h"
|
#include "metaIdx.h"
|
||||||
#include "metaOptions.h"
|
#include "metaTbCfg.h"
|
||||||
#include "metaTbOptions.h"
|
|
||||||
#include "metaTbTag.h"
|
#include "metaTbTag.h"
|
||||||
#include "metaTbUid.h"
|
#include "metaTbUid.h"
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ extern "C" {
|
||||||
|
|
||||||
struct SMeta {
|
struct SMeta {
|
||||||
char* path;
|
char* path;
|
||||||
SMetaOptions options;
|
SMetaCfg options;
|
||||||
meta_db_t* pDB;
|
meta_db_t* pDB;
|
||||||
meta_index_t* pIdx;
|
meta_index_t* pIdx;
|
||||||
meta_cache_t* pCache;
|
meta_cache_t* pCache;
|
||||||
|
|
|
@ -28,7 +28,7 @@ typedef rocksdb_t meta_index_t;
|
||||||
|
|
||||||
int metaOpenIdx(SMeta *pMeta);
|
int metaOpenIdx(SMeta *pMeta);
|
||||||
void metaCloseIdx(SMeta *pMeta);
|
void metaCloseIdx(SMeta *pMeta);
|
||||||
int metaSaveTableToIdx(SMeta *pMeta, const STbOptions *pTbOptions);
|
int metaSaveTableToIdx(SMeta *pMeta, const STbCfg *pTbOptions);
|
||||||
int metaRemoveTableFromIdx(SMeta *pMeta, tb_uid_t uid);
|
int metaRemoveTableFromIdx(SMeta *pMeta, tb_uid_t uid);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_META_TABLE_OPTIONS_H_
|
#ifndef _TD_META_TABLE_CFG_H_
|
||||||
#define _TD_META_TABLE_OPTIONS_H_
|
#define _TD_META_TABLE_CFG_H_
|
||||||
|
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
|
||||||
|
@ -22,11 +22,15 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int metaValidateTbOptions(SMeta *pMeta, const STbOptions *);
|
#define META_SUPER_TABLE 0
|
||||||
size_t metaEncodeTbObjFromTbOptions(const STbOptions *, void *pBuf, size_t bsize);
|
#define META_CHILD_TABLE 1
|
||||||
|
#define META_NORMAL_TABLE 2
|
||||||
|
|
||||||
|
int metaValidateTbOptions(SMeta *pMeta, const STbCfg *);
|
||||||
|
size_t metaEncodeTbObjFromTbOptions(const STbCfg *, void *pBuf, size_t bsize);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_META_TABLE_OPTIONS_H_*/
|
#endif /*_TD_META_TABLE_CFG_H_*/
|
|
@ -18,8 +18,8 @@
|
||||||
|
|
||||||
int metaOpenCache(SMeta *pMeta) {
|
int metaOpenCache(SMeta *pMeta) {
|
||||||
// TODO
|
// TODO
|
||||||
if (pMeta->options.lruCacheSize) {
|
if (pMeta->options.lruSize) {
|
||||||
pMeta->pCache = rocksdb_cache_create_lru(pMeta->options.lruCacheSize);
|
pMeta->pCache = rocksdb_cache_create_lru(pMeta->options.lruSize);
|
||||||
if (pMeta->pCache == NULL) {
|
if (pMeta->pCache == NULL) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -15,20 +15,20 @@
|
||||||
|
|
||||||
#include "metaDef.h"
|
#include "metaDef.h"
|
||||||
|
|
||||||
const SMetaOptions defaultMetaOptions = {.lruCacheSize = 0};
|
const SMetaCfg defaultMetaOptions = {.lruSize = 0};
|
||||||
|
|
||||||
/* ------------------------ EXPOSED METHODS ------------------------ */
|
/* ------------------------ EXPOSED METHODS ------------------------ */
|
||||||
void metaOptionsInit(SMetaOptions *pMetaOptions) { metaOptionsCopy(pMetaOptions, &defaultMetaOptions); }
|
void metaOptionsInit(SMetaCfg *pMetaOptions) { metaOptionsCopy(pMetaOptions, &defaultMetaOptions); }
|
||||||
|
|
||||||
void metaOptionsClear(SMetaOptions *pMetaOptions) {
|
void metaOptionsClear(SMetaCfg *pMetaOptions) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaValidateOptions(const SMetaOptions *pMetaOptions) {
|
int metaValidateOptions(const SMetaCfg *pMetaOptions) {
|
||||||
// TODO
|
// TODO
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void metaOptionsCopy(SMetaOptions *pDest, const SMetaOptions *pSrc) { memcpy(pDest, pSrc, sizeof(*pSrc)); }
|
void metaOptionsCopy(SMetaCfg *pDest, const SMetaCfg *pSrc) { memcpy(pDest, pSrc, sizeof(*pSrc)); }
|
||||||
|
|
||||||
/* ------------------------ STATIC METHODS ------------------------ */
|
/* ------------------------ STATIC METHODS ------------------------ */
|
|
@ -92,7 +92,7 @@ void metaCloseDB(SMeta *pMeta) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaSaveTableToDB(SMeta *pMeta, const STbOptions *pTbOptions) {
|
int metaSaveTableToDB(SMeta *pMeta, const STbCfg *pTbOptions) {
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
char * err = NULL;
|
char * err = NULL;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
@ -102,7 +102,7 @@ int metaSaveTableToDB(SMeta *pMeta, const STbOptions *pTbOptions) {
|
||||||
|
|
||||||
// Generate a uid for child and normal table
|
// Generate a uid for child and normal table
|
||||||
if (pTbOptions->type == META_SUPER_TABLE) {
|
if (pTbOptions->type == META_SUPER_TABLE) {
|
||||||
uid = pTbOptions->stbOptions.uid;
|
uid = pTbOptions->stbCfg.suid;
|
||||||
} else {
|
} else {
|
||||||
uid = metaGenerateUid(pMeta);
|
uid = metaGenerateUid(pMeta);
|
||||||
}
|
}
|
||||||
|
@ -117,22 +117,22 @@ int metaSaveTableToDB(SMeta *pMeta, const STbOptions *pTbOptions) {
|
||||||
switch (pTbOptions->type) {
|
switch (pTbOptions->type) {
|
||||||
case META_NORMAL_TABLE:
|
case META_NORMAL_TABLE:
|
||||||
// save schemaDB
|
// save schemaDB
|
||||||
metaSaveSchemaDB(pMeta, uid, pTbOptions->ntbOptions.pSchame);
|
metaSaveSchemaDB(pMeta, uid, pTbOptions->ntbCfg.pSchema);
|
||||||
break;
|
break;
|
||||||
case META_SUPER_TABLE:
|
case META_SUPER_TABLE:
|
||||||
// save schemaDB
|
// save schemaDB
|
||||||
metaSaveSchemaDB(pMeta, uid, pTbOptions->stbOptions.pSchema);
|
metaSaveSchemaDB(pMeta, uid, pTbOptions->stbCfg.pSchema);
|
||||||
|
|
||||||
// save mapDB (really need?)
|
// save mapDB (really need?)
|
||||||
rocksdb_put(pMeta->pDB->mapDb, wopt, (char *)(&uid), sizeof(uid), "", 0, &err);
|
rocksdb_put(pMeta->pDB->mapDb, wopt, (char *)(&uid), sizeof(uid), "", 0, &err);
|
||||||
break;
|
break;
|
||||||
case META_CHILD_TABLE:
|
case META_CHILD_TABLE:
|
||||||
// save tagDB
|
// save tagDB
|
||||||
rocksdb_put(pMeta->pDB->tagDb, wopt, (char *)(&uid), sizeof(uid), pTbOptions->ctbOptions.tags,
|
rocksdb_put(pMeta->pDB->tagDb, wopt, (char *)(&uid), sizeof(uid), pTbOptions->ctbCfg.pTag,
|
||||||
kvRowLen(pTbOptions->ctbOptions.tags), &err);
|
kvRowLen(pTbOptions->ctbCfg.pTag), &err);
|
||||||
|
|
||||||
// save mapDB
|
// save mapDB
|
||||||
metaSaveMapDB(pMeta, pTbOptions->ctbOptions.suid, uid);
|
metaSaveMapDB(pMeta, pTbOptions->ctbCfg.suid, uid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
|
|
@ -47,7 +47,7 @@ void metaCloseIdx(SMeta *pMeta) { /* TODO */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaSaveTableToIdx(SMeta *pMeta, const STbOptions *pTbOptions) {
|
int metaSaveTableToIdx(SMeta *pMeta, const STbCfg *pTbOptions) {
|
||||||
// TODO
|
// TODO
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -15,17 +15,14 @@
|
||||||
|
|
||||||
#include "tcoding.h"
|
#include "tcoding.h"
|
||||||
|
|
||||||
#include "meta.h"
|
|
||||||
#include "metaDB.h"
|
|
||||||
#include "metaDef.h"
|
#include "metaDef.h"
|
||||||
#include "metaOptions.h"
|
|
||||||
|
|
||||||
static SMeta *metaNew(const char *path, const SMetaOptions *pMetaOptions);
|
static SMeta *metaNew(const char *path, const SMetaCfg *pMetaOptions);
|
||||||
static void metaFree(SMeta *pMeta);
|
static void metaFree(SMeta *pMeta);
|
||||||
static int metaOpenImpl(SMeta *pMeta);
|
static int metaOpenImpl(SMeta *pMeta);
|
||||||
static void metaCloseImpl(SMeta *pMeta);
|
static void metaCloseImpl(SMeta *pMeta);
|
||||||
|
|
||||||
SMeta *metaOpen(const char *path, const SMetaOptions *pMetaOptions) {
|
SMeta *metaOpen(const char *path, const SMetaCfg *pMetaOptions) {
|
||||||
SMeta *pMeta = NULL;
|
SMeta *pMeta = NULL;
|
||||||
|
|
||||||
// Set default options
|
// Set default options
|
||||||
|
@ -68,7 +65,7 @@ void metaClose(SMeta *pMeta) {
|
||||||
void metaRemove(const char *path) { taosRemoveDir(path); }
|
void metaRemove(const char *path) { taosRemoveDir(path); }
|
||||||
|
|
||||||
/* ------------------------ STATIC METHODS ------------------------ */
|
/* ------------------------ STATIC METHODS ------------------------ */
|
||||||
static SMeta *metaNew(const char *path, const SMetaOptions *pMetaOptions) {
|
static SMeta *metaNew(const char *path, const SMetaCfg *pMetaOptions) {
|
||||||
SMeta *pMeta;
|
SMeta *pMeta;
|
||||||
size_t psize = strlen(path);
|
size_t psize = strlen(path);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "metaDef.h"
|
#include "metaDef.h"
|
||||||
|
|
||||||
int metaCreateTable(SMeta *pMeta, const STbOptions *pTbOptions) {
|
int metaCreateTable(SMeta *pMeta, const STbCfg *pTbOptions) {
|
||||||
// Validate the tbOptions
|
// Validate the tbOptions
|
||||||
if (metaValidateTbOptions(pMeta, pTbOptions) < 0) {
|
if (metaValidateTbOptions(pMeta, pTbOptions) < 0) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
#include "metaDef.h"
|
#include "metaDef.h"
|
||||||
#include "tcoding.h"
|
#include "tcoding.h"
|
||||||
|
|
||||||
int metaValidateTbOptions(SMeta *pMeta, const STbOptions *pTbOptions) {
|
int metaValidateTbOptions(SMeta *pMeta, const STbCfg *pTbOptions) {
|
||||||
// TODO
|
// TODO
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t metaEncodeTbObjFromTbOptions(const STbOptions *pTbOptions, void *pBuf, size_t bsize) {
|
size_t metaEncodeTbObjFromTbOptions(const STbCfg *pTbOptions, void *pBuf, size_t bsize) {
|
||||||
void **ppBuf = &pBuf;
|
void **ppBuf = &pBuf;
|
||||||
int tlen = 0;
|
int tlen = 0;
|
||||||
|
|
||||||
|
@ -31,12 +31,12 @@ size_t metaEncodeTbObjFromTbOptions(const STbOptions *pTbOptions, void *pBuf, si
|
||||||
|
|
||||||
switch (pTbOptions->type) {
|
switch (pTbOptions->type) {
|
||||||
case META_SUPER_TABLE:
|
case META_SUPER_TABLE:
|
||||||
tlen += taosEncodeFixedU64(ppBuf, pTbOptions->stbOptions.uid);
|
tlen += taosEncodeFixedU64(ppBuf, pTbOptions->stbCfg.suid);
|
||||||
tlen += tdEncodeSchema(ppBuf, pTbOptions->stbOptions.pTagSchema);
|
tlen += tdEncodeSchema(ppBuf, pTbOptions->stbCfg.pTagSchema);
|
||||||
// TODO: encode schema version array
|
// TODO: encode schema version array
|
||||||
break;
|
break;
|
||||||
case META_CHILD_TABLE:
|
case META_CHILD_TABLE:
|
||||||
tlen += taosEncodeFixedU64(ppBuf, pTbOptions->ctbOptions.suid);
|
tlen += taosEncodeFixedU64(ppBuf, pTbOptions->ctbCfg.suid);
|
||||||
break;
|
break;
|
||||||
case META_NORMAL_TABLE:
|
case META_NORMAL_TABLE:
|
||||||
// TODO: encode schema version array
|
// TODO: encode schema version array
|
Loading…
Reference in New Issue