Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
codyshao
TDengine
提交
aeef63f0
T
TDengine
项目概览
codyshao
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
aeef63f0
编写于
4月 06, 2020
作者:
S
slguan
提交者:
GitHub
4月 06, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1537 from taosdata/feature/2.0tsdb
Feature/2.0tsdb
上级
f8908155
ecd1e289
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
73 addition
and
15 deletion
+73
-15
src/common/inc/dataformat.h
src/common/inc/dataformat.h
+2
-1
src/common/src/dataformat.c
src/common/src/dataformat.c
+8
-2
src/os/linux/inc/os.h
src/os/linux/inc/os.h
+2
-0
src/os/linux/src/tlinux.c
src/os/linux/src/tlinux.c
+26
-0
src/vnode/main/src/vnodeMain.c
src/vnode/main/src/vnodeMain.c
+20
-9
src/vnode/tsdb/inc/tsdb.h
src/vnode/tsdb/inc/tsdb.h
+10
-1
src/vnode/tsdb/inc/tsdbMain.h
src/vnode/tsdb/inc/tsdbMain.h
+2
-0
src/vnode/tsdb/src/tsdbMain.c
src/vnode/tsdb/src/tsdbMain.c
+2
-1
src/vnode/tsdb/tests/tsdbTests.cpp
src/vnode/tsdb/tests/tsdbTests.cpp
+1
-1
未找到文件。
src/common/inc/dataformat.h
浏览文件 @
aeef63f0
...
...
@@ -110,7 +110,8 @@ typedef struct SDataCol {
int
bytes
;
int
len
;
int
offset
;
void
*
pData
;
void
*
pData
;
// Original data
void
*
pCData
;
// Compressed data
}
SDataCol
;
typedef
struct
{
...
...
src/common/src/dataformat.c
浏览文件 @
aeef63f0
...
...
@@ -317,14 +317,17 @@ void tdInitDataCols(SDataCols *pCols, STSchema *pSchema) {
pCols
->
numOfCols
=
schemaNCols
(
pSchema
);
pCols
->
cols
[
0
].
pData
=
pCols
->
buf
;
int
offset
=
TD_DATA_ROW_HEAD_SIZE
;
for
(
int
i
=
0
;
i
<
schemaNCols
(
pSchema
);
i
++
)
{
if
(
i
>
0
)
{
pCols
->
cols
[
i
].
pData
=
(
char
*
)(
pCols
->
cols
[
i
-
1
].
pData
)
+
schemaColAt
(
pSchema
,
i
-
1
)
->
bytes
*
pCols
->
maxPoints
;
}
pCols
->
cols
[
i
].
type
=
colType
(
schemaColAt
(
pSchema
,
i
));
pCols
->
cols
[
i
].
bytes
=
colBytes
(
schemaColAt
(
pSchema
,
i
));
pCols
->
cols
[
i
].
offset
=
colOffset
(
schemaColAt
(
pSchema
,
i
))
;
pCols
->
cols
[
i
].
offset
=
offset
;
pCols
->
cols
[
i
].
colId
=
colColId
(
schemaColAt
(
pSchema
,
i
));
offset
+=
TYPE_BYTES
[
pCols
->
cols
[
i
].
type
];
}
}
...
...
@@ -343,7 +346,6 @@ void tdResetDataCols(SDataCols *pCols) {
}
void
tdAppendDataRowToDataCol
(
SDataRow
row
,
SDataCols
*
pCols
)
{
TSKEY
key
=
dataRowKey
(
row
);
for
(
int
i
=
0
;
i
<
pCols
->
numOfCols
;
i
++
)
{
SDataCol
*
pCol
=
pCols
->
cols
+
i
;
memcpy
((
void
*
)((
char
*
)(
pCol
->
pData
)
+
pCol
->
len
),
dataRowAt
(
row
,
pCol
->
offset
),
pCol
->
bytes
);
...
...
@@ -379,3 +381,7 @@ static int tdFLenFromSchema(STSchema *pSchema) {
return
ret
;
}
int
tdMergeDataCols
(
SDataCols
*
target
,
SDataCols
*
source
)
{
return
0
;
}
\ No newline at end of file
src/os/linux/inc/os.h
浏览文件 @
aeef63f0
...
...
@@ -205,6 +205,8 @@ ssize_t tsendfile(int dfd, int sfd, off_t *offset, size_t size);
ssize_t
twrite
(
int
fd
,
void
*
buf
,
size_t
n
);
ssize_t
tread
(
int
fd
,
void
*
buf
,
size_t
count
);
bool
taosCheckPthreadValid
(
pthread_t
thread
);
void
taosResetPthread
(
pthread_t
*
thread
);
...
...
src/os/linux/src/tlinux.c
浏览文件 @
aeef63f0
...
...
@@ -291,6 +291,30 @@ int taosInitTimer(void (*callback)(int), int ms) {
return
0
;
}
ssize_t
tread
(
int
fd
,
void
*
buf
,
size_t
count
)
{
size_t
leftbytes
=
count
;
ssize_t
readbytes
;
char
*
tbuf
=
(
char
*
)
buf
;
while
(
leftbytes
>
0
)
{
readbytes
=
read
(
fd
,
(
void
*
)
tbuf
,
leftbytes
);
if
(
readbytes
<
0
)
{
if
(
errno
==
EINTR
)
{
continue
;
}
else
{
return
-
1
;
}
}
else
if
(
readbytes
==
0
)
{
return
(
ssize_t
)(
count
-
leftbytes
);
}
leftbytes
-=
readbytes
;
tbuf
+=
readbytes
;
}
return
(
ssize_t
)
count
;
}
ssize_t
tsendfile
(
int
dfd
,
int
sfd
,
off_t
*
offset
,
size_t
size
)
{
size_t
leftbytes
=
size
;
ssize_t
sentbytes
;
...
...
@@ -308,6 +332,8 @@ ssize_t tsendfile(int dfd, int sfd, off_t *offset, size_t size) {
else
{
return
-
1
;
}
}
else
if
(
sentbytes
==
0
)
{
return
(
ssize_t
)(
size
-
leftbytes
);
}
leftbytes
-=
sentbytes
;
...
...
src/vnode/main/src/vnodeMain.c
浏览文件 @
aeef63f0
...
...
@@ -32,6 +32,7 @@
static
void
*
tsDnodeVnodesHash
;
static
void
vnodeCleanUp
(
SVnodeObj
*
pVnode
);
static
void
vnodeBuildVloadMsg
(
char
*
pNode
,
void
*
param
);
static
int
vnodeWALCallback
(
void
*
arg
);
static
int
tsOpennedVnodes
;
static
pthread_once_t
vnodeModuleInit
=
PTHREAD_ONCE_INIT
;
...
...
@@ -120,24 +121,29 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
vnodeObj
.
version
=
0
;
SVnodeObj
*
pVnode
=
(
SVnodeObj
*
)
taosAddIntHash
(
tsDnodeVnodesHash
,
vnodeObj
.
vgId
,
(
char
*
)(
&
vnodeObj
));
sprintf
(
temp
,
"%s/tsdb"
,
rootDir
);
void
*
pTsdb
=
tsdbOpenRepo
(
temp
);
if
(
pTsdb
==
NULL
)
{
dError
(
"pVnode:%p vgId:%d, failed to open tsdb at %s(%s)"
,
pVnode
,
pVnode
->
vgId
,
temp
,
tstrerror
(
terrno
));
taosDeleteIntHash
(
tsDnodeVnodesHash
,
pVnode
->
vgId
);
return
terrno
;
}
pVnode
->
wqueue
=
dnodeAllocateWqueue
(
pVnode
);
pVnode
->
rqueue
=
dnodeAllocateRqueue
(
pVnode
);
sprintf
(
temp
,
"%s/wal"
,
rootDir
);
pVnode
->
wal
=
walOpen
(
temp
,
3
,
tsCommitLog
);
pVnode
->
tsdb
=
pTsdb
;
pVnode
->
sync
=
NULL
;
pVnode
->
events
=
NULL
;
pVnode
->
cq
=
NULL
;
STsdbAppH
appH
=
{
0
};
appH
.
appH
=
(
void
*
)
pVnode
;
appH
.
walCallBack
=
vnodeWALCallback
;
sprintf
(
temp
,
"%s/tsdb"
,
rootDir
);
void
*
pTsdb
=
tsdbOpenRepo
(
temp
,
&
appH
);
if
(
pTsdb
==
NULL
)
{
dError
(
"pVnode:%p vgId:%d, failed to open tsdb at %s(%s)"
,
pVnode
,
pVnode
->
vgId
,
temp
,
tstrerror
(
terrno
));
taosDeleteIntHash
(
tsDnodeVnodesHash
,
pVnode
->
vgId
);
return
terrno
;
}
pVnode
->
tsdb
=
pTsdb
;
walRestore
(
pVnode
->
wal
,
pVnode
,
vnodeWriteToQueue
);
pVnode
->
status
=
VN_STATUS_READY
;
...
...
@@ -249,3 +255,8 @@ static void vnodeCleanUp(SVnodeObj *pVnode) {
vnodeRelease
(
pVnode
);
}
static
int
vnodeWALCallback
(
void
*
arg
)
{
SVnodeObj
*
pVnode
=
arg
;
return
walRenew
(
pVnode
->
wal
);
}
\ No newline at end of file
src/vnode/tsdb/inc/tsdb.h
浏览文件 @
aeef63f0
...
...
@@ -34,6 +34,15 @@ extern "C" {
#define TSDB_INVALID_SUPER_TABLE_ID -1
// --------- TSDB APPLICATION HANDLE DEFINITION
typedef
struct
{
// WAL handle
void
*
appH
;
int
(
*
walCallBack
)(
void
*
);
int
(
*
eventCallBack
)(
void
*
);
int
(
*
cqueryCallBack
)(
void
*
);
}
STsdbAppH
;
// --------- TSDB REPOSITORY CONFIGURATION DEFINITION
typedef
struct
{
int8_t
precision
;
...
...
@@ -55,7 +64,7 @@ typedef void tsdb_repo_t; // use void to hide implementation details from outsi
int
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
,
void
*
limiter
);
int32_t
tsdbDropRepo
(
tsdb_repo_t
*
repo
);
tsdb_repo_t
*
tsdbOpenRepo
(
char
*
tsdbDir
);
tsdb_repo_t
*
tsdbOpenRepo
(
char
*
tsdbDir
,
STsdbAppH
*
pAppH
);
int32_t
tsdbCloseRepo
(
tsdb_repo_t
*
repo
);
int32_t
tsdbConfigRepo
(
tsdb_repo_t
*
repo
,
STsdbCfg
*
pCfg
);
int32_t
tsdbTriggerCommit
(
tsdb_repo_t
*
repo
);
...
...
src/vnode/tsdb/inc/tsdbMain.h
浏览文件 @
aeef63f0
...
...
@@ -322,6 +322,8 @@ typedef struct _tsdb_repo {
// TSDB configuration
STsdbCfg
config
;
STsdbAppH
appH
;
// The meter meta handle of this TSDB repository
STsdbMeta
*
tsdbMeta
;
...
...
src/vnode/tsdb/src/tsdbMain.c
浏览文件 @
aeef63f0
...
...
@@ -177,7 +177,7 @@ int32_t tsdbDropRepo(tsdb_repo_t *repo) {
*
* @return a TSDB repository handle on success, NULL for failure and the error number is set
*/
tsdb_repo_t
*
tsdbOpenRepo
(
char
*
tsdbDir
)
{
tsdb_repo_t
*
tsdbOpenRepo
(
char
*
tsdbDir
,
STsdbAppH
*
pAppH
)
{
char
dataDir
[
128
]
=
"
\0
"
;
if
(
access
(
tsdbDir
,
F_OK
|
W_OK
|
R_OK
)
<
0
)
{
return
NULL
;
...
...
@@ -191,6 +191,7 @@ tsdb_repo_t *tsdbOpenRepo(char *tsdbDir) {
pRepo
->
rootDir
=
strdup
(
tsdbDir
);
tsdbRestoreCfg
(
pRepo
,
&
(
pRepo
->
config
));
if
(
pAppH
)
pRepo
->
appH
=
*
pAppH
;
pRepo
->
tsdbMeta
=
tsdbInitMeta
(
tsdbDir
,
pRepo
->
config
.
maxTables
);
if
(
pRepo
->
tsdbMeta
==
NULL
)
{
...
...
src/vnode/tsdb/tests/tsdbTests.cpp
浏览文件 @
aeef63f0
...
...
@@ -140,7 +140,7 @@ TEST(TsdbTest, createRepo) {
// TEST(TsdbTest, DISABLED_openRepo) {
TEST
(
TsdbTest
,
openRepo
)
{
tsdb_repo_t
*
repo
=
tsdbOpenRepo
(
"/home/ubuntu/work/ttest/vnode0"
);
tsdb_repo_t
*
repo
=
tsdbOpenRepo
(
"/home/ubuntu/work/ttest/vnode0"
,
NULL
);
ASSERT_NE
(
repo
,
nullptr
);
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录