Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
627dc00b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
627dc00b
编写于
6月 13, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more work
上级
2c634308
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
174 addition
and
24 deletion
+174
-24
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+39
-18
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+1
-0
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+134
-6
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
627dc00b
...
...
@@ -112,14 +112,15 @@ typedef struct SCacheFReader SCacheFReader;
// tsdbCommit.c ==============================================================================================
// tsdbReadImpl.c ==============================================================================================
typedef
struct
SBlockIdx
SBlockIdx
;
typedef
struct
SBlockInfo
SBlockInfo
;
typedef
struct
SBlock
SBlock
;
typedef
struct
SBlockCol
SBlockCol
;
typedef
struct
SBlockStatis
SBlockStatis
;
typedef
struct
SAggrBlkCol
SAggrBlkCol
;
typedef
struct
SBlockData
SBlockData
;
typedef
struct
SReadH
SReadH
;
typedef
struct
SBlockIdxItem
SBlockIdxItem
;
typedef
struct
SBlockIdx
SBlockIdx
;
typedef
struct
SBlockInfo
SBlockInfo
;
typedef
struct
SBlock
SBlock
;
typedef
struct
SBlockCol
SBlockCol
;
typedef
struct
SBlockStatis
SBlockStatis
;
typedef
struct
SAggrBlkCol
SAggrBlkCol
;
typedef
struct
SBlockData
SBlockData
;
typedef
struct
SReadH
SReadH
;
typedef
struct
SDFileSetReader
SDFileSetReader
;
typedef
struct
SDFileSetWriter
SDFileSetWriter
;
...
...
@@ -149,6 +150,16 @@ void tsdbFree(uint8_t *pBuf);
int32_t
tTABLEIDCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
int32_t
tsdbKeyCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
// SBlockIdx
int32_t
tBlockIdxClear
(
SBlockIdx
*
pBlockIdx
);
int32_t
tBlockIdxPutItem
(
SBlockIdx
*
pBlockIdx
,
SBlockIdxItem
*
pItem
);
int32_t
tBlockIdxGetItemByIdx
(
SBlockIdx
*
pBlockIdx
,
SBlockIdxItem
*
pItem
,
int32_t
idx
);
int32_t
tBlockIdxGetItem
(
SBlockIdx
*
pBlockIdx
,
SBlockIdxItem
*
pItem
,
TABLEID
id
);
int32_t
tPutBlockIdx
(
uint8_t
*
p
,
SBlockIdx
*
pBlockIdx
);
int32_t
tGetBlockIdx
(
uint8_t
*
p
,
SBlockIdx
*
pBlockIdx
);
// SBlock
// SDelIdx
int32_t
tDelIdxClear
(
SDelIdx
*
pDelIdx
);
int32_t
tDelIdxPutItem
(
SDelIdx
*
pDelIdx
,
SDelIdxItem
*
pItem
);
...
...
@@ -251,15 +262,24 @@ struct TSDBROW {
STSRow
*
pTSRow
;
};
struct
SBlockIdx
{
struct
SBlockIdx
Item
{
int64_t
suid
;
int64_t
uid
;
int64_t
maxVersion
;
TSDBKEY
minKey
;
TSDBKEY
maxKey
;
int64_t
minVersion
;
int64_t
maxVersion
;
int64_t
offset
;
int64_t
size
;
};
struct
SBlockIdx
{
uint32_t
delimiter
;
SOffset
offset
;
uint32_t
nData
;
uint8_t
*
pData
;
};
typedef
enum
{
TSDB_SBLK_VER_0
=
0
,
TSDB_SBLK_VER_MAX
,
...
...
@@ -267,19 +287,20 @@ typedef enum {
#define SBlockVerLatest TSDB_SBLK_VER_0
struct
SBlock
{
struct
SBlock
Item
{
TSDBKEY
minKey
;
TSDBKEY
maxKey
;
int64_t
minVerion
;
int64_t
maxVersion
;
int64_t
minVersion
;
uint8_t
flags
;
// last, algorithm
};
struct
SBlockInfo
{
int32_t
delimiter
;
// For recovery usage
uint64_t
suid
;
uint64_t
uid
;
SBlock
blocks
[];
struct
SBlock
{
uint32_t
delimiter
;
int64_t
suid
;
int64_t
uid
;
SOffset
offset
;
uint32_t
nData
;
uint8_t
*
pData
;
};
struct
SBlockCol
{
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
627dc00b
...
...
@@ -295,6 +295,7 @@ static int32_t tsdbCommitDelEnd(SCommitter *pCommitter) {
if
(
code
)
goto
_err
;
}
tDelDataClear
(
&
pCommitter
->
delDataNew
);
tDelIdxClear
(
&
pCommitter
->
delIdxNew
);
return
code
;
...
...
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
627dc00b
...
...
@@ -203,6 +203,25 @@ int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
return
0
;
}
// TSDBKEY ======================================================
static
FORCE_INLINE
int32_t
tPutTSDBKEY
(
uint8_t
*
p
,
TSDBKEY
*
pKey
)
{
int32_t
n
=
0
;
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pKey
->
version
);
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pKey
->
ts
);
return
n
;
}
static
FORCE_INLINE
int32_t
tGetTSDBKEY
(
uint8_t
*
p
,
TSDBKEY
*
pKey
)
{
int32_t
n
=
0
;
n
+=
tGetI64v
(
p
+
n
,
&
pKey
->
version
);
n
+=
tGetI64
(
p
+
n
,
&
pKey
->
ts
);
return
n
;
}
// SDelIdxItem ======================================================
static
FORCE_INLINE
int32_t
tPutDelIdxItem
(
uint8_t
*
p
,
SDelIdxItem
*
pDelIdxItem
)
{
int32_t
n
=
0
;
...
...
@@ -234,6 +253,116 @@ static FORCE_INLINE int32_t tGetDelIdxItem(uint8_t *p, SDelIdxItem *pDelIdxItem)
return
n
;
}
// SBlockIdxItem ======================================================
static
FORCE_INLINE
int32_t
tPutBlockIdxItem
(
uint8_t
*
p
,
SBlockIdxItem
*
pItem
)
{
int32_t
n
=
0
;
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pItem
->
suid
);
n
+=
tPutI64
(
p
?
p
+
n
:
p
,
pItem
->
uid
);
n
+=
tPutTSDBKEY
(
p
?
p
+
n
:
p
,
&
pItem
->
minKey
);
n
+=
tPutTSDBKEY
(
p
?
p
+
n
:
p
,
&
pItem
->
maxKey
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pItem
->
minVersion
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pItem
->
maxVersion
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pItem
->
offset
);
n
+=
tPutI64v
(
p
?
p
+
n
:
p
,
pItem
->
size
);
return
n
;
}
static
FORCE_INLINE
int32_t
tGetBlockIdxItem
(
uint8_t
*
p
,
SBlockIdxItem
*
pItem
)
{
int32_t
n
=
0
;
n
+=
tGetI64
(
p
+
n
,
&
pItem
->
suid
);
n
+=
tGetI64
(
p
+
n
,
&
pItem
->
uid
);
n
+=
tGetTSDBKEY
(
p
+
n
,
&
pItem
->
minKey
);
n
+=
tGetTSDBKEY
(
p
+
n
,
&
pItem
->
maxKey
);
n
+=
tGetI64v
(
p
+
n
,
&
pItem
->
minVersion
);
n
+=
tGetI64v
(
p
+
n
,
&
pItem
->
maxVersion
);
n
+=
tGetI64v
(
p
+
n
,
&
pItem
->
offset
);
n
+=
tGetI64v
(
p
+
n
,
&
pItem
->
size
);
return
n
;
}
// SBlockIdx ======================================================
int32_t
tBlockIdxClear
(
SBlockIdx
*
pBlockIdx
)
{
int32_t
code
=
0
;
tsdbFree
(
pBlockIdx
->
offset
.
pOffset
);
tsdbFree
(
pBlockIdx
->
pData
);
return
code
;
}
int32_t
tBlockIdxPutItem
(
SBlockIdx
*
pBlockIdx
,
SBlockIdxItem
*
pItem
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
int32_t
tBlockIdxGetItemByIdx
(
SBlockIdx
*
pBlockIdx
,
SBlockIdxItem
*
pItem
,
int32_t
idx
)
{
int32_t
code
=
0
;
int32_t
offset
;
offset
=
tsdbGetOffset
(
&
pBlockIdx
->
offset
,
idx
);
if
(
offset
<
0
)
{
code
=
TSDB_CODE_NOT_FOUND
;
goto
_exit
;
}
tGetBlockIdxItem
(
pBlockIdx
->
pData
+
offset
,
pItem
);
_exit:
return
code
;
}
int32_t
tBlockIdxGetItem
(
SBlockIdx
*
pBlockIdx
,
SBlockIdxItem
*
pItem
,
TABLEID
id
)
{
int32_t
code
=
0
;
int32_t
lidx
=
0
;
int32_t
ridx
=
pBlockIdx
->
offset
.
nOffset
-
1
;
int32_t
midx
;
int32_t
c
;
while
(
lidx
<=
ridx
)
{
midx
=
(
lidx
+
midx
)
/
2
;
code
=
tBlockIdxGetItemByIdx
(
pBlockIdx
,
pItem
,
midx
);
if
(
code
)
goto
_exit
;
c
=
tTABLEIDCmprFn
(
&
id
,
pItem
);
if
(
c
==
0
)
{
goto
_exit
;
}
else
if
(
c
<
0
)
{
ridx
=
midx
-
1
;
}
else
{
lidx
=
midx
+
1
;
}
}
code
=
TSDB_CODE_NOT_FOUND
;
_exit:
return
code
;
}
int32_t
tPutBlockIdx
(
uint8_t
*
p
,
SBlockIdx
*
pBlockIdx
)
{
int32_t
n
=
0
;
n
+=
tPutU32
(
p
?
p
+
n
:
p
,
pBlockIdx
->
delimiter
);
n
+=
tPutOffset
(
p
?
p
+
n
:
p
,
&
pBlockIdx
->
offset
);
n
+=
tPutBinary
(
p
?
p
+
n
:
p
,
pBlockIdx
->
pData
,
pBlockIdx
->
nData
);
return
n
;
}
int32_t
tGetBlockIdx
(
uint8_t
*
p
,
SBlockIdx
*
pBlockIdx
)
{
int32_t
n
=
0
;
n
+=
tGetU32
(
p
+
n
,
&
pBlockIdx
->
delimiter
);
n
+=
tGetOffset
(
p
+
n
,
&
pBlockIdx
->
offset
);
n
+=
tGetBinary
(
p
+
n
,
&
pBlockIdx
->
pData
,
&
pBlockIdx
->
nData
);
return
n
;
}
// SDelIdx ======================================================
int32_t
tDelIdxClear
(
SDelIdx
*
pDelIdx
)
{
int32_t
code
=
0
;
...
...
@@ -279,12 +408,11 @@ _exit:
}
int32_t
tDelIdxGetItem
(
SDelIdx
*
pDelIdx
,
SDelIdxItem
*
pItem
,
TABLEID
id
)
{
int32_t
code
=
0
;
int32_t
lidx
=
0
;
int32_t
ridx
=
pDelIdx
->
offset
.
nOffset
-
1
;
int32_t
midx
;
uint64_t
offset
;
int32_t
c
;
int32_t
code
=
0
;
int32_t
lidx
=
0
;
int32_t
ridx
=
pDelIdx
->
offset
.
nOffset
-
1
;
int32_t
midx
;
int32_t
c
;
while
(
lidx
<=
ridx
)
{
midx
=
(
lidx
+
ridx
)
/
2
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录