Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
4574944c
提交
4574944c
authored
10月 27, 2015
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #189 from svladykin/batchJoin2
Batching support for index lookups and batched joins.
上级
79ea94ee
998283ae
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
1023 行增加
和
51 行删除
+1023
-51
CommandContainer.java
h2/src/main/org/h2/command/CommandContainer.java
+1
-1
BaseIndex.java
h2/src/main/org/h2/index/BaseIndex.java
+3
-8
Index.java
h2/src/main/org/h2/index/Index.java
+5
-21
IndexLookupBatch.java
h2/src/main/org/h2/index/IndexLookupBatch.java
+50
-0
MultiVersionIndex.java
h2/src/main/org/h2/index/MultiVersionIndex.java
+3
-7
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+630
-2
DoneFuture.java
h2/src/main/org/h2/util/DoneFuture.java
+55
-0
TestTableEngines.java
h2/src/test/org/h2/test/db/TestTableEngines.java
+276
-12
没有找到文件。
h2/src/main/org/h2/command/CommandContainer.java
浏览文件 @
4574944c
...
...
@@ -17,7 +17,7 @@ import org.h2.value.ValueNull;
* Represents a single SQL statements.
* It wraps a prepared statement.
*/
class
CommandContainer
extends
Command
{
public
class
CommandContainer
extends
Command
{
private
Prepared
prepared
;
private
boolean
readOnlyKnown
;
...
...
h2/src/main/org/h2/index/BaseIndex.java
浏览文件 @
4574944c
...
...
@@ -427,13 +427,8 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
}
@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."
);
public
IndexLookupBatch
createLookupBatch
(
TableFilter
filter
)
{
// Lookup batching is not supported.
return
null
;
}
}
h2/src/main/org/h2/index/Index.java
浏览文件 @
4574944c
...
...
@@ -259,27 +259,11 @@ public interface Index extends SchemaObject {
void
setSortedInsertMode
(
boolean
sortedInsertMode
);
/**
*
If this index can do batched lookups, it may return it's preferred batch size,
*
otherwise it must return 0
.
*
Creates new lookup batch. Note that returned {@link IndexLookupBatch} instance
*
can be used multiple times
.
*
* @
return preferred batch size or 0 if lookup batching is not supported
* @
see #findBatched(TableFilter, Collection)
* @
param filter Table filter.
* @
return Created batch or {@code null} if batched lookup is not supported by this index.
*/
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
);
IndexLookupBatch
createLookupBatch
(
TableFilter
filter
);
}
h2/src/main/org/h2/index/IndexLookupBatch.java
0 → 100644
浏览文件 @
4574944c
/*
* 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
.
index
;
import
java.util.List
;
import
java.util.concurrent.Future
;
import
org.h2.result.SearchRow
;
/**
* Support for asynchronous batched lookups in indexes. The flow is the following:
* H2 engine will be calling {@link #addSearchRows(SearchRow, SearchRow)} until
* method {@link #isBatchFull()}} will return {@code true} or there are no more
* search rows to add. Then method {@link #find()} will be called to execute batched lookup.
* Note that a single instance of {@link IndexLookupBatch} can be reused for multiple
* sequential batched lookups.
*
* @see Index#createLookupBatch(TableFilter)
* @author Sergi Vladykin
*/
public
interface
IndexLookupBatch
{
/**
* Add search row pair to the batch.
*
* @param first the first row, or null for no limit
* @param last the last row, or null for no limit
* @see Index#find(TableFilter, SearchRow, SearchRow)
*/
void
addSearchRows
(
SearchRow
first
,
SearchRow
last
);
/**
* Check if this batch is full.
*
* @return {@code true} If batch is full, will not accept any
* more rows and {@link #find()} can be executed.
*/
boolean
isBatchFull
();
/**
* Execute batched lookup and return future cursor for each provided
* search row pair. Note that this method must return exactly the same number
* of future cursors in result list as number of {@link #addSearchRows(SearchRow, SearchRow)}
* calls has been done before {@link #find()} call exactly in the same order.
*
* @return List of future cursors for collected search rows.
*/
List
<
Future
<
Cursor
>>
find
();
}
h2/src/main/org/h2/index/MultiVersionIndex.java
浏览文件 @
4574944c
...
...
@@ -389,12 +389,8 @@ public class MultiVersionIndex implements Index {
}
@Override
public
int
getPreferedLookupBatchSize
()
{
return
0
;
}
@Override
public
List
<
Future
<
Cursor
>>
findBatched
(
TableFilter
filter
,
List
<
SearchRow
>
firstLastPairs
)
{
throw
DbException
.
throwInternalError
(
"Must never be called."
);
public
IndexLookupBatch
createLookupBatch
(
TableFilter
filter
)
{
// Lookup batching is not supported.
return
null
;
}
}
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
4574944c
差异被折叠。
点击展开。
h2/src/main/org/h2/util/DoneFuture.java
0 → 100644
浏览文件 @
4574944c
/*
* 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
浏览文件 @
4574944c
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论