Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ba5244d1
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
ba5244d1
编写于
11月 15, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: add tag filter results cache.
上级
8b0b351d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
90 addition
and
0 deletion
+90
-0
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+1
-0
source/dnode/vnode/src/meta/metaCache.c
source/dnode/vnode/src/meta/metaCache.c
+89
-0
未找到文件。
source/dnode/vnode/src/inc/meta.h
浏览文件 @
ba5244d1
...
...
@@ -70,6 +70,7 @@ int32_t metaCacheDrop(SMeta* pMeta, int64_t uid);
int32_t
metaStatsCacheUpsert
(
SMeta
*
pMeta
,
SMetaStbStats
*
pInfo
);
int32_t
metaStatsCacheDrop
(
SMeta
*
pMeta
,
int64_t
uid
);
int32_t
metaStatsCacheGet
(
SMeta
*
pMeta
,
int64_t
uid
,
SMetaStbStats
*
pInfo
);
int32_t
metaUidFilterCacheGet
(
SMeta
*
pMeta
,
uint64_t
suid
,
const
void
*
pKey
,
int32_t
keyLen
,
LRUHandle
**
pHandle
);
struct
SMeta
{
TdThreadRwlock
lock
;
...
...
source/dnode/vnode/src/meta/metaCache.c
浏览文件 @
ba5244d1
...
...
@@ -31,6 +31,12 @@ typedef struct SMetaStbStatsEntry {
SMetaStbStats
info
;
}
SMetaStbStatsEntry
;
typedef
struct
STagFilterResEntry
{
uint64_t
suid
;
// uid for super table
SList
*
pList
;
// the linked list of md5 digest, extracted from the serialized tag query condition
uint32_t
qTimes
;
// queried times for current super table
}
STagFilterResEntry
;
struct
SMetaCache
{
// child, normal, super, table entry cache
struct
SEntryCache
{
...
...
@@ -47,6 +53,10 @@ struct SMetaCache {
}
sStbStatsCache
;
// query cache
struct
STagFilterResCache
{
SHashObj
*
pTableEntry
;
SLRUCache
*
pUidResCache
;
}
sTagFilterResCache
;
};
static
void
entryCacheClose
(
SMeta
*
pMeta
)
{
...
...
@@ -388,3 +398,82 @@ int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo) {
return
code
;
}
int32_t
metaUidFilterCacheGet
(
SMeta
*
pMeta
,
uint64_t
suid
,
const
void
*
pKey
,
int32_t
keyLen
,
LRUHandle
**
pHandle
)
{
// generate the composed key for LRU cache
char
*
p
=
taosMemoryMalloc
(
keyLen
+
sizeof
(
uint64_t
));
*
(
uint64_t
*
)
p
=
suid
;
memcpy
(
p
+
sizeof
(
suid
),
pKey
,
keyLen
);
int32_t
len
=
keyLen
+
sizeof
(
uint64_t
);
*
pHandle
=
taosLRUCacheLookup
(
pMeta
->
pCache
->
sTagFilterResCache
.
pUidResCache
,
p
,
len
);
if
(
*
pHandle
==
NULL
)
{
taosMemoryFree
(
p
);
return
TSDB_CODE_SUCCESS
;
}
else
{
// do some book mark work after acquiring the filter result from cache
STagFilterResEntry
*
pEntry
=
taosHashGet
(
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
,
&
suid
,
sizeof
(
uint64_t
));
ASSERT
(
pEntry
!=
NULL
);
pEntry
->
qTimes
+=
1
;
// check if scanning all items are necessary or not
if
(
pEntry
->
qTimes
>
5000
&&
TD_DLIST_NELES
(
pEntry
->
pList
)
>
10
)
{
SArray
*
pList
=
taosArrayInit
(
64
,
POINTER_BYTES
);
SListIter
iter
=
{
0
};
tdListInitIter
(
pEntry
->
pList
,
&
iter
,
TD_LIST_FORWARD
);
SListNode
*
pNode
=
NULL
;
while
((
pNode
=
tdListNext
(
&
iter
))
!=
NULL
)
{
memcpy
(
p
+
sizeof
(
suid
),
pNode
->
data
,
keyLen
);
// check whether it is existed in LRU cache, and remove it from linked list if not.
void
*
pRes
=
taosLRUCacheLookup
(
pMeta
->
pCache
->
sTagFilterResCache
.
pUidResCache
,
p
,
len
);
if
(
pRes
==
NULL
)
{
// remove the item in the linked list
taosArrayPush
(
pList
,
&
pNode
);
}
}
// remove the keys, of which query uid lists have been replaced already.
size_t
s
=
taosArrayGetSize
(
pList
);
for
(
int32_t
i
=
0
;
i
<
s
;
++
i
)
{
SListNode
**
p1
=
taosArrayGet
(
pList
,
i
);
tdListPopNode
(
pEntry
->
pList
,
*
p1
);
}
}
taosMemoryFree
(
p
);
}
return
TSDB_CODE_SUCCESS
;
}
// check both the payload size and selectivity ratio
int32_t
metaUidFilterCachePut
(
SMeta
*
pMeta
,
uint64_t
suid
,
const
void
*
pKey
,
int32_t
keyLen
,
void
*
pPayload
)
{
return
TSDB_CODE_SUCCESS
;
}
// remove the lru cache that are expired due to the tags value update, or creating, or dropping, of child tables
int32_t
metaUidCacheClear
(
SMeta
*
pMeta
,
uint64_t
suid
)
{
STagFilterResEntry
*
pEntry
=
taosHashGet
(
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
,
&
suid
,
sizeof
(
uint64_t
));
if
(
pEntry
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
keyLen
=
sizeof
(
uint64_t
)
+
128
;
char
*
p
=
taosMemoryMalloc
(
keyLen
);
*
(
uint64_t
*
)
p
=
pEntry
->
suid
;
SListIter
iter
=
{
0
};
tdListInitIter
(
pEntry
->
pList
,
&
iter
,
TD_LIST_FORWARD
);
SListNode
*
pNode
=
NULL
;
while
((
pNode
=
tdListNext
(
&
iter
))
!=
NULL
)
{
memcpy
(
p
+
sizeof
(
suid
),
pNode
->
data
,
128
);
taosLRUCacheErase
(
pMeta
->
pCache
->
sTagFilterResCache
.
pUidResCache
,
p
,
keyLen
);
}
return
TSDB_CODE_SUCCESS
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录