Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
15948d7f
提交
15948d7f
authored
2月 16, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unused code.
上级
4a10fc4b
显示空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
82 行增加
和
80 行删除
+82
-80
ScriptBase.java
h2/src/main/org/h2/command/dml/ScriptBase.java
+0
-6
Select.java
h2/src/main/org/h2/command/dml/Select.java
+1
-1
AggregateData.java
h2/src/main/org/h2/expression/AggregateData.java
+3
-3
HashIndex.java
h2/src/main/org/h2/index/HashIndex.java
+1
-1
NonUniqueHashIndex.java
h2/src/main/org/h2/index/NonUniqueHashIndex.java
+1
-1
TreeCursor.java
h2/src/main/org/h2/index/TreeCursor.java
+0
-1
JdbcDataSource.java
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
+2
-1
JdbcDataSourceFactory.java
h2/src/main/org/h2/jdbcx/JdbcDataSourceFactory.java
+11
-9
LocalResult.java
h2/src/main/org/h2/result/LocalResult.java
+1
-1
DataHandler.java
h2/src/main/org/h2/store/DataHandler.java
+0
-10
Recover.java
h2/src/main/org/h2/tools/Recover.java
+0
-7
ValueHashMap.java
h2/src/main/org/h2/util/ValueHashMap.java
+5
-17
TestConnectionPool.java
h2/src/test/org/h2/test/jdbcx/TestConnectionPool.java
+16
-0
TestDataSource.java
h2/src/test/org/h2/test/jdbcx/TestDataSource.java
+39
-2
TestDataPage.java
h2/src/test/org/h2/test/unit/TestDataPage.java
+0
-5
TestFile.java
h2/src/test/org/h2/test/unit/TestFile.java
+0
-5
TestValueHashMap.java
h2/src/test/org/h2/test/unit/TestValueHashMap.java
+2
-6
TestValueMemory.java
h2/src/test/org/h2/test/unit/TestValueMemory.java
+0
-4
没有找到文件。
h2/src/main/org/h2/command/dml/ScriptBase.java
浏览文件 @
15948d7f
...
...
@@ -11,7 +11,6 @@ import java.io.BufferedOutputStream;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
org.h2.command.Prepared
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
...
...
@@ -29,7 +28,6 @@ import org.h2.tools.CompressTool;
import
org.h2.util.IOUtils
;
import
org.h2.util.SmallLRUCache
;
import
org.h2.util.TempFileDeleter
;
import
org.h2.value.Value
;
/**
* This class is the base for RunScriptCommand and ScriptCommand.
...
...
@@ -201,10 +199,6 @@ public abstract class ScriptBase extends Prepared implements DataHandler {
session
.
getDatabase
().
freeUpDiskSpace
();
}
public
int
compareTypeSave
(
Value
a
,
Value
b
)
{
throw
DbException
.
throwInternalError
();
}
public
int
getMaxLengthInplaceLob
()
{
return
session
.
getDatabase
().
getMaxLengthInplaceLob
();
}
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
15948d7f
...
...
@@ -298,7 +298,7 @@ public class Select extends Query {
}
private
void
queryGroup
(
int
columnCount
,
LocalResult
result
)
{
ValueHashMap
<
HashMap
<
Expression
,
Object
>>
groups
=
ValueHashMap
.
newInstance
(
session
.
getDatabase
()
);
ValueHashMap
<
HashMap
<
Expression
,
Object
>>
groups
=
ValueHashMap
.
newInstance
();
int
rowNumber
=
0
;
setCurrentRowNumber
(
0
);
ValueArray
defaultGroup
=
ValueArray
.
get
(
new
Value
[
0
]);
...
...
h2/src/main/org/h2/expression/AggregateData.java
浏览文件 @
15948d7f
...
...
@@ -48,11 +48,11 @@ class AggregateData {
if
(
aggregateType
==
Aggregate
.
SELECTIVITY
)
{
count
++;
if
(
distinctValues
==
null
)
{
distinctValues
=
ValueHashMap
.
newInstance
(
database
);
distinctValues
=
ValueHashMap
.
newInstance
();
}
int
size
=
distinctValues
.
size
();
if
(
size
>
Constants
.
SELECTIVITY_DISTINCT_COUNT
)
{
distinctValues
=
ValueHashMap
.
newInstance
(
database
);
distinctValues
=
ValueHashMap
.
newInstance
();
sum
+=
size
;
}
distinctValues
.
put
(
v
,
this
);
...
...
@@ -68,7 +68,7 @@ class AggregateData {
count
++;
if
(
distinct
)
{
if
(
distinctValues
==
null
)
{
distinctValues
=
ValueHashMap
.
newInstance
(
database
);
distinctValues
=
ValueHashMap
.
newInstance
();
}
distinctValues
.
put
(
v
,
this
);
return
;
...
...
h2/src/main/org/h2/index/HashIndex.java
浏览文件 @
15948d7f
...
...
@@ -33,7 +33,7 @@ public class HashIndex extends BaseIndex {
}
private
void
reset
()
{
rows
=
ValueHashMap
.
newInstance
(
table
.
getDatabase
()
);
rows
=
ValueHashMap
.
newInstance
();
}
public
void
truncate
(
Session
session
)
{
...
...
h2/src/main/org/h2/index/NonUniqueHashIndex.java
浏览文件 @
15948d7f
...
...
@@ -35,7 +35,7 @@ public class NonUniqueHashIndex extends HashIndex {
}
private
void
reset
()
{
rows
=
ValueHashMap
.
newInstance
(
table
.
getDatabase
()
);
rows
=
ValueHashMap
.
newInstance
();
rowCount
=
0
;
}
...
...
h2/src/main/org/h2/index/TreeCursor.java
浏览文件 @
15948d7f
...
...
@@ -59,5 +59,4 @@ public class TreeCursor implements Cursor {
return
node
!=
null
;
}
}
h2/src/main/org/h2/jdbcx/JdbcDataSource.java
浏览文件 @
15948d7f
...
...
@@ -7,6 +7,7 @@
package
org
.
h2
.
jdbcx
;
import
java.io.IOException
;
import
java.io.ObjectInputStream
;
import
java.io.PrintWriter
;
import
java.io.Serializable
;
import
java.sql.Connection
;
...
...
@@ -85,7 +86,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
setTrace
(
factory
.
getTrace
(),
TraceObject
.
DATA_SOURCE
,
id
);
}
private
void
readObject
(
java
.
io
.
ObjectInputStream
in
)
throws
IOException
,
ClassNotFoundException
{
private
void
readObject
(
ObjectInputStream
in
)
throws
IOException
,
ClassNotFoundException
{
initFactory
();
in
.
defaultReadObject
();
}
...
...
h2/src/main/org/h2/jdbcx/JdbcDataSourceFactory.java
浏览文件 @
15948d7f
...
...
@@ -61,6 +61,7 @@ implements ObjectFactory
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"getObjectInstance obj="
+
obj
+
" name="
+
name
+
" nameCtx="
+
nameCtx
+
" environment="
+
environment
);
}
if
(
obj
instanceof
Reference
)
{
Reference
ref
=
(
Reference
)
obj
;
if
(
ref
.
getClassName
().
equals
(
JdbcDataSource
.
class
.
getName
()))
{
JdbcDataSource
dataSource
=
new
JdbcDataSource
();
...
...
@@ -71,6 +72,7 @@ implements ObjectFactory
dataSource
.
setLoginTimeout
(
Integer
.
parseInt
(
s
));
return
dataSource
;
}
}
return
null
;
}
//## Java 1.4 end ##
...
...
h2/src/main/org/h2/result/LocalResult.java
浏览文件 @
15948d7f
...
...
@@ -180,7 +180,7 @@ public class LocalResult implements ResultInterface {
*/
public
void
setDistinct
()
{
distinct
=
true
;
distinctRows
=
ValueHashMap
.
newInstance
(
session
.
getDatabase
()
);
distinctRows
=
ValueHashMap
.
newInstance
();
}
/**
...
...
h2/src/main/org/h2/store/DataHandler.java
浏览文件 @
15948d7f
...
...
@@ -8,7 +8,6 @@ package org.h2.store;
import
org.h2.util.SmallLRUCache
;
import
org.h2.util.TempFileDeleter
;
import
org.h2.value.Value
;
/**
* A data handler contains a number of callback methods.
...
...
@@ -56,15 +55,6 @@ public interface DataHandler {
*/
void
freeUpDiskSpace
();
/**
* Compare two values.
*
* @param a the first value
* @param b the second value
* @return 0 for equal, 1 if a is larger than b, and -1 otherwise
*/
int
compareTypeSave
(
Value
a
,
Value
b
);
/**
* Get the maximum length of a in-place large object
*
...
...
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
15948d7f
...
...
@@ -1149,13 +1149,6 @@ public class Recover extends Tool implements DataHandler {
// nothing to do
}
/**
* INTERNAL
*/
public
int
compareTypeSave
(
Value
a
,
Value
b
)
{
throw
DbException
.
throwInternalError
();
}
/**
* INTERNAL
*/
...
...
h2/src/main/org/h2/util/ValueHashMap.java
浏览文件 @
15948d7f
...
...
@@ -8,7 +8,6 @@ package org.h2.util;
import
java.util.ArrayList
;
import
org.h2.message.DbException
;
import
org.h2.store.DataHandler
;
import
org.h2.value.Value
;
import
org.h2.value.ValueNull
;
...
...
@@ -21,17 +20,6 @@ public class ValueHashMap<V> extends HashBase {
private
Value
[]
keys
;
private
V
[]
values
;
private
DataHandler
handler
;
/**
* Create a new value hash map using the given data handler.
* The data handler is used to compare values.
*
* @param handler the data handler
*/
private
ValueHashMap
(
DataHandler
handler
)
{
this
.
handler
=
handler
;
}
/**
* Create a new value hash map using the given data handler.
...
...
@@ -40,8 +28,8 @@ public class ValueHashMap<V> extends HashBase {
* @param handler the data handler
* @return the object
*/
public
static
<
T
>
ValueHashMap
<
T
>
newInstance
(
DataHandler
handler
)
{
return
new
ValueHashMap
<
T
>(
handler
);
public
static
<
T
>
ValueHashMap
<
T
>
newInstance
()
{
return
new
ValueHashMap
<
T
>();
}
@SuppressWarnings
(
"unchecked"
)
...
...
@@ -95,7 +83,7 @@ public class ValueHashMap<V> extends HashBase {
if
(
deleted
<
0
)
{
deleted
=
index
;
}
}
else
if
(
handler
.
compareTypeSave
(
k
,
key
)
==
0
)
{
}
else
if
(
k
.
equals
(
key
)
)
{
// update existing
values
[
index
]
=
value
;
return
;
...
...
@@ -122,7 +110,7 @@ public class ValueHashMap<V> extends HashBase {
return
;
}
else
if
(
k
==
ValueNull
.
DELETED
)
{
// found a deleted record
}
else
if
(
handler
.
compareTypeSave
(
k
,
key
)
==
0
)
{
}
else
if
(
k
.
equals
(
key
)
)
{
// found the record
keys
[
index
]
=
ValueNull
.
DELETED
;
values
[
index
]
=
null
;
...
...
@@ -152,7 +140,7 @@ public class ValueHashMap<V> extends HashBase {
return
null
;
}
else
if
(
k
==
ValueNull
.
DELETED
)
{
// found a deleted record
}
else
if
(
handler
.
compareTypeSave
(
k
,
key
)
==
0
)
{
}
else
if
(
k
.
equals
(
key
)
)
{
// found it
return
values
[
index
];
}
...
...
h2/src/test/org/h2/test/jdbcx/TestConnectionPool.java
浏览文件 @
15948d7f
...
...
@@ -6,6 +6,8 @@
*/
package
org
.
h2
.
test
.
jdbcx
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
...
...
@@ -42,6 +44,20 @@ public class TestConnectionPool extends TestBase {
private
void
testUncommittedTransaction
()
throws
SQLException
{
String
url
=
getURL
(
"connectionPool"
,
true
),
user
=
getUser
(),
password
=
getPassword
();
JdbcConnectionPool
man
=
JdbcConnectionPool
.
create
(
url
,
user
,
password
);
assertEquals
(
5
*
60
,
man
.
getLoginTimeout
());
man
.
setLoginTimeout
(
1
);
assertEquals
(
1
,
man
.
getLoginTimeout
());
man
.
setLoginTimeout
(
0
);
assertEquals
(
5
*
60
,
man
.
getLoginTimeout
());
assertEquals
(
10
,
man
.
getMaxConnections
());
PrintWriter
old
=
man
.
getLogWriter
();
PrintWriter
pw
=
new
PrintWriter
(
new
StringWriter
());
man
.
setLogWriter
(
pw
);
assertTrue
(
pw
==
man
.
getLogWriter
());
man
.
setLogWriter
(
old
);
Connection
conn1
=
man
.
getConnection
();
assertTrue
(
conn1
.
getAutoCommit
());
conn1
.
setAutoCommit
(
false
);
...
...
h2/src/test/org/h2/test/jdbcx/TestDataSource.java
浏览文件 @
15948d7f
...
...
@@ -9,14 +9,16 @@ package org.h2.test.jdbcx;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
javax.naming.Reference
;
import
javax.naming.StringRefAddr
;
import
javax.naming.spi.ObjectFactory
;
import
javax.sql.ConnectionEvent
;
import
javax.sql.ConnectionEventListener
;
import
javax.sql.XAConnection
;
import
javax.transaction.xa.XAResource
;
import
javax.transaction.xa.Xid
;
import
org.h2.jdbcx.JdbcDataSource
;
import
org.h2.jdbcx.JdbcDataSourceFactory
;
import
org.h2.test.TestBase
;
/**
...
...
@@ -24,6 +26,15 @@ import org.h2.test.TestBase;
*/
public
class
TestDataSource
extends
TestBase
{
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
// public static void main(String... args) throws SQLException {
//
// // first, need to start on the command line:
...
...
@@ -49,11 +60,37 @@ public class TestDataSource extends TestBase {
// }
public
void
test
()
throws
Exception
{
testDataSourceFactory
();
testDataSource
();
testXAConnection
();
deleteDb
(
"dataSource"
);
}
private
void
testDataSourceFactory
()
throws
Exception
{
ObjectFactory
factory
=
new
JdbcDataSourceFactory
();
assertTrue
(
null
==
factory
.
getObjectInstance
(
"test"
,
null
,
null
,
null
));
Reference
ref
=
new
Reference
(
"java.lang.String"
);
assertTrue
(
null
==
factory
.
getObjectInstance
(
ref
,
null
,
null
,
null
));
ref
=
new
Reference
(
JdbcDataSource
.
class
.
getName
());
ref
.
add
(
new
StringRefAddr
(
"url"
,
"jdbc:h2:mem:"
));
ref
.
add
(
new
StringRefAddr
(
"user"
,
"u"
));
ref
.
add
(
new
StringRefAddr
(
"password"
,
"p"
));
ref
.
add
(
new
StringRefAddr
(
"loginTimeout"
,
"1"
));
JdbcDataSource
ds
=
(
JdbcDataSource
)
factory
.
getObjectInstance
(
ref
,
null
,
null
,
null
);
assertEquals
(
1
,
ds
.
getLoginTimeout
());
assertEquals
(
"jdbc:h2:mem:"
,
ds
.
getURL
());
assertEquals
(
"u"
,
ds
.
getUser
());
assertEquals
(
"p"
,
ds
.
getPassword
());
Reference
ref2
=
ds
.
getReference
();
assertEquals
(
ref
.
size
(),
ref2
.
size
());
assertEquals
(
ref
.
get
(
"url"
).
getContent
().
toString
(),
ref2
.
get
(
"url"
).
getContent
().
toString
());
assertEquals
(
ref
.
get
(
"user"
).
getContent
().
toString
(),
ref2
.
get
(
"user"
).
getContent
().
toString
());
assertEquals
(
ref
.
get
(
"password"
).
getContent
().
toString
(),
ref2
.
get
(
"password"
).
getContent
().
toString
());
assertEquals
(
ref
.
get
(
"loginTimeout"
).
getContent
().
toString
(),
ref2
.
get
(
"loginTimeout"
).
getContent
().
toString
());
ds
.
setPasswordChars
(
"abc"
.
toCharArray
());
assertEquals
(
"abc"
,
ds
.
getPassword
());
}
private
void
testXAConnection
()
throws
Exception
{
deleteDb
(
"dataSource"
);
JdbcDataSource
ds
=
new
JdbcDataSource
();
...
...
h2/src/test/org/h2/test/unit/TestDataPage.java
浏览文件 @
15948d7f
...
...
@@ -10,7 +10,6 @@ import java.math.BigDecimal;
import
java.sql.Date
;
import
java.sql.Time
;
import
java.sql.Timestamp
;
import
org.h2.message.DbException
;
import
org.h2.store.Data
;
import
org.h2.store.DataHandler
;
import
org.h2.store.FileStore
;
...
...
@@ -285,10 +284,6 @@ public class TestDataPage extends TestBase implements DataHandler {
// nothing to do
}
public
int
compareTypeSave
(
Value
a
,
Value
b
)
{
throw
DbException
.
throwInternalError
();
}
public
int
getMaxLengthInplaceLob
()
{
throw
new
AssertionError
();
}
...
...
h2/src/test/org/h2/test/unit/TestFile.java
浏览文件 @
15948d7f
...
...
@@ -13,7 +13,6 @@ import org.h2.test.TestBase;
import
org.h2.util.IOUtils
;
import
org.h2.util.SmallLRUCache
;
import
org.h2.util.TempFileDeleter
;
import
org.h2.value.Value
;
/**
* Tests the in-memory file system.
...
...
@@ -138,10 +137,6 @@ public class TestFile extends TestBase implements DataHandler {
// nothing to do
}
public
int
compareTypeSave
(
Value
a
,
Value
b
)
{
return
0
;
}
public
void
freeUpDiskSpace
()
{
// nothing to do
}
...
...
h2/src/test/org/h2/test/unit/TestValueHashMap.java
浏览文件 @
15948d7f
...
...
@@ -45,7 +45,7 @@ public class TestValueHashMap extends TestBase implements DataHandler {
}
private
void
testNotANumber
()
{
ValueHashMap
<
Integer
>
map
=
ValueHashMap
.
newInstance
(
this
);
ValueHashMap
<
Integer
>
map
=
ValueHashMap
.
newInstance
();
for
(
int
i
=
1
;
i
<
100
;
i
++)
{
double
d
=
Double
.
longBitsToDouble
(
0x7ff0000000000000
L
|
i
);
ValueDouble
v
=
ValueDouble
.
get
(
d
);
...
...
@@ -55,7 +55,7 @@ public class TestValueHashMap extends TestBase implements DataHandler {
}
private
void
testRandomized
()
{
ValueHashMap
<
Value
>
map
=
ValueHashMap
.
newInstance
(
this
);
ValueHashMap
<
Value
>
map
=
ValueHashMap
.
newInstance
();
HashMap
<
Value
,
Value
>
hash
=
New
.
hashMap
();
Random
random
=
new
Random
(
1
);
Comparator
<
Value
>
vc
=
new
Comparator
<
Value
>()
{
...
...
@@ -127,10 +127,6 @@ public class TestValueHashMap extends TestBase implements DataHandler {
// nothing to do
}
public
int
compareTypeSave
(
Value
a
,
Value
b
)
{
return
a
.
compareTo
(
b
,
compareMode
);
}
public
int
getMaxLengthInplaceLob
()
{
return
0
;
}
...
...
h2/src/test/org/h2/test/unit/TestValueMemory.java
浏览文件 @
15948d7f
...
...
@@ -194,10 +194,6 @@ public class TestValueMemory extends TestBase implements DataHandler {
// nothing to do
}
public
int
compareTypeSave
(
Value
a
,
Value
b
)
{
return
0
;
}
public
void
freeUpDiskSpace
()
{
// nothing to do
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论