Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
8a96db5a
提交
8a96db5a
authored
10月 19, 2015
作者:
S.Vladykin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Batching support for index lookups and batched joins.
上级
b2a70c1c
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
920 行增加
和
32 行删除
+920
-32
CommandContainer.java
h2/src/main/org/h2/command/CommandContainer.java
+1
-1
BaseIndex.java
h2/src/main/org/h2/index/BaseIndex.java
+14
-0
Index.java
h2/src/main/org/h2/index/Index.java
+28
-1
IndexCursor.java
h2/src/main/org/h2/index/IndexCursor.java
+33
-5
MultiVersionIndex.java
h2/src/main/org/h2/index/MultiVersionIndex.java
+13
-1
Table.java
h2/src/main/org/h2/table/Table.java
+10
-8
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+511
-4
DoneFuture.java
h2/src/main/org/h2/util/DoneFuture.java
+55
-0
TestTableEngines.java
h2/src/test/org/h2/test/db/TestTableEngines.java
+255
-12
没有找到文件。
h2/src/main/org/h2/command/CommandContainer.java
浏览文件 @
8a96db5a
...
@@ -17,7 +17,7 @@ import org.h2.value.ValueNull;
...
@@ -17,7 +17,7 @@ import org.h2.value.ValueNull;
* Represents a single SQL statements.
* Represents a single SQL statements.
* It wraps a prepared statement.
* It wraps a prepared statement.
*/
*/
class
CommandContainer
extends
Command
{
public
class
CommandContainer
extends
Command
{
private
Prepared
prepared
;
private
Prepared
prepared
;
private
boolean
readOnlyKnown
;
private
boolean
readOnlyKnown
;
...
...
h2/src/main/org/h2/index/BaseIndex.java
浏览文件 @
8a96db5a
...
@@ -5,6 +5,10 @@
...
@@ -5,6 +5,10 @@
*/
*/
package
org
.
h2
.
index
;
package
org
.
h2
.
index
;
import
java.util.Collection
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.concurrent.Future
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.engine.Constants
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.DbObject
;
...
@@ -424,4 +428,14 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
...
@@ -424,4 +428,14 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
// ignore
// ignore
}
}
@Override
public
int
getPreferedLookupBatchSize
()
{
// No batched lookups supported by default.
return
0
;
}
@Override
public
List
<
Future
<
Cursor
>>
findBatched
(
TableFilter
filter
,
List
<
SearchRow
>
firstLastPairs
)
{
throw
DbException
.
throwInternalError
(
"Must not be called if getPreferedLookupBatchSize() is 0."
);
}
}
}
h2/src/main/org/h2/index/Index.java
浏览文件 @
8a96db5a
...
@@ -5,6 +5,9 @@
...
@@ -5,6 +5,9 @@
*/
*/
package
org
.
h2
.
index
;
package
org
.
h2
.
index
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.concurrent.Future
;
import
org.h2.engine.Session
;
import
org.h2.engine.Session
;
import
org.h2.result.Row
;
import
org.h2.result.Row
;
import
org.h2.result.SearchRow
;
import
org.h2.result.SearchRow
;
...
@@ -255,5 +258,29 @@ public interface Index extends SchemaObject {
...
@@ -255,5 +258,29 @@ public interface Index extends SchemaObject {
* @param sortedInsertMode the new value
* @param sortedInsertMode the new value
*/
*/
void
setSortedInsertMode
(
boolean
sortedInsertMode
);
void
setSortedInsertMode
(
boolean
sortedInsertMode
);
/**
* If this index can do batched lookups, it may return it's preferred batch size,
* otherwise it must return 0.
*
* @return preferred batch size or 0 if lookup batching is not supported
* @see #findBatched(TableFilter, Collection)
*/
int
getPreferedLookupBatchSize
();
/**
* Do batched lookup over the given collection of {@link SearchRow} pairs as in
* {@link #find(TableFilter, SearchRow, SearchRow)}.
* <br/><br/>
* Correct implementation must always return number of future cursors equal to
* {@code firstLastPairs.size() / 2}. Instead of {@link Future} containing empty
* {@link Cursor} it is possible to put {@code null} in result list.
*
* @param filter the table filter
* @param firstLastPairs List of batched search row pairs as in
* {@link #find(TableFilter, SearchRow, SearchRow)}, the collection will be reused by H2,
* thus it makes sense to defensively copy contents if needed.
* @return batched cursors for respective search row pairs in the same order
*/
List
<
Future
<
Cursor
>>
findBatched
(
TableFilter
filter
,
List
<
SearchRow
>
firstLastPairs
);
}
}
h2/src/main/org/h2/index/IndexCursor.java
浏览文件 @
8a96db5a
...
@@ -68,12 +68,12 @@ public class IndexCursor implements Cursor {
...
@@ -68,12 +68,12 @@ public class IndexCursor implements Cursor {
}
}
/**
/**
*
Re-evaluate the start and end values of the index search for rows
.
*
Prepare this index cursor to make a lookup in index
.
*
*
* @param s
the session
* @param s
Session.
* @param indexConditions
the index conditions
* @param indexConditions
Index conditions.
*/
*/
public
void
find
(
Session
s
,
ArrayList
<
IndexCondition
>
indexConditions
)
{
public
void
prepare
(
Session
s
,
ArrayList
<
IndexCondition
>
indexConditions
)
{
this
.
session
=
s
;
this
.
session
=
s
;
alwaysFalse
=
false
;
alwaysFalse
=
false
;
start
=
end
=
null
;
start
=
end
=
null
;
...
@@ -148,6 +148,16 @@ public class IndexCursor implements Cursor {
...
@@ -148,6 +148,16 @@ public class IndexCursor implements Cursor {
}
}
}
}
}
}
}
/**
* Re-evaluate the start and end values of the index search for rows.
*
* @param s the session
* @param indexConditions the index conditions
*/
public
void
find
(
Session
s
,
ArrayList
<
IndexCondition
>
indexConditions
)
{
prepare
(
s
,
indexConditions
);
if
(
inColumn
!=
null
)
{
if
(
inColumn
!=
null
)
{
return
;
return
;
}
}
...
@@ -251,6 +261,24 @@ public class IndexCursor implements Cursor {
...
@@ -251,6 +261,24 @@ public class IndexCursor implements Cursor {
public
boolean
isAlwaysFalse
()
{
public
boolean
isAlwaysFalse
()
{
return
alwaysFalse
;
return
alwaysFalse
;
}
}
/**
* Get start search row.
*
* @return search row
*/
public
SearchRow
getStart
()
{
return
start
;
}
/**
* Get end search row.
*
* @return search row
*/
public
SearchRow
getEnd
()
{
return
end
;
}
@Override
@Override
public
Row
get
()
{
public
Row
get
()
{
...
...
h2/src/main/org/h2/index/MultiVersionIndex.java
浏览文件 @
8a96db5a
...
@@ -6,7 +6,10 @@
...
@@ -6,7 +6,10 @@
package
org
.
h2
.
index
;
package
org
.
h2
.
index
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.concurrent.Future
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Database
;
import
org.h2.engine.Database
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.DbObject
;
...
@@ -387,4 +390,13 @@ public class MultiVersionIndex implements Index {
...
@@ -387,4 +390,13 @@ public class MultiVersionIndex implements Index {
delta
.
setSortedInsertMode
(
sortedInsertMode
);
delta
.
setSortedInsertMode
(
sortedInsertMode
);
}
}
@Override
public
int
getPreferedLookupBatchSize
()
{
return
0
;
}
@Override
public
List
<
Future
<
Cursor
>>
findBatched
(
TableFilter
filter
,
List
<
SearchRow
>
firstLastPairs
)
{
throw
DbException
.
throwInternalError
(
"Must never be called."
);
}
}
}
h2/src/main/org/h2/table/Table.java
浏览文件 @
8a96db5a
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
package
org
.
h2
.
table
;
package
org
.
h2
.
table
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -104,7 +105,7 @@ public abstract class Table extends SchemaObjectBase {
...
@@ -104,7 +105,7 @@ public abstract class Table extends SchemaObjectBase {
private
ArrayList
<
TableView
>
views
;
private
ArrayList
<
TableView
>
views
;
private
boolean
checkForeignKeyConstraints
=
true
;
private
boolean
checkForeignKeyConstraints
=
true
;
private
boolean
onCommitDrop
,
onCommitTruncate
;
private
boolean
onCommitDrop
,
onCommitTruncate
;
private
Row
nullRow
;
private
volatile
Row
nullRow
;
public
Table
(
Schema
schema
,
int
id
,
String
name
,
boolean
persistIndexes
,
public
Table
(
Schema
schema
,
int
id
,
String
name
,
boolean
persistIndexes
,
boolean
persistData
)
{
boolean
persistData
)
{
...
@@ -616,14 +617,15 @@ public abstract class Table extends SchemaObjectBase {
...
@@ -616,14 +617,15 @@ public abstract class Table extends SchemaObjectBase {
return
new
SimpleRow
(
new
Value
[
columns
.
length
]);
return
new
SimpleRow
(
new
Value
[
columns
.
length
]);
}
}
synchronized
Row
getNullRow
()
{
Row
getNullRow
()
{
if
(
nullRow
==
null
)
{
Row
row
=
nullRow
;
nullRow
=
new
Row
(
new
Value
[
columns
.
length
],
1
);
if
(
row
==
null
)
{
for
(
int
i
=
0
;
i
<
columns
.
length
;
i
++)
{
// Here can be concurrently produced more than one row, but it must be ok.
nullRow
.
setValue
(
i
,
ValueNull
.
INSTANCE
);
Value
[]
values
=
new
Value
[
columns
.
length
];
}
Arrays
.
fill
(
values
,
ValueNull
.
INSTANCE
);
nullRow
=
row
=
new
Row
(
values
,
1
);
}
}
return
nullR
ow
;
return
r
ow
;
}
}
public
Column
[]
getColumns
()
{
public
Column
[]
getColumns
()
{
...
...
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
8a96db5a
差异被折叠。
点击展开。
h2/src/main/org/h2/util/DoneFuture.java
0 → 100644
浏览文件 @
8a96db5a
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
util
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeoutException
;
/**
* Future which is already done.
*
* @param <T> Result value.
* @author Sergi Vladykin
*/
public
class
DoneFuture
<
T
>
implements
Future
<
T
>
{
final
T
x
;
public
DoneFuture
(
T
x
)
{
this
.
x
=
x
;
}
@Override
public
T
get
()
throws
InterruptedException
,
ExecutionException
{
return
x
;
}
@Override
public
T
get
(
long
timeout
,
TimeUnit
unit
)
throws
InterruptedException
,
ExecutionException
,
TimeoutException
{
return
x
;
}
@Override
public
boolean
isDone
()
{
return
true
;
}
@Override
public
boolean
cancel
(
boolean
mayInterruptIfRunning
)
{
return
false
;
}
@Override
public
boolean
isCancelled
()
{
return
false
;
}
@Override
public
String
toString
()
{
return
"DoneFuture->"
+
x
;
}
}
h2/src/test/org/h2/test/db/TestTableEngines.java
浏览文件 @
8a96db5a
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论