Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
f89fd3a4
T
TDengine
项目概览
慢慢CG
/
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看板
未验证
提交
f89fd3a4
编写于
4月 11, 2020
作者:
S
slguan
提交者:
GitHub
4月 11, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1584 from taosdata/hotfix/duplicate_key
fix duplicate commit key
上级
649465d7
0039bd87
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
98 addition
and
94 deletion
+98
-94
src/vnode/tsdb/src/tsdbMain.c
src/vnode/tsdb/src/tsdbMain.c
+2
-2
src/vnode/tsdb/tests/tsdbTests.cpp
src/vnode/tsdb/tests/tsdbTests.cpp
+96
-92
未找到文件。
src/vnode/tsdb/src/tsdbMain.c
浏览文件 @
f89fd3a4
...
@@ -763,6 +763,8 @@ static int tsdbReadRowsFromCache(SSkipListIterator *pIter, TSKEY maxKey, int max
...
@@ -763,6 +763,8 @@ static int tsdbReadRowsFromCache(SSkipListIterator *pIter, TSKEY maxKey, int max
int
numOfRows
=
0
;
int
numOfRows
=
0
;
do
{
do
{
if
(
numOfRows
>=
maxRowsToRead
)
break
;
SSkipListNode
*
node
=
tSkipListIterGet
(
pIter
);
SSkipListNode
*
node
=
tSkipListIterGet
(
pIter
);
if
(
node
==
NULL
)
break
;
if
(
node
==
NULL
)
break
;
...
@@ -770,9 +772,7 @@ static int tsdbReadRowsFromCache(SSkipListIterator *pIter, TSKEY maxKey, int max
...
@@ -770,9 +772,7 @@ static int tsdbReadRowsFromCache(SSkipListIterator *pIter, TSKEY maxKey, int max
if
(
dataRowKey
(
row
)
>
maxKey
)
break
;
if
(
dataRowKey
(
row
)
>
maxKey
)
break
;
tdAppendDataRowToDataCol
(
row
,
pCols
);
tdAppendDataRowToDataCol
(
row
,
pCols
);
numOfRows
++
;
numOfRows
++
;
if
(
numOfRows
>=
maxRowsToRead
)
break
;
}
while
(
tSkipListIterNext
(
pIter
));
}
while
(
tSkipListIterNext
(
pIter
));
return
numOfRows
;
return
numOfRows
;
...
...
src/vnode/tsdb/tests/tsdbTests.cpp
浏览文件 @
f89fd3a4
...
@@ -48,104 +48,104 @@ TEST(TsdbTest, DISABLED_tableEncodeDecode) {
...
@@ -48,104 +48,104 @@ TEST(TsdbTest, DISABLED_tableEncodeDecode) {
ASSERT_EQ
(
memcmp
(
pTable
->
schema
,
tTable
->
schema
,
sizeof
(
STSchema
)
+
sizeof
(
STColumn
)
*
nCols
),
0
);
ASSERT_EQ
(
memcmp
(
pTable
->
schema
,
tTable
->
schema
,
sizeof
(
STSchema
)
+
sizeof
(
STColumn
)
*
nCols
),
0
);
}
}
//
TEST(TsdbTest, DISABLED_createRepo) {
TEST
(
TsdbTest
,
DISABLED_createRepo
)
{
TEST
(
TsdbTest
,
createRepo
)
{
//
TEST(TsdbTest, createRepo) {
STsdbCfg
config
;
//
STsdbCfg config;
// 1. Create a tsdb repository
//
//
1. Create a tsdb repository
tsdbSetDefaultCfg
(
&
config
);
//
tsdbSetDefaultCfg(&config);
tsdb_repo_t
*
pRepo
=
tsdbCreateRepo
(
"/home/ubuntu/work/ttest/vnode0"
,
&
config
,
NULL
);
//
tsdb_repo_t *pRepo = tsdbCreateRepo("/home/ubuntu/work/ttest/vnode0", &config, NULL);
ASSERT_NE
(
pRepo
,
nullptr
);
//
ASSERT_NE(pRepo, nullptr);
// 2. Create a normal table
//
//
2. Create a normal table
STableCfg
tCfg
;
//
STableCfg tCfg;
ASSERT_EQ
(
tsdbInitTableCfg
(
&
tCfg
,
TSDB_SUPER_TABLE
,
987607499877672L
,
0
),
-
1
);
//
ASSERT_EQ(tsdbInitTableCfg(&tCfg, TSDB_SUPER_TABLE, 987607499877672L, 0), -1);
ASSERT_EQ
(
tsdbInitTableCfg
(
&
tCfg
,
TSDB_NORMAL_TABLE
,
987607499877672L
,
0
),
0
);
//
ASSERT_EQ(tsdbInitTableCfg(&tCfg, TSDB_NORMAL_TABLE, 987607499877672L, 0), 0);
int
nCols
=
5
;
//
int nCols = 5;
STSchema
*
schema
=
tdNewSchema
(
nCols
);
//
STSchema *schema = tdNewSchema(nCols);
for
(
int
i
=
0
;
i
<
nCols
;
i
++
)
{
//
for (int i = 0; i < nCols; i++) {
if
(
i
==
0
)
{
//
if (i == 0) {
tdSchemaAppendCol
(
schema
,
TSDB_DATA_TYPE_TIMESTAMP
,
i
,
-
1
);
//
tdSchemaAppendCol(schema, TSDB_DATA_TYPE_TIMESTAMP, i, -1);
}
else
{
//
} else {
tdSchemaAppendCol
(
schema
,
TSDB_DATA_TYPE_INT
,
i
,
-
1
);
//
tdSchemaAppendCol(schema, TSDB_DATA_TYPE_INT, i, -1);
}
//
}
}
//
}
tsdbTableSetSchema
(
&
tCfg
,
schema
,
true
);
//
tsdbTableSetSchema(&tCfg, schema, true);
tsdbCreateTable
(
pRepo
,
&
tCfg
);
//
tsdbCreateTable(pRepo, &tCfg);
// // 3. Loop to write some simple data
// //
//
3. Loop to write some simple data
int
nRows
=
1
;
//
int nRows = 1;
int
rowsPerSubmit
=
1
;
//
int rowsPerSubmit = 1;
int64_t
start_time
=
1584081000000
;
//
int64_t start_time = 1584081000000;
SSubmitMsg
*
pMsg
=
(
SSubmitMsg
*
)
malloc
(
sizeof
(
SSubmitMsg
)
+
sizeof
(
SSubmitBlk
)
+
tdMaxRowBytesFromSchema
(
schema
)
*
rowsPerSubmit
);
//
SSubmitMsg *pMsg = (SSubmitMsg *)malloc(sizeof(SSubmitMsg) + sizeof(SSubmitBlk) + tdMaxRowBytesFromSchema(schema) * rowsPerSubmit);
double
stime
=
getCurTime
();
//
double stime = getCurTime();
for
(
int
k
=
0
;
k
<
nRows
/
rowsPerSubmit
;
k
++
)
{
//
for (int k = 0; k < nRows/rowsPerSubmit; k++) {
memset
((
void
*
)
pMsg
,
0
,
sizeof
(
SSubmitMsg
));
//
memset((void *)pMsg, 0, sizeof(SSubmitMsg));
SSubmitBlk
*
pBlock
=
pMsg
->
blocks
;
//
SSubmitBlk *pBlock = pMsg->blocks;
pBlock
->
uid
=
987607499877672L
;
//
pBlock->uid = 987607499877672L;
pBlock
->
tid
=
0
;
//
pBlock->tid = 0;
pBlock
->
sversion
=
0
;
//
pBlock->sversion = 0;
pBlock
->
len
=
0
;
//
pBlock->len = 0;
for
(
int
i
=
0
;
i
<
rowsPerSubmit
;
i
++
)
{
//
for (int i = 0; i < rowsPerSubmit; i++) {
// start_time += 1000;
//
// start_time += 1000;
start_time
+=
1000
;
//
start_time += 1000;
SDataRow
row
=
(
SDataRow
)(
pBlock
->
data
+
pBlock
->
len
);
//
SDataRow row = (SDataRow)(pBlock->data + pBlock->len);
tdInitDataRow
(
row
,
schema
);
//
tdInitDataRow(row, schema);
for
(
int
j
=
0
;
j
<
schemaNCols
(
schema
);
j
++
)
{
//
for (int j = 0; j < schemaNCols(schema); j++) {
if
(
j
==
0
)
{
// Just for timestamp
//
if (j == 0) { // Just for timestamp
tdAppendColVal
(
row
,
(
void
*
)(
&
start_time
),
schemaColAt
(
schema
,
j
));
//
tdAppendColVal(row, (void *)(&start_time), schemaColAt(schema, j));
}
else
{
// For int
//
} else { // For int
int
val
=
10
;
//
int val = 10;
tdAppendColVal
(
row
,
(
void
*
)(
&
val
),
schemaColAt
(
schema
,
j
));
//
tdAppendColVal(row, (void *)(&val), schemaColAt(schema, j));
}
//
}
}
//
}
pBlock
->
len
+=
dataRowLen
(
row
);
//
pBlock->len += dataRowLen(row);
}
//
}
pMsg
->
length
=
pMsg
->
length
+
sizeof
(
SSubmitBlk
)
+
pBlock
->
len
;
//
pMsg->length = pMsg->length + sizeof(SSubmitBlk) + pBlock->len;
pMsg
->
numOfBlocks
=
1
;
//
pMsg->numOfBlocks = 1;
pBlock
->
len
=
htonl
(
pBlock
->
len
);
//
pBlock->len = htonl(pBlock->len);
pBlock
->
numOfRows
=
htonl
(
pBlock
->
numOfRows
);
//
pBlock->numOfRows = htonl(pBlock->numOfRows);
pBlock
->
uid
=
htobe64
(
pBlock
->
uid
);
//
pBlock->uid = htobe64(pBlock->uid);
pBlock
->
tid
=
htonl
(
pBlock
->
tid
);
//
pBlock->tid = htonl(pBlock->tid);
pBlock
->
sversion
=
htonl
(
pBlock
->
sversion
);
//
pBlock->sversion = htonl(pBlock->sversion);
pBlock
->
padding
=
htonl
(
pBlock
->
padding
);
//
pBlock->padding = htonl(pBlock->padding);
pMsg
->
length
=
htonl
(
pMsg
->
length
);
//
pMsg->length = htonl(pMsg->length);
pMsg
->
numOfBlocks
=
htonl
(
pMsg
->
numOfBlocks
);
//
pMsg->numOfBlocks = htonl(pMsg->numOfBlocks);
pMsg
->
compressed
=
htonl
(
pMsg
->
numOfBlocks
);
//
pMsg->compressed = htonl(pMsg->numOfBlocks);
tsdbInsertData
(
pRepo
,
pMsg
);
//
tsdbInsertData(pRepo, pMsg);
}
//
}
double
etime
=
getCurTime
();
//
double etime = getCurTime();
void
*
ptr
=
malloc
(
150000
);
//
void *ptr = malloc(150000);
free
(
ptr
);
//
free(ptr);
printf
(
"Spent %f seconds to write %d records
\n
"
,
etime
-
stime
,
nRows
);
//
printf("Spent %f seconds to write %d records\n", etime - stime, nRows);
tsdbCloseRepo
(
pRepo
);
//
tsdbCloseRepo(pRepo);
}
}
// TEST(TsdbTest, DISABLED_openRepo) {
// TEST(TsdbTest, DISABLED_openRepo) {
TEST
(
TsdbTest
,
openRepo
)
{
TEST
(
TsdbTest
,
openRepo
)
{
tsdb_repo_t
*
repo
=
tsdbOpenRepo
(
"/home/ubuntu/work/
ttest/vnode0
"
,
NULL
);
tsdb_repo_t
*
repo
=
tsdbOpenRepo
(
"/home/ubuntu/work/
build/test/data/vnode/vnode2/tsdb
"
,
NULL
);
ASSERT_NE
(
repo
,
nullptr
);
ASSERT_NE
(
repo
,
nullptr
);
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
SFileGroup
*
pGroup
=
tsdbSearchFGroup
(
pRepo
->
tsdbFileH
,
1
833
);
SFileGroup
*
pGroup
=
tsdbSearchFGroup
(
pRepo
->
tsdbFileH
,
1
655
);
for
(
int
type
=
TSDB_FILE_TYPE_HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
for
(
int
type
=
TSDB_FILE_TYPE_HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
tsdbOpenFile
(
&
pGroup
->
files
[
type
],
O_RDONLY
);
tsdbOpenFile
(
&
pGroup
->
files
[
type
],
O_RDONLY
);
...
@@ -156,7 +156,7 @@ TEST(TsdbTest, openRepo) {
...
@@ -156,7 +156,7 @@ TEST(TsdbTest, openRepo) {
SCompInfo
*
pCompInfo
=
(
SCompInfo
*
)
malloc
(
sizeof
(
SCompInfo
)
+
pIdx
[
1
].
len
);
SCompInfo
*
pCompInfo
=
(
SCompInfo
*
)
malloc
(
sizeof
(
SCompInfo
)
+
pIdx
[
1
].
len
);
tsdbLoadCompBlocks
(
pGroup
,
&
pIdx
[
0
],
(
void
*
)
pCompInfo
);
tsdbLoadCompBlocks
(
pGroup
,
&
pIdx
[
1
],
(
void
*
)
pCompInfo
);
int
blockIdx
=
0
;
int
blockIdx
=
0
;
SCompBlock
*
pBlock
=
&
(
pCompInfo
->
blocks
[
blockIdx
]);
SCompBlock
*
pBlock
=
&
(
pCompInfo
->
blocks
[
blockIdx
]);
...
@@ -166,11 +166,15 @@ TEST(TsdbTest, openRepo) {
...
@@ -166,11 +166,15 @@ TEST(TsdbTest, openRepo) {
tsdbLoadCompCols
(
&
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
],
pBlock
,
(
void
*
)
pCompData
);
tsdbLoadCompCols
(
&
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
],
pBlock
,
(
void
*
)
pCompData
);
STable
*
pTable
=
tsdbGetTableByUid
(
pRepo
->
tsdbMeta
,
pCompData
->
uid
);
STable
*
pTable
=
tsdbGetTableByUid
(
pRepo
->
tsdbMeta
,
pCompData
->
uid
);
SDataCols
*
pDataCols
=
tdNewDataCols
(
tdMaxRowBytesFromSchema
(
pTable
->
schema
),
5
,
10
);
SDataCols
*
pDataCols
=
tdNewDataCols
(
tdMaxRowBytesFromSchema
(
tsdbGetTableSchema
(
pRepo
->
tsdbMeta
,
pTable
)
),
5
,
10
);
tdInitDataCols
(
pDataCols
,
pTable
->
schema
);
tdInitDataCols
(
pDataCols
,
tsdbGetTableSchema
(
pRepo
->
tsdbMeta
,
pTable
)
);
tsdbLoadDataBlock
(
&
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
],
pBlock
,
1
,
pDataCols
,
pCompData
);
tsdbLoadDataBlock
(
&
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
],
pBlock
,
1
,
pDataCols
,
pCompData
);
tdResetDataCols
(
pDataCols
);
tsdbLoadDataBlock
(
&
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
],
pBlock
+
1
,
1
,
pDataCols
,
pCompData
);
int
k
=
0
;
int
k
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录