Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
78155dab
Unverified
提交
78155dab
authored
1月 05, 2019
作者:
Noel Grandin
提交者:
GitHub
1月 05, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1643 from grandinj/javadoc4
more javadoc update
上级
8722b796
f125a8a4
显示空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
379 行增加
和
20 行删除
+379
-20
Select.java
h2/src/main/org/h2/command/dml/Select.java
+19
-2
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
+8
-1
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+66
-1
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+51
-0
Page.java
h2/src/main/org/h2/mvstore/Page.java
+76
-1
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
StringUtils.java
h2/src/main/org/h2/util/StringUtils.java
+1
-1
ValueInterval.java
h2/src/main/org/h2/value/ValueInterval.java
+1
-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
浏览文件 @
78155dab
...
...
@@ -114,6 +114,10 @@ public class Select extends Query {
private
int
[]
groupByCopies
;
/**
* This flag is set when SELECT statement contains (non-window) aggregate
* functions, GROUP BY clause or HAVING clause.
*/
boolean
isGroupQuery
;
private
boolean
isGroupSortedQuery
;
private
boolean
isWindowQuery
;
...
...
@@ -173,7 +177,8 @@ public class Select extends Query {
}
/**
* Called if this query contains aggregate functions.
* Set when SELECT statement contains (non-window) aggregate functions,
* GROUP BY clause or HAVING clause.
*/
public
void
setGroupQuery
()
{
isGroupQuery
=
true
;
...
...
@@ -194,6 +199,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 +482,12 @@ public class Select extends Query {
groupData
.
done
();
}
/**
* Update any aggregate expressions with the query stage.
* @param columnCount number of columns
* @param stage see STAGE_RESET/STAGE_GROUP/STAGE_WINDOW in DataAnalysisOperation
*/
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
浏览文件 @
78155dab
...
...
@@ -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
浏览文件 @
78155dab
...
...
@@ -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
浏览文件 @
78155dab
...
...
@@ -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
*/
protected
Expression
filterCondition
;
AbstractAggregate
(
Select
select
,
boolean
distinct
)
{
...
...
h2/src/main/org/h2/expression/analysis/DataAnalysisOperation.java
浏览文件 @
78155dab
...
...
@@ -44,14 +44,31 @@ public abstract class DataAnalysisOperation extends Expression {
*/
public
static
final
int
STAGE_WINDOW
=
2
;
/**
* SELECT
*/
protected
final
Select
select
;
/**
* OVER clause
*/
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 and FILTER clauses.
*
* @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
浏览文件 @
78155dab
...
...
@@ -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/MVMap.java
浏览文件 @
78155dab
...
...
@@ -109,6 +109,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
this
.
singleWriter
=
singleWriter
;
}
/**
* Clone the current map.
*
* @return clone of this.
*/
protected
MVMap
<
K
,
V
>
cloneIt
()
{
return
new
MVMap
<>(
this
);
}
...
...
@@ -786,6 +791,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
return
root
.
get
();
}
/**
* Get the root reference, flushing any current append buffer.
*
* @return current root reference
*/
public
RootReference
flushAndGetRoot
()
{
RootReference
rootReference
=
getRoot
();
if
(
singleWriter
&&
rootReference
.
getAppendCounter
()
>
0
)
{
...
...
@@ -799,6 +809,12 @@ public class MVMap<K, V> extends AbstractMap<K, V>
while
(
setNewRoot
(
null
,
rootPage
,
++
attempt
,
false
)
==
null
)
{
/**/
}
}
/**
* Set the initial root.
*
* @param rootPage root page
* @param version initial version
*/
final
void
setInitialRoot
(
Page
rootPage
,
long
version
)
{
root
.
set
(
new
RootReference
(
rootPage
,
version
));
}
...
...
@@ -860,6 +876,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
}
/**
* Roll the root back to the specified version.
*
* @param version to rollback to
*/
void
rollbackRoot
(
long
version
)
{
RootReference
rootReference
=
flushAndGetRoot
();
...
...
@@ -1071,6 +1092,12 @@ public class MVMap<K, V> extends AbstractMap<K, V>
rootReference
.
version
:
previous
.
version
;
}
/**
* Does the root have changes since the specified version?
*
* @param version root version
* @return true if has changes
*/
final
boolean
hasChangesSince
(
long
version
)
{
RootReference
rootReference
=
getRoot
();
Page
root
=
rootReference
.
root
;
...
...
@@ -1144,10 +1171,20 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
}
/**
* Create empty leaf node page.
*
* @return new page
*/
public
Page
createEmptyLeaf
()
{
return
Page
.
createEmptyLeaf
(
this
);
}
/**
* Create empty internal node page.
*
* @return new page
*/
protected
Page
createEmptyNode
()
{
return
Page
.
createEmptyNode
(
this
);
}
...
...
@@ -1601,6 +1638,11 @@ public class MVMap<K, V> extends AbstractMap<K, V>
return
create
(
config
);
}
/**
* Create map from config.
* @param config config map
* @return new map
*/
protected
abstract
M
create
(
Map
<
String
,
Object
>
config
);
}
...
...
@@ -1665,6 +1707,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
*/
public
abstract
static
class
DecisionMaker
<
V
>
{
/**
* Decision maker for transaction rollback.
*/
public
static
final
DecisionMaker
<
Object
>
DEFAULT
=
new
DecisionMaker
<
Object
>()
{
@Override
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
...
...
@@ -1677,6 +1722,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
};
/**
* Decision maker for put().
*/
public
static
final
DecisionMaker
<
Object
>
PUT
=
new
DecisionMaker
<
Object
>()
{
@Override
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
...
...
@@ -1689,6 +1737,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
};
/**
* Decision maker for remove().
*/
public
static
final
DecisionMaker
<
Object
>
REMOVE
=
new
DecisionMaker
<
Object
>()
{
@Override
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
...
...
@@ -1701,6 +1752,9 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
};
/**
* Decision maker for putIfAbsent() key/value.
*/
static
final
DecisionMaker
<
Object
>
IF_ABSENT
=
new
DecisionMaker
<
Object
>()
{
@Override
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
...
...
@@ -1713,7 +1767,10 @@ public class MVMap<K, V> extends AbstractMap<K, V>
}
};
static
final
DecisionMaker
<
Object
>
IF_PRESENT
=
new
DecisionMaker
<
Object
>()
{
/**
* Decision maker for replace().
*/
static
final
DecisionMaker
<
Object
>
IF_PRESENT
=
new
DecisionMaker
<
Object
>()
{
@Override
public
Decision
decide
(
Object
existingValue
,
Object
providedValue
)
{
return
existingValue
!=
null
?
Decision
.
PUT
:
Decision
.
ABORT
;
...
...
@@ -1757,6 +1814,14 @@ public class MVMap<K, V> extends AbstractMap<K, V>
public
void
reset
()
{}
}
/**
* Apply an operation to a key-value pair.
*
* @param key key to operate on
* @param value new value
* @param decisionMaker command object to make choices during transaction.
* @return new value
*/
@SuppressWarnings
(
"unchecked"
)
public
V
operate
(
K
key
,
V
value
,
DecisionMaker
<?
super
V
>
decisionMaker
)
{
beforeWrite
();
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
78155dab
...
...
@@ -529,6 +529,14 @@ public class MVStore implements AutoCloseable {
}
}
/**
* Get map by id.
*
* @param <K> the key type
* @param <V> the value type
* @param id map id
* @return Map
*/
public
<
K
,
V
>
MVMap
<
K
,
V
>
getMap
(
int
id
)
{
checkOpen
();
@SuppressWarnings
(
"unchecked"
)
...
...
@@ -609,6 +617,12 @@ public class MVStore implements AutoCloseable {
return
meta
.
containsKey
(
"name."
+
name
);
}
/**
* Check whether a given map exists and has data.
*
* @param name the map name
* @return true if it exists and has data.
*/
public
boolean
hasData
(
String
name
)
{
return
hasMap
(
name
)
&&
getRootPos
(
meta
,
getMapId
(
name
))
!=
0
;
}
...
...
@@ -969,6 +983,13 @@ public class MVStore implements AutoCloseable {
}
}
/**
* Read a page of data into a ByteBuffer.
*
* @param pos page pos
* @param expectedMapId expected map id for the page
* @return ByteBuffer containing page data.
*/
ByteBuffer
readBufferForPage
(
long
pos
,
int
expectedMapId
)
{
Chunk
c
=
getChunk
(
pos
);
long
filePos
=
c
.
block
*
BLOCK_SIZE
;
...
...
@@ -1493,6 +1514,13 @@ public class MVStore implements AutoCloseable {
return
new
HashSet
<>(
referencedChunks
.
keySet
());
}
/**
* Visit a page on a chunk and collect ids for it and its children.
*
* @param page the page to visit
* @param executorService the service to use when doing visit in parallel
* @param executingThreadCounter number of threads currently active
*/
public
void
visit
(
Page
page
,
ThreadPoolExecutor
executorService
,
AtomicInteger
executingThreadCounter
)
{
long
pos
=
page
.
getPos
();
if
(
DataUtils
.
isPageSaved
(
pos
))
{
...
...
@@ -1515,6 +1543,13 @@ public class MVStore implements AutoCloseable {
cacheCollectedChunkIds
(
pos
,
childCollector
);
}
/**
* Visit a page on a chunk and collect ids for it and its children.
*
* @param pos position of the page to visit
* @param executorService the service to use when doing visit in parallel
* @param executingThreadCounter number of threads currently active
*/
public
void
visit
(
long
pos
,
ThreadPoolExecutor
executorService
,
AtomicInteger
executingThreadCounter
)
{
if
(!
DataUtils
.
isPageSaved
(
pos
))
{
return
;
...
...
@@ -1544,6 +1579,11 @@ public class MVStore implements AutoCloseable {
}
}
/**
* Add chunk to list of referenced chunks.
*
* @param chunkId chunk id
*/
void
registerChunk
(
int
chunkId
)
{
if
(
referencedChunks
.
put
(
chunkId
,
1
)
==
null
&&
parent
!=
null
)
{
parent
.
registerChunk
(
chunkId
);
...
...
@@ -2603,6 +2643,12 @@ public class MVStore implements AutoCloseable {
removeMap
(
map
,
true
);
}
/**
* Remove a map.
*
* @param map the map to remove
* @param delayed whether to delay deleting the metadata
*/
public
void
removeMap
(
MVMap
<?,
?>
map
,
boolean
delayed
)
{
storeLock
.
lock
();
try
{
...
...
@@ -2637,6 +2683,11 @@ public class MVStore implements AutoCloseable {
}
}
/**
* Remove map by name.
*
* @param name the map name
*/
public
void
removeMap
(
String
name
)
{
int
id
=
getMapId
(
name
);
if
(
id
>
0
)
{
...
...
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
78155dab
...
...
@@ -137,7 +137,7 @@ public abstract class Page implements Cloneable
}
/**
* Create a new, empty page.
* Create a new, empty
leaf
page.
*
* @param map the map
* @return the new page
...
...
@@ -146,6 +146,12 @@ public abstract class Page implements Cloneable
return
createLeaf
(
map
,
EMPTY_OBJECT_ARRAY
,
EMPTY_OBJECT_ARRAY
,
PAGE_LEAF_MEMORY
);
}
/**
* Create a new, empty internal node page.
*
* @param map the map
* @return the new page
*/
static
Page
createEmptyNode
(
MVMap
<?,
?>
map
)
{
return
createNode
(
map
,
EMPTY_OBJECT_ARRAY
,
SINGLE_EMPTY
,
0
,
PAGE_NODE_MEMORY
+
MEMORY_POINTER
+
PAGE_MEMORY_CHILD
);
// there is always one child
...
...
@@ -396,6 +402,11 @@ public abstract class Page implements Cloneable
return
buff
.
toString
();
}
/**
* Dump debug data for this page.
*
* @param buff append buffer
*/
protected
void
dump
(
StringBuilder
buff
)
{
buff
.
append
(
"id: "
).
append
(
System
.
identityHashCode
(
this
)).
append
(
'\n'
);
buff
.
append
(
"pos: "
).
append
(
Long
.
toHexString
(
pos
)).
append
(
'\n'
);
...
...
@@ -490,6 +501,13 @@ public abstract class Page implements Cloneable
*/
abstract
Page
split
(
int
at
);
/**
* Split the current keys array into two arrays.
*
* @param aCount size of the first array.
* @param bCount size of the second array/
* @return the second array.
*/
final
Object
[]
splitKeys
(
int
aCount
,
int
bCount
)
{
assert
aCount
+
bCount
<=
getKeyCount
();
Object
[]
aKeys
=
createKeyStorage
(
aCount
);
...
...
@@ -502,6 +520,12 @@ public abstract class Page implements Cloneable
abstract
void
expand
(
int
extraKeyCount
,
Object
[]
extraKeys
,
Object
[]
extraValues
);
/**
* Expand the keys array.
*
* @param extraKeyCount number of extra key entries to create
* @param extraKeys extra key values
*/
final
void
expandKeys
(
int
extraKeyCount
,
Object
[]
extraKeys
)
{
int
keyCount
=
getKeyCount
();
Object
[]
newKeys
=
createKeyStorage
(
keyCount
+
extraKeyCount
);
...
...
@@ -580,6 +604,12 @@ public abstract class Page implements Cloneable
*/
public
abstract
void
insertNode
(
int
index
,
Object
key
,
Page
childPage
);
/**
* Insert a key into the key array
*
* @param index index to insert at
* @param key the key value
*/
final
void
insertKey
(
int
index
,
Object
key
)
{
int
keyCount
=
getKeyCount
();
assert
index
<=
keyCount
:
index
+
" > "
+
keyCount
;
...
...
@@ -660,6 +690,11 @@ public abstract class Page implements Cloneable
recalculateMemory
();
}
/**
* Read the page payload from the buffer.
*
* @param buff the buffer
*/
protected
abstract
void
readPayLoad
(
ByteBuffer
buff
);
public
final
boolean
isSaved
()
{
...
...
@@ -748,8 +783,19 @@ public abstract class Page implements Cloneable
return
typePos
+
1
;
}
/**
* Write values that the buffer contains to the buff.
*
* @param buff the target buffer
*/
protected
abstract
void
writeValues
(
WriteBuffer
buff
);
/**
* Write page children to the buff.
*
* @param buff the target buffer
* @param withCounts true if the descendant counts should be written
*/
protected
abstract
void
writeChildren
(
WriteBuffer
buff
,
boolean
withCounts
);
/**
...
...
@@ -829,6 +875,11 @@ public abstract class Page implements Cloneable
memory
=
calculateMemory
();
}
/**
* Calculate estimated memory used in persistent case.
*
* @return memory in bytes
*/
protected
int
calculateMemory
()
{
int
mem
=
keys
.
length
*
MEMORY_POINTER
;
DataType
keyType
=
map
.
getKeyType
();
...
...
@@ -842,6 +893,9 @@ public abstract class Page implements Cloneable
return
true
;
}
/**
* Called when done with copying page.
*/
public
void
setComplete
()
{}
/**
...
...
@@ -859,13 +913,28 @@ public abstract class Page implements Cloneable
public
abstract
CursorPos
getAppendCursorPos
(
CursorPos
cursorPos
);
/**
* Remove all page data recursively.
*/
public
abstract
void
removeAllRecursive
();
/**
* Create array for keys storage.
*
* @param size number of entries
* @return values array
*/
private
Object
[]
createKeyStorage
(
int
size
)
{
return
new
Object
[
size
];
}
/**
* Create array for values storage.
*
* @param size number of entries
* @return values array
*/
final
Object
[]
createValueStorage
(
int
size
)
{
return
new
Object
[
size
];
...
...
@@ -876,6 +945,9 @@ public abstract class Page implements Cloneable
*/
public
static
final
class
PageReference
{
/**
* Singleton object used when arrays of PageReference have not yet been filled.
*/
public
static
final
PageReference
EMPTY
=
new
PageReference
(
null
,
0
,
0
);
/**
...
...
@@ -928,6 +1000,9 @@ public abstract class Page implements Cloneable
return
pos
;
}
/**
* Re-acquire position from in-memory page.
*/
void
resetPos
()
{
Page
p
=
page
;
if
(
p
!=
null
&&
p
.
isSaved
())
{
...
...
h2/src/main/org/h2/mvstore/cache/CacheLongKeyLIRS.java
浏览文件 @
78155dab
...
...
@@ -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
浏览文件 @
78155dab
...
...
@@ -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
浏览文件 @
78155dab
...
...
@@ -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
浏览文件 @
78155dab
...
...
@@ -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
final
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
浏览文件 @
78155dab
...
...
@@ -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
浏览文件 @
78155dab
...
...
@@ -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
浏览文件 @
78155dab
...
...
@@ -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/util/StringUtils.java
浏览文件 @
78155dab
h2/src/main/org/h2/value/ValueInterval.java
浏览文件 @
78155dab
h2/src/main/org/h2/value/VersionedValue.java
浏览文件 @
78155dab
...
...
@@ -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
浏览文件 @
78155dab
...
...
@@ -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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论