Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9001468b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9001468b
编写于
11月 22, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact
上级
416e6354
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
194 addition
and
225 deletion
+194
-225
include/common/trow.h
include/common/trow.h
+3
-2
include/common/tschema.h
include/common/tschema.h
+12
-9
include/dnode/vnode/meta/impl/metaImpl.h
include/dnode/vnode/meta/impl/metaImpl.h
+0
-75
include/dnode/vnode/meta/meta.h
include/dnode/vnode/meta/meta.h
+53
-16
include/dnode/vnode/vnode.h
include/dnode/vnode/vnode.h
+29
-29
source/dnode/mgmt/src/dnodeVnodes.c
source/dnode/mgmt/src/dnodeVnodes.c
+18
-16
source/dnode/vnode/impl/inc/vnodeCfg.h
source/dnode/vnode/impl/inc/vnodeCfg.h
+6
-6
source/dnode/vnode/impl/inc/vnodeDef.h
source/dnode/vnode/impl/inc/vnodeDef.h
+11
-11
source/dnode/vnode/impl/src/vnodeBufferPool.c
source/dnode/vnode/impl/src/vnodeBufferPool.c
+2
-2
source/dnode/vnode/impl/src/vnodeCfg.c
source/dnode/vnode/impl/src/vnodeCfg.c
+6
-6
source/dnode/vnode/impl/src/vnodeMain.c
source/dnode/vnode/impl/src/vnodeMain.c
+10
-10
source/dnode/vnode/meta/inc/metaCfg.h
source/dnode/vnode/meta/inc/metaCfg.h
+6
-6
source/dnode/vnode/meta/inc/metaDB.h
source/dnode/vnode/meta/inc/metaDB.h
+1
-1
source/dnode/vnode/meta/inc/metaDef.h
source/dnode/vnode/meta/inc/metaDef.h
+3
-3
source/dnode/vnode/meta/inc/metaIdx.h
source/dnode/vnode/meta/inc/metaIdx.h
+1
-1
source/dnode/vnode/meta/inc/metaTbCfg.h
source/dnode/vnode/meta/inc/metaTbCfg.h
+9
-5
source/dnode/vnode/meta/src/metaCache.c
source/dnode/vnode/meta/src/metaCache.c
+2
-2
source/dnode/vnode/meta/src/metaCfg.c
source/dnode/vnode/meta/src/metaCfg.c
+5
-5
source/dnode/vnode/meta/src/metaDB.c
source/dnode/vnode/meta/src/metaDB.c
+7
-7
source/dnode/vnode/meta/src/metaIdx.c
source/dnode/vnode/meta/src/metaIdx.c
+1
-1
source/dnode/vnode/meta/src/metaMain.c
source/dnode/vnode/meta/src/metaMain.c
+3
-6
source/dnode/vnode/meta/src/metaTable.c
source/dnode/vnode/meta/src/metaTable.c
+1
-1
source/dnode/vnode/meta/src/metaTbCfg.c
source/dnode/vnode/meta/src/metaTbCfg.c
+5
-5
未找到文件。
include/common/trow.h
浏览文件 @
9001468b
...
...
@@ -18,6 +18,7 @@
#include "os.h"
#include "tbuffer.h"
#include "tdataformat.h"
#include "tdef.h"
#include "tschema.h"
...
...
@@ -91,8 +92,8 @@ typedef struct {
}
SRowBuilder
;
typedef
struct
{
SSchema
*
pSchema
;
SRow
*
pRow
;
S
T
Schema
*
pSchema
;
SRow
*
pRow
;
}
SRowReader
;
typedef
struct
{
...
...
include/common/tschema.h
浏览文件 @
9001468b
...
...
@@ -25,7 +25,8 @@ extern "C" {
typedef
uint16_t
col_id_t
;
typedef
struct
SColumn
{
#if 0
typedef struct STColumn {
/// column name
char *cname;
union {
...
...
@@ -45,9 +46,9 @@ typedef struct SColumn {
};
/// comment about the column
char *comment;
}
SColumn
;
} S
T
Column;
typedef
struct
SSchema
{
typedef struct S
T
Schema {
/// schema version
uint16_t sver;
/// number of columns
...
...
@@ -58,20 +59,22 @@ typedef struct SSchema {
SArray *smaArray;
};
/// column info
SColumn
cols
[];
}
SSchema
;
S
T
Column cols[];
} S
T
Schema;
typedef struct {
uint64_t
size
;
SSchema
*
pSchema
;
}
SShemaBuilder
;
uint64_t
size;
S
T
Schema *pSchema;
} S
T
ShemaBuilder;
#define tSchemaBuilderInit(target, capacity) \
{ .size = (capacity), .pSchema = (target) }
void
tSchemaBuilderSetSver
(
SShemaBuilder
*
pSchemaBuilder
,
uint16_t
sver
);
void tSchemaBuilderSetSver(S
T
ShemaBuilder *pSchemaBuilder, uint16_t sver);
void tSchemaBuilderSetSMA(bool sma, SArray *smaArray);
int tSchemaBuilderPutColumn(char *cname, bool sma, uint8_t type, col_id_t cid, uint32_t bytes, char *comment);
#endif
#ifdef __cplusplus
}
#endif
...
...
include/dnode/vnode/meta/impl/metaImpl.h
已删除
100644 → 0
浏览文件 @
416e6354
/*
* 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_*/
\ No newline at end of file
include/dnode/vnode/meta/meta.h
浏览文件 @
9001468b
...
...
@@ -16,38 +16,75 @@
#ifndef _TD_META_H_
#define _TD_META_H_
#include "impl/metaImpl.h"
#include "os.h"
#include "trow.h"
#ifdef __cplusplus
extern
"C"
{
#endif
// Types exported
typedef
struct
SMeta
SMeta
;
typedef
struct
SMetaOptions
SMetaOptions
;
typedef
struct
STbOptions
STbOptions
;
typedef
uint64_t
tb_uid_t
;
typedef
struct
SMeta
SMeta
;
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
*
metaOpen
(
const
char
*
path
,
const
SMeta
Options
*
pOptions
);
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMeta
Cfg
*
pOptions
);
void
metaClose
(
SMeta
*
pMeta
);
void
metaRemove
(
const
char
*
path
);
int
metaCreateTable
(
SMeta
*
pMeta
,
const
STb
Options
*
pTbOptions
);
int
metaCreateTable
(
SMeta
*
pMeta
,
const
STb
Cfg
*
pTbOptions
);
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaCommit
(
SMeta
*
pMeta
);
// Options
void
metaOptionsInit
(
SMeta
Options
*
pOptions
);
void
metaOptionsClear
(
SMeta
Options
*
pOptions
);
void
metaOptionsInit
(
SMeta
Cfg
*
pOptions
);
void
metaOptionsClear
(
SMeta
Cfg
*
pOptions
);
// STableOpts
#define META_TABLE_OPTS_DECLARE(name) STableOpts name = {0}
void
metaNormalTableOptsInit
(
STbOptions
*
pTbOptions
,
const
char
*
name
,
const
STSchema
*
pSchema
);
void
metaSuperTableOptsInit
(
STbOptions
*
pTbOptions
,
const
char
*
name
,
tb_uid_t
uid
,
const
STSchema
*
pSchema
,
const
STSchema
*
pTagSchema
);
void
metaChildTableOptsInit
(
STbOptions
*
pTbOptions
,
const
char
*
name
,
tb_uid_t
suid
,
const
SKVRow
tags
);
void
metaTableOptsClear
(
STbOptions
*
pTbOptions
);
uint64_t
metaEncodeTbOptions
(
void
**
pBuf
,
STbOptions
*
pTbOptions
);
STbOptions
*
metaDecodeTbOptions
(
void
*
pBuf
,
size_t
size
,
bool
endian
);
//
#define META_TABLE_OPTS_DECLARE(name) STableOpts name = {0}
// void metaNormalTableOptsInit(STbCfg
*pTbOptions, const char *name, const STSchema *pSchema);
// void metaSuperTableOptsInit(STbCfg
*pTbOptions, const char *name, tb_uid_t uid, const STSchema *pSchema,
//
const STSchema *pTagSchema);
// void metaChildTableOptsInit(STbCfg
*pTbOptions, const char *name, tb_uid_t suid, const SKVRow tags);
// void metaTableOptsClear(STbCfg
*pTbOptions);
// uint64_t metaEncodeTbOptions(void **pBuf, STbCfg
*pTbOptions);
// STbCfg *
metaDecodeTbOptions(void *pBuf, size_t size, bool endian);
#ifdef __cplusplus
}
...
...
include/dnode/vnode/vnode.h
浏览文件 @
9001468b
...
...
@@ -29,8 +29,8 @@ extern "C" {
#endif
/* ------------------------ TYPES EXPOSED ------------------------ */
typedef
struct
SVnode
SVnode
;
typedef
struct
SVnode
Options
SVnodeOptions
;
typedef
struct
SVnode
SVnode
;
typedef
struct
SVnode
Cfg
SVnodeCfg
;
/* ------------------------ SVnode ------------------------ */
/**
...
...
@@ -40,7 +40,7 @@ typedef struct SVnodeOptions SVnodeOptions;
* @param pVnodeOptions options of the vnode
* @return SVnode* The vnode object
*/
SVnode
*
vnodeOpen
(
const
char
*
path
,
const
SVnode
Options
*
pVnodeOptions
);
SVnode
*
vnodeOpen
(
const
char
*
path
,
const
SVnode
Cfg
*
pVnodeOptions
);
/**
* @brief Close a VNODE
...
...
@@ -85,23 +85,23 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
*/
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
/* ------------------------ SVnode
Options
------------------------ */
/* ------------------------ SVnode
Cfg
------------------------ */
/**
* @brief Initialize VNODE options.
*
* @param pOptions The options object to be initialized. It should not be NULL.
*/
void
vnodeOptionsInit
(
SVnode
Options
*
pOptions
);
void
vnodeOptionsInit
(
SVnode
Cfg
*
pOptions
);
/**
* @brief Clear VNODE options.
*
* @param pOptions Options to clear.
*/
void
vnodeOptionsClear
(
SVnode
Options
*
pOptions
);
void
vnodeOptionsClear
(
SVnode
Cfg
*
pOptions
);
/* ------------------------ STRUCT DEFINITIONS ------------------------ */
struct
SVnode
Options
{
struct
SVnode
Cfg
{
/**
* @brief write buffer size in BYTES
*
...
...
@@ -137,7 +137,7 @@ struct SVnodeOptions {
* @brief META options
*
*/
SMeta
Options
metaOptions
;
SMeta
Cfg
metaOptions
;
// STqOptions tqOptions; // TODO
};
...
...
@@ -148,27 +148,27 @@ struct SVnodeOptions {
#include "taosmsg.h"
#include "trpc.h"
typedef
struct
{
char
db
[
TSDB_FULL_DB_NAME_LEN
];
int32_t
cacheBlockSize
;
// MB
int32_t
totalBlocks
;
int32_t
daysPerFile
;
int32_t
daysToKeep0
;
int32_t
daysToKeep1
;
int32_t
daysToKeep2
;
int32_t
minRowsPerFileBlock
;
int32_t
maxRowsPerFileBlock
;
int8_t
precision
;
// time resolution
int8_t
compression
;
int8_t
cacheLastRow
;
int8_t
update
;
int8_t
quorum
;
int8_t
replica
;
int8_t
selfIndex
;
int8_t
walLevel
;
int32_t
fsyncPeriod
;
// millisecond
SReplica
replicas
[
TSDB_MAX_REPLICA
];
}
SVnodeCfg
;
//
typedef struct {
//
char db[TSDB_FULL_DB_NAME_LEN];
//
int32_t cacheBlockSize; // MB
//
int32_t totalBlocks;
//
int32_t daysPerFile;
//
int32_t daysToKeep0;
//
int32_t daysToKeep1;
//
int32_t daysToKeep2;
//
int32_t minRowsPerFileBlock;
//
int32_t maxRowsPerFileBlock;
//
int8_t precision; // time resolution
//
int8_t compression;
//
int8_t cacheLastRow;
//
int8_t update;
//
int8_t quorum;
//
int8_t replica;
//
int8_t selfIndex;
//
int8_t walLevel;
//
int32_t fsyncPeriod; // millisecond
//
SReplica replicas[TSDB_MAX_REPLICA];
//
} SVnodeCfg;
typedef
enum
{
VN_MSG_TYPE_WRITE
=
1
,
...
...
source/dnode/mgmt/src/dnodeVnodes.c
浏览文件 @
9001468b
...
...
@@ -15,8 +15,8 @@
#define _DEFAULT_SOURCE
#include "dnodeVnodes.h"
#include "dnodeTransport.h"
#include "cJSON.h"
#include "dnodeTransport.h"
#include "thash.h"
#include "tlockfree.h"
#include "tqueue.h"
...
...
@@ -30,7 +30,7 @@ typedef struct {
int32_t
refCount
;
int8_t
dropped
;
int8_t
accessState
;
SVnode
*
pImpl
;
SVnode
*
pImpl
;
taos_queue
pWriteQ
;
taos_queue
pSyncQ
;
taos_queue
pApplyQ
;
...
...
@@ -48,14 +48,14 @@ typedef struct {
}
SVThread
;
static
struct
{
SHashObj
*
hash
;
SHashObj
*
hash
;
SWorkerPool
mgmtPool
;
SWorkerPool
queryPool
;
SWorkerPool
fetchPool
;
SMWorkerPool
syncPool
;
SMWorkerPool
writePool
;
taos_queue
pMgmtQ
;
SSteps
*
pSteps
;
SSteps
*
pSteps
;
int32_t
openVnodes
;
int32_t
totalVnodes
;
SRWLatch
latch
;
...
...
@@ -169,7 +169,7 @@ static SVnodeObj **dnodeGetVnodesFromHash(int32_t *numOfVnodes) {
void
*
pIter
=
taosHashIterate
(
tsVnodes
.
hash
,
NULL
);
while
(
pIter
)
{
SVnodeObj
**
ppVnode
=
pIter
;
SVnodeObj
*
pVnode
=
*
ppVnode
;
SVnodeObj
*
pVnode
=
*
ppVnode
;
if
(
pVnode
)
{
num
++
;
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
len
=
0
;
int32_t
maxLen
=
30000
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
cJSON
*
root
=
NULL
;
FILE
*
fp
=
NULL
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
cJSON
*
root
=
NULL
;
FILE
*
fp
=
NULL
;
char
file
[
PATH_MAX
+
20
]
=
{
0
};
SVnodeObj
*
pVnodes
=
NULL
;
snprintf
(
file
,
PATH_MAX
+
20
,
"%s/vnodes.json"
,
tsVnodeDir
);
fp
=
fopen
(
file
,
"r"
);
if
(
!
fp
)
{
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
)
{
cJSON
*
vnode
=
cJSON_GetArrayItem
(
vnodes
,
i
);
cJSON
*
vnode
=
cJSON_GetArrayItem
(
vnodes
,
i
);
SVnodeObj
*
pVnode
=
&
pVnodes
[
i
];
cJSON
*
vgId
=
cJSON_GetObjectItem
(
vnode
,
"vgId"
);
...
...
@@ -281,7 +281,7 @@ static int32_t dnodeWriteVnodesToFile() {
int32_t
len
=
0
;
int32_t
maxLen
=
30000
;
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
char
*
content
=
calloc
(
1
,
maxLen
+
1
);
int32_t
numOfVnodes
=
0
;
SVnodeObj
**
pVnodes
=
dnodeGetVnodesFromHash
(
&
numOfVnodes
);
...
...
@@ -322,7 +322,7 @@ static int32_t dnodeCreateVnode(int32_t vgId, SVnodeCfg *pCfg) {
int32_t
code
=
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
);
if
(
pImpl
==
NULL
)
{
...
...
@@ -375,7 +375,7 @@ static void *dnodeOpenVnodeFunc(void *param) {
dnodeReportStartup
(
"open-vnodes"
,
stepDesc
);
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
);
if
(
pImpl
==
NULL
)
{
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
;
*
vgId
=
htonl
(
pCreate
->
vgId
);
#if 0
tstrncpy(pCfg->db, pCreate->db, TSDB_FULL_DB_NAME_LEN);
pCfg->cacheBlockSize = htonl(pCreate->cacheBlockSize);
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);
tstrncpy(pCfg->replicas[i].fqdn, pCreate->replicas[i].fqdn, TSDB_FQDN_LEN);
}
#endif
return
0
;
}
...
...
@@ -668,7 +670,7 @@ static void dnodeProcessVnodeMgmtQueue(void *unused, SRpcMsg *pMsg) {
break
;
case
TSDB_MSG_TYPE_AUTH_VNODE_IN
:
code
=
vnodeProcessAuthVnodeReq
(
pMsg
);
break
;
break
;
case
TSDB_MSG_TYPE_SYNC_VNODE_IN
:
code
=
vnodeProcessSyncVnodeReq
(
pMsg
);
break
;
...
...
@@ -696,7 +698,7 @@ static void dnodeProcessVnodeFetchQueue(SVnodeObj *pVnode, SVnodeMsg *pMsg) {
static
void
dnodeProcessVnodeWriteQueue
(
SVnodeObj
*
pVnode
,
taos_qall
qall
,
int32_t
numOfMsgs
)
{
SVnodeMsg
*
pMsg
=
vnodeInitMsg
(
numOfMsgs
);
SRpcMsg
*
pRpcMsg
=
NULL
;
SRpcMsg
*
pRpcMsg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
taosGetQitem
(
qall
,
(
void
**
)
&
pRpcMsg
);
...
...
@@ -1008,7 +1010,7 @@ void dnodeGetVnodeLoads(SVnodeLoads *pLoads) {
pLoads
->
num
=
taosHashGetSize
(
tsVnodes
.
hash
);
int32_t
v
=
0
;
void
*
pIter
=
taosHashIterate
(
tsVnodes
.
hash
,
NULL
);
void
*
pIter
=
taosHashIterate
(
tsVnodes
.
hash
,
NULL
);
while
(
pIter
)
{
SVnodeObj
**
ppVnode
=
pIter
;
if
(
ppVnode
==
NULL
)
continue
;
...
...
source/dnode/vnode/impl/inc/vnode
Options
.h
→
source/dnode/vnode/impl/inc/vnode
Cfg
.h
浏览文件 @
9001468b
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_VNODE_
OPTIONS
_H_
#define _TD_VNODE_
OPTIONS
_H_
#ifndef _TD_VNODE_
CFG
_H_
#define _TD_VNODE_
CFG
_H_
#include "vnode.h"
...
...
@@ -22,13 +22,13 @@
extern
"C"
{
#endif
extern
const
SVnode
Options
defaultVnodeOptions
;
extern
const
SVnode
Cfg
defaultVnodeOptions
;
int
vnodeValidateOptions
(
const
SVnode
Options
*
);
void
vnodeOptionsCopy
(
SVnode
Options
*
pDest
,
const
SVnodeOptions
*
pSrc
);
int
vnodeValidateOptions
(
const
SVnode
Cfg
*
);
void
vnodeOptionsCopy
(
SVnode
Cfg
*
pDest
,
const
SVnodeCfg
*
pSrc
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_VNODE_OPTIONS_H_*/
\ No newline at end of file
#endif
/*_TD_VNODE_CFG_H_*/
\ No newline at end of file
source/dnode/vnode/impl/inc/vnodeDef.h
浏览文件 @
9001468b
...
...
@@ -25,7 +25,7 @@
#include "vnodeBufferPool.h"
#include "vnodeCommit.h"
#include "vnodeFileSystem.h"
#include "vnode
Options
.h"
#include "vnode
Cfg
.h"
#include "vnodeStateMgr.h"
#include "vnodeSync.h"
...
...
@@ -34,16 +34,16 @@ extern "C" {
#endif
struct
SVnode
{
char
*
path
;
SVnode
Options
options
;
SVState
state
;
SVBufPool
*
pBufPool
;
SMeta
*
pMeta
;
STsdb
*
pTsdb
;
STQ
*
pTq
;
SWal
*
pWal
;
SVnodeSync
*
pSync
;
SVnodeFS
*
pFs
;
char
*
path
;
SVnode
Cfg
config
;
SVState
state
;
SVBufPool
*
pBufPool
;
SMeta
*
pMeta
;
STsdb
*
pTsdb
;
STQ
*
pTq
;
SWal
*
pWal
;
SVnodeSync
*
pSync
;
SVnodeFS
*
pFs
;
};
#ifdef __cplusplus
...
...
source/dnode/vnode/impl/src/vnodeBufferPool.c
浏览文件 @
9001468b
...
...
@@ -84,8 +84,8 @@ int vnodeOpenBufPool(SVnode *pVnode) {
tdListInit
(
&
(
pVnode
->
pBufPool
->
free
),
0
);
tdListInit
(
&
(
pVnode
->
pBufPool
->
incycle
),
0
);
capacity
=
pVnode
->
options
.
wsize
/
VNODE_BUF_POOL_SHARDS
;
if
(
pVnode
->
options
.
isHeapAllocator
)
{
capacity
=
pVnode
->
config
.
wsize
/
VNODE_BUF_POOL_SHARDS
;
if
(
pVnode
->
config
.
isHeapAllocator
)
{
type
=
E_V_HEAP_ALLOCATOR
;
}
...
...
source/dnode/vnode/impl/src/vnode
Options
.c
→
source/dnode/vnode/impl/src/vnode
Cfg
.c
浏览文件 @
9001468b
...
...
@@ -15,20 +15,20 @@
#include "vnodeDef.h"
const
SVnode
Options
defaultVnodeOptions
=
{
0
};
/* TODO */
const
SVnode
Cfg
defaultVnodeOptions
=
{
0
};
/* TODO */
void
vnodeOptionsInit
(
SVnode
Options
*
pVnodeOptions
)
{
/* TODO */
void
vnodeOptionsInit
(
SVnode
Cfg
*
pVnodeOptions
)
{
/* TODO */
vnodeOptionsCopy
(
pVnodeOptions
,
&
defaultVnodeOptions
);
}
void
vnodeOptionsClear
(
SVnode
Options
*
pVnodeOptions
)
{
/* TODO */
void
vnodeOptionsClear
(
SVnode
Cfg
*
pVnodeOptions
)
{
/* TODO */
}
int
vnodeValidateOptions
(
const
SVnode
Options
*
pVnodeOptions
)
{
int
vnodeValidateOptions
(
const
SVnode
Cfg
*
pVnodeOptions
)
{
// TODO
return
0
;
}
void
vnodeOptionsCopy
(
SVnode
Options
*
pDest
,
const
SVnodeOptions
*
pSrc
)
{
memcpy
((
void
*
)
pDest
,
(
void
*
)
pSrc
,
sizeof
(
SVnode
Options
));
void
vnodeOptionsCopy
(
SVnode
Cfg
*
pDest
,
const
SVnodeCfg
*
pSrc
)
{
memcpy
((
void
*
)
pDest
,
(
void
*
)
pSrc
,
sizeof
(
SVnode
Cfg
));
}
\ No newline at end of file
source/dnode/vnode/impl/src/vnodeMain.c
浏览文件 @
9001468b
...
...
@@ -15,27 +15,27 @@
#include "vnodeDef.h"
static
SVnode
*
vnodeNew
(
const
char
*
path
,
const
SVnode
Options
*
pVnodeOptions
);
static
SVnode
*
vnodeNew
(
const
char
*
path
,
const
SVnode
Cfg
*
pVnodeCfg
);
static
void
vnodeFree
(
SVnode
*
pVnode
);
static
int
vnodeOpenImpl
(
SVnode
*
pVnode
);
static
void
vnodeCloseImpl
(
SVnode
*
pVnode
);
SVnode
*
vnodeOpen
(
const
char
*
path
,
const
SVnode
Options
*
pVnodeOptions
)
{
SVnode
*
vnodeOpen
(
const
char
*
path
,
const
SVnode
Cfg
*
pVnodeCfg
)
{
SVnode
*
pVnode
=
NULL
;
// Set default options
if
(
pVnode
Options
==
NULL
)
{
pVnode
Options
=
&
defaultVnodeOptions
;
if
(
pVnode
Cfg
==
NULL
)
{
pVnode
Cfg
=
&
defaultVnodeOptions
;
}
// Validate options
if
(
vnodeValidateOptions
(
pVnode
Options
)
<
0
)
{
if
(
vnodeValidateOptions
(
pVnode
Cfg
)
<
0
)
{
// TODO
return
NULL
;
}
// Create the handle
pVnode
=
vnodeNew
(
path
,
pVnode
Options
);
pVnode
=
vnodeNew
(
path
,
pVnode
Cfg
);
if
(
pVnode
==
NULL
)
{
// TODO: handle error
return
NULL
;
...
...
@@ -62,7 +62,7 @@ void vnodeClose(SVnode *pVnode) {
void
vnodeDestroy
(
const
char
*
path
)
{
taosRemoveDir
(
path
);
}
/* ------------------------ STATIC METHODS ------------------------ */
static
SVnode
*
vnodeNew
(
const
char
*
path
,
const
SVnode
Options
*
pVnodeOptions
)
{
static
SVnode
*
vnodeNew
(
const
char
*
path
,
const
SVnode
Cfg
*
pVnodeCfg
)
{
SVnode
*
pVnode
=
NULL
;
pVnode
=
(
SVnode
*
)
calloc
(
1
,
sizeof
(
*
pVnode
));
...
...
@@ -72,7 +72,7 @@ static SVnode *vnodeNew(const char *path, const SVnodeOptions *pVnodeOptions) {
}
pVnode
->
path
=
strdup
(
path
);
vnodeOptionsCopy
(
&
(
pVnode
->
options
),
pVnodeOptions
);
vnodeOptionsCopy
(
&
(
pVnode
->
config
),
pVnodeCfg
);
return
pVnode
;
}
...
...
@@ -94,7 +94,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
// Open meta
sprintf
(
dir
,
"%s/meta"
,
pVnode
->
path
);
pVnode
->
pMeta
=
metaOpen
(
dir
,
&
(
pVnode
->
options
.
metaOptions
));
pVnode
->
pMeta
=
metaOpen
(
dir
,
&
(
pVnode
->
config
.
metaOptions
));
if
(
pVnode
->
pMeta
==
NULL
)
{
// TODO: handle error
return
-
1
;
...
...
@@ -102,7 +102,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
// Open tsdb
sprintf
(
dir
,
"%s/tsdb"
,
pVnode
->
path
);
pVnode
->
pTsdb
=
tsdbOpen
(
dir
,
&
(
pVnode
->
options
.
tsdbOptions
));
pVnode
->
pTsdb
=
tsdbOpen
(
dir
,
&
(
pVnode
->
config
.
tsdbOptions
));
if
(
pVnode
->
pTsdb
==
NULL
)
{
// TODO: handle error
return
-
1
;
...
...
source/dnode/vnode/meta/inc/meta
Options
.h
→
source/dnode/vnode/meta/inc/meta
Cfg
.h
浏览文件 @
9001468b
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_META_
OPTIONS
_H_
#define _TD_META_
OPTIONS
_H_
#ifndef _TD_META_
CFG
_H_
#define _TD_META_
CFG
_H_
#include "meta.h"
...
...
@@ -22,13 +22,13 @@
extern
"C"
{
#endif
extern
const
SMeta
Options
defaultMetaOptions
;
extern
const
SMeta
Cfg
defaultMetaOptions
;
int
metaValidateOptions
(
const
SMeta
Options
*
);
void
metaOptionsCopy
(
SMeta
Options
*
pDest
,
const
SMetaOptions
*
pSrc
);
int
metaValidateOptions
(
const
SMeta
Cfg
*
);
void
metaOptionsCopy
(
SMeta
Cfg
*
pDest
,
const
SMetaCfg
*
pSrc
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_META_OPTIONS_H_*/
\ No newline at end of file
#endif
/*_TD_META_CFG_H_*/
\ No newline at end of file
source/dnode/vnode/meta/inc/metaDB.h
浏览文件 @
9001468b
...
...
@@ -34,7 +34,7 @@ typedef struct {
int
metaOpenDB
(
SMeta
*
pMeta
);
void
metaCloseDB
(
SMeta
*
pMeta
);
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
const
STb
Options
*
pTbOptions
);
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
const
STb
Cfg
*
pTbOptions
);
int
metaRemoveTableFromDb
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
#ifdef __cplusplus
...
...
source/dnode/vnode/meta/inc/metaDef.h
浏览文件 @
9001468b
...
...
@@ -20,10 +20,10 @@
#include "meta.h"
#include "metaCache.h"
#include "metaCfg.h"
#include "metaDB.h"
#include "metaIdx.h"
#include "metaOptions.h"
#include "metaTbOptions.h"
#include "metaTbCfg.h"
#include "metaTbTag.h"
#include "metaTbUid.h"
...
...
@@ -33,7 +33,7 @@ extern "C" {
struct
SMeta
{
char
*
path
;
SMeta
Options
options
;
SMeta
Cfg
options
;
meta_db_t
*
pDB
;
meta_index_t
*
pIdx
;
meta_cache_t
*
pCache
;
...
...
source/dnode/vnode/meta/inc/metaIdx.h
浏览文件 @
9001468b
...
...
@@ -28,7 +28,7 @@ typedef rocksdb_t meta_index_t;
int
metaOpenIdx
(
SMeta
*
pMeta
);
void
metaCloseIdx
(
SMeta
*
pMeta
);
int
metaSaveTableToIdx
(
SMeta
*
pMeta
,
const
STb
Options
*
pTbOptions
);
int
metaSaveTableToIdx
(
SMeta
*
pMeta
,
const
STb
Cfg
*
pTbOptions
);
int
metaRemoveTableFromIdx
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
#ifdef __cplusplus
...
...
source/dnode/vnode/meta/inc/metaTb
Options
.h
→
source/dnode/vnode/meta/inc/metaTb
Cfg
.h
浏览文件 @
9001468b
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_META_TABLE_
OPTIONS
_H_
#define _TD_META_TABLE_
OPTIONS
_H_
#ifndef _TD_META_TABLE_
CFG
_H_
#define _TD_META_TABLE_
CFG
_H_
#include "meta.h"
...
...
@@ -22,11 +22,15 @@
extern
"C"
{
#endif
int
metaValidateTbOptions
(
SMeta
*
pMeta
,
const
STbOptions
*
);
size_t
metaEncodeTbObjFromTbOptions
(
const
STbOptions
*
,
void
*
pBuf
,
size_t
bsize
);
#define META_SUPER_TABLE 0
#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
}
#endif
#endif
/*_TD_META_TABLE_OPTIONS_H_*/
\ No newline at end of file
#endif
/*_TD_META_TABLE_CFG_H_*/
\ No newline at end of file
source/dnode/vnode/meta/src/metaCache.c
浏览文件 @
9001468b
...
...
@@ -18,8 +18,8 @@
int
metaOpenCache
(
SMeta
*
pMeta
)
{
// TODO
if
(
pMeta
->
options
.
lru
Cache
Size
)
{
pMeta
->
pCache
=
rocksdb_cache_create_lru
(
pMeta
->
options
.
lru
Cache
Size
);
if
(
pMeta
->
options
.
lruSize
)
{
pMeta
->
pCache
=
rocksdb_cache_create_lru
(
pMeta
->
options
.
lruSize
);
if
(
pMeta
->
pCache
==
NULL
)
{
// TODO: handle error
return
-
1
;
...
...
source/dnode/vnode/meta/src/meta
Options
.c
→
source/dnode/vnode/meta/src/meta
Cfg
.c
浏览文件 @
9001468b
...
...
@@ -15,20 +15,20 @@
#include "metaDef.h"
const
SMeta
Options
defaultMetaOptions
=
{.
lruCache
Size
=
0
};
const
SMeta
Cfg
defaultMetaOptions
=
{.
lru
Size
=
0
};
/* ------------------------ EXPOSED METHODS ------------------------ */
void
metaOptionsInit
(
SMeta
Options
*
pMetaOptions
)
{
metaOptionsCopy
(
pMetaOptions
,
&
defaultMetaOptions
);
}
void
metaOptionsInit
(
SMeta
Cfg
*
pMetaOptions
)
{
metaOptionsCopy
(
pMetaOptions
,
&
defaultMetaOptions
);
}
void
metaOptionsClear
(
SMeta
Options
*
pMetaOptions
)
{
void
metaOptionsClear
(
SMeta
Cfg
*
pMetaOptions
)
{
// TODO
}
int
metaValidateOptions
(
const
SMeta
Options
*
pMetaOptions
)
{
int
metaValidateOptions
(
const
SMeta
Cfg
*
pMetaOptions
)
{
// TODO
return
0
;
}
void
metaOptionsCopy
(
SMeta
Options
*
pDest
,
const
SMetaOptions
*
pSrc
)
{
memcpy
(
pDest
,
pSrc
,
sizeof
(
*
pSrc
));
}
void
metaOptionsCopy
(
SMeta
Cfg
*
pDest
,
const
SMetaCfg
*
pSrc
)
{
memcpy
(
pDest
,
pSrc
,
sizeof
(
*
pSrc
));
}
/* ------------------------ STATIC METHODS ------------------------ */
\ No newline at end of file
source/dnode/vnode/meta/src/metaDB.c
浏览文件 @
9001468b
...
...
@@ -92,7 +92,7 @@ void metaCloseDB(SMeta *pMeta) {
}
}
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
const
STb
Options
*
pTbOptions
)
{
int
metaSaveTableToDB
(
SMeta
*
pMeta
,
const
STb
Cfg
*
pTbOptions
)
{
tb_uid_t
uid
;
char
*
err
=
NULL
;
size_t
size
;
...
...
@@ -102,7 +102,7 @@ int metaSaveTableToDB(SMeta *pMeta, const STbOptions *pTbOptions) {
// Generate a uid for child and normal table
if
(
pTbOptions
->
type
==
META_SUPER_TABLE
)
{
uid
=
pTbOptions
->
stb
Options
.
uid
;
uid
=
pTbOptions
->
stb
Cfg
.
s
uid
;
}
else
{
uid
=
metaGenerateUid
(
pMeta
);
}
...
...
@@ -117,22 +117,22 @@ int metaSaveTableToDB(SMeta *pMeta, const STbOptions *pTbOptions) {
switch
(
pTbOptions
->
type
)
{
case
META_NORMAL_TABLE
:
// save schemaDB
metaSaveSchemaDB
(
pMeta
,
uid
,
pTbOptions
->
ntb
Options
.
pSchame
);
metaSaveSchemaDB
(
pMeta
,
uid
,
pTbOptions
->
ntb
Cfg
.
pSchema
);
break
;
case
META_SUPER_TABLE
:
// save schemaDB
metaSaveSchemaDB
(
pMeta
,
uid
,
pTbOptions
->
stb
Options
.
pSchema
);
metaSaveSchemaDB
(
pMeta
,
uid
,
pTbOptions
->
stb
Cfg
.
pSchema
);
// save mapDB (really need?)
rocksdb_put
(
pMeta
->
pDB
->
mapDb
,
wopt
,
(
char
*
)(
&
uid
),
sizeof
(
uid
),
""
,
0
,
&
err
);
break
;
case
META_CHILD_TABLE
:
// save tagDB
rocksdb_put
(
pMeta
->
pDB
->
tagDb
,
wopt
,
(
char
*
)(
&
uid
),
sizeof
(
uid
),
pTbOptions
->
ctb
Options
.
tags
,
kvRowLen
(
pTbOptions
->
ctb
Options
.
tags
),
&
err
);
rocksdb_put
(
pMeta
->
pDB
->
tagDb
,
wopt
,
(
char
*
)(
&
uid
),
sizeof
(
uid
),
pTbOptions
->
ctb
Cfg
.
pTag
,
kvRowLen
(
pTbOptions
->
ctb
Cfg
.
pTag
),
&
err
);
// save mapDB
metaSaveMapDB
(
pMeta
,
pTbOptions
->
ctb
Options
.
suid
,
uid
);
metaSaveMapDB
(
pMeta
,
pTbOptions
->
ctb
Cfg
.
suid
,
uid
);
break
;
default:
ASSERT
(
0
);
...
...
source/dnode/vnode/meta/src/metaIdx.c
浏览文件 @
9001468b
...
...
@@ -47,7 +47,7 @@ void metaCloseIdx(SMeta *pMeta) { /* TODO */
}
}
int
metaSaveTableToIdx
(
SMeta
*
pMeta
,
const
STb
Options
*
pTbOptions
)
{
int
metaSaveTableToIdx
(
SMeta
*
pMeta
,
const
STb
Cfg
*
pTbOptions
)
{
// TODO
return
0
;
}
\ No newline at end of file
source/dnode/vnode/meta/src/metaMain.c
浏览文件 @
9001468b
...
...
@@ -15,17 +15,14 @@
#include "tcoding.h"
#include "meta.h"
#include "metaDB.h"
#include "metaDef.h"
#include "metaOptions.h"
static
SMeta
*
metaNew
(
const
char
*
path
,
const
SMeta
Options
*
pMetaOptions
);
static
SMeta
*
metaNew
(
const
char
*
path
,
const
SMeta
Cfg
*
pMetaOptions
);
static
void
metaFree
(
SMeta
*
pMeta
);
static
int
metaOpenImpl
(
SMeta
*
pMeta
);
static
void
metaCloseImpl
(
SMeta
*
pMeta
);
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMeta
Options
*
pMetaOptions
)
{
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMeta
Cfg
*
pMetaOptions
)
{
SMeta
*
pMeta
=
NULL
;
// Set default options
...
...
@@ -68,7 +65,7 @@ void metaClose(SMeta *pMeta) {
void
metaRemove
(
const
char
*
path
)
{
taosRemoveDir
(
path
);
}
/* ------------------------ STATIC METHODS ------------------------ */
static
SMeta
*
metaNew
(
const
char
*
path
,
const
SMeta
Options
*
pMetaOptions
)
{
static
SMeta
*
metaNew
(
const
char
*
path
,
const
SMeta
Cfg
*
pMetaOptions
)
{
SMeta
*
pMeta
;
size_t
psize
=
strlen
(
path
);
...
...
source/dnode/vnode/meta/src/metaTable.c
浏览文件 @
9001468b
...
...
@@ -15,7 +15,7 @@
#include "metaDef.h"
int
metaCreateTable
(
SMeta
*
pMeta
,
const
STb
Options
*
pTbOptions
)
{
int
metaCreateTable
(
SMeta
*
pMeta
,
const
STb
Cfg
*
pTbOptions
)
{
// Validate the tbOptions
if
(
metaValidateTbOptions
(
pMeta
,
pTbOptions
)
<
0
)
{
// TODO: handle error
...
...
source/dnode/vnode/meta/src/metaTb
Options
.c
→
source/dnode/vnode/meta/src/metaTb
Cfg
.c
浏览文件 @
9001468b
...
...
@@ -16,12 +16,12 @@
#include "metaDef.h"
#include "tcoding.h"
int
metaValidateTbOptions
(
SMeta
*
pMeta
,
const
STb
Options
*
pTbOptions
)
{
int
metaValidateTbOptions
(
SMeta
*
pMeta
,
const
STb
Cfg
*
pTbOptions
)
{
// TODO
return
0
;
}
size_t
metaEncodeTbObjFromTbOptions
(
const
STb
Options
*
pTbOptions
,
void
*
pBuf
,
size_t
bsize
)
{
size_t
metaEncodeTbObjFromTbOptions
(
const
STb
Cfg
*
pTbOptions
,
void
*
pBuf
,
size_t
bsize
)
{
void
**
ppBuf
=
&
pBuf
;
int
tlen
=
0
;
...
...
@@ -31,12 +31,12 @@ size_t metaEncodeTbObjFromTbOptions(const STbOptions *pTbOptions, void *pBuf, si
switch
(
pTbOptions
->
type
)
{
case
META_SUPER_TABLE
:
tlen
+=
taosEncodeFixedU64
(
ppBuf
,
pTbOptions
->
stb
Options
.
uid
);
tlen
+=
tdEncodeSchema
(
ppBuf
,
pTbOptions
->
stb
Options
.
pTagSchema
);
tlen
+=
taosEncodeFixedU64
(
ppBuf
,
pTbOptions
->
stb
Cfg
.
s
uid
);
tlen
+=
tdEncodeSchema
(
ppBuf
,
pTbOptions
->
stb
Cfg
.
pTagSchema
);
// TODO: encode schema version array
break
;
case
META_CHILD_TABLE
:
tlen
+=
taosEncodeFixedU64
(
ppBuf
,
pTbOptions
->
ctb
Options
.
suid
);
tlen
+=
taosEncodeFixedU64
(
ppBuf
,
pTbOptions
->
ctb
Cfg
.
suid
);
break
;
case
META_NORMAL_TABLE
:
// TODO: encode schema version array
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录