Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
cae5edea
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看板
提交
cae5edea
编写于
8月 05, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make skiplist node malloc
上级
a896c60f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
19 deletion
+32
-19
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+1
-1
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+24
-11
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+6
-6
src/tsdb/tests/tsdbTests.cpp
src/tsdb/tests/tsdbTests.cpp
+1
-1
未找到文件。
src/tsdb/inc/tsdbMain.h
浏览文件 @
cae5edea
...
...
@@ -415,7 +415,7 @@ static FORCE_INLINE SDataRow tsdbNextIterRow(SSkipListIterator* pIter) {
SSkipListNode
*
node
=
tSkipListIterGet
(
pIter
);
if
(
node
==
NULL
)
return
NULL
;
return
SL_GET_NODE_DATA
(
node
);
return
*
(
SDataRow
*
)
SL_GET_NODE_DATA
(
node
);
}
static
FORCE_INLINE
TSKEY
tsdbNextIterKey
(
SSkipListIterator
*
pIter
)
{
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
cae5edea
...
...
@@ -45,7 +45,6 @@ int tsdbInsertRowToMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
SMemTable
*
pMemTable
=
pRepo
->
mem
;
STableData
*
pTableData
=
NULL
;
SSkipList
*
pSList
=
NULL
;
int
bytes
=
0
;
if
(
pMemTable
!=
NULL
&&
TABLE_TID
(
pTable
)
<
pMemTable
->
maxTables
&&
pMemTable
->
tData
[
TABLE_TID
(
pTable
)]
!=
NULL
&&
pMemTable
->
tData
[
TABLE_TID
(
pTable
)]
->
uid
==
TABLE_UID
(
pTable
))
{
...
...
@@ -55,27 +54,39 @@ int tsdbInsertRowToMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
tSkipListNewNodeInfo
(
pSList
,
&
level
,
&
headSize
);
bytes
=
headSize
+
dataRowLen
(
row
);
SSkipListNode
*
pNode
=
tsdbAllocBytes
(
pRepo
,
bytes
);
SSkipListNode
*
pNode
=
(
SSkipListNode
*
)
malloc
(
headSize
+
sizeof
(
SDataRow
*
));
if
(
pNode
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
void
*
pRow
=
tsdbAllocBytes
(
pRepo
,
dataRowLen
(
row
));
if
(
pRow
==
NULL
)
{
tsdbError
(
"vgId:%d failed to insert row with key %"
PRId64
" to table %s while allocate %d bytes since %s"
,
REPO_ID
(
pRepo
),
key
,
TABLE_CHAR_NAME
(
pTable
),
bytes
,
tstrerror
(
terrno
));
REPO_ID
(
pRepo
),
key
,
TABLE_CHAR_NAME
(
pTable
),
dataRowLen
(
row
),
tstrerror
(
terrno
));
free
(
pNode
);
return
-
1
;
}
pNode
->
level
=
level
;
dataRowCpy
(
SL_GET_NODE_DATA
(
pNode
),
row
);
dataRowCpy
(
pRow
,
row
);
*
(
SDataRow
*
)
SL_GET_NODE_DATA
(
pNode
)
=
pRow
;
// Operations above may change pRepo->mem, retake those values
ASSERT
(
pRepo
->
mem
!=
NULL
);
pMemTable
=
pRepo
->
mem
;
if
(
TABLE_TID
(
pTable
)
>=
pMemTable
->
maxTables
)
{
if
(
tsdbAdjustMemMaxTables
(
pMemTable
,
pMeta
->
maxTables
)
<
0
)
return
-
1
;;
if
(
tsdbAdjustMemMaxTables
(
pMemTable
,
pMeta
->
maxTables
)
<
0
)
{
tsdbFreeBytes
(
pRepo
,
pRow
,
dataRowLen
(
row
));
free
(
pNode
);
return
-
1
;
}
}
pTableData
=
pMemTable
->
tData
[
TABLE_TID
(
pTable
)];
if
(
pTableData
==
NULL
||
pTableData
->
uid
!=
TABLE_UID
(
pTable
))
{
if
(
pTableData
!=
NULL
)
{
// destroy the table skiplist (may have race condition problem)
if
(
pTableData
!=
NULL
)
{
taosWLockLatch
(
&
(
pMemTable
->
latch
));
pMemTable
->
tData
[
TABLE_TID
(
pTable
)]
=
NULL
;
tsdbFreeTableData
(
pTableData
);
...
...
@@ -87,7 +98,8 @@ int tsdbInsertRowToMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
tsdbError
(
"vgId:%d failed to insert row with key %"
PRId64
" to table %s while create new table data object since %s"
,
REPO_ID
(
pRepo
),
key
,
TABLE_CHAR_NAME
(
pTable
),
tstrerror
(
terrno
));
tsdbFreeBytes
(
pRepo
,
(
void
*
)
pNode
,
bytes
);
tsdbFreeBytes
(
pRepo
,
(
void
*
)
pRow
,
dataRowLen
(
row
));
free
(
pNode
);
return
-
1
;
}
...
...
@@ -97,7 +109,8 @@ int tsdbInsertRowToMem(STsdbRepo *pRepo, SDataRow row, STable *pTable) {
ASSERT
((
pTableData
!=
NULL
)
&&
pTableData
->
uid
==
TABLE_UID
(
pTable
));
if
(
tSkipListPut
(
pTableData
->
pData
,
pNode
)
==
NULL
)
{
tsdbFreeBytes
(
pRepo
,
(
void
*
)
pNode
,
bytes
);
tsdbFreeBytes
(
pRepo
,
(
void
*
)
pRow
,
dataRowLen
(
row
));
free
(
pNode
);
}
else
{
if
(
TABLE_LASTKEY
(
pTable
)
<
key
)
TABLE_LASTKEY
(
pTable
)
=
key
;
if
(
pMemTable
->
keyFirst
>
key
)
pMemTable
->
keyFirst
=
key
;
...
...
@@ -416,7 +429,7 @@ static STableData *tsdbNewTableData(STsdbCfg *pCfg, STable *pTable) {
pTableData
->
numOfRows
=
0
;
pTableData
->
pData
=
tSkipListCreate
(
TSDB_DATA_SKIPLIST_LEVEL
,
TSDB_DATA_TYPE_TIMESTAMP
,
TYPE_BYTES
[
TSDB_DATA_TYPE_TIMESTAMP
],
0
,
0
,
0
,
tsdbGetTsTupleKey
);
TYPE_BYTES
[
TSDB_DATA_TYPE_TIMESTAMP
],
0
,
0
,
1
,
tsdbGetTsTupleKey
);
if
(
pTableData
->
pData
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_err
;
...
...
@@ -436,7 +449,7 @@ static void tsdbFreeTableData(STableData *pTableData) {
}
}
static
char
*
tsdbGetTsTupleKey
(
const
void
*
data
)
{
return
dataRowTuple
(
data
);
}
static
char
*
tsdbGetTsTupleKey
(
const
void
*
data
)
{
return
dataRowTuple
(
*
(
SDataRow
*
)
data
);
}
static
void
*
tsdbCommitData
(
void
*
arg
)
{
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
arg
;
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
cae5edea
...
...
@@ -343,7 +343,7 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
SSkipListNode
*
node
=
tSkipListIterGet
(
pCheckInfo
->
iter
);
assert
(
node
!=
NULL
);
SDataRow
row
=
SL_GET_NODE_DATA
(
node
);
SDataRow
row
=
*
(
SDataRow
*
)
SL_GET_NODE_DATA
(
node
);
TSKEY
key
=
dataRowKey
(
row
);
// first timestamp in buffer
tsdbDebug
(
"%p uid:%"
PRId64
", tid:%d check data in mem from skey:%"
PRId64
", order:%d, %p"
,
pHandle
,
pCheckInfo
->
tableId
.
uid
,
pCheckInfo
->
tableId
.
tid
,
key
,
order
,
pHandle
->
qinfo
);
...
...
@@ -356,7 +356,7 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
SSkipListNode
*
node
=
tSkipListIterGet
(
pCheckInfo
->
iiter
);
assert
(
node
!=
NULL
);
SDataRow
row
=
SL_GET_NODE_DATA
(
node
);
SDataRow
row
=
*
(
SDataRow
*
)
SL_GET_NODE_DATA
(
node
);
TSKEY
key
=
dataRowKey
(
row
);
// first timestamp in buffer
tsdbDebug
(
"%p uid:%"
PRId64
", tid:%d check data in imem from skey:%"
PRId64
", order:%d, %p"
,
pHandle
,
pCheckInfo
->
tableId
.
uid
,
pCheckInfo
->
tableId
.
tid
,
key
,
order
,
pHandle
->
qinfo
);
...
...
@@ -378,14 +378,14 @@ SDataRow getSDataRowInTableMem(STableCheckInfo* pCheckInfo, int32_t order) {
if
(
pCheckInfo
->
iter
)
{
SSkipListNode
*
node
=
tSkipListIterGet
(
pCheckInfo
->
iter
);
if
(
node
!=
NULL
)
{
rmem
=
SL_GET_NODE_DATA
(
node
);
rmem
=
*
(
SDataRow
*
)
SL_GET_NODE_DATA
(
node
);
}
}
if
(
pCheckInfo
->
iiter
)
{
SSkipListNode
*
node
=
tSkipListIterGet
(
pCheckInfo
->
iiter
);
if
(
node
!=
NULL
)
{
rimem
=
SL_GET_NODE_DATA
(
node
);
rimem
=
*
(
SDataRow
*
)
SL_GET_NODE_DATA
(
node
);
}
}
...
...
@@ -1184,8 +1184,8 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
* copy them all to result buffer, since it may be overlapped with file data block.
*/
if
(
node
==
NULL
||
((
dataRowKey
(
SL_GET_NODE_DATA
(
node
))
>
pQueryHandle
->
window
.
ekey
)
&&
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
||
((
dataRowKey
(
SL_GET_NODE_DATA
(
node
))
<
pQueryHandle
->
window
.
ekey
)
&&
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)))
{
((
dataRowKey
(
*
(
SDataRow
*
)
SL_GET_NODE_DATA
(
node
))
>
pQueryHandle
->
window
.
ekey
)
&&
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
||
((
dataRowKey
(
*
(
SDataRow
*
)
SL_GET_NODE_DATA
(
node
))
<
pQueryHandle
->
window
.
ekey
)
&&
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)))
{
// no data in cache or data in cache is greater than the ekey of time window, load data from file block
if
(
cur
->
win
.
skey
==
TSKEY_INITIAL_VAL
)
{
cur
->
win
.
skey
=
tsArray
[
pos
];
...
...
src/tsdb/tests/tsdbTests.cpp
浏览文件 @
cae5edea
...
...
@@ -35,7 +35,7 @@ static int insertData(SInsertInfo *pInfo) {
for
(
int
k
=
0
;
k
<
pInfo
->
totalRows
/
pInfo
->
rowsPerSubmit
;
k
++
)
{
memset
((
void
*
)
pMsg
,
0
,
sizeof
(
SSubmitMsg
));
SSubmitBlk
*
pBlock
=
pMsg
->
blocks
;
SSubmitBlk
*
pBlock
=
(
SSubmitBlk
*
)
pMsg
->
blocks
;
pBlock
->
uid
=
pInfo
->
uid
;
pBlock
->
tid
=
pInfo
->
tid
;
pBlock
->
sversion
=
pInfo
->
sversion
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录