Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bcc01d63
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看板
提交
bcc01d63
编写于
6月 10, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more work
上级
39626c1b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
118 addition
and
35 deletion
+118
-35
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+24
-16
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+17
-0
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+0
-8
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+34
-1
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+43
-10
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
bcc01d63
...
...
@@ -219,6 +219,15 @@ int32_t tsdbLoadSBlockStatis(SDFileSetReader *pReader, SBlock *pBlock, SBlockSta
// SDelFReader
// tsdbUtil.c ==============================================================================================
int32_t
tsdbRealloc
(
uint8_t
**
ppBuf
,
int64_t
size
);
void
tsdbFree
(
uint8_t
*
pBuf
);
// STMap
typedef
struct
STMap
STMap
;
int32_t
tPutTMap
(
uint8_t
*
p
,
STMap
*
pMap
);
int32_t
tGetTMap
(
uint8_t
*
p
,
STMap
*
pMap
);
int32_t
tTABLEIDCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
int32_t
tsdbKeyCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
...
...
@@ -244,8 +253,6 @@ struct STsdb {
STsdbFS
*
fs
;
};
#if 1 // ======================================
struct
STable
{
uint64_t
suid
;
uint64_t
uid
;
...
...
@@ -771,29 +778,23 @@ typedef struct {
}
SDelDataItem
;
struct
SDelData
{
uint32_t
delimiter
;
tb_uid_t
suid
;
tb_uid_t
uid
;
int8_t
flags
;
int64_t
nItem
;
uint8_t
*
pOffset
;
uint32_t
nData
;
uint8_t
*
pData
;
int64_t
version
;
TSKEY
sKey
;
TSKEY
eKey
;
};
typedef
struct
{
struct
SDelIdx
{
tb_uid_t
suid
;
tb_uid_t
uid
;
TSKEY
minKey
;
TSKEY
maxKey
;
int64_t
maxVersion
;
int64_t
minVersion
;
int64_t
maxVersion
;
int64_t
offset
;
int64_t
size
;
}
SDelIdxItem
;
};
struct
SDelIdx
{
uint32_t
delimiter
;
struct
STMap
{
uint8_t
flags
;
uint32_t
nOffset
;
uint8_t
*
pOffset
;
...
...
@@ -801,7 +802,14 @@ struct SDelIdx {
uint8_t
*
pData
;
};
#endif
struct
SDelFile
{
TSKEY
minKey
;
TSKEY
maxKey
;
int64_t
minVersion
;
int64_t
maxVersion
;
int64_t
size
;
int64_t
offset
;
};
#ifdef __cplusplus
}
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
bcc01d63
...
...
@@ -42,6 +42,8 @@ struct SCommitter {
SDelFWriter
*
pDelFWriter
;
SDelIdx
oDelIdx
;
SDelIdx
nDelIdx
;
SDelData
oDelData
;
SDelData
nDelData
;
/* commit cache */
};
...
...
@@ -248,6 +250,21 @@ static int32_t tsdbCommitDelImpl(SCommitter *pCommitter) {
static
int32_t
tsdbCommitDelEnd
(
SCommitter
*
pCommitter
)
{
int32_t
code
=
0
;
code
=
tsdbWriteDelIdx
(
pCommitter
->
pDelFWriter
,
&
pCommitter
->
nDelIdx
,
&
pCommitter
->
pBuf3
);
if
(
code
)
{
goto
_err
;
}
code
=
tsdbDelFWriterClose
(
pCommitter
->
pDelFWriter
);
if
(
code
)
{
goto
_err
;
}
if
(
pCommitter
->
pDelFReader
)
{
code
=
tsdbDelFReaderClose
(
pCommitter
->
pDelFReader
);
if
(
code
)
goto
_err
;
}
return
code
;
_err:
...
...
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
bcc01d63
...
...
@@ -18,14 +18,6 @@
static
const
char
*
tsdbFileSuffix
[]
=
{
".tombstone"
,
".cache"
,
".index"
,
".data"
,
".last"
,
".sma"
,
""
};
// .tombstone
struct
SDelFile
{
TSKEY
minKey
;
TSKEY
maxKey
;
int64_t
minVersion
;
int64_t
maxVersion
;
int64_t
size
;
int64_t
offset
;
};
struct
STsdbIndexFile
{
int64_t
size
;
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
bcc01d63
...
...
@@ -105,6 +105,7 @@ int32_t tsdbWriteDelIdx(SDelFWriter *pWriter, SDelIdx *pDelIdx, uint8_t **ppBuf)
// SDelFReader ====================================================
struct
SDelFReader
{
STsdb
*
pTsdb
;
SDelFile
*
pFile
;
TdFilePtr
pReadH
;
};
...
...
@@ -129,6 +130,38 @@ int32_t tsdbReadDelData(SDelFReader *pReader, SDelData *pDelData, uint8_t **ppBu
int32_t
tsdbReadDelIdx
(
SDelFReader
*
pReader
,
SDelIdx
*
pDelIdx
,
uint8_t
**
ppBuf
)
{
int32_t
code
=
0
;
// TODO
int64_t
offset
=
pReader
->
pFile
->
offset
;
int64_t
size
=
pReader
->
pFile
->
size
-
offset
;
// seek
if
(
taosLSeekFile
(
pReader
->
pReadH
,
pReader
->
pFile
->
offset
,
SEEK_SET
)
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
// read
if
(
taosReadFile
(
pReader
->
pReadH
,
*
ppBuf
,
size
)
<
size
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
// realloc buf
code
=
tsdbRealloc
(
ppBuf
,
size
);
if
(
code
)
{
goto
_err
;
}
// check
if
(
!
taosCheckChecksumWhole
(
*
ppBuf
,
size
))
{
code
=
TSDB_CODE_FILE_CORRUPTED
;
goto
_err
;
}
// decode
return
code
;
_err:
tsdbError
(
"vgId:%d failed to read del idx since %s"
,
TD_VID
(
pReader
->
pTsdb
->
pVnode
),
tstrerror
(
code
));
return
code
;
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
bcc01d63
...
...
@@ -15,6 +15,41 @@
#include "tsdb.h"
int32_t
tsdbRealloc
(
uint8_t
**
ppBuf
,
int64_t
size
)
{
int32_t
code
=
0
;
int64_t
bsize
=
0
;
uint8_t
*
pBuf
;
if
(
*
ppBuf
)
{
bsize
=
*
(
int64_t
*
)((
*
ppBuf
)
-
sizeof
(
int64_t
));
}
if
(
bsize
>=
size
)
goto
_exit
;
if
(
bsize
==
0
)
bsize
=
128
;
while
(
bsize
<
size
)
{
bsize
*=
2
;
}
pBuf
=
taosMemoryRealloc
(
*
ppBuf
?
(
*
ppBuf
)
-
sizeof
(
int64_t
)
:
*
ppBuf
,
bsize
+
sizeof
(
int64_t
));
if
(
pBuf
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
*
(
int64_t
*
)
pBuf
=
bsize
;
*
ppBuf
=
pBuf
+
sizeof
(
int64_t
);
_exit:
return
code
;
}
void
tsdbFree
(
uint8_t
*
pBuf
)
{
if
(
pBuf
)
{
taosMemoryFree
(
pBuf
-
sizeof
(
int64_t
));
}
}
int32_t
tTABLEIDCmprFn
(
const
void
*
p1
,
const
void
*
p2
)
{
TABLEID
*
pId1
=
(
TABLEID
*
)
p1
;
TABLEID
*
pId2
=
(
TABLEID
*
)
p2
;
...
...
@@ -53,24 +88,22 @@ int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
return
0
;
}
int32_t
tPut
SDelIdx
(
uint8_t
*
p
,
SDelIdx
*
pDelIdx
)
{
int32_t
tPut
TMap
(
uint8_t
*
p
,
STMap
*
pMap
)
{
int32_t
n
=
0
;
n
+=
tPutU32
(
p
?
p
+
n
:
p
,
pDelIdx
->
delimiter
);
n
+=
tPutU8
(
p
?
p
+
n
:
p
,
pDelIdx
->
flags
);
n
+=
tPutBinary
(
p
?
p
+
n
:
p
,
pDelIdx
->
pOffset
,
pDelIdx
->
nOffset
);
n
+=
tPutBinary
(
p
?
p
+
n
:
p
,
pDelIdx
->
pData
,
pDelIdx
->
nData
);
n
+=
tPutU8
(
p
?
p
+
n
:
p
,
pMap
->
flags
);
n
+=
tPutBinary
(
p
?
p
+
n
:
p
,
pMap
->
pOffset
,
pMap
->
nOffset
);
n
+=
tPutBinary
(
p
?
p
+
n
:
p
,
pMap
->
pData
,
pMap
->
nData
);
return
n
;
}
int32_t
tGet
SDelIdx
(
uint8_t
*
p
,
SDelIdx
*
pDelIdx
)
{
int32_t
tGet
TMap
(
uint8_t
*
p
,
STMap
*
pMap
)
{
int32_t
n
=
0
;
n
+=
tGetU32
(
p
+
n
,
&
pDelIdx
->
delimiter
);
n
+=
tGetU8
(
p
+
n
,
&
pDelIdx
->
flags
);
n
+=
tGetBinary
(
p
+
n
,
&
pDelIdx
->
pOffset
,
&
pDelIdx
->
nOffset
);
n
+=
tGetBinary
(
p
+
n
,
&
pDelIdx
->
pData
,
&
pDelIdx
->
nData
);
n
+=
tGetU8
(
p
,
&
pMap
->
flags
);
n
+=
tGetBinary
(
p
,
&
pMap
->
pOffset
,
&
pMap
->
nOffset
);
n
+=
tGetBinary
(
p
,
&
pMap
->
pData
,
&
pMap
->
nData
);
return
n
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录