Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
91926786
提交
91926786
authored
4月 09, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Formatting / javadocs
上级
d95318e6
显示空白字符变更
内嵌
并排
正在显示
25 个修改的文件
包含
342 行增加
和
271 行删除
+342
-271
Parser.java
h2/src/main/org/h2/command/Parser.java
+1
-1
Select.java
h2/src/main/org/h2/command/dml/Select.java
+2
-2
SetTypes.java
h2/src/main/org/h2/command/dml/SetTypes.java
+1
-1
Mode.java
h2/src/main/org/h2/engine/Mode.java
+2
-2
Function.java
h2/src/main/org/h2/expression/Function.java
+1
-1
BaseIndex.java
h2/src/main/org/h2/index/BaseIndex.java
+6
-3
Index.java
h2/src/main/org/h2/index/Index.java
+1
-0
Chunk.java
h2/src/main/org/h2/mvstore/Chunk.java
+1
-1
DataUtils.java
h2/src/main/org/h2/mvstore/DataUtils.java
+1
-1
FreeSpaceList.java
h2/src/main/org/h2/mvstore/FreeSpaceList.java
+208
-208
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+1
-1
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+6
-6
Page.java
h2/src/main/org/h2/mvstore/Page.java
+1
-1
MVPrimaryIndex.java
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
+1
-1
MVTable.java
h2/src/main/org/h2/mvstore/db/MVTable.java
+2
-2
MVTableEngine.java
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
+1
-1
TransactionStore.java
h2/src/main/org/h2/mvstore/db/TransactionStore.java
+72
-14
Table.java
h2/src/main/org/h2/table/Table.java
+1
-0
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+1
-1
CompareMode.java
h2/src/main/org/h2/value/CompareMode.java
+9
-6
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+1
-1
TestCases.java
h2/src/test/org/h2/test/db/TestCases.java
+4
-4
TestCompatibility.java
h2/src/test/org/h2/test/db/TestCompatibility.java
+1
-1
TestFunctions.java
h2/src/test/org/h2/test/db/TestFunctions.java
+7
-7
TestOptimizations.java
h2/src/test/org/h2/test/db/TestOptimizations.java
+10
-5
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
91926786
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
91926786
...
@@ -1273,7 +1273,7 @@ public class Select extends Query {
...
@@ -1273,7 +1273,7 @@ public class Select extends Query {
return
false
;
return
false
;
}
}
public
SortOrder
prepare
Order
()
{
public
SortOrder
getSort
Order
()
{
return
sort
;
return
sort
;
}
}
...
...
h2/src/main/org/h2/command/dml/SetTypes.java
浏览文件 @
91926786
h2/src/main/org/h2/engine/Mode.java
浏览文件 @
91926786
h2/src/main/org/h2/expression/Function.java
浏览文件 @
91926786
h2/src/main/org/h2/index/BaseIndex.java
浏览文件 @
91926786
...
@@ -124,6 +124,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
...
@@ -124,6 +124,7 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
*
*
* @param masks the search mask
* @param masks the search mask
* @param rowCount the number of rows in the index
* @param rowCount the number of rows in the index
* @param sortOrder the sort order
* @return the estimated cost
* @return the estimated cost
*/
*/
protected
long
getCostRangeIndex
(
int
[]
masks
,
long
rowCount
,
SortOrder
sortOrder
)
{
protected
long
getCostRangeIndex
(
int
[]
masks
,
long
rowCount
,
SortOrder
sortOrder
)
{
...
@@ -163,8 +164,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
...
@@ -163,8 +164,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
break
;
break
;
}
}
}
}
//
If the query ORDER BY clause matches the ordering of this index, it will be cheaper
//
if the ORDER BY clause matches the ordering of this index,
//
than another index, so adjust the cost accordingly.
//
it will be cheaper than another index, so adjust the cost accordingly
if
(
sortOrder
!=
null
)
{
if
(
sortOrder
!=
null
)
{
int
[]
columnIndexes
=
new
int
[
indexColumns
.
length
];
int
[]
columnIndexes
=
new
int
[
indexColumns
.
length
];
int
[]
columnSortTypes
=
new
int
[
indexColumns
.
length
];
int
[]
columnSortTypes
=
new
int
[
indexColumns
.
length
];
...
@@ -187,7 +188,9 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
...
@@ -187,7 +188,9 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
coveringCount
++;
coveringCount
++;
}
}
if
(
sortOrderMatches
)
{
if
(
sortOrderMatches
)
{
// "coveringCount" makes sure that when we have two or more covering indexes, we choose the one that covers more
// "coveringCount" makes sure that when we have two
// or more covering indexes, we choose the one
// that covers more
cost
-=
coveringCount
;
cost
-=
coveringCount
;
}
}
}
}
...
...
h2/src/main/org/h2/index/Index.java
浏览文件 @
91926786
...
@@ -80,6 +80,7 @@ public interface Index extends SchemaObject {
...
@@ -80,6 +80,7 @@ public interface Index extends SchemaObject {
* @param session the session
* @param session the session
* @param masks per-column comparison bit masks, null means 'always false',
* @param masks per-column comparison bit masks, null means 'always false',
* see constants in IndexCondition
* see constants in IndexCondition
* @param sortOrder the sort order
* @return the estimated cost
* @return the estimated cost
*/
*/
double
getCost
(
Session
session
,
int
[]
masks
,
SortOrder
sortOrder
);
double
getCost
(
Session
session
,
int
[]
masks
,
SortOrder
sortOrder
);
...
...
h2/src/main/org/h2/mvstore/Chunk.java
浏览文件 @
91926786
h2/src/main/org/h2/mvstore/DataUtils.java
浏览文件 @
91926786
h2/src/main/org/h2/mvstore/FreeSpaceList.java
浏览文件 @
91926786
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
91926786
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
91926786
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
91926786
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
浏览文件 @
91926786
h2/src/main/org/h2/mvstore/db/MVTable.java
浏览文件 @
91926786
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
浏览文件 @
91926786
h2/src/main/org/h2/mvstore/db/TransactionStore.java
浏览文件 @
91926786
...
@@ -159,7 +159,7 @@ public class TransactionStore {
...
@@ -159,7 +159,7 @@ public class TransactionStore {
return
new
Transaction
(
this
,
transactionId
,
status
,
null
,
0
);
return
new
Transaction
(
this
,
transactionId
,
status
,
null
,
0
);
}
}
void
storeTransaction
(
Transaction
t
)
{
private
void
storeTransaction
(
Transaction
t
)
{
long
transactionId
=
t
.
getId
();
long
transactionId
=
t
.
getId
();
if
(
openTransactions
.
containsKey
(
transactionId
))
{
if
(
openTransactions
.
containsKey
(
transactionId
))
{
return
;
return
;
...
@@ -812,6 +812,12 @@ public class TransactionStore {
...
@@ -812,6 +812,12 @@ public class TransactionStore {
return
get
(
key
,
mapWrite
);
return
get
(
key
,
mapWrite
);
}
}
/**
* Whether the map contains the key.
*
* @param key the key
* @return true if the map contains an entry for this key
*/
public
boolean
containsKey
(
K
key
)
{
public
boolean
containsKey
(
K
key
)
{
return
get
(
key
)
!=
null
;
return
get
(
key
)
!=
null
;
}
}
...
@@ -855,50 +861,102 @@ public class TransactionStore {
...
@@ -855,50 +861,102 @@ public class TransactionStore {
}
}
}
}
/**
* Rename the map.
*
* @param newMapName the new map name
*/
public
void
renameMap
(
String
newMapName
)
{
public
void
renameMap
(
String
newMapName
)
{
// TODO rename maps transactionally
// TODO rename maps transactionally
mapWrite
.
renameMap
(
newMapName
);
mapWrite
.
renameMap
(
newMapName
);
}
}
/**
* Check whether this map is closed.
*
* @return true if closed
*/
public
boolean
isClosed
()
{
public
boolean
isClosed
()
{
return
mapWrite
.
isClosed
();
return
mapWrite
.
isClosed
();
}
}
/**
* Remove the map.
*/
public
void
removeMap
()
{
public
void
removeMap
()
{
// TODO remove in a transaction
// TODO remove in a transaction
mapWrite
.
removeMap
();
mapWrite
.
removeMap
();
}
}
/**
* Clear the map.
*/
public
void
clear
()
{
public
void
clear
()
{
// TODO truncate transactionally
// TODO truncate transactionally
mapWrite
.
clear
();
mapWrite
.
clear
();
}
}
/**
* Get the first key.
*
* @return the first key, or null if empty
*/
public
K
firstKey
()
{
public
K
firstKey
()
{
// TODO transactional firstKey
// TODO transactional firstKey
return
mapRead
.
firstKey
();
return
mapRead
.
firstKey
();
}
}
/**
* Get the last key.
*
* @return the last key, or null if empty
*/
public
K
lastKey
()
{
public
K
lastKey
()
{
// TODO transactional lastKey
// TODO transactional lastKey
return
mapRead
.
lastKey
();
return
mapRead
.
lastKey
();
}
}
/**
* Iterate over all keys.
*
* @param from the first key to return
* @return the iterator
*/
public
Iterator
<
K
>
keyIterator
(
K
from
)
{
public
Iterator
<
K
>
keyIterator
(
K
from
)
{
// TODO transactional keyIterator
// TODO transactional keyIterator
return
mapRead
.
keyIterator
(
from
);
return
mapRead
.
keyIterator
(
from
);
}
}
/**
* Get the smallest key that is larger or equal to this key.
*
* @param key the key (may not be null)
* @return the result
*/
public
K
ceilingKey
(
K
key
)
{
public
K
ceilingKey
(
K
key
)
{
// TODO transactional ceilingKey
// TODO transactional ceilingKey
return
mapRead
.
ceilingKey
(
key
);
return
mapRead
.
ceilingKey
(
key
);
}
}
/**
* Get the smallest key that is larger than the given key, or null if no
* such key exists.
*
* @param key the key (may not be null)
* @return the result
*/
public
K
higherKey
(
K
key
)
{
public
K
higherKey
(
K
key
)
{
// TODO transactional higherKey
// TODO transactional higherKey
return
mapRead
.
higherKey
(
key
);
return
mapRead
.
higherKey
(
key
);
}
}
/**
* Get the largest key that is smaller than the given key, or null if no
* such key exists.
*
* @param key the key (may not be null)
* @return the result
*/
public
K
lowerKey
(
K
key
)
{
public
K
lowerKey
(
K
key
)
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
return
mapRead
.
lowerKey
(
key
);
return
mapRead
.
lowerKey
(
key
);
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
91926786
...
@@ -626,6 +626,7 @@ public abstract class Table extends SchemaObjectBase {
...
@@ -626,6 +626,7 @@ public abstract class Table extends SchemaObjectBase {
* @param session the session
* @param session the session
* @param masks per-column comparison bit masks, null means 'always false',
* @param masks per-column comparison bit masks, null means 'always false',
* see constants in IndexCondition
* see constants in IndexCondition
* @param sortOrder the sort order
* @return the plan item
* @return the plan item
*/
*/
public
PlanItem
getBestPlanItem
(
Session
session
,
int
[]
masks
,
SortOrder
sortOrder
)
{
public
PlanItem
getBestPlanItem
(
Session
session
,
int
[]
masks
,
SortOrder
sortOrder
)
{
...
...
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
91926786
...
@@ -178,7 +178,7 @@ public class TableFilter implements ColumnResolver {
...
@@ -178,7 +178,7 @@ public class TableFilter implements ColumnResolver {
}
}
SortOrder
sortOrder
=
null
;
SortOrder
sortOrder
=
null
;
if
(
select
!=
null
)
{
if
(
select
!=
null
)
{
sortOrder
=
select
.
prepare
Order
();
sortOrder
=
select
.
getSort
Order
();
}
}
item
=
table
.
getBestPlanItem
(
s
,
masks
,
sortOrder
);
item
=
table
.
getBestPlanItem
(
s
,
masks
,
sortOrder
);
// The more index conditions, the earlier the table.
// The more index conditions, the earlier the table.
...
...
h2/src/main/org/h2/value/CompareMode.java
浏览文件 @
91926786
...
@@ -35,12 +35,14 @@ public class CompareMode {
...
@@ -35,12 +35,14 @@ public class CompareMode {
public
static
final
String
ICU4J
=
"ICU4J_"
;
public
static
final
String
ICU4J
=
"ICU4J_"
;
/**
/**
* This constant means that the BINARY columns are sorted as if the bytes were signed.
* This constant means that the BINARY columns are sorted as if the bytes
* were signed.
*/
*/
public
static
final
String
SIGNED
=
"SIGNED"
;
public
static
final
String
SIGNED
=
"SIGNED"
;
/**
/**
* This constant means that the BINARY columns are sorted as if the bytes were unsigned.
* This constant means that the BINARY columns are sorted as if the bytes
* were unsigned.
*/
*/
public
static
final
String
UNSIGNED
=
"UNSIGNED"
;
public
static
final
String
UNSIGNED
=
"UNSIGNED"
;
...
@@ -78,6 +80,7 @@ public class CompareMode {
...
@@ -78,6 +80,7 @@ public class CompareMode {
*
*
* @param name the collation name or null
* @param name the collation name or null
* @param strength the collation strength
* @param strength the collation strength
* @param binaryUnsigned whether to compare binaries as unsigned
* @return the compare mode
* @return the compare mode
*/
*/
public
static
synchronized
CompareMode
getInstance
(
String
name
,
int
strength
,
boolean
binaryUnsigned
)
{
public
static
synchronized
CompareMode
getInstance
(
String
name
,
int
strength
,
boolean
binaryUnsigned
)
{
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
91926786
h2/src/test/org/h2/test/db/TestCases.java
浏览文件 @
91926786
h2/src/test/org/h2/test/db/TestCompatibility.java
浏览文件 @
91926786
h2/src/test/org/h2/test/db/TestFunctions.java
浏览文件 @
91926786
h2/src/test/org/h2/test/db/TestOptimizations.java
浏览文件 @
91926786
...
@@ -783,7 +783,10 @@ public class TestOptimizations extends TestBase {
...
@@ -783,7 +783,10 @@ public class TestOptimizations extends TestBase {
conn
.
close
();
conn
.
close
();
}
}
/** Where there are multiple indices, and we have an ORDER BY, select the index that already has the required ordering. */
/**
* Where there are multiple indices, and we have an ORDER BY, select the
* index that already has the required ordering.
*/
private
void
testOrderedIndexes
()
throws
SQLException
{
private
void
testOrderedIndexes
()
throws
SQLException
{
deleteDb
(
"optimizations"
);
deleteDb
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
...
@@ -797,7 +800,8 @@ public class TestOptimizations extends TestBase {
...
@@ -797,7 +800,8 @@ public class TestOptimizations extends TestBase {
stat
.
execute
(
"DROP TABLE my_table"
);
stat
.
execute
(
"DROP TABLE my_table"
);
// where we have two covering indexes, make sure we choose the one that covers more
// where we have two covering indexes, make sure
// we choose the one that covers more
stat
.
execute
(
"CREATE TABLE my_table(K1 INT, K2 INT, VAL VARCHAR)"
);
stat
.
execute
(
"CREATE TABLE my_table(K1 INT, K2 INT, VAL VARCHAR)"
);
stat
.
execute
(
"CREATE INDEX my_index1 ON my_table(K1,K2);"
);
stat
.
execute
(
"CREATE INDEX my_index1 ON my_table(K1,K2);"
);
stat
.
execute
(
"CREATE INDEX my_index2 ON my_table(K1,K2,VAL);"
);
stat
.
execute
(
"CREATE INDEX my_index2 ON my_table(K1,K2,VAL);"
);
...
@@ -807,4 +811,5 @@ public class TestOptimizations extends TestBase {
...
@@ -807,4 +811,5 @@ public class TestOptimizations extends TestBase {
conn
.
close
();
conn
.
close
();
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论