Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
129a021d
提交
129a021d
authored
16 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
new experimental page store
上级
f1c816b8
master
noel-pr1
plus33-master
pr/267
stumc-Issue#576
version-1.1.x
version-1.4.198
version-1.4.197
version-1.4.196
version-1.4.195
version-1.4.194
version-1.4.193
version-1.4.192
version-1.4.191
version-1.4.190
version-1.4.188
version-1.4.187
version-1.4.186
version-1.4.185
version-1.4.184
version-1.4.183
version-1.4.182
version-1.4.181
version-1.4.178
version-1.4.177
version-1.3
version-1.2
version-1.1
version-1.0
无相关合并请求
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
104 行增加
和
18 行删除
+104
-18
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+1
-1
BaseIndex.java
h2/src/main/org/h2/index/BaseIndex.java
+0
-5
BtreeIndex.java
h2/src/main/org/h2/index/BtreeIndex.java
+9
-0
FunctionIndex.java
h2/src/main/org/h2/index/FunctionIndex.java
+9
-1
HashIndex.java
h2/src/main/org/h2/index/HashIndex.java
+9
-0
Index.java
h2/src/main/org/h2/index/Index.java
+7
-0
LinkedIndex.java
h2/src/main/org/h2/index/LinkedIndex.java
+9
-0
MetaIndex.java
h2/src/main/org/h2/index/MetaIndex.java
+10
-2
MultiVersionIndex.java
h2/src/main/org/h2/index/MultiVersionIndex.java
+4
-0
PageDataLeaf.java
h2/src/main/org/h2/index/PageDataLeaf.java
+0
-4
PageScanIndex.java
h2/src/main/org/h2/index/PageScanIndex.java
+12
-1
RangeIndex.java
h2/src/main/org/h2/index/RangeIndex.java
+8
-0
ScanIndex.java
h2/src/main/org/h2/index/ScanIndex.java
+8
-3
TreeIndex.java
h2/src/main/org/h2/index/TreeIndex.java
+10
-1
ViewIndex.java
h2/src/main/org/h2/index/ViewIndex.java
+8
-0
没有找到文件。
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
129a021d
...
...
@@ -229,7 +229,7 @@ public class ScriptCommand extends ScriptBase {
add
(
sql
,
false
);
if
(
Table
.
TABLE
.
equals
(
tableType
))
{
if
(
table
.
canGetRowCount
())
{
String
rowcount
=
"-- "
+
table
.
getRowCount
(
session
)
+
" =
SELECT COUNT(*) FROM "
String
rowcount
=
"-- "
+
table
.
getRowCount
Approximation
()
+
" +/-
SELECT COUNT(*) FROM "
+
table
.
getSQL
();
add
(
rowcount
,
false
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/BaseIndex.java
浏览文件 @
129a021d
...
...
@@ -36,7 +36,6 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
protected
int
[]
columnIds
;
protected
Table
table
;
protected
IndexType
indexType
;
protected
long
rowCount
;
protected
boolean
isMultiVersion
;
/**
...
...
@@ -179,10 +178,6 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
throw
Message
.
getInternalError
();
}
public
long
getRowCount
(
Session
session
)
{
return
rowCount
;
}
public
int
getLookupCost
(
long
rowCount
)
{
return
2
;
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/BtreeIndex.java
浏览文件 @
129a021d
...
...
@@ -54,6 +54,7 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
private
boolean
needRebuild
;
private
int
headPos
;
private
long
lastChange
;
private
long
rowCount
;
/**
* Create a new b tree index with the given properties. If the index does
...
...
@@ -424,4 +425,12 @@ public class BtreeIndex extends BaseIndex implements RecordReader {
return
cursor
;
}
public
long
getRowCount
(
Session
session
)
{
return
rowCount
;
}
public
long
getRowCountApproximation
()
{
return
rowCount
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/FunctionIndex.java
浏览文件 @
129a021d
...
...
@@ -56,7 +56,7 @@ public class FunctionIndex extends BaseIndex {
}
long
expectedRows
;
if
(
functionTable
.
canGetRowCount
())
{
expectedRows
=
functionTable
.
getRowCount
(
session
);
expectedRows
=
functionTable
.
getRowCount
Approximation
(
);
}
else
{
expectedRows
=
SysProperties
.
ESTIMATED_FUNCTION_TABLE_ROWS
;
}
...
...
@@ -87,4 +87,12 @@ public class FunctionIndex extends BaseIndex {
throw
Message
.
getUnsupportedException
();
}
public
long
getRowCount
(
Session
session
)
{
return
functionTable
.
getRowCount
(
session
);
}
public
long
getRowCountApproximation
()
{
return
functionTable
.
getRowCountApproximation
();
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/HashIndex.java
浏览文件 @
129a021d
...
...
@@ -29,6 +29,7 @@ public class HashIndex extends BaseIndex {
private
ValueHashMap
rows
;
private
IntIntHashMap
intMap
;
private
TableData
tableData
;
private
long
rowCount
;
public
HashIndex
(
TableData
table
,
int
id
,
String
indexName
,
IndexColumn
[]
columns
,
IndexType
indexType
)
{
initBaseIndex
(
table
,
id
,
indexName
,
columns
,
indexType
);
...
...
@@ -152,4 +153,12 @@ public class HashIndex extends BaseIndex {
throw
Message
.
getUnsupportedException
();
}
public
long
getRowCount
(
Session
session
)
{
return
rowCount
;
}
public
long
getRowCountApproximation
()
{
return
rowCount
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/Index.java
浏览文件 @
129a021d
...
...
@@ -150,6 +150,13 @@ public interface Index extends SchemaObject {
* @return the row count
*/
long
getRowCount
(
Session
session
);
/**
* Get the approximated row count for this table.
*
* @return the approximated row count
*/
long
getRowCountApproximation
();
/**
* Estimate the cost required to search a number of rows.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/LinkedIndex.java
浏览文件 @
129a021d
...
...
@@ -30,6 +30,7 @@ public class LinkedIndex extends BaseIndex {
private
TableLink
link
;
private
String
targetTableName
;
private
long
rowCount
;
public
LinkedIndex
(
TableLink
table
,
int
id
,
IndexColumn
[]
columns
,
IndexType
indexType
)
{
initBaseIndex
(
table
,
id
,
null
,
columns
,
indexType
);
...
...
@@ -285,4 +286,12 @@ public class LinkedIndex extends BaseIndex {
return
Message
.
getSQLException
(
ErrorCode
.
ERROR_ACCESSING_LINKED_TABLE_2
,
new
String
[]
{
sql
,
e
.
toString
()
},
e
);
}
public
long
getRowCount
(
Session
session
)
{
return
rowCount
;
}
public
long
getRowCountApproximation
()
{
return
rowCount
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/MetaIndex.java
浏览文件 @
129a021d
...
...
@@ -49,9 +49,9 @@ public class MetaIndex extends BaseIndex {
public
double
getCost
(
Session
session
,
int
[]
masks
)
{
if
(
scan
)
{
return
10
000
;
return
10
*
MetaTable
.
ROW_COUNT_APPROXIMATION
;
}
return
getCostRangeIndex
(
masks
,
1000
);
return
getCostRangeIndex
(
masks
,
MetaTable
.
ROW_COUNT_APPROXIMATION
);
}
public
void
truncate
(
Session
session
)
throws
SQLException
{
...
...
@@ -90,4 +90,12 @@ public class MetaIndex extends BaseIndex {
throw
Message
.
getUnsupportedException
();
}
public
long
getRowCount
(
Session
session
)
{
return
MetaTable
.
ROW_COUNT_APPROXIMATION
;
}
public
long
getRowCountApproximation
()
{
return
MetaTable
.
ROW_COUNT_APPROXIMATION
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/MultiVersionIndex.java
浏览文件 @
129a021d
...
...
@@ -308,4 +308,8 @@ public class MultiVersionIndex implements Index {
base
.
setTemporary
(
temporary
);
}
public
long
getRowCountApproximation
()
{
return
base
.
getRowCountApproximation
();
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageDataLeaf.java
浏览文件 @
129a021d
...
...
@@ -240,10 +240,6 @@ class PageDataLeaf extends PageData {
* @return the row
*/
Row
getRowAt
(
int
at
)
throws
SQLException
{
if
(
at
>=
rows
.
length
)
{
int
test
;
System
.
out
.
println
(
"test"
);
}
Row
r
=
rows
[
at
];
if
(
r
==
null
)
{
if
(
firstOverflowPageId
!=
0
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageScanIndex.java
浏览文件 @
129a021d
...
...
@@ -38,6 +38,8 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
// TODO use an undo log and maybe redo log (for performance)
// TODO file position, content checksums
private
int
nextKey
;
private
long
rowCount
;
private
long
rowCountApproximation
;
public
PageScanIndex
(
TableData
table
,
int
id
,
IndexColumn
[]
columns
,
IndexType
indexType
,
int
headPos
)
throws
SQLException
{
initBaseIndex
(
table
,
id
,
table
.
getName
()
+
"_TABLE_SCAN"
,
columns
,
indexType
);
...
...
@@ -137,7 +139,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
}
public
double
getCost
(
Session
session
,
int
[]
masks
)
throws
SQLException
{
long
cost
=
10
*
tableData
.
getRowCount
(
session
)
+
Constants
.
COST_ROW_OFFSET
;
long
cost
=
10
*
tableData
.
getRowCount
Approximation
(
)
+
Constants
.
COST_ROW_OFFSET
;
return
cost
;
}
...
...
@@ -192,4 +194,13 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
return
tableData
.
readRow
(
data
);
}
public
long
getRowCountApproximation
()
{
return
rowCountApproximation
;
}
public
long
getRowCount
(
Session
session
)
{
int
todo
;
return
rowCount
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/RangeIndex.java
浏览文件 @
129a021d
...
...
@@ -81,4 +81,12 @@ public class RangeIndex extends BaseIndex {
return
new
RangeCursor
(
pos
,
pos
);
}
public
long
getRowCount
(
Session
session
)
{
return
rangeTable
.
getRowCountApproximation
();
}
public
long
getRowCountApproximation
()
{
return
rangeTable
.
getRowCountApproximation
();
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/ScanIndex.java
浏览文件 @
129a021d
...
...
@@ -41,6 +41,7 @@ public class ScanIndex extends BaseIndex implements RowIndex {
private
int
rowCountDiff
;
private
HashMap
sessionRowCount
;
private
HashSet
delta
;
private
long
rowCount
;
public
ScanIndex
(
TableData
table
,
int
id
,
IndexColumn
[]
columns
,
IndexType
indexType
)
{
initBaseIndex
(
table
,
id
,
table
.
getName
()
+
"_TABLE_SCAN"
,
columns
,
indexType
);
...
...
@@ -201,7 +202,7 @@ public class ScanIndex extends BaseIndex implements RowIndex {
}
public
double
getCost
(
Session
session
,
int
[]
masks
)
{
long
cost
=
tableData
.
getRowCount
(
session
)
+
Constants
.
COST_ROW_OFFSET
;
long
cost
=
tableData
.
getRowCount
Approximation
(
)
+
Constants
.
COST_ROW_OFFSET
;
if
(
storage
!=
null
)
{
cost
*=
10
;
}
...
...
@@ -212,11 +213,11 @@ public class ScanIndex extends BaseIndex implements RowIndex {
if
(
database
.
isMultiVersion
())
{
Integer
i
=
(
Integer
)
sessionRowCount
.
get
(
ObjectUtils
.
getInteger
(
session
.
getId
()));
long
count
=
i
==
null
?
0
:
i
.
intValue
();
count
+=
super
.
getRowCount
(
session
)
;
count
+=
rowCount
;
count
-=
rowCountDiff
;
return
count
;
}
return
super
.
getRowCount
(
session
)
;
return
rowCount
;
}
/**
...
...
@@ -277,4 +278,8 @@ public class ScanIndex extends BaseIndex implements RowIndex {
return
delta
==
null
?
Collections
.
EMPTY_LIST
.
iterator
()
:
delta
.
iterator
();
}
public
long
getRowCountApproximation
()
{
return
rowCount
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/TreeIndex.java
浏览文件 @
129a021d
...
...
@@ -25,6 +25,7 @@ public class TreeIndex extends BaseIndex {
private
TreeNode
root
;
private
TableData
tableData
;
private
long
rowCount
;
public
TreeIndex
(
TableData
table
,
int
id
,
String
indexName
,
IndexColumn
[]
columns
,
IndexType
indexType
)
{
initBaseIndex
(
table
,
id
,
indexName
,
columns
,
indexType
);
...
...
@@ -293,7 +294,7 @@ public class TreeIndex extends BaseIndex {
}
public
double
getCost
(
Session
session
,
int
[]
masks
)
{
return
getCostRangeIndex
(
masks
,
tableData
.
getRowCount
(
session
));
return
getCostRangeIndex
(
masks
,
tableData
.
getRowCount
Approximation
(
));
}
public
void
remove
(
Session
session
)
{
...
...
@@ -414,4 +415,12 @@ public class TreeIndex extends BaseIndex {
return
cursor
;
}
public
long
getRowCount
(
Session
session
)
{
return
rowCount
;
}
public
long
getRowCountApproximation
()
{
return
rowCount
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/ViewIndex.java
浏览文件 @
129a021d
...
...
@@ -265,4 +265,12 @@ public class ViewIndex extends BaseIndex {
this
.
recursive
=
value
;
}
public
long
getRowCount
(
Session
session
)
{
return
0
;
}
public
long
getRowCountApproximation
()
{
return
0
;
}
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论