Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
764a8129
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
764a8129
编写于
3月 21, 2023
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add backend
上级
914d3918
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
99 addition
and
2 deletion
+99
-2
source/libs/stream/src/streamStateRocksdb.c
source/libs/stream/src/streamStateRocksdb.c
+99
-2
未找到文件。
source/libs/stream/src/streamStateRocksdb.c
浏览文件 @
764a8129
...
...
@@ -438,6 +438,35 @@ int32_t streamStateSessionPut_rocksdb(SStreamState* pState, const SSessionKey* k
STREAM_STATE_PUT_ROCKSDB
(
pState
,
"sess"
,
key
,
value
,
vLen
);
return
code
;
}
SStreamStateCur
*
streamStateSessionSeekKeyCurrentPrev_rocksdb
(
SStreamState
*
pState
,
const
SSessionKey
*
key
)
{
SStreamStateCur
*
pCur
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamStateCur
));
if
(
pCur
==
NULL
)
{
return
NULL
;
}
pCur
->
number
=
pState
->
number
;
pCur
->
iter
=
rocksdb_create_iterator_cf
(
pState
->
pTdbState
->
rocksdb
,
pState
->
pTdbState
->
ropts
,
pState
->
pTdbState
->
pHandle
[
2
]);
if
(
!
rocksdb_iter_valid
(
pCur
->
iter
))
{
streamStateFreeCur
(
pCur
);
return
NULL
;
}
SStateSessionKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
int32_t
c
=
0
;
size_t
klen
;
const
char
*
iKey
=
rocksdb_iter_key
(
pCur
->
iter
,
&
klen
);
SStateSessionKey
curKey
=
{
0
};
stateSessionKeyDecode
(
&
curKey
,
(
char
*
)
iKey
);
if
(
stateSessionKeyCmpr
(
&
sKey
,
sizeof
(
sKey
),
&
curKey
,
sizeof
(
curKey
))
>=
0
)
return
pCur
;
rocksdb_iter_prev
(
pCur
->
iter
);
if
(
!
rocksdb_iter_valid
(
pCur
->
iter
))
{
streamStateFreeCur
(
pCur
);
return
NULL
;
}
return
pCur
;
}
SStreamStateCur
*
streamStateSessionSeekKeyCurrentNext_rocksdb
(
SStreamState
*
pState
,
SSessionKey
*
key
)
{
SStreamStateCur
*
pCur
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamStateCur
));
if
(
pCur
==
NULL
)
{
...
...
@@ -467,21 +496,89 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentNext_rocksdb(SStreamState* pSta
}
return
pCur
;
}
int32_t
streamStateSessionGetKVByCur_rocksdb
(
SStreamStateCur
*
pCur
,
SSessionKey
*
pKey
,
void
**
pVal
,
int32_t
*
pVLen
)
{
if
(
!
pCur
)
{
return
-
1
;
}
SStateSessionKey
ktmp
=
{
0
};
SStateSessionKey
*
pKTmp
=
&
ktmp
;
int32_t
kLen
,
vLen
;
if
(
!
rocksdb_iter_valid
(
pCur
->
iter
))
{
return
-
1
;
}
const
char
*
curKey
=
rocksdb_iter_key
(
pCur
->
iter
,
(
size_t
*
)
&
kLen
);
stateSessionKeyDecode
((
void
*
)
&
ktmp
,
(
char
*
)
curKey
);
const
char
*
val
=
rocksdb_iter_value
(
pCur
->
iter
,
(
size_t
*
)
&
vLen
);
*
pVal
=
(
char
*
)
val
;
*
pVLen
=
vLen
;
if
(
pKTmp
->
opNum
!=
pCur
->
number
)
{
return
-
1
;
}
if
(
pKey
->
groupId
!=
0
&&
pKey
->
groupId
!=
pKTmp
->
key
.
groupId
)
{
return
-
1
;
}
*
pKey
=
pKTmp
->
key
;
return
0
;
}
int32_t
streamStateCurNext_rocksdb
(
SStreamState
*
pState
,
SStreamStateCur
*
pCur
)
{
if
(
!
pCur
)
{
return
-
1
;
}
rocksdb_iter_next
(
pCur
->
iter
);
return
0
;
}
int32_t
streamStateSessionGet_rocksdb
(
SStreamState
*
pState
,
SSessionKey
*
key
,
void
**
pVal
,
int32_t
*
pVLen
)
{
int
code
=
0
;
SStreamStateCur
*
pCur
=
streamStateSessionSeekKeyCurrentNext
(
pState
,
key
);
SStreamStateCur
*
pCur
=
streamStateSessionSeekKeyCurrentNext
_rocksdb
(
pState
,
key
);
SSessionKey
resKey
=
*
key
;
void
*
tmp
=
NULL
;
code
=
streamStateSessionGetKVByCur_rocksdb
(
pCur
,
&
resKey
,
&
tmp
,
pVLen
);
if
(
code
==
0
)
{
if
(
key
->
win
.
skey
!=
resKey
.
win
.
skey
)
{
code
=
-
1
;
}
else
{
*
key
=
resKey
;
*
pVal
=
tmp
;
}
}
streamStateFreeCur
(
pCur
);
// impl later
return
code
;
}
int32_t
streamStateSessionDel
(
SStreamState
*
pState
,
const
SSessionKey
*
key
)
{
int32_t
streamStateSessionDel
_rocksdb
(
SStreamState
*
pState
,
const
SSessionKey
*
key
)
{
int
code
=
0
;
SStateSessionKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
STREAM_STATE_DEL_ROCKSDB
(
pState
,
"sess"
,
key
);
return
code
;
}
int32_t
streamStateSessionClear
(
SStreamState
*
pState
)
{
SSessionKey
key
=
{.
win
.
skey
=
0
,
.
win
.
ekey
=
0
,
.
groupId
=
0
};
SStreamStateCur
*
pCur
=
streamStateSessionSeekKeyCurrentNext_rocksdb
(
pState
,
&
key
);
while
(
1
)
{
SSessionKey
delKey
=
{
0
};
void
*
buf
=
NULL
;
int32_t
size
=
0
;
int32_t
code
=
streamStateSessionGetKVByCur_rocksdb
(
pCur
,
&
delKey
,
&
buf
,
&
size
);
if
(
code
==
0
&&
size
>
0
)
{
memset
(
buf
,
0
,
size
);
streamStateSessionPut_rocksdb
(
pState
,
&
delKey
,
buf
,
size
);
}
else
{
break
;
}
streamStateCurNext_rocksdb
(
pState
,
pCur
);
}
streamStateFreeCur
(
pCur
);
return
-
1
;
}
int32_t
streamStatePutParTag_rocksdb
(
SStreamState
*
pState
,
int64_t
groupId
,
const
void
*
tag
,
int32_t
tagLen
)
{
int
code
=
0
;
STREAM_STATE_PUT_ROCKSDB
(
pState
,
"partag"
,
&
groupId
,
tag
,
tagLen
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录