Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e99d088f
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e99d088f
编写于
6月 10, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
85d4ee60
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
52 addition
and
27 deletion
+52
-27
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+52
-27
未找到文件。
source/libs/function/src/builtinsimpl.c
浏览文件 @
e99d088f
...
...
@@ -4527,36 +4527,50 @@ int32_t tDeserializeBlockDistInfo(void* buf, int32_t bufLen, STableBlockDistInfo
int32_t
blockDistFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STableBlockDistInfo
info
=
{
0
};
char
*
pData
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
0
);
int32_t
row
=
0
;
STableBlockDistInfo
info
=
{
0
};
tDeserializeBlockDistInfo
(
varDataVal
(
pData
),
varDataLen
(
pData
),
&
info
);
int32_t
step
=
(
info
.
defMaxRows
-
info
.
defMinRows
)
/
50
;
char
st
[
256
]
=
{
0
};
int32_t
len
=
sprintf
(
st
+
VARSTR_HEADER_SIZE
,
"Blocks=[%d] Size=[%.3fKb] Average_Block_size=[%.3fKb] Compression_Ratio=[%.3f]"
,
info
.
numOfBlocks
,
info
.
totalSize
/
1024
.
0
,
info
.
totalSize
/
(
info
.
numOfBlocks
*
1024
.
0
),
info
.
totalSize
/
(
info
.
totalRows
*
info
.
rowSize
*
1
.
0
)
);
varDataSetLen
(
st
,
len
);
colDataAppend
(
pColInfo
,
row
++
,
st
,
false
);
// convert to string results
char
st
[
128
]
=
{
0
};
sprintf
(
st
,
"Blocks=[%d] Size=[%.3fKb] Average_Block_size=[%.3fKb] Compression_Ratio=[%.3f]"
,
info
.
numOfBlock
s
,
info
.
totalSize
/
1024
.
0
,
info
.
totalSize
/
(
info
.
numOfBlocks
*
1024
.
0
)
,
info
.
totalSize
/
(
info
.
totalRows
*
info
.
rowSize
*
1
.
0
)
);
len
=
sprintf
(
st
+
VARSTR_HEADER_SIZE
,
"Total_Rows=[%ld] MinRows=[%d] MaxRows=[%d] Averge_Rows=[%ld] Inmem_Rows=[%d]"
,
info
.
totalRows
,
info
.
minRow
s
,
info
.
maxRows
,
info
.
totalRows
/
info
.
numOfBlocks
,
info
.
numOfInmemRows
);
sprintf
(
st
,
"Total_Rows=[%"
PRId64
"] MinRows=[%d] MaxRows=[%d] Averge_Rows=[%"
PRId64
"] Inmem_Rows=[%d]"
,
info
.
totalRows
,
info
.
minRows
,
info
.
maxRows
,
info
.
totalRows
/
info
.
numOfBlocks
,
info
.
numOfInmemRows
);
varDataSetLen
(
st
,
len
);
colDataAppend
(
pColInfo
,
row
++
,
st
,
false
);
sprintf
(
st
,
"Total_Tables=[%d] Total_Files=[%d] Total_Vgroups=[%d]"
,
info
.
numOfTables
,
info
.
numOfFiles
,
0
);
sprintf
(
st
,
"----------------------------------------------------------------------"
);
len
=
sprintf
(
st
+
VARSTR_HEADER_SIZE
,
"Total_Tables=[%d] Total_Files=[%d] Total_Vgroups=[%d]"
,
info
.
numOfTables
,
info
.
numOfFiles
,
0
);
varDataSetLen
(
st
,
len
);
colDataAppend
(
pColInfo
,
row
++
,
st
,
false
);
len
=
sprintf
(
st
+
VARSTR_HEADER_SIZE
,
"--------------------------------------------------------------------------------"
);
varDataSetLen
(
st
,
len
);
colDataAppend
(
pColInfo
,
row
++
,
st
,
false
);
int32_t
maxVal
=
0
;
int32_t
minVal
=
INT32_MAX
;
for
(
int32_t
i
=
0
;
i
<
100
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
sizeof
(
info
.
blockRowsHisto
)
/
sizeof
(
info
.
blockRowsHisto
[
0
])
;
++
i
)
{
if
(
maxVal
<
info
.
blockRowsHisto
[
i
])
{
maxVal
=
info
.
blockRowsHisto
[
i
];
}
...
...
@@ -4566,17 +4580,28 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
}
}
for
(
int32_t
i
=
0
;
i
<
100
;
++
i
)
{
int32_t
len
=
sprintf
(
st
,
"%d |"
,
info
.
defMinRows
+
step
);
int32_t
delta
=
maxVal
-
minVal
;
int32_t
step
=
delta
/
50
;
int32_t
numOfBuckets
=
sizeof
(
info
.
blockRowsHisto
)
/
sizeof
(
info
.
blockRowsHisto
[
0
]);
int32_t
bucketRange
=
(
info
.
maxRows
-
info
.
minRows
)
/
numOfBuckets
;
for
(
int32_t
i
=
0
;
i
<
20
;
++
i
)
{
len
+=
sprintf
(
st
+
VARSTR_HEADER_SIZE
,
"%04d |"
,
info
.
defMinRows
+
bucketRange
*
(
i
+
1
));
int32_t
num
=
(
info
.
blockRowsHisto
[
i
]
+
step
-
1
)
/
step
;
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
int32_t
x
=
sprintf
(
st
+
len
,
"%c"
,
'|'
);
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
int32_t
x
=
sprintf
(
st
+
VARSTR_HEADER_SIZE
+
len
,
"%c"
,
'|'
);
len
+=
x
;
}
double
v
=
info
.
blockRowsHisto
[
i
]
*
1
.
0
/
info
.
numOfBlocks
;
sprintf
(
st
+
len
,
" %d (%.3f)
\n
"
,
info
.
blockRowsHisto
[
i
],
v
);
double
v
=
info
.
blockRowsHisto
[
i
]
*
100
.
0
/
info
.
numOfBlocks
;
len
+=
sprintf
(
st
+
VARSTR_HEADER_SIZE
+
len
,
" %d (%.3f%c)"
,
info
.
blockRowsHisto
[
i
],
v
,
'%'
);
printf
(
"%s
\n
"
,
st
);
varDataSetLen
(
st
,
len
);
colDataAppend
(
pColInfo
,
row
++
,
st
,
false
);
}
return
100
;
return
row
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录