Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4a6c170d
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
提交
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 {
...
@@ -77,11 +77,6 @@ typedef struct {
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex
;
}
SSdbObject
;
}
SSdbObject
;
typedef
struct
{
int32_t
rowSize
;
void
*
row
;
}
SSdbRow
;
typedef
struct
{
typedef
struct
{
pthread_t
thread
;
pthread_t
thread
;
int32_t
workerId
;
int32_t
workerId
;
...
@@ -419,7 +414,7 @@ void sdbDecRef(void *handle, void *pObj) {
...
@@ -419,7 +414,7 @@ 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
;
if
(
pTable
==
NULL
)
return
NULL
;
int32_t
keySize
=
sizeof
(
int32_t
);
int32_t
keySize
=
sizeof
(
int32_t
);
...
@@ -427,24 +422,20 @@ static SSdbRow *sdbGetRowMeta(SSdbTable *pTable, void *key) {
...
@@ -427,24 +422,20 @@ static SSdbRow *sdbGetRowMeta(SSdbTable *pTable, void *key) {
keySize
=
strlen
((
char
*
)
key
);
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
));
return
sdbGetRowMeta
(
pTable
,
sdbGetObjKey
(
pTable
,
key
));
}
}
void
*
sdbGetRow
(
void
*
handle
,
void
*
key
)
{
void
*
sdbGetRow
(
void
*
handle
,
void
*
key
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
handle
;
void
*
pRow
=
sdbGetRowMeta
(
handle
,
key
);
int32_t
keySize
=
sizeof
(
int32_t
);
if
(
pRow
)
{
if
(
pTable
->
keyType
==
SDB_KEY_STRING
||
pTable
->
keyType
==
SDB_KEY_VAR_STRING
)
{
sdbIncRef
(
handle
,
pRow
);
keySize
=
strlen
((
char
*
)
key
);
return
pRow
;
}
SSdbRow
*
pMeta
=
taosHashGet
(
pTable
->
iHandle
,
key
,
keySize
);
if
(
pMeta
)
{
sdbIncRef
(
pTable
,
pMeta
->
row
);
return
pMeta
->
row
;
}
else
{
}
else
{
return
NULL
;
return
NULL
;
}
}
...
@@ -455,10 +446,6 @@ static void *sdbGetRowFromObj(SSdbTable *pTable, void *key) {
...
@@ -455,10 +446,6 @@ static void *sdbGetRowFromObj(SSdbTable *pTable, void *key) {
}
}
static
int32_t
sdbInsertHash
(
SSdbTable
*
pTable
,
SSdbOper
*
pOper
)
{
static
int32_t
sdbInsertHash
(
SSdbTable
*
pTable
,
SSdbOper
*
pOper
)
{
SSdbRow
rowMeta
;
rowMeta
.
rowSize
=
pOper
->
rowSize
;
rowMeta
.
row
=
pOper
->
pObj
;
void
*
key
=
sdbGetObjKey
(
pTable
,
pOper
->
pObj
);
void
*
key
=
sdbGetObjKey
(
pTable
,
pOper
->
pObj
);
int32_t
keySize
=
sizeof
(
int32_t
);
int32_t
keySize
=
sizeof
(
int32_t
);
...
@@ -466,7 +453,7 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) {
...
@@ -466,7 +453,7 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) {
keySize
=
strlen
((
char
*
)
key
);
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
);
sdbIncRef
(
pTable
,
pOper
->
pObj
);
atomic_add_fetch_32
(
&
pTable
->
numOfRows
,
1
);
atomic_add_fetch_32
(
&
pTable
->
numOfRows
,
1
);
...
@@ -586,17 +573,17 @@ static int sdbWrite(void *param, void *data, int type) {
...
@@ -586,17 +573,17 @@ static int sdbWrite(void *param, void *data, int type) {
code
=
(
*
pTable
->
decodeFp
)(
&
oper
);
code
=
(
*
pTable
->
decodeFp
)(
&
oper
);
return
sdbInsertHash
(
pTable
,
&
oper
);
return
sdbInsertHash
(
pTable
,
&
oper
);
}
else
if
(
action
==
SDB_ACTION_DELETE
)
{
}
else
if
(
action
==
SDB_ACTION_DELETE
)
{
SSdbRow
*
rowMeta
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
void
*
pRow
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
if
(
rowMeta
==
NULL
||
rowMeta
->
r
ow
==
NULL
)
{
if
(
pR
ow
==
NULL
)
{
sdbError
(
"table:%s, failed to get object:%s from wal while dispose delete action"
,
pTable
->
tableName
,
sdbError
(
"table:%s, failed to get object:%s from wal while dispose delete action"
,
pTable
->
tableName
,
pHead
->
cont
);
pHead
->
cont
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SSdbOper
oper
=
{.
table
=
pTable
,
.
pObj
=
rowMeta
->
r
ow
};
SSdbOper
oper
=
{.
table
=
pTable
,
.
pObj
=
pR
ow
};
return
sdbDeleteHash
(
pTable
,
&
oper
);
return
sdbDeleteHash
(
pTable
,
&
oper
);
}
else
if
(
action
==
SDB_ACTION_UPDATE
)
{
}
else
if
(
action
==
SDB_ACTION_UPDATE
)
{
SSdbRow
*
rowMeta
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
void
*
pRow
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
if
(
rowMeta
==
NULL
||
rowMeta
->
r
ow
==
NULL
)
{
if
(
pR
ow
==
NULL
)
{
sdbError
(
"table:%s, failed to get object:%s from wal while dispose update action"
,
pTable
->
tableName
,
sdbError
(
"table:%s, failed to get object:%s from wal while dispose update action"
,
pTable
->
tableName
,
pHead
->
cont
);
pHead
->
cont
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -675,18 +662,12 @@ int32_t sdbDeleteRow(SSdbOper *pOper) {
...
@@ -675,18 +662,12 @@ int32_t sdbDeleteRow(SSdbOper *pOper) {
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pOper
->
table
;
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pOper
->
table
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
SSdbRow
*
pMeta
=
sdbGetRowMetaFromObj
(
pTable
,
pOper
->
pObj
);
void
*
pRow
=
sdbGetRowMetaFromObj
(
pTable
,
pOper
->
pObj
);
if
(
p
Meta
==
NULL
)
{
if
(
p
Row
==
NULL
)
{
sdbDebug
(
"table:%s, record is not there, delete failed"
,
pTable
->
tableName
);
sdbDebug
(
"table:%s, record is not there, delete failed"
,
pTable
->
tableName
);
return
TSDB_CODE_MND_SDB_OBJ_NOT_THERE
;
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
);
sdbIncRef
(
pTable
,
pOper
->
pObj
);
int32_t
code
=
sdbDeleteHash
(
pTable
,
pOper
);
int32_t
code
=
sdbDeleteHash
(
pTable
,
pOper
);
...
@@ -728,18 +709,12 @@ int32_t sdbUpdateRow(SSdbOper *pOper) {
...
@@ -728,18 +709,12 @@ int32_t sdbUpdateRow(SSdbOper *pOper) {
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pOper
->
table
;
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pOper
->
table
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
SSdbRow
*
pMeta
=
sdbGetRowMetaFromObj
(
pTable
,
pOper
->
pObj
);
void
*
pRow
=
sdbGetRowMetaFromObj
(
pTable
,
pOper
->
pObj
);
if
(
p
Meta
==
NULL
)
{
if
(
p
Row
==
NULL
)
{
sdbDebug
(
"table:%s, record is not there, update failed"
,
pTable
->
tableName
);
sdbDebug
(
"table:%s, record is not there, update failed"
,
pTable
->
tableName
);
return
TSDB_CODE_MND_SDB_OBJ_NOT_THERE
;
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
);
int32_t
code
=
sdbUpdateHash
(
pTable
,
pOper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
sdbError
(
"table:%s, failed to update hash"
,
pTable
->
tableName
);
sdbError
(
"table:%s, failed to update hash"
,
pTable
->
tableName
);
...
@@ -789,14 +764,14 @@ void *sdbFetchRow(void *handle, void *pNode, void **ppRow) {
...
@@ -789,14 +764,14 @@ void *sdbFetchRow(void *handle, void *pNode, void **ppRow) {
return
NULL
;
return
NULL
;
}
}
SSdbRow
*
pMeta
=
taosHashIterGet
(
pIter
);
void
**
ppMetaRow
=
taosHashIterGet
(
pIter
);
if
(
p
Meta
==
NULL
)
{
if
(
p
pMetaRow
==
NULL
)
{
taosHashDestroyIter
(
pIter
);
taosHashDestroyIter
(
pIter
);
return
NULL
;
return
NULL
;
}
}
*
ppRow
=
pMeta
->
r
ow
;
*
ppRow
=
*
ppMetaR
ow
;
sdbIncRef
(
handle
,
pMeta
->
r
ow
);
sdbIncRef
(
handle
,
*
ppMetaR
ow
);
return
pIter
;
return
pIter
;
}
}
...
@@ -846,11 +821,11 @@ void sdbCloseTable(void *handle) {
...
@@ -846,11 +821,11 @@ void sdbCloseTable(void *handle) {
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pTable
->
iHandle
);
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pTable
->
iHandle
);
while
(
taosHashIterNext
(
pIter
))
{
while
(
taosHashIterNext
(
pIter
))
{
SSdbRow
*
pMeta
=
taosHashIterGet
(
pIter
);
void
**
ppRow
=
taosHashIterGet
(
pIter
);
if
(
p
Meta
==
NULL
)
continue
;
if
(
p
pRow
==
NULL
)
continue
;
SSdbOper
oper
=
{
SSdbOper
oper
=
{
.
pObj
=
pMeta
->
r
ow
,
.
pObj
=
*
ppR
ow
,
.
table
=
pTable
,
.
table
=
pTable
,
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录