Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0788dac9
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看板
提交
0788dac9
编写于
11月 01, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into 3.0_refact
上级
f84b1eb2
5294b54c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
117 addition
and
21 deletion
+117
-21
source/server/vnode/tq/inc/tqMetaStore.h
source/server/vnode/tq/inc/tqMetaStore.h
+19
-21
source/server/vnode/tq/src/tqMetaStore.c
source/server/vnode/tq/src/tqMetaStore.c
+98
-0
未找到文件。
source/server/vnode/tq/inc/tqMetaStore.h
浏览文件 @
0788dac9
...
@@ -43,35 +43,33 @@ typedef struct TqMetaList {
...
@@ -43,35 +43,33 @@ typedef struct TqMetaList {
typedef
struct
TqMetaStore
{
typedef
struct
TqMetaStore
{
TqMetaList
*
inUse
[
TQ_INUSE_SIZE
];
TqMetaList
*
inUse
[
TQ_INUSE_SIZE
];
//a table head, key is empty
TqMetaList
*
unpersistHead
;
TqMetaList
*
unpersistHead
;
//deserializer
int
fileFd
;
//TODO:temporaral use
//serializer
int
idxFd
;
//TODO:temporaral use
//deleter
void
*
(
*
serializer
)(
void
*
);
void
*
(
*
deserializer
)(
void
*
);
void
(
*
deleter
)(
void
*
);
}
TqMetaStore
;
}
TqMetaStore
;
typedef
struct
TqMetaPageBuf
{
TqMetaStore
*
tqStoreOpen
(
const
char
*
path
,
void
*
serializer
(
void
*
),
void
*
deserializer
(
void
*
),
void
deleter
(
void
*
));
int16_t
offset
;
int32_t
tqStoreClose
(
TqMetaStore
*
);
char
buffer
[
TQ_PAGE_SIZE
];
int32_t
tqStoreDelete
(
TqMetaStore
*
);
}
TqMetaPageBuf
;
//int32_t TqStoreCommitAll(TqMetaStore*);
int32_t
tqStorePersist
(
TqMetaStore
*
);
TqMetaStore
*
TqStoreOpen
(
const
char
*
path
,
void
*
serializer
(
void
*
),
void
*
deserializer
(
void
*
));
TqMetaHandle
*
tqHandleGetInUse
(
TqMetaStore
*
,
int64_t
key
);
int32_t
TqStoreClose
(
TqMetaStore
*
);
int32_t
tqHandlePutInUse
(
TqMetaStore
*
,
TqMetaHandle
*
handle
);
int32_t
TqStoreDelete
(
TqMetaStore
*
);
TqMetaHandle
*
tqHandleGetInTxn
(
TqMetaStore
*
,
int64_t
key
);
int32_t
TqStoreCommitAll
(
TqMetaStore
*
);
int32_t
tqHandlePutInTxn
(
TqMetaStore
*
,
TqMetaHandle
*
handle
);
int32_t
TqStorePersist
(
TqMetaStore
*
);
TqMetaHandle
*
TqHandleGetInUse
(
TqMetaStore
*
,
int64_t
key
);
int32_t
TqHandlePutInUse
(
TqMetaStore
*
,
TqMetaHandle
*
handle
);
TqMetaHandle
*
TqHandleGetInTxn
(
TqMetaStore
*
,
int64_t
key
);
int32_t
TqHandlePutInTxn
(
TqMetaStore
*
,
TqMetaHandle
*
handle
);
//delete in-use-handle, make in-txn-handle in use
//delete in-use-handle, make in-txn-handle in use
int32_t
T
qHandleCommit
(
TqMetaStore
*
,
int64_t
key
);
int32_t
t
qHandleCommit
(
TqMetaStore
*
,
int64_t
key
);
//delete in-txn-handle
//delete in-txn-handle
int32_t
T
qHandleAbort
(
TqMetaStore
*
,
int64_t
key
);
int32_t
t
qHandleAbort
(
TqMetaStore
*
,
int64_t
key
);
//delete in-use-handle
//delete in-use-handle
int32_t
T
qHandleDel
(
TqMetaStore
*
,
int64_t
key
);
int32_t
t
qHandleDel
(
TqMetaStore
*
,
int64_t
key
);
//delete in-use-handle and in-txn-handle
//delete in-use-handle and in-txn-handle
int32_t
T
qHandleClear
(
TqMetaStore
*
,
int64_t
key
);
int32_t
t
qHandleClear
(
TqMetaStore
*
,
int64_t
key
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/server/vnode/tq/src/tqMetaStore.c
浏览文件 @
0788dac9
...
@@ -12,3 +12,101 @@
...
@@ -12,3 +12,101 @@
* You should have received a copy of the GNU Affero General Public License
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "tqMetaStore.h"
//TODO:replace by a abstract file layer
#include <fcntl.h>
#include <unistd.h>
typedef
struct
TqMetaPageBuf
{
int16_t
offset
;
char
buffer
[
TQ_PAGE_SIZE
];
}
TqMetaPageBuf
;
TqMetaStore
*
tqStoreOpen
(
const
char
*
path
,
void
*
serializer
(
void
*
),
void
*
deserializer
(
void
*
),
void
deleter
(
void
*
))
{
//concat data file name and index file name
int
fileFd
=
open
(
path
,
O_WRONLY
|
O_CREAT
|
O_EXCL
,
0755
);
if
(
fileFd
<
0
)
return
NULL
;
TqMetaStore
*
pMeta
=
malloc
(
sizeof
(
TqMetaStore
));
if
(
pMeta
==
NULL
)
{
//close
return
NULL
;
}
memset
(
pMeta
,
0
,
sizeof
(
TqMetaStore
));
pMeta
->
fileFd
=
fileFd
;
int
idxFd
=
open
(
path
,
O_WRONLY
|
O_CREAT
|
O_EXCL
,
0755
);
if
(
idxFd
<
0
)
{
//close file
//free memory
return
NULL
;
}
pMeta
->
idxFd
=
idxFd
;
pMeta
->
unpersistHead
=
malloc
(
sizeof
(
TqMetaList
));
if
(
pMeta
->
unpersistHead
==
NULL
)
{
//close file
//free memory
return
NULL
;
}
pMeta
->
serializer
=
serializer
;
pMeta
->
deserializer
=
deserializer
;
pMeta
->
deleter
=
deleter
;
return
pMeta
;
}
int32_t
tqStoreClose
(
TqMetaStore
*
pMeta
)
{
//commit data and idx
//close file
//free memory
return
0
;
}
int32_t
tqStoreDelete
(
TqMetaStore
*
pMeta
)
{
//close file
//delete file
//free memory
return
0
;
}
int32_t
tqStorePersist
(
TqMetaStore
*
pMeta
)
{
TqMetaList
*
node
=
pMeta
->
unpersistHead
;
while
(
node
->
unpersistNext
)
{
//serialize
//append data
//write offset and idx
//remove from unpersist list
}
return
0
;
}
int32_t
tqHandlePutInUse
(
TqMetaStore
*
pMeta
,
TqMetaHandle
*
handle
)
{
return
0
;
}
TqMetaHandle
*
tqHandleGetInUse
(
TqMetaStore
*
pMeta
,
int64_t
key
)
{
return
NULL
;
}
int32_t
tqHandlePutInTxn
(
TqMetaStore
*
pMeta
,
TqMetaHandle
*
handle
)
{
return
0
;
}
TqMetaHandle
*
tqHandleGetInTxn
(
TqMetaStore
*
pMeta
,
int64_t
key
)
{
return
NULL
;
}
int32_t
tqHandleCommit
(
TqMetaStore
*
pMeta
,
int64_t
key
)
{
return
0
;
}
int32_t
tqHandleAbort
(
TqMetaStore
*
pMeta
,
int64_t
key
)
{
return
0
;
}
int32_t
tqHandleDel
(
TqMetaStore
*
pMeta
,
int64_t
key
)
{
return
0
;
}
int32_t
tqHandleClear
(
TqMetaStore
*
pMeta
,
int64_t
key
)
{
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录