Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4e8f3db5
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看板
提交
4e8f3db5
编写于
7月 01, 2022
作者:
wafwerar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
os: replace win qsort func
上级
f421ab09
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
73 addition
and
19 deletion
+73
-19
include/os/osMath.h
include/os/osMath.h
+7
-0
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+1
-1
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+2
-2
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+1
-1
source/libs/function/src/taggfunction.c
source/libs/function/src/taggfunction.c
+2
-2
source/libs/function/src/tpercentile.c
source/libs/function/src/tpercentile.c
+1
-1
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+4
-4
source/libs/parser/src/parInsertData.c
source/libs/parser/src/parInsertData.c
+2
-2
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+2
-2
source/os/src/osMath.c
source/os/src/osMath.c
+47
-0
source/util/src/tarray.c
source/util/src/tarray.c
+2
-2
source/util/src/tdigest.c
source/util/src/tdigest.c
+1
-1
source/util/src/terror.c
source/util/src/terror.c
+1
-1
未找到文件。
include/os/osMath.h
浏览文件 @
4e8f3db5
...
...
@@ -60,6 +60,13 @@ extern "C" {
})
#endif
#ifndef __COMPAR_FN_T
#define __COMPAR_FN_T
typedef
int32_t
(
*
__compar_fn_t
)(
const
void
*
,
const
void
*
);
#endif
void
taosSort
(
void
*
arr
,
int64_t
sz
,
int64_t
width
,
__compar_fn_t
compar
);
#ifdef __cplusplus
}
#endif
...
...
source/common/src/tdatablock.c
浏览文件 @
4e8f3db5
...
...
@@ -892,7 +892,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) {
int64_t
p0
=
taosGetTimestampUs
();
__compar_fn_t
fn
=
getKeyComparFunc
(
pColInfoData
->
info
.
type
,
pOrder
->
order
);
qs
ort
(
pColInfoData
->
pData
,
pDataBlock
->
info
.
rows
,
pColInfoData
->
info
.
bytes
,
fn
);
taosS
ort
(
pColInfoData
->
pData
,
pDataBlock
->
info
.
rows
,
pColInfoData
->
info
.
bytes
,
fn
);
int64_t
p1
=
taosGetTimestampUs
();
uDebug
(
"blockDataSort easy cost:%"
PRId64
", rows:%d
\n
"
,
p1
-
p0
,
pDataBlock
->
info
.
rows
);
...
...
source/common/src/tdataformat.c
浏览文件 @
4e8f3db5
...
...
@@ -931,9 +931,9 @@ int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag) {
// sort
if
(
isJson
)
{
qs
ort
(
pArray
->
pData
,
nTag
,
sizeof
(
STagVal
),
tTagValJsonCmprFn
);
taosS
ort
(
pArray
->
pData
,
nTag
,
sizeof
(
STagVal
),
tTagValJsonCmprFn
);
}
else
{
qs
ort
(
pArray
->
pData
,
nTag
,
sizeof
(
STagVal
),
tTagValCmprFn
);
taosS
ort
(
pArray
->
pData
,
nTag
,
sizeof
(
STagVal
),
tTagValCmprFn
);
}
// get size
...
...
source/libs/executor/src/executil.c
浏览文件 @
4e8f3db5
...
...
@@ -118,7 +118,7 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap, int
if
(
order
==
TSDB_ORDER_ASC
||
order
==
TSDB_ORDER_DESC
)
{
__compar_fn_t
fn
=
(
order
==
TSDB_ORDER_ASC
)
?
resultrowComparAsc
:
resultrowComparDesc
;
qs
ort
(
pGroupResInfo
->
pRows
->
pData
,
taosArrayGetSize
(
pGroupResInfo
->
pRows
),
POINTER_BYTES
,
fn
);
taosS
ort
(
pGroupResInfo
->
pRows
->
pData
,
taosArrayGetSize
(
pGroupResInfo
->
pRows
),
POINTER_BYTES
,
fn
);
}
pGroupResInfo
->
index
=
0
;
...
...
source/libs/function/src/taggfunction.c
浏览文件 @
4e8f3db5
...
...
@@ -1887,10 +1887,10 @@ static void top_bottom_func_finalizer(SqlFunctionCtx *pCtx) {
// user specify the order of output by sort the result according to timestamp
if (pCtx->param[1].param.i == PRIMARYKEY_TIMESTAMP_COL_ID) {
__compar_fn_t comparator = (pCtx->param[2].param.i == TSDB_ORDER_ASC) ? resAscComparFn : resDescComparFn;
qs
ort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator);
taosS
ort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator);
} else /*if (pCtx->param[1].param.i > PRIMARYKEY_TIMESTAMP_COL_ID)*/ {
__compar_fn_t comparator = (pCtx->param[2].param.i == TSDB_ORDER_ASC) ? resDataAscComparFn : resDataDescComparFn;
qs
ort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator);
taosS
ort(tvp, (size_t)pResInfo->numOfRes, POINTER_BYTES, comparator);
}
GET_TRUE_DATA_TYPE();
...
...
source/libs/function/src/tpercentile.c
浏览文件 @
4e8f3db5
...
...
@@ -44,7 +44,7 @@ static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx)
offset
+=
(
int32_t
)(
pg
->
num
*
pMemBucket
->
bytes
);
}
qs
ort
(
buffer
->
data
,
pMemBucket
->
pSlots
[
slotIdx
].
info
.
size
,
pMemBucket
->
bytes
,
pMemBucket
->
comparFn
);
taosS
ort
(
buffer
->
data
,
pMemBucket
->
pSlots
[
slotIdx
].
info
.
size
,
pMemBucket
->
bytes
,
pMemBucket
->
comparFn
);
return
buffer
;
}
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
4e8f3db5
...
...
@@ -790,11 +790,11 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
pColIdx
[
i
].
schemaColIdx
=
pColList
->
boundColumns
[
i
];
pColIdx
[
i
].
boundIdx
=
i
;
}
qs
ort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
schemaIdxCompar
);
taosS
ort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
schemaIdxCompar
);
for
(
col_id_t
i
=
0
;
i
<
pColList
->
numOfBound
;
++
i
)
{
pColIdx
[
i
].
finalIdx
=
i
;
}
qs
ort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
boundIdxCompar
);
taosS
ort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
boundIdxCompar
);
}
if
(
pColList
->
numOfCols
>
pColList
->
numOfBound
)
{
...
...
@@ -2232,11 +2232,11 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS
pColIdx
[
i
].
schemaColIdx
=
pColList
->
boundColumns
[
i
];
pColIdx
[
i
].
boundIdx
=
i
;
}
qs
ort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
schemaIdxCompar
);
taosS
ort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
schemaIdxCompar
);
for
(
col_id_t
i
=
0
;
i
<
pColList
->
numOfBound
;
++
i
)
{
pColIdx
[
i
].
finalIdx
=
i
;
}
qs
ort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
boundIdxCompar
);
taosS
ort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
boundIdxCompar
);
}
if
(
pColList
->
numOfCols
>
pColList
->
numOfBound
)
{
...
...
source/libs/parser/src/parInsertData.c
浏览文件 @
4e8f3db5
...
...
@@ -295,7 +295,7 @@ void sortRemoveDataBlockDupRowsRaw(STableDataBlocks* dataBuf) {
char
*
pBlockData
=
pBlocks
->
data
;
// todo. qsort is unstable, if timestamp is same, should get the last one
qs
ort
(
pBlockData
,
pBlocks
->
numOfRows
,
dataBuf
->
rowSize
,
rowDataCompar
);
taosS
ort
(
pBlockData
,
pBlocks
->
numOfRows
,
dataBuf
->
rowSize
,
rowDataCompar
);
int32_t
i
=
0
;
int32_t
j
=
1
;
...
...
@@ -365,7 +365,7 @@ int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKey
pBlkKeyTuple
=
pBlkKeyInfo
->
pKeyTuple
;
// todo. qsort is unstable, if timestamp is same, should get the last one
qs
ort
(
pBlkKeyTuple
,
nRows
,
sizeof
(
SBlockKeyTuple
),
rowDataComparStable
);
taosS
ort
(
pBlkKeyTuple
,
nRows
,
sizeof
(
SBlockKeyTuple
),
rowDataComparStable
);
pBlkKeyTuple
=
pBlkKeyInfo
->
pKeyTuple
;
int32_t
i
=
0
;
...
...
source/libs/scalar/src/filter.c
浏览文件 @
4e8f3db5
...
...
@@ -2059,7 +2059,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t
}
if
(
colIdxi
>
1
)
{
qs
ort
(
colIdx
,
colIdxi
,
sizeof
(
uint32_t
),
getComparFunc
(
TSDB_DATA_TYPE_USMALLINT
,
0
));
taosS
ort
(
colIdx
,
colIdxi
,
sizeof
(
uint32_t
),
getComparFunc
(
TSDB_DATA_TYPE_USMALLINT
,
0
));
}
for
(
uint32_t
l
=
0
;
l
<
colIdxi
;
++
l
)
{
...
...
@@ -2294,7 +2294,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR
return
TSDB_CODE_SUCCESS
;
}
qs
ort
(
gRes
,
*
gResNum
,
POINTER_BYTES
,
filterCompareGroupCtx
);
taosS
ort
(
gRes
,
*
gResNum
,
POINTER_BYTES
,
filterCompareGroupCtx
);
int32_t
pEnd
=
0
,
cStart
=
0
,
cEnd
=
0
;
uint32_t
pColNum
=
0
,
cColNum
=
0
;
...
...
source/os/src/osMath.c
0 → 100644
浏览文件 @
4e8f3db5
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define ALLOW_FORBID_FUNC
#define _DEFAULT_SOURCE
#include "os.h"
#ifdef WINDOWS
void
swapStr
(
char
*
j
,
char
*
J
,
int
width
)
{
int
i
;
char
tmp
;
for
(
i
=
0
;
i
<
width
;
i
++
)
{
tmp
=
*
j
;
*
j
=
*
J
;
*
J
=
tmp
;
j
++
;
J
++
;
}
}
#endif
void
taosSort
(
void
*
arr
,
int64_t
sz
,
int64_t
width
,
__compar_fn_t
compar
)
{
#ifdef WINDOWS
int64_t
i
,
j
;
for
(
i
=
0
;
i
<
sz
-
1
;
i
++
)
{
for
(
j
=
0
;
j
<
sz
-
1
-
i
;
j
++
)
{
if
(
compar
((
char
*
)
arr
+
j
*
width
,
(
char
*
)
arr
+
(
j
+
1
)
*
width
)
>
0
.
00
)
{
swapStr
((
char
*
)
arr
+
j
*
width
,
(
char
*
)
arr
+
(
j
+
1
)
*
width
,
width
);
}
}
}
#else
qsort
(
arr
,
sz
,
width
,
compar
);
#endif
}
source/util/src/tarray.c
浏览文件 @
4e8f3db5
...
...
@@ -373,7 +373,7 @@ void taosArraySort(SArray* pArray, __compar_fn_t compar) {
assert
(
pArray
!=
NULL
);
assert
(
compar
!=
NULL
);
qs
ort
(
pArray
->
pData
,
pArray
->
size
,
pArray
->
elemSize
,
compar
);
taosS
ort
(
pArray
->
pData
,
pArray
->
size
,
pArray
->
elemSize
,
compar
);
}
void
*
taosArraySearch
(
const
SArray
*
pArray
,
const
void
*
key
,
__compar_fn_t
comparFn
,
int32_t
flags
)
{
...
...
@@ -390,7 +390,7 @@ int32_t taosArraySearchIdx(const SArray* pArray, const void* key, __compar_fn_t
void
taosArraySortString
(
SArray
*
pArray
,
__compar_fn_t
comparFn
)
{
assert
(
pArray
!=
NULL
);
qs
ort
(
pArray
->
pData
,
pArray
->
size
,
pArray
->
elemSize
,
comparFn
);
taosS
ort
(
pArray
->
pData
,
pArray
->
size
,
pArray
->
elemSize
,
comparFn
);
}
char
*
taosArraySearchString
(
const
SArray
*
pArray
,
const
char
*
key
,
__compar_fn_t
comparFn
,
int32_t
flags
)
{
...
...
source/util/src/tdigest.c
浏览文件 @
4e8f3db5
...
...
@@ -124,7 +124,7 @@ void tdigestCompress(TDigest *t) {
t
->
num_buffered_pts
=
0
;
t
->
total_weight
+=
unmerged_weight
;
qs
ort
(
unmerged_centroids
,
num_unmerged
,
sizeof
(
SCentroid
),
cmpCentroid
);
taosS
ort
(
unmerged_centroids
,
num_unmerged
,
sizeof
(
SCentroid
),
cmpCentroid
);
memset
(
&
args
,
0
,
sizeof
(
SMergeArgs
));
args
.
centroids
=
(
SCentroid
*
)
taosMemoryMalloc
((
size_t
)(
sizeof
(
SCentroid
)
*
t
->
size
));
memset
(
args
.
centroids
,
0
,
(
size_t
)(
sizeof
(
SCentroid
)
*
t
->
size
));
...
...
source/util/src/terror.c
浏览文件 @
4e8f3db5
...
...
@@ -614,7 +614,7 @@ static int32_t taosCompareTaosError(const void* a, const void* b) {
static
TdThreadOnce
tsErrorInit
=
PTHREAD_ONCE_INIT
;
static
void
tsSortError
(
void
)
{
qs
ort
(
errors
,
sizeof
(
errors
)
/
sizeof
(
errors
[
0
]),
sizeof
(
errors
[
0
]),
taosCompareTaosError
);
taosS
ort
(
errors
,
sizeof
(
errors
)
/
sizeof
(
errors
[
0
]),
sizeof
(
errors
[
0
]),
taosCompareTaosError
);
}
const
char
*
tstrerror
(
int32_t
err
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录