Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8bed2612
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8bed2612
编写于
1月 12, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
a96de233
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
14 deletion
+27
-14
source/dnode/vnode/src/meta/metaCache.c
source/dnode/vnode/src/meta/metaCache.c
+27
-14
未找到文件。
source/dnode/vnode/src/meta/metaCache.c
浏览文件 @
8bed2612
...
@@ -464,7 +464,7 @@ static void removeInvalidCacheItem(SArray* pInvalidRes, struct STagFilterResEntr
...
@@ -464,7 +464,7 @@ static void removeInvalidCacheItem(SArray* pInvalidRes, struct STagFilterResEntr
taosMemoryFree
(
*
p1
);
taosMemoryFree
(
*
p1
);
}
}
atomic_store_32
(
&
(
pEntry
->
qTimes
),
0
)
;
// reset the query times
pEntry
->
qTimes
=
0
;
// reset the query times
taosArrayDestroy
(
pInvalidRes
);
taosArrayDestroy
(
pInvalidRes
);
}
}
...
@@ -476,7 +476,6 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
...
@@ -476,7 +476,6 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
TdThreadMutex
*
pLock
=
&
pMeta
->
pCache
->
sTagFilterResCache
.
lock
;
TdThreadMutex
*
pLock
=
&
pMeta
->
pCache
->
sTagFilterResCache
.
lock
;
uint64_t
buf
[
3
];
uint64_t
buf
[
3
];
uint32_t
times
=
0
;
*
acquireRes
=
0
;
*
acquireRes
=
0
;
buf
[
0
]
=
suid
;
buf
[
0
]
=
suid
;
...
@@ -502,14 +501,14 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
...
@@ -502,14 +501,14 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
// set the result into the buffer
// set the result into the buffer
taosArrayAddBatch
(
pList1
,
p
+
sizeof
(
int32_t
),
size
);
taosArrayAddBatch
(
pList1
,
p
+
sizeof
(
int32_t
),
size
);
times
=
atomic_add_fetch_32
(
&
(
*
pEntry
)
->
qTimes
,
1
)
;
(
*
pEntry
)
->
qTimes
+=
1
;
taosLRUCacheRelease
(
pCache
,
pHandle
,
false
);
taosLRUCacheRelease
(
pCache
,
pHandle
,
false
);
// unlock meta
// unlock meta
taosThreadMutexUnlock
(
pLock
);
taosThreadMutexUnlock
(
pLock
);
// check if scanning all items are necessary or not
// check if scanning all items are necessary or not
if
(
NEED_CHECK_CACHE_ITEM
(
listNEles
(
&
(
*
pEntry
)
->
list
),
t
imes
))
{
if
(
NEED_CHECK_CACHE_ITEM
(
listNEles
(
&
(
*
pEntry
)
->
list
),
(
*
pEntry
)
->
qT
imes
))
{
taosThreadMutexLock
(
pLock
);
taosThreadMutexLock
(
pLock
);
SArray
*
pInvalidRes
=
taosArrayInit
(
64
,
POINTER_BYTES
);
SArray
*
pInvalidRes
=
taosArrayInit
(
64
,
POINTER_BYTES
);
...
@@ -529,6 +528,19 @@ static void freePayload(const void* key, size_t keyLen, void* value) {
...
@@ -529,6 +528,19 @@ static void freePayload(const void* key, size_t keyLen, void* value) {
taosMemoryFree
(
value
);
taosMemoryFree
(
value
);
}
}
static
int32_t
addNewEntry
(
SHashObj
*
pTableEntry
,
const
void
*
pKey
,
int32_t
keyLen
,
uint64_t
suid
)
{
STagFilterResEntry
*
p
=
taosMemoryMalloc
(
sizeof
(
STagFilterResEntry
));
if
(
p
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
p
->
qTimes
=
1
;
tdListInit
(
&
p
->
list
,
keyLen
);
taosHashPut
(
pTableEntry
,
&
suid
,
sizeof
(
uint64_t
),
&
p
,
POINTER_BYTES
);
tdListAppend
(
&
p
->
list
,
pKey
);
return
0
;
}
// check both the payload size and selectivity ratio
// check both the payload size and selectivity ratio
int32_t
metaUidFilterCachePut
(
SMeta
*
pMeta
,
uint64_t
suid
,
const
void
*
pKey
,
int32_t
keyLen
,
void
*
pPayload
,
int32_t
metaUidFilterCachePut
(
SMeta
*
pMeta
,
uint64_t
suid
,
const
void
*
pKey
,
int32_t
keyLen
,
void
*
pPayload
,
int32_t
payloadLen
,
double
selectivityRatio
)
{
int32_t
payloadLen
,
double
selectivityRatio
)
{
...
@@ -556,19 +568,19 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
...
@@ -556,19 +568,19 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
buf
[
0
]
=
suid
;
buf
[
0
]
=
suid
;
memcpy
(
&
buf
[
1
],
pKey
,
keyLen
);
memcpy
(
&
buf
[
1
],
pKey
,
keyLen
);
ASSERT
(
sizeof
(
uint64_t
)
+
keyLen
==
24
);
ASSERT
(
sizeof
(
uint64_t
)
+
keyLen
==
24
);
int32_t
code
=
0
;
taosThreadMutexLock
(
pLock
);
taosThreadMutexLock
(
pLock
);
STagFilterResEntry
**
pEntry
=
taosHashGet
(
pTableEntry
,
&
suid
,
sizeof
(
uint64_t
));
STagFilterResEntry
**
pEntry
=
taosHashGet
(
pTableEntry
,
&
suid
,
sizeof
(
uint64_t
));
if
(
pEntry
==
NULL
)
{
if
(
pEntry
==
NULL
)
{
STagFilterResEntry
*
p
=
taosMemoryMalloc
(
sizeof
(
STagFilterResEntry
));
code
=
addNewEntry
(
pTableEntry
,
pKey
,
keyLen
,
suid
);
p
->
qTimes
=
0
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tdListInit
(
&
p
->
list
,
keyLen
);
goto
_end
;
taosHashPut
(
pTableEntry
,
&
suid
,
sizeof
(
uint64_t
),
&
p
,
POINTER_BYTES
);
}
tdListAppend
(
&
p
->
list
,
pKey
);
}
else
{
}
else
{
// check if it exists or not
// check if it exists or not
int32_t
times
=
atomic_add_fetch_32
(
&
(
*
pEntry
)
->
qTimes
,
1
)
;
(
*
pEntry
)
->
qTimes
+=
1
;
size_t
size
=
listNEles
(
&
(
*
pEntry
)
->
list
);
size_t
size
=
listNEles
(
&
(
*
pEntry
)
->
list
);
if
(
size
==
0
)
{
if
(
size
==
0
)
{
...
@@ -577,6 +589,7 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
...
@@ -577,6 +589,7 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
SListNode
*
pNode
=
listHead
(
&
(
*
pEntry
)
->
list
);
SListNode
*
pNode
=
listHead
(
&
(
*
pEntry
)
->
list
);
uint64_t
*
p
=
(
uint64_t
*
)
pNode
->
data
;
uint64_t
*
p
=
(
uint64_t
*
)
pNode
->
data
;
if
(
p
[
1
]
==
((
uint64_t
*
)
pKey
)[
1
]
&&
p
[
0
]
==
((
uint64_t
*
)
pKey
)[
0
])
{
if
(
p
[
1
]
==
((
uint64_t
*
)
pKey
)[
1
]
&&
p
[
0
]
==
((
uint64_t
*
)
pKey
)[
0
])
{
// we have already found the existed items, no need to added to cache anymore.
taosThreadMutexUnlock
(
pLock
);
taosThreadMutexUnlock
(
pLock
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
else
{
// not equal, append it
}
else
{
// not equal, append it
...
@@ -588,7 +601,7 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
...
@@ -588,7 +601,7 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
uint64_t
keyBuf
[
3
];
uint64_t
keyBuf
[
3
];
// if the threshold value is reached, need to check the value.
// if the threshold value is reached, need to check the value.
if
(
NEED_CHECK_CACHE_ITEM
(
size
,
t
imes
))
{
if
(
NEED_CHECK_CACHE_ITEM
(
size
,
(
*
pEntry
)
->
qT
imes
))
{
checkCacheEntry
=
true
;
checkCacheEntry
=
true
;
keyBuf
[
0
]
=
suid
;
keyBuf
[
0
]
=
suid
;
pInvalidRes
=
taosArrayInit
(
64
,
POINTER_BYTES
);
pInvalidRes
=
taosArrayInit
(
64
,
POINTER_BYTES
);
...
@@ -619,7 +632,7 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
...
@@ -619,7 +632,7 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
keyBuf
[
2
]
=
p
[
2
];
keyBuf
[
2
]
=
p
[
2
];
LRUHandle
*
pRes
=
taosLRUCacheLookup
(
pCache
,
keyBuf
,
24
);
LRUHandle
*
pRes
=
taosLRUCacheLookup
(
pCache
,
keyBuf
,
24
);
if
(
pRes
==
NULL
)
{
//
remove the item in the linked list
if
(
pRes
==
NULL
)
{
//
add the invalid item in the array list to be removed.
taosArrayPush
(
pInvalidRes
,
&
pNode
);
taosArrayPush
(
pInvalidRes
,
&
pNode
);
}
else
{
}
else
{
taosLRUCacheRelease
(
pCache
,
pRes
,
false
);
taosLRUCacheRelease
(
pCache
,
pRes
,
false
);
...
@@ -639,13 +652,13 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
...
@@ -639,13 +652,13 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
// add to cache.
// add to cache.
taosLRUCacheInsert
(
pCache
,
buf
,
sizeof
(
uint64_t
)
+
keyLen
,
pPayload
,
payloadLen
,
freePayload
,
NULL
,
taosLRUCacheInsert
(
pCache
,
buf
,
sizeof
(
uint64_t
)
+
keyLen
,
pPayload
,
payloadLen
,
freePayload
,
NULL
,
TAOS_LRU_PRIORITY_LOW
);
TAOS_LRU_PRIORITY_LOW
);
_end:
taosThreadMutexUnlock
(
pLock
);
taosThreadMutexUnlock
(
pLock
);
metaDebug
(
"vgId:%d, suid:%"
PRIu64
" list cache added into cache, total:%d, tables:%d"
,
TD_VID
(
pMeta
->
pVnode
),
suid
,
metaDebug
(
"vgId:%d, suid:%"
PRIu64
" list cache added into cache, total:%d, tables:%d"
,
TD_VID
(
pMeta
->
pVnode
),
suid
,
(
int32_t
)
taosLRUCacheGetUsage
(
pCache
),
taosHashGetSize
(
pTableEntry
));
(
int32_t
)
taosLRUCacheGetUsage
(
pCache
),
taosHashGetSize
(
pTableEntry
));
return
TSDB_CODE_SUCCESS
;
return
code
;
}
}
// remove the lru cache that are expired due to the tags value update, or creating, or dropping, of child tables
// remove the lru cache that are expired due to the tags value update, or creating, or dropping, of child tables
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录