Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f942f144
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
f942f144
编写于
5月 07, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: bitmap operation optimization
上级
23405458
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
41 deletion
+32
-41
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+2
-3
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+5
-5
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+20
-9
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
+5
-24
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
f942f144
...
...
@@ -325,9 +325,8 @@ typedef struct {
typedef
struct
{
int16_t
colId
;
uint16_t
type
:
6
;
uint16_t
blen
:
10
;
// bitmap length(TODO: full UT for the bitmap compress of various data input)
uint32_t
bitmap
:
1
;
// 0: no bitmap if all rows are NORM, 1: has bitmap if has NULL/NORM rows
uint32_t
len
:
31
;
// data length + bitmap length
uint16_t
blen
:
10
;
// 0 no bitmap if all rows are NORM, > 0 bitmap length
uint32_t
len
;
// data length + bitmap length
uint32_t
offset
;
}
SBlockColV0
;
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
f942f144
...
...
@@ -943,16 +943,16 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
&
(
pAggrBlkCol
->
numOfNull
));
if
(
pAggrBlkCol
->
numOfNull
==
0
)
{
TD_SET_COL_ROWS_NORM
(
pBlockCol
)
;
pBlockCol
->
blen
=
0
;
}
else
{
TD_SET_COL_ROWS_MISC
(
pBlockCol
)
;
pBlockCol
->
blen
=
1
;
}
++
nColsOfBlockSma
;
}
else
if
(
tdIsBitmapBlkNorm
(
pDataCol
->
pBitmap
,
rowsToWrite
,
pDataCols
->
bitmapMode
))
{
// check if all rows normal
TD_SET_COL_ROWS_NORM
(
pBlockCol
)
;
pBlockCol
->
blen
=
0
;
}
else
{
TD_SET_COL_ROWS_MISC
(
pBlockCol
)
;
pBlockCol
->
blen
=
1
;
}
++
nColsNotAllNull
;
...
...
@@ -985,7 +985,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
#ifdef TD_SUPPORT_BITMAP
int32_t
tBitmaps
=
0
;
int32_t
tBitmapsLen
=
0
;
if
((
ncol
!=
0
)
&&
!
TD_COL_ROWS_NORM
(
pBlockCol
))
{
if
((
ncol
!=
0
)
&&
(
pBlockCol
->
blen
>
0
))
{
tBitmaps
=
isSuper
?
sBitmaps
:
nBitmaps
;
}
#endif
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
f942f144
...
...
@@ -1619,7 +1619,7 @@ static int32_t mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capa
SCellVal
sVal
=
{
0
};
TSKEY
rowKey
=
TSKEY_INITIAL_VAL
;
int32_t
nResult
=
0
;
bool
isMerge
=
true
;
int32_t
mergeOption
=
0
;
// 0 discard 1 overwrite 2 merge
// the schema version info is embeded in STSRow
int32_t
numOfColsOfRow1
=
0
;
...
...
@@ -1715,12 +1715,18 @@ static int32_t mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capa
if
(
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
rowKey
=
*
(
TSKEY
*
)
sVal
.
val
;
if
(
rowKey
!=
*
lastRowKey
)
{
isMerge
=
false
;
mergeOption
=
1
;
if
(
*
lastRowKey
!=
TSKEY_INITIAL_VAL
)
{
++
(
*
curRow
);
}
++
nResult
;
}
else
if
(
update
){
mergeOption
=
2
;
}
else
{
mergeOption
=
0
;
break
;
}
*
lastRowKey
=
rowKey
;
}
}
else
{
...
...
@@ -1730,11 +1736,16 @@ static int32_t mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capa
tdSKvRowGetVal
(
row
,
PRIMARYKEY_TIMESTAMP_COL_ID
,
-
1
,
-
1
,
&
sVal
);
rowKey
=
*
(
TSKEY
*
)
sVal
.
val
;
if
(
rowKey
!=
*
lastRowKey
)
{
isMerge
=
false
;
mergeOption
=
1
;
if
(
*
lastRowKey
!=
TSKEY_INITIAL_VAL
)
{
++
(
*
curRow
);
}
++
nResult
;
}
else
if
(
update
)
{
mergeOption
=
2
;
}
else
{
mergeOption
=
0
;
break
;
}
*
lastRowKey
=
rowKey
;
}
else
{
...
...
@@ -1754,7 +1765,7 @@ static int32_t mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capa
colDataAppend
(
pColInfo
,
*
curRow
,
NULL
,
true
);
}
else
if
(
tdValTypeIsNone
(
sVal
.
valType
))
{
// TODO: Set null if nothing append for this row
if
(
!
isMerge
)
{
if
(
mergeOption
==
1
)
{
colDataAppend
(
pColInfo
,
*
curRow
,
NULL
,
true
);
}
}
else
{
...
...
@@ -1769,14 +1780,14 @@ static int32_t mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capa
++
k
;
}
}
else
{
if
(
!
isMerge
)
{
if
(
mergeOption
==
1
)
{
colDataAppend
(
pColInfo
,
*
curRow
,
NULL
,
true
);
}
++
i
;
}
}
if
(
*
lastRowKey
!=
rowKey
)
{
if
(
mergeOption
==
1
)
{
while
(
i
<
numOfCols
)
{
// the remain columns are all null data
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pTsdbReadHandle
->
pColumns
,
i
);
colDataAppend
(
pColInfo
,
*
curRow
,
NULL
,
true
);
...
...
@@ -2008,7 +2019,7 @@ static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInf
}
numOfRows
+=
mergeTwoRowFromMem
(
pTsdbReadHandle
,
pTsdbReadHandle
->
outputCapacity
,
&
curRow
,
row1
,
row2
,
numOfCols
,
pCheckInfo
->
tableId
,
pSchema1
,
pSchema2
,
tru
e
,
&
lastRowKey
);
pCheckInfo
->
tableId
,
pSchema1
,
pSchema2
,
pCfg
->
updat
e
,
&
lastRowKey
);
// numOfRows += 1;
if
(
cur
->
win
.
skey
==
TSKEY_INITIAL_VAL
)
{
cur
->
win
.
skey
=
key
;
...
...
@@ -2065,7 +2076,7 @@ static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInf
}
numOfRows
+=
mergeTwoRowFromMem
(
pTsdbReadHandle
,
pTsdbReadHandle
->
outputCapacity
,
&
curRow
,
row1
,
row2
,
numOfCols
,
pCheckInfo
->
tableId
,
pSchema1
,
pSchema2
,
tru
e
,
&
lastRowKey
);
pCheckInfo
->
tableId
,
pSchema1
,
pSchema2
,
pCfg
->
updat
e
,
&
lastRowKey
);
// ++numOfRows;
if
(
cur
->
win
.
skey
==
TSKEY_INITIAL_VAL
)
{
cur
->
win
.
skey
=
key
;
...
...
@@ -2747,7 +2758,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
rv
=
TD_ROW_SVER
(
row
);
}
numOfRows
+=
mergeTwoRowFromMem
(
pTsdbReadHandle
,
maxRowsToRead
,
&
curRows
,
row
,
NULL
,
numOfCols
,
pCheckInfo
->
tableId
,
pSchema
,
NULL
,
tru
e
,
&
lastRowKey
);
NULL
,
pCfg
->
updat
e
,
&
lastRowKey
);
if
(
numOfRows
>=
maxRowsToRead
)
{
moveToNextRowInMem
(
pCheckInfo
);
...
...
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
浏览文件 @
f942f144
...
...
@@ -616,7 +616,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
tcolId
=
pBlockCol
->
colId
;
toffset
=
tsdbGetBlockColOffset
(
pBlockCol
);
tlen
=
pBlockCol
->
len
;
pDataCol
->
bitmap
=
pBlockCol
->
b
itmap
;
pDataCol
->
bitmap
=
pBlockCol
->
b
len
>
0
?
1
:
0
;
}
else
{
ASSERT
(
pDataCol
->
colId
==
tcolId
);
TD_SET_COL_ROWS_NORM
(
pDataCol
);
...
...
@@ -624,17 +624,8 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
// int32_t tBitmaps = 0;
int32_t
tLenBitmap
=
0
;
if
((
dcol
!=
0
)
&&
!
TD_COL_ROWS_NORM
(
pBlockCol
))
{
if
((
dcol
!=
0
)
&&
(
pBlockCol
->
blen
>
0
))
{
tLenBitmap
=
nBitmaps
;
#if 0
if (IS_VAR_DATA_TYPE(pDataCol->type)) {
tBitmaps = nBitmaps;
tLenBitmap = tBitmaps;
} else {
tBitmaps = (int32_t)ceil((double)nBitmaps / TYPE_BYTES[pDataCol->type]);
tLenBitmap = tBitmaps * TYPE_BYTES[pDataCol->type];
}
#endif
}
if
(
tcolId
==
pDataCol
->
colId
)
{
...
...
@@ -784,8 +775,7 @@ static int tsdbLoadBlockDataColsImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *
if
(
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
// load the key row
blockCol
.
colId
=
colId
;
TD_SET_COL_ROWS_NORM
(
&
blockCol
);
// default is NORM for the primary key column
blockCol
.
blen
=
0
;
blockCol
.
blen
=
0
;
// default is NORM for the primary key column
blockCol
.
len
=
pBlock
->
keyLen
;
blockCol
.
type
=
pDataCol
->
type
;
blockCol
.
offset
=
TSDB_KEY_COL_OFFSET
;
...
...
@@ -815,7 +805,7 @@ static int tsdbLoadBlockDataColsImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *
ASSERT
(
pBlockCol
->
colId
==
pDataCol
->
colId
);
}
// set the bitmap
pDataCol
->
bitmap
=
pBlockCol
->
b
itmap
;
pDataCol
->
bitmap
=
pBlockCol
->
b
len
>
0
?
1
:
0
;
if
(
tsdbLoadColData
(
pReadh
,
pDFile
,
pBlock
,
pBlockCol
,
pDataCol
)
<
0
)
return
-
1
;
}
...
...
@@ -833,17 +823,8 @@ static int tsdbLoadColData(SReadH *pReadh, SDFile *pDFile, SBlock *pBlock, SBloc
// int32_t tBitmaps = 0;
int32_t
tLenBitmap
=
0
;
if
(
!
TD_COL_ROWS_NORM
(
pBlockCol
)
)
{
if
(
pBlockCol
->
blen
)
{
tLenBitmap
=
nBitmaps
;
#if 0
if (IS_VAR_DATA_TYPE(pDataCol->type)) {
tBitmaps = nBitmaps;
tLenBitmap = tBitmaps;
} else {
tBitmaps = (int32_t)ceil((double)nBitmaps / TYPE_BYTES[pDataCol->type]);
tLenBitmap = tBitmaps * TYPE_BYTES[pDataCol->type];
}
#endif
}
int
tsize
=
pDataCol
->
bytes
*
pBlock
->
numOfRows
+
tLenBitmap
+
2
*
COMP_OVERFLOW_BYTES
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录