Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN产品汪
TDengine
提交
7ca58999
T
TDengine
项目概览
CSDN产品汪
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
5
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,发现更多精彩内容 >>
提交
7ca58999
编写于
6月 15, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-353
上级
209ebe59
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
36 deletion
+51
-36
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+1
-1
src/tsdb/src/tsdbRWHelper.c
src/tsdb/src/tsdbRWHelper.c
+50
-35
未找到文件。
src/tsdb/inc/tsdbMain.h
浏览文件 @
7ca58999
...
@@ -150,7 +150,7 @@ typedef struct {
...
@@ -150,7 +150,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
uint32_t
len
;
uint32_t
len
;
uint32_t
offset
;
uint32_t
offset
;
uint32_t
padding
;
//
uint32_t padding;
uint32_t
hasLast
:
2
;
uint32_t
hasLast
:
2
;
uint32_t
numOfBlocks
:
30
;
uint32_t
numOfBlocks
:
30
;
uint64_t
uid
;
uint64_t
uid
;
...
...
src/tsdb/src/tsdbRWHelper.c
浏览文件 @
7ca58999
...
@@ -498,36 +498,6 @@ _err:
...
@@ -498,36 +498,6 @@ _err:
return
-
1
;
return
-
1
;
}
}
void
*
tsdbEncodeSCompIdx
(
void
*
buf
,
SCompIdx
*
pIdx
)
{
buf
=
taosEncodeVariantU32
(
buf
,
pIdx
->
len
);
buf
=
taosEncodeVariantU32
(
buf
,
pIdx
->
offset
);
buf
=
taosEncodeFixedU8
(
buf
,
pIdx
->
hasLast
);
buf
=
taosEncodeVariantU32
(
buf
,
pIdx
->
numOfBlocks
);
buf
=
taosEncodeFixedU64
(
buf
,
pIdx
->
uid
);
buf
=
taosEncodeFixedU64
(
buf
,
pIdx
->
maxKey
);
return
buf
;
}
void
*
tsdbDecodeSCompIdx
(
void
*
buf
,
SCompIdx
*
pIdx
)
{
uint8_t
hasLast
=
0
;
uint32_t
numOfBlocks
=
0
;
uint64_t
value
=
0
;
if
((
buf
=
taosDecodeVariantU32
(
buf
,
&
(
pIdx
->
len
)))
==
NULL
)
return
NULL
;
if
((
buf
=
taosDecodeVariantU32
(
buf
,
&
(
pIdx
->
offset
)))
==
NULL
)
return
NULL
;
if
((
buf
=
taosDecodeFixedU8
(
buf
,
&
(
hasLast
)))
==
NULL
)
return
NULL
;
pIdx
->
hasLast
=
hasLast
;
if
((
buf
=
taosDecodeVariantU32
(
buf
,
&
(
numOfBlocks
)))
==
NULL
)
return
NULL
;
pIdx
->
numOfBlocks
=
numOfBlocks
;
if
((
buf
=
taosDecodeFixedU64
(
buf
,
&
value
))
==
NULL
)
return
NULL
;
pIdx
->
uid
=
(
int64_t
)
value
;
if
((
buf
=
taosDecodeFixedU64
(
buf
,
&
value
))
==
NULL
)
return
NULL
;
pIdx
->
maxKey
=
(
TSKEY
)
value
;
return
buf
;
}
int
tsdbUpdateFileHeader
(
SFile
*
pFile
,
uint32_t
version
)
{
int
tsdbUpdateFileHeader
(
SFile
*
pFile
,
uint32_t
version
)
{
char
buf
[
TSDB_FILE_HEAD_SIZE
]
=
"
\0
"
;
char
buf
[
TSDB_FILE_HEAD_SIZE
]
=
"
\0
"
;
...
@@ -583,15 +553,18 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
...
@@ -583,15 +553,18 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
int64_t
offset
=
0
;
int64_t
offset
=
0
;
offset
=
lseek
(
pFile
->
fd
,
0
,
SEEK_END
);
offset
=
lseek
(
pFile
->
fd
,
0
,
SEEK_END
);
if
(
offset
<
0
)
goto
_err
;
if
(
offset
<
0
)
{
tsdbError
(
"vgId:%d failed to write block to file %s since %s"
,
REPO_ID
(
pHelper
->
pRepo
),
pFile
->
fname
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
int
nColsNotAllNull
=
0
;
int
nColsNotAllNull
=
0
;
for
(
int
ncol
=
0
;
ncol
<
pDataCols
->
numOfCols
;
ncol
++
)
{
for
(
int
ncol
=
0
;
ncol
<
pDataCols
->
numOfCols
;
ncol
++
)
{
SDataCol
*
pDataCol
=
pDataCols
->
cols
+
ncol
;
SDataCol
*
pDataCol
=
pDataCols
->
cols
+
ncol
;
SCompCol
*
pCompCol
=
pCompData
->
cols
+
nColsNotAllNull
;
SCompCol
*
pCompCol
=
pCompData
->
cols
+
nColsNotAllNull
;
if
(
isNEleNull
(
pDataCol
,
rowsToWrite
))
{
if
(
isNEleNull
(
pDataCol
,
rowsToWrite
))
{
// all data to commit are NULL, just ignore it
// all data to commit are NULL, just ignore it
continue
;
continue
;
}
}
...
@@ -630,7 +603,10 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
...
@@ -630,7 +603,10 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
if
(
pHelper
->
config
.
compress
)
{
if
(
pHelper
->
config
.
compress
)
{
if
(
pHelper
->
config
.
compress
==
TWO_STAGE_COMP
)
{
if
(
pHelper
->
config
.
compress
==
TWO_STAGE_COMP
)
{
pHelper
->
compBuffer
=
trealloc
(
pHelper
->
compBuffer
,
tlen
+
COMP_OVERFLOW_BYTES
);
pHelper
->
compBuffer
=
trealloc
(
pHelper
->
compBuffer
,
tlen
+
COMP_OVERFLOW_BYTES
);
if
(
pHelper
->
compBuffer
==
NULL
)
goto
_err
;
if
(
pHelper
->
compBuffer
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_err
;
}
}
}
pCompCol
->
len
=
(
*
(
tDataTypeDesc
[
pDataCol
->
type
].
compFunc
))(
pCompCol
->
len
=
(
*
(
tDataTypeDesc
[
pDataCol
->
type
].
compFunc
))(
...
@@ -657,7 +633,11 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
...
@@ -657,7 +633,11 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
pCompData
,
tsize
);
taosCalcChecksumAppend
(
0
,
(
uint8_t
*
)
pCompData
,
tsize
);
// Write the whole block to file
// Write the whole block to file
if
(
twrite
(
pFile
->
fd
,
(
void
*
)
pCompData
,
lsize
)
<
lsize
)
goto
_err
;
if
(
twrite
(
pFile
->
fd
,
(
void
*
)
pCompData
,
lsize
)
<
lsize
)
{
tsdbError
(
"vgId:%d failed to write %d bytes to file %s since %s"
,
REPO_ID
(
helperRepo
(
pHelper
)),
lsize
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
// Update pCompBlock membership vairables
// Update pCompBlock membership vairables
pCompBlock
->
last
=
isLast
;
pCompBlock
->
last
=
isLast
;
...
@@ -671,6 +651,11 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
...
@@ -671,6 +651,11 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
pCompBlock
->
keyFirst
=
dataColsKeyFirst
(
pDataCols
);
pCompBlock
->
keyFirst
=
dataColsKeyFirst
(
pDataCols
);
pCompBlock
->
keyLast
=
dataColsKeyAt
(
pDataCols
,
rowsToWrite
-
1
);
pCompBlock
->
keyLast
=
dataColsKeyAt
(
pDataCols
,
rowsToWrite
-
1
);
tsdbTrace
(
"vgId:%d tid:%d a block of data is written to file %s, offset %"
PRId64
" numOfRows %d len %d numOfCols %"
PRId16
" keyFirst %"
PRId64
" keyLast %"
PRId64
,
REPO_ID
(
helperRepo
(
pHelper
)),
pHelper
->
tableInfo
.
tid
,
pFile
->
fname
,
pCompBlock
->
offset
,
pCompBlock
->
numOfRows
,
pCompBlock
->
len
,
pCompBlock
->
numOfCols
,
pCompBlock
->
keyFirst
,
pCompBlock
->
keyLast
);
return
0
;
return
0
;
_err:
_err:
...
@@ -1235,3 +1220,33 @@ static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDa
...
@@ -1235,3 +1220,33 @@ static int tsdbLoadBlockDataImpl(SRWHelper *pHelper, SCompBlock *pCompBlock, SDa
_err:
_err:
return
-
1
;
return
-
1
;
}
}
static
void
*
tsdbEncodeSCompIdx
(
void
*
buf
,
SCompIdx
*
pIdx
)
{
buf
=
taosEncodeVariantU32
(
buf
,
pIdx
->
len
);
buf
=
taosEncodeVariantU32
(
buf
,
pIdx
->
offset
);
buf
=
taosEncodeFixedU8
(
buf
,
pIdx
->
hasLast
);
buf
=
taosEncodeVariantU32
(
buf
,
pIdx
->
numOfBlocks
);
buf
=
taosEncodeFixedU64
(
buf
,
pIdx
->
uid
);
buf
=
taosEncodeFixedU64
(
buf
,
pIdx
->
maxKey
);
return
buf
;
}
static
void
*
tsdbDecodeSCompIdx
(
void
*
buf
,
SCompIdx
*
pIdx
)
{
uint8_t
hasLast
=
0
;
uint32_t
numOfBlocks
=
0
;
uint64_t
value
=
0
;
if
((
buf
=
taosDecodeVariantU32
(
buf
,
&
(
pIdx
->
len
)))
==
NULL
)
return
NULL
;
if
((
buf
=
taosDecodeVariantU32
(
buf
,
&
(
pIdx
->
offset
)))
==
NULL
)
return
NULL
;
if
((
buf
=
taosDecodeFixedU8
(
buf
,
&
(
hasLast
)))
==
NULL
)
return
NULL
;
pIdx
->
hasLast
=
hasLast
;
if
((
buf
=
taosDecodeVariantU32
(
buf
,
&
(
numOfBlocks
)))
==
NULL
)
return
NULL
;
pIdx
->
numOfBlocks
=
numOfBlocks
;
if
((
buf
=
taosDecodeFixedU64
(
buf
,
&
value
))
==
NULL
)
return
NULL
;
pIdx
->
uid
=
(
int64_t
)
value
;
if
((
buf
=
taosDecodeFixedU64
(
buf
,
&
value
))
==
NULL
)
return
NULL
;
pIdx
->
maxKey
=
(
TSKEY
)
value
;
return
buf
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录