Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5deae213
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看板
提交
5deae213
编写于
11月 01, 2021
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine tq meta data structure
上级
4e902908
变更
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
浏览文件 @
5deae213
...
...
@@ -43,35 +43,33 @@ typedef struct TqMetaList {
typedef
struct
TqMetaStore
{
TqMetaList
*
inUse
[
TQ_INUSE_SIZE
];
//a table head, key is empty
TqMetaList
*
unpersistHead
;
//deserializer
//serializer
//deleter
int
fileFd
;
//TODO:temporaral use
int
idxFd
;
//TODO:temporaral use
void
*
(
*
serializer
)(
void
*
);
void
*
(
*
deserializer
)(
void
*
);
void
(
*
deleter
)(
void
*
);
}
TqMetaStore
;
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
*
));
int32_t
tqStoreClose
(
TqMetaStore
*
);
int32_t
tqStoreDelete
(
TqMetaStore
*
);
//int32_t TqStoreCommitAll(TqMetaStore*);
int32_t
tqStorePersist
(
TqMetaStore
*
);
TqMetaStore
*
TqStoreOpen
(
const
char
*
path
,
void
*
serializer
(
void
*
),
void
*
deserializer
(
void
*
));
int32_t
TqStoreClose
(
TqMetaStore
*
);
int32_t
TqStoreDelete
(
TqMetaStore
*
);
int32_t
TqStoreCommitAll
(
TqMetaStore
*
);
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
);
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
int32_t
T
qHandleCommit
(
TqMetaStore
*
,
int64_t
key
);
int32_t
t
qHandleCommit
(
TqMetaStore
*
,
int64_t
key
);
//delete in-txn-handle
int32_t
T
qHandleAbort
(
TqMetaStore
*
,
int64_t
key
);
int32_t
t
qHandleAbort
(
TqMetaStore
*
,
int64_t
key
);
//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
int32_t
T
qHandleClear
(
TqMetaStore
*
,
int64_t
key
);
int32_t
t
qHandleClear
(
TqMetaStore
*
,
int64_t
key
);
#ifdef __cplusplus
}
...
...
source/server/vnode/tq/src/tqMetaStore.c
浏览文件 @
5deae213
...
...
@@ -12,3 +12,101 @@
* 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/>.
*/
#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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录