Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
10cee51d
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
10cee51d
编写于
5月 10, 2023
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(cache/get): move rocks wring out of column iterating
上级
0958fe56
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
29 deletion
+27
-29
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+27
-29
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
10cee51d
...
...
@@ -340,6 +340,16 @@ _exit:
return
code
;
}
static
void
reallocVarData
(
SColVal
*
pColVal
)
{
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
uint8_t
*
pVal
=
pColVal
->
value
.
pData
;
pColVal
->
value
.
pData
=
taosMemoryMalloc
(
pColVal
->
value
.
nData
);
if
(
pColVal
->
value
.
nData
)
{
memcpy
(
pColVal
->
value
.
pData
,
pVal
,
pColVal
->
value
.
nData
);
}
}
}
static
int32_t
mergeLastCid
(
tb_uid_t
uid
,
STsdb
*
pTsdb
,
SArray
**
ppLastArray
,
SCacheRowsReader
*
pr
,
int16_t
*
aCols
,
int
nCols
,
int16_t
*
slotIds
);
...
...
@@ -347,9 +357,10 @@ static int32_t mergeLastRowCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray,
int
nCols
,
int16_t
*
slotIds
);
int32_t
tsdbCacheGet
(
STsdb
*
pTsdb
,
tb_uid_t
uid
,
SArray
*
pLastArray
,
SCacheRowsReader
*
pr
,
int32_t
ltype
)
{
static
char
const
*
alstring
[
2
]
=
{
"last_row"
,
"last"
};
char
const
*
lstring
=
alstring
[
ltype
];
int32_t
code
=
0
;
static
char
const
*
alstring
[
2
]
=
{
"last_row"
,
"last"
};
char
const
*
lstring
=
alstring
[
ltype
];
rocksdb_writebatch_t
*
wb
=
NULL
;
int32_t
code
=
0
;
SArray
*
pCidList
=
pr
->
pCidList
;
int
num_keys
=
TARRAY_SIZE
(
pCidList
);
...
...
@@ -387,14 +398,7 @@ int32_t tsdbCacheGet(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCacheRowsR
int16_t
cid
=
*
(
int16_t
*
)
taosArrayGet
(
pCidList
,
i
);
SLastCol
noneCol
=
{.
ts
=
TSKEY_MIN
,
.
colVal
=
COL_VAL_NONE
(
cid
,
pr
->
pSchema
->
columns
[
pr
->
pSlotIds
[
i
]].
type
)};
if
(
pLastCol
)
{
SColVal
*
pColVal
=
&
pLastCol
->
colVal
;
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
uint8_t
*
pVal
=
pColVal
->
value
.
pData
;
pColVal
->
value
.
pData
=
taosMemoryMalloc
(
pColVal
->
value
.
nData
);
if
(
pColVal
->
value
.
nData
)
{
memcpy
(
pColVal
->
value
.
pData
,
pVal
,
pColVal
->
value
.
nData
);
}
}
reallocVarData
(
&
pLastCol
->
colVal
);
}
else
{
taosThreadMutexLock
(
&
pTsdb
->
rCache
.
rMutex
);
...
...
@@ -423,31 +427,17 @@ int32_t tsdbCacheGet(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCacheRowsR
}
// store result back to rocks cache
rocksdb_writebatch_t
*
wb
=
pTsdb
->
rCache
.
writebatch
;
char
*
value
=
NULL
;
size_t
vlen
=
0
;
wb
=
pTsdb
->
rCache
.
writebatch
;
char
*
value
=
NULL
;
size_t
vlen
=
0
;
tsdbCacheSerialize
(
pLastCol
,
&
value
,
&
vlen
);
char
key
[
ROCKS_KEY_LEN
];
size_t
klen
=
snprintf
(
key
,
ROCKS_KEY_LEN
,
"%"
PRIi64
":%"
PRIi16
":%s"
,
uid
,
pLastCol
->
colVal
.
cid
,
lstring
);
rocksdb_writebatch_put
(
wb
,
key
,
klen
,
value
,
vlen
);
taosMemoryFree
(
value
);
char
*
err
=
NULL
;
rocksdb_write
(
pTsdb
->
rCache
.
db
,
pTsdb
->
rCache
.
writeoptions
,
wb
,
&
err
);
if
(
NULL
!=
err
)
{
tsdbError
(
"vgId:%d, %s failed at line %d since %s"
,
TD_VID
(
pTsdb
->
pVnode
),
__func__
,
__LINE__
,
err
);
rocksdb_free
(
err
);
}
}
else
{
SColVal
*
pColVal
=
&
pLastCol
->
colVal
;
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
uint8_t
*
pVal
=
pColVal
->
value
.
pData
;
pColVal
->
value
.
pData
=
taosMemoryMalloc
(
pColVal
->
value
.
nData
);
if
(
pColVal
->
value
.
nData
)
{
memcpy
(
pColVal
->
value
.
pData
,
pVal
,
pColVal
->
value
.
nData
);
}
}
reallocVarData
(
&
pLastCol
->
colVal
);
}
taosThreadMutexUnlock
(
&
pTsdb
->
rCache
.
rMutex
);
...
...
@@ -463,6 +453,14 @@ int32_t tsdbCacheGet(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCacheRowsR
taosMemoryFree
(
values_list
);
taosMemoryFree
(
values_list_sizes
);
if
(
wb
)
{
char
*
err
=
NULL
;
rocksdb_write
(
pTsdb
->
rCache
.
db
,
pTsdb
->
rCache
.
writeoptions
,
wb
,
&
err
);
if
(
NULL
!=
err
)
{
tsdbError
(
"vgId:%d, %s failed at line %d since %s"
,
TD_VID
(
pTsdb
->
pVnode
),
__func__
,
__LINE__
,
err
);
rocksdb_free
(
err
);
}
}
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录