Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8387f044
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
8387f044
编写于
3月 30, 2023
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reset version
上级
03f80fbe
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
1201 addition
and
61 deletion
+1201
-61
source/libs/stream/src/streamStateRocksdb.c
source/libs/stream/src/streamStateRocksdb.c
+64
-61
stream
stream
+1137
-0
未找到文件。
source/libs/stream/src/streamStateRocksdb.c
浏览文件 @
8387f044
...
...
@@ -411,76 +411,79 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfNa
rocksdb_readoptions_t
**
readOpt
)
{
int
idx
=
streamGetInit
(
cfName
);
*
snapshot
=
(
rocksdb_snapshot_t
*
)
rocksdb_create_snapshot
(
pState
->
pTdbState
->
rocksdb
);
//*snapshot = (rocksdb_snapshot_t*)rocksdb_create_snapshot(pState->pTdbState->rocksdb);
*
snapshot
=
NULL
;
rocksdb_readoptions_t
*
rOpt
=
rocksdb_readoptions_create
();
*
readOpt
=
rOpt
;
rocksdb_readoptions_set_snapshot
(
rOpt
,
*
snapshot
);
// rocksdb_readoptions_set_snapshot(rOpt, *snapshot);
rocksdb_readoptions_set_fill_cache
(
rOpt
,
0
);
return
rocksdb_create_iterator_cf
(
pState
->
pTdbState
->
rocksdb
,
rOpt
,
pState
->
pTdbState
->
pHandle
[
idx
]);
}
#define STREAM_STATE_PUT_ROCKSDB(pState, funcname, key, value, vLen)
\
do {
\
code = 0;
\
char buf[128] = {0};
\
char* err = NULL;
\
int i = streamGetInit(funcname);
\
if (i < 0) {
\
qWarn("streamState failed to get cf name: %s", funcname);
\
return -1;
\
}
\
char toString[128] = {0};
\
if (qDebugFlag & DEBUG_TRACE) ginitDict[i].toStrFunc((void*)key, toString);
\
ginitDict[i].enFunc((void*)key, buf);
\
rocksdb_column_family_handle_t* pHandle = pState->pTdbState->pHandle[ginitDict[i].idx];
\
rocksdb_t* db = pState->pTdbState->rocksdb;
\
rocksdb_writeoptions_t* opts = pState->pTdbState->writeOpts;
\
rocksdb_put_cf(db, opts, pHandle, (const char*)buf,
sizeof(*key)
, (const char*)value, (size_t)vLen, &err); \
if (err != NULL) {
\
taosMemoryFree(err);
\
qDebug("streamState str: %s failed to write to %s, err: %s", toString, funcname, err);
\
code = -1;
\
} else {
\
qDebug("streamState str:%s succ to write to %s, valLen:%d", toString, funcname, vLen);
\
}
\
#define STREAM_STATE_PUT_ROCKSDB(pState, funcname, key, value, vLen) \
do { \
code = 0; \
char buf[128] = {0}; \
char* err = NULL; \
int i = streamGetInit(funcname); \
if (i < 0) { \
qWarn("streamState failed to get cf name: %s", funcname); \
return -1; \
} \
char toString[128] = {0}; \
if (qDebugFlag & DEBUG_TRACE) ginitDict[i].toStrFunc((void*)key, toString); \
int32_t klen = ginitDict[i].enFunc((void*)key, buf);
\
rocksdb_column_family_handle_t* pHandle = pState->pTdbState->pHandle[ginitDict[i].idx]; \
rocksdb_t* db = pState->pTdbState->rocksdb; \
rocksdb_writeoptions_t* opts = pState->pTdbState->writeOpts; \
rocksdb_put_cf(db, opts, pHandle, (const char*)buf,
klen
, (const char*)value, (size_t)vLen, &err); \
if (err != NULL) { \
taosMemoryFree(err); \
qDebug("streamState str: %s failed to write to %s, err: %s", toString, funcname, err); \
code = -1; \
} else { \
qDebug("streamState str:%s succ to write to %s, valLen:%d", toString, funcname, vLen); \
} \
} while (0);
#define STREAM_STATE_GET_ROCKSDB(pState, funcname, key, pVal, vLen)
\
do {
\
code = 0;
\
char buf[128] = {0};
\
char* err = NULL;
\
int i = streamGetInit(funcname);
\
if (i < 0) {
\
qWarn("streamState failed to get cf name: %s", funcname);
\
return -1;
\
}
\
char toString[128] = {0};
\
if (qDebugFlag & DEBUG_TRACE) ginitDict[i].toStrFunc((void*)key, toString);
\
ginitDict[i].enFunc((void*)key, buf);
\
rocksdb_column_family_handle_t* pHandle = pState->pTdbState->pHandle[ginitDict[i].idx];
\
rocksdb_t* db = pState->pTdbState->rocksdb;
\
rocksdb_readoptions_t* opts = pState->pTdbState->readOpts;
\
size_t len = 0;
\
char* val = rocksdb_get_cf(db, opts, pHandle, (const char*)buf,
sizeof(*key)
, (size_t*)&len, &err); \
if (val == NULL) {
\
qDebug("streamState str: %s failed to read from %s, err: not exist", toString, funcname);
\
if (err != NULL) taosMemoryFree(err);
\
code = -1;
\
} else {
\
if (pVal != NULL) *pVal = val;
\
if (vLen != NULL) *vLen = len;
\
}
\
if (err != NULL) {
\
taosMemoryFree(err);
\
qDebug("streamState str: %s failed to read from %s, err: %s", toString, funcname, err);
\
code = -1;
\
} else {
\
if (code == 0) qDebug("streamState str: %s succ to read from %s", toString, funcname);
\
}
\
#define STREAM_STATE_GET_ROCKSDB(pState, funcname, key, pVal, vLen) \
do { \
code = 0; \
char buf[128] = {0}; \
char* err = NULL; \
int i = streamGetInit(funcname); \
if (i < 0) { \
qWarn("streamState failed to get cf name: %s", funcname); \
return -1; \
} \
char toString[128] = {0}; \
if (qDebugFlag & DEBUG_TRACE) ginitDict[i].toStrFunc((void*)key, toString); \
int32_t klen = ginitDict[i].enFunc((void*)key, buf);
\
rocksdb_column_family_handle_t* pHandle = pState->pTdbState->pHandle[ginitDict[i].idx]; \
rocksdb_t* db = pState->pTdbState->rocksdb; \
rocksdb_readoptions_t* opts = pState->pTdbState->readOpts; \
size_t len = 0; \
char* val = rocksdb_get_cf(db, opts, pHandle, (const char*)buf,
klen
, (size_t*)&len, &err); \
if (val == NULL) { \
qDebug("streamState str: %s failed to read from %s, err: not exist", toString, funcname); \
if (err != NULL) taosMemoryFree(err); \
code = -1; \
} else { \
if (pVal != NULL) *pVal = val; \
if (vLen != NULL) *vLen = len; \
} \
if (err != NULL) { \
taosMemoryFree(err); \
qDebug("streamState str: %s failed to read from %s, err: %s", toString, funcname, err); \
code = -1; \
} else { \
if (code == 0) qDebug("streamState str: %s succ to read from %s", toString, funcname); \
} \
} while (0);
#define STREAM_STATE_DEL_ROCKSDB(pState, funcname, key) \
...
...
@@ -495,11 +498,11 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfNa
} \
char toString[128] = {0}; \
if (qDebugFlag & DEBUG_TRACE) ginitDict[i].toStrFunc((void*)key, toString); \
ginitDict[i].enFunc((void*)key, buf);
\
int32_t klen = ginitDict[i].enFunc((void*)key, buf);
\
rocksdb_column_family_handle_t* pHandle = pState->pTdbState->pHandle[ginitDict[i].idx]; \
rocksdb_t* db = pState->pTdbState->rocksdb; \
rocksdb_writeoptions_t* opts = pState->pTdbState->writeOpts; \
rocksdb_delete_cf(db, opts, pHandle, (const char*)buf,
sizeof(*key), &err);
\
rocksdb_delete_cf(db, opts, pHandle, (const char*)buf,
klen, &err);
\
if (err != NULL) { \
qDebug("streamState str: %s failed to del from %s, err: %s", toString, funcname, err); \
taosMemoryFree(err); \
...
...
stream
0 → 100644
浏览文件 @
8387f044
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录