Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
dd3ee7e8
提交
dd3ee7e8
authored
7月 06, 2012
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make method static where possible and other cleanup.
上级
8c55bcf6
隐藏空白字符变更
内嵌
并排
正在显示
26 个修改的文件
包含
116 行增加
和
120 行删除
+116
-120
PageBtreeIndex.java
h2/src/main/org/h2/index/PageBtreeIndex.java
+1
-1
JdbcResultSet.java
h2/src/main/org/h2/jdbc/JdbcResultSet.java
+1
-1
Recover.java
h2/src/main/org/h2/tools/Recover.java
+1
-1
CaseInsensitiveMap.java
h2/src/main/org/h2/value/CaseInsensitiveMap.java
+1
-1
TestFullText.java
h2/src/test/org/h2/test/db/TestFullText.java
+1
-2
ProductAnnotationOnly.java
h2/src/test/org/h2/test/jaqu/ProductAnnotationOnly.java
+0
-1
ProductNoCreateTable.java
h2/src/test/org/h2/test/jaqu/ProductNoCreateTable.java
+0
-2
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+2
-2
TestAutoReconnect.java
h2/src/test/org/h2/test/unit/TestAutoReconnect.java
+1
-1
TestClassLoaderLeak.java
h2/src/test/org/h2/test/unit/TestClassLoaderLeak.java
+2
-1
TestCompress.java
h2/src/test/org/h2/test/unit/TestCompress.java
+27
-27
TestDate.java
h2/src/test/org/h2/test/unit/TestDate.java
+1
-1
TestFileLockProcess.java
h2/src/test/org/h2/test/unit/TestFileLockProcess.java
+2
-3
TestFileSystem.java
h2/src/test/org/h2/test/unit/TestFileSystem.java
+3
-3
TestJmx.java
h2/src/test/org/h2/test/unit/TestJmx.java
+1
-1
TestSort.java
h2/src/test/org/h2/test/unit/TestSort.java
+2
-2
TestUtils.java
h2/src/test/org/h2/test/unit/TestUtils.java
+2
-2
ProxyCodeGenerator.java
h2/src/test/org/h2/test/utils/ProxyCodeGenerator.java
+1
-1
RailroadImages.java
h2/src/tools/org/h2/build/doc/RailroadImages.java
+1
-1
FilePathZip2.java
h2/src/tools/org/h2/dev/fs/FilePathZip2.java
+5
-5
FileShell.java
h2/src/tools/org/h2/dev/fs/FileShell.java
+10
-10
InPlaceStableMergeSort.java
h2/src/tools/org/h2/dev/sort/InPlaceStableMergeSort.java
+13
-13
InPlaceStableQuicksort.java
h2/src/tools/org/h2/dev/sort/InPlaceStableQuicksort.java
+24
-24
BtreeMapStore.java
h2/src/tools/org/h2/dev/store/btree/BtreeMapStore.java
+2
-2
Node.java
h2/src/tools/org/h2/dev/store/tree/Node.java
+10
-10
TreeMapStore.java
h2/src/tools/org/h2/dev/store/tree/TreeMapStore.java
+2
-2
没有找到文件。
h2/src/main/org/h2/index/PageBtreeIndex.java
浏览文件 @
dd3ee7e8
...
...
@@ -77,7 +77,7 @@ public class PageBtreeIndex extends PageIndex {
memoryPerPage
=
(
Constants
.
MEMORY_PAGE_BTREE
+
store
.
getPageSize
())
>>
2
;
}
private
void
checkIndexColumnTypes
(
IndexColumn
[]
columns
)
{
private
static
void
checkIndexColumnTypes
(
IndexColumn
[]
columns
)
{
for
(
IndexColumn
c
:
columns
)
{
int
type
=
c
.
column
.
getType
();
if
(
type
==
Value
.
CLOB
||
type
==
Value
.
BLOB
)
{
...
...
h2/src/main/org/h2/jdbc/JdbcResultSet.java
浏览文件 @
dd3ee7e8
...
...
@@ -2918,7 +2918,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
throw
DbException
.
get
(
ErrorCode
.
COLUMN_NOT_FOUND_1
,
columnLabel
);
}
private
void
mapColumn
(
HashMap
<
String
,
Integer
>
map
,
String
label
,
int
index
)
{
private
static
void
mapColumn
(
HashMap
<
String
,
Integer
>
map
,
String
label
,
int
index
)
{
// put the index (usually that's the only operation)
Integer
old
=
map
.
put
(
label
,
index
);
if
(
old
!=
null
)
{
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
dd3ee7e8
...
...
@@ -1257,7 +1257,7 @@ public class Recover extends Tool implements DataHandler {
}
}
private
boolean
isSchemaObjectTypeDelayed
(
MetaRecord
m
)
{
private
static
boolean
isSchemaObjectTypeDelayed
(
MetaRecord
m
)
{
switch
(
m
.
getObjectType
())
{
case
DbObject
.
INDEX
:
case
DbObject
.
CONSTRAINT
:
...
...
h2/src/main/org/h2/value/CaseInsensitiveMap.java
浏览文件 @
dd3ee7e8
...
...
@@ -34,7 +34,7 @@ public class CaseInsensitiveMap<V> extends HashMap<String, V> {
return
super
.
remove
(
toUpper
(
key
));
}
private
String
toUpper
(
Object
key
)
{
private
static
String
toUpper
(
Object
key
)
{
return
key
==
null
?
null
:
StringUtils
.
toUpperEnglish
(
key
.
toString
());
}
...
...
h2/src/test/org/h2/test/db/TestFullText.java
浏览文件 @
dd3ee7e8
...
...
@@ -19,7 +19,6 @@ import java.util.StringTokenizer;
import
java.util.UUID
;
import
org.h2.fulltext.FullText
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.test.TestAll
;
import
org.h2.test.TestBase
;
import
org.h2.util.Task
;
...
...
@@ -76,7 +75,7 @@ public class TestFullText extends TestBase {
deleteDb
(
"fullTextReopen"
);
}
private
void
close
(
Collection
<
Connection
>
conns
)
throws
SQLException
{
private
static
void
close
(
Collection
<
Connection
>
conns
)
throws
SQLException
{
for
(
Connection
conn
:
conns
)
{
conn
.
close
();
}
...
...
h2/src/test/org/h2/test/jaqu/ProductAnnotationOnly.java
浏览文件 @
dd3ee7e8
...
...
@@ -33,7 +33,6 @@ public class ProductAnnotationOnly {
@JQColumn
(
name
=
"name"
)
private
String
productName
;
@SuppressWarnings
(
"unused"
)
@JQColumn
private
Double
unitPrice
;
...
...
h2/src/test/org/h2/test/jaqu/ProductNoCreateTable.java
浏览文件 @
dd3ee7e8
...
...
@@ -17,11 +17,9 @@ import org.h2.jaqu.Table.JQTable;
@JQTable
(
createIfRequired
=
false
)
public
class
ProductNoCreateTable
{
@SuppressWarnings
(
"unused"
)
@JQColumn
(
name
=
"id"
)
private
Integer
productId
;
@SuppressWarnings
(
"unused"
)
@JQColumn
(
name
=
"name"
)
private
String
productName
;
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
dd3ee7e8
...
...
@@ -91,7 +91,7 @@ public class TestPreparedStatement extends TestBase {
deleteDb
(
"preparedStatement"
);
}
private
void
testChangeType
(
Connection
conn
)
throws
SQLException
{
private
static
void
testChangeType
(
Connection
conn
)
throws
SQLException
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select (? || ? || ?) from dual"
);
prep
.
setString
(
1
,
"a"
);
prep
.
setString
(
2
,
"b"
);
...
...
@@ -192,7 +192,7 @@ public class TestPreparedStatement extends TestBase {
stat
.
execute
(
"drop table d"
);
}
private
void
testCallTablePrepared
(
Connection
conn
)
throws
SQLException
{
private
static
void
testCallTablePrepared
(
Connection
conn
)
throws
SQLException
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"call table(x int = (1))"
);
prep
.
executeQuery
();
prep
.
executeQuery
();
...
...
h2/src/test/org/h2/test/unit/TestAutoReconnect.java
浏览文件 @
dd3ee7e8
...
...
@@ -64,7 +64,7 @@ public class TestAutoReconnect extends TestBase implements DatabaseEventListener
deleteDb
(
"autoReconnect"
);
Server
tcp
=
Server
.
createTcpServer
().
start
();
try
{
Connection
conn
=
getConnection
(
"jdbc:h2:"
+
getBaseDir
()
+
"/autoReconnect;AUTO_SERVER=TRUE"
);
conn
=
getConnection
(
"jdbc:h2:"
+
getBaseDir
()
+
"/autoReconnect;AUTO_SERVER=TRUE"
);
assertThrows
(
ErrorCode
.
DATABASE_ALREADY_OPEN_1
,
this
).
getConnection
(
"jdbc:h2:"
+
getBaseDir
()
+
"/autoReconnect;OPEN_NEW=TRUE"
);
assertThrows
(
ErrorCode
.
DATABASE_ALREADY_OPEN_1
,
this
).
...
...
h2/src/test/org/h2/test/unit/TestClassLoaderLeak.java
浏览文件 @
dd3ee7e8
...
...
@@ -55,7 +55,8 @@ public class TestClassLoaderLeak extends TestBase {
// using -XX:+HeapDumpOnOutOfMemoryError
// which can be analyzed using EclipseMAT
// (check incoming references to TestClassLoader)
if
(
false
)
{
boolean
fillMemory
=
false
;
if
(
fillMemory
)
{
ArrayList
<
byte
[]>
memory
=
New
.
arrayList
();
for
(
int
i
=
0
;
i
<
Integer
.
MAX_VALUE
;
i
++)
{
memory
.
add
(
new
byte
[
1024
]);
...
...
h2/src/test/org/h2/test/unit/TestCompress.java
浏览文件 @
dd3ee7e8
...
...
@@ -100,12 +100,12 @@ public class TestCompress extends TestBase {
Task
t
=
new
Task
()
{
public
void
call
()
{
CompressTool
tool
=
CompressTool
.
getInstance
();
byte
[]
b
uff
=
new
byte
[
1024
];
byte
[]
b
=
new
byte
[
1024
];
Random
r
=
new
Random
();
while
(!
stop
)
{
r
.
nextBytes
(
b
uff
);
byte
[]
test
=
tool
.
expand
(
tool
.
compress
(
b
uff
,
"LZF"
));
assertEquals
(
b
uff
,
test
);
r
.
nextBytes
(
b
);
byte
[]
test
=
tool
.
expand
(
tool
.
compress
(
b
,
"LZF"
));
assertEquals
(
b
,
test
);
}
}
};
...
...
@@ -120,17 +120,17 @@ public class TestCompress extends TestBase {
private
void
testVariableEnd
()
throws
Exception
{
CompressTool
utils
=
CompressTool
.
getInstance
();
StringBuilder
b
uff
=
new
StringBuilder
();
StringBuilder
b
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
90
;
i
++)
{
b
uff
.
append
(
'0'
);
b
.
append
(
'0'
);
}
String
prefix
=
b
uff
.
toString
();
String
prefix
=
b
.
toString
();
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
b
uff
=
new
StringBuilder
(
prefix
);
b
=
new
StringBuilder
(
prefix
);
for
(
int
j
=
0
;
j
<
i
;
j
++)
{
b
uff
.
append
((
char
)
(
'1'
+
j
));
b
.
append
((
char
)
(
'1'
+
j
));
}
String
test
=
b
uff
.
toString
();
String
test
=
b
.
toString
();
byte
[]
in
=
test
.
getBytes
();
assertEquals
(
in
,
utils
.
expand
(
utils
.
compress
(
in
,
"LZF"
)));
}
...
...
@@ -152,19 +152,19 @@ public class TestCompress extends TestBase {
conn
.
close
();
Compressor
compress
=
new
CompressLZF
();
int
pageSize
=
Constants
.
DEFAULT_PAGE_SIZE
;
byte
[]
buff
=
new
byte
[
pageSize
];
byte
[]
buff
2
=
new
byte
[
pageSize
];
byte
[]
test
=
new
byte
[
2
*
pageSize
];
compress
.
compress
(
buff
,
pageSize
,
test
,
0
);
compress
.
compress
(
buff
2
,
pageSize
,
test
,
0
);
for
(
int
j
=
0
;
j
<
4
;
j
++)
{
long
time
=
System
.
currentTimeMillis
();
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
InputStream
in
=
FileUtils
.
newInputStream
(
"memFS:compress.h2.db"
);
while
(
true
)
{
int
len
=
in
.
read
(
buff
);
int
len
=
in
.
read
(
buff
2
);
if
(
len
<
0
)
{
break
;
}
compress
.
compress
(
buff
,
pageSize
,
test
,
0
);
compress
.
compress
(
buff
2
,
pageSize
,
test
,
0
);
}
in
.
close
();
}
...
...
@@ -175,11 +175,11 @@ public class TestCompress extends TestBase {
ArrayList
<
byte
[]>
comp
=
New
.
arrayList
();
InputStream
in
=
FileUtils
.
newInputStream
(
"memFS:compress.h2.db"
);
while
(
true
)
{
int
len
=
in
.
read
(
buff
);
int
len
=
in
.
read
(
buff
2
);
if
(
len
<
0
)
{
break
;
}
int
b
=
compress
.
compress
(
buff
,
pageSize
,
test
,
0
);
int
b
=
compress
.
compress
(
buff
2
,
pageSize
,
test
,
0
);
byte
[]
data
=
new
byte
[
b
];
System
.
arraycopy
(
test
,
0
,
data
,
0
,
b
);
comp
.
add
(
data
);
...
...
@@ -200,24 +200,24 @@ public class TestCompress extends TestBase {
private
void
test
(
int
len
)
throws
IOException
{
Random
r
=
new
Random
(
len
);
for
(
int
pattern
=
0
;
pattern
<
4
;
pattern
++)
{
byte
[]
b
uff
=
new
byte
[
len
];
byte
[]
b
=
new
byte
[
len
];
switch
(
pattern
)
{
case
0
:
// leave empty
break
;
case
1
:
{
r
.
nextBytes
(
b
uff
);
r
.
nextBytes
(
b
);
break
;
}
case
2
:
{
for
(
int
x
=
0
;
x
<
len
;
x
++)
{
b
uff
[
x
]
=
(
byte
)
(
x
&
10
);
b
[
x
]
=
(
byte
)
(
x
&
10
);
}
break
;
}
case
3
:
{
for
(
int
x
=
0
;
x
<
len
;
x
++)
{
b
uff
[
x
]
=
(
byte
)
(
x
/
10
);
b
[
x
]
=
(
byte
)
(
x
/
10
);
}
break
;
}
...
...
@@ -226,7 +226,7 @@ public class TestCompress extends TestBase {
if
(
r
.
nextInt
(
2
)
<
1
)
{
for
(
int
x
=
0
;
x
<
len
;
x
++)
{
if
(
r
.
nextInt
(
20
)
<
1
)
{
b
uff
[
x
]
=
(
byte
)
(
r
.
nextInt
(
255
));
b
[
x
]
=
(
byte
)
(
r
.
nextInt
(
255
));
}
}
}
...
...
@@ -234,27 +234,27 @@ public class TestCompress extends TestBase {
// level 9 is highest, strategy 2 is huffman only
for
(
String
a
:
new
String
[]
{
"LZF"
,
"No"
,
"Deflate"
,
"Deflate level 9 strategy 2"
})
{
long
time
=
System
.
currentTimeMillis
();
byte
[]
out
=
utils
.
compress
(
b
uff
,
a
);
byte
[]
out
=
utils
.
compress
(
b
,
a
);
byte
[]
test
=
utils
.
expand
(
out
);
if
(
testPerformance
)
{
System
.
out
.
println
(
"p:"
+
pattern
+
" len: "
+
out
.
length
+
" time: "
+
(
System
.
currentTimeMillis
()
-
time
)
+
" "
+
a
);
}
assertEquals
(
b
uff
.
length
,
test
.
length
);
assertEquals
(
b
uff
,
test
);
assertEquals
(
b
.
length
,
test
.
length
);
assertEquals
(
b
,
test
);
Arrays
.
fill
(
test
,
(
byte
)
0
);
CompressTool
.
expand
(
out
,
test
,
0
);
assertEquals
(
b
uff
,
test
);
assertEquals
(
b
,
test
);
}
for
(
String
a
:
new
String
[]
{
null
,
"LZF"
,
"DEFLATE"
,
"ZIP"
,
"GZIP"
})
{
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
OutputStream
out2
=
CompressTool
.
wrapOutputStream
(
out
,
a
,
"test"
);
IOUtils
.
copy
(
new
ByteArrayInputStream
(
b
uff
),
out2
);
IOUtils
.
copy
(
new
ByteArrayInputStream
(
b
),
out2
);
out2
.
close
();
InputStream
in
=
new
ByteArrayInputStream
(
out
.
toByteArray
());
in
=
CompressTool
.
wrapInputStream
(
in
,
a
,
"test"
);
out
.
reset
();
IOUtils
.
copy
(
in
,
out
);
assertEquals
(
b
uff
,
out
.
toByteArray
());
assertEquals
(
b
,
out
.
toByteArray
());
}
}
}
...
...
h2/src/test/org/h2/test/unit/TestDate.java
浏览文件 @
dd3ee7e8
...
...
@@ -351,7 +351,7 @@ public class TestDate extends TestBase {
}
}
private
void
testCalculateLocalMillis
()
{
private
static
void
testCalculateLocalMillis
()
{
TimeZone
defaultTimeZone
=
TimeZone
.
getDefault
();
try
{
for
(
TimeZone
tz
:
TestDate
.
getDistinctTimeZones
())
{
...
...
h2/src/test/org/h2/test/unit/TestFileLockProcess.java
浏览文件 @
dd3ee7e8
...
...
@@ -32,11 +32,10 @@ public class TestFileLockProcess extends TestBase {
return
;
}
String
url
=
args
[
0
];
TestFileLockProcess
app
=
new
TestFileLockProcess
();
app
.
execute
(
url
);
execute
(
url
);
}
private
void
execute
(
String
url
)
{
private
static
void
execute
(
String
url
)
{
org
.
h2
.
Driver
.
load
();
try
{
Class
.
forName
(
"org.h2.Driver"
);
...
...
h2/src/test/org/h2/test/unit/TestFileSystem.java
浏览文件 @
dd3ee7e8
...
...
@@ -283,7 +283,7 @@ public class TestFileSystem extends TestBase {
}
}
private
void
testDirectories
(
String
fsBase
)
{
private
static
void
testDirectories
(
String
fsBase
)
{
final
String
fileName
=
fsBase
+
"/testFile"
;
if
(
FileUtils
.
exists
(
fileName
))
{
FileUtils
.
delete
(
fileName
);
...
...
@@ -299,7 +299,7 @@ public class TestFileSystem extends TestBase {
}
}
private
void
testMoveTo
(
String
fsBase
)
{
private
static
void
testMoveTo
(
String
fsBase
)
{
final
String
fileName
=
fsBase
+
"/testFile"
;
final
String
fileName2
=
fsBase
+
"/testFile2"
;
if
(
FileUtils
.
exists
(
fileName
))
{
...
...
@@ -319,7 +319,7 @@ public class TestFileSystem extends TestBase {
}
}
private
void
testUnsupportedFeatures
(
String
fsBase
)
throws
IOException
{
private
static
void
testUnsupportedFeatures
(
String
fsBase
)
throws
IOException
{
final
String
fileName
=
fsBase
+
"/testFile"
;
if
(
FileUtils
.
exists
(
fileName
))
{
FileUtils
.
delete
(
fileName
);
...
...
h2/src/test/org/h2/test/unit/TestJmx.java
浏览文件 @
dd3ee7e8
...
...
@@ -34,7 +34,6 @@ public class TestJmx extends TestBase {
TestBase
.
createCaller
().
init
().
test
();
}
@SuppressWarnings
(
"unchecked"
)
public
void
test
()
throws
Exception
{
HashMap
<
String
,
MBeanAttributeInfo
>
attrMap
;
HashMap
<
String
,
MBeanOperationInfo
>
opMap
;
...
...
@@ -104,6 +103,7 @@ public class TestJmx extends TestBase {
conn
=
getConnection
(
"jmx;jmx=true"
);
name
=
new
ObjectName
(
"org.h2:name=JMX,*"
);
@SuppressWarnings
(
"rawtypes"
)
Set
set
=
mbeanServer
.
queryNames
(
name
,
null
);
name
=
(
ObjectName
)
set
.
iterator
().
next
();
...
...
h2/src/test/org/h2/test/unit/TestSort.java
浏览文件 @
dd3ee7e8
...
...
@@ -52,8 +52,8 @@ public class TestSort extends TestBase {
test
(
Arrays
.
class
);
}
private
void
test
(
Class
<?>
c
lazz
)
throws
Exception
{
this
.
clazz
=
c
lazz
;
private
void
test
(
Class
<?>
c
)
throws
Exception
{
this
.
clazz
=
c
;
ordered
(
array
);
shuffle
(
array
);
stabilize
(
array
);
...
...
h2/src/test/org/h2/test/unit/TestUtils.java
浏览文件 @
dd3ee7e8
...
...
@@ -93,8 +93,8 @@ public class TestUtils extends TestBase {
String
pathSeparator
=
(
String
)
Utils
.
getStaticField
(
"java.io.File.pathSeparator"
);
assertEquals
(
File
.
pathSeparator
,
pathSeparator
);
// Instance fields
String
test
Field
=
(
String
)
Utils
.
getField
(
this
,
"testField"
);
assertEquals
(
this
.
testField
,
test
Field
);
String
test
=
(
String
)
Utils
.
getField
(
this
,
"testField"
);
assertEquals
(
this
.
testField
,
test
);
// Class present?
assertFalse
(
Utils
.
isClassPresent
(
"abc"
));
assertTrue
(
Utils
.
isClassPresent
(
getClass
().
getName
()));
...
...
h2/src/test/org/h2/test/utils/ProxyCodeGenerator.java
浏览文件 @
dd3ee7e8
...
...
@@ -142,7 +142,7 @@ public class ProxyCodeGenerator {
methods
.
put
(
getMethodName
(
m
),
m
);
}
private
String
getMethodName
(
Method
m
)
{
private
static
String
getMethodName
(
Method
m
)
{
StringBuilder
buff
=
new
StringBuilder
();
buff
.
append
(
m
.
getReturnType
()).
append
(
' '
);
buff
.
append
(
m
.
getName
());
...
...
h2/src/tools/org/h2/build/doc/RailroadImages.java
浏览文件 @
dd3ee7e8
...
...
@@ -86,7 +86,7 @@ public class RailroadImages {
savePng
(
flipHorizontal
(
img
),
"div-ke.png"
);
}
private
void
setStroke
(
Graphics2D
g
,
int
i
)
{
private
static
void
setStroke
(
Graphics2D
g
,
int
i
)
{
if
(
i
==
0
)
{
g
.
setColor
(
Color
.
WHITE
);
g
.
setStroke
(
new
BasicStroke
(
STROKE
*
2
));
...
...
h2/src/tools/org/h2/dev/fs/FilePathZip2.java
浏览文件 @
dd3ee7e8
...
...
@@ -207,11 +207,11 @@ public class FilePathZip2 extends FilePath {
if
(
entry
==
null
)
{
break
;
}
String
n
ame
=
entry
.
getName
();
if
(
name
.
startsWith
(
dirName
)
&&
n
ame
.
length
()
>
dirName
.
length
())
{
int
idx
=
n
ame
.
indexOf
(
'/'
,
dirName
.
length
());
if
(
idx
<
0
||
idx
>=
n
ame
.
length
()
-
1
)
{
list
.
add
(
getPath
(
prefix
+
n
ame
));
String
entryN
ame
=
entry
.
getName
();
if
(
entryName
.
startsWith
(
dirName
)
&&
entryN
ame
.
length
()
>
dirName
.
length
())
{
int
idx
=
entryN
ame
.
indexOf
(
'/'
,
dirName
.
length
());
if
(
idx
<
0
||
idx
>=
entryN
ame
.
length
()
-
1
)
{
list
.
add
(
getPath
(
prefix
+
entryN
ame
));
}
}
file
.
closeEntry
();
...
...
h2/src/tools/org/h2/dev/fs/FileShell.java
浏览文件 @
dd3ee7e8
...
...
@@ -285,7 +285,7 @@ public class FileShell extends Tool {
return
true
;
}
private
void
end
(
String
[]
list
,
int
index
)
throws
IOException
{
private
static
void
end
(
String
[]
list
,
int
index
)
throws
IOException
{
if
(
list
.
length
!=
index
)
{
throw
new
IOException
(
"End of command expected, got: "
+
list
[
index
]);
}
...
...
@@ -298,14 +298,14 @@ public class FileShell extends Tool {
if
(
FileUtils
.
isDirectory
(
fileName
))
{
print
(
"Is a directory: "
+
fileName
);
}
InputStream
in
=
null
;
InputStream
in
File
=
null
;
try
{
in
=
FileUtils
.
newInputStream
(
fileName
);
IOUtils
.
copy
(
in
,
out
,
length
);
in
File
=
FileUtils
.
newInputStream
(
fileName
);
IOUtils
.
copy
(
in
File
,
out
,
length
);
}
catch
(
IOException
e
)
{
error
(
e
);
}
finally
{
IOUtils
.
closeSilently
(
in
);
IOUtils
.
closeSilently
(
in
File
);
}
println
(
""
);
}
...
...
@@ -333,7 +333,7 @@ public class FileShell extends Tool {
}
}
private
void
zip
(
String
zipFileName
,
String
base
,
ArrayList
<
String
>
source
)
{
private
static
void
zip
(
String
zipFileName
,
String
base
,
ArrayList
<
String
>
source
)
{
FileUtils
.
delete
(
zipFileName
);
OutputStream
fileOut
=
null
;
try
{
...
...
@@ -376,10 +376,10 @@ public class FileShell extends Tool {
}
private
void
unzip
(
String
zipFileName
,
String
targetDir
)
{
InputStream
in
=
null
;
InputStream
in
File
=
null
;
try
{
in
=
FileUtils
.
newInputStream
(
zipFileName
);
ZipInputStream
zipIn
=
new
ZipInputStream
(
in
);
in
File
=
FileUtils
.
newInputStream
(
zipFileName
);
ZipInputStream
zipIn
=
new
ZipInputStream
(
in
File
);
while
(
true
)
{
ZipEntry
entry
=
zipIn
.
getNextEntry
();
if
(
entry
==
null
)
{
...
...
@@ -407,7 +407,7 @@ public class FileShell extends Tool {
}
catch
(
IOException
e
)
{
error
(
e
);
}
finally
{
IOUtils
.
closeSilently
(
in
);
IOUtils
.
closeSilently
(
in
File
);
}
}
...
...
h2/src/tools/org/h2/dev/sort/InPlaceStableMergeSort.java
浏览文件 @
dd3ee7e8
...
...
@@ -56,18 +56,18 @@ public class InPlaceStableMergeSort<T> {
/**
* Sort an array using the given comparator.
*
* @param d
ata
the data array to sort
* @param c
omp
the comparator
* @param d the data array to sort
* @param c the comparator
*/
public
void
sortArray
(
T
[]
d
ata
,
Comparator
<
T
>
comp
)
{
this
.
data
=
d
ata
;
this
.
comp
=
c
omp
;
int
len
=
Math
.
max
((
int
)
(
100
*
Math
.
log
(
d
ata
.
length
)),
TEMP_SIZE
);
len
=
Math
.
min
(
d
ata
.
length
,
len
);
public
void
sortArray
(
T
[]
d
,
Comparator
<
T
>
c
)
{
this
.
data
=
d
;
this
.
comp
=
c
;
int
len
=
Math
.
max
((
int
)
(
100
*
Math
.
log
(
d
.
length
)),
TEMP_SIZE
);
len
=
Math
.
min
(
d
.
length
,
len
);
@SuppressWarnings
(
"unchecked"
)
T
[]
t
=
(
T
[])
new
Object
[
len
];
this
.
temp
=
t
;
mergeSort
(
0
,
d
ata
.
length
-
1
);
mergeSort
(
0
,
d
.
length
-
1
);
}
/**
...
...
@@ -309,14 +309,14 @@ public class InPlaceStableMergeSort<T> {
/**
* Swap two elements in the array.
*
* @param d
ata
the array
* @param d the array
* @param a the index of the first element
* @param b the index of the second element
*/
private
void
swap
(
T
[]
d
ata
,
int
a
,
int
b
)
{
T
t
emp
=
data
[
a
];
d
ata
[
a
]
=
data
[
b
];
d
ata
[
b
]
=
temp
;
private
void
swap
(
T
[]
d
,
int
a
,
int
b
)
{
T
t
=
d
[
a
];
d
[
a
]
=
d
[
b
];
d
[
b
]
=
t
;
}
}
\ No newline at end of file
h2/src/tools/org/h2/dev/sort/InPlaceStableQuicksort.java
浏览文件 @
dd3ee7e8
...
...
@@ -56,18 +56,18 @@ public class InPlaceStableQuicksort<T> {
/**
* Sort an array using the given comparator.
*
* @param d
ata
the data array to sort
* @param c
omp
the comparator
* @param d the data array to sort
* @param c the comparator
*/
public
void
sortArray
(
T
[]
d
ata
,
Comparator
<
T
>
comp
)
{
this
.
data
=
d
ata
;
this
.
comp
=
c
omp
;
int
len
=
Math
.
max
((
int
)
(
100
*
Math
.
log
(
d
ata
.
length
)),
TEMP_SIZE
);
len
=
Math
.
min
(
d
ata
.
length
,
len
);
public
void
sortArray
(
T
[]
d
,
Comparator
<
T
>
c
)
{
this
.
data
=
d
;
this
.
comp
=
c
;
int
len
=
Math
.
max
((
int
)
(
100
*
Math
.
log
(
d
.
length
)),
TEMP_SIZE
);
len
=
Math
.
min
(
d
.
length
,
len
);
@SuppressWarnings
(
"unchecked"
)
T
[]
t
=
(
T
[])
new
Object
[
len
];
this
.
temp
=
t
;
quicksort
(
0
,
d
ata
.
length
-
1
);
quicksort
(
0
,
d
.
length
-
1
);
}
/**
...
...
@@ -250,19 +250,19 @@ public class InPlaceStableQuicksort<T> {
/**
* Select the specified element.
*
* @param d
ata
the array
* @param d the array
* @param from the index of the first element
* @param to the index of the last element
* @param k which element to return (1 means the lowest)
* @return the specified element
*/
private
T
select
(
T
[]
d
ata
,
int
from
,
int
to
,
int
k
)
{
private
T
select
(
T
[]
d
,
int
from
,
int
to
,
int
k
)
{
while
(
true
)
{
int
pivotIndex
=
(
to
+
from
)
>>>
1
;
int
pivotNewIndex
=
selectPartition
(
d
ata
,
from
,
to
,
pivotIndex
);
int
pivotNewIndex
=
selectPartition
(
d
,
from
,
to
,
pivotIndex
);
int
pivotDist
=
pivotNewIndex
-
from
+
1
;
if
(
pivotDist
==
k
)
{
return
d
ata
[
pivotNewIndex
];
return
d
[
pivotNewIndex
];
}
else
if
(
k
<
pivotDist
)
{
to
=
pivotNewIndex
-
1
;
}
else
{
...
...
@@ -275,37 +275,37 @@ public class InPlaceStableQuicksort<T> {
/**
* Partition the elements to select an element.
*
* @param d
ata
the array
* @param d the array
* @param from the index of the first element
* @param to the index of the last element
* @param pivotIndex the index of the pivot
* @return the new index
*/
private
int
selectPartition
(
T
[]
d
ata
,
int
from
,
int
to
,
int
pivotIndex
)
{
T
pivotValue
=
d
ata
[
pivotIndex
];
swap
(
d
ata
,
pivotIndex
,
to
);
private
int
selectPartition
(
T
[]
d
,
int
from
,
int
to
,
int
pivotIndex
)
{
T
pivotValue
=
d
[
pivotIndex
];
swap
(
d
,
pivotIndex
,
to
);
int
storeIndex
=
from
;
for
(
int
i
=
from
;
i
<=
to
;
i
++)
{
if
(
comp
.
compare
(
d
ata
[
i
],
pivotValue
)
<
0
)
{
swap
(
d
ata
,
storeIndex
,
i
);
if
(
comp
.
compare
(
d
[
i
],
pivotValue
)
<
0
)
{
swap
(
d
,
storeIndex
,
i
);
storeIndex
++;
}
}
swap
(
d
ata
,
to
,
storeIndex
);
swap
(
d
,
to
,
storeIndex
);
return
storeIndex
;
}
/**
* Swap two elements in the array.
*
* @param d
ata
the array
* @param d the array
* @param a the index of the first element
* @param b the index of the second element
*/
private
void
swap
(
T
[]
d
ata
,
int
a
,
int
b
)
{
T
t
emp
=
data
[
a
];
d
ata
[
a
]
=
data
[
b
];
d
ata
[
b
]
=
temp
;
private
void
swap
(
T
[]
d
,
int
a
,
int
b
)
{
T
t
=
d
[
a
];
d
[
a
]
=
d
[
b
];
d
[
b
]
=
t
;
}
}
h2/src/tools/org/h2/dev/store/btree/BtreeMapStore.java
浏览文件 @
dd3ee7e8
...
...
@@ -238,7 +238,7 @@ public class BtreeMapStore {
return
pos
;
}
private
long
getId
(
int
blockId
,
int
offset
)
{
private
static
long
getId
(
int
blockId
,
int
offset
)
{
return
((
long
)
blockId
<<
32
)
|
offset
;
}
...
...
@@ -597,7 +597,7 @@ public class BtreeMapStore {
}
}
private
int
getBlockId
(
long
pageId
)
{
private
static
int
getBlockId
(
long
pageId
)
{
return
(
int
)
(
pageId
>>>
32
);
}
...
...
h2/src/tools/org/h2/dev/store/tree/Node.java
浏览文件 @
dd3ee7e8
...
...
@@ -291,39 +291,39 @@ class Node {
/**
* Compare the key with the key of this node.
*
* @param k
ey
the key
* @param k the key
* @return -1 if the key is smaller than this nodes key, 1 if bigger, and 0
* if equal
*/
int
compare
(
Object
k
ey
)
{
return
map
.
compare
(
k
ey
,
this
.
key
);
int
compare
(
Object
k
)
{
return
map
.
compare
(
k
,
this
.
key
);
}
private
Node
remove
(
Object
k
ey
)
{
private
Node
remove
(
Object
k
)
{
Node
n
=
copyOnWrite
();
if
(
map
.
compare
(
k
ey
,
n
.
key
)
<
0
)
{
if
(
map
.
compare
(
k
,
n
.
key
)
<
0
)
{
if
(!
isRed
(
n
.
getLeft
())
&&
!
isRed
(
n
.
getLeft
().
getLeft
()))
{
n
=
n
.
moveRedLeft
();
}
n
.
setLeft
(
n
.
getLeft
().
remove
(
k
ey
));
n
.
setLeft
(
n
.
getLeft
().
remove
(
k
));
}
else
{
if
(
isRed
(
n
.
getLeft
()))
{
n
=
n
.
rotateRight
();
}
if
(
n
.
compare
(
k
ey
)
==
0
&&
n
.
getRight
()
==
null
)
{
if
(
n
.
compare
(
k
)
==
0
&&
n
.
getRight
()
==
null
)
{
map
.
removeNode
(
id
);
return
null
;
}
if
(!
isRed
(
n
.
getRight
())
&&
!
isRed
(
n
.
getRight
().
getLeft
()))
{
n
=
n
.
moveRedRight
();
}
if
(
n
.
compare
(
k
ey
)
==
0
)
{
if
(
n
.
compare
(
k
)
==
0
)
{
Node
min
=
n
.
getRight
().
getMin
();
n
.
key
=
min
.
key
;
n
.
data
=
min
.
data
;
n
.
setRight
(
n
.
getRight
().
removeMin
());
}
else
{
n
.
setRight
(
n
.
getRight
().
remove
(
k
ey
));
n
.
setRight
(
n
.
getRight
().
remove
(
k
));
}
}
return
n
.
fixUp
();
...
...
@@ -390,7 +390,7 @@ class Node {
return
n
;
}
private
boolean
isRed
(
Node
n
)
{
private
static
boolean
isRed
(
Node
n
)
{
return
n
!=
null
&&
(
n
.
flags
&
FLAG_BLACK
)
==
0
;
}
...
...
h2/src/tools/org/h2/dev/store/tree/TreeMapStore.java
浏览文件 @
dd3ee7e8
...
...
@@ -304,7 +304,7 @@ public class TreeMapStore {
return
pos
;
}
private
long
getId
(
int
blockId
,
int
offset
)
{
private
static
long
getId
(
int
blockId
,
int
offset
)
{
return
((
long
)
blockId
<<
32
)
|
offset
;
}
...
...
@@ -632,7 +632,7 @@ public class TreeMapStore {
}
}
private
int
getBlockId
(
long
nodeId
)
{
private
static
int
getBlockId
(
long
nodeId
)
{
return
(
int
)
(
nodeId
>>>
32
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论