Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dgr6878
TDengine
提交
520e97be
T
TDengine
项目概览
dgr6878
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
520e97be
编写于
5月 18, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix maxtables problem
上级
e52fd48d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
39 addition
and
38 deletion
+39
-38
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+2
-1
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+15
-16
src/tsdb/src/tsdbRWHelper.c
src/tsdb/src/tsdbRWHelper.c
+22
-21
未找到文件。
src/tsdb/inc/tsdbMain.h
浏览文件 @
520e97be
...
...
@@ -465,7 +465,7 @@ typedef struct {
SCompData
*
pCompData
;
SDataCols
*
pDataCols
[
2
];
void
*
block
Buffer
;
// Buffer to hold the whole data block
void
*
p
Buffer
;
// Buffer to hold the whole data block
void
*
compBuffer
;
// Buffer for temperary compress/decompress purpose
}
SRWHelper
;
...
...
@@ -512,6 +512,7 @@ void tsdbFitRetention(STsdbRepo *pRepo);
int
tsdbAlterCacheTotalBlocks
(
STsdbRepo
*
pRepo
,
int
totalBlocks
);
void
tsdbAdjustCacheBlocks
(
STsdbCache
*
pCache
);
int32_t
tsdbGetMetaFileName
(
char
*
rootDir
,
char
*
fname
);
int
tsdbUpdateFileHeader
(
SFile
*
pFile
,
uint32_t
version
);
#ifdef __cplusplus
}
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
520e97be
...
...
@@ -37,7 +37,6 @@ const char *tsdbFileSuffix[] = {
static
int
compFGroupKey
(
const
void
*
key
,
const
void
*
fgroup
);
static
int
compFGroup
(
const
void
*
arg1
,
const
void
*
arg2
);
static
int
tsdbWriteFileHead
(
SFile
*
pFile
);
static
int
tsdbOpenFGroup
(
STsdbFileH
*
pFileH
,
char
*
dataDir
,
int
fid
);
STsdbFileH
*
tsdbInitFileH
(
char
*
dataDir
,
STsdbCfg
*
pCfg
)
{
...
...
@@ -83,11 +82,21 @@ void tsdbCloseFileH(STsdbFileH *pFileH) {
}
static
int
tsdbInitFile
(
char
*
dataDir
,
int
fid
,
const
char
*
suffix
,
SFile
*
pFile
)
{
uint32_t
version
;
char
buf
[
512
]
=
"
\0
"
;
tsdbGetFileName
(
dataDir
,
fid
,
suffix
,
pFile
->
fname
);
if
(
access
(
pFile
->
fname
,
F_OK
|
R_OK
|
W_OK
)
<
0
)
return
-
1
;
pFile
->
fd
=
-
1
;
// TODO: recover the file info
// pFile->info = {0};
if
(
tsdbOpenFile
(
pFile
,
O_RDONLY
)
<
0
)
return
-
1
;
if
(
tread
(
pFile
->
fd
,
buf
,
TSDB_FILE_HEAD_SIZE
)
<
TSDB_FILE_HEAD_SIZE
)
return
-
1
;
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
buf
,
TSDB_FILE_HEAD_SIZE
))
return
-
1
;
void
*
pBuf
=
buf
;
pBuf
=
taosDecodeFixed32
(
pBuf
,
&
version
);
pBuf
=
tsdbDecodeSFileInfo
(
pBuf
,
&
(
pFile
->
info
));
return
0
;
}
...
...
@@ -284,18 +293,6 @@ static int compFGroup(const void *arg1, const void *arg2) {
return
((
SFileGroup
*
)
arg1
)
->
fileId
-
((
SFileGroup
*
)
arg2
)
->
fileId
;
}
static
int
tsdbWriteFileHead
(
SFile
*
pFile
)
{
char
head
[
TSDB_FILE_HEAD_SIZE
]
=
"
\0
"
;
pFile
->
info
.
size
+=
TSDB_FILE_HEAD_SIZE
;
// TODO: write version and File statistic to the head
lseek
(
pFile
->
fd
,
0
,
SEEK_SET
);
if
(
write
(
pFile
->
fd
,
head
,
TSDB_FILE_HEAD_SIZE
)
<
0
)
return
-
1
;
return
0
;
}
int
tsdbGetFileName
(
char
*
dataDir
,
int
fileId
,
const
char
*
suffix
,
char
*
fname
)
{
if
(
dataDir
==
NULL
||
fname
==
NULL
)
return
-
1
;
...
...
@@ -345,7 +342,9 @@ int tsdbCreateFile(char *dataDir, int fileId, const char *suffix, SFile *pFile)
return
-
1
;
}
if
(
tsdbWriteFileHead
(
pFile
)
<
0
)
{
pFile
->
info
.
size
=
TSDB_FILE_HEAD_SIZE
;
if
(
tsdbUpdateFileHeader
(
pFile
,
0
)
<
0
)
{
tsdbCloseFile
(
pFile
);
return
-
1
;
}
...
...
src/tsdb/src/tsdbRWHelper.c
浏览文件 @
520e97be
...
...
@@ -132,10 +132,10 @@ static int tsdbInitHelper(SRWHelper *pHelper, STsdbRepo *pRepo, tsdb_rw_helper_t
// Init block part
if
(
tsdbInitHelperBlock
(
pHelper
)
<
0
)
goto
_err
;
pHelper
->
block
Buffer
=
pHelper
->
p
Buffer
=
tmalloc
(
sizeof
(
SCompData
)
+
(
sizeof
(
SCompCol
)
+
sizeof
(
TSCKSUM
)
+
COMP_OVERFLOW_BYTES
)
*
pHelper
->
config
.
maxCols
+
pHelper
->
config
.
maxRowSize
*
pHelper
->
config
.
maxRowsPerFileBlock
+
sizeof
(
TSCKSUM
));
if
(
pHelper
->
block
Buffer
==
NULL
)
goto
_err
;
if
(
pHelper
->
p
Buffer
==
NULL
)
goto
_err
;
return
0
;
...
...
@@ -155,7 +155,7 @@ int tsdbInitWriteHelper(SRWHelper *pHelper, STsdbRepo *pRepo) {
void
tsdbDestroyHelper
(
SRWHelper
*
pHelper
)
{
if
(
pHelper
)
{
tzfree
(
pHelper
->
block
Buffer
);
tzfree
(
pHelper
->
p
Buffer
);
tzfree
(
pHelper
->
compBuffer
);
tsdbDestroyHelperFile
(
pHelper
);
tsdbDestroyHelperTable
(
pHelper
);
...
...
@@ -241,6 +241,7 @@ int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
pHelper
->
files
.
headF
.
fd
=
-
1
;
}
if
(
pHelper
->
files
.
dataF
.
fd
>
0
)
{
if
(
!
hasError
)
tsdbUpdateFileHeader
(
&
(
pHelper
->
files
.
dataF
),
0
);
close
(
pHelper
->
files
.
dataF
.
fd
);
pHelper
->
files
.
dataF
.
fd
=
-
1
;
}
...
...
@@ -249,6 +250,7 @@ int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
pHelper
->
files
.
lastF
.
fd
=
-
1
;
}
if
(
pHelper
->
files
.
nHeadF
.
fd
>
0
)
{
if
(
!
hasError
)
tsdbUpdateFileHeader
(
&
(
pHelper
->
files
.
nHeadF
),
0
);
close
(
pHelper
->
files
.
nHeadF
.
fd
);
pHelper
->
files
.
nHeadF
.
fd
=
-
1
;
if
(
hasError
)
{
...
...
@@ -260,6 +262,7 @@ int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
}
if
(
pHelper
->
files
.
nLastF
.
fd
>
0
)
{
if
(
!
hasError
)
tsdbUpdateFileHeader
(
&
(
pHelper
->
files
.
nLastF
),
0
);
close
(
pHelper
->
files
.
nLastF
.
fd
);
pHelper
->
files
.
nLastF
.
fd
=
-
1
;
if
(
hasError
)
{
...
...
@@ -419,7 +422,7 @@ int tsdbWriteCompInfo(SRWHelper *pHelper) {
pIdx
->
offset
=
lseek
(
pHelper
->
files
.
nHeadF
.
fd
,
0
,
SEEK_END
);
pIdx
->
uid
=
pHelper
->
tableInfo
.
uid
;
if
(
pIdx
->
offset
<
0
)
return
-
1
;
ASSERT
(
pIdx
->
offset
>=
tsizeof
(
pHelper
->
pCompIdx
)
);
ASSERT
(
pIdx
->
offset
>=
TSDB_FILE_HEAD_SIZE
);
if
(
twrite
(
pHelper
->
files
.
nHeadF
.
fd
,
(
void
*
)(
pHelper
->
pCompInfo
),
pIdx
->
len
)
<
pIdx
->
len
)
return
-
1
;
}
...
...
@@ -435,7 +438,8 @@ int tsdbWriteCompIdx(SRWHelper *pHelper) {
SFile
*
pFile
=
&
(
pHelper
->
files
.
nHeadF
);
pFile
->
info
.
offset
=
offset
;
void
*
buf
=
pHelper
->
blockBuffer
;
// TODO: change the implementation of pHelper->pBuffer
void
*
buf
=
pHelper
->
pBuffer
;
for
(
uint32_t
i
=
0
;
i
<
pHelper
->
config
.
maxTables
;
i
++
)
{
SCompIdx
*
pCompIdx
=
pHelper
->
pCompIdx
+
i
;
if
(
pCompIdx
->
offset
>
0
)
{
...
...
@@ -444,10 +448,10 @@ int tsdbWriteCompIdx(SRWHelper *pHelper) {
}
}
int
tsize
=
(
char
*
)
buf
-
(
char
*
)
pHelper
->
block
Buffer
+
sizeof
(
TSCKSUM
);
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
pHelper
->
block
Buffer
,
tsize
);
int
tsize
=
(
char
*
)
buf
-
(
char
*
)
pHelper
->
p
Buffer
+
sizeof
(
TSCKSUM
);
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
pHelper
->
p
Buffer
,
tsize
);
if
(
twrite
(
pHelper
->
files
.
nHeadF
.
fd
,
(
void
*
)
pHelper
->
block
Buffer
,
tsize
)
<
tsize
)
return
-
1
;
if
(
twrite
(
pHelper
->
files
.
nHeadF
.
fd
,
(
void
*
)
pHelper
->
p
Buffer
,
tsize
)
<
tsize
)
return
-
1
;
pFile
->
info
.
len
=
tsize
;
return
0
;
}
...
...
@@ -465,23 +469,23 @@ int tsdbLoadCompIdx(SRWHelper *pHelper, void *target) {
ASSERT
(
pFile
->
info
.
offset
>
TSDB_FILE_HEAD_SIZE
);
if
(
lseek
(
fd
,
pFile
->
info
.
offset
,
SEEK_SET
)
<
0
)
return
-
1
;
if
(
tread
(
fd
,
(
void
*
)(
pHelper
->
block
Buffer
),
pFile
->
info
.
len
)
<
pFile
->
info
.
len
)
if
(
tread
(
fd
,
(
void
*
)(
pHelper
->
p
Buffer
),
pFile
->
info
.
len
)
<
pFile
->
info
.
len
)
return
-
1
;
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)(
pHelper
->
block
Buffer
),
pFile
->
info
.
len
))
{
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)(
pHelper
->
p
Buffer
),
pFile
->
info
.
len
))
{
// TODO: File is broken, try to deal with it
return
-
1
;
}
// Decode it
void
*
ptr
=
pHelper
->
block
Buffer
;
while
((
char
*
)
ptr
-
(
char
*
)
pHelper
->
block
Buffer
>=
pFile
->
info
.
len
-
sizeof
(
TSCKSUM
))
{
void
*
ptr
=
pHelper
->
p
Buffer
;
while
((
char
*
)
ptr
-
(
char
*
)
pHelper
->
p
Buffer
>=
pFile
->
info
.
len
-
sizeof
(
TSCKSUM
))
{
uint32_t
tid
=
0
;
if
((
ptr
=
taosDecodeVariant32
(
ptr
,
&
tid
))
==
NULL
)
return
-
1
;
ASSERT
(
tid
>
0
&&
tid
<
pHelper
->
config
.
maxTables
);
if
((
ptr
=
tsdbDecodeSCompIdx
(
ptr
,
pHelper
->
pCompIdx
+
tid
))
==
NULL
)
return
-
1
;
ASSERT
((
char
*
)
ptr
-
(
char
*
)
pHelper
->
block
Buffer
<=
pFile
->
info
.
len
-
sizeof
(
TSCKSUM
));
ASSERT
((
char
*
)
ptr
-
(
char
*
)
pHelper
->
p
Buffer
<=
pFile
->
info
.
len
-
sizeof
(
TSCKSUM
));
}
}
...
...
@@ -626,9 +630,9 @@ static int tsdbCheckAndDecodeColumnData(SDataCol *pDataCol, char *content, int32
static
int
tsdbLoadBlockDataImpl
(
SRWHelper
*
pHelper
,
SCompBlock
*
pCompBlock
,
SDataCols
*
pDataCols
)
{
ASSERT
(
pCompBlock
->
numOfSubBlocks
<=
1
);
ASSERT
(
tsizeof
(
pHelper
->
block
Buffer
)
>=
pCompBlock
->
len
);
ASSERT
(
tsizeof
(
pHelper
->
p
Buffer
)
>=
pCompBlock
->
len
);
SCompData
*
pCompData
=
(
SCompData
*
)
pHelper
->
block
Buffer
;
SCompData
*
pCompData
=
(
SCompData
*
)
pHelper
->
p
Buffer
;
int
fd
=
(
pCompBlock
->
last
)
?
pHelper
->
files
.
lastF
.
fd
:
pHelper
->
files
.
dataF
.
fd
;
if
(
lseek
(
fd
,
pCompBlock
->
offset
,
SEEK_SET
)
<
0
)
goto
_err
;
...
...
@@ -721,7 +725,7 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
ASSERT
(
rowsToWrite
>
0
&&
rowsToWrite
<=
pDataCols
->
numOfPoints
&&
rowsToWrite
<=
pHelper
->
config
.
maxRowsPerFileBlock
);
SCompData
*
pCompData
=
(
SCompData
*
)(
pHelper
->
block
Buffer
);
SCompData
*
pCompData
=
(
SCompData
*
)(
pHelper
->
p
Buffer
);
int64_t
offset
=
0
;
offset
=
lseek
(
pFile
->
fd
,
0
,
SEEK_END
);
...
...
@@ -776,7 +780,7 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
}
pCompCol
->
len
=
(
*
(
tDataTypeDesc
[
pDataCol
->
type
].
compFunc
))(
(
char
*
)
pDataCol
->
pData
,
tlen
,
rowsToWrite
,
tptr
,
tsizeof
(
pHelper
->
block
Buffer
)
-
lsize
,
(
char
*
)
pDataCol
->
pData
,
tlen
,
rowsToWrite
,
tptr
,
tsizeof
(
pHelper
->
p
Buffer
)
-
lsize
,
pHelper
->
config
.
compress
,
pHelper
->
compBuffer
,
tsizeof
(
pHelper
->
compBuffer
));
}
else
{
pCompCol
->
len
=
tlen
;
...
...
@@ -1242,11 +1246,8 @@ int tsdbUpdateFileHeader(SFile *pFile, uint32_t version) {
void
*
pBuf
=
(
void
*
)
buf
;
pBuf
=
taosEncodeFixed32
(
pBuf
,
version
);
pBuf
=
tsdbEncodeSFileInfo
(
pBuf
,
&
(
pFile
->
info
));
int
tsize
=
(
char
*
)
pBuf
-
buf
+
sizeof
(
TSCKSUM
);
ASSERT
(
tsize
<=
TSDB_FILE_HEAD_SIZE
);
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
buf
,
tsize
);
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
buf
,
TSDB_FILE_HEAD_SIZE
);
if
(
lseek
(
pFile
->
fd
,
0
,
SEEK_SET
)
<
0
)
return
-
1
;
if
(
twrite
(
pFile
->
fd
,
(
void
*
)
buf
,
TSDB_FILE_HEAD_SIZE
)
<
TSDB_FILE_HEAD_SIZE
)
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录