Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
51797a8b
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
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看板
提交
51797a8b
编写于
2月 09, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-11818] optimize the sort performance.
上级
1172e668
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
64 addition
and
57 deletion
+64
-57
include/common/common.h
include/common/common.h
+1
-0
include/common/tep.h
include/common/tep.h
+41
-3
source/common/src/tep.c
source/common/src/tep.c
+22
-54
未找到文件。
include/common/common.h
浏览文件 @
51797a8b
...
@@ -74,6 +74,7 @@ typedef struct SVarColAttr {
...
@@ -74,6 +74,7 @@ typedef struct SVarColAttr {
// pBlockAgg->numOfNull == 0, no data are null.
// pBlockAgg->numOfNull == 0, no data are null.
typedef
struct
SColumnInfoData
{
typedef
struct
SColumnInfoData
{
SColumnInfo
info
;
// TODO filter info needs to be removed
SColumnInfo
info
;
// TODO filter info needs to be removed
bool
hasNull
;
// if current column data has null value.
char
*
pData
;
// the corresponding block data in memory
char
*
pData
;
// the corresponding block data in memory
union
{
union
{
char
*
nullbitmap
;
// bitmap, one bit for each item in the list
char
*
nullbitmap
;
// bitmap, one bit for each item in the list
...
...
include/common/tep.h
浏览文件 @
51797a8b
...
@@ -27,12 +27,50 @@ bool isEpsetEqual(const SEpSet *s1, const SEpSet *s2);
...
@@ -27,12 +27,50 @@ bool isEpsetEqual(const SEpSet *s1, const SEpSet *s2);
void
updateEpSet_s
(
SCorEpSet
*
pEpSet
,
SEpSet
*
pNewEpSet
);
void
updateEpSet_s
(
SCorEpSet
*
pEpSet
,
SEpSet
*
pNewEpSet
);
SEpSet
getEpSet_s
(
SCorEpSet
*
pEpSet
);
SEpSet
getEpSet_s
(
SCorEpSet
*
pEpSet
);
bool
colDataIsNull_f
(
const
char
*
bitmap
,
uint32_t
row
);
#define BitPos(_n) ((_n) & ((1<<NBIT) - 1))
#define NBIT (3u)
static
FORCE_INLINE
bool
colDataIsNull_f
(
const
char
*
bitmap
,
uint32_t
row
)
{
return
(
bitmap
[
row
>>
3u
]
&
(
1u
<<
(
7u
-
BitPos
(
row
))))
==
(
1u
<<
(
7u
-
BitPos
(
row
)));
}
void
colDataSetNull_f
(
char
*
bitmap
,
uint32_t
row
);
void
colDataSetNull_f
(
char
*
bitmap
,
uint32_t
row
);
bool
colDataIsNull
(
const
SColumnInfoData
*
pColumnInfoData
,
uint32_t
totalRows
,
uint32_t
row
,
SColumnDataAgg
*
pColAgg
);
static
FORCE_INLINE
bool
colDataIsNull
(
const
SColumnInfoData
*
pColumnInfoData
,
uint32_t
totalRows
,
uint32_t
row
,
SColumnDataAgg
*
pColAgg
)
{
if
(
!
pColumnInfoData
->
hasNull
)
{
return
false
;
}
if
(
pColAgg
!=
NULL
)
{
if
(
pColAgg
->
numOfNull
==
totalRows
)
{
ASSERT
(
pColumnInfoData
->
nullbitmap
==
NULL
);
return
true
;
}
else
if
(
pColAgg
->
numOfNull
==
0
)
{
ASSERT
(
pColumnInfoData
->
nullbitmap
==
NULL
);
return
false
;
}
}
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
return
pColumnInfoData
->
varmeta
.
offset
[
row
]
==
-
1
;
}
else
{
if
(
pColumnInfoData
->
nullbitmap
==
NULL
)
{
return
false
;
}
return
colDataIsNull_f
(
pColumnInfoData
->
nullbitmap
,
row
);
}
}
static
FORCE_INLINE
char
*
colDataGet
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
row
)
{
char
*
p
=
pColumnInfoData
->
pData
;
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
return
p
+
pColumnInfoData
->
varmeta
.
offset
[
row
];
}
else
{
return
p
+
(
row
*
pColumnInfoData
->
info
.
bytes
);
}
}
char
*
colDataGet
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
row
);
int32_t
colDataAppend
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
bool
isNull
);
int32_t
colDataAppend
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
bool
isNull
);
int32_t
colDataMergeCol
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
numOfRow1
,
const
SColumnInfoData
*
pSource
,
uint32_t
numOfRow2
);
int32_t
colDataMergeCol
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
numOfRow1
,
const
SColumnInfoData
*
pSource
,
uint32_t
numOfRow2
);
int32_t
colDataUpdateTsWindow
(
SSDataBlock
*
pDataBlock
);
int32_t
colDataUpdateTsWindow
(
SSDataBlock
*
pDataBlock
);
...
...
source/common/src/tep.c
浏览文件 @
51797a8b
...
@@ -60,49 +60,12 @@ SEpSet getEpSet_s(SCorEpSet *pEpSet) {
...
@@ -60,49 +60,12 @@ SEpSet getEpSet_s(SCorEpSet *pEpSet) {
return
ep
;
return
ep
;
}
}
bool
colDataIsNull
(
const
SColumnInfoData
*
pColumnInfoData
,
uint32_t
totalRows
,
uint32_t
row
,
SColumnDataAgg
*
pColAgg
)
{
if
(
pColAgg
!=
NULL
)
{
if
(
pColAgg
->
numOfNull
==
totalRows
)
{
ASSERT
(
pColumnInfoData
->
nullbitmap
==
NULL
);
return
true
;
}
else
if
(
pColAgg
->
numOfNull
==
0
)
{
ASSERT
(
pColumnInfoData
->
nullbitmap
==
NULL
);
return
false
;
}
}
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
return
pColumnInfoData
->
varmeta
.
offset
[
row
]
==
-
1
;
}
else
{
if
(
pColumnInfoData
->
nullbitmap
==
NULL
)
{
return
false
;
}
return
colDataIsNull_f
(
pColumnInfoData
->
nullbitmap
,
row
);
}
}
#define NBIT (3u)
#define BitmapLen(_n) (((_n) + ((1<<NBIT)-1)) >> NBIT)
#define BitmapLen(_n) (((_n) + ((1<<NBIT)-1)) >> NBIT)
#define BitPos(_n) ((_n) & ((1<<NBIT) - 1))
bool
colDataIsNull_f
(
const
char
*
bitmap
,
uint32_t
row
)
{
return
(
bitmap
[
row
>>
3u
]
&
(
1u
<<
(
7u
-
BitPos
(
row
))))
==
(
1u
<<
(
7u
-
BitPos
(
row
)));
}
void
colDataSetNull_f
(
char
*
bitmap
,
uint32_t
row
)
{
void
colDataSetNull_f
(
char
*
bitmap
,
uint32_t
row
)
{
bitmap
[
row
>>
3u
]
|=
(
1u
<<
(
7u
-
BitPos
(
row
)));
bitmap
[
row
>>
3u
]
|=
(
1u
<<
(
7u
-
BitPos
(
row
)));
}
}
char
*
colDataGet
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
row
)
{
char
*
p
=
pColumnInfoData
->
pData
;
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
return
p
+
pColumnInfoData
->
varmeta
.
offset
[
row
];
}
else
{
return
p
+
(
row
*
pColumnInfoData
->
info
.
bytes
);
}
}
static
int32_t
ensureBitmapSize
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
size
)
{
static
int32_t
ensureBitmapSize
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
size
)
{
#if 0
#if 0
ASSERT(pColumnInfoData != NULL);
ASSERT(pColumnInfoData != NULL);
...
@@ -579,11 +542,12 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) {
...
@@ -579,11 +542,12 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) {
int32_t
*
right
=
(
int32_t
*
)
p2
;
int32_t
*
right
=
(
int32_t
*
)
p2
;
SArray
*
pInfo
=
pHelper
->
orderInfo
;
SArray
*
pInfo
=
pHelper
->
orderInfo
;
size_t
num
=
taosArrayGetSize
(
pInfo
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInfo
->
size
;
++
i
)
{
SBlockOrderInfo
*
pOrder
=
taosArrayGet
(
pInfo
,
i
);
SBlockOrderInfo
*
pOrder
=
taosArrayGet
(
pInfo
,
i
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
pOrder
->
colIndex
);
SColumnInfoData
*
pColInfoData
=
TARRAY_GET_ELEM
(
pDataBlock
->
pDataBlock
,
pOrder
->
colIndex
);
if
(
pColInfoData
->
hasNull
)
{
bool
leftNull
=
colDataIsNull
(
pColInfoData
,
pDataBlock
->
info
.
rows
,
*
left
,
pDataBlock
->
pBlockAgg
);
bool
leftNull
=
colDataIsNull
(
pColInfoData
,
pDataBlock
->
info
.
rows
,
*
left
,
pDataBlock
->
pBlockAgg
);
bool
rightNull
=
colDataIsNull
(
pColInfoData
,
pDataBlock
->
info
.
rows
,
*
right
,
pDataBlock
->
pBlockAgg
);
bool
rightNull
=
colDataIsNull
(
pColInfoData
,
pDataBlock
->
info
.
rows
,
*
right
,
pDataBlock
->
pBlockAgg
);
if
(
leftNull
&&
rightNull
)
{
if
(
leftNull
&&
rightNull
)
{
...
@@ -597,19 +561,23 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) {
...
@@ -597,19 +561,23 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) {
if
(
leftNull
)
{
if
(
leftNull
)
{
return
pHelper
->
nullFirst
?
-
1
:
1
;
return
pHelper
->
nullFirst
?
-
1
:
1
;
}
}
}
void
*
left1
=
colDataGet
(
pColInfoData
,
*
left
);
void
*
left1
=
colDataGet
(
pColInfoData
,
*
left
);
void
*
right1
=
colDataGet
(
pColInfoData
,
*
right
);
void
*
right1
=
colDataGet
(
pColInfoData
,
*
right
);
switch
(
pColInfoData
->
info
.
type
)
{
switch
(
pColInfoData
->
info
.
type
)
{
case
TSDB_DATA_TYPE_INT
:
{
case
TSDB_DATA_TYPE_INT
:
{
if
(
*
(
int32_t
*
)
left1
==
*
(
int32_t
*
)
right1
)
{
int32_t
leftx
=
*
(
int32_t
*
)
left1
;
int32_t
rightx
=
*
(
int32_t
*
)
right1
;
if
(
leftx
==
rightx
)
{
break
;
break
;
}
else
{
}
else
{
if
(
pOrder
->
order
==
TSDB_ORDER_ASC
)
{
if
(
pOrder
->
order
==
TSDB_ORDER_ASC
)
{
return
(
*
(
int32_t
*
)
left1
<=
*
(
int32_t
*
)
right1
)
?
-
1
:
1
;
return
(
leftx
<=
rightx
)
?
-
1
:
1
;
}
else
{
}
else
{
return
(
*
(
int32_t
*
)
left1
<=
*
(
int32_t
*
)
right1
)
?
1
:-
1
;
return
(
leftx
<=
rightx
)
?
1
:-
1
;
}
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录