Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5dcfd2a6
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看板
提交
5dcfd2a6
编写于
1月 15, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact more
上级
99d223f9
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
47 addition
and
41 deletion
+47
-41
src/common/src/tdataformat.c
src/common/src/tdataformat.c
+20
-12
src/tsdb/inc/tsdbFS.h
src/tsdb/inc/tsdbFS.h
+1
-1
src/tsdb/inc/tsdbFile.h
src/tsdb/inc/tsdbFile.h
+6
-0
src/tsdb/inc/tsdbReadImpl.h
src/tsdb/inc/tsdbReadImpl.h
+6
-9
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+2
-2
src/tsdb/src/tsdbReadImpl.c
src/tsdb/src/tsdbReadImpl.c
+12
-17
未找到文件。
src/common/src/tdataformat.c
浏览文件 @
5dcfd2a6
...
...
@@ -289,24 +289,32 @@ SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) {
return
NULL
;
}
pCols
->
maxPoints
=
maxRows
;
if
(
maxCols
>
0
)
{
pCols
->
cols
=
(
SDataCol
*
)
calloc
(
maxCols
,
sizeof
(
SDataCol
));
if
(
pCols
->
cols
==
NULL
)
{
uDebug
(
"malloc failure, size:%"
PRId64
" failed, reason:%s"
,
(
int64_t
)
sizeof
(
SDataCol
)
*
maxCols
,
strerror
(
errno
));
uDebug
(
"malloc failure, size:%"
PRId64
" failed, reason:%s"
,
(
int64_t
)
sizeof
(
SDataCol
)
*
maxCols
,
strerror
(
errno
));
tdFreeDataCols
(
pCols
);
return
NULL
;
}
pCols
->
maxRowSize
=
maxRowSize
;
pCols
->
maxCols
=
maxCols
;
pCols
->
maxPoints
=
maxRows
;
}
pCols
->
maxRowSize
=
maxRowSize
;
pCols
->
bufSize
=
maxRowSize
*
maxRows
;
if
(
pCols
->
bufSize
>
0
)
{
pCols
->
buf
=
malloc
(
pCols
->
bufSize
);
if
(
pCols
->
buf
==
NULL
)
{
uDebug
(
"malloc failure, size:%"
PRId64
" failed, reason:%s"
,
(
int64_t
)
sizeof
(
SDataCol
)
*
maxCols
,
strerror
(
errno
));
uDebug
(
"malloc failure, size:%"
PRId64
" failed, reason:%s"
,
(
int64_t
)
sizeof
(
SDataCol
)
*
maxCols
,
strerror
(
errno
));
tdFreeDataCols
(
pCols
);
return
NULL
;
}
}
return
pCols
;
}
...
...
src/tsdb/inc/tsdbFS.h
浏览文件 @
5dcfd2a6
...
...
@@ -70,7 +70,7 @@ typedef struct {
STsdbFS
*
tsdbNewFS
(
int
keep
,
int
days
);
void
*
tsdbFreeFS
(
STsdbFS
*
pfs
);
int
tdbOpenFS
(
STsdbFS
*
pFs
,
int
keep
,
int
days
);
int
t
s
dbOpenFS
(
STsdbFS
*
pFs
,
int
keep
,
int
days
);
void
tsdbCloseFS
(
STsdbFS
*
pFs
);
int
tsdbStartTxn
(
STsdbFS
*
pfs
);
int
tsdbEndTxn
(
STsdbFS
*
pfs
);
...
...
src/tsdb/inc/tsdbFile.h
浏览文件 @
5dcfd2a6
...
...
@@ -287,6 +287,12 @@ typedef struct {
#define TSDB_DFILE_IN_SET(s, t) ((s)->files + (t))
#define TSDB_FSET_LEVEL(s) TSDB_FILE_LEVEL(TSDB_DFILE_IN_SET(s, 0))
#define TSDB_FSET_ID(s) TSDB_FILE_ID(TSDB_DFILE_IN_SET(s, 0))
#define TSDB_FSET_SET_CLOSED(s) \
do { \
for (TSDB_FILE_T ftype = TSDB_FILE_HEAD; ftype < TSDB_FILE_MAX; ftype++) { \
TSDB_FILE_SET_CLOSED(TSDB_DFILE_IN_SET(s, ftype)); \
} \
} while (0);
void
tsdbInitDFileSet
(
SDFileSet
*
pSet
,
SDiskID
did
,
int
vid
,
int
fid
,
uint32_t
ver
);
void
tsdbInitDFileSetEx
(
SDFileSet
*
pSet
,
SDFileSet
*
pOSet
);
...
...
src/tsdb/inc/tsdbReadImpl.h
浏览文件 @
5dcfd2a6
...
...
@@ -16,9 +16,6 @@
#ifndef _TD_TSDB_READ_IMPL_H_
#define _TD_TSDB_READ_IMPL_H_
#include "taosdef.h"
#include "tdataformat.h"
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
@@ -78,16 +75,16 @@ typedef struct {
struct
SReadH
{
STsdbRepo
*
pRepo
;
SDFileSet
rSet
;
// File set
SArray
*
aBlkIdx
;
STable
*
pTable
;
// Table info
SBlockIdx
*
pBlkIdx
;
SDFileSet
rSet
;
// FSET to read
SArray
*
aBlkIdx
;
// SBlockIdx array
STable
*
pTable
;
// table to read
SBlockIdx
*
pBlkIdx
;
// current reading table SBlockIdx
int
cidx
;
SBlockInfo
*
pBlkInfo
;
SBlockData
*
pBlkData
;
// Block info
SDataCols
*
pDCols
[
2
];
void
*
pBuf
;
void
*
pCBuf
;
void
*
pBuf
;
// buffer
void
*
pCBuf
;
// compression buffer
};
#define TSDB_READ_REPO(rh) ((rh)->pRepo)
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
5dcfd2a6
...
...
@@ -724,7 +724,7 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
SBlockIdx
*
compIndex
=
pQueryHandle
->
rhelper
.
pBlkIdx
;
// no data block in this file, try next file
if
(
compIndex
->
len
==
0
||
compIndex
->
numOfBlocks
==
0
||
compIndex
->
uid
!=
pCheckInfo
->
tableId
.
uid
)
{
if
(
compIndex
==
NULL
||
compIndex
->
uid
!=
pCheckInfo
->
tableId
.
uid
)
{
continue
;
// no data blocks in the file belongs to pCheckInfo->pTable
}
...
...
src/tsdb/src/tsdbReadImpl.c
浏览文件 @
5dcfd2a6
...
...
@@ -34,9 +34,7 @@ int tsdbInitReadH(SReadH *pReadh, STsdbRepo *pRepo) {
memset
((
void
*
)
pReadh
,
0
,
sizeof
(
*
pReadh
));
pReadh
->
pRepo
=
pRepo
;
for
(
TSDB_FILE_T
ftype
=
TSDB_FILE_HEAD
;
ftype
<
TSDB_FILE_MAX
;
ftype
++
)
{
TSDB_FILE_SET_CLOSED
(
TSDB_DFILE_IN_SET
(
TSDB_READ_FSET
(
pReadh
),
ftype
));
}
TSDB_FSET_SET_CLOSED
(
TSDB_READ_FSET
(
pReadh
));
pReadh
->
aBlkIdx
=
taosArrayInit
(
1024
,
sizeof
(
SBlockIdx
));
if
(
pReadh
->
aBlkIdx
==
NULL
)
{
...
...
@@ -83,9 +81,7 @@ int tsdbSetAndOpenReadFSet(SReadH *pReadh, SDFileSet *pSet) {
tsdbResetReadFile
(
pReadh
);
pReadh
->
rSet
=
*
pSet
;
for
(
TSDB_FILE_T
ftype
=
TSDB_FILE_HEAD
;
ftype
<
TSDB_FILE_MAX
;
ftype
++
)
{
TSDB_FILE_SET_CLOSED
(
TSDB_DFILE_IN_SET
(
TSDB_READ_FSET
(
pReadh
),
ftype
));
}
TSDB_FSET_SET_CLOSED
(
TSDB_READ_FSET
(
pReadh
));
if
(
tsdbOpenDFileSet
(
TSDB_READ_FSET
(
pReadh
),
O_RDONLY
)
<
0
)
return
-
1
;
return
0
;
...
...
@@ -233,6 +229,8 @@ int tsdbLoadBlockInfo(SReadH *pReadh, void *pTarget) {
return
-
1
;
}
ASSERT
(
pBlkIdx
->
tid
==
pReadh
->
pBlkInfo
->
tid
&&
pBlkIdx
->
uid
==
pReadh
->
pBlkInfo
->
uid
);
if
(
pTarget
)
{
memcpy
(
pTarget
,
(
void
*
)(
pReadh
->
pBlkInfo
),
pBlkIdx
->
len
);
}
...
...
@@ -410,7 +408,7 @@ static void tsdbResetReadFile(SReadH *pReadh) {
static
int
tsdbLoadBlockDataImpl
(
SReadH
*
pReadh
,
SBlock
*
pBlock
,
SDataCols
*
pDataCols
)
{
ASSERT
(
pBlock
->
numOfSubBlocks
>=
0
&&
pBlock
->
numOfSubBlocks
<=
1
);
SDFile
*
pDFile
=
(
pBlock
->
last
)
?
TSDB_READ_LAST_FILE
(
pReadh
)
:
TSDB_READ_
HEAD
_FILE
(
pReadh
);
SDFile
*
pDFile
=
(
pBlock
->
last
)
?
TSDB_READ_LAST_FILE
(
pReadh
)
:
TSDB_READ_
DATA
_FILE
(
pReadh
);
tdResetDataCols
(
pDataCols
);
if
(
tsdbMakeRoom
((
void
**
)(
&
TSDB_READ_BUF
(
pReadh
)),
pBlock
->
len
)
<
0
)
return
-
1
;
...
...
@@ -426,7 +424,8 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
int64_t
nread
=
tsdbReadDFile
(
pDFile
,
TSDB_READ_BUF
(
pReadh
),
pBlock
->
len
);
if
(
nread
<
0
)
{
tsdbError
(
"vgId:%d failed to load block data part while read file %s sinces %s, offset:%"
PRId64
" len :%d"
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tstrerror
(
terrno
),
(
int64_t
)
pBlock
->
offset
,
pBlock
->
len
);
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tstrerror
(
terrno
),
(
int64_t
)
pBlock
->
offset
,
pBlock
->
len
);
return
-
1
;
}
...
...
@@ -479,16 +478,12 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
if
(
tcolId
==
pDataCol
->
colId
)
{
if
(
pBlock
->
algorithm
==
TWO_STAGE_COMP
)
{
int
zsize
=
pDataCol
->
bytes
*
pBlock
->
numOfRows
+
COMP_OVERFLOW_BYTES
;
if
(
IS_VAR_DATA_TYPE
(
pDataCol
->
type
))
{
zsize
+=
(
sizeof
(
VarDataLenT
)
*
pBlock
->
numOfRows
);
}
if
(
tsdbMakeRoom
((
void
**
)(
&
TSDB_READ_COMP_BUF
(
pReadh
)),
zsize
)
<
0
)
return
-
1
;
}
if
(
tsdbCheckAndDecodeColumnData
(
pDataCol
,
POINTER_SHIFT
(
pBlockData
,
tsize
+
toffset
),
tlen
,
pBlock
->
algorithm
,
pBlock
->
numOfRows
,
pDataCols
->
maxPoints
,
TSDB_READ_COMP_BUF
(
pReadh
),
(
int32_t
)
taosTSizeof
(
TSDB_READ_COMP_BUF
(
pReadh
)))
<
0
)
{
taosTSizeof
(
TSDB_READ_COMP_BUF
(
pReadh
)))
<
0
)
{
tsdbError
(
"vgId:%d file %s is broken at column %d block offset %"
PRId64
" column offset %d"
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tcolId
,
(
int64_t
)
pBlock
->
offset
,
toffset
);
return
-
1
;
...
...
@@ -622,11 +617,11 @@ static int tsdbLoadColData(SReadH *pReadh, SDFile *pDFile, SBlock *pBlock, SBloc
ASSERT
(
pDataCol
->
colId
==
pBlockCol
->
colId
);
STsdbRepo
*
pRepo
=
TSDB_READ_REPO
(
pReadh
);
STsdbCfg
*
pCfg
=
&
(
pRepo
->
config
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
int
tsize
=
pDataCol
->
bytes
*
pBlock
->
numOfRows
+
COMP_OVERFLOW_BYTES
;
if
(
tsdbMakeRoom
((
void
**
)(
&
(
pReadh
->
pBuf
)),
pBlockCol
->
len
)
<
0
)
return
-
1
;
if
(
tsdbMakeRoom
((
void
**
)(
&
(
pReadh
->
pCBuf
)),
tsize
)
<
0
)
return
-
1
;
if
(
tsdbMakeRoom
((
void
**
)(
&
(
TSDB_READ_BUF
(
pReadh
)
)),
pBlockCol
->
len
)
<
0
)
return
-
1
;
if
(
tsdbMakeRoom
((
void
**
)(
&
(
TSDB_READ_COMP_BUF
(
pReadh
)
)),
tsize
)
<
0
)
return
-
1
;
int64_t
offset
=
pBlock
->
offset
+
TSDB_BLOCK_STATIS_SIZE
(
pBlock
->
numOfCols
)
+
pBlockCol
->
offset
;
if
(
tsdbSeekDFile
(
pDFile
,
offset
,
SEEK_SET
)
<
0
)
{
...
...
@@ -635,7 +630,7 @@ static int tsdbLoadColData(SReadH *pReadh, SDFile *pDFile, SBlock *pBlock, SBloc
return
-
1
;
}
int64_t
nread
=
tsdbReadDFile
(
pDFile
,
pReadh
->
pBuf
,
pBlockCol
->
len
);
int64_t
nread
=
tsdbReadDFile
(
pDFile
,
TSDB_READ_BUF
(
pReadh
)
,
pBlockCol
->
len
);
if
(
nread
<
0
)
{
tsdbError
(
"vgId:%d failed to load block column data while read file %s sinces %s, offset:%"
PRId64
" len :%d"
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tstrerror
(
terrno
),
offset
,
pBlockCol
->
len
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录