Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
冷面1992
TDengine
提交
4a6c170d
TDengine
项目概览
冷面1992
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4a6c170d
编写于
7月 19, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change hash data in sdb
上级
f28c39da
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
52 deletion
+27
-52
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+27
-52
未找到文件。
src/mnode/src/mnodeSdb.c
浏览文件 @
4a6c170d
...
...
@@ -77,11 +77,6 @@ typedef struct {
pthread_mutex_t
mutex
;
}
SSdbObject
;
typedef
struct
{
int32_t
rowSize
;
void
*
row
;
}
SSdbRow
;
typedef
struct
{
pthread_t
thread
;
int32_t
workerId
;
...
...
@@ -419,32 +414,28 @@ void sdbDecRef(void *handle, void *pObj) {
}
}
static
SSdbRow
*
sdbGetRowMeta
(
SSdbTable
*
pTable
,
void
*
key
)
{
static
void
*
sdbGetRowMeta
(
SSdbTable
*
pTable
,
void
*
key
)
{
if
(
pTable
==
NULL
)
return
NULL
;
int32_t
keySize
=
sizeof
(
int32_t
);
if
(
pTable
->
keyType
==
SDB_KEY_STRING
||
pTable
->
keyType
==
SDB_KEY_VAR_STRING
)
{
keySize
=
strlen
((
char
*
)
key
);
}
return
taosHashGet
(
pTable
->
iHandle
,
key
,
keySize
);
void
**
ppRow
=
(
void
**
)
taosHashGet
(
pTable
->
iHandle
,
key
,
keySize
);
if
(
ppRow
==
NULL
)
return
NULL
;
return
*
ppRow
;
}
static
SSdbRow
*
sdbGetRowMetaFromObj
(
SSdbTable
*
pTable
,
void
*
key
)
{
static
void
*
sdbGetRowMetaFromObj
(
SSdbTable
*
pTable
,
void
*
key
)
{
return
sdbGetRowMeta
(
pTable
,
sdbGetObjKey
(
pTable
,
key
));
}
void
*
sdbGetRow
(
void
*
handle
,
void
*
key
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
handle
;
int32_t
keySize
=
sizeof
(
int32_t
);
if
(
pTable
->
keyType
==
SDB_KEY_STRING
||
pTable
->
keyType
==
SDB_KEY_VAR_STRING
)
{
keySize
=
strlen
((
char
*
)
key
);
}
SSdbRow
*
pMeta
=
taosHashGet
(
pTable
->
iHandle
,
key
,
keySize
);
if
(
pMeta
)
{
sdbIncRef
(
pTable
,
pMeta
->
row
);
return
pMeta
->
row
;
void
*
pRow
=
sdbGetRowMeta
(
handle
,
key
);
if
(
pRow
)
{
sdbIncRef
(
handle
,
pRow
);
return
pRow
;
}
else
{
return
NULL
;
}
...
...
@@ -455,10 +446,6 @@ static void *sdbGetRowFromObj(SSdbTable *pTable, void *key) {
}
static
int32_t
sdbInsertHash
(
SSdbTable
*
pTable
,
SSdbOper
*
pOper
)
{
SSdbRow
rowMeta
;
rowMeta
.
rowSize
=
pOper
->
rowSize
;
rowMeta
.
row
=
pOper
->
pObj
;
void
*
key
=
sdbGetObjKey
(
pTable
,
pOper
->
pObj
);
int32_t
keySize
=
sizeof
(
int32_t
);
...
...
@@ -466,7 +453,7 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) {
keySize
=
strlen
((
char
*
)
key
);
}
taosHashPut
(
pTable
->
iHandle
,
key
,
keySize
,
&
rowMeta
,
sizeof
(
SSdbRow
));
taosHashPut
(
pTable
->
iHandle
,
key
,
keySize
,
&
pOper
->
pObj
,
sizeof
(
void
**
));
sdbIncRef
(
pTable
,
pOper
->
pObj
);
atomic_add_fetch_32
(
&
pTable
->
numOfRows
,
1
);
...
...
@@ -586,17 +573,17 @@ static int sdbWrite(void *param, void *data, int type) {
code
=
(
*
pTable
->
decodeFp
)(
&
oper
);
return
sdbInsertHash
(
pTable
,
&
oper
);
}
else
if
(
action
==
SDB_ACTION_DELETE
)
{
SSdbRow
*
rowMeta
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
if
(
rowMeta
==
NULL
||
rowMeta
->
r
ow
==
NULL
)
{
void
*
pRow
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
if
(
pR
ow
==
NULL
)
{
sdbError
(
"table:%s, failed to get object:%s from wal while dispose delete action"
,
pTable
->
tableName
,
pHead
->
cont
);
return
TSDB_CODE_SUCCESS
;
}
SSdbOper
oper
=
{.
table
=
pTable
,
.
pObj
=
rowMeta
->
r
ow
};
SSdbOper
oper
=
{.
table
=
pTable
,
.
pObj
=
pR
ow
};
return
sdbDeleteHash
(
pTable
,
&
oper
);
}
else
if
(
action
==
SDB_ACTION_UPDATE
)
{
SSdbRow
*
rowMeta
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
if
(
rowMeta
==
NULL
||
rowMeta
->
r
ow
==
NULL
)
{
void
*
pRow
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
if
(
pR
ow
==
NULL
)
{
sdbError
(
"table:%s, failed to get object:%s from wal while dispose update action"
,
pTable
->
tableName
,
pHead
->
cont
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -675,18 +662,12 @@ int32_t sdbDeleteRow(SSdbOper *pOper) {
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pOper
->
table
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
SSdbRow
*
pMeta
=
sdbGetRowMetaFromObj
(
pTable
,
pOper
->
pObj
);
if
(
p
Meta
==
NULL
)
{
void
*
pRow
=
sdbGetRowMetaFromObj
(
pTable
,
pOper
->
pObj
);
if
(
p
Row
==
NULL
)
{
sdbDebug
(
"table:%s, record is not there, delete failed"
,
pTable
->
tableName
);
return
TSDB_CODE_MND_SDB_OBJ_NOT_THERE
;
}
void
*
pMetaRow
=
pMeta
->
row
;
if
(
pMetaRow
==
NULL
)
{
sdbError
(
"table:%s, record meta is null"
,
pTable
->
tableName
);
return
TSDB_CODE_MND_SDB_INVAID_META_ROW
;
}
sdbIncRef
(
pTable
,
pOper
->
pObj
);
int32_t
code
=
sdbDeleteHash
(
pTable
,
pOper
);
...
...
@@ -728,18 +709,12 @@ int32_t sdbUpdateRow(SSdbOper *pOper) {
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pOper
->
table
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
SSdbRow
*
pMeta
=
sdbGetRowMetaFromObj
(
pTable
,
pOper
->
pObj
);
if
(
p
Meta
==
NULL
)
{
void
*
pRow
=
sdbGetRowMetaFromObj
(
pTable
,
pOper
->
pObj
);
if
(
p
Row
==
NULL
)
{
sdbDebug
(
"table:%s, record is not there, update failed"
,
pTable
->
tableName
);
return
TSDB_CODE_MND_SDB_OBJ_NOT_THERE
;
}
void
*
pMetaRow
=
pMeta
->
row
;
if
(
pMetaRow
==
NULL
)
{
sdbError
(
"table:%s, record meta is null"
,
pTable
->
tableName
);
return
TSDB_CODE_MND_SDB_INVAID_META_ROW
;
}
int32_t
code
=
sdbUpdateHash
(
pTable
,
pOper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
sdbError
(
"table:%s, failed to update hash"
,
pTable
->
tableName
);
...
...
@@ -789,14 +764,14 @@ void *sdbFetchRow(void *handle, void *pNode, void **ppRow) {
return
NULL
;
}
SSdbRow
*
pMeta
=
taosHashIterGet
(
pIter
);
if
(
p
Meta
==
NULL
)
{
void
**
ppMetaRow
=
taosHashIterGet
(
pIter
);
if
(
p
pMetaRow
==
NULL
)
{
taosHashDestroyIter
(
pIter
);
return
NULL
;
}
*
ppRow
=
pMeta
->
r
ow
;
sdbIncRef
(
handle
,
pMeta
->
r
ow
);
*
ppRow
=
*
ppMetaR
ow
;
sdbIncRef
(
handle
,
*
ppMetaR
ow
);
return
pIter
;
}
...
...
@@ -846,11 +821,11 @@ void sdbCloseTable(void *handle) {
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pTable
->
iHandle
);
while
(
taosHashIterNext
(
pIter
))
{
SSdbRow
*
pMeta
=
taosHashIterGet
(
pIter
);
if
(
p
Meta
==
NULL
)
continue
;
void
**
ppRow
=
taosHashIterGet
(
pIter
);
if
(
p
pRow
==
NULL
)
continue
;
SSdbOper
oper
=
{
.
pObj
=
pMeta
->
r
ow
,
.
pObj
=
*
ppR
ow
,
.
table
=
pTable
,
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录