Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
93260417
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看板
提交
93260417
编写于
5月 13, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-149] change hash imp in sdb
上级
b3a1070b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
54 addition
and
28 deletion
+54
-28
src/mnode/src/mgmtSdb.c
src/mnode/src/mgmtSdb.c
+51
-28
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+3
-0
未找到文件。
src/mnode/src/mgmtSdb.c
浏览文件 @
93260417
...
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "taoserror.h"
#include "hash.h"
#include "trpc.h"
#include "tutil.h"
#include "tbalance.h"
...
...
@@ -83,12 +84,6 @@ typedef struct {
}
SSdbRow
;
static
SSdbObject
tsSdbObj
=
{
0
};
static
void
*
(
*
sdbInitIndexFp
[])(
int32_t
maxRows
,
int32_t
dataSize
)
=
{
sdbOpenStrHash
,
sdbOpenIntHash
,
sdbOpenIntHash
};
static
void
*
(
*
sdbAddIndexFp
[])(
void
*
handle
,
void
*
key
,
void
*
data
)
=
{
sdbAddStrHash
,
sdbAddIntHash
,
sdbAddIntHash
};
static
void
(
*
sdbDeleteIndexFp
[])(
void
*
handle
,
void
*
key
)
=
{
sdbDeleteStrHash
,
sdbDeleteIntHash
,
sdbDeleteIntHash
};
static
void
*
(
*
sdbGetIndexFp
[])(
void
*
handle
,
void
*
key
)
=
{
sdbGetStrHashData
,
sdbGetIntHashData
,
sdbGetIntHashData
};
static
void
(
*
sdbCleanUpIndexFp
[])(
void
*
handle
)
=
{
sdbCloseStrHash
,
sdbCloseIntHash
,
sdbCloseIntHash
};
static
void
*
(
*
sdbFetchRowFp
[])(
void
*
handle
,
void
*
ptr
,
void
**
ppRow
)
=
{
sdbFetchStrHashData
,
sdbFetchIntHashData
,
sdbFetchIntHashData
};
static
int
sdbWrite
(
void
*
param
,
void
*
data
,
int
type
);
int32_t
sdbGetId
(
void
*
handle
)
{
...
...
@@ -375,7 +370,11 @@ static SSdbRow *sdbGetRowMeta(void *handle, void *key) {
if
(
handle
==
NULL
)
return
NULL
;
pMeta
=
(
*
sdbGetIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
key
);
int32_t
keySize
=
sizeof
(
int32_t
);
if
(
pTable
->
keyType
==
SDB_KEY_STRING
)
{
keySize
=
strlen
((
char
*
)
key
);
}
pMeta
=
taosHashGet
(
pTable
->
iHandle
,
key
,
keySize
);
return
pMeta
;
}
...
...
@@ -387,13 +386,17 @@ void *sdbGetRow(void *handle, void *key) {
if
(
handle
==
NULL
)
return
NULL
;
pthread_mutex_lock
(
&
pTable
->
mutex
);
pMeta
=
(
*
sdbGetIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
key
);
int32_t
keySize
=
sizeof
(
int32_t
);
if
(
pTable
->
keyType
==
SDB_KEY_STRING
)
{
keySize
=
strlen
((
char
*
)
key
);
}
pMeta
=
taosHashGet
(
pTable
->
iHandle
,
key
,
keySize
);
if
(
pMeta
)
sdbIncRef
(
pTable
,
pMeta
->
row
);
pthread_mutex_unlock
(
&
pTable
->
mutex
);
if
(
pMeta
==
NULL
)
{
return
NULL
;
}
if
(
pMeta
==
NULL
)
return
NULL
;
return
pMeta
->
row
;
}
...
...
@@ -404,7 +407,13 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) {
rowMeta
.
row
=
pOper
->
pObj
;
pthread_mutex_lock
(
&
pTable
->
mutex
);
(
*
sdbAddIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
pOper
->
pObj
,
&
rowMeta
);
int32_t
keySize
=
sizeof
(
int32_t
);
if
(
pTable
->
keyType
==
SDB_KEY_STRING
)
{
keySize
=
strlen
((
char
*
)
pOper
->
pObj
);
}
taosHashPut
(
pTable
->
iHandle
,
pOper
->
pObj
,
keySize
,
&
rowMeta
,
sizeof
(
SSdbRow
));
sdbIncRef
(
pTable
,
pOper
->
pObj
);
pTable
->
numOfRows
++
;
...
...
@@ -427,7 +436,13 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbOper *pOper) {
(
*
pTable
->
deleteFp
)(
pOper
);
pthread_mutex_lock
(
&
pTable
->
mutex
);
(
*
sdbDeleteIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
pOper
->
pObj
);
int32_t
keySize
=
sizeof
(
int32_t
);
if
(
pTable
->
keyType
==
SDB_KEY_STRING
)
{
keySize
=
strlen
((
char
*
)
pOper
->
pObj
);
}
taosHashRemove
(
pTable
->
iHandle
,
pOper
->
pObj
,
keySize
);
pTable
->
numOfRows
--
;
pthread_mutex_unlock
(
&
pTable
->
mutex
);
...
...
@@ -637,18 +652,26 @@ int32_t sdbUpdateRow(SSdbOper *pOper) {
void
*
sdbFetchRow
(
void
*
handle
,
void
*
pNode
,
void
**
ppRow
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
handle
;
SSdbRow
*
pMeta
;
*
ppRow
=
NULL
;
if
(
pTable
==
NULL
)
return
NULL
;
pNode
=
(
*
sdbFetchRowFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
pNode
,
(
void
**
)
&
pMeta
);
SHashMutableIterator
*
pIter
=
pNode
;
if
(
pIter
==
NULL
)
{
pIter
=
taosHashCreateIter
(
pTable
->
iHandle
);
}
if
(
!
taosHashIterNext
(
pIter
))
{
taosHashDestroyIter
(
pIter
);
return
NULL
;
}
SSdbRow
*
pMeta
=
taosHashIterGet
(
pIter
);
if
(
pMeta
==
NULL
)
return
NULL
;
*
ppRow
=
pMeta
->
row
;
sdbIncRef
(
handle
,
pMeta
->
row
);
return
p
Node
;
return
p
Iter
;
}
void
*
sdbOpenTable
(
SSdbTableDesc
*
pDesc
)
{
...
...
@@ -669,10 +692,12 @@ void *sdbOpenTable(SSdbTableDesc *pDesc) {
pTable
->
decodeFp
=
pDesc
->
decodeFp
;
pTable
->
destroyFp
=
pDesc
->
destroyFp
;
pTable
->
restoredFp
=
pDesc
->
restoredFp
;
if
(
sdbInitIndexFp
[
pTable
->
keyType
]
!=
NULL
)
{
pTable
->
iHandle
=
(
*
sdbInitIndexFp
[
pTable
->
keyType
])(
pTable
->
maxRowSize
,
sizeof
(
SSdbRow
));
_hash_fn_t
hashFp
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
);
if
(
pTable
->
keyType
==
SDB_KEY_STRING
)
{
hashFp
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
}
pTable
->
iHandle
=
taosHashInit
(
pTable
->
hashSessions
,
hashFp
,
true
);
pthread_mutex_init
(
&
pTable
->
mutex
,
NULL
);
...
...
@@ -688,11 +713,10 @@ void sdbCloseTable(void *handle) {
tsSdbObj
.
numOfTables
--
;
tsSdbObj
.
tableList
[
pTable
->
tableId
]
=
NULL
;
void
*
pNode
=
NULL
;
while
(
1
)
{
SSdbRow
*
pMeta
;
pNode
=
(
*
sdbFetchRowFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
pNode
,
(
void
**
)
&
pMeta
);
if
(
pMeta
==
NULL
)
break
;
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pTable
->
iHandle
);
while
(
taosHashIterNext
(
pIter
))
{
SSdbRow
*
pMeta
=
taosHashIterGet
(
pIter
);
if
(
pMeta
==
NULL
)
continue
;
SSdbOper
oper
=
{
.
pObj
=
pMeta
->
row
,
...
...
@@ -702,9 +726,8 @@ void sdbCloseTable(void *handle) {
(
*
pTable
->
destroyFp
)(
&
oper
);
}
if
(
sdbCleanUpIndexFp
[
pTable
->
keyType
])
{
(
*
sdbCleanUpIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
);
}
taosHashDestroyIter
(
pIter
);
taosHashCleanup
(
pTable
->
iHandle
);
pthread_mutex_destroy
(
&
pTable
->
mutex
);
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
93260417
...
...
@@ -812,6 +812,7 @@ static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) {
dnodeSendMsgToDnode
(
&
ipSet
,
&
rpcMsg
);
mgmtDecVgroupRef
(
pVgroup
);
}
taosHashDestroyIter
(
pIter
);
mgmtDropAllChildTablesInStable
(
pStable
);
}
...
...
@@ -1288,6 +1289,8 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) {
mgmtDecVgroupRef
(
pVgroup
);
}
taosHashDestroyIter
(
pIter
);
pVgroupInfo
->
numOfVgroups
=
htonl
(
vgSize
);
// one table is done, try the next table
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录