Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱划水de鲸鱼哥~
TDengine
提交
35b52a5f
T
TDengine
项目概览
爱划水de鲸鱼哥~
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
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,发现更多精彩内容 >>
提交
35b52a5f
编写于
3月 21, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-34
上级
c0578258
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
41 deletion
+46
-41
src/common/inc/dataformat.h
src/common/inc/dataformat.h
+2
-0
src/vnode/tsdb/inc/tsdbMeta.h
src/vnode/tsdb/inc/tsdbMeta.h
+19
-13
src/vnode/tsdb/src/tsdbMain.c
src/vnode/tsdb/src/tsdbMain.c
+12
-7
src/vnode/tsdb/src/tsdbMeta.c
src/vnode/tsdb/src/tsdbMeta.c
+12
-19
src/vnode/tsdb/tests/tsdbTests.cpp
src/vnode/tsdb/tests/tsdbTests.cpp
+1
-2
未找到文件。
src/common/inc/dataformat.h
浏览文件 @
35b52a5f
...
...
@@ -81,11 +81,13 @@ STSchema *tdDecodeSchema(void **psrc);
*/
typedef
void
*
SDataRow
;
#define TD_DATA_ROW_HEAD_SIZE (2 * sizeof(int32_t))
#define dataRowLen(r) (*(int32_t *)(r))
#define dataRowFLen(r) (*(int32_t *)((char *)(r) + sizeof(int32_t)))
#define dataRowTuple(r) ((char *)(r) + TD_DATA_ROW_HEAD_SIZE)
#define dataRowKey(r) (*(TSKEY *)(dataRowTuple(r)))
#define dataRowSetLen(r, l) (dataRowLen(r) = (l))
#define dataRowSetFLen(r, l) (dataRowFLen(r) = (l))
#define dataRowIdx(r, i) ((char *)(r) + i)
...
...
src/vnode/tsdb/inc/tsdbMeta.h
浏览文件 @
35b52a5f
...
...
@@ -33,20 +33,25 @@ extern "C" {
#define IS_CREATE_STABLE(pCfg) ((pCfg)->tagValues != NULL)
typedef
struct
{
TSKEY
keyFirst
;
TSKEY
keyLast
;
int32_t
numOfPoints
;
void
*
pData
;
}
SMemTable
;
// ---------- TSDB TABLE DEFINITION
typedef
struct
STable
{
int8_t
type
;
STableId
tableId
;
int32_t
superUid
;
// Super table UID
int32_t
sversion
;
STSchema
*
schema
;
STSchema
*
tagSchema
;
SDataRow
tagVal
;
union
{
void
*
pData
;
// For TSDB_NORMAL_TABLE and TSDB_CHILD_TABLE, it is the skiplist for cache data
void
*
pIndex
;
// For TSDB_SUPER_TABLE, it is the skiplist index
}
content
;
void
*
iData
;
// Skiplist to commit
int8_t
type
;
STableId
tableId
;
int32_t
superUid
;
// Super table UID
int32_t
sversion
;
STSchema
*
schema
;
STSchema
*
tagSchema
;
SDataRow
tagVal
;
SMemTable
*
mem
;
SMemTable
*
imem
;
void
*
pIndex
;
// For TSDB_SUPER_TABLE, it is the skiplist index
void
*
eventHandler
;
// TODO
void
*
streamHandler
;
// TODO
struct
STable
*
next
;
// TODO: remove the next
...
...
@@ -94,8 +99,9 @@ int32_t tsdbFreeMeta(STsdbMeta *pMeta);
int32_t
tsdbCreateTableImpl
(
STsdbMeta
*
pMeta
,
STableCfg
*
pCfg
);
int32_t
tsdbDropTableImpl
(
STsdbMeta
*
pMeta
,
STableId
tableId
);
STable
*
tsdbIsValidTableToInsert
(
STsdbMeta
*
pMeta
,
STableId
tableId
);
int32_t
tsdbInsertRowToTableImpl
(
SSkipListNode
*
pNode
,
STable
*
pTable
);
//
int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable);
STable
*
tsdbGetTableByUid
(
STsdbMeta
*
pMeta
,
int64_t
uid
);
char
*
getTupleKey
(
const
void
*
data
);
#ifdef __cplusplus
}
...
...
src/vnode/tsdb/src/tsdbMain.c
浏览文件 @
35b52a5f
...
...
@@ -311,10 +311,9 @@ int32_t tsdbTriggerCommit(tsdb_repo_t *repo) {
// Loop to move pData to iData
for
(
int
i
=
0
;
i
<
pRepo
->
config
.
maxTables
;
i
++
)
{
STable
*
pTable
=
pRepo
->
tsdbMeta
->
tables
[
i
];
if
(
pTable
!=
NULL
)
{
void
*
pData
=
pTable
->
content
.
pData
;
pTable
->
content
.
pData
=
NULL
;
pTable
->
iData
=
pData
;
if
(
pTable
!=
NULL
&&
pTable
->
mem
!=
NULL
)
{
pTable
->
imem
=
pTable
->
mem
;
pTable
->
mem
=
NULL
;
}
}
// Loop to move mem to imem
...
...
@@ -669,7 +668,13 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable
int32_t
level
=
0
;
int32_t
headSize
=
0
;
tSkipListRandNodeInfo
(
pTable
->
content
.
pData
,
&
level
,
&
headSize
);
if
(
pTable
->
mem
==
NULL
)
{
pTable
->
mem
=
(
SMemTable
*
)
calloc
(
1
,
sizeof
(
SMemTable
));
if
(
pTable
->
mem
==
NULL
)
return
-
1
;
pTable
->
mem
->
pData
=
tSkipListCreate
(
5
,
TSDB_DATA_TYPE_TIMESTAMP
,
TYPE_BYTES
[
TSDB_DATA_TYPE_TIMESTAMP
],
0
,
0
,
getTupleKey
);
}
tSkipListRandNodeInfo
(
pTable
->
mem
->
pData
,
&
level
,
&
headSize
);
// Copy row into the memory
SSkipListNode
*
pNode
=
tsdbAllocFromCache
(
pRepo
->
tsdbCache
,
headSize
+
dataRowLen
(
row
));
...
...
@@ -681,7 +686,7 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable
dataRowCpy
(
SL_GET_NODE_DATA
(
pNode
),
row
);
// Insert the skiplist node into the data
t
sdbInsertRowToTableImpl
(
pNode
,
pTabl
e
);
t
SkipListPut
(
pTable
->
mem
->
pData
,
pNod
e
);
return
0
;
}
...
...
@@ -712,7 +717,7 @@ static void *tsdbCommitToFile(void *arg) {
for
(
int
i
=
0
;
i
<
pRepo
->
config
.
maxTables
;
i
++
)
{
STable
*
pTable
=
pMeta
->
tables
[
i
];
if
(
pTable
==
NULL
)
continue
;
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pTable
->
iData
);
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pTable
->
i
mem
->
p
Data
);
while
(
tSkipListIterNext
(
pIter
))
{
SSkipListNode
*
node
=
tSkipListIterGet
(
pIter
);
SDataRow
row
=
SL_GET_NODE_DATA
(
node
);
...
...
src/vnode/tsdb/src/tsdbMeta.c
浏览文件 @
35b52a5f
...
...
@@ -18,7 +18,6 @@ static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable);
static
int
tsdbAddTableIntoIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
static
int
tsdbRemoveTableFromIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
static
int
tsdbEstimateTableEncodeSize
(
STable
*
pTable
);
static
char
*
getTupleKey
(
const
void
*
data
);
/**
* Encode a TSDB table object as a binary content
...
...
@@ -102,12 +101,9 @@ int tsdbRestoreTable(void *pHandle, void *cont, int contLen) {
if
(
pTable
==
NULL
)
return
-
1
;
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
pTable
->
content
.
pIndex
=
pTable
->
pIndex
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
TSDB_DATA_TYPE_TIMESTAMP
,
sizeof
(
int64_t
),
1
,
0
,
getTupleKey
);
}
else
{
pTable
->
content
.
pData
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
TSDB_DATA_TYPE_TIMESTAMP
,
TYPE_BYTES
[
TSDB_DATA_TYPE_TIMESTAMP
],
0
,
0
,
getTupleKey
);
}
}
tsdbAddTableToMeta
(
pMeta
,
pTable
,
false
);
...
...
@@ -208,10 +204,10 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
super
->
schema
=
tdDupSchema
(
pCfg
->
schema
);
super
->
tagSchema
=
tdDupSchema
(
pCfg
->
tagSchema
);
super
->
tagVal
=
tdDataRowDup
(
pCfg
->
tagValues
);
super
->
content
.
pIndex
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
TSDB_DATA_TYPE_TIMESTAMP
,
sizeof
(
int64_t
),
1
,
super
->
pIndex
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
TSDB_DATA_TYPE_TIMESTAMP
,
sizeof
(
int64_t
),
1
,
0
,
getTupleKey
);
// Allow duplicate key, no lock
if
(
super
->
content
.
pIndex
==
NULL
)
{
if
(
super
->
pIndex
==
NULL
)
{
tdFreeSchema
(
super
->
schema
);
tdFreeSchema
(
super
->
tagSchema
);
tdFreeDataRow
(
super
->
tagVal
);
...
...
@@ -223,7 +219,7 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
}
}
STable
*
table
=
(
STable
*
)
malloc
(
sizeof
(
STable
));
STable
*
table
=
(
STable
*
)
calloc
(
1
,
sizeof
(
STable
));
if
(
table
==
NULL
)
{
if
(
newSuper
)
tsdbFreeTable
(
super
);
return
-
1
;
...
...
@@ -239,7 +235,6 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
table
->
superUid
=
-
1
;
table
->
schema
=
tdDupSchema
(
pCfg
->
schema
);
}
table
->
content
.
pData
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
TSDB_DATA_TYPE_TIMESTAMP
,
TYPE_BYTES
[
TSDB_DATA_TYPE_TIMESTAMP
],
0
,
0
,
getTupleKey
);
// Register to meta
if
(
newSuper
)
tsdbAddTableToMeta
(
pMeta
,
super
,
true
);
...
...
@@ -299,10 +294,10 @@ int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId) {
return
0
;
}
int32_t
tsdbInsertRowToTableImpl
(
SSkipListNode
*
pNode
,
STable
*
pTable
)
{
tSkipListPut
(
pTable
->
content
.
pData
,
pNode
);
return
0
;
}
//
int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable) {
// tSkipListPut(pTable->mem->
pData, pNode);
//
return 0;
//
}
static
int
tsdbFreeTable
(
STable
*
pTable
)
{
// TODO: finish this function
...
...
@@ -314,10 +309,8 @@ static int tsdbFreeTable(STable *pTable) {
// Free content
if
(
TSDB_TABLE_IS_SUPER_TABLE
(
pTable
))
{
tSkipListDestroy
(
pTable
->
content
.
pIndex
);
}
else
{
tSkipListDestroy
(
pTable
->
content
.
pData
);
}
tSkipListDestroy
(
pTable
->
pIndex
);
}
free
(
pTable
);
return
0
;
...
...
@@ -404,7 +397,7 @@ static int tsdbEstimateTableEncodeSize(STable *pTable) {
return
size
;
}
static
char
*
getTupleKey
(
const
void
*
data
)
{
char
*
getTupleKey
(
const
void
*
data
)
{
SDataRow
row
=
(
SDataRow
)
data
;
return
dataRowAt
(
row
,
TD_DATA_ROW_HEAD_SIZE
);
...
...
src/vnode/tsdb/tests/tsdbTests.cpp
浏览文件 @
35b52a5f
...
...
@@ -40,7 +40,6 @@ TEST(TsdbTest, tableEncodeDecode) {
ASSERT_EQ
(
pTable
->
superUid
,
tTable
->
superUid
);
ASSERT_EQ
(
pTable
->
sversion
,
tTable
->
sversion
);
ASSERT_EQ
(
memcmp
(
pTable
->
schema
,
tTable
->
schema
,
sizeof
(
STSchema
)
+
sizeof
(
STColumn
)
*
nCols
),
0
);
ASSERT_EQ
(
tTable
->
content
.
pData
,
nullptr
);
}
TEST
(
TsdbTest
,
createRepo
)
{
...
...
@@ -72,7 +71,7 @@ TEST(TsdbTest, createRepo) {
tsdbCreateTable
(
pRepo
,
&
tCfg
);
// // 3. Loop to write some simple data
int
nRows
=
100
;
int
nRows
=
100
0
;
int
rowsPerSubmit
=
10
;
int64_t
start_time
=
1584081000000
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录