Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c3a8ecd9
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看板
提交
c3a8ecd9
编写于
3月 30, 2023
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reset version
上级
009d5099
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
66 addition
and
24 deletion
+66
-24
source/libs/stream/src/streamStateRocksdb.c
source/libs/stream/src/streamStateRocksdb.c
+66
-24
未找到文件。
source/libs/stream/src/streamStateRocksdb.c
浏览文件 @
c3a8ecd9
...
...
@@ -319,8 +319,8 @@ int streamInitBackend(SStreamState* pState, char* path) {
rocksdb_options_set_block_based_table_factory
((
rocksdb_options_t
*
)
cfOpt
[
i
],
tableOpt
);
rocksdb_slicetransform_t
*
trans
=
rocksdb_slicetransform_create_fixed_prefix
(
8
);
rocksdb_options_set_prefix_extractor
((
rocksdb_options_t
*
)
cfOpt
[
i
],
trans
);
//
rocksdb_slicetransform_t* trans = rocksdb_slicetransform_create_fixed_prefix(8);
//
rocksdb_options_set_prefix_extractor((rocksdb_options_t*)cfOpt[i], trans);
};
rocksdb_comparator_t
**
pCompare
=
taosMemoryCalloc
(
cfLen
,
sizeof
(
rocksdb_comparator_t
**
));
...
...
@@ -401,9 +401,12 @@ int streamGetInit(const char* funcName) {
return
-
1
;
}
bool
streamStateIterSeekAndValid
(
rocksdb_iterator_t
*
iter
,
char
*
buf
,
size_t
len
)
{
rocksdb_iter_seek
_for_prev
(
iter
,
buf
,
len
);
rocksdb_iter_seek
(
iter
,
buf
,
len
);
if
(
!
rocksdb_iter_valid
(
iter
))
{
return
false
;
rocksdb_iter_seek_for_prev
(
iter
,
buf
,
len
);
if
(
!
rocksdb_iter_valid
(
iter
))
{
return
false
;
}
}
return
true
;
}
...
...
@@ -412,8 +415,9 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfNa
int
idx
=
streamGetInit
(
cfName
);
//*snapshot = (rocksdb_snapshot_t*)rocksdb_create_snapshot(pState->pTdbState->rocksdb);
*
snapshot
=
NULL
;
if
(
snapshot
!=
NULL
)
{
*
snapshot
=
NULL
;
}
rocksdb_readoptions_t
*
rOpt
=
rocksdb_readoptions_create
();
*
readOpt
=
rOpt
;
...
...
@@ -572,29 +576,67 @@ int32_t streamStateFillDel_rocksdb(SStreamState* pState, const SWinKey* key) {
int32_t
streamStateClear_rocksdb
(
SStreamState
*
pState
)
{
qDebug
(
"streamStateClear_rocksdb"
);
SStateKey
sKey
=
{.
key
=
{.
ts
=
0
,
.
groupId
=
0
},
.
opNum
=
pState
->
number
};
SStateKey
eKey
=
{.
key
=
{.
ts
=
INT64_MAX
,
.
groupId
=
UINT64_MAX
},
.
opNum
=
pState
->
number
};
char
sKeyStr
[
128
]
=
{
0
};
char
eKeyStr
[
128
]
=
{
0
};
//
SStateKey sKey = {.key = {.ts = 0, .groupId = 0}, .opNum = pState->number};
//
SStateKey eKey = {.key = {.ts = INT64_MAX, .groupId = UINT64_MAX}, .opNum = pState->number};
//
char sKeyStr[128] = {0};
//
char eKeyStr[128] = {0};
int
sLen
=
stateKeyEncode
(
&
sKey
,
sKeyStr
);
int
eLen
=
stateKeyEncode
(
&
eKey
,
eKeyStr
);
//
int sLen = stateKeyEncode(&sKey, sKeyStr);
//
int eLen = stateKeyEncode(&eKey, eKeyStr);
char
toStringStart
[
128
]
=
{
0
};
char
toStringEnd
[
128
]
=
{
0
};
if
(
qDebugFlag
&
DEBUG_TRACE
)
{
stateKeyToString
(
&
sKey
,
toStringStart
);
stateKeyToString
(
&
eKey
,
toStringEnd
);
}
// char toStringStart[128] = {0};
// char toStringEnd[128] = {0};
// if (qDebugFlag & DEBUG_TRACE) {
// stateKeyToString(&sKey, toStringStart);
// stateKeyToString(&eKey, toStringEnd);
// }
// char* err = NULL;
// rocksdb_delete_range_cf(pState->pTdbState->rocksdb, pState->pTdbState->writeOpts, pState->pTdbState->pHandle[0],
// sKeyStr, sLen, eKeyStr, eLen, &err);
// // rocksdb_compact_range_cf(pState->pTdbState->rocksdb, pState->pTdbState->pHandle[0], sKeyStr, sLen, eKeyStr,
// eLen); if (err != NULL) {
// qWarn("failed to delete range cf(default) err: %s, start: %s, end:%s", err, toStringStart, toStringEnd);
// taosMemoryFree(err);
// }
// del one by one
char
buf
[
128
]
=
{
0
};
char
*
s
=
"null"
;
SWinKey
key
=
{.
ts
=
0
,
.
groupId
=
0
};
SStateKey
skey
=
{.
key
=
key
,
.
opNum
=
pState
->
number
};
int
sLen
=
stateKeyEncode
(
&
skey
,
buf
);
streamStatePut_rocksdb
(
pState
,
&
key
,
s
,
strlen
(
s
));
rocksdb_readoptions_t
*
opt
=
NULL
;
rocksdb_iterator_t
*
iter
=
streamStateIterCreate
(
pState
,
"default"
,
NULL
,
&
opt
);
rocksdb_iter_seek
(
iter
,
buf
,
sLen
);
// int32_t limit = 128;
// krocksdb_writebatch_t* batch = rocksdb_writebatch_create();
char
*
err
=
NULL
;
rocksdb_delete_range_cf
(
pState
->
pTdbState
->
rocksdb
,
pState
->
pTdbState
->
writeOpts
,
pState
->
pTdbState
->
pHandle
[
0
],
sKeyStr
,
sLen
,
eKeyStr
,
eLen
,
&
err
);
// rocksdb_compact_range_cf(pState->pTdbState->rocksdb, pState->pTdbState->pHandle[0], sKeyStr, sLen, eKeyStr, eLen);
if
(
err
!=
NULL
)
{
qWarn
(
"failed to delete range cf(default) err: %s, start: %s, end:%s"
,
err
,
toStringStart
,
toStringEnd
);
taosMemoryFree
(
err
);
while
(
rocksdb_iter_valid
(
iter
))
{
int
kLen
=
0
;
char
*
key
=
(
char
*
)
rocksdb_iter_key
(
iter
,
(
size_t
*
)
&
kLen
);
SStateKey
sskey
=
{
0
};
stateKeyDecode
((
void
*
)
&
sskey
,
key
);
if
(
sskey
.
opNum
!=
pState
->
number
)
{
rocksdb_iter_next
(
iter
);
continue
;
}
rocksdb_delete_cf
(
pState
->
pTdbState
->
rocksdb
,
pState
->
pTdbState
->
writeOpts
,
pState
->
pTdbState
->
pHandle
[
0
],
key
,
kLen
,
&
err
);
if
(
err
!=
NULL
)
{
taosMemoryFree
(
err
);
}
if
(
rocksdb_iter_valid
(
iter
))
rocksdb_iter_next
(
iter
);
}
rocksdb_iter_destroy
(
iter
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录