Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c4a00eb9
提交
c4a00eb9
authored
10月 08, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix formatting.
上级
2526201d
隐藏空白字符变更
内嵌
并排
正在显示
21 个修改的文件
包含
103 行增加
和
76 行删除
+103
-76
Query.java
h2/src/main/org/h2/command/dml/Query.java
+1
-1
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+3
-3
Engine.java
h2/src/main/org/h2/engine/Engine.java
+1
-1
FileStore.java
h2/src/main/org/h2/mvstore/FileStore.java
+3
-3
MVMap.java
h2/src/main/org/h2/mvstore/MVMap.java
+1
-1
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+8
-8
MVStoreTool.java
h2/src/main/org/h2/mvstore/MVStoreTool.java
+5
-5
Page.java
h2/src/main/org/h2/mvstore/Page.java
+1
-1
FilePathCache.java
h2/src/main/org/h2/mvstore/cache/FilePathCache.java
+1
-1
FileChannelInputStream.java
h2/src/main/org/h2/store/fs/FileChannelInputStream.java
+3
-3
FilePathZip.java
h2/src/main/org/h2/store/fs/FilePathZip.java
+1
-1
ChangeFileEncryption.java
h2/src/main/org/h2/tools/ChangeFileEncryption.java
+1
-1
ScriptReader.java
h2/src/main/org/h2/util/ScriptReader.java
+37
-11
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+4
-4
TestScript.java
h2/src/test/org/h2/test/db/TestScript.java
+1
-1
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+4
-3
TestKillProcessWhileWriting.java
...c/test/org/h2/test/store/TestKillProcessWhileWriting.java
+7
-7
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+7
-7
TestRandomMapOps.java
h2/src/test/org/h2/test/store/TestRandomMapOps.java
+7
-7
TestStreamStore.java
h2/src/test/org/h2/test/store/TestStreamStore.java
+3
-3
TestFileSystem.java
h2/src/test/org/h2/test/unit/TestFileSystem.java
+4
-4
没有找到文件。
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
c4a00eb9
...
...
@@ -512,7 +512,7 @@ public abstract class Query extends Prepared {
public
void
setSampleSize
(
Expression
sampleSize
)
{
this
.
sampleSizeExpr
=
sampleSize
;
}
protected
final
int
getSampleSizeValue
(
Session
session
)
{
if
(
sampleSizeExpr
==
null
)
{
return
0
;
...
...
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
c4a00eb9
...
...
@@ -405,9 +405,9 @@ public class ConnectionInfo implements Cloneable {
public
byte
[]
getFilePasswordHash
()
{
return
filePasswordHash
;
}
byte
[]
getFileEncryptionKey
()
{
return
fileEncryptionKey
;
return
fileEncryptionKey
;
}
/**
...
...
@@ -549,7 +549,7 @@ public class ConnectionInfo implements Cloneable {
public
void
setFilePasswordHash
(
byte
[]
hash
)
{
this
.
filePasswordHash
=
hash
;
}
public
void
setFileEncryptionKey
(
byte
[]
key
)
{
this
.
fileEncryptionKey
=
key
;
}
...
...
h2/src/main/org/h2/engine/Engine.java
浏览文件 @
c4a00eb9
...
...
@@ -165,7 +165,7 @@ public class Engine implements SessionFactory {
// wait a bit to avoid a busy loop (the method is synchronized)
if
(
i
>
60
*
1000
)
{
// retry at most 1 minute
throw
DbException
.
get
(
ErrorCode
.
DATABASE_ALREADY_OPEN_1
,
throw
DbException
.
get
(
ErrorCode
.
DATABASE_ALREADY_OPEN_1
,
"Waited for database closing longer than 1 minute"
);
}
try
{
...
...
h2/src/main/org/h2/mvstore/FileStore.java
浏览文件 @
c4a00eb9
...
...
@@ -59,7 +59,7 @@ public class FileStore {
* The file.
*/
protected
FileChannel
file
;
/**
* The encrypted file (if encryption is used).
*/
...
...
@@ -228,13 +228,13 @@ public class FileStore {
public
FileChannel
getFile
()
{
return
file
;
}
/**
* Get the encrypted file instance, if encryption is used.
* <p>
* The application may read from the file (for example for online backup),
* but not write to it or truncate it.
*
*
* @return the encrypted file, or null if encryption is not used
*/
public
FileChannel
getEncryptedFile
()
{
...
...
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
c4a00eb9
...
...
@@ -688,7 +688,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
if
(
p
.
getKeyCount
()
==
0
)
{
p
.
setChild
(
index
,
c
);
p
.
setCounts
(
index
,
c
);
c
.
removePage
();
c
.
removePage
();
}
else
{
p
.
remove
(
index
);
}
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
c4a00eb9
...
...
@@ -332,7 +332,7 @@ public class MVStore {
// setWriteDelay starts the thread, but only if
// the parameter is different than the current value
o
=
config
.
get
(
"writeDelay"
);
int
writeDelay
=
o
==
null
?
1000
:
(
Integer
)
o
;
setWriteDelay
(
writeDelay
);
...
...
@@ -486,10 +486,10 @@ public class MVStore {
meta
.
remove
(
"root."
+
id
);
maps
.
remove
(
id
);
}
/**
* Check whether a given map exists.
*
*
* @param name the map name
* @return true if it exists
*/
...
...
@@ -651,14 +651,14 @@ public class MVStore {
}
if
(
fileStore
!=
null
&&
!
fileStore
.
isReadOnly
())
{
stopBackgroundThread
();
if
(
currentStoreVersion
>=
0
)
{
// in this case, store is called manually in another thread
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_WRITING_FAILED
,
DataUtils
.
ERROR_WRITING_FAILED
,
"Can not close while storing"
);
}
if
(
hasUnsavedChanges
()
||
lastCommittedVersion
!=
currentVersion
)
{
rollbackTo
(
lastCommittedVersion
);
metaChanged
=
true
;
...
...
@@ -824,7 +824,7 @@ public class MVStore {
currentStoreVersion
=
-
1
;
}
}
private
long
storeNow
(
boolean
temp
)
{
int
currentUnsavedPageCount
=
unsavedPageCount
;
long
storeVersion
=
currentStoreVersion
;
...
...
@@ -1232,7 +1232,7 @@ public class MVStore {
reuseSpace
=
true
;
for
(
Chunk
c
:
move
)
{
if
(!
chunks
.
containsKey
(
c
.
id
))
{
// already removed during the
// already removed during the
// previous store operation
continue
;
}
...
...
h2/src/main/org/h2/mvstore/MVStoreTool.java
浏览文件 @
c4a00eb9
...
...
@@ -38,7 +38,7 @@ public class MVStoreTool {
}
}
}
/**
* Read the contents of the file and write them to system out.
*
...
...
@@ -135,10 +135,10 @@ public class MVStoreTool {
counts
[
i
]
=
s
;
}
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
pw
.
println
(
" < "
+
keys
[
i
]
+
": "
+
pw
.
println
(
" < "
+
keys
[
i
]
+
": "
+
counts
[
i
]
+
" -> "
+
getPosString
(
children
[
i
]));
}
pw
.
println
(
" >= : "
+
pw
.
println
(
" >= : "
+
counts
[
len
]
+
" -> "
+
getPosString
(
children
[
len
]));
}
else
{
// meta map leaf
...
...
@@ -169,9 +169,9 @@ public class MVStoreTool {
pw
.
println
();
pw
.
flush
();
}
private
static
String
getPosString
(
long
pos
)
{
return
"pos "
+
pos
+
", chunk "
+
DataUtils
.
getPageChunkId
(
pos
)
+
return
"pos "
+
pos
+
", chunk "
+
DataUtils
.
getPageChunkId
(
pos
)
+
", offset "
+
DataUtils
.
getPageOffset
(
pos
);
}
...
...
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
c4a00eb9
...
...
@@ -174,7 +174,7 @@ public class Page {
maxLength
=
(
int
)
Math
.
min
(
fileSize
-
filePos
,
maxLength
);
int
length
=
maxLength
;
if
(
length
<
0
)
{
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_FILE_CORRUPT
,
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_FILE_CORRUPT
,
"Illegal page length {0} reading at {1}; file size {1} "
,
length
,
filePos
,
fileSize
);
}
buff
=
fileStore
.
readFully
(
filePos
,
length
);
...
...
h2/src/main/org/h2/mvstore/cache/FilePathCache.java
浏览文件 @
c4a00eb9
...
...
@@ -129,7 +129,7 @@ public class FilePathCache extends FilePathWrapper {
clearCache
(
src
,
position
());
return
base
.
write
(
src
);
}
private
void
clearCache
(
ByteBuffer
src
,
long
position
)
{
if
(
cache
.
size
()
>
0
)
{
int
len
=
src
.
remaining
();
...
...
h2/src/main/org/h2/store/fs/FileChannelInputStream.java
浏览文件 @
c4a00eb9
...
...
@@ -18,13 +18,13 @@ public class FileChannelInputStream extends InputStream {
private
final
FileChannel
channel
;
private
final
boolean
closeChannel
;
private
ByteBuffer
buffer
;
private
long
pos
;
/**
* Create a new file object input stream from the file channel.
*
*
* @param channel the file channel
* @param closeChannel whether closing the stream should close the channel
*/
...
...
@@ -36,7 +36,7 @@ public class FileChannelInputStream extends InputStream {
@Override
public
int
read
()
throws
IOException
{
if
(
buffer
==
null
)
{
buffer
=
ByteBuffer
.
allocate
(
1
);
buffer
=
ByteBuffer
.
allocate
(
1
);
}
buffer
.
rewind
();
int
len
=
channel
.
read
(
buffer
,
pos
++);
...
...
h2/src/main/org/h2/store/fs/FilePathZip.java
浏览文件 @
c4a00eb9
...
...
@@ -378,7 +378,7 @@ class FileZip extends FileBase {
}
return
null
;
}
@Override
protected
void
implCloseChannel
()
throws
IOException
{
if
(
in
!=
null
)
{
...
...
h2/src/main/org/h2/tools/ChangeFileEncryption.java
浏览文件 @
c4a00eb9
...
...
@@ -206,7 +206,7 @@ public class ChangeFileEncryption extends Tool {
in
.
init
();
copy
(
fileName
,
in
,
encrypt
);
}
private
void
copy
(
String
fileName
)
throws
IOException
{
if
(
FileUtils
.
isDirectory
(
fileName
))
{
return
;
...
...
h2/src/main/org/h2/util/ScriptReader.java
浏览文件 @
c4a00eb9
...
...
@@ -18,23 +18,49 @@ import org.h2.message.DbException;
* in comments and quotes.
*/
public
class
ScriptReader
{
private
final
Reader
reader
;
private
char
[]
buffer
;
/** position in the buffer of the next char to be read */
/**
* The position in the buffer of the next char to be read
*/
private
int
bufferPos
;
/** position in the buffer of the statement start */
/**
* The position in the buffer of the statement start
*/
private
int
bufferStart
=
-
1
;
/** position in the buffer of the last available char */
/**
* The position in the buffer of the last available char
*/
private
int
bufferEnd
;
/** true if we have read past the end of file */
/**
* True if we have read past the end of file
*/
private
boolean
endOfFile
;
/** true if we are inside a comment */
/**
* True if we are inside a comment
*/
private
boolean
insideRemark
;
/** Only valid if insideRemark is true. True if we are inside a block comment, false if we are inside a line comment */
/**
* Only valid if insideRemark is true. True if we are inside a block
* comment, false if we are inside a line comment
*/
private
boolean
blockRemark
;
/** true if comments should be skipped completely by this reader. */
/**
* True if comments should be skipped completely by this reader.
*/
private
boolean
skipRemarks
;
/** position in buffer of start of comment */
/**
* The position in buffer of start of comment
*/
private
int
remarkStart
;
/**
...
...
@@ -239,9 +265,9 @@ public class ScriptReader {
if
(
keep
+
Constants
.
IO_BUFFER_SIZE
>
src
.
length
)
{
// protect against NegativeArraySizeException
if
(
src
.
length
>=
Integer
.
MAX_VALUE
/
2
)
{
throw
new
IOException
(
"Error in parsing script, "
+
"statement size exceeds 1G, "
+
"first 80 characters of statement looks like: "
+
throw
new
IOException
(
"Error in parsing script, "
+
"statement size exceeds 1G, "
+
"first 80 characters of statement looks like: "
+
new
String
(
buffer
,
bufferStart
,
80
));
}
buffer
=
new
char
[
src
.
length
*
2
];
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
c4a00eb9
...
...
@@ -712,9 +712,9 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
// synth
new
TestBtreeIndex
().
runTest
(
this
);
new
TestDiskFull
().
runTest
(
this
);
new
TestCrashAPI
().
runTest
(
this
);
new
TestFuzzOptimizations
().
runTest
(
this
);
new
TestLimit
().
runTest
(
this
);
new
TestRandomSQL
().
runTest
(
this
);
...
...
@@ -761,9 +761,9 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
new
TestFile
().
runTest
(
this
);
new
TestFileLock
().
runTest
(
this
);
new
TestFileLockProcess
().
runTest
(
this
);
new
TestFileLockSerialized
().
runTest
(
this
);
new
TestFtp
().
runTest
(
this
);
new
TestFileSystem
().
runTest
(
this
);
new
TestIntArray
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/db/TestScript.java
浏览文件 @
c4a00eb9
...
...
@@ -46,7 +46,7 @@ public class TestScript extends TestBase {
private
String
putBack
;
private
StringBuilder
errors
;
private
ArrayList
<
String
>
statements
;
private
Random
random
=
new
Random
(
1
);
/**
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
c4a00eb9
...
...
@@ -1170,7 +1170,8 @@ public class TestPreparedStatement extends TestBase {
}
private
void
testPreparedStatementWithLiteralsNone
()
throws
SQLException
{
// make sure that when the analyze table kicks in, it works with ALLOW_LITERALS=NONE
// make sure that when the analyze table kicks in,
// it works with ALLOW_LITERALS=NONE
deleteDb
(
"preparedStatement"
);
Connection
conn
=
getConnection
(
"preparedStatement;ANALYZE_AUTO=100"
);
conn
.
createStatement
().
execute
(
"SET ALLOW_LITERALS NONE"
);
...
...
@@ -1179,11 +1180,11 @@ public class TestPreparedStatement extends TestBase {
for
(
int
i
=
0
;
i
<
200
;
i
++)
{
ps
.
setInt
(
1
,
i
);
ps
.
executeUpdate
();
}
}
conn
.
close
();
deleteDb
(
"preparedStatement"
);
}
private
void
checkBigDecimal
(
ResultSet
rs
,
String
[]
value
)
throws
SQLException
{
for
(
String
v
:
value
)
{
assertTrue
(
rs
.
next
());
...
...
h2/src/test/org/h2/test/store/TestKillProcessWhileWriting.java
浏览文件 @
c4a00eb9
...
...
@@ -36,13 +36,13 @@ public class TestKillProcessWhileWriting extends TestBase {
public
void
test
()
throws
Exception
{
fs
=
FilePathUnstable
.
register
();
test
(
"unstable:memFS:killProcess.h3"
);
int
todo
;
// need to test with a file system splits writes into blocks of 4 KB
FilePathCrypt
.
register
();
test
(
"unstable:crypt:0007:memFS:killProcess.h3"
);
}
public
void
test
(
String
fileName
)
throws
Exception
{
for
(
seed
=
0
;
seed
<
10
;
seed
++)
{
this
.
fileName
=
fileName
;
...
...
@@ -55,7 +55,7 @@ public class TestKillProcessWhileWriting extends TestBase {
}
}
}
private
void
test
(
int
x
)
throws
Exception
{
FileUtils
.
delete
(
fileName
);
fs
.
setDiskFullCount
(
x
);
...
...
@@ -69,8 +69,8 @@ public class TestKillProcessWhileWriting extends TestBase {
fs
.
setDiskFullCount
(
0
);
verify
();
}
}
}
private
int
write
()
{
MVStore
s
;
MVMap
<
Integer
,
byte
[]>
m
;
...
...
@@ -127,9 +127,9 @@ public class TestKillProcessWhileWriting extends TestBase {
return
op
;
}
}
private
void
verify
()
{
MVStore
s
;
MVMap
<
Integer
,
byte
[]>
m
;
...
...
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
c4a00eb9
...
...
@@ -96,7 +96,7 @@ public class TestMVStore extends TestBase {
// longer running tests
testLargerThan2G
();
}
private
void
testRemoveMap
()
throws
Exception
{
String
fileName
=
getBaseDir
()
+
"/testCloseMap.h3"
;
FileUtils
.
delete
(
fileName
);
...
...
@@ -104,23 +104,23 @@ public class TestMVStore extends TestBase {
fileName
(
fileName
).
open
();
MVMap
<
Integer
,
Integer
>
map
;
map
=
s
.
openMap
(
"data"
);
map
.
put
(
1
,
1
);
assertEquals
(
1
,
map
.
get
(
1
).
intValue
());
s
.
store
();
map
.
removeMap
();
s
.
store
();
map
=
s
.
openMap
(
"data"
);
assertTrue
(
map
.
isEmpty
());
map
.
put
(
2
,
2
);
s
.
store
();
s
.
close
();
}
private
void
testIsEmpty
()
throws
Exception
{
MVStore
s
=
new
MVStore
.
Builder
().
pageSplitSize
(
50
).
...
...
@@ -643,7 +643,7 @@ public class TestMVStore extends TestBase {
}
}
s
.
close
();
FilePath
f
=
FilePath
.
get
(
fileName
);
int
blockSize
=
4
*
1024
;
// test corrupt file headers
...
...
h2/src/test/org/h2/test/store/TestRandomMapOps.java
浏览文件 @
c4a00eb9
...
...
@@ -28,7 +28,7 @@ public class TestRandomMapOps extends TestBase {
/**
* Run just this test.
*
*
* @param a ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
...
...
@@ -168,14 +168,14 @@ public class TestRandomMapOps extends TestBase {
s
.
store
();
s
.
close
();
}
private
static
MVStore
openStore
(
String
fileName
)
{
MVStore
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
pageSplitSize
(
50
).
writeDelay
(
0
).
open
();
pageSplitSize
(
50
).
writeDelay
(
0
).
open
();
s
.
setRetentionTime
(
0
);
return
s
;
}
private
void
assertEqualsMapValues
(
byte
[]
x
,
byte
[]
y
)
{
if
(
x
==
null
||
y
==
null
)
{
if
(
x
!=
y
)
{
...
...
@@ -185,17 +185,17 @@ public class TestRandomMapOps extends TestBase {
assertEquals
(
x
.
length
,
y
.
length
);
}
}
/**
* Log the operation
*
*
* @param op the operation id
* @param k the key
* @param v the value
* @param msg the message
*/
private
static
void
log
(
int
op
,
int
k
,
byte
[]
v
,
String
msg
)
{
// msg = MessageFormat.format(msg, k,
// msg = MessageFormat.format(msg, k,
// v == null ? null : "new byte[" + v.length + "]");
// System.out.println(msg + "; // op " + op);
}
...
...
h2/src/test/org/h2/test/store/TestStreamStore.java
浏览文件 @
c4a00eb9
...
...
@@ -52,7 +52,7 @@ public class TestStreamStore extends TestBase {
testWithFullMap
();
testLoop
();
}
private
void
testReadCount
()
throws
IOException
{
String
fileName
=
getBaseDir
()
+
"/testReadCount.h3"
;
FileUtils
.
delete
(
fileName
);
...
...
@@ -69,7 +69,7 @@ public class TestStreamStore extends TestBase {
MVMap
<
Long
,
byte
[]>
map
=
s
.
openMap
(
"data"
);
assertTrue
(
"size: "
+
map
.
size
(),
map
.
sizeAsLong
()
>=
100
);
s
.
close
();
s
=
new
MVStore
.
Builder
().
fileName
(
fileName
).
open
();
...
...
@@ -86,7 +86,7 @@ public class TestStreamStore extends TestBase {
assertTrue
(
"size: "
+
map
.
size
(),
map
.
sizeAsLong
()
>=
200
);
s
.
close
();
}
private
static
StreamStore
getAutoCommitStreamStore
(
final
MVStore
s
)
{
MVMap
<
Long
,
byte
[]>
map
=
s
.
openMap
(
"data"
);
return
new
StreamStore
(
map
)
{
...
...
h2/src/test/org/h2/test/unit/TestFileSystem.java
浏览文件 @
c4a00eb9
...
...
@@ -106,14 +106,14 @@ public class TestFileSystem extends TestBase {
FileUtils
.
delete
(
getBaseDir
()
+
"/fs"
);
}
}
private
void
testZipFileSystem
(
String
prefix
)
throws
IOException
{
Random
r
=
new
Random
(
1
);
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
testZipFileSystem
(
prefix
,
r
);
}
}
private
void
testZipFileSystem
(
String
prefix
,
Random
r
)
throws
IOException
{
byte
[]
data
=
new
byte
[
r
.
nextInt
(
16
*
1024
)];
long
x
=
r
.
nextLong
();
...
...
@@ -693,13 +693,13 @@ public class TestFileSystem extends TestBase {
FileUtils
.
delete
(
s
);
}
}
private
static
ByteBuffer
createSlicedBuffer
(
byte
[]
buffer
,
int
offset
,
int
len
)
{
ByteBuffer
byteBuff
=
ByteBuffer
.
wrap
(
buffer
);
byteBuff
.
position
(
offset
);
// force the arrayOffset to be non-0
byteBuff
=
byteBuff
.
slice
();
byteBuff
.
limit
(
len
);
byteBuff
.
limit
(
len
);
return
byteBuff
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论