Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c5d33cf2
提交
c5d33cf2
authored
12月 10, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Formatting / javadocs
上级
a6c34373
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
72 行增加
和
62 行删除
+72
-62
Database.java
h2/src/main/org/h2/engine/Database.java
+1
-1
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
+4
-3
Page.java
h2/src/main/org/h2/mvstore/Page.java
+18
-9
MVTable.java
h2/src/main/org/h2/mvstore/db/MVTable.java
+3
-2
LocalResult.java
h2/src/main/org/h2/result/LocalResult.java
+1
-1
TestCompatibility.java
h2/src/test/org/h2/test/db/TestCompatibility.java
+1
-1
TestLob.java
h2/src/test/org/h2/test/db/TestLob.java
+1
-1
TestMultiThread.java
h2/src/test/org/h2/test/db/TestMultiThread.java
+2
-2
TestConcurrent.java
h2/src/test/org/h2/test/store/TestConcurrent.java
+2
-2
TestMVStore.java
h2/src/test/org/h2/test/store/TestMVStore.java
+1
-1
TestIntPerfectHash.java
h2/src/test/org/h2/test/unit/TestIntPerfectHash.java
+2
-2
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+3
-4
IntPerfectHash.java
h2/src/tools/org/h2/dev/hash/IntPerfectHash.java
+20
-20
ImmutableArray3.java
h2/src/tools/org/h2/dev/util/ImmutableArray3.java
+4
-4
没有找到文件。
h2/src/main/org/h2/engine/Database.java
浏览文件 @
c5d33cf2
...
...
@@ -2713,7 +2713,7 @@ public class Database implements DataHandler {
public
byte
[]
getFileEncryptionKey
()
{
return
fileEncryptionKey
;
}
public
int
getPageSize
()
{
return
pageSize
;
}
...
...
h2/src/main/org/h2/mvstore/MVMap.java
浏览文件 @
c5d33cf2
...
...
@@ -125,7 +125,7 @@ public class MVMap<K, V> extends AbstractMap<K, V>
/**
* Add or replace a key-value pair in a branch.
*
*
* @param root the root page
* @param key the key (may not be null)
* @param value the value (may not be null)
...
...
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
c5d33cf2
...
...
@@ -168,9 +168,9 @@ public class MVStore {
private
CacheLongKeyLIRS
<
Page
>
cache
;
/**
* The page chunk references cache. The default size is 4 MB, and the
average size is 2 KB.
*
It is split in 16 segments. The stack move distance is 2% of the expected
* number of entries.
* The page chunk references cache. The default size is 4 MB, and the
*
average size is 2 KB. It is split in 16 segments. The stack move distance
*
is 2% of the expected
number of entries.
*/
private
CacheLongKeyLIRS
<
PageChildren
>
cacheChunkRef
;
...
...
@@ -1201,7 +1201,7 @@ public class MVStore {
}
}
}
private
Set
<
Integer
>
collectReferencedChunks
()
{
long
testVersion
=
lastChunk
.
version
;
DataUtils
.
checkArgument
(
testVersion
>
0
,
"Collect references on version 0"
);
...
...
@@ -1224,7 +1224,7 @@ public class MVStore {
readCount
=
fileStore
.
readCount
-
readCount
;
return
referenced
;
}
private
int
collectReferencedChunks
(
Set
<
Integer
>
targetChunkSet
,
int
mapId
,
long
pos
)
{
targetChunkSet
.
add
(
DataUtils
.
getPageChunkId
(
pos
));
if
(
DataUtils
.
getPageType
(
pos
)
==
DataUtils
.
PAGE_TYPE_LEAF
)
{
...
...
@@ -1240,7 +1240,7 @@ public class MVStore {
return
count
;
}
PageChildren
readPageChunkReferences
(
int
mapId
,
long
pos
,
int
parentChunk
)
{
private
PageChildren
readPageChunkReferences
(
int
mapId
,
long
pos
,
int
parentChunk
)
{
if
(
DataUtils
.
getPageType
(
pos
)
==
DataUtils
.
PAGE_TYPE_LEAF
)
{
return
null
;
}
...
...
@@ -1323,7 +1323,7 @@ public class MVStore {
* Apply the freed space to the chunk metadata. The metadata is updated, but
* completely free chunks are not removed from the set of chunks, and the
* disk space is not yet marked as free.
*
*
* @param storeVersion apply up to the given version
*/
private
Set
<
Chunk
>
applyFreedSpace
(
long
storeVersion
)
{
...
...
@@ -1676,7 +1676,7 @@ public class MVStore {
// calculate the fill rate
long
maxLengthSum
=
0
;
long
maxLengthLiveSum
=
0
;
long
time
=
getTime
();
for
(
Chunk
c
:
chunks
.
values
())
{
...
...
h2/src/main/org/h2/mvstore/MVStoreTool.java
浏览文件 @
c5d33cf2
...
...
@@ -86,6 +86,7 @@ public class MVStoreTool {
*
* @param fileName the name of the file
* @param writer the print writer
* @param details print the page details
*/
public
static
void
dump
(
String
fileName
,
Writer
writer
,
boolean
details
)
{
PrintWriter
pw
=
new
PrintWriter
(
writer
,
true
);
...
...
@@ -97,7 +98,7 @@ public class MVStoreTool {
pw
.
printf
(
"File %s, %d bytes, %d MB\n"
,
fileName
,
size
,
size
/
1024
/
1024
);
FileChannel
file
=
null
;
int
blockSize
=
MVStore
.
BLOCK_SIZE
;
TreeMap
<
Integer
,
Long
>
mapSizesTotal
=
TreeMap
<
Integer
,
Long
>
mapSizesTotal
=
new
TreeMap
<
Integer
,
Long
>();
long
pageSizeTotal
=
0
;
try
{
...
...
@@ -139,7 +140,7 @@ public class MVStoreTool {
pos
+=
length
;
int
remaining
=
c
.
pageCount
;
pageCount
+=
c
.
pageCount
;
TreeMap
<
Integer
,
Integer
>
mapSizes
=
TreeMap
<
Integer
,
Integer
>
mapSizes
=
new
TreeMap
<
Integer
,
Integer
>();
int
pageSizeSum
=
0
;
while
(
remaining
>
0
)
{
...
...
@@ -269,7 +270,7 @@ public class MVStoreTool {
}
pw
.
printf
(
"%n%0"
+
len
+
"x eof%n"
,
fileSize
);
pw
.
printf
(
"\n"
);
pw
.
printf
(
"page size total: %d bytes, page count: %d, average page size: %d bytes\n"
,
pw
.
printf
(
"page size total: %d bytes, page count: %d, average page size: %d bytes\n"
,
pageSizeTotal
,
pageCount
,
pageSizeTotal
/
pageCount
);
for
(
Integer
mapId
:
mapSizesTotal
.
keySet
())
{
int
percent
=
(
int
)
(
100
*
mapSizesTotal
.
get
(
mapId
)
/
pageSizeTotal
);
...
...
h2/src/main/org/h2/mvstore/Page.java
浏览文件 @
c5d33cf2
...
...
@@ -984,7 +984,7 @@ public class Page {
this
.
pos
=
pos
;
this
.
children
=
children
;
}
PageChildren
(
Page
p
)
{
this
.
pos
=
p
.
getPos
();
int
count
=
p
.
getRawChildPageCount
();
...
...
@@ -997,16 +997,16 @@ public class Page {
int
getMemory
()
{
return
64
+
8
*
children
.
length
;
}
/**
* Read the page from the buffer.
* Read an inner node page from the buffer, but ignore the keys and
* values.
*
* @param pos the position
* @param buff the buffer
* @param chunkId the chunk id
* @param fileStore the file store
* @param filePos the position in the file
* @param mapId the map id
* @param
offset the offset within the chunk
* @
param maxLength the maximum length
* @param
pos the position
* @
return the page children object
*/
static
PageChildren
read
(
FileStore
fileStore
,
long
filePos
,
int
mapId
,
long
pos
)
{
ByteBuffer
buff
;
...
...
@@ -1066,11 +1066,20 @@ public class Page {
}
return
new
PageChildren
(
pos
,
children
);
}
/**
* Only keep one reference to the same chunk. Only leaf references are
* removed (references to inner nodes are not removed, as they could
* indirectly point to other chunks).
*/
void
removeDuplicateChunkReferences
()
{
HashSet
<
Integer
>
chunks
=
New
.
hashSet
();
// we don't need references to leaves in the same chunk
chunks
.
add
(
DataUtils
.
getPageChunkId
(
pos
));
// possible space optimization:
// we could remove more children, for example
// we could remove all leaf references to the same chunk
// if there is also a inner node reference to that chunk
for
(
int
i
=
0
;
i
<
children
.
length
;
i
++)
{
long
p
=
children
[
i
];
if
(
DataUtils
.
getPageType
(
p
)
==
DataUtils
.
PAGE_TYPE_NODE
)
{
...
...
h2/src/main/org/h2/mvstore/db/MVTable.java
浏览文件 @
c5d33cf2
...
...
@@ -50,9 +50,10 @@ public class MVTable extends TableBase {
private
final
ArrayList
<
Index
>
indexes
=
New
.
arrayList
();
private
long
lastModificationId
;
private
volatile
Session
lockExclusiveSession
;
// using a ConcurrentHashMap as a set
private
final
ConcurrentHashMap
<
Session
,
Session
>
lockSharedSessions
=
new
ConcurrentHashMap
<
Session
,
Session
>();
private
final
ConcurrentHashMap
<
Session
,
Session
>
lockSharedSessions
=
new
ConcurrentHashMap
<
Session
,
Session
>();
/**
* The queue of sessions waiting to lock the table. It is a FIFO queue to
...
...
h2/src/main/org/h2/result/LocalResult.java
浏览文件 @
c5d33cf2
...
...
@@ -254,7 +254,7 @@ public class LocalResult implements ResultInterface, ResultTarget {
public
int
getRowId
()
{
return
rowId
;
}
private
void
cloneLobs
(
Value
[]
values
)
{
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
Value
v
=
values
[
i
];
...
...
h2/src/test/org/h2/test/db/TestCompatibility.java
浏览文件 @
c5d33cf2
...
...
@@ -327,7 +327,7 @@ public class TestCompatibility extends TestBase {
"comment='Comment Again' ENGINE=InnoDB"
);
stat
.
execute
(
"CREATE TABLE TEST2(ID INT) ROW_FORMAT=DYNAMIC"
);
conn
.
close
();
conn
=
getConnection
(
"compatibility"
);
}
...
...
h2/src/test/org/h2/test/db/TestLob.java
浏览文件 @
c5d33cf2
...
...
@@ -111,7 +111,7 @@ public class TestLob extends TestBase {
deleteDb
(
"lob"
);
FileUtils
.
deleteRecursive
(
TEMP_DIR
,
true
);
}
private
void
testConcurrentRemoveRead
()
throws
Exception
{
deleteDb
(
"lob"
);
final
String
url
=
getURL
(
"lob"
,
true
);
...
...
h2/src/test/org/h2/test/db/TestMultiThread.java
浏览文件 @
c5d33cf2
...
...
@@ -62,7 +62,7 @@ public class TestMultiThread extends TestBase implements Runnable {
testConcurrentInsertUpdateSelect
();
testLockModeWithMultiThreaded
();
}
private
void
testConcurrentSchemaChange
()
throws
Exception
{
String
db
=
"testConcurrentSchemaChange"
;
deleteDb
(
db
);
...
...
@@ -94,7 +94,7 @@ public class TestMultiThread extends TestBase implements Runnable {
for
(
Task
t
:
tasks
)
{
t
.
get
();
}
conn
.
close
();
conn
.
close
();
}
private
void
testConcurrentLobAdd
()
throws
Exception
{
...
...
h2/src/test/org/h2/test/store/TestConcurrent.java
浏览文件 @
c5d33cf2
...
...
@@ -277,7 +277,7 @@ public class TestConcurrent extends TestMVStore {
}
}
task
.
get
();
// this will mark old chunks as unused,
// this will mark old chunks as unused,
// but not remove (and overwrite) them yet
s
.
commit
();
// this will remove them, so we end up with
...
...
@@ -287,7 +287,7 @@ public class TestConcurrent extends TestMVStore {
s
.
commit
();
m
.
put
(
2
,
2
);
s
.
commit
();
MVMap
<
String
,
String
>
meta
=
s
.
getMetaMap
();
int
chunkCount
=
0
;
for
(
String
k
:
meta
.
keyList
())
{
...
...
h2/src/test/org/h2/test/store/TestMVStore.java
浏览文件 @
c5d33cf2
...
...
@@ -1750,7 +1750,7 @@ public class TestMVStore extends TestBase {
}
}
assertTrue
(
chunkCount1
+
">"
+
chunkCount2
+
">"
+
chunkCount3
,
assertTrue
(
chunkCount1
+
">"
+
chunkCount2
+
">"
+
chunkCount3
,
chunkCount3
<
chunkCount1
);
for
(
int
i
=
0
;
i
<
10
*
factor
;
i
++)
{
...
...
h2/src/test/org/h2/test/unit/TestIntPerfectHash.java
浏览文件 @
c5d33cf2
...
...
@@ -57,7 +57,7 @@ public class TestIntPerfectHash extends TestBase {
test
(
i
);
}
}
private
void
testBitArray
()
{
byte
[]
data
=
new
byte
[
0
];
BitSet
set
=
new
BitSet
();
...
...
@@ -76,7 +76,7 @@ public class TestIntPerfectHash extends TestBase {
}
assertTrue
(
BitArray
.
countBits
(
data
)
==
set
.
cardinality
());
}
private
int
test
(
int
size
)
{
Random
r
=
new
Random
(
size
);
HashSet
<
Integer
>
set
=
new
HashSet
<
Integer
>();
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
c5d33cf2
...
...
@@ -765,7 +765,6 @@ compaction aggressive powerful traversing pietrzak michi karl rewriting conseque
linearly patching perfect hole sip enwiki flooding uniformly recursions happening
permanently nucleus forbidden student trusted poodle agentlib
jech ladislav cognitect sergey thompson evdokimov arykov mfulton
dimitrijs fedotovs kingdom manley xso latvia ontwikkeling reeve
extendable republic uniquely
datasources accidentally recursing respecting
\ No newline at end of file
dimitrijs fedotovs kingdom manley xso latvia ontwikkeling reeve
extendable republic uniquely datasources accidentally recursing respecting
young sweep
\ No newline at end of file
h2/src/tools/org/h2/dev/hash/IntPerfectHash.java
浏览文件 @
c5d33cf2
...
...
@@ -65,10 +65,10 @@ public class IntPerfectHash {
public
IntPerfectHash
(
byte
[]
data
)
{
this
.
data
=
data
;
}
/**
* Get the hash function description.
*
*
* @return the data
*/
public
byte
[]
getData
()
{
...
...
@@ -307,12 +307,12 @@ public class IntPerfectHash {
}
return
len
;
}
/**
* A stream of bytes.
*/
static
class
ByteStream
{
private
byte
[]
data
;
private
int
pos
;
...
...
@@ -323,19 +323,19 @@ public class IntPerfectHash {
ByteStream
(
byte
[]
data
)
{
this
.
data
=
data
;
}
/**
* Read a byte.
*
*
* @return the byte, or -1.
*/
int
read
()
{
return
pos
<
data
.
length
?
(
data
[
pos
++]
&
255
)
:
-
1
;
}
/**
* Write a byte.
*
*
* @param value the byte
*/
void
write
(
byte
value
)
{
...
...
@@ -344,26 +344,26 @@ public class IntPerfectHash {
}
data
[
pos
++]
=
value
;
}
/**
* Get the byte array.
*
*
* @return the byte array
*/
byte
[]
toByteArray
()
{
return
Arrays
.
copyOf
(
data
,
pos
);
}
}
/**
* A helper class for bit arrays.
*/
public
static
class
BitArray
{
/**
* Set a bit in the array.
*
*
* @param data the array
* @param x the bit index
* @param value the new value
...
...
@@ -381,10 +381,10 @@ public class IntPerfectHash {
}
return
data
;
}
/**
* Get a bit in a bit array.
*
*
* @param data the array
* @param x the bit index
* @return the value
...
...
@@ -392,10 +392,10 @@ public class IntPerfectHash {
public
static
boolean
getBit
(
byte
[]
data
,
int
x
)
{
return
(
data
[
x
/
8
]
&
(
1
<<
(
x
&
7
)))
!=
0
;
}
/**
* Count the number of set bits.
*
*
* @param data the array
* @return the number of set bits
*/
...
...
@@ -406,8 +406,8 @@ public class IntPerfectHash {
}
return
count
;
}
}
}
h2/src/tools/org/h2/dev/util/ImmutableArray3.java
浏览文件 @
c5d33cf2
...
...
@@ -105,7 +105,7 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
/**
* Get the level of "abstraction".
*
*
* @return the level
*/
abstract
int
level
();
...
...
@@ -204,7 +204,7 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
/**
* Get a plain array with the given entry updated.
*
*
* @param <K> the type
* @param base the base type
* @param index the index
...
...
@@ -223,7 +223,7 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
/**
* Get a plain array with the given entry inserted.
*
*
* @param <K> the type
* @param base the base type
* @param index the index
...
...
@@ -242,7 +242,7 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
/**
* Get a plain array with the given entry removed.
*
*
* @param <K> the type
* @param base the base type
* @param index the index
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论