Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a8b91991
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a8b91991
编写于
9月 21, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
0929326c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
116 addition
and
19 deletion
+116
-19
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+23
-0
source/dnode/vnode/src/tsdb/tsdbDiskData.c
source/dnode/vnode/src/tsdb/tsdbDiskData.c
+6
-19
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+87
-0
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
a8b91991
...
...
@@ -32,6 +32,12 @@ extern "C" {
#define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSD ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
// clang-format on
#define TSDB_CHECK_CODE(CODE, LINO, LABEL) \
if (CODE) { \
LINO = __LINE__; \
goto LABEL; \
}
typedef
struct
TSDBROW
TSDBROW
;
typedef
struct
TABLEID
TABLEID
;
typedef
struct
TSDBKEY
TSDBKEY
;
...
...
@@ -65,6 +71,8 @@ typedef struct SSmaInfo SSmaInfo;
typedef
struct
SBlockCol
SBlockCol
;
typedef
struct
SVersionRange
SVersionRange
;
typedef
struct
SLDataIter
SLDataIter
;
typedef
struct
SDiskCol
SDiskCol
;
typedef
struct
SDiskData
SDiskData
;
#define TSDB_FILE_DLMT ((uint32_t)0xF00AFA0F)
#define TSDB_MAX_SUBBLOCKS 8
...
...
@@ -652,6 +660,21 @@ typedef struct {
STSchema
*
pTSchema
;
}
SSkmInfo
;
struct
SDiskCol
{
SBlockCol
bCol
;
const
uint8_t
*
pBit
;
const
uint8_t
*
pOff
;
const
uint8_t
*
pVal
;
};
struct
SDiskData
{
SDiskDataHdr
hdr
;
const
uint8_t
*
pUid
;
const
uint8_t
*
pVer
;
const
uint8_t
*
pKey
;
SArray
*
aDiskCol
;
// SArray<SDiskCol>
};
int32_t
tMergeTreeOpen
(
SMergeTree
*
pMTree
,
int8_t
backward
,
SDataFReader
*
pFReader
,
uint64_t
suid
,
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pVerRange
,
void
*
pLoadInfo
,
const
char
*
idStr
);
void
tMergeTreeAddIter
(
SMergeTree
*
pMTree
,
SLDataIter
*
pIter
);
...
...
source/dnode/vnode/src/tsdb/tsdbDiskData.c
浏览文件 @
a8b91991
...
...
@@ -17,8 +17,6 @@
typedef
struct
SDiskDataBuilder
SDiskDataBuilder
;
typedef
struct
SDiskColBuilder
SDiskColBuilder
;
typedef
struct
SDiskCol
SDiskCol
;
typedef
struct
SDiskData
SDiskData
;
struct
SDiskColBuilder
{
int16_t
cid
;
...
...
@@ -45,21 +43,6 @@ struct SDiskDataBuilder {
uint8_t
*
aBuf
[
2
];
};
struct
SDiskCol
{
SBlockCol
bCol
;
const
uint8_t
*
pBit
;
const
uint8_t
*
pOff
;
const
uint8_t
*
pVal
;
};
struct
SDiskData
{
SDiskDataHdr
hdr
;
const
uint8_t
*
pUid
;
const
uint8_t
*
pVer
;
const
uint8_t
*
pKey
;
SArray
*
aDiskCol
;
// SArray<SDiskCol>
};
// SDiskColBuilder ================================================
static
int32_t
tDiskColInit
(
SDiskColBuilder
*
pBuilder
,
int16_t
cid
,
int8_t
type
,
uint8_t
cmprAlg
)
{
int32_t
code
=
0
;
...
...
@@ -147,9 +130,13 @@ static int32_t tDiskColAddValue(SDiskColBuilder *pBuilder, SColVal *pColVal) {
code
=
tCompress
(
pBuilder
->
pOffC
,
&
pBuilder
->
offset
,
sizeof
(
int32_t
));
if
(
code
)
goto
_exit
;
pBuilder
->
offset
+=
pColVal
->
value
.
nData
;
code
=
tCompress
(
pBuilder
->
pValC
,
pColVal
->
value
.
pData
,
pColVal
->
value
.
nData
);
if
(
code
)
goto
_exit
;
}
else
{
code
=
tCompress
(
pBuilder
->
pValC
,
&
pColVal
->
value
.
val
,
tDataTypes
[
pColVal
->
type
].
bytes
);
if
(
code
)
goto
_exit
;
}
code
=
tCompress
(
pBuilder
->
pValC
,
pColVal
->
value
.
pData
,
pColVal
->
value
.
nData
/*TODO*/
);
if
(
code
)
goto
_exit
;
_exit:
return
code
;
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
a8b91991
...
...
@@ -607,6 +607,93 @@ _err:
return
code
;
}
int32_t
tsdbWriteDiskData
(
SDataFWriter
*
pWriter
,
SDiskData
*
pDiskData
,
SBlockInfo
*
pBlkInfo
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
STsdbFD
*
pFD
=
pWriter
->
pDataFD
;
// todo
int64_t
offset
=
pWriter
->
fData
.
size
;
// hdr
int32_t
n
=
tPutDiskDataHdr
(
NULL
,
&
pDiskData
->
hdr
);
code
=
tRealloc
(
&
pWriter
->
aBuf
[
0
],
n
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
tPutDiskDataHdr
(
pWriter
->
aBuf
[
0
],
&
pDiskData
->
hdr
);
code
=
tsdbWriteFile
(
pFD
,
offset
,
pWriter
->
aBuf
[
0
],
n
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
offset
+=
n
;
// uid + ver + key
if
(
pDiskData
->
hdr
.
szUid
)
{
code
=
tsdbWriteFile
(
pFD
,
offset
,
pDiskData
->
pUid
,
pDiskData
->
hdr
.
szUid
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
offset
+=
pDiskData
->
hdr
.
szUid
;
}
code
=
tsdbWriteFile
(
pFD
,
offset
,
pDiskData
->
pVer
,
pDiskData
->
hdr
.
szVer
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
offset
+=
pDiskData
->
hdr
.
szVer
;
code
=
tsdbWriteFile
(
pFD
,
offset
,
pDiskData
->
pKey
,
pDiskData
->
hdr
.
szKey
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
offset
+=
pDiskData
->
hdr
.
szKey
;
// SBlockCol
if
(
pDiskData
->
hdr
.
szBlkCol
)
{
code
=
tRealloc
(
&
pWriter
->
aBuf
[
0
],
pDiskData
->
hdr
.
szBlkCol
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
n
=
0
;
for
(
int32_t
iDiskCol
=
0
;
iDiskCol
<
taosArrayGetSize
(
pDiskData
->
aDiskCol
);
iDiskCol
++
)
{
SDiskCol
*
pDiskCol
=
(
SDiskCol
*
)
taosArrayGet
(
pDiskData
->
aDiskCol
,
iDiskCol
);
n
+=
tPutBlockCol
(
pWriter
->
aBuf
[
0
]
+
n
,
&
pDiskCol
->
bCol
);
}
ASSERT
(
n
==
pDiskData
->
hdr
.
szBlkCol
);
code
=
tsdbWriteFile
(
pFD
,
offset
,
pWriter
->
aBuf
[
0
],
pDiskData
->
hdr
.
szBlkCol
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
offset
+=
pDiskData
->
hdr
.
szBlkCol
;
}
// pData
for
(
int32_t
iDiskCol
=
0
;
iDiskCol
<
taosArrayGetSize
(
pDiskData
->
aDiskCol
);
iDiskCol
++
)
{
SDiskCol
*
pDiskCol
=
(
SDiskCol
*
)
taosArrayGet
(
pDiskData
->
aDiskCol
,
iDiskCol
);
if
(
pDiskCol
->
bCol
.
flag
==
HAS_NULL
)
continue
;
if
(
pDiskCol
->
bCol
.
szBitmap
)
{
code
=
tsdbWriteFile
(
pFD
,
offset
,
pDiskCol
->
pBit
,
pDiskCol
->
bCol
.
szBitmap
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
offset
+=
pDiskCol
->
bCol
.
szBitmap
;
}
if
(
pDiskCol
->
bCol
.
szOffset
)
{
code
=
tsdbWriteFile
(
pFD
,
offset
,
pDiskCol
->
pOff
,
pDiskCol
->
bCol
.
szOffset
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
offset
+=
pDiskCol
->
bCol
.
szOffset
;
}
if
(
pDiskCol
->
bCol
.
szValue
)
{
code
=
tsdbWriteFile
(
pFD
,
offset
,
pDiskCol
->
pVal
,
pDiskCol
->
bCol
.
szValue
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
offset
+=
pDiskCol
->
bCol
.
szValue
;
}
}
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at %d since %s"
,
TD_VID
(
pWriter
->
pTsdb
->
pVnode
),
__func__
,
lino
,
tstrerror
(
code
));
}
else
{
tsdbDebug
(
"vgId:%d %s"
,
TD_VID
(
pWriter
->
pTsdb
->
pVnode
),
__func__
);
}
return
code
;
}
int32_t
tsdbDFileSetCopy
(
STsdb
*
pTsdb
,
SDFileSet
*
pSetFrom
,
SDFileSet
*
pSetTo
)
{
int32_t
code
=
0
;
int64_t
n
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录