Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
904fe287
提交
904fe287
authored
4月 14, 2018
作者:
andrei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code review comments addressed
上级
00dbc15d
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
104 行增加
和
78 行删除
+104
-78
Session.java
h2/src/main/org/h2/engine/Session.java
+17
-15
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+5
-5
Transaction.java
h2/src/main/org/h2/mvstore/tx/Transaction.java
+5
-5
TransactionMap.java
h2/src/main/org/h2/mvstore/tx/TransactionMap.java
+1
-1
TransactionStore.java
h2/src/main/org/h2/mvstore/tx/TransactionStore.java
+43
-11
VersionedBitSet.java
h2/src/main/org/h2/mvstore/tx/VersionedBitSet.java
+2
-11
TestMVStoreTool.java
h2/src/test/org/h2/test/store/TestMVStoreTool.java
+1
-1
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+30
-29
没有找到文件。
h2/src/main/org/h2/engine/Session.java
浏览文件 @
904fe287
...
...
@@ -818,6 +818,10 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
}
}
}
// Because cache may have captured query result (in Query.lastResult),
// which is based on data from uncommitted transaction.,
// It is not valid after rollback, therefore cache has to be cleared.
if
(
queryCache
!=
null
)
{
queryCache
.
clear
();
}
...
...
@@ -1788,19 +1792,17 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
private
static
Row
getRowFromVersionedValue
(
MVTable
table
,
long
recKey
,
VersionedValue
versionedValue
)
{
Object
value
=
versionedValue
==
null
?
null
:
versionedValue
.
value
;
Row
result
=
null
;
if
(
value
!=
null
)
{
Row
result11
;
if
(
value
==
null
)
{
return
null
;
}
Row
result
;
if
(
value
instanceof
Row
)
{
result11
=
(
Row
)
value
;
assert
result11
.
getKey
()
==
recKey
:
result11
.
getKey
()
+
" != "
+
recKey
;
result
=
(
Row
)
value
;
assert
result
.
getKey
()
==
recKey
:
result
.
getKey
()
+
" != "
+
recKey
;
}
else
{
ValueArray
array
=
(
ValueArray
)
value
;
result11
=
table
.
createRow
(
array
.
getList
(),
0
);
result11
.
setKey
(
recKey
);
}
result
=
result11
;
result
=
table
.
createRow
(
array
.
getList
(),
0
);
result
.
setKey
(
recKey
);
}
return
result
;
}
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
904fe287
h2/src/main/org/h2/mvstore/tx/Transaction.java
浏览文件 @
904fe287
...
...
@@ -98,7 +98,7 @@ public class Transaction {
public
final
long
sequenceNum
;
/*
* Transation state is an atomic composite field:
* Transa
c
tion state is an atomic composite field:
* bit 45 : flag whether transaction had rollback(s)
* bits 44-41 : status
* bits 40 : overflow control bit, 1 indicates overflow
...
...
h2/src/main/org/h2/mvstore/tx/TransactionMap.java
浏览文件 @
904fe287
h2/src/main/org/h2/mvstore/tx/TransactionStore.java
浏览文件 @
904fe287
...
...
@@ -63,8 +63,20 @@ public class TransactionStore {
private
final
DataType
dataType
;
/**
* This BitSet is used as vacancy indicator for transaction slots in transactions[].
* It provides easy way to find first unoccupied slot, and also allows for copy-on-write
* non-blocking updates.
*/
final
AtomicReference
<
VersionedBitSet
>
openTransactions
=
new
AtomicReference
<>(
new
VersionedBitSet
());
/**
* This is intended to be the source of ultimate truth about transaction being committed.
* Once bit is set, corresponding transaction is logically committed,
* although it might be plenty of "uncommitted" entries in various maps
* and undo record are still around.
* Nevertheless, all of those should be considered by other transactions as committed.
*/
final
AtomicReference
<
BitSet
>
committingTransactions
=
new
AtomicReference
<>(
new
BitSet
());
private
boolean
init
;
...
...
@@ -78,6 +90,7 @@ public class TransactionStore {
/**
* Array holding all open transaction objects.
* Position in array is "transaction id".
* VolatileReferenceArray would do the job here, but there is no such thing in Java yet
*/
private
final
AtomicReferenceArray
<
Transaction
>
transactions
=
new
AtomicReferenceArray
<>(
MAX_OPEN_TRANSACTIONS
);
...
...
@@ -91,7 +104,7 @@ public class TransactionStore {
* Hard limit on the number of concurrently opened transactions
*/
// TODO: introduce constructor parameter instead of a static field, driven by URL parameter
private
static
final
int
MAX_OPEN_TRANSACTIONS
=
0x
1
00
;
private
static
final
int
MAX_OPEN_TRANSACTIONS
=
0x
4
00
;
...
...
@@ -195,7 +208,7 @@ public class TransactionStore {
*/
public
void
setMaxTransactionId
(
int
max
)
{
DataUtils
.
checkArgument
(
max
<=
MAX_OPEN_TRANSACTIONS
,
"Concurrent transactions limit is too high
t
: {0}"
,
max
);
"Concurrent transactions limit is too high: {0}"
,
max
);
this
.
maxTransactionId
=
max
;
}
...
...
@@ -322,7 +335,7 @@ public class TransactionStore {
"There are {0} open transactions"
,
transactionId
-
1
);
}
VersionedBitSet
clone
=
original
.
clone
It
();
VersionedBitSet
clone
=
original
.
clone
();
clone
.
set
(
transactionId
);
sequenceNo
=
clone
.
getVersion
()
+
1
;
clone
.
setVersion
(
sequenceNo
);
...
...
@@ -331,8 +344,8 @@ public class TransactionStore {
Transaction
transaction
=
new
Transaction
(
this
,
transactionId
,
sequenceNo
,
status
,
name
,
logId
,
listener
);
success
=
transactions
.
compareAndSet
(
transactionId
,
null
,
transaction
)
;
assert
success
;
assert
transactions
.
get
(
transactionId
)
==
null
;
transactions
.
set
(
transactionId
,
transaction
)
;
return
transaction
;
}
...
...
@@ -420,7 +433,9 @@ public class TransactionStore {
*
* @param t the transaction
* @param maxLogId the last log id
* @param hasChanges false for R/O tx
* @param hasChanges true if there were updates within specified
* transaction (even fully rolled back),
* false if just data access
*/
void
commit
(
Transaction
t
,
long
maxLogId
,
boolean
hasChanges
)
{
if
(
store
.
isClosed
())
{
...
...
@@ -571,12 +586,14 @@ public class TransactionStore {
int
txId
=
t
.
transactionId
;
t
.
setStatus
(
Transaction
.
STATUS_CLOSED
);
boolean
success
=
transactions
.
compareAndSet
(
txId
,
t
,
null
);
assert
success
;
assert
transactions
.
get
(
txId
)
==
t
:
transactions
.
get
(
txId
)
+
" != "
+
t
;
transactions
.
set
(
txId
,
null
);
boolean
success
;
do
{
VersionedBitSet
original
=
openTransactions
.
get
();
assert
original
.
get
(
txId
);
VersionedBitSet
clone
=
original
.
clone
It
();
VersionedBitSet
clone
=
original
.
clone
();
clone
.
clear
(
txId
);
success
=
openTransactions
.
compareAndSet
(
original
,
clone
);
}
while
(!
success
);
...
...
@@ -755,16 +772,31 @@ public class TransactionStore {
}
}
/**
* This listener can be registered with the transaction to be notified of
* every compensating change during transaction rollback.
* Normally this is not required, if no external resources were modified,
* because state of all transactional maps will be restored automatically.
* Only state of external resources, possibly modified by triggers
* need to be restored.
*/
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
* @param key of the modified entry
* @param existingValue value in the map (null if delete is rolled back)
* @param restoredValue value to be restored (null if add is rolled back)
*/
void
onRollback
(
MVMap
<
Object
,
VersionedValue
>
map
,
Object
key
,
VersionedValue
existingValue
,
VersionedValue
restoredValue
);
}
...
...
h2/src/main/org/h2/mvstore/tx/VersionedBitSet.java
浏览文件 @
904fe287
...
...
@@ -10,8 +10,6 @@ import java.util.BitSet;
/**
* Class VersionedBitSet extends standard BitSet to add a version field.
* This will allow bit set and version to be changed atomically.
*
* @author <a href='mailto:andrei.tokar@gmail.com'>Andrei Tokar</a>
*/
final
class
VersionedBitSet
extends
BitSet
{
...
...
@@ -27,15 +25,8 @@ final class VersionedBitSet extends BitSet
this
.
version
=
version
;
}
public
VersionedBitSet
cloneIt
()
{
VersionedBitSet
res
=
(
VersionedBitSet
)
super
.
clone
();
res
.
version
=
version
;
return
res
;
}
@Override
@SuppressWarnings
(
"MethodDoesntCallSuperMethod"
)
public
Object
clone
()
{
return
cloneIt
();
public
VersionedBitSet
clone
()
{
return
(
VersionedBitSet
)
super
.
clone
();
}
}
h2/src/test/org/h2/test/store/TestMVStoreTool.java
浏览文件 @
904fe287
...
...
@@ -107,7 +107,7 @@ public class TestMVStoreTool extends TestBase {
assertEquals
(
size2
,
FileUtils
.
size
(
fileNameNew
));
MVStoreTool
.
compact
(
fileNameCompressed
,
true
);
assertEquals
(
size3
,
FileUtils
.
size
(
fileNameCompressed
));
trace
(
"Recompacted in "
+
(
System
.
currentTimeMillis
()
-
start
)
+
" ms."
);
trace
(
"Re
-
compacted in "
+
(
System
.
currentTimeMillis
()
-
start
)
+
" ms."
);
start
=
System
.
currentTimeMillis
();
MVStore
s1
=
new
MVStore
.
Builder
().
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
904fe287
...
...
@@ -17,7 +17,7 @@ agent agentlib agg aggregate aggregated aggregates aggregating aggressive agile
agrave agree agreeable agreed agreement agreements agrees ahead
ahilmnqbjkcdeopfrsg aid air ajax alan alarm ale alefsym alert alessio alexander alfki
algo algorithm algorithms alias aliased aliases aliasing align aligned alignment
alive all allclasses alleged alleging allocate allocated allocates allocating
alive all allclasses alleged alleging alloc
alloc
ate allocated allocates allocating
allocation allow allowed allowing allows almost aload alone along alpha
alphabetical alphabetically already also alt alter altering alternate alternative
alternatives alters although always ambiguity ambiguous america among amount amp
...
...
@@ -108,11 +108,12 @@ combo combobox come comes coming comma command commands commas comment commented
comments commercial commit commits committed committing common commonly commons
communicates communication community comp compact compacted compacting compaction
compacts companies company comparable comparative comparator compare compared
compares comparing comparison comparisons compatibility compatible compensation
compilable compilation compile compiled compiler compiles compiling complete
completed completely completion complex complexity compliance compliant
compares comparing comparison comparisons compatibility compatible
compensation compensating compilable compilation compile compiled
compiler compiles compiling complete completed completely
completion complex complexity compliance compliant
complicate complicated complies comply complying component components composed
composite compound compounds compress compressed compresses compressibility
compos
e compos
ite compound compounds compress compressed compresses compressibility
compressible compressing compression compressor compromise compsci computation
compute computed computer computers computing con concat concatenate concatenated
concatenates concatenating concatenation concentrate concept concerning concrete
...
...
@@ -187,8 +188,8 @@ differs dig digest digit digital digits diligence dim dimension dimensional
dimensions dimitrijs dinamica dining dip dips dir direct direction directly
directories directory directs dirname dirs dirty disable disabled
disablelastaccess disables disabling disadvantage disadvantages disallow
disallowed disappear disappear
ed disc disclaimed disclaimer disclaimers disclaim
s
disclosed disconnect disconnected disconnecting disconnections disconnects
disallowed disappear disappear
ance disappeared disc disclaimed disclaimer disclaimer
s
discl
aims discl
osed disconnect disconnected disconnecting disconnections disconnects
discontinue discount discriminator discussion disjunctive disk disks dispatch
dispatcher display displayed displaying displays dispose disposed disposition
disputes dist distance distinct distinguish distinguishable distinguished
...
...
@@ -212,16 +213,16 @@ effort egrave eid eing eins einstellung either elapsed eldest elect electronic
element elements elephant elig eligible eliminate elisabetta ell ellipsis elm else
elsewhere elton email emails embedded embedding embeds emergency emf emit emitted
emma empire employee empty emsp emulate emulated emulates emulation enable
enabled enables enabling enc encapsulate
s enclose enclosed enclosing encode
encoded encoder encodes encoding encountered encounters encrypt encrypted
enabled enables enabling enc encapsulate
encapsulates enclose enclosed enclosing
encode
encode
d encoder encodes encoding encountered encounters encrypt encrypted
encrypting encryption encrypts end ended enderbury endif ending endings endless
endlessly endorse ends enforce enforceability enforceable enforced engine engines
english enhance enhanced enhancement enhancer enlarge enough enqueued ensp ensure
ensures ensuring enter entered entering enterprise entire entities entity entrance
entries entry enum enumerate enumerated enumerator enumerators enumeration env envelope
environment environments enwiki eof eol epl epoch epoll epsilon equal equality equally
equals equipment equitable equiv equivalen
t equivalents era erable eremainder eric
erik err error errorlevel errors erwan ery esc escape escaped escapes escaping
equals equipment equitable equiv equivalen
ce equivalent equivalents era erable eremainder
eri
c eri
k err error errorlevel errors erwan ery esc escape escaped escapes escaping
escargots ese espa essential essentials established estimate estimated estimates
estimating estimation estoppel eta etc eth etl euml euro europe europeu euros eva eval
evaluatable evaluate evaluated evaluates evaluating evaluation evdokimov even evenly
...
...
@@ -301,8 +302,8 @@ ideas identical identification identified identifier identifiers identify identi
identities identity idiomatic idiv idle ids idx idxname iee ieee iexcl iface ifeq
ifexists ifge ifgt ifle iflt ifne ifnonnull ifnull iframe ifx ignore ignorecase ignored
ignoredriverprivileges ignorelist ignores ignoring ignite igrave iinc ikura ikvm ikvmc
illegal il
oad image imageio images imaginary img iml immediately immutable imola imp
impact imperial impersonate impl imple implement implementation implementations
illegal il
legally iload image imageio images imaginary img iml immediately immutable
im
ola imp im
pact imperial impersonate impl imple implement implementation implementations
implemented implementing implements implication implicit implicitly implied
implies import important imported importing imports impose imposes impossible
improperly improve improved improvement improvements improves improving imul
...
...
@@ -373,8 +374,8 @@ literal literals litigation little live lives ljava llc lload lmul lneg lnot loa
loaded loader loading loads lob lobs local localdb locale locales localhost
locality localization localized localname locals locate located locates location
locations locators lock locked locker locking locks log logback logged logger
logging logic logical logi
n logins logo logos logout logs logsize long longblob
longer longest longitude longnvarchar longs longtext longvarbinary longvarchar
logging logic logical logi
cally login logins logo logos logout logs logsize long
long
blob long
er longest longitude longnvarchar longs longtext longvarbinary longvarchar
look lookahead looking looks lookup lookups lookupswitch loop loopback looping
loops loose lor lore lose losing loss losses lossless losslessly lost lot lots
low lowast lower lowercase lowercased lowest loz lpad lrem lreturn lrm lru lsaquo
...
...
@@ -412,20 +413,20 @@ mpl msg mssql mssqlserver msxml much mueller mul multi multianewarray multipart
multiple multiples multiplication multiplied multiply multiplying multithreaded
multithreading multiuser music must mutable mutate mutation mutationtest muttered
mutton mutually mvc mvcc mvn mvr mvstore mydb myna myself mysql mysqladmin mysqld
myster
y mystic myydd nabla naive naked name namecnt named names namespace naming
nan nano nanos nanosecond nanoseconds nantes napping national nations native
myster
ious mystery mystic myydd nabla naive naked name namecnt named names namespace
na
ming na
n nano nanos nanosecond nanoseconds nantes napping national nations native
natural nature naur nav navigable navigate navigation navigator nbsp ncgc nchar
nclob ncr ndash near nearest nearly necessarily necessary nederlands need needed
needing needs neg negate negated negating negation negative negligence
negotiations neighbor neither nelson neo nest nested nesterov nesting net
netbeans netherlands netscape netstat network networked networks never ne
w
newarray newer newest newline newlines newly news newsfeed newsfeeds newsgroups
netbeans netherlands netscape netstat network networked networks never ne
vertheless
new
new
array newer newest newline newlines newly news newsfeed newsfeeds newsgroups
newsletter next nextval nfontes nger nice nicer nicolas night nih niklas nikolaj
niku nine nio nls nlst noah nobody nobuffer nocache nocheck nocycle nodata nodded
node nodelay nodes noel noframe noframes noindex noi
se nomaxvalue nominvalue non
no
nce noncompliance none noop nop nopack nopasswords nopmd nor noresize normal
nor
malize normalized normally northern northwoods norway nosettings not nota
notably notation notch note notes nothing notice notices notification notified
node nodelay nodes noel noframe noframes noindex noi
nspection noise nomaxvalue
no
minvalue non nonce noncompliance none noop nop nopack nopasswords nopmd nor
nor
esize normal normalize normalized normally northern northwoods norway nosettings
not
nota not
ably notation notch note notes nothing notice notices notification notified
notifies notify notifying notin notranslate notwithstanding nougat nov novelist
november now nowait nowrap npl nsi nsis nsub ntext ntfs nth ntilde nucleus nul
null nullable nullid nullif nulls nullsoft num number numbering numbers numeral
...
...
@@ -471,7 +472,7 @@ petra pfgrc pfister pgdn pgup phane phantom phase phi philip philippe
philosophers phone php phrase phrases phromros physical pick picked pickle pico
pid pieces pier pietrzak pilot piman ping pinned pipe piped pit pitest piv pivot
pkcolumn pkcs pktable place placed placeholders places placing plain plaintext
plan planned planner planning plans plant platform platforms play player please
plan planned planner planning plans plant pl
enty pl
atform platforms play player please
plug pluggable plugin plugins plus plusmn png point pointbase pointed pointer pointers
pointing points poker poland polar pole poleposition policies policy polish poll
polling polski poly polygon pom pondered poodle pool poolable pooled pooling
...
...
@@ -658,18 +659,18 @@ tools toolset top topic topics toplink topology tort total totals touch toward
tpc trace traces tracing track tracked tracker tracking tracks trade trademark
trademarks traditional traditionally trailing train trans transact transaction
transactional transactionally transactions transfer transferred transferring
transform transformation transient transiently transition transitional
transform transformation transient transiently transition transitional
transitioned
transitions translatable translate translated translates translating translation
translations translator transmission transmitted transparent transport travel
traversal traverse traversing tray tread treat treated treatment trede tree trees
trial trick tricky tried tries trig trigger triggered triggers trigonometric trim
trimmed trims trip trivial trouble true trunc truncate truncated truncates
truncating truncation trunk trust trusted trx try trying tsi tsmsys tsv tucc
truncating truncation trunk trust trusted tr
uth tr
x try trying tsi tsmsys tsv tucc
tucker tuesday tune tunes tuning turkel turkish turn turned turns tutorial tweak
tweaking tweet twelve twice twitter two txt tymczak type typed typeof types typesafe
typical typically typing typlen typname typo typos typtypmod tzd tzh tzm tzr
uacute uarr ubuntu ucase ucb ucirc ucs udt udts uffff ugly ugrave uid uint ujint
ujlong ulimit uml umlaut umr unable unaligned unary unavailability unbound
ujlong ulimit u
ltimate u
ml umlaut umr unable unaligned unary unavailability unbound
uncached uncaught unchanged unchecked uncle unclear unclosed uncommitted uncommon
uncompressed undefined under underflow undergraduate underline underlined
underlying underneath underscore understand understanding understands understood
...
...
@@ -679,7 +680,7 @@ unindexed uninitialized uninstall uninteresting uninterpreted uninterruptible
union unique uniquely uniqueness uniques unit united units universal universally
unix unixtime unknown unless unlike unlikely unlimited unlink unlinked unload unloaded
unloading unloads unlock unlocked unlocking unlocks unmaintained unmappable
unmapped unmodified unmounted unnamed unnecessarily unnecessary unneeded uno
unmapped unmodified unmounted unnamed unnecessarily unnecessary unneeded uno
unoccupied
unofficial unordered unpredictable unquoted unrecognized unrecoverable
unreferenced unregister unregisters unrelated unreleased unsafe unsaved unscaled
unset unsigned unsorted unspecified unstable unsuccessful unsupported
...
...
@@ -689,7 +690,7 @@ updating upgrade upgraded upgrader upgrades upgrading upload uploaded upon upper
uppercase uppercased uppermost ups upsert upset upside upsih upsilon urgent urgently
uri url urls usa usable usage usd use used useful user userbyid username userpwd
users uses using usr usual usually utc ute utf util utilities utility utilization
utilize utilizes utils uui uuid uuml vacuum vacuuming val valid validate
utilize utilizes utils uui uuid uuml vac
ancy vac
uum vacuuming val valid validate
validated validates validating validation validities validity validly valign
valuable value values van var varargs varbinary varchar variable variables
variance variant variants varies various varp varray vars vary varying vasilakis
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论