Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b3fae65d
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b3fae65d
编写于
8月 01, 2023
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(tsdb/cache/read): lazy init table map hash and entries
上级
347e78ec
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
34 addition
and
20 deletion
+34
-20
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+33
-6
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
+1
-14
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
b3fae65d
...
...
@@ -1592,6 +1592,29 @@ _err:
return
code
;
}
static
void
freeTableInfoFunc
(
void
*
param
)
{
void
**
p
=
(
void
**
)
param
;
taosMemoryFreeClear
(
*
p
);
}
static
STableLoadInfo
*
getTableLoadInfo
(
SCacheRowsReader
*
pReader
,
uint64_t
uid
)
{
STableLoadInfo
*
pInfo
=
NULL
;
if
(
!
pReader
->
pTableMap
)
{
pReader
->
pTableMap
=
tSimpleHashInit
(
pReader
->
numOfTables
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
));
tSimpleHashSetFreeFp
(
pReader
->
pTableMap
,
freeTableInfoFunc
);
}
pInfo
=
*
(
STableLoadInfo
**
)
tSimpleHashGet
(
pReader
->
pTableMap
,
&
uid
,
sizeof
(
uid
));
if
(
!
pInfo
)
{
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STableLoadInfo
));
tSimpleHashPut
(
pReader
->
pTableMap
,
&
uid
,
sizeof
(
uint64_t
),
&
pInfo
,
POINTER_BYTES
);
}
return
pInfo
;
}
static
int32_t
loadTombFromBlk
(
const
TTombBlkArray
*
pTombBlkArray
,
SCacheRowsReader
*
pReader
,
void
*
pFileReader
,
bool
isFile
)
{
int32_t
code
=
0
;
...
...
@@ -1618,7 +1641,7 @@ static int32_t loadTombFromBlk(const TTombBlkArray *pTombBlkArray, SCacheRowsRea
}
uint64_t
uid
=
uidList
[
j
];
STableLoadInfo
*
pInfo
=
*
(
STableLoadInfo
**
)
tSimpleHashGet
(
pReader
->
pTableMap
,
&
uid
,
sizeof
(
uid
)
);
STableLoadInfo
*
pInfo
=
getTableLoadInfo
(
pReader
,
uid
);
if
(
pInfo
->
pTombData
==
NULL
)
{
pInfo
->
pTombData
=
taosArrayInit
(
4
,
sizeof
(
SDelData
));
}
...
...
@@ -1660,13 +1683,16 @@ static int32_t loadTombFromBlk(const TTombBlkArray *pTombBlkArray, SCacheRowsRea
}
if
(
newTable
)
{
pInfo
=
*
(
STableLoadInfo
**
)
tSimpleHashGet
(
pReader
->
pTableMap
,
&
uid
,
sizeof
(
uid
)
);
pInfo
=
getTableLoadInfo
(
pReader
,
uid
);
if
(
pInfo
->
pTombData
==
NULL
)
{
pInfo
->
pTombData
=
taosArrayInit
(
4
,
sizeof
(
SDelData
));
}
}
if
(
record
.
version
<=
pReader
->
info
.
verRange
.
maxVer
)
{
tsdbError
(
"tomb xx load/cache: vgId:%d fid:%d commit %"
PRId64
"~%"
PRId64
"~%"
PRId64
" tomb records"
,
TD_VID
(
pReader
->
pTsdb
->
pVnode
),
pReader
->
pCurFileSet
->
fid
,
record
.
skey
,
record
.
ekey
,
uid
);
SDelData
delData
=
{.
version
=
record
.
version
,
.
sKey
=
record
.
skey
,
.
eKey
=
record
.
ekey
};
taosArrayPush
(
pInfo
->
pTombData
,
&
delData
);
}
...
...
@@ -2458,13 +2484,14 @@ static int32_t nextRowIterGet(CacheNextRowIter *pIter, TSDBROW **ppRow, bool *pI
pIter
->
pSkyline
=
taosArrayInit
(
32
,
sizeof
(
TSDBKEY
));
uint64_t
uid
=
pIter
->
idx
.
uid
;
STableLoadInfo
*
pInfo
=
*
(
STableLoadInfo
**
)
tSimpleHashGet
(
pIter
->
pr
->
pTableMap
,
&
uid
,
sizeof
(
uid
)
);
STableLoadInfo
*
pInfo
=
getTableLoadInfo
(
pIter
->
pr
,
uid
);
SArray
*
pTombData
=
pInfo
->
pTombData
;
if
(
pTombData
)
{
taosArrayAddAll
(
pTombData
,
pIter
->
pMemDelData
);
code
=
tsdbBuildDeleteSkyline
(
pTombData
,
0
,
(
int32_t
)(
TARRAY_SIZE
(
pTombData
)
-
1
),
pIter
->
pSkyline
);
if
(
pTombData
)
{
taosArrayAddAll
(
pIter
->
pMemDelData
,
pTombData
);
}
code
=
tsdbBuildDeleteSkyline
(
pIter
->
pMemDelData
,
0
,
(
int32_t
)(
TARRAY_SIZE
(
pIter
->
pMemDelData
)
-
1
),
pIter
->
pSkyline
);
pIter
->
iSkyline
=
taosArrayGetSize
(
pIter
->
pSkyline
)
-
1
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
浏览文件 @
b3fae65d
...
...
@@ -143,11 +143,6 @@ static int32_t uidComparFunc(const void* p1, const void* p2) {
}
}
static
void
freeTableInfoFunc
(
void
*
param
)
{
void
**
p
=
(
void
**
)
param
;
taosMemoryFreeClear
(
*
p
);
}
int32_t
tsdbCacherowsReaderOpen
(
void
*
pVnode
,
int32_t
type
,
void
*
pTableIdList
,
int32_t
numOfTables
,
int32_t
numOfCols
,
SArray
*
pCidList
,
int32_t
*
pSlotIds
,
uint64_t
suid
,
void
**
pReader
,
const
char
*
idstr
)
{
*
pReader
=
NULL
;
...
...
@@ -173,25 +168,17 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList,
p
->
pTableList
=
pTableIdList
;
p
->
numOfTables
=
numOfTables
;
p
->
pTableMap
=
tSimpleHashInit
(
numOfTables
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
));
if
(
p
->
pTableMap
==
NULL
)
{
tsdbCacherowsReaderClose
(
p
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
p
->
uidList
=
taosMemoryMalloc
(
numOfTables
*
sizeof
(
uint64_t
));
if
(
p
->
uidList
==
NULL
)
{
tsdbCacherowsReaderClose
(
p
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
uint64_t
uid
=
p
->
pTableList
[
i
].
uid
;
p
->
uidList
[
i
]
=
uid
;
STableLoadInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STableLoadInfo
));
tSimpleHashPut
(
p
->
pTableMap
,
&
uid
,
sizeof
(
uint64_t
),
&
pInfo
,
POINTER_BYTES
);
}
tSimpleHashSetFreeFp
(
p
->
pTableMap
,
freeTableInfoFunc
);
taosSort
(
p
->
uidList
,
numOfTables
,
sizeof
(
uint64_t
),
uidComparFunc
);
int32_t
code
=
setTableSchema
(
p
,
suid
,
idstr
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录