Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
341be22e
提交
341be22e
authored
14 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clob.getSubString and Blob.getBytes are now up to 3 times faster.
上级
3ee41492
master
noel-pr1
plus33-master
pr/267
stumc-Issue#576
version-1.4.198
version-1.4.197
version-1.4.196
version-1.4.195
version-1.4.194
version-1.4.193
version-1.4.192
version-1.4.191
version-1.4.190
version-1.4.188
version-1.4.187
version-1.4.186
version-1.4.185
version-1.4.184
version-1.4.183
version-1.4.182
version-1.4.181
version-1.4.178
version-1.4.177
version-1.3
version-1.2
version-1.1
version-1.0
无相关合并请求
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
64 行增加
和
133 行删除
+64
-133
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
JdbcBlob.java
h2/src/main/org/h2/jdbc/JdbcBlob.java
+2
-23
JdbcClob.java
h2/src/main/org/h2/jdbc/JdbcClob.java
+5
-24
WebThread.java
h2/src/main/org/h2/server/web/WebThread.java
+2
-10
FileSystemDisk.java
h2/src/main/org/h2/store/fs/FileSystemDisk.java
+2
-11
Recover.java
h2/src/main/org/h2/tools/Recover.java
+3
-12
IOUtils.java
h2/src/main/org/h2/util/IOUtils.java
+47
-43
SourceCompiler.java
h2/src/main/org/h2/util/SourceCompiler.java
+1
-9
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
341be22e
...
...
@@ -18,7 +18,8 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
New database setting DEFAULT_CONNECTION (disabled by default)
<ul><li>
Clob.getSubString and Blob.getBytes are now up to 3 times faster.
</li><li>
New database setting DEFAULT_CONNECTION (disabled by default)
to support DriverManager.getConnection("jdbc:default:connection").
Please note the Oracle JDBC driver will try to resolve this database URL if it is loaded before the H2 driver.
</li><li>
JaQu: the static map Db.TOKENS was not synchronized.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcBlob.java
浏览文件 @
341be22e
...
...
@@ -58,21 +58,7 @@ public class JdbcBlob extends TraceObject implements Blob {
return
precision
;
}
}
long
size
=
0
;
InputStream
in
=
value
.
getInputStream
();
try
{
byte
[]
buff
=
new
byte
[
Constants
.
IO_BUFFER_SIZE
];
while
(
true
)
{
int
len
=
in
.
read
(
buff
,
0
,
Constants
.
IO_BUFFER_SIZE
);
if
(
len
<=
0
)
{
break
;
}
size
+=
len
;
}
}
finally
{
in
.
close
();
}
return
size
;
return
IOUtils
.
copyAndCloseInput
(
value
.
getInputStream
(),
null
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
...
...
@@ -106,14 +92,7 @@ public class JdbcBlob extends TraceObject implements Blob {
InputStream
in
=
value
.
getInputStream
();
try
{
IOUtils
.
skipFully
(
in
,
pos
-
1
);
while
(
length
>
0
)
{
int
x
=
in
.
read
();
if
(
x
<
0
)
{
break
;
}
out
.
write
(
x
);
length
--;
}
IOUtils
.
copy
(
in
,
out
,
length
);
}
finally
{
in
.
close
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcClob.java
浏览文件 @
341be22e
...
...
@@ -13,6 +13,7 @@ import java.io.PipedInputStream;
import
java.io.PipedOutputStream
;
import
java.io.Reader
;
import
java.io.StringReader
;
import
java.io.StringWriter
;
import
java.io.Writer
;
import
java.sql.Clob
;
//## Java 1.6 begin ##
...
...
@@ -63,21 +64,7 @@ public class JdbcClob extends TraceObject implements Clob
return
precision
;
}
}
Reader
in
=
value
.
getReader
();
try
{
long
size
=
0
;
char
[]
buff
=
new
char
[
Constants
.
IO_BUFFER_SIZE
];
while
(
true
)
{
int
len
=
in
.
read
(
buff
,
0
,
Constants
.
IO_BUFFER_SIZE
);
if
(
len
<=
0
)
{
break
;
}
size
+=
len
;
}
return
size
;
}
finally
{
in
.
close
();
}
return
IOUtils
.
copyAndCloseInput
(
value
.
getReader
(),
null
,
Long
.
MAX_VALUE
);
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
...
...
@@ -196,21 +183,15 @@ public class JdbcClob extends TraceObject implements Clob
if
(
length
<
0
)
{
throw
DbException
.
getInvalidValueException
(
"length"
,
length
);
}
String
Builder
buff
=
new
StringBuilder
(
Math
.
min
(
4096
,
length
));
String
Writer
writer
=
new
StringWriter
(
Math
.
min
(
Constants
.
IO_BUFFER_SIZE
,
length
));
Reader
reader
=
value
.
getReader
();
try
{
IOUtils
.
skipFully
(
reader
,
pos
-
1
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
int
ch
=
reader
.
read
();
if
(
ch
<
0
)
{
break
;
}
buff
.
append
((
char
)
ch
);
}
IOUtils
.
copyAndCloseInput
(
reader
,
writer
,
length
);
}
finally
{
reader
.
close
();
}
return
buff
.
toString
();
return
writer
.
toString
();
}
catch
(
Exception
e
)
{
throw
logAndConvert
(
e
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/WebThread.java
浏览文件 @
341be22e
...
...
@@ -354,21 +354,13 @@ class WebThread extends WebApp implements Runnable {
len
-=
headerBytes
;
File
file
=
new
File
(
WebServer
.
TRANSFER
,
fileName
);
OutputStream
out
=
new
FileOutputStream
(
file
);
byte
[]
bytes
=
Utils
.
newBytes
(
Constants
.
IO_BUFFER_SIZE
);
while
(
len
>
0
)
{
int
l
=
Math
.
min
(
Constants
.
IO_BUFFER_SIZE
,
len
);
l
=
in
.
read
(
bytes
,
0
,
l
);
if
(
l
<
0
)
{
break
;
}
out
.
write
(
bytes
,
0
,
l
);
len
-=
l
;
}
IOUtils
.
copy
(
in
,
out
,
len
);
out
.
close
();
// remove the boundary
RandomAccessFile
f
=
new
RandomAccessFile
(
file
,
"rw"
);
int
testSize
=
(
int
)
Math
.
min
(
f
.
length
(),
Constants
.
IO_BUFFER_SIZE
);
f
.
seek
(
f
.
length
()
-
testSize
);
byte
[]
bytes
=
Utils
.
newBytes
(
Constants
.
IO_BUFFER_SIZE
);
f
.
readFully
(
bytes
,
0
,
testSize
);
String
s
=
new
String
(
bytes
,
"ASCII"
);
int
x
=
s
.
lastIndexOf
(
boundary
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/fs/FileSystemDisk.java
浏览文件 @
341be22e
...
...
@@ -18,7 +18,6 @@ import java.net.URL;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Constants
;
import
org.h2.message.DbException
;
import
org.h2.util.IOUtils
;
import
org.h2.util.StringUtils
;
...
...
@@ -322,17 +321,9 @@ public class FileSystemDisk extends FileSystem {
OutputStream
out
=
null
;
InputStream
in
=
null
;
try
{
out
=
IOUtils
.
openFileOutputStream
(
target
,
false
);
in
=
IOUtils
.
openFileInputStream
(
source
);
byte
[]
buffer
=
new
byte
[
Constants
.
IO_BUFFER_SIZE
];
while
(
true
)
{
int
len
=
in
.
read
(
buffer
);
if
(
len
<
0
)
{
break
;
}
out
.
write
(
buffer
,
0
,
len
);
}
out
.
close
();
out
=
IOUtils
.
openFileOutputStream
(
target
,
false
);
IOUtils
.
copy
(
in
,
out
);
}
catch
(
IOException
e
)
{
throw
DbException
.
convertIOException
(
e
,
"original: "
+
source
+
" copy: "
+
target
);
}
finally
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
341be22e
...
...
@@ -280,24 +280,15 @@ public class Recover extends Tool implements DataHandler {
private
void
dumpLob
(
String
fileName
,
boolean
lobCompression
)
{
OutputStream
fileOut
=
null
;
FileStore
fileStore
=
null
;
int
size
=
0
;
long
size
=
0
;
String
n
=
fileName
+
(
lobCompression
?
".comp"
:
""
)
+
".txt"
;
InputStream
in
=
null
;
try
{
fileOut
=
IOUtils
.
openFileOutputStream
(
n
,
false
);
fileStore
=
FileStore
.
open
(
null
,
fileName
,
"r"
);
fileStore
.
init
();
in
=
new
BufferedInputStream
(
new
FileStoreInputStream
(
fileStore
,
this
,
lobCompression
,
false
));
byte
[]
buffer
=
new
byte
[
Constants
.
IO_BUFFER_SIZE
];
while
(
true
)
{
int
l
=
in
.
read
(
buffer
);
if
(
l
<
0
)
{
break
;
}
fileOut
.
write
(
buffer
,
0
,
l
);
size
+=
l
;
}
fileOut
.
close
();
in
=
new
FileStoreInputStream
(
fileStore
,
this
,
lobCompression
,
false
);
size
=
IOUtils
.
copy
(
in
,
fileOut
);
}
catch
(
Throwable
e
)
{
// this is usually not a problem, because we try both compressed and
// uncompressed
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/IOUtils.java
浏览文件 @
341be22e
...
...
@@ -33,8 +33,6 @@ import org.h2.store.fs.FileSystem;
*/
public
class
IOUtils
{
private
static
final
int
BUFFER_BLOCK_SIZE
=
4
*
1024
;
private
IOUtils
()
{
// utility class
}
...
...
@@ -126,7 +124,7 @@ public class IOUtils {
* input stream. Exceptions while closing are ignored.
*
* @param in the input stream
* @param out the output stream
* @param out the output stream
(null if writing is not required)
* @return the number of bytes copied
*/
public
static
long
copyAndCloseInput
(
InputStream
in
,
OutputStream
out
)
throws
IOException
{
...
...
@@ -144,22 +142,40 @@ public class IOUtils {
* are kept open.
*
* @param in the input stream
* @param out the output stream
* @param out the output stream
(null if writing is not required)
* @return the number of bytes copied
*/
public
static
long
copy
(
InputStream
in
,
OutputStream
out
)
throws
IOException
{
return
copy
(
in
,
out
,
Long
.
MAX_VALUE
);
}
/**
* Copy all data from the input stream to the output stream. Both streams
* are kept open.
*
* @param in the input stream
* @param out the output stream (null if writing is not required)
* @param length the maximum number of bytes to copy
* @return the number of bytes copied
*/
public
static
long
copy
(
InputStream
in
,
OutputStream
out
,
long
length
)
throws
IOException
{
try
{
long
written
=
0
;
byte
[]
buffer
=
new
byte
[
4
*
1024
];
while
(
true
)
{
int
len
=
in
.
read
(
buffer
);
long
copied
=
0
;
int
len
=
(
int
)
Math
.
min
(
length
,
Constants
.
IO_BUFFER_SIZE
);
byte
[]
buffer
=
new
byte
[
len
];
while
(
length
>
0
)
{
len
=
in
.
read
(
buffer
,
0
,
len
);
if
(
len
<
0
)
{
break
;
}
if
(
out
!=
null
)
{
out
.
write
(
buffer
,
0
,
len
);
written
+=
len
;
}
return
written
;
copied
+=
len
;
length
-=
len
;
len
=
(
int
)
Math
.
min
(
length
,
Constants
.
IO_BUFFER_SIZE
);
}
return
copied
;
}
catch
(
Exception
e
)
{
throw
DbException
.
convertToIOException
(
e
);
}
...
...
@@ -170,22 +186,28 @@ public class IOUtils {
* Exceptions while closing are ignored.
*
* @param in the reader
* @param out the writer
* @param out the writer (null if writing is not required)
* @param length the maximum number of bytes to copy
* @return the number of characters copied
*/
public
static
long
copyAndCloseInput
(
Reader
in
,
Writer
out
)
throws
IOException
{
public
static
long
copyAndCloseInput
(
Reader
in
,
Writer
out
,
long
length
)
throws
IOException
{
try
{
long
written
=
0
;
char
[]
buffer
=
new
char
[
4
*
1024
];
while
(
true
)
{
int
len
=
in
.
read
(
buffer
);
long
copied
=
0
;
int
len
=
(
int
)
Math
.
min
(
length
,
Constants
.
IO_BUFFER_SIZE
);
char
[]
buffer
=
new
char
[
len
];
while
(
length
>
0
)
{
len
=
in
.
read
(
buffer
,
0
,
len
);
if
(
len
<
0
)
{
break
;
}
if
(
out
!=
null
)
{
out
.
write
(
buffer
,
0
,
len
);
written
+=
len
;
}
return
written
;
length
-=
len
;
len
=
(
int
)
Math
.
min
(
length
,
Constants
.
IO_BUFFER_SIZE
);
copied
+=
len
;
}
return
copied
;
}
catch
(
Exception
e
)
{
throw
DbException
.
convertToIOException
(
e
);
}
finally
{
...
...
@@ -253,18 +275,9 @@ public class IOUtils {
if
(
length
<=
0
)
{
length
=
Integer
.
MAX_VALUE
;
}
int
block
=
Math
.
min
(
BUFFER_BLOCK
_SIZE
,
length
);
int
block
=
Math
.
min
(
Constants
.
IO_BUFFER
_SIZE
,
length
);
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
(
block
);
byte
[]
buff
=
new
byte
[
block
];
while
(
length
>
0
)
{
int
len
=
Math
.
min
(
block
,
length
);
len
=
in
.
read
(
buff
,
0
,
len
);
if
(
len
<
0
)
{
break
;
}
out
.
write
(
buff
,
0
,
len
);
length
-=
len
;
}
copy
(
in
,
out
,
length
);
return
out
.
toByteArray
();
}
catch
(
Exception
e
)
{
throw
DbException
.
convertToIOException
(
e
);
...
...
@@ -286,18 +299,9 @@ public class IOUtils {
if
(
length
<=
0
)
{
length
=
Integer
.
MAX_VALUE
;
}
int
block
=
Math
.
min
(
BUFFER_BLOCK_SIZE
,
length
);
StringWriter
out
=
new
StringWriter
(
length
==
Integer
.
MAX_VALUE
?
block
:
length
);
char
[]
buff
=
new
char
[
block
];
while
(
length
>
0
)
{
int
len
=
Math
.
min
(
block
,
length
);
len
=
in
.
read
(
buff
,
0
,
len
);
if
(
len
<
0
)
{
break
;
}
out
.
write
(
buff
,
0
,
len
);
length
-=
len
;
}
int
block
=
Math
.
min
(
Constants
.
IO_BUFFER_SIZE
,
length
);
StringWriter
out
=
new
StringWriter
(
block
);
copyAndCloseInput
(
in
,
out
,
length
);
return
out
.
toString
();
}
finally
{
in
.
close
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/SourceCompiler.java
浏览文件 @
341be22e
...
...
@@ -218,15 +218,7 @@ public class SourceCompiler {
private
static
void
copyInThread
(
final
InputStream
in
,
final
OutputStream
out
)
{
new
Task
()
{
public
void
call
()
throws
IOException
{
while
(
true
)
{
int
x
=
in
.
read
();
if
(
x
<
0
)
{
return
;
}
if
(
out
!=
null
)
{
out
.
write
(
x
);
}
}
IOUtils
.
copy
(
in
,
out
);
}
}.
execute
();
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论