Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ed4aaade
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看板
提交
ed4aaade
编写于
4月 12, 2023
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add backend
上级
7db12bb3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
62 addition
and
15 deletion
+62
-15
include/libs/stream/tstreamFileState.h
include/libs/stream/tstreamFileState.h
+14
-9
source/libs/stream/inc/streamBackendRocksdb.h
source/libs/stream/inc/streamBackendRocksdb.h
+1
-0
source/libs/stream/src/streamStateRocksdb.c
source/libs/stream/src/streamStateRocksdb.c
+34
-2
source/libs/stream/src/tstreamFileState.c
source/libs/stream/src/tstreamFileState.c
+13
-4
未找到文件。
include/libs/stream/tstreamFileState.h
浏览文件 @
ed4aaade
...
...
@@ -18,6 +18,7 @@
#include "os.h"
#include "tarray.h"
#include "tdef.h"
#include "tlist.h"
...
...
@@ -27,29 +28,33 @@ extern "C" {
typedef
struct
SStreamFileState
SStreamFileState
;
typedef
struct
SRowBuffPos
{
void
*
pRowBuff
;
void
*
pKey
;
bool
beFlushed
;
bool
beUsed
;
void
*
pRowBuff
;
void
*
pKey
;
bool
beFlushed
;
bool
beUsed
;
}
SRowBuffPos
;
typedef
SList
SStreamSnapshot
;
typedef
TSKEY
(
*
GetTsFun
)(
void
*
);
SStreamFileState
*
streamFileStateInit
(
int64_t
memSize
,
uint32_t
keySize
,
uint32_t
rowSize
,
GetTsFun
fp
,
void
*
pFile
,
TSKEY
delMark
);
SStreamFileState
*
streamFileStateInit
(
int64_t
memSize
,
uint32_t
keySize
,
uint32_t
rowSize
,
GetTsFun
fp
,
void
*
pFile
,
TSKEY
delMark
);
void
streamFileStateDestroy
(
SStreamFileState
*
pFileState
);
void
streamFileStateClear
(
SStreamFileState
*
pFileState
);
int32_t
getRowBuff
(
SStreamFileState
*
pFileState
,
void
*
pKey
,
int32_t
keyLen
,
void
**
pVal
,
int32_t
*
pVLen
);
int32_t
deleteRowBuff
(
SStreamFileState
*
pFileState
,
const
void
*
pKey
,
int32_t
keyLen
);
int32_t
getRowBuffByPos
(
SStreamFileState
*
pFileState
,
SRowBuffPos
*
pPos
,
void
**
pVal
);
void
releaseRowBuffPos
(
SRowBuffPos
*
pBuff
);
bool
hasRowBuff
(
SStreamFileState
*
pFileState
,
void
*
pKey
,
int32_t
keyLen
);
void
releaseRowBuffPos
(
SRowBuffPos
*
pBuff
);
bool
hasRowBuff
(
SStreamFileState
*
pFileState
,
void
*
pKey
,
int32_t
keyLen
);
SStreamSnapshot
*
getSnapshot
(
SStreamFileState
*
pFileState
);
int32_t
flushSnapshot
(
SStreamFileState
*
pFileState
,
SStreamSnapshot
*
pSnapshot
,
bool
flushState
);
int32_t
recoverSnapshot
(
SStreamFileState
*
pFileState
);
int32_t
flushSnapshot
(
SStreamFileState
*
pFileState
,
SStreamSnapshot
*
pSnapshot
,
bool
flushState
);
int32_t
recoverSnapshot
(
SStreamFileState
*
pFileState
);
int32_t
getSnapshotIdList
(
SStreamFileState
*
pFileState
,
SArray
*
list
);
int32_t
forceRemoveCheckpoint
(
SStreamFileState
*
pFileState
,
int64_t
checkpointId
);
#ifdef __cplusplus
}
...
...
source/libs/stream/inc/streamBackendRocksdb.h
浏览文件 @
ed4aaade
...
...
@@ -89,4 +89,5 @@ int32_t streamStatePutBatch_rocksdb(SStreamState* pState, void* pBatch);
int32_t
streamDefaultPut_rocksdb
(
SStreamState
*
pState
,
const
void
*
key
,
void
*
pVal
,
int32_t
pVLen
);
int32_t
streamDefaultGet_rocksdb
(
SStreamState
*
pState
,
const
void
*
key
,
void
**
pVal
,
int32_t
*
pVLen
);
int32_t
streamDefaultDel_rocksdb
(
SStreamState
*
pState
,
const
void
*
key
);
int32_t
streamDefaultIter_rocksdb
(
SStreamState
*
pState
,
const
void
*
start
,
const
void
*
end
,
SArray
*
result
);
#endif
\ No newline at end of file
source/libs/stream/src/streamStateRocksdb.c
浏览文件 @
ed4aaade
...
...
@@ -458,9 +458,8 @@ 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);
if
(
snapshot
!=
NULL
)
{
*
snapshot
=
NULL
;
*
snapshot
=
(
rocksdb_snapshot_t
*
)
rocksdb_create_snapshot
(
pState
->
pTdbState
->
rocksdb
)
;
}
rocksdb_readoptions_t
*
rOpt
=
rocksdb_readoptions_create
();
...
...
@@ -638,6 +637,39 @@ int32_t streamDefaultDel_rocksdb(SStreamState* pState, const void* key) {
return
code
;
}
int32_t
streamDefaultIter_rocksdb
(
SStreamState
*
pState
,
const
void
*
start
,
const
void
*
end
,
SArray
*
result
)
{
int
code
=
0
;
char
*
err
=
NULL
;
rocksdb_snapshot_t
*
snapshot
=
NULL
;
rocksdb_readoptions_t
*
readopts
=
NULL
;
rocksdb_iterator_t
*
pIter
=
streamStateIterCreate
(
pState
,
"default"
,
&
snapshot
,
&
readopts
);
if
(
pIter
==
NULL
)
{
return
-
1
;
}
rocksdb_iter_seek
(
pIter
,
start
,
strlen
(
start
));
while
(
rocksdb_iter_valid
(
pIter
))
{
const
char
*
key
=
rocksdb_iter_key
(
pIter
,
NULL
);
if
(
end
!=
NULL
&&
strcmp
(
key
,
end
)
>
0
)
{
break
;
}
if
(
strncmp
(
key
,
start
,
strlen
(
start
))
==
0
&&
strlen
(
key
)
>=
strlen
(
start
)
+
1
)
{
int64_t
checkPoint
=
0
;
if
(
sscanf
(
key
+
strlen
(
key
),
":%"
PRId64
""
,
&
checkPoint
)
==
1
)
{
taosArrayPush
(
result
,
&
checkPoint
);
}
}
else
{
break
;
}
rocksdb_iter_next
(
pIter
);
}
rocksdb_release_snapshot
(
pState
->
pTdbState
->
rocksdb
,
snapshot
);
rocksdb_readoptions_destroy
(
readopts
);
rocksdb_iter_destroy
(
pIter
);
return
code
;
}
int32_t
streamStateGet_rocksdb
(
SStreamState
*
pState
,
const
SWinKey
*
key
,
void
**
pVal
,
int32_t
*
pVLen
)
{
int
code
=
0
;
SStateKey
sKey
=
{.
key
=
*
key
,
.
opNum
=
pState
->
number
};
...
...
source/libs/stream/src/tstreamFileState.c
浏览文件 @
ed4aaade
...
...
@@ -371,7 +371,7 @@ int32_t flushSnapshot(SStreamFileState* pFileState, SStreamSnapshot* pSnapshot,
char
keyBuf
[
128
]
=
{
0
};
char
valBuf
[
64
]
=
{
0
};
int32_t
len
=
0
;
sprintf
(
keyBuf
,
"%s:%"
PRId64
""
,
taskKey
,
INT64_MIN
);
memcpy
(
keyBuf
,
taskKey
,
strlen
(
taskKey
)
);
sprintf
(
valBuf
,
"%"
PRId64
""
,
((
SStreamState
*
)
pFileState
->
pFileStore
)
->
checkPointId
);
streamStatePutBatch
(
pFileState
->
pFileStore
,
"default"
,
batch
,
keyBuf
,
valBuf
,
strlen
(
valBuf
));
...
...
@@ -382,7 +382,16 @@ int32_t flushSnapshot(SStreamFileState* pFileState, SStreamSnapshot* pSnapshot,
streamStateDestroyBatch
(
batch
);
return
code
;
}
int32_t
forceRemoveCheckpoint
(
SStreamFileState
*
pFileState
,
int64_t
checkpointId
)
{
const
char
*
taskKey
=
"streamFileState"
;
char
keyBuf
[
128
]
=
{
0
};
sprintf
(
keyBuf
,
"%s:%"
PRId64
""
,
taskKey
,
checkpointId
);
return
streamDefaultDel_rocksdb
(
pFileState
->
pFileStore
,
keyBuf
);
}
int32_t
getSnapshotIdList
(
SStreamFileState
*
pFileState
,
SArray
*
list
)
{
const
char
*
taskKey
=
"streamFileState"
;
return
streamDefaultIter_rocksdb
(
pFileState
->
pFileStore
,
taskKey
,
NULL
,
list
);
}
int32_t
recoverSnapshot
(
SStreamFileState
*
pFileState
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
const
char
*
taskKey
=
"streamFileState"
;
...
...
@@ -391,7 +400,7 @@ int32_t recoverSnapshot(SStreamFileState* pFileState) {
char
buf
[
128
]
=
{
0
};
void
*
val
=
NULL
;
int32_t
len
=
0
;
sprintf
(
buf
,
"%s:%"
PRId64
""
,
taskKey
,
INT64_MIN
);
memcpy
(
buf
,
taskKey
,
strlen
(
taskKey
)
);
code
=
streamDefaultGet_rocksdb
(
pFileState
->
pFileStore
,
buf
,
&
val
,
&
len
);
if
(
code
!=
0
)
{
return
TSDB_CODE_FAILED
;
...
...
@@ -412,7 +421,7 @@ int32_t recoverSnapshot(SStreamFileState* pFileState) {
sscanf
(
val
,
"%"
PRId64
""
,
&
ts
);
taosMemoryFree
(
val
);
if
(
ts
<
pFileState
->
flushMark
)
{
// forceRemoveCheckPoint(pFileState->pFileStor
e, i);
forceRemoveCheckpoint
(
pFileStat
e
,
i
);
break
;
}
else
{
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录