Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aae9b3c1
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看板
提交
aae9b3c1
编写于
7月 17, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add a idx file for query speed
上级
58d06bdb
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
178 addition
and
154 deletion
+178
-154
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+20
-14
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+9
-9
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+6
-6
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+4
-3
src/tsdb/src/tsdbRWHelper.c
src/tsdb/src/tsdbRWHelper.c
+139
-122
未找到文件。
src/tsdb/inc/tsdbMain.h
浏览文件 @
aae9b3c1
...
...
@@ -132,21 +132,23 @@ typedef struct {
// ------------------ tsdbFile.c
extern
const
char
*
tsdbFileSuffix
[];
typedef
enum
{
TSDB_FILE_TYPE_HEAD
=
0
,
TSDB_FILE_TYPE_IDX
=
0
,
TSDB_FILE_TYPE_HEAD
,
TSDB_FILE_TYPE_DATA
,
TSDB_FILE_TYPE_LAST
,
TSDB_FILE_TYPE_MAX
,
TSDB_FILE_TYPE_NIDX
,
TSDB_FILE_TYPE_NHEAD
,
TSDB_FILE_TYPE_NLAST
}
TSDB_FILE_TYPE
;
typedef
struct
{
uint32_t
offset
;
uint32_t
magic
;
uint32_t
len
;
uint64_t
size
;
// total size of the file
uint64_t
tombSize
;
// unused file size
uint32_t
totalBlocks
;
uint32_t
totalSubBlocks
;
uint64_t
size
;
// total size of the file
uint64_t
tombSize
;
// unused file size
}
STsdbFileInfo
;
typedef
struct
{
...
...
@@ -249,16 +251,12 @@ typedef struct {
typedef
enum
{
TSDB_WRITE_HELPER
,
TSDB_READ_HELPER
}
tsdb_rw_helper_t
;
typedef
struct
{
int
fid
;
TSKEY
minKey
;
TSKEY
maxKey
;
// For read/write purpose
SFile
headF
;
SFile
dataF
;
SFile
lastF
;
// For write purpose only
SFile
nHeadF
;
SFile
nLastF
;
TSKEY
minKey
;
TSKEY
maxKey
;
SFileGroup
fGroup
;
SFile
nIdxF
;
SFile
nHeadF
;
SFile
nLastF
;
}
SHelperFile
;
typedef
struct
{
...
...
@@ -444,6 +442,14 @@ void tsdbRemoveFileGroup(STsdbRepo* pRepo, SFileGroup* pFGroup);
#define helperRepo(h) (h)->pRepo
#define helperState(h) (h)->state
#define TSDB_NLAST_FILE_OPENED(h) ((h)->files.nLastF.fd > 0)
#define helperFileId(h) ((h)->files.fGroup.fileId)
#define helperIdxF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_IDX]))
#define helperHeadF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_HEAD]))
#define helperDataF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_DATA]))
#define helperLastF(h) (&((h)->files.fGroup.files[TSDB_FILE_TYPE_LAST]))
#define helperNewIdxF(h) (&((h)->files.nIdxF))
#define helperNewHeadF(h) (&((h)->files.nHeadF))
#define helperNewLastF(h) (&((h)->files.nLastF))
int
tsdbInitReadHelper
(
SRWHelper
*
pHelper
,
STsdbRepo
*
pRepo
);
int
tsdbInitWriteHelper
(
SRWHelper
*
pHelper
,
STsdbRepo
*
pRepo
);
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
aae9b3c1
...
...
@@ -30,7 +30,7 @@
#include "ttime.h"
#include "tfile.h"
const
char
*
tsdbFileSuffix
[]
=
{
".
head"
,
".data"
,
".last"
,
"
"
,
".h"
,
".l"
};
const
char
*
tsdbFileSuffix
[]
=
{
".
idx"
,
".head"
,
".data"
,
".last"
,
""
,
".i
"
,
".h"
,
".l"
};
static
int
tsdbInitFile
(
SFile
*
pFile
,
STsdbRepo
*
pRepo
,
int
fid
,
int
type
);
static
void
tsdbDestroyFile
(
SFile
*
pFile
);
...
...
@@ -108,7 +108,7 @@ int tsdbOpenFileH(STsdbRepo *pRepo) {
memset
((
void
*
)(
&
fileGroup
),
0
,
sizeof
(
SFileGroup
));
fileGroup
.
fileId
=
fid
;
for
(
int
type
=
TSDB_FILE_TYPE_
HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
for
(
int
type
=
TSDB_FILE_TYPE_
IDX
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
if
(
tsdbInitFile
(
&
fileGroup
.
files
[
type
],
pRepo
,
fid
,
type
)
<
0
)
{
tsdbError
(
"vgId:%d failed to init file fid %d type %d"
,
REPO_ID
(
pRepo
),
fid
,
type
);
goto
_err
;
...
...
@@ -126,7 +126,7 @@ int tsdbOpenFileH(STsdbRepo *pRepo) {
return
0
;
_err:
for
(
int
type
=
TSDB_FILE_TYPE_
HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
tsdbDestroyFile
(
&
fileGroup
.
files
[
type
]);
for
(
int
type
=
TSDB_FILE_TYPE_
IDX
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
tsdbDestroyFile
(
&
fileGroup
.
files
[
type
]);
tfree
(
tDataDir
);
if
(
dir
!=
NULL
)
closedir
(
dir
);
...
...
@@ -139,7 +139,7 @@ void tsdbCloseFileH(STsdbRepo *pRepo) {
for
(
int
i
=
0
;
i
<
pFileH
->
nFGroups
;
i
++
)
{
SFileGroup
*
pFGroup
=
pFileH
->
pFGroup
+
i
;
for
(
int
type
=
TSDB_FILE_TYPE_
HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
for
(
int
type
=
TSDB_FILE_TYPE_
IDX
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
tsdbDestroyFile
(
&
pFGroup
->
files
[
type
]);
}
}
...
...
@@ -156,7 +156,7 @@ SFileGroup *tsdbCreateFGroupIfNeed(STsdbRepo *pRepo, char *dataDir, int fid, int
SFileGroup
*
pGroup
=
tsdbSearchFGroup
(
pFileH
,
fid
,
TD_EQ
);
if
(
pGroup
==
NULL
)
{
// if not exists, create one
pFGroup
->
fileId
=
fid
;
for
(
int
type
=
TSDB_FILE_TYPE_
HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
for
(
int
type
=
TSDB_FILE_TYPE_
IDX
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
if
(
tsdbCreateFile
(
&
pFGroup
->
files
[
type
],
pRepo
,
fid
,
type
)
<
0
)
goto
_err
;
}
...
...
@@ -169,7 +169,7 @@ SFileGroup *tsdbCreateFGroupIfNeed(STsdbRepo *pRepo, char *dataDir, int fid, int
return
pGroup
;
_err:
for
(
int
type
=
TSDB_FILE_TYPE_
HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
tsdbDestroyFile
(
&
pGroup
->
files
[
type
]);
for
(
int
type
=
TSDB_FILE_TYPE_
IDX
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
tsdbDestroyFile
(
&
pGroup
->
files
[
type
]);
return
NULL
;
}
...
...
@@ -323,7 +323,7 @@ int tsdbUpdateFileHeader(SFile *pFile, uint32_t version) {
int
tsdbEncodeSFileInfo
(
void
**
buf
,
const
STsdbFileInfo
*
pInfo
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
offset
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
magic
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
len
);
tlen
+=
taosEncodeFixedU64
(
buf
,
pInfo
->
size
);
tlen
+=
taosEncodeFixedU64
(
buf
,
pInfo
->
tombSize
);
...
...
@@ -334,7 +334,7 @@ int tsdbEncodeSFileInfo(void **buf, const STsdbFileInfo *pInfo) {
}
void
*
tsdbDecodeSFileInfo
(
void
*
buf
,
STsdbFileInfo
*
pInfo
)
{
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
offset
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
magic
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
len
));
buf
=
taosDecodeFixedU64
(
buf
,
&
(
pInfo
->
size
));
buf
=
taosDecodeFixedU64
(
buf
,
&
(
pInfo
->
tombSize
));
...
...
@@ -358,7 +358,7 @@ void tsdbRemoveFileGroup(STsdbRepo *pRepo, SFileGroup *pFGroup) {
pFileH
->
nFGroups
--
;
ASSERT
(
pFileH
->
nFGroups
>=
0
);
for
(
int
type
=
TSDB_FILE_TYPE_
HEAD
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
for
(
int
type
=
TSDB_FILE_TYPE_
IDX
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
if
(
remove
(
fileGroup
.
files
[
type
].
fname
)
<
0
)
{
tsdbError
(
"vgId:%d failed to remove file %s"
,
REPO_ID
(
pRepo
),
fileGroup
.
files
[
type
].
fname
);
}
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
aae9b3c1
...
...
@@ -214,7 +214,7 @@ uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_
char
*
prefix
=
dirname
(
sdup
);
if
(
name
[
0
]
==
0
)
{
// get the file from index or after, but not larger than eindex
int
fid
=
(
*
index
)
/
3
;
int
fid
=
(
*
index
)
/
TSDB_FILE_TYPE_MAX
;
if
(
pFileH
->
nFGroups
==
0
||
fid
>
pFileH
->
pFGroup
[
pFileH
->
nFGroups
-
1
].
fileId
)
{
if
(
*
index
<=
TSDB_META_FILE_INDEX
&&
TSDB_META_FILE_INDEX
<=
eindex
)
{
...
...
@@ -228,11 +228,11 @@ uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_
SFileGroup
*
pFGroup
=
taosbsearch
(
&
fid
,
pFileH
->
pFGroup
,
pFileH
->
nFGroups
,
sizeof
(
SFileGroup
),
keyFGroupCompFunc
,
TD_GE
);
if
(
pFGroup
->
fileId
==
fid
)
{
fname
=
strdup
(
pFGroup
->
files
[(
*
index
)
%
3
].
fname
);
fname
=
strdup
(
pFGroup
->
files
[(
*
index
)
%
TSDB_FILE_TYPE_MAX
].
fname
);
}
else
{
if
(
pFGroup
->
fileId
*
3
+
2
<
eindex
)
{
if
(
(
pFGroup
->
fileId
+
1
)
*
TSDB_FILE_TYPE_MAX
-
1
<
eindex
)
{
fname
=
strdup
(
pFGroup
->
files
[
0
].
fname
);
*
index
=
pFGroup
->
fileId
*
3
;
*
index
=
pFGroup
->
fileId
*
TSDB_FILE_TYPE_MAX
;
}
else
{
tfree
(
sdup
);
return
0
;
...
...
@@ -244,14 +244,14 @@ uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_
if
(
*
index
==
TSDB_META_FILE_INDEX
)
{
// get meta file
fname
=
tsdbGetMetaFileName
(
pRepo
->
rootDir
);
}
else
{
int
fid
=
(
*
index
)
/
3
;
int
fid
=
(
*
index
)
/
TSDB_FILE_TYPE_MAX
;
SFileGroup
*
pFGroup
=
tsdbSearchFGroup
(
pFileH
,
fid
,
TD_EQ
);
if
(
pFGroup
==
NULL
)
{
// not found
tfree
(
sdup
);
return
0
;
}
SFile
*
pFile
=
&
pFGroup
->
files
[(
*
index
)
%
3
];
SFile
*
pFile
=
&
pFGroup
->
files
[(
*
index
)
%
TSDB_FILE_TYPE_MAX
];
fname
=
strdup
(
pFile
->
fname
);
}
}
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
aae9b3c1
...
...
@@ -628,9 +628,10 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitIter *iters, SRWHe
tsdbCloseHelperFile
(
pHelper
,
0
);
pthread_rwlock_wrlock
(
&
(
pFileH
->
fhlock
));
pGroup
->
files
[
TSDB_FILE_TYPE_HEAD
]
=
pHelper
->
files
.
headF
;
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
]
=
pHelper
->
files
.
dataF
;
pGroup
->
files
[
TSDB_FILE_TYPE_LAST
]
=
pHelper
->
files
.
lastF
;
pGroup
->
files
[
TSDB_FILE_TYPE_IDX
]
=
*
(
helperIdxF
(
pHelper
));
pGroup
->
files
[
TSDB_FILE_TYPE_HEAD
]
=
*
(
helperHeadF
(
pHelper
));
pGroup
->
files
[
TSDB_FILE_TYPE_DATA
]
=
*
(
helperDataF
(
pHelper
));
pGroup
->
files
[
TSDB_FILE_TYPE_LAST
]
=
*
(
helperLastF
(
pHelper
));
pthread_rwlock_unlock
(
&
(
pFileH
->
fhlock
));
return
0
;
...
...
src/tsdb/src/tsdbRWHelper.c
浏览文件 @
aae9b3c1
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录