Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
6c5d1ec8
提交
6c5d1ec8
authored
2月 22, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
When using temporary table, the database didn't shrink sometimes when closing.
上级
dadfe1d7
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
48 行增加
和
65 行删除
+48
-65
InDoubtTransaction.java
h2/src/main/org/h2/store/InDoubtTransaction.java
+1
-1
PageInputStream.java
h2/src/main/org/h2/store/PageInputStream.java
+10
-8
PageLog.java
h2/src/main/org/h2/store/PageLog.java
+9
-10
PageOutputStream.java
h2/src/main/org/h2/store/PageOutputStream.java
+4
-2
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+7
-22
PageStreamData.java
h2/src/main/org/h2/store/PageStreamData.java
+7
-10
PageStreamTrunk.java
h2/src/main/org/h2/store/PageStreamTrunk.java
+5
-7
SessionState.java
h2/src/main/org/h2/store/SessionState.java
+3
-3
WriterThread.java
h2/src/main/org/h2/store/WriterThread.java
+2
-2
没有找到文件。
h2/src/main/org/h2/store/InDoubtTransaction.java
浏览文件 @
6c5d1ec8
...
...
@@ -55,7 +55,7 @@ public class InDoubtTransaction {
/**
* Change the state of this transaction.
* This will also update the
log file
.
* This will also update the
transaction log
.
*
* @param state the new state
*/
...
...
h2/src/main/org/h2/store/PageInputStream.java
浏览文件 @
6c5d1ec8
...
...
@@ -24,7 +24,9 @@ public class PageInputStream extends InputStream {
private
PageStreamTrunk
.
Iterator
trunkIterator
;
private
int
dataPage
;
private
PageStreamTrunk
trunk
;
private
int
trunkIndex
;
private
PageStreamData
data
;
private
int
dataPos
;
private
boolean
endOfFile
;
private
int
remaining
;
private
byte
[]
buffer
=
new
byte
[
1
];
...
...
@@ -73,8 +75,9 @@ public class PageInputStream extends InputStream {
return
-
1
;
}
int
l
=
Math
.
min
(
remaining
,
len
);
data
.
read
(
buff
,
off
,
l
);
data
.
read
(
dataPos
,
buff
,
off
,
l
);
remaining
-=
l
;
dataPos
+=
l
;
return
l
;
}
catch
(
DbException
e
)
{
throw
new
EOFException
();
...
...
@@ -89,15 +92,15 @@ public class PageInputStream extends InputStream {
while
(
true
)
{
if
(
trunk
==
null
)
{
trunk
=
trunkIterator
.
next
();
trunkIndex
=
0
;
logKey
++;
if
(
trunk
==
null
||
trunk
.
getLogKey
()
!=
logKey
)
{
endOfFile
=
true
;
return
;
}
trunk
.
resetIndex
();
}
if
(
trunk
!=
null
)
{
next
=
trunk
.
get
NextPageData
(
);
next
=
trunk
.
get
PageData
(
trunkIndex
++
);
if
(
next
==
-
1
)
{
trunk
=
null
;
}
else
if
(
dataPage
==
-
1
||
dataPage
==
next
)
{
...
...
@@ -118,8 +121,8 @@ public class PageInputStream extends InputStream {
endOfFile
=
true
;
return
;
}
data
.
initRead
();
remaining
=
data
.
getRemaining
()
;
data
Pos
=
data
.
getReadStart
();
remaining
=
store
.
getPageSize
()
-
dataPos
;
}
/**
...
...
@@ -141,9 +144,8 @@ public class PageInputStream extends InputStream {
break
;
}
pages
.
set
(
t
.
getPos
());
t
.
resetIndex
();
while
(
true
)
{
int
n
=
t
.
getNextPageData
();
for
(
int
i
=
0
;;
i
++)
{
int
n
=
t
.
getPageData
(
i
);
if
(
n
==
-
1
)
{
break
;
}
...
...
h2/src/main/org/h2/store/PageLog.java
浏览文件 @
6c5d1ec8
...
...
@@ -31,7 +31,7 @@ import org.h2.value.ValueNull;
* <li>type (0: no-op, 1: undo, 2: commit, ...)</li>
* <li>data</li>
* </ul>
* The
log file
is split into sections.
* The
transaction log
is split into sections.
* A checkpoint starts a new section.
*/
public
class
PageLog
{
...
...
@@ -533,7 +533,7 @@ public class PageLog {
}
// store it on a separate log page
int
pageSize
=
store
.
getPageSize
();
flushOut
();
pageOut
.
flush
();
pageOut
.
fillPage
();
Data
buffer
=
getBuffer
();
buffer
.
writeByte
((
byte
)
PREPARE_COMMIT
);
...
...
@@ -636,7 +636,7 @@ public class PageLog {
undo
=
new
BitSet
();
logSectionId
++;
logPos
=
0
;
flushOut
();
pageOut
.
flush
();
pageOut
.
fillPage
();
int
currentDataPage
=
pageOut
.
getCurrentDataPageId
();
logSectionPageMap
.
put
(
logSectionId
,
currentDataPage
);
...
...
@@ -684,15 +684,14 @@ public class PageLog {
Page
p
=
store
.
getPage
(
trunkPage
);
PageStreamTrunk
t
=
(
PageStreamTrunk
)
p
;
logKey
=
t
.
getLogKey
();
t
.
resetIndex
();
if
(
t
.
contains
(
firstDataPageToKeep
))
{
return
t
.
getPos
();
}
trunkPage
=
t
.
getNextTrunk
();
IntArray
list
=
new
IntArray
();
list
.
add
(
t
.
getPos
());
while
(
true
)
{
int
next
=
t
.
get
NextPageData
(
);
for
(
int
i
=
0
;;
i
++
)
{
int
next
=
t
.
get
PageData
(
i
);
if
(
next
==
-
1
)
{
break
;
}
...
...
@@ -719,8 +718,8 @@ public class PageLog {
* Check if the session committed after than the given position.
*
* @param sessionId the session id
* @param logId the log
file
id
* @param pos the position in the log
file
* @param logId the log id
* @param pos the position in the log
* @return true if it is committed
*/
private
boolean
isSessionCommitted
(
int
sessionId
,
int
logId
,
int
pos
)
{
...
...
@@ -735,8 +734,8 @@ public class PageLog {
* Set the last commit record for a session.
*
* @param sessionId the session id
* @param logId the log
file
id
* @param pos the position in the log
file
* @param logId the log id
* @param pos the position in the log
*/
private
void
setLastCommitForSession
(
int
sessionId
,
int
logId
,
int
pos
)
{
SessionState
state
=
getOrAddSessionState
(
sessionId
);
...
...
h2/src/main/org/h2/store/PageOutputStream.java
浏览文件 @
6c5d1ec8
...
...
@@ -24,6 +24,7 @@ public class PageOutputStream {
private
int
trunkNext
;
private
IntArray
reservedPages
=
new
IntArray
();
private
PageStreamTrunk
trunk
;
private
int
trunkIndex
;
private
PageStreamData
data
;
private
int
reserved
;
private
int
remaining
;
...
...
@@ -79,7 +80,7 @@ public class PageOutputStream {
}
private
void
initNextData
()
{
int
nextData
=
trunk
==
null
?
-
1
:
trunk
.
get
NextPageData
(
);
int
nextData
=
trunk
==
null
?
-
1
:
trunk
.
get
PageData
(
trunkIndex
++
);
if
(
nextData
==
-
1
)
{
int
parent
=
trunkPageId
;
if
(
trunkNext
!=
0
)
{
...
...
@@ -93,10 +94,11 @@ public class PageOutputStream {
trunkNext
=
reservedPages
.
get
(
len
);
logKey
++;
trunk
=
PageStreamTrunk
.
create
(
store
,
parent
,
trunkPageId
,
trunkNext
,
logKey
,
pageIds
);
trunkIndex
=
0
;
pageCount
++;
trunk
.
write
();
reservedPages
.
removeRange
(
0
,
len
+
1
);
nextData
=
trunk
.
get
NextPageData
(
);
nextData
=
trunk
.
get
PageData
(
trunkIndex
++
);
}
data
=
PageStreamData
.
create
(
store
,
nextData
,
trunk
.
getPos
(),
logKey
);
pageCount
++;
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
6c5d1ec8
...
...
@@ -12,6 +12,7 @@ import java.util.ArrayList;
import
java.util.BitSet
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.zip.CRC32
;
import
org.h2.command.ddl.CreateTableData
;
import
org.h2.constant.ErrorCode
;
...
...
@@ -323,7 +324,7 @@ public class PageStore implements CacheWriter {
}
/**
* Flush all pending changes to disk, and
re-open the log file
.
* Flush all pending changes to disk, and
switch the new transaction log
.
*/
public
void
checkpoint
()
{
trace
.
debug
(
"checkpoint"
);
...
...
@@ -564,8 +565,6 @@ public class PageStore implements CacheWriter {
}
private
void
readStaticHeader
()
{
long
length
=
file
.
length
();
database
.
notifyFileSize
(
length
);
file
.
seek
(
FileStore
.
HEADER_LENGTH
);
Data
page
=
Data
.
create
(
database
,
new
byte
[
PAGE_SIZE_MIN
-
FileStore
.
HEADER_LENGTH
]);
file
.
readFully
(
page
.
getBytes
(),
0
,
PAGE_SIZE_MIN
-
FileStore
.
HEADER_LENGTH
);
...
...
@@ -1056,11 +1055,13 @@ public class PageStore implements CacheWriter {
}
PageDataIndex
systemTable
=
(
PageDataIndex
)
metaObjects
.
get
(
0
);
isNew
=
systemTable
==
null
;
for
(
Index
openIndex
:
metaObjects
.
values
())
{
for
(
Iterator
<
PageIndex
>
it
=
metaObjects
.
values
().
iterator
();
it
.
hasNext
();)
{
Index
openIndex
=
it
.
next
();
if
(
openIndex
.
getTable
().
isTemporary
())
{
openIndex
.
truncate
(
systemSession
);
openIndex
.
remove
(
systemSession
);
removeMetaIndex
(
openIndex
,
systemSession
);
it
.
remove
();
}
else
{
openIndex
.
close
(
systemSession
);
}
...
...
@@ -1414,9 +1415,9 @@ public class PageStore implements CacheWriter {
}
/**
* Set the maximum
log file
size in megabytes.
* Set the maximum
transaction log
size in megabytes.
*
* @param maxSize the new maximum log
file
size
* @param maxSize the new maximum log size
*/
public
void
setMaxLogSize
(
long
maxSize
)
{
this
.
maxLogSize
=
maxSize
;
...
...
@@ -1586,20 +1587,4 @@ public class PageStore implements CacheWriter {
return
changeCount
;
}
int
getLogFirstTrunkPage
()
{
return
logFirstTrunkPage
;
}
int
getLogKey
()
{
return
logKey
;
}
public
PageLog
getLog
()
{
return
log
;
}
int
getLogFirstDataPage
()
{
return
logFirstDataPage
;
}
}
h2/src/main/org/h2/store/PageStreamData.java
浏览文件 @
6c5d1ec8
...
...
@@ -118,12 +118,13 @@ public class PageStreamData extends Page {
/**
* Read the next bytes from the buffer.
*
* @param startPos the position in the data page
* @param buff the target buffer
* @param off the offset in the target buffer
* @param len the number of bytes to read
*/
void
read
(
byte
[]
buff
,
int
off
,
int
len
)
{
data
.
read
(
buff
,
off
,
len
);
void
read
(
int
startPos
,
byte
[]
buff
,
int
off
,
int
len
)
{
System
.
arraycopy
(
data
.
getBytes
(),
startPos
,
buff
,
off
,
len
);
}
/**
...
...
@@ -144,14 +145,6 @@ public class PageStreamData extends Page {
return
store
.
getPageSize
()
>>
2
;
}
/**
* Reset the index.
*/
void
initRead
()
{
data
.
setPos
(
DATA_START
);
remaining
=
store
.
getPageSize
()
-
DATA_START
;
}
public
void
moveTo
(
Session
session
,
int
newPos
)
{
// not required
}
...
...
@@ -168,4 +161,8 @@ public class PageStreamData extends Page {
return
true
;
}
public
int
getReadStart
()
{
return
DATA_START
;
}
}
\ No newline at end of file
h2/src/main/org/h2/store/PageStreamTrunk.java
浏览文件 @
6c5d1ec8
...
...
@@ -42,7 +42,6 @@ public class PageStreamTrunk extends Page {
private
int
[]
pageIds
;
private
int
pageCount
;
private
Data
data
;
private
int
index
;
private
PageStreamTrunk
(
PageStore
store
,
int
parent
,
int
pageId
,
int
next
,
int
logKey
,
int
[]
pageIds
)
{
setPos
(
pageId
);
...
...
@@ -107,13 +106,12 @@ public class PageStreamTrunk extends Page {
}
/**
* Reset the read/write index.
* Get the data page id at the given position.
*
* @param index the index (0, 1, ...)
* @return the value, or -1 if the index is too large
*/
void
resetIndex
()
{
index
=
0
;
}
int
getNextPageData
()
{
int
getPageData
(
int
index
)
{
if
(
index
>=
pageIds
.
length
)
{
return
-
1
;
}
...
...
h2/src/main/org/h2/store/SessionState.java
浏览文件 @
6c5d1ec8
...
...
@@ -19,7 +19,7 @@ class SessionState {
public
int
sessionId
;
/**
* The last log
file
id where a commit for this session is found.
* The last log id where a commit for this session is found.
*/
public
int
lastCommitLog
;
...
...
@@ -36,8 +36,8 @@ class SessionState {
/**
* Check if this session state is already committed at this point.
*
* @param logId the log
file
id
* @param pos the position in the log
file
* @param logId the log id
* @param pos the position in the log
* @return true if it is committed
*/
public
boolean
isCommitted
(
int
logId
,
int
pos
)
{
...
...
h2/src/main/org/h2/store/WriterThread.java
浏览文件 @
6c5d1ec8
...
...
@@ -14,8 +14,8 @@ import org.h2.message.Trace;
import
org.h2.message.TraceSystem
;
/**
* The writer thread is responsible to flush the transaction
log file from time
* to time.
* The writer thread is responsible to flush the transaction
transaction log
*
from time
to time.
*/
public
class
WriterThread
implements
Runnable
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论