Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
4867529d
提交
4867529d
authored
1月 05, 2019
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
javadoc update
上级
8722b796
显示空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
179 行增加
和
13 行删除
+179
-13
Select.java
h2/src/main/org/h2/command/dml/Select.java
+15
-0
Expression.java
h2/src/main/org/h2/expression/Expression.java
+12
-0
ExpressionVisitor.java
h2/src/main/org/h2/expression/ExpressionVisitor.java
+7
-0
AbstractAggregate.java
...c/main/org/h2/expression/aggregate/AbstractAggregate.java
+6
-0
DataAnalysisOperation.java
...ain/org/h2/expression/analysis/DataAnalysisOperation.java
+67
-0
Function.java
h2/src/main/org/h2/expression/function/Function.java
+7
-0
CacheLongKeyLIRS.java
h2/src/main/org/h2/mvstore/cache/CacheLongKeyLIRS.java
+3
-0
MVPrimaryIndex.java
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
+14
-1
MVTableEngine.java
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
+12
-0
TransactionStore.java
h2/src/main/org/h2/mvstore/tx/TransactionStore.java
+17
-10
VersionedValueCommitted.java
h2/src/main/org/h2/mvstore/tx/VersionedValueCommitted.java
+5
-0
VersionedValueUncommitted.java
h2/src/main/org/h2/mvstore/tx/VersionedValueUncommitted.java
+8
-0
IntervalUtils.java
h2/src/main/org/h2/util/IntervalUtils.java
+2
-1
VersionedValue.java
h2/src/main/org/h2/value/VersionedValue.java
+3
-0
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-1
没有找到文件。
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
4867529d
...
...
@@ -114,6 +114,9 @@ public class Select extends Query {
private
int
[]
groupByCopies
;
/**
* Whether this query contains aggregate functions.
*/
boolean
isGroupQuery
;
private
boolean
isGroupSortedQuery
;
private
boolean
isWindowQuery
;
...
...
@@ -194,6 +197,12 @@ public class Select extends Query {
return
group
;
}
/**
* Get the group data if there is currently a group-by active.
*
* @param window is this a window function
* @return the grouped data
*/
public
SelectGroups
getGroupDataIfCurrent
(
boolean
window
)
{
return
groupData
!=
null
&&
(
window
||
groupData
.
isCurrentGroup
())
?
groupData
:
null
;
}
...
...
@@ -471,6 +480,12 @@ public class Select extends Query {
groupData
.
done
();
}
/**
* Update any aggregate expressions with the query stage.
* @param columnCount number of columns
* @param stage stage of query (window or normal)
*/
void
updateAgg
(
int
columnCount
,
int
stage
)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
if
((
groupByExpression
==
null
||
!
groupByExpression
[
i
])
...
...
h2/src/main/org/h2/expression/Expression.java
浏览文件 @
4867529d
...
...
@@ -40,6 +40,12 @@ public abstract class Expression {
private
boolean
addedToFilter
;
/**
* Get the SQL snippet for a list of expressions.
*
* @param builder the builder to append the SQL to
* @param expressions the list of expressions
*/
public
static
void
writeExpressions
(
StringBuilder
builder
,
List
<?
extends
Expression
>
expressions
)
{
for
(
int
i
=
0
,
length
=
expressions
.
size
();
i
<
length
;
i
++)
{
if
(
i
>
0
)
{
...
...
@@ -49,6 +55,12 @@ public abstract class Expression {
}
}
/**
* Get the SQL snippet for an array of expressions.
*
* @param builder the builder to append the SQL to
* @param expressions the list of expressions
*/
public
static
void
writeExpressions
(
StringBuilder
builder
,
Expression
[]
expressions
)
{
for
(
int
i
=
0
,
length
=
expressions
.
length
;
i
<
length
;
i
++)
{
if
(
i
>
0
)
{
...
...
h2/src/main/org/h2/expression/ExpressionVisitor.java
浏览文件 @
4867529d
...
...
@@ -271,6 +271,12 @@ public class ExpressionVisitor {
columns1
.
add
(
column
);
}
/**
* Add a new column to the set of columns.
* This is used for GET_COLUMNS2 visitors.
*
* @param column the additional column.
*/
void
addColumn2
(
Column
column
)
{
if
(
table
==
null
||
table
==
column
.
getTable
())
{
columns2
.
add
(
column
);
...
...
@@ -367,6 +373,7 @@ public class ExpressionVisitor {
* Get the set of columns of all tables.
*
* @param filters the filters
* @param allColumnsSet the on-demand all-columns set
*/
public
static
void
allColumnsForTableFilters
(
TableFilter
[]
filters
,
AllColumnsForPlan
allColumnsSet
)
{
for
(
TableFilter
filter
:
filters
)
{
...
...
h2/src/main/org/h2/expression/aggregate/AbstractAggregate.java
浏览文件 @
4867529d
...
...
@@ -25,8 +25,14 @@ import org.h2.value.Value;
*/
public
abstract
class
AbstractAggregate
extends
DataAnalysisOperation
{
/**
* is this a DISTINCT aggregate
*/
protected
final
boolean
distinct
;
/**
* FILTER condition for aggregate/window
*/
protected
Expression
filterCondition
;
AbstractAggregate
(
Select
select
,
boolean
distinct
)
{
...
...
h2/src/main/org/h2/expression/analysis/DataAnalysisOperation.java
浏览文件 @
4867529d
...
...
@@ -44,14 +44,31 @@ public abstract class DataAnalysisOperation extends Expression {
*/
public
static
final
int
STAGE_WINDOW
=
2
;
/**
* SELECT
*/
protected
final
Select
select
;
/**
* Window clause / OVER
*/
protected
Window
over
;
/**
* Sort order for OVER
*/
protected
SortOrder
overOrderBySort
;
private
int
lastGroupRowId
;
/**
* Create sort order.
*
* @param session database session
* @param orderBy array of order by expressions
* @param offset index offset
* @return the SortOrder
*/
protected
static
SortOrder
createOrder
(
Session
session
,
ArrayList
<
SelectOrderBy
>
orderBy
,
int
offset
)
{
int
size
=
orderBy
.
size
();
int
[]
index
=
new
int
[
size
];
...
...
@@ -111,6 +128,13 @@ public abstract class DataAnalysisOperation extends Expression {
mapColumnsAnalysis
(
resolver
,
level
,
state
);
}
/**
* Map the columns of the resolver to expression columns.
*
* @param resolver the column resolver
* @param level the subquery nesting level
* @param innerState one of the Expression MAP_IN_* values
*/
protected
void
mapColumnsAnalysis
(
ColumnResolver
resolver
,
int
level
,
int
innerState
)
{
if
(
over
!=
null
)
{
over
.
mapColumns
(
resolver
,
level
);
...
...
@@ -173,6 +197,13 @@ public abstract class DataAnalysisOperation extends Expression {
updateAggregate
(
session
,
groupData
,
groupRowId
);
}
/**
* Update a row of an aggregate.
*
* @param session the database session
* @param groupData data for the aggregate group
* @param groupRowId row id of group
*/
protected
abstract
void
updateAggregate
(
Session
session
,
SelectGroups
groupData
,
int
groupRowId
);
/**
...
...
@@ -207,6 +238,14 @@ public abstract class DataAnalysisOperation extends Expression {
*/
protected
abstract
void
rememberExpressions
(
Session
session
,
Value
[]
array
);
/**
* Get the aggregate data for a window clause.
*
* @param session database session
* @param groupData aggregate group data
* @param forOrderBy true if this is for ORDER BY
* @return the aggregate data object, specific to each kind of aggregate.
*/
protected
Object
getWindowData
(
Session
session
,
SelectGroups
groupData
,
boolean
forOrderBy
)
{
Object
data
;
Value
key
=
over
.
getCurrentKey
(
session
);
...
...
@@ -220,6 +259,13 @@ public abstract class DataAnalysisOperation extends Expression {
return
data
;
}
/**
* Get the aggregate group data object from the collector object.
* @param groupData the collector object
* @param ifExists if true, return null if object not found,
* if false, return new object if nothing found
* @return group data object
*/
protected
Object
getGroupData
(
SelectGroups
groupData
,
boolean
ifExists
)
{
Object
data
;
data
=
groupData
.
getCurrentGroupExprData
(
this
);
...
...
@@ -233,6 +279,11 @@ public abstract class DataAnalysisOperation extends Expression {
return
data
;
}
/**
* Create aggregate data object specific to the subclass.
*
* @return aggregate-specific data object.
*/
protected
abstract
Object
createAggregateData
();
@Override
...
...
@@ -316,6 +367,14 @@ public abstract class DataAnalysisOperation extends Expression {
*/
protected
abstract
Value
getAggregatedValue
(
Session
session
,
Object
aggregateData
);
/**
* Update a row of an ordered aggregate.
*
* @param session the database session
* @param groupData data for the aggregate group
* @param groupRowId row id of group
* @param orderBy list of order by expressions
*/
protected
void
updateOrderedAggregate
(
Session
session
,
SelectGroups
groupData
,
int
groupRowId
,
ArrayList
<
SelectOrderBy
>
orderBy
)
{
int
ne
=
getNumExpressions
();
...
...
@@ -352,6 +411,8 @@ public abstract class DataAnalysisOperation extends Expression {
}
/**
* Returns result of this window function or window aggregate.
*
* @param session
* the session
* @param result
...
...
@@ -364,6 +425,12 @@ public abstract class DataAnalysisOperation extends Expression {
protected
abstract
void
getOrderedResultLoop
(
Session
session
,
HashMap
<
Integer
,
Value
>
result
,
ArrayList
<
Value
[]>
ordered
,
int
rowIdColumn
);
/**
* Used to create SQL for the OVER part of the command.
*
* @param builder string builder
* @return the builder object
*/
protected
StringBuilder
appendTailConditions
(
StringBuilder
builder
)
{
if
(
over
!=
null
)
{
builder
.
append
(
' '
);
...
...
h2/src/main/org/h2/expression/function/Function.java
浏览文件 @
4867529d
...
...
@@ -1167,6 +1167,13 @@ public class Function extends Expression implements FunctionCall {
return
v
;
}
/**
* Return the resulting value for the given expression arguments.
*
* @param session the session
* @param args argument expressions
* @return the result
*/
protected
Value
getValueWithArgs
(
Session
session
,
Expression
[]
args
)
{
Value
[]
values
=
new
Value
[
args
.
length
];
if
(
info
.
nullIfParameterIsNull
)
{
...
...
h2/src/main/org/h2/mvstore/cache/CacheLongKeyLIRS.java
浏览文件 @
4867529d
...
...
@@ -493,6 +493,9 @@ public class CacheLongKeyLIRS<V> {
}
}
/**
* Loop through segments, trimming the non resident queue.
*/
public
void
trimNonResidentQueue
()
{
for
(
Segment
<
V
>
s
:
segments
)
{
synchronized
(
s
)
{
...
...
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
浏览文件 @
4867529d
...
...
@@ -209,6 +209,12 @@ public class MVPrimaryIndex extends BaseIndex {
}
}
/**
* Lock a set of rows.
*
* @param session database session
* @param rowsForUpdate rows to lock
*/
void
lockRows
(
Session
session
,
Iterable
<
Row
>
rowsForUpdate
)
{
TransactionMap
<
Value
,
Value
>
map
=
getMap
(
session
);
for
(
Row
row
:
rowsForUpdate
)
{
...
...
@@ -217,6 +223,13 @@ public class MVPrimaryIndex extends BaseIndex {
}
}
/**
* Lock a single row.
*
* @param session database session
* @param row to lock
* @return row object if it exists
*/
Row
lockRow
(
Session
session
,
Row
row
)
{
TransactionMap
<
Value
,
Value
>
map
=
getMap
(
session
);
long
key
=
row
.
getKey
();
...
...
@@ -273,7 +286,7 @@ public class MVPrimaryIndex extends BaseIndex {
return
getRow
(
session
,
key
,
(
ValueArray
)
v
);
}
p
ublic
Row
getRow
(
Session
session
,
long
key
,
ValueArray
array
)
{
p
rivate
Row
getRow
(
Session
session
,
long
key
,
ValueArray
array
)
{
Row
row
=
session
.
createRow
(
array
.
getList
(),
0
);
row
.
setKey
(
key
);
return
row
;
...
...
h2/src/main/org/h2/mvstore/db/MVTableEngine.java
浏览文件 @
4867529d
...
...
@@ -97,6 +97,12 @@ public class MVTableEngine implements TableEngine {
return
store
;
}
/**
* Convert password from byte[] to char[].
*
* @param key password as byte[]
* @return password as char[].
*/
static
char
[]
decodePassword
(
byte
[]
key
)
{
char
[]
password
=
new
char
[
key
.
length
/
2
];
for
(
int
i
=
0
;
i
<
password
.
length
;
i
++)
{
...
...
@@ -210,6 +216,12 @@ public class MVTableEngine implements TableEngine {
return
transactionStore
;
}
/**
* Get MVTable by table name.
*
* @param tableName table name
* @return MVTable
*/
public
MVTable
getTable
(
String
tableName
)
{
return
tableMap
.
get
(
tableName
);
}
...
...
h2/src/main/org/h2/mvstore/tx/TransactionStore.java
浏览文件 @
4867529d
...
...
@@ -179,7 +179,7 @@ public class TransactionStore {
assert
committed
||
getTransactionId
(
lastUndoKey
)
==
transactionId
;
long
logId
=
lastUndoKey
==
null
?
0
:
getLogId
(
lastUndoKey
)
+
1
;
registerTransaction
(
transactionId
,
status
,
name
,
logId
,
timeoutMillis
,
0
,
R
ollbackListener
.
NONE
);
R
OLLBACK_LISTENER_
NONE
);
continue
;
}
}
...
...
@@ -307,7 +307,7 @@ public class TransactionStore {
* @return the transaction
*/
public
Transaction
begin
()
{
return
begin
(
R
ollbackListener
.
NONE
,
timeoutMillis
,
0
);
return
begin
(
R
OLLBACK_LISTENER_
NONE
,
timeoutMillis
,
0
);
}
/**
...
...
@@ -387,6 +387,7 @@ public class TransactionStore {
* @param transactionId id of the transaction
* @param logId sequential number of the log record within transaction
* @param undoLogRecord Object[mapId, key, previousValue]
* @return undo key
*/
long
addUndoLogRecord
(
int
transactionId
,
long
logId
,
Object
[]
undoLogRecord
)
{
MVMap
<
Long
,
Object
[]>
undoLog
=
undoLogs
[
transactionId
];
...
...
@@ -582,6 +583,12 @@ public class TransactionStore {
return
true
;
}
/**
* Get Transaction object for a transaction id.
*
* @param transactionId id for an open transaction
* @return Transaction object.
*/
Transaction
getTransaction
(
int
transactionId
)
{
return
transactions
.
get
(
transactionId
);
}
...
...
@@ -711,14 +718,6 @@ public class TransactionStore {
*/
public
interface
RollbackListener
{
RollbackListener
NONE
=
new
RollbackListener
()
{
@Override
public
void
onRollback
(
MVMap
<
Object
,
VersionedValue
>
map
,
Object
key
,
VersionedValue
existingValue
,
VersionedValue
restoredValue
)
{
// do nothing
}
};
/**
* Notified of a single map change (add/update/remove)
* @param map modified
...
...
@@ -730,6 +729,14 @@ public class TransactionStore {
VersionedValue
existingValue
,
VersionedValue
restoredValue
);
}
private
static
RollbackListener
ROLLBACK_LISTENER_NONE
=
new
RollbackListener
()
{
@Override
public
void
onRollback
(
MVMap
<
Object
,
VersionedValue
>
map
,
Object
key
,
VersionedValue
existingValue
,
VersionedValue
restoredValue
)
{
// do nothing
}
};
/**
* A data type that contains an array of objects with the specified data
* types.
...
...
h2/src/main/org/h2/mvstore/tx/VersionedValueCommitted.java
浏览文件 @
4867529d
...
...
@@ -22,6 +22,11 @@ class VersionedValueCommitted extends VersionedValue {
this
.
value
=
value
;
}
/**
* Either cast to VersionedValue, or wrap in VersionedValueCommitted
* @param value the object to cast/wrap
* @return VersionedValue instance
*/
static
VersionedValue
getInstance
(
Object
value
)
{
assert
value
!=
null
;
return
value
instanceof
VersionedValue
?
(
VersionedValue
)
value
:
new
VersionedValueCommitted
(
value
);
...
...
h2/src/main/org/h2/mvstore/tx/VersionedValueUncommitted.java
浏览文件 @
4867529d
...
...
@@ -23,6 +23,14 @@ class VersionedValueUncommitted extends VersionedValueCommitted {
this
.
committedValue
=
committedValue
;
}
/**
* Create new VersionedValueUncommitted.
*
* @param operationId combined log/transaction id
* @param value value before commit
* @param committedValue value after commit
* @return VersionedValue instance
*/
static
VersionedValue
getInstance
(
long
operationId
,
Object
value
,
Object
committedValue
)
{
return
new
VersionedValueUncommitted
(
operationId
,
value
,
committedValue
);
}
...
...
h2/src/main/org/h2/util/IntervalUtils.java
浏览文件 @
4867529d
...
...
@@ -328,7 +328,8 @@ public class IntervalUtils {
return
ValueInterval
.
from
(
qualifier
,
negative
,
leading
,
remaining
);
}
private
static
ValueInterval
parseInterval2
(
IntervalQualifier
qualifier
,
String
s
,
char
ch
,
int
max
,
boolean
negative
)
{
private
static
ValueInterval
parseInterval2
(
IntervalQualifier
qualifier
,
String
s
,
char
ch
,
int
max
,
boolean
negative
)
{
long
leading
;
long
remaining
;
int
dash
=
s
.
indexOf
(
ch
,
1
);
...
...
h2/src/main/org/h2/value/VersionedValue.java
浏览文件 @
4867529d
...
...
@@ -13,6 +13,9 @@ package org.h2.value;
*/
public
class
VersionedValue
{
/**
* Used when we don't care about a VersionedValue instance.
*/
public
static
final
VersionedValue
DUMMY
=
new
VersionedValue
();
protected
VersionedValue
()
{}
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
4867529d
...
...
@@ -805,4 +805,4 @@ queryparser tokenized freeze factorings recompilation unenclosed rfe dsync
econd irst bcef ordinality nord unnest
analyst occupation distributive josaph aor engineer sajeewa isuru randil kevin doctor businessman artist ashan
corrupts splitted disruption unintentional octets preconditions predicates subq objectweb insn opcodes
preserves masking holder unboxing avert iae
preserves masking holder unboxing avert iae
transformed
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论