Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿拉亮
soar
提交
027e992f
S
soar
项目概览
阿拉亮
/
soar
与 Fork 源项目一致
Fork自
Xiaomi / soar
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
soar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
027e992f
编写于
3月 22, 2021
作者:
martianzhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FIXME: SUPPORT VIEW
上级
16f00375
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
28 deletion
+33
-28
database/mysql.go
database/mysql.go
+5
-2
database/sampling.go
database/sampling.go
+6
-2
database/show.go
database/show.go
+6
-6
database/show_test.go
database/show_test.go
+9
-10
env/env_test.go
env/env_test.go
+7
-8
未找到文件。
database/mysql.go
浏览文件 @
027e992f
...
...
@@ -189,11 +189,14 @@ func (db *Connector) ColumnCardinality(tb, col string) float64 {
common
.
Log
.
Debug
(
"(db *Connector) ColumnCardinality() No table status: %s"
,
tb
)
return
1
}
rowTotal
:=
tbStatus
.
Rows
[
0
]
.
Rows
if
rowTotal
==
0
{
rowTotal
,
err
:=
strconv
.
ParseUint
(
string
(
tbStatus
.
Rows
[
0
]
.
Rows
),
10
,
64
)
if
rowTotal
==
0
||
err
!=
nil
{
if
common
.
Config
.
Sampling
{
common
.
Log
.
Debug
(
"ColumnCardinality, %s rowTotal == 0"
,
tb
)
}
if
err
!=
nil
{
common
.
Log
.
Error
(
"ColumnCardinality, Error:"
,
err
.
Error
())
}
return
1
}
...
...
database/sampling.go
浏览文件 @
027e992f
...
...
@@ -19,6 +19,7 @@ package database
import
(
"database/sql"
"fmt"
"strconv"
"strings"
"time"
...
...
@@ -74,9 +75,12 @@ func (db *Connector) SamplingData(onlineConn *Connector, tables ...string) error
return
nil
}
tableRows
:=
tableStatus
.
Rows
[
0
]
.
Rows
if
tableRows
==
0
{
tableRows
,
err
:=
strconv
.
ParseUint
(
string
(
tableStatus
.
Rows
[
0
]
.
Rows
),
10
,
64
)
if
tableRows
==
0
||
err
!=
nil
{
common
.
Log
.
Info
(
"SamplingData, Table %s with no data, stop sampling"
,
table
)
if
err
!=
nil
{
common
.
Log
.
Error
(
"SamplingData, Error: "
,
err
.
Error
())
}
return
nil
}
...
...
database/show.go
浏览文件 @
027e992f
...
...
@@ -41,25 +41,25 @@ type tableStatusRow struct {
Engine
[]
byte
// 该表使用的存储引擎
Version
[]
byte
// 该表的 .frm 文件版本号
RowFormat
[]
byte
// 该表使用的行存储格式
Rows
uint64
// 表行数, InnoDB 引擎中为预估值,甚至可能会有40%~50%的数值偏差
AvgRowLength
uint64
// 平均行长度
Rows
[]
byte
// 表行数, InnoDB 引擎中为预估值,甚至可能会有40%~50%的数值偏差
AvgRowLength
[]
byte
// 平均行长度
// MyISAM: Data_length 为数据文件的大小,单位为 bytes
// InnoDB: Data_length 为聚簇索引分配的近似内存量,单位为 bytes, 计算方式为聚簇索引数量乘以 InnoDB 页面大小
// 其他不同的存储引擎中该值的意义可能不尽相同
DataLength
uint64
DataLength
[]
byte
// MyISAM: Max_data_length 为数据文件长度的最大值。这是在给定使用的数据指针大小的情况下,可以存储在表中的数据的最大字节数
// InnoDB: 未使用
// 其他不同的存储引擎中该值的意义可能不尽相同
MaxDataLength
uint64
MaxDataLength
[]
byte
// MyISAM: Index_length 为 index 文件的大小,单位为 bytes
// InnoDB: Index_length 为非聚簇索引分配的近似内存量,单位为 bytes,计算方式为非聚簇索引数量乘以 InnoDB 页面大小
// 其他不同的存储引擎中该值的意义可能不尽相同
IndexLength
uint64
IndexLength
[]
byte
DataFree
uint64
// 已分配但未使用的字节数
DataFree
[]
byte
// 已分配但未使用的字节数
AutoIncrement
[]
byte
// 下一个自增值
CreateTime
[]
byte
// 创建时间
UpdateTime
[]
byte
// 最近一次更新时间,该值不准确
...
...
database/show_test.go
浏览文件 @
027e992f
...
...
@@ -38,16 +38,15 @@ func TestShowTableStatus(t *testing.T) {
}
pretty
.
Println
(
ts
)
// FIXME: too much column NULL ABLE
//connTest.Database = "sakila"
//ts, err = connTest.ShowTableStatus("actor_info")
//if err != nil {
// t.Error("ShowTableStatus Error: ", err)
//}
//if string(ts.Rows[0].Comment) != "VIEW" {
// t.Error("actor_info should be VIEW", ts.Rows[0].Comment)
//}
//pretty.Println(ts)
connTest
.
Database
=
"sakila"
ts
,
err
=
connTest
.
ShowTableStatus
(
"actor_info"
)
if
err
!=
nil
{
t
.
Error
(
"ShowTableStatus Error: "
,
err
)
}
if
string
(
ts
.
Rows
[
0
]
.
Comment
)
!=
"VIEW"
{
t
.
Error
(
"actor_info should be VIEW"
,
ts
.
Rows
[
0
]
.
Comment
)
}
pretty
.
Println
(
ts
)
connTest
.
Database
=
orgDatabase
common
.
Log
.
Debug
(
"Exiting function: %s"
,
common
.
GetFunctionName
())
}
...
...
env/env_test.go
浏览文件 @
027e992f
...
...
@@ -259,14 +259,13 @@ func TestCreateTable(t *testing.T) {
"rental"
,
"staff"
,
"store"
,
// FIXME: SUPPORT VIEW
//"staff_list",
//"customer_list",
//"actor_info",
//"sales_by_film_category",
//"sales_by_store",
//"nicer_but_slower_film_list",
//"film_list",
"staff_list"
,
"customer_list"
,
"actor_info"
,
"sales_by_film_category"
,
"sales_by_store"
,
"nicer_but_slower_film_list"
,
"film_list"
,
}
for
_
,
table
:=
range
tables
{
err
:=
vEnv
.
createTable
(
rEnv
,
table
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录