Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mr、小李
TDengine
提交
73376165
T
TDengine
项目概览
Mr、小李
/
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,发现更多精彩内容 >>
提交
73376165
编写于
4月 19, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-100
上级
fdb0cbf6
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
51 addition
and
36 deletion
+51
-36
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+1
-1
src/tsdb/src/tsdbRWHelper.c
src/tsdb/src/tsdbRWHelper.c
+11
-3
src/tsdb/tests/tsdbTests.cpp
src/tsdb/tests/tsdbTests.cpp
+39
-32
未找到文件。
src/tsdb/src/tsdbMain.c
浏览文件 @
73376165
...
@@ -867,7 +867,7 @@ static void *tsdbCommitData(void *arg) {
...
@@ -867,7 +867,7 @@ static void *tsdbCommitData(void *arg) {
SRWHelper
whelper
=
{
0
};
SRWHelper
whelper
=
{
0
};
if
(
pCache
->
imem
==
NULL
)
return
NULL
;
if
(
pCache
->
imem
==
NULL
)
return
NULL
;
pRepo
->
appH
.
walCallBack
(
pRepo
->
appH
.
appH
);
if
(
pRepo
->
appH
.
walCallBack
)
pRepo
->
appH
.
walCallBack
(
pRepo
->
appH
.
appH
);
// Create the iterator to read from cache
// Create the iterator to read from cache
SSkipListIterator
**
iters
=
tsdbCreateTableIters
(
pMeta
,
pCfg
->
maxTables
);
SSkipListIterator
**
iters
=
tsdbCreateTableIters
(
pMeta
,
pCfg
->
maxTables
);
...
...
src/tsdb/src/tsdbRWHelper.c
浏览文件 @
73376165
...
@@ -29,7 +29,7 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
...
@@ -29,7 +29,7 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
static
int
tsdbInsertSuperBlock
(
SRWHelper
*
pHelper
,
SCompBlock
*
pCompBlock
,
int
blkIdx
);
static
int
tsdbInsertSuperBlock
(
SRWHelper
*
pHelper
,
SCompBlock
*
pCompBlock
,
int
blkIdx
);
static
int
tsdbAddSubBlock
(
SRWHelper
*
pHelper
,
SCompBlock
*
pCompBlock
,
int
blkIdx
,
int
rowsAdded
);
static
int
tsdbAddSubBlock
(
SRWHelper
*
pHelper
,
SCompBlock
*
pCompBlock
,
int
blkIdx
,
int
rowsAdded
);
static
int
tsdbUpdateSuperBlock
(
SRWHelper
*
pHelper
,
SCompBlock
*
pCompBlock
,
int
blkIdx
);
static
int
tsdbUpdateSuperBlock
(
SRWHelper
*
pHelper
,
SCompBlock
*
pCompBlock
,
int
blkIdx
);
static
int
tsdbGetRowsInRange
(
SDataCols
*
pDataCols
,
int
minKey
,
int
maxKey
);
static
int
tsdbGetRowsInRange
(
SDataCols
*
pDataCols
,
TSKEY
minKey
,
TSKEY
maxKey
);
static
void
tsdbResetHelperBlock
(
SRWHelper
*
pHelper
);
static
void
tsdbResetHelperBlock
(
SRWHelper
*
pHelper
);
// ---------- Operations on Helper File part
// ---------- Operations on Helper File part
...
@@ -934,7 +934,15 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
...
@@ -934,7 +934,15 @@ static int tsdbMergeDataWithBlock(SRWHelper *pHelper, int blkIdx, SDataCols *pDa
return
-
1
;
return
-
1
;
}
}
static
int
compTSKEY
(
const
void
*
key1
,
const
void
*
key2
)
{
return
((
TSKEY
*
)
key1
-
(
TSKEY
*
)
key2
);
}
static
int
compTSKEY
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(
*
(
TSKEY
*
)
key1
>
*
(
TSKEY
*
)
key2
)
{
return
1
;
}
else
if
(
*
(
TSKEY
*
)
key1
==
*
(
TSKEY
*
)
key2
)
{
return
0
;
}
else
{
return
-
1
;
}
}
static
int
tsdbAdjustInfoSizeIfNeeded
(
SRWHelper
*
pHelper
,
size_t
esize
)
{
static
int
tsdbAdjustInfoSizeIfNeeded
(
SRWHelper
*
pHelper
,
size_t
esize
)
{
...
@@ -1104,7 +1112,7 @@ static int tsdbUpdateSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int
...
@@ -1104,7 +1112,7 @@ static int tsdbUpdateSuperBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int
}
}
// Get the number of rows in range [minKey, maxKey]
// Get the number of rows in range [minKey, maxKey]
static
int
tsdbGetRowsInRange
(
SDataCols
*
pDataCols
,
int
minKey
,
int
maxKey
)
{
static
int
tsdbGetRowsInRange
(
SDataCols
*
pDataCols
,
TSKEY
minKey
,
TSKEY
maxKey
)
{
if
(
pDataCols
->
numOfPoints
==
0
)
return
0
;
if
(
pDataCols
->
numOfPoints
==
0
)
return
0
;
ASSERT
(
minKey
<=
maxKey
);
ASSERT
(
minKey
<=
maxKey
);
...
...
src/tsdb/tests/tsdbTests.cpp
浏览文件 @
73376165
...
@@ -13,6 +13,7 @@ static double getCurTime() {
...
@@ -13,6 +13,7 @@ static double getCurTime() {
typedef
struct
{
typedef
struct
{
TsdbRepoT
*
pRepo
;
TsdbRepoT
*
pRepo
;
bool
isAscend
;
int
tid
;
int
tid
;
int64_t
uid
;
int64_t
uid
;
int
sversion
;
int
sversion
;
...
@@ -41,7 +42,11 @@ static int insertData(SInsertInfo *pInfo) {
...
@@ -41,7 +42,11 @@ static int insertData(SInsertInfo *pInfo) {
pBlock
->
len
=
0
;
pBlock
->
len
=
0
;
for
(
int
i
=
0
;
i
<
pInfo
->
rowsPerSubmit
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pInfo
->
rowsPerSubmit
;
i
++
)
{
// start_time += 1000;
// start_time += 1000;
if
(
pInfo
->
isAscend
)
{
start_time
+=
pInfo
->
interval
;
start_time
+=
pInfo
->
interval
;
}
else
{
start_time
-=
pInfo
->
interval
;
}
SDataRow
row
=
(
SDataRow
)(
pBlock
->
data
+
pBlock
->
len
);
SDataRow
row
=
(
SDataRow
)(
pBlock
->
data
+
pBlock
->
len
);
tdInitDataRow
(
row
,
pInfo
->
pSchema
);
tdInitDataRow
(
row
,
pInfo
->
pSchema
);
...
@@ -155,12 +160,14 @@ TEST(TsdbTest, createRepo) {
...
@@ -155,12 +160,14 @@ TEST(TsdbTest, createRepo) {
// Insert Some Data
// Insert Some Data
SInsertInfo
iInfo
=
{
SInsertInfo
iInfo
=
{
.
pRepo
=
pRepo
,
.
pRepo
=
pRepo
,
// .isAscend = true,
.
isAscend
=
false
,
.
tid
=
tCfg
.
tableId
.
tid
,
.
tid
=
tCfg
.
tableId
.
tid
,
.
uid
=
tCfg
.
tableId
.
uid
,
.
uid
=
tCfg
.
tableId
.
uid
,
.
sversion
=
tCfg
.
sversion
,
.
sversion
=
tCfg
.
sversion
,
.
startTime
=
1584081000000
,
.
startTime
=
1584081000000
,
.
interval
=
1000
,
.
interval
=
1000
,
.
totalRows
=
50
,
.
totalRows
=
50
00000
,
.
rowsPerSubmit
=
1
,
.
rowsPerSubmit
=
1
,
.
pSchema
=
schema
.
pSchema
=
schema
};
};
...
@@ -175,34 +182,34 @@ TEST(TsdbTest, createRepo) {
...
@@ -175,34 +182,34 @@ TEST(TsdbTest, createRepo) {
repo
=
(
STsdbRepo
*
)
pRepo
;
repo
=
(
STsdbRepo
*
)
pRepo
;
ASSERT_NE
(
pRepo
,
nullptr
);
ASSERT_NE
(
pRepo
,
nullptr
);
// Insert more data
//
//
Insert more data
iInfo
.
startTime
=
iInfo
.
startTime
+
iInfo
.
interval
*
iInfo
.
totalRows
;
//
iInfo.startTime = iInfo.startTime + iInfo.interval * iInfo.totalRows;
iInfo
.
totalRows
=
10
;
//
iInfo.totalRows = 10;
iInfo
.
pRepo
=
pRepo
;
//
iInfo.pRepo = pRepo;
ASSERT_EQ
(
insertData
(
&
iInfo
),
0
);
//
ASSERT_EQ(insertData(&iInfo), 0);
// Close the repository
//
//
Close the repository
tsdbCloseRepo
(
pRepo
);
//
tsdbCloseRepo(pRepo);
// Open the repository again
//
//
Open the repository again
pRepo
=
tsdbOpenRepo
(
"/home/ubuntu/work/ttest/vnode0"
,
NULL
);
//
pRepo = tsdbOpenRepo("/home/ubuntu/work/ttest/vnode0", NULL);
repo
=
(
STsdbRepo
*
)
pRepo
;
//
repo = (STsdbRepo *)pRepo;
ASSERT_NE
(
pRepo
,
nullptr
);
//
ASSERT_NE(pRepo, nullptr);
// Read from file
//
//
Read from file
SRWHelper
rhelper
;
//
SRWHelper rhelper;
tsdbInitReadHelper
(
&
rhelper
,
repo
);
//
tsdbInitReadHelper(&rhelper, repo);
SFileGroup
*
pFGroup
=
tsdbSearchFGroup
(
repo
->
tsdbFileH
,
1833
);
//
SFileGroup *pFGroup = tsdbSearchFGroup(repo->tsdbFileH, 1833);
ASSERT_NE
(
pFGroup
,
nullptr
);
//
ASSERT_NE(pFGroup, nullptr);
ASSERT_GE
(
tsdbSetAndOpenHelperFile
(
&
rhelper
,
pFGroup
),
0
);
//
ASSERT_GE(tsdbSetAndOpenHelperFile(&rhelper, pFGroup), 0);
STable
*
pTable
=
tsdbGetTableByUid
(
repo
->
tsdbMeta
,
tCfg
.
tableId
.
uid
);
//
STable *pTable = tsdbGetTableByUid(repo->tsdbMeta, tCfg.tableId.uid);
ASSERT_NE
(
pTable
,
nullptr
);
//
ASSERT_NE(pTable, nullptr);
tsdbSetHelperTable
(
&
rhelper
,
pTable
,
repo
);
//
tsdbSetHelperTable(&rhelper, pTable, repo);
ASSERT_EQ
(
tsdbLoadCompInfo
(
&
rhelper
,
NULL
),
0
);
//
ASSERT_EQ(tsdbLoadCompInfo(&rhelper, NULL), 0);
ASSERT_EQ
(
tsdbLoadBlockData
(
&
rhelper
,
blockAtIdx
(
&
rhelper
,
0
),
NULL
),
0
);
//
ASSERT_EQ(tsdbLoadBlockData(&rhelper, blockAtIdx(&rhelper, 0), NULL), 0);
int
k
=
0
;
int
k
=
0
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录