Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
buyaopa
TDengine
提交
f3c92ad3
T
TDengine
项目概览
buyaopa
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
3
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,发现更多精彩内容 >>
提交
f3c92ad3
编写于
8月 31, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1206]
上级
50e73ebb
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
452 addition
and
711 deletion
+452
-711
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+3
-15
src/query/inc/qPercentile.h
src/query/inc/qPercentile.h
+31
-33
src/query/src/qPercentile.c
src/query/src/qPercentile.c
+418
-663
未找到文件。
src/client/src/tscFunctionImpl.c
浏览文件 @
f3c92ad3
...
...
@@ -2422,24 +2422,14 @@ static void top_bottom_func_finalizer(SQLFunctionCtx *pCtx) {
///////////////////////////////////////////////////////////////////////////////////////////////
static
bool
percentile_function_setup
(
SQLFunctionCtx
*
pCtx
)
{
const
int32_t
MAX_AVAILABLE_BUFFER_SIZE
=
1
<<
20
;
// 1MB
const
int32_t
NUMOFCOLS
=
1
;
if
(
!
function_setup
(
pCtx
))
{
return
false
;
}
SResultInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SSchema
field
[
1
]
=
{
{
(
uint8_t
)
pCtx
->
inputType
,
"dummyCol"
,
0
,
pCtx
->
inputBytes
}
};
SColumnModel
*
pModel
=
createColumnModel
(
field
,
1
,
1000
);
int32_t
orderIdx
=
0
;
// tOrderDesc object
tOrderDescriptor
*
pDesc
=
tOrderDesCreate
(
&
orderIdx
,
NUMOFCOLS
,
pModel
,
TSDB_ORDER_DESC
);
((
SPercentileInfo
*
)(
pResInfo
->
interResultBuf
))
->
pMemBucket
=
tMemBucketCreate
(
1024
,
MAX_AVAILABLE_BUFFER_SIZE
,
pCtx
->
inputBytes
,
pCtx
->
inputType
,
pDesc
);
tMemBucketCreate
(
pCtx
->
inputBytes
,
pCtx
->
inputType
);
return
true
;
}
...
...
@@ -2485,15 +2475,13 @@ static void percentile_finalizer(SQLFunctionCtx *pCtx) {
SResultInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
tMemBucket
*
pMemBucket
=
((
SPercentileInfo
*
)
pResInfo
->
interResultBuf
)
->
pMemBucket
;
if
(
pMemBucket
->
numOfElems
>
0
)
{
// check for null
if
(
pMemBucket
->
total
>
0
)
{
// check for null
*
(
double
*
)
pCtx
->
aOutputBuf
=
getPercentile
(
pMemBucket
,
v
);
}
else
{
setNull
(
pCtx
->
aOutputBuf
,
pCtx
->
outputType
,
pCtx
->
outputBytes
);
}
tOrderDescDestroy
(
pMemBucket
->
pOrderDesc
);
tMemBucketDestroy
(
pMemBucket
);
doFinalizer
(
pCtx
);
}
...
...
src/query/inc/qPercentile.h
浏览文件 @
f3c92ad3
...
...
@@ -17,6 +17,8 @@
#define TDENGINE_QPERCENTILE_H
#include "qExtbuffer.h"
#include "qResultbuf.h"
#include "qTsbuf.h"
typedef
struct
MinMaxEntry
{
union
{
...
...
@@ -31,47 +33,43 @@ typedef struct MinMaxEntry {
};
}
MinMaxEntry
;
typedef
struct
tMemBucketSegment
{
int32_t
numOfSlots
;
MinMaxEntry
*
pBoundingEntries
;
tExtMemBuffer
**
pBuffer
;
}
tMemBucketSegment
;
typedef
struct
{
int32_t
size
;
int32_t
pageId
;
tFilePage
*
data
;
}
SSlotInfo
;
typedef
struct
tMemBucketSlot
{
SSlotInfo
info
;
MinMaxEntry
range
;
}
tMemBucketSlot
;
struct
tMemBucket
;
typedef
int32_t
(
*
__perc_hash_func_t
)(
struct
tMemBucket
*
pBucket
,
const
void
*
value
);
typedef
struct
tMemBucket
{
int16_t
numOfSegs
;
int16_t
nTotalSlots
;
int16_t
nSlotsOfSeg
;
int16_t
dataType
;
int16_t
nElemSize
;
int32_t
numOfElems
;
int32_t
nTotalBufferSize
;
int32_t
maxElemsCapacity
;
int32_t
pageSize
;
int16_t
numOfTotalPages
;
int16_t
numOfAvailPages
;
/* remain available buffer pages */
tMemBucketSegment
*
pSegs
;
tOrderDescriptor
*
pOrderDesc
;
MinMaxEntry
nRange
;
void
(
*
HashFunc
)(
struct
tMemBucket
*
pBucket
,
void
*
value
,
int16_t
*
segIdx
,
int16_t
*
slotIdx
);
int16_t
numOfSlots
;
int16_t
type
;
int16_t
bytes
;
int32_t
total
;
int32_t
elemPerPage
;
// number of elements for each object
int32_t
maxCapacity
;
// maximum allowed number of elements that can be sort directly to get the result
int32_t
bufPageSize
;
// disk page size
MinMaxEntry
range
;
// value range
int32_t
times
;
// count that has been checked for deciding the correct data value buckets.
__compar_fn_t
comparFn
;
tMemBucketSlot
*
pSlots
;
SDiskbasedResultBuf
*
pBuffer
;
__perc_hash_func_t
hashFunc
;
}
tMemBucket
;
tMemBucket
*
tMemBucketCreate
(
int32_t
totalSlots
,
int32_t
nBufferSize
,
int16_t
nElemSize
,
int16_t
dataType
,
tOrderDescriptor
*
pDesc
);
tMemBucket
*
tMemBucketCreate
(
int16_t
nElemSize
,
int16_t
dataType
);
void
tMemBucketDestroy
(
tMemBucket
*
pBucket
);
void
tMemBucketPut
(
tMemBucket
*
pBucket
,
void
*
data
,
int32_t
numOfRows
);
void
tMemBucketPut
(
tMemBucket
*
pBucket
,
const
void
*
data
,
size_t
size
);
double
getPercentile
(
tMemBucket
*
pMemBucket
,
double
percent
);
void
tBucketIntHash
(
tMemBucket
*
pBucket
,
void
*
value
,
int16_t
*
segIdx
,
int16_t
*
slotIdx
);
void
tBucketDoubleHash
(
tMemBucket
*
pBucket
,
void
*
value
,
int16_t
*
segIdx
,
int16_t
*
slotIdx
);
#endif // TDENGINE_QPERCENTILE_H
src/query/src/qPercentile.c
浏览文件 @
f3c92ad3
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录