Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
00083108
提交
00083108
authored
2月 05, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace ObjectArray with ArrayList.
上级
8094d423
隐藏空白字符变更
内嵌
并排
正在显示
34 个修改的文件
包含
178 行增加
和
595 行删除
+178
-595
AlterTableAddConstraint.java
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
+2
-3
AlterTableAlterColumn.java
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
+5
-5
CreateTable.java
h2/src/main/org/h2/command/ddl/CreateTable.java
+3
-3
CreateTableData.java
h2/src/main/org/h2/command/ddl/CreateTableData.java
+3
-2
DropDatabase.java
h2/src/main/org/h2/command/ddl/DropDatabase.java
+5
-4
DropIndex.java
h2/src/main/org/h2/command/ddl/DropIndex.java
+2
-2
ScriptCommand.java
h2/src/main/org/h2/command/dml/ScriptCommand.java
+8
-7
Select.java
h2/src/main/org/h2/command/dml/Select.java
+2
-3
Database.java
h2/src/main/org/h2/engine/Database.java
+24
-25
DbObject.java
h2/src/main/org/h2/engine/DbObject.java
+2
-2
DbObjectBase.java
h2/src/main/org/h2/engine/DbObjectBase.java
+2
-3
Session.java
h2/src/main/org/h2/engine/Session.java
+3
-4
UndoLog.java
h2/src/main/org/h2/engine/UndoLog.java
+4
-3
User.java
h2/src/main/org/h2/engine/User.java
+4
-4
Aggregate.java
h2/src/main/org/h2/expression/Aggregate.java
+3
-7
MultiVersionIndex.java
h2/src/main/org/h2/index/MultiVersionIndex.java
+2
-2
ResultDiskBuffer.java
h2/src/main/org/h2/result/ResultDiskBuffer.java
+5
-1
SortOrder.java
h2/src/main/org/h2/result/SortOrder.java
+28
-68
Schema.java
h2/src/main/org/h2/schema/Schema.java
+5
-5
PageStore.java
h2/src/main/org/h2/store/PageStore.java
+2
-3
FunctionTable.java
h2/src/main/org/h2/table/FunctionTable.java
+2
-3
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+7
-9
RangeTable.java
h2/src/main/org/h2/table/RangeTable.java
+2
-3
Table.java
h2/src/main/org/h2/table/Table.java
+18
-20
TableData.java
h2/src/main/org/h2/table/TableData.java
+7
-7
TableLink.java
h2/src/main/org/h2/table/TableLink.java
+6
-7
TableView.java
h2/src/main/org/h2/table/TableView.java
+1
-2
Cache.java
h2/src/main/org/h2/util/Cache.java
+2
-1
CacheLRU.java
h2/src/main/org/h2/util/CacheLRU.java
+5
-4
CacheObject.java
h2/src/main/org/h2/util/CacheObject.java
+4
-2
CacheSecondLevel.java
h2/src/main/org/h2/util/CacheSecondLevel.java
+2
-1
ObjectArray.java
h2/src/main/org/h2/util/ObjectArray.java
+0
-372
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+3
-3
CacheTQ.java
h2/src/tools/org/h2/dev/util/CacheTQ.java
+5
-5
没有找到文件。
h2/src/main/org/h2/command/ddl/AlterTableAddConstraint.java
浏览文件 @
00083108
...
...
@@ -7,8 +7,8 @@
package
org
.
h2
.
command
.
ddl
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constraint.Constraint
;
import
org.h2.constraint.ConstraintCheck
;
...
...
@@ -28,7 +28,6 @@ import org.h2.table.IndexColumn;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
/**
* This class represents the statement
...
...
@@ -114,7 +113,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
case
PRIMARY_KEY:
{
IndexColumn
.
mapColumns
(
indexColumns
,
table
);
index
=
table
.
findPrimaryKey
();
ObjectArray
<
Constraint
>
constraints
=
table
.
getConstraints
();
ArrayList
<
Constraint
>
constraints
=
table
.
getConstraints
();
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
Constraint
c
=
constraints
.
get
(
i
);
if
(
Constraint
.
PRIMARY_KEY
.
equals
(
c
.
getConstraintType
()))
{
...
...
h2/src/main/org/h2/command/ddl/AlterTableAlterColumn.java
浏览文件 @
00083108
...
...
@@ -31,7 +31,7 @@ import org.h2.table.Column;
import
org.h2.table.Table
;
import
org.h2.table.TableData
;
import
org.h2.table.TableView
;
import
org.h2.util.
ObjectArray
;
import
org.h2.util.
New
;
/**
* This class represents the statements
...
...
@@ -207,7 +207,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
Database
db
=
session
.
getDatabase
();
String
tempName
=
db
.
getTempTableName
(
session
);
Column
[]
columns
=
table
.
getColumns
();
ObjectArray
<
Column
>
newColumns
=
ObjectArray
.
newInstance
();
ArrayList
<
Column
>
newColumns
=
New
.
arrayList
();
TableData
newTable
=
cloneTableStructure
(
columns
,
db
,
tempName
,
newColumns
);
List
<
String
>
views
;
try
{
...
...
@@ -247,7 +247,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
}
}
private
TableData
cloneTableStructure
(
Column
[]
columns
,
Database
db
,
String
tempName
,
ObjectArray
<
Column
>
newColumns
)
throws
SQLException
{
private
TableData
cloneTableStructure
(
Column
[]
columns
,
Database
db
,
String
tempName
,
ArrayList
<
Column
>
newColumns
)
throws
SQLException
{
for
(
Column
col
:
columns
)
{
newColumns
.
add
(
col
.
getClone
());
}
...
...
@@ -314,7 +314,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
execute
(
newTableSQL
,
true
);
newTable
=
(
TableData
)
newTableSchema
.
getTableOrView
(
session
,
newTableName
);
ObjectArray
<
String
>
triggers
=
ObjectArray
.
newInstance
();
ArrayList
<
String
>
triggers
=
New
.
arrayList
();
for
(
DbObject
child
:
table
.
getChildren
())
{
if
(
child
instanceof
Sequence
)
{
continue
;
...
...
@@ -427,7 +427,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
private
void
dropSingleColumnIndexes
()
throws
SQLException
{
Database
db
=
session
.
getDatabase
();
ObjectArray
<
Index
>
indexes
=
table
.
getIndexes
();
ArrayList
<
Index
>
indexes
=
table
.
getIndexes
();
for
(
int
i
=
0
;
i
<
indexes
.
size
();
i
++)
{
Index
index
=
indexes
.
get
(
i
);
if
(
index
.
getCreateSQL
()
==
null
)
{
...
...
h2/src/main/org/h2/command/ddl/CreateTable.java
浏览文件 @
00083108
...
...
@@ -21,7 +21,7 @@ import org.h2.schema.Sequence;
import
org.h2.table.Column
;
import
org.h2.table.IndexColumn
;
import
org.h2.table.TableData
;
import
org.h2.util.
ObjectArray
;
import
org.h2.util.
New
;
import
org.h2.value.DataType
;
/**
...
...
@@ -31,7 +31,7 @@ import org.h2.value.DataType;
public
class
CreateTable
extends
SchemaCommand
{
private
CreateTableData
data
=
new
CreateTableData
();
private
ObjectArray
<
Prepared
>
constraintCommands
=
ObjectArray
.
newInstance
();
private
ArrayList
<
Prepared
>
constraintCommands
=
New
.
arrayList
();
private
IndexColumn
[]
pkColumns
;
private
boolean
ifNotExists
;
private
boolean
globalTemporary
;
...
...
@@ -124,7 +124,7 @@ public class CreateTable extends SchemaCommand {
}
}
}
ObjectArray
<
Sequence
>
sequences
=
ObjectArray
.
newInstance
();
ArrayList
<
Sequence
>
sequences
=
New
.
arrayList
();
for
(
Column
c
:
data
.
columns
)
{
if
(
c
.
isAutoIncrement
())
{
int
objId
=
getObjectId
();
...
...
h2/src/main/org/h2/command/ddl/CreateTableData.java
浏览文件 @
00083108
...
...
@@ -6,10 +6,11 @@
*/
package
org
.
h2
.
command
.
ddl
;
import
java.util.ArrayList
;
import
org.h2.engine.Session
;
import
org.h2.schema.Schema
;
import
org.h2.table.Column
;
import
org.h2.util.
ObjectArray
;
import
org.h2.util.
New
;
/**
* The data required to create a table.
...
...
@@ -34,7 +35,7 @@ public class CreateTableData {
/**
* The column list.
*/
public
ObjectArray
<
Column
>
columns
=
ObjectArray
.
newInstance
();
public
ArrayList
<
Column
>
columns
=
New
.
arrayList
();
/**
* Whether this is a temporary table.
...
...
h2/src/main/org/h2/command/ddl/DropDatabase.java
浏览文件 @
00083108
...
...
@@ -7,6 +7,7 @@
package
org
.
h2
.
command
.
ddl
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
org.h2.engine.Database
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.Role
;
...
...
@@ -15,7 +16,7 @@ import org.h2.engine.User;
import
org.h2.schema.Schema
;
import
org.h2.schema.SchemaObject
;
import
org.h2.table.Table
;
import
org.h2.util.
ObjectArray
;
import
org.h2.util.
New
;
/**
* This class represents the statement
...
...
@@ -50,7 +51,7 @@ public class DropDatabase extends DefineCommand {
db
.
removeDatabaseObject
(
session
,
schema
);
}
}
ObjectArray
<
Table
>
tables
=
db
.
getAllTablesAndViews
(
false
);
ArrayList
<
Table
>
tables
=
db
.
getAllTablesAndViews
(
false
);
for
(
Table
t
:
tables
)
{
if
(
t
.
getName
()
!=
null
&&
Table
.
VIEW
.
equals
(
t
.
getTableType
()))
{
db
.
removeSchemaObject
(
session
,
t
);
...
...
@@ -67,7 +68,7 @@ public class DropDatabase extends DefineCommand {
}
}
session
.
findLocalTempTable
(
null
);
ObjectArray
<
SchemaObject
>
list
=
ObjectArray
.
newInstance
();
ArrayList
<
SchemaObject
>
list
=
New
.
arrayList
();
list
.
addAll
(
db
.
getAllSchemaObjects
(
DbObject
.
SEQUENCE
));
// maybe constraints and triggers on system tables will be allowed in
// the future
...
...
@@ -89,7 +90,7 @@ public class DropDatabase extends DefineCommand {
db
.
removeDatabaseObject
(
session
,
role
);
}
}
ObjectArray
<
DbObject
>
dbObjects
=
ObjectArray
.
newInstance
();
ArrayList
<
DbObject
>
dbObjects
=
New
.
arrayList
();
dbObjects
.
addAll
(
db
.
getAllRights
());
dbObjects
.
addAll
(
db
.
getAllFunctionAliases
());
dbObjects
.
addAll
(
db
.
getAllAggregates
());
...
...
h2/src/main/org/h2/command/ddl/DropIndex.java
浏览文件 @
00083108
...
...
@@ -7,6 +7,7 @@
package
org
.
h2
.
command
.
ddl
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constraint.Constraint
;
import
org.h2.engine.Database
;
...
...
@@ -16,7 +17,6 @@ import org.h2.index.Index;
import
org.h2.message.Message
;
import
org.h2.schema.Schema
;
import
org.h2.table.Table
;
import
org.h2.util.ObjectArray
;
/**
* This class represents the statement
...
...
@@ -51,7 +51,7 @@ public class DropIndex extends SchemaCommand {
Table
table
=
index
.
getTable
();
session
.
getUser
().
checkRight
(
index
.
getTable
(),
Right
.
ALL
);
Constraint
pkConstraint
=
null
;
ObjectArray
<
Constraint
>
constraints
=
table
.
getConstraints
();
ArrayList
<
Constraint
>
constraints
=
table
.
getConstraints
();
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
Constraint
cons
=
constraints
.
get
(
i
);
if
(
cons
.
usesIndex
(
index
))
{
...
...
h2/src/main/org/h2/command/dml/ScriptCommand.java
浏览文件 @
00083108
...
...
@@ -14,6 +14,8 @@ import java.sql.Connection;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
org.h2.command.Parser
;
import
org.h2.constant.SysProperties
;
...
...
@@ -49,7 +51,6 @@ import org.h2.table.Table;
import
org.h2.util.ByteUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.value.Value
;
...
...
@@ -171,10 +172,10 @@ public class ScriptCommand extends ScriptBase {
}
add
(
agg
.
getCreateSQL
(),
false
);
}
ObjectArray
<
Table
>
tables
=
db
.
getAllTablesAndViews
(
false
);
ArrayList
<
Table
>
tables
=
db
.
getAllTablesAndViews
(
false
);
// sort by id, so that views are after tables and views on views
// after the base views
tables
.
sort
(
new
Comparator
<
Table
>()
{
Collections
.
sort
(
tables
,
new
Comparator
<
Table
>()
{
public
int
compare
(
Table
t1
,
Table
t2
)
{
return
t1
.
getId
()
-
t2
.
getId
();
}
...
...
@@ -206,7 +207,7 @@ public class ScriptCommand extends ScriptBase {
}
String
tableType
=
table
.
getTableType
();
add
(
sql
,
false
);
ObjectArray
<
Constraint
>
constraints
=
table
.
getConstraints
();
ArrayList
<
Constraint
>
constraints
=
table
.
getConstraints
();
if
(
constraints
!=
null
)
{
for
(
Constraint
constraint
:
constraints
)
{
if
(
Constraint
.
PRIMARY_KEY
.
equals
(
constraint
.
getConstraintType
()))
{
...
...
@@ -276,7 +277,7 @@ public class ScriptCommand extends ScriptBase {
}
}
}
ObjectArray
<
Index
>
indexes
=
table
.
getIndexes
();
ArrayList
<
Index
>
indexes
=
table
.
getIndexes
();
for
(
int
j
=
0
;
indexes
!=
null
&&
j
<
indexes
.
size
();
j
++)
{
Index
index
=
indexes
.
get
(
j
);
if
(!
index
.
getIndexType
().
getBelongsToConstraint
())
{
...
...
@@ -291,8 +292,8 @@ public class ScriptCommand extends ScriptBase {
add
(
"DROP ALIAS IF EXISTS SYSTEM_COMBINE_BLOB"
,
true
);
tempLobTableCreated
=
false
;
}
ObjectArray
<
SchemaObject
>
constraints
=
db
.
getAllSchemaObjects
(
DbObject
.
CONSTRAINT
);
constraints
.
sort
(
new
Comparator
<
SchemaObject
>()
{
ArrayList
<
SchemaObject
>
constraints
=
db
.
getAllSchemaObjects
(
DbObject
.
CONSTRAINT
);
Collections
.
sort
(
constraints
,
new
Comparator
<
SchemaObject
>()
{
public
int
compare
(
SchemaObject
c1
,
SchemaObject
c2
)
{
return
((
Constraint
)
c1
).
compareTo
((
Constraint
)
c2
);
}
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
00083108
...
...
@@ -39,7 +39,6 @@ import org.h2.table.IndexColumn;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.util.ValueHashMap
;
...
...
@@ -237,7 +236,7 @@ public class Select extends Query {
if
(
groupIndex
==
null
||
groupByExpression
==
null
)
{
return
null
;
}
ObjectArray
<
Index
>
indexes
=
topTableFilter
.
getTable
().
getIndexes
();
ArrayList
<
Index
>
indexes
=
topTableFilter
.
getTable
().
getIndexes
();
for
(
int
i
=
0
;
indexes
!=
null
&&
i
<
indexes
.
size
();
i
++)
{
Index
index
=
indexes
.
get
(
i
);
if
(
index
.
getIndexType
().
isScan
())
{
...
...
@@ -406,7 +405,7 @@ public class Select extends Query {
// sort just on constants - can use scan index
return
topTableFilter
.
getTable
().
getScanIndex
(
session
);
}
ObjectArray
<
Index
>
list
=
topTableFilter
.
getTable
().
getIndexes
();
ArrayList
<
Index
>
list
=
topTableFilter
.
getTable
().
getIndexes
();
for
(
int
i
=
0
;
list
!=
null
&&
i
<
list
.
size
();
i
++)
{
Index
index
=
list
.
get
(
i
);
if
(
index
.
getCreateSQL
()
==
null
)
{
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
00083108
...
...
@@ -55,7 +55,6 @@ import org.h2.util.ClassUtils;
import
org.h2.util.FileUtils
;
import
org.h2.util.NetUtils
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.SmallLRUCache
;
import
org.h2.util.SourceCompiler
;
import
org.h2.util.StringUtils
;
...
...
@@ -554,7 +553,7 @@ public class Database implements DataHandler {
systemUser
.
setAdmin
(
true
);
systemSession
=
new
Session
(
this
,
systemUser
,
++
nextSessionId
);
CreateTableData
data
=
new
CreateTableData
();
ObjectArray
<
Column
>
cols
=
data
.
columns
;
ArrayList
<
Column
>
cols
=
data
.
columns
;
Column
columnId
=
new
Column
(
"ID"
,
Value
.
INT
);
columnId
.
setNullable
(
false
);
cols
.
add
(
columnId
);
...
...
@@ -1183,16 +1182,16 @@ public class Database implements DataHandler {
return
i
;
}
public
ObjectArray
<
UserAggregate
>
getAllAggregates
()
{
return
ObjectArray
.
newInstance
(
aggregates
.
values
());
public
ArrayList
<
UserAggregate
>
getAllAggregates
()
{
return
New
.
arrayList
(
aggregates
.
values
());
}
public
ObjectArray
<
Comment
>
getAllComments
()
{
return
ObjectArray
.
newInstance
(
comments
.
values
());
public
ArrayList
<
Comment
>
getAllComments
()
{
return
New
.
arrayList
(
comments
.
values
());
}
public
ObjectArray
<
FunctionAlias
>
getAllFunctionAliases
()
{
return
ObjectArray
.
newInstance
(
functionAliases
.
values
());
public
ArrayList
<
FunctionAlias
>
getAllFunctionAliases
()
{
return
New
.
arrayList
(
functionAliases
.
values
());
}
public
int
getAllowLiterals
()
{
...
...
@@ -1202,12 +1201,12 @@ public class Database implements DataHandler {
return
allowLiterals
;
}
public
ObjectArray
<
Right
>
getAllRights
()
{
return
ObjectArray
.
newInstance
(
rights
.
values
());
public
ArrayList
<
Right
>
getAllRights
()
{
return
New
.
arrayList
(
rights
.
values
());
}
public
ObjectArray
<
Role
>
getAllRoles
()
{
return
ObjectArray
.
newInstance
(
roles
.
values
());
public
ArrayList
<
Role
>
getAllRoles
()
{
return
New
.
arrayList
(
roles
.
values
());
}
/**
...
...
@@ -1216,11 +1215,11 @@ public class Database implements DataHandler {
* @param type the object type
* @return all objects of that type
*/
public
ObjectArray
<
SchemaObject
>
getAllSchemaObjects
(
int
type
)
{
public
ArrayList
<
SchemaObject
>
getAllSchemaObjects
(
int
type
)
{
if
(
type
==
DbObject
.
TABLE_OR_VIEW
)
{
initMetaTables
();
}
ObjectArray
<
SchemaObject
>
list
=
ObjectArray
.
newInstance
();
ArrayList
<
SchemaObject
>
list
=
New
.
arrayList
();
for
(
Schema
schema
:
schemas
.
values
())
{
list
.
addAll
(
schema
.
getAll
(
type
));
}
...
...
@@ -1233,32 +1232,32 @@ public class Database implements DataHandler {
* @param includeMeta whether to include the meta data tables
* @return all objects of that type
*/
public
ObjectArray
<
Table
>
getAllTablesAndViews
(
boolean
includeMeta
)
{
public
ArrayList
<
Table
>
getAllTablesAndViews
(
boolean
includeMeta
)
{
if
(
includeMeta
)
{
initMetaTables
();
}
ObjectArray
<
Table
>
list
=
ObjectArray
.
newInstance
();
ArrayList
<
Table
>
list
=
New
.
arrayList
();
for
(
Schema
schema
:
schemas
.
values
())
{
list
.
addAll
(
schema
.
getAllTablesAndViews
());
}
return
list
;
}
public
ObjectArray
<
Schema
>
getAllSchemas
()
{
public
ArrayList
<
Schema
>
getAllSchemas
()
{
initMetaTables
();
return
ObjectArray
.
newInstance
(
schemas
.
values
());
return
New
.
arrayList
(
schemas
.
values
());
}
public
ObjectArray
<
Setting
>
getAllSettings
()
{
return
ObjectArray
.
newInstance
(
settings
.
values
());
public
ArrayList
<
Setting
>
getAllSettings
()
{
return
New
.
arrayList
(
settings
.
values
());
}
public
ObjectArray
<
UserDataType
>
getAllUserDataTypes
()
{
return
ObjectArray
.
newInstance
(
userDataTypes
.
values
());
public
ArrayList
<
UserDataType
>
getAllUserDataTypes
()
{
return
New
.
arrayList
(
userDataTypes
.
values
());
}
public
ObjectArray
<
User
>
getAllUsers
()
{
return
ObjectArray
.
newInstance
(
users
.
values
());
public
ArrayList
<
User
>
getAllUsers
()
{
return
New
.
arrayList
(
users
.
values
());
}
public
String
getCacheType
()
{
...
...
@@ -1346,7 +1345,7 @@ public class Database implements DataHandler {
}
private
synchronized
void
updateWithChildren
(
Session
session
,
DbObject
obj
)
throws
SQLException
{
ObjectArray
<
DbObject
>
list
=
obj
.
getChildren
();
ArrayList
<
DbObject
>
list
=
obj
.
getChildren
();
Comment
comment
=
findComment
(
obj
);
if
(
comment
!=
null
)
{
Message
.
throwInternalError
();
...
...
h2/src/main/org/h2/engine/DbObject.java
浏览文件 @
00083108
...
...
@@ -7,8 +7,8 @@
package
org
.
h2
.
engine
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
org.h2.table.Table
;
import
org.h2.util.ObjectArray
;
/**
* A database object such as a table, an index, or a user.
...
...
@@ -116,7 +116,7 @@ public interface DbObject {
*
* @return the list of children
*/
ObjectArray
<
DbObject
>
getChildren
();
ArrayList
<
DbObject
>
getChildren
();
/**
* Get the database.
...
...
h2/src/main/org/h2/engine/DbObjectBase.java
浏览文件 @
00083108
...
...
@@ -7,12 +7,11 @@
package
org
.
h2
.
engine
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
org.h2.command.Parser
;
import
org.h2.message.Message
;
import
org.h2.message.Trace
;
import
org.h2.table.Table
;
import
org.h2.util.ObjectArray
;
/**
* The base class for all database objects.
...
...
@@ -117,7 +116,7 @@ public abstract class DbObjectBase implements DbObject {
return
Parser
.
quoteIdentifier
(
objectName
);
}
public
ObjectArray
<
DbObject
>
getChildren
()
{
public
ArrayList
<
DbObject
>
getChildren
()
{
return
null
;
}
...
...
h2/src/main/org/h2/engine/Session.java
浏览文件 @
00083108
...
...
@@ -31,7 +31,6 @@ import org.h2.store.DataHandler;
import
org.h2.store.InDoubtTransaction
;
import
org.h2.table.Table
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
import
org.h2.value.Value
;
import
org.h2.value.ValueLob
;
import
org.h2.value.ValueLong
;
...
...
@@ -201,11 +200,11 @@ public class Session extends SessionWithState implements SessionFactory {
return
localTempTables
.
get
(
name
);
}
public
ObjectArray
<
Table
>
getLocalTempTables
()
{
public
ArrayList
<
Table
>
getLocalTempTables
()
{
if
(
localTempTables
==
null
)
{
return
ObjectArray
.
newInstance
();
return
New
.
arrayList
();
}
return
ObjectArray
.
newInstance
(
localTempTables
.
values
());
return
New
.
arrayList
(
localTempTables
.
values
());
}
/**
...
...
h2/src/main/org/h2/engine/UndoLog.java
浏览文件 @
00083108
...
...
@@ -7,11 +7,12 @@
package
org
.
h2
.
engine
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
org.h2.constant.SysProperties
;
import
org.h2.message.Message
;
import
org.h2.store.Data
;
import
org.h2.store.FileStore
;
import
org.h2.util.
ObjectArray
;
import
org.h2.util.
New
;
/**
* Each session keeps a undo log if rollback is required.
...
...
@@ -20,7 +21,7 @@ public class UndoLog {
private
Database
database
;
// TODO undo log entry: a chain would probably be faster
// and use less memory than an array
private
ObjectArray
<
UndoLogRecord
>
records
=
ObjectArray
.
newInstance
();
private
ArrayList
<
UndoLogRecord
>
records
=
New
.
arrayList
();
private
FileStore
file
;
private
Data
rowBuff
;
private
int
memoryUndo
;
...
...
@@ -97,7 +98,7 @@ public class UndoLog {
*/
public
void
removeLast
(
boolean
trimToSize
)
{
int
i
=
records
.
size
()
-
1
;
UndoLogRecord
r
=
(
UndoLogRecord
)
records
.
remove
(
i
);
UndoLogRecord
r
=
records
.
remove
(
i
);
if
(!
r
.
isStored
())
{
memoryUndo
--;
}
...
...
h2/src/main/org/h2/engine/User.java
浏览文件 @
00083108
...
...
@@ -7,7 +7,7 @@
package
org
.
h2
.
engine
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
org.h2.constant.ErrorCode
;
import
org.h2.message.Message
;
import
org.h2.message.Trace
;
...
...
@@ -19,7 +19,7 @@ import org.h2.table.Table;
import
org.h2.table.TableView
;
import
org.h2.util.ByteUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.
ObjectArray
;
import
org.h2.util.
New
;
import
org.h2.util.StringUtils
;
/**
...
...
@@ -186,8 +186,8 @@ public class User extends RightOwner {
return
DbObject
.
USER
;
}
public
ObjectArray
<
DbObject
>
getChildren
()
{
ObjectArray
<
DbObject
>
children
=
ObjectArray
.
newInstance
();
public
ArrayList
<
DbObject
>
getChildren
()
{
ArrayList
<
DbObject
>
children
=
New
.
arrayList
();
for
(
Right
right
:
database
.
getAllRights
())
{
if
(
right
.
getGrantee
()
==
this
)
{
children
.
add
(
right
);
...
...
h2/src/main/org/h2/expression/Aggregate.java
浏览文件 @
00083108
...
...
@@ -300,13 +300,9 @@ public class Aggregate extends Expression {
final
SortOrder
sortOrder
=
sort
;
Collections
.
sort
(
list
,
new
Comparator
<
Value
>()
{
public
int
compare
(
Value
v1
,
Value
v2
)
{
try
{
Value
[]
a1
=
((
ValueArray
)
v1
).
getList
();
Value
[]
a2
=
((
ValueArray
)
v2
).
getList
();
return
sortOrder
.
compare
(
a1
,
a2
);
}
catch
(
SQLException
e
)
{
throw
Message
.
convertToInternal
(
e
);
}
Value
[]
a1
=
((
ValueArray
)
v1
).
getList
();
Value
[]
a2
=
((
ValueArray
)
v2
).
getList
();
return
sortOrder
.
compare
(
a1
,
a2
);
}
});
}
catch
(
Exception
e
)
{
...
...
h2/src/main/org/h2/index/MultiVersionIndex.java
浏览文件 @
00083108
...
...
@@ -7,6 +7,7 @@
package
org
.
h2
.
index
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
org.h2.engine.Database
;
import
org.h2.engine.DbObject
;
import
org.h2.engine.Session
;
...
...
@@ -18,7 +19,6 @@ import org.h2.table.Column;
import
org.h2.table.IndexColumn
;
import
org.h2.table.Table
;
import
org.h2.table.TableData
;
import
org.h2.util.ObjectArray
;
import
org.h2.value.Value
;
import
org.h2.value.ValueNull
;
...
...
@@ -265,7 +265,7 @@ public class MultiVersionIndex implements Index {
base
.
checkRename
();
}
public
ObjectArray
<
DbObject
>
getChildren
()
{
public
ArrayList
<
DbObject
>
getChildren
()
{
return
base
.
getChildren
();
}
...
...
h2/src/main/org/h2/result/ResultDiskBuffer.java
浏览文件 @
00083108
...
...
@@ -202,7 +202,11 @@ class ResultDiskBuffer implements ResultExternal {
private
int
compareTapes
(
ResultDiskTape
a
,
ResultDiskTape
b
)
throws
SQLException
{
Value
[]
va
=
a
.
buffer
.
get
(
0
);
Value
[]
vb
=
b
.
buffer
.
get
(
0
);
return
sort
.
compare
(
va
,
vb
);
try
{
return
sort
.
compare
(
va
,
vb
);
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
}
protected
void
finalize
()
{
...
...
h2/src/main/org/h2/result/SortOrder.java
浏览文件 @
00083108
...
...
@@ -8,10 +8,12 @@ package org.h2.result;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Database
;
import
org.h2.expression.Expression
;
import
org.h2.
util.MathUtils
;
import
org.h2.
message.Message
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.value.Value
;
...
...
@@ -20,7 +22,7 @@ import org.h2.value.ValueNull;
/**
* A sort order represents an ORDER BY clause in a query.
*/
public
class
SortOrder
{
public
class
SortOrder
implements
Comparator
<
Value
[]>
{
/**
* This bit mask means the values should be sorted in ascending order.
...
...
@@ -127,25 +129,29 @@ public class SortOrder {
* @param b the second expression list
* @return the result of the comparison
*/
public
int
compare
(
Value
[]
a
,
Value
[]
b
)
throws
SQLException
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
idx
=
indexes
[
i
];
int
type
=
sortTypes
[
i
];
Value
ao
=
a
[
idx
];
Value
bo
=
b
[
idx
];
boolean
aNull
=
ao
==
ValueNull
.
INSTANCE
,
bNull
=
bo
==
ValueNull
.
INSTANCE
;
if
(
aNull
||
bNull
)
{
if
(
aNull
==
bNull
)
{
continue
;
public
int
compare
(
Value
[]
a
,
Value
[]
b
)
{
try
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
idx
=
indexes
[
i
];
int
type
=
sortTypes
[
i
];
Value
ao
=
a
[
idx
];
Value
bo
=
b
[
idx
];
boolean
aNull
=
ao
==
ValueNull
.
INSTANCE
,
bNull
=
bo
==
ValueNull
.
INSTANCE
;
if
(
aNull
||
bNull
)
{
if
(
aNull
==
bNull
)
{
continue
;
}
return
compareNull
(
aNull
,
bNull
,
type
);
}
int
comp
=
database
.
compare
(
ao
,
bo
);
if
(
comp
!=
0
)
{
return
(
type
&
DESCENDING
)
==
0
?
comp
:
-
comp
;
}
return
compareNull
(
aNull
,
bNull
,
type
);
}
int
comp
=
database
.
compare
(
ao
,
bo
);
if
(
comp
!=
0
)
{
return
(
type
&
DESCENDING
)
==
0
?
comp
:
-
comp
;
}
return
0
;
}
catch
(
SQLException
e
)
{
throw
Message
.
convertToInternal
(
e
);
}
return
0
;
}
/**
...
...
@@ -154,56 +160,10 @@ public class SortOrder {
* @param rows the list of rows
*/
public
void
sort
(
ArrayList
<
Value
[]>
rows
)
throws
SQLException
{
int
todoUseArraySort
;
sort
(
rows
,
0
,
rows
.
size
()
-
1
);
}
private
void
swap
(
ArrayList
<
Value
[]>
rows
,
int
a
,
int
b
)
{
Value
[]
t
=
rows
.
get
(
a
);
rows
.
set
(
a
,
rows
.
get
(
b
));
rows
.
set
(
b
,
t
);
}
private
void
sort
(
ArrayList
<
Value
[]>
rows
,
int
l
,
int
r
)
throws
SQLException
{
// quicksort
int
i
,
j
;
while
(
r
-
l
>
10
)
{
// randomized pivot to avoid worst case
i
=
MathUtils
.
randomInt
(
r
-
l
-
4
)
+
l
+
2
;
if
(
compare
(
rows
.
get
(
l
),
rows
.
get
(
r
))
>
0
)
{
swap
(
rows
,
l
,
r
);
}
if
(
compare
(
rows
.
get
(
i
),
rows
.
get
(
l
))
<
0
)
{
swap
(
rows
,
l
,
i
);
}
else
if
(
compare
(
rows
.
get
(
i
),
rows
.
get
(
r
))
>
0
)
{
swap
(
rows
,
i
,
r
);
}
j
=
r
-
1
;
swap
(
rows
,
i
,
j
);
Value
[]
p
=
rows
.
get
(
j
);
i
=
l
;
while
(
true
)
{
do
{
++
i
;
}
while
(
compare
(
rows
.
get
(
i
),
p
)
<
0
);
do
{
--
j
;
}
while
(
compare
(
rows
.
get
(
j
),
p
)
>
0
);
if
(
i
>=
j
)
{
break
;
}
swap
(
rows
,
i
,
j
);
}
swap
(
rows
,
i
,
r
-
1
);
sort
(
rows
,
l
,
i
-
1
);
l
=
i
+
1
;
}
for
(
i
=
l
+
1
;
i
<=
r
;
i
++)
{
Value
[]
t
=
rows
.
get
(
i
);
for
(
j
=
i
-
1
;
j
>=
l
&&
(
compare
(
rows
.
get
(
j
),
t
)
>
0
);
j
--)
{
rows
.
set
(
j
+
1
,
rows
.
get
(
j
));
}
rows
.
set
(
j
+
1
,
t
);
try
{
Collections
.
sort
(
rows
,
this
);
}
catch
(
Exception
e
)
{
throw
Message
.
convert
(
e
);
}
}
...
...
h2/src/main/org/h2/schema/Schema.java
浏览文件 @
00083108
...
...
@@ -7,6 +7,7 @@
package
org
.
h2
.
schema
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
org.h2.command.ddl.CreateTableData
;
...
...
@@ -25,7 +26,6 @@ import org.h2.table.Table;
import
org.h2.table.TableData
;
import
org.h2.table.TableLink
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
/**
* A schema as created by the SQL statement
...
...
@@ -450,9 +450,9 @@ public class Schema extends DbObjectBase {
* @param type the object type
* @return a (possible empty) list of all objects
*/
public
ObjectArray
<
SchemaObject
>
getAll
(
int
type
)
{
public
ArrayList
<
SchemaObject
>
getAll
(
int
type
)
{
HashMap
<
String
,
SchemaObject
>
map
=
getMap
(
type
);
return
ObjectArray
.
newInstance
(
map
.
values
());
return
New
.
arrayList
(
map
.
values
());
}
/**
...
...
@@ -460,8 +460,8 @@ public class Schema extends DbObjectBase {
*
* @return a (possible empty) list of all objects
*/
public
ObjectArray
<
Table
>
getAllTablesAndViews
()
{
return
ObjectArray
.
newInstance
(
tablesAndViews
.
values
());
public
ArrayList
<
Table
>
getAllTablesAndViews
()
{
return
New
.
arrayList
(
tablesAndViews
.
values
());
}
/**
...
...
h2/src/main/org/h2/store/PageStore.java
浏览文件 @
00083108
...
...
@@ -49,7 +49,6 @@ import org.h2.util.FileUtils;
import
org.h2.util.IntArray
;
import
org.h2.util.IntIntHashMap
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.value.CompareMode
;
...
...
@@ -320,7 +319,7 @@ public class PageStore implements CacheWriter {
}
private
void
writeBack
()
throws
SQLException
{
ObjectArray
<
CacheObject
>
list
=
cache
.
getAllChanged
();
ArrayList
<
CacheObject
>
list
=
cache
.
getAllChanged
();
CacheObject
.
sort
(
list
);
for
(
CacheObject
rec
:
list
)
{
writeBack
(
rec
);
...
...
@@ -1199,7 +1198,7 @@ public class PageStore implements CacheWriter {
private
void
openMetaIndex
()
throws
SQLException
{
CreateTableData
data
=
new
CreateTableData
();
ObjectArray
<
Column
>
cols
=
data
.
columns
;
ArrayList
<
Column
>
cols
=
data
.
columns
;
cols
.
add
(
new
Column
(
"ID"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"TYPE"
,
Value
.
INT
));
cols
.
add
(
new
Column
(
"PARENT"
,
Value
.
INT
));
...
...
h2/src/main/org/h2/table/FunctionTable.java
浏览文件 @
00083108
...
...
@@ -9,7 +9,7 @@ package org.h2.table;
import
java.sql.ResultSet
;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
org.h2.constant.ErrorCode
;
import
org.h2.engine.Session
;
import
org.h2.expression.Expression
;
...
...
@@ -22,7 +22,6 @@ import org.h2.message.Message;
import
org.h2.result.LocalResult
;
import
org.h2.result.Row
;
import
org.h2.schema.Schema
;
import
org.h2.util.ObjectArray
;
import
org.h2.value.DataType
;
import
org.h2.value.Value
;
import
org.h2.value.ValueNull
;
...
...
@@ -124,7 +123,7 @@ public class FunctionTable extends Table {
return
new
FunctionIndex
(
this
,
IndexColumn
.
wrap
(
columns
));
}
public
ObjectArray
<
Index
>
getIndexes
()
{
public
ArrayList
<
Index
>
getIndexes
()
{
return
null
;
}
...
...
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
00083108
...
...
@@ -17,7 +17,6 @@ import java.sql.Timestamp;
import
java.text.Collator
;
import
java.util.ArrayList
;
import
java.util.Locale
;
import
org.h2.command.Command
;
import
org.h2.constant.SysProperties
;
import
org.h2.constraint.Constraint
;
...
...
@@ -53,7 +52,6 @@ import org.h2.store.PageStore;
import
org.h2.tools.Csv
;
import
org.h2.util.MathUtils
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.Resources
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
...
...
@@ -567,9 +565,9 @@ public class MetaTable extends Table {
return
s
;
}
private
ObjectArray
<
Table
>
getAllTables
(
Session
session
)
{
ObjectArray
<
Table
>
tables
=
database
.
getAllTablesAndViews
(
true
);
ObjectArray
<
Table
>
tempTables
=
session
.
getLocalTempTables
();
private
ArrayList
<
Table
>
getAllTables
(
Session
session
)
{
ArrayList
<
Table
>
tables
=
database
.
getAllTablesAndViews
(
true
);
ArrayList
<
Table
>
tempTables
=
session
.
getLocalTempTables
();
tables
.
addAll
(
tempTables
);
return
tables
;
}
...
...
@@ -727,8 +725,8 @@ public class MetaTable extends Table {
if
(!
checkIndex
(
session
,
tableName
,
indexFrom
,
indexTo
))
{
continue
;
}
ObjectArray
<
Index
>
indexes
=
table
.
getIndexes
();
ObjectArray
<
Constraint
>
constraints
=
table
.
getConstraints
();
ArrayList
<
Index
>
indexes
=
table
.
getIndexes
();
ArrayList
<
Constraint
>
constraints
=
table
.
getConstraints
();
for
(
int
j
=
0
;
indexes
!=
null
&&
j
<
indexes
.
size
();
j
++)
{
Index
index
=
indexes
.
get
(
j
);
if
(
index
.
getCreateSQL
()
==
null
)
{
...
...
@@ -1713,11 +1711,11 @@ public class MetaTable extends Table {
return
new
MetaIndex
(
this
,
IndexColumn
.
wrap
(
columns
),
true
);
}
public
ObjectArray
<
Index
>
getIndexes
()
{
public
ArrayList
<
Index
>
getIndexes
()
{
if
(
metaIndex
==
null
)
{
return
null
;
}
ObjectArray
<
Index
>
list
=
ObjectArray
.
newInstance
();
ArrayList
<
Index
>
list
=
New
.
arrayList
();
list
.
add
(
new
MetaIndex
(
this
,
IndexColumn
.
wrap
(
columns
),
true
));
// TODO fixed scan index
list
.
add
(
metaIndex
);
...
...
h2/src/main/org/h2/table/RangeTable.java
浏览文件 @
00083108
...
...
@@ -7,7 +7,7 @@
package
org
.
h2
.
table
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
org.h2.engine.Session
;
import
org.h2.expression.Expression
;
import
org.h2.index.Index
;
...
...
@@ -16,7 +16,6 @@ import org.h2.index.RangeIndex;
import
org.h2.message.Message
;
import
org.h2.result.Row
;
import
org.h2.schema.Schema
;
import
org.h2.util.ObjectArray
;
import
org.h2.value.Value
;
/**
...
...
@@ -148,7 +147,7 @@ public class RangeTable extends Table {
}
}
public
ObjectArray
<
Index
>
getIndexes
()
{
public
ArrayList
<
Index
>
getIndexes
()
{
return
null
;
}
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
00083108
...
...
@@ -11,7 +11,6 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.h2.command.Prepared
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constraint.Constraint
;
...
...
@@ -36,7 +35,6 @@ import org.h2.schema.SchemaObjectBase;
import
org.h2.schema.Sequence
;
import
org.h2.schema.TriggerObject
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
import
org.h2.value.CompareMode
;
import
org.h2.value.DataType
;
import
org.h2.value.Value
;
...
...
@@ -96,10 +94,10 @@ public abstract class Table extends SchemaObjectBase {
private
final
HashMap
<
String
,
Column
>
columnMap
=
New
.
hashMap
();
private
boolean
persistIndexes
;
private
boolean
persistData
;
private
ObjectArray
<
TriggerObject
>
triggers
;
private
ObjectArray
<
Constraint
>
constraints
;
private
ObjectArray
<
Sequence
>
sequences
;
private
ObjectArray
<
TableView
>
views
;
private
ArrayList
<
TriggerObject
>
triggers
;
private
ArrayList
<
Constraint
>
constraints
;
private
ArrayList
<
Sequence
>
sequences
;
private
ArrayList
<
TableView
>
views
;
private
boolean
checkForeignKeyConstraints
=
true
;
private
boolean
onCommitDrop
,
onCommitTruncate
;
private
Row
nullRow
;
...
...
@@ -217,7 +215,7 @@ public abstract class Table extends SchemaObjectBase {
*
* @return the list of indexes
*/
public
abstract
ObjectArray
<
Index
>
getIndexes
();
public
abstract
ArrayList
<
Index
>
getIndexes
();
/**
* Check if this table is locked exclusively.
...
...
@@ -291,9 +289,9 @@ public abstract class Table extends SchemaObjectBase {
}
}
public
ObjectArray
<
DbObject
>
getChildren
()
{
ObjectArray
<
DbObject
>
children
=
ObjectArray
.
newInstance
();
ObjectArray
<
Index
>
indexes
=
getIndexes
();
public
ArrayList
<
DbObject
>
getChildren
()
{
ArrayList
<
DbObject
>
children
=
New
.
arrayList
();
ArrayList
<
Index
>
indexes
=
getIndexes
();
if
(
indexes
!=
null
)
{
children
.
addAll
(
indexes
);
}
...
...
@@ -309,7 +307,7 @@ public abstract class Table extends SchemaObjectBase {
if
(
views
!=
null
)
{
children
.
addAll
(
views
);
}
ObjectArray
<
Right
>
rights
=
database
.
getAllRights
();
ArrayList
<
Right
>
rights
=
database
.
getAllRights
();
for
(
Right
right
:
rights
)
{
if
(
right
.
getGrantedTable
()
==
this
)
{
children
.
add
(
right
);
...
...
@@ -455,7 +453,7 @@ public abstract class Table extends SchemaObjectBase {
throw
Message
.
getSQLException
(
ErrorCode
.
COLUMN_MAY_BE_REFERENCED_1
,
constraint
.
getSQL
());
}
}
ObjectArray
<
Index
>
indexes
=
getIndexes
();
ArrayList
<
Index
>
indexes
=
getIndexes
();
for
(
int
i
=
0
;
indexes
!=
null
&&
i
<
indexes
.
size
();
i
++)
{
Index
index
=
indexes
.
get
(
i
);
if
(
index
.
getColumns
().
length
==
1
)
{
...
...
@@ -543,7 +541,7 @@ public abstract class Table extends SchemaObjectBase {
PlanItem
item
=
new
PlanItem
();
item
.
setIndex
(
getScanIndex
(
session
));
item
.
cost
=
item
.
getIndex
().
getCost
(
session
,
null
);
ObjectArray
<
Index
>
indexes
=
getIndexes
();
ArrayList
<
Index
>
indexes
=
getIndexes
();
for
(
int
i
=
1
;
indexes
!=
null
&&
masks
!=
null
&&
i
<
indexes
.
size
();
i
++)
{
Index
index
=
indexes
.
get
(
i
);
double
cost
=
index
.
getCost
(
session
,
masks
);
...
...
@@ -561,7 +559,7 @@ public abstract class Table extends SchemaObjectBase {
* @return the primary key index or null
*/
public
Index
findPrimaryKey
()
{
ObjectArray
<
Index
>
indexes
=
getIndexes
();
ArrayList
<
Index
>
indexes
=
getIndexes
();
for
(
int
i
=
0
;
indexes
!=
null
&&
i
<
indexes
.
size
();
i
++)
{
Index
idx
=
indexes
.
get
(
i
);
if
(
idx
.
getIndexType
().
isPrimaryKey
())
{
...
...
@@ -604,7 +602,7 @@ public abstract class Table extends SchemaObjectBase {
}
}
private
void
remove
(
ObjectArray
<
?
extends
DbObject
>
list
,
DbObject
obj
)
{
private
void
remove
(
ArrayList
<
?
extends
DbObject
>
list
,
DbObject
obj
)
{
if
(
list
!=
null
)
{
int
i
=
list
.
indexOf
(
obj
);
if
(
i
>=
0
)
{
...
...
@@ -619,7 +617,7 @@ public abstract class Table extends SchemaObjectBase {
* @param index the index to remove
*/
public
void
removeIndex
(
Index
index
)
{
ObjectArray
<
Index
>
indexes
=
getIndexes
();
ArrayList
<
Index
>
indexes
=
getIndexes
();
if
(
indexes
!=
null
)
{
remove
(
indexes
,
index
);
if
(
index
.
getIndexType
().
isPrimaryKey
())
{
...
...
@@ -687,7 +685,7 @@ public abstract class Table extends SchemaObjectBase {
}
}
public
ObjectArray
<
Constraint
>
getConstraints
()
{
public
ArrayList
<
Constraint
>
getConstraints
()
{
return
constraints
;
}
...
...
@@ -709,9 +707,9 @@ public abstract class Table extends SchemaObjectBase {
triggers
=
add
(
triggers
,
trigger
);
}
private
<
T
>
ObjectArray
<
T
>
add
(
ObjectArray
<
T
>
list
,
T
obj
)
{
private
<
T
>
ArrayList
<
T
>
add
(
ArrayList
<
T
>
list
,
T
obj
)
{
if
(
list
==
null
)
{
list
=
ObjectArray
.
newInstance
();
list
=
New
.
arrayList
();
}
// self constraints are two entries in the list
list
.
add
(
obj
);
...
...
@@ -838,7 +836,7 @@ public abstract class Table extends SchemaObjectBase {
* @return the index or null
*/
public
Index
getIndexForColumn
(
Column
column
,
boolean
first
)
{
ObjectArray
<
Index
>
indexes
=
getIndexes
();
ArrayList
<
Index
>
indexes
=
getIndexes
();
for
(
int
i
=
1
;
indexes
!=
null
&&
i
<
indexes
.
size
();
i
++)
{
Index
index
=
indexes
.
get
(
i
);
if
(
index
.
canGetFirstOrLast
())
{
...
...
h2/src/main/org/h2/table/TableData.java
浏览文件 @
00083108
...
...
@@ -8,6 +8,7 @@ package org.h2.table;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashSet
;
import
java.util.Set
;
...
...
@@ -38,7 +39,6 @@ import org.h2.result.SortOrder;
import
org.h2.schema.SchemaObject
;
import
org.h2.util.MathUtils
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
import
org.h2.value.CompareMode
;
...
...
@@ -57,7 +57,7 @@ public class TableData extends Table {
private
HashSet
<
Session
>
lockShared
=
New
.
hashSet
();
private
Trace
traceLock
;
private
boolean
globalTemporary
;
private
final
ObjectArray
<
Index
>
indexes
=
ObjectArray
.
newInstance
();
private
final
ArrayList
<
Index
>
indexes
=
New
.
arrayList
();
private
long
lastModificationId
;
private
boolean
containsLargeObject
;
private
PageDataIndex
mainIndex
;
...
...
@@ -168,7 +168,7 @@ public class TableData extends Table {
return
null
;
}
public
ObjectArray
<
Index
>
getIndexes
()
{
public
ArrayList
<
Index
>
getIndexes
()
{
return
indexes
;
}
...
...
@@ -221,7 +221,7 @@ public class TableData extends Table {
Cursor
cursor
=
scan
.
find
(
session
,
null
,
null
);
long
i
=
0
;
int
bufferSize
=
Constants
.
DEFAULT_MAX_MEMORY_ROWS
;
ObjectArray
<
Row
>
buffer
=
ObjectArray
.
newInstance
(
bufferSize
);
ArrayList
<
Row
>
buffer
=
New
.
arrayList
(
bufferSize
);
String
n
=
getName
()
+
":"
+
index
.
getName
();
int
t
=
MathUtils
.
convertLongToInt
(
total
);
while
(
cursor
.
next
())
{
...
...
@@ -294,10 +294,10 @@ public class TableData extends Table {
return
true
;
}
private
void
addRowsToIndex
(
Session
session
,
ObjectArray
<
Row
>
list
,
Index
index
)
throws
SQLException
{
private
void
addRowsToIndex
(
Session
session
,
ArrayList
<
Row
>
list
,
Index
index
)
throws
SQLException
{
final
Index
idx
=
index
;
try
{
list
.
sort
(
new
Comparator
<
Row
>()
{
Collections
.
sort
(
list
,
new
Comparator
<
Row
>()
{
public
int
compare
(
Row
r1
,
Row
r2
)
{
try
{
return
idx
.
compareRows
(
r1
,
r2
);
...
...
@@ -685,7 +685,7 @@ public class TableData extends Table {
}
public
boolean
canTruncate
()
{
ObjectArray
<
Constraint
>
constraints
=
getConstraints
();
ArrayList
<
Constraint
>
constraints
=
getConstraints
();
for
(
int
i
=
0
;
constraints
!=
null
&&
i
<
constraints
.
size
();
i
++)
{
Constraint
c
=
constraints
.
get
(
i
);
if
(!(
c
.
getConstraintType
().
equals
(
Constraint
.
REFERENTIAL
)))
{
...
...
h2/src/main/org/h2/table/TableLink.java
浏览文件 @
00083108
...
...
@@ -30,7 +30,6 @@ import org.h2.schema.Schema;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.StringUtils
;
import
org.h2.value.DataType
;
import
org.h2.value.Value
;
...
...
@@ -49,7 +48,7 @@ public class TableLink extends Table {
private
String
driver
,
url
,
user
,
password
,
originalSchema
,
originalTable
,
qualifiedTableName
;
private
TableLinkConnection
conn
;
private
HashMap
<
String
,
PreparedStatement
>
preparedMap
=
New
.
hashMap
();
private
final
ObjectArray
<
Index
>
indexes
=
ObjectArray
.
newInstance
();
private
final
ArrayList
<
Index
>
indexes
=
New
.
arrayList
();
private
final
boolean
emitUpdates
;
private
LinkedIndex
linkedIndex
;
private
SQLException
connectException
;
...
...
@@ -191,10 +190,10 @@ public class TableLink extends Table {
rs
=
null
;
}
String
pkName
=
""
;
ObjectArray
<
Column
>
list
;
ArrayList
<
Column
>
list
;
if
(
rs
!=
null
&&
rs
.
next
())
{
// the problem is, the rows are not sorted by KEY_SEQ
list
=
ObjectArray
.
newInstance
();
list
=
New
.
arrayList
();
do
{
int
idx
=
rs
.
getInt
(
"KEY_SEQ"
);
if
(
pkName
==
null
)
{
...
...
@@ -224,7 +223,7 @@ public class TableLink extends Table {
rs
=
null
;
}
String
indexName
=
null
;
list
=
ObjectArray
.
newInstance
();
list
=
New
.
arrayList
();
IndexType
indexType
=
null
;
if
(
rs
!=
null
)
{
while
(
rs
.
next
())
{
...
...
@@ -285,7 +284,7 @@ public class TableLink extends Table {
return
columnName
;
}
private
void
addIndex
(
ObjectArray
<
Column
>
list
,
IndexType
indexType
)
{
private
void
addIndex
(
ArrayList
<
Column
>
list
,
IndexType
indexType
)
{
Column
[]
cols
=
new
Column
[
list
.
size
()];
list
.
toArray
(
cols
);
Index
index
=
new
LinkedIndex
(
this
,
0
,
IndexColumn
.
wrap
(
cols
),
indexType
);
...
...
@@ -472,7 +471,7 @@ public class TableLink extends Table {
return
url
.
startsWith
(
"jdbc:oracle:"
);
}
public
ObjectArray
<
Index
>
getIndexes
()
{
public
ArrayList
<
Index
>
getIndexes
()
{
return
indexes
;
}
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
00083108
...
...
@@ -26,7 +26,6 @@ import org.h2.schema.Schema;
import
org.h2.util.IntArray
;
import
org.h2.util.MemoryUtils
;
import
org.h2.util.New
;
import
org.h2.util.ObjectArray
;
import
org.h2.util.SmallLRUCache
;
import
org.h2.util.StatementBuilder
;
import
org.h2.util.StringUtils
;
...
...
@@ -268,7 +267,7 @@ public class TableView extends Table {
return
item
.
getIndex
();
}
public
ObjectArray
<
Index
>
getIndexes
()
{
public
ArrayList
<
Index
>
getIndexes
()
{
return
null
;
}
...
...
h2/src/main/org/h2/util/Cache.java
浏览文件 @
00083108
...
...
@@ -7,6 +7,7 @@
package
org
.
h2
.
util
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
/**
* The cache keeps frequently used objects in the main memory.
...
...
@@ -18,7 +19,7 @@ public interface Cache {
*
* @return the list of objects
*/
ObjectArray
<
CacheObject
>
getAllChanged
();
ArrayList
<
CacheObject
>
getAllChanged
();
/**
* Clear the cache.
...
...
h2/src/main/org/h2/util/CacheLRU.java
浏览文件 @
00083108
...
...
@@ -7,6 +7,7 @@
package
org
.
h2
.
util
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.Map
;
import
java.util.WeakHashMap
;
...
...
@@ -122,7 +123,7 @@ public class CacheLRU implements Cache {
private
void
removeOld
()
throws
SQLException
{
int
i
=
0
;
ObjectArray
<
CacheObject
>
changed
=
ObjectArray
.
newInstance
();
ArrayList
<
CacheObject
>
changed
=
New
.
arrayList
();
int
mem
=
sizeMemory
;
int
rc
=
recordCount
;
boolean
flushed
=
false
;
...
...
@@ -287,11 +288,11 @@ public class CacheLRU implements Cache {
// }
// }
public
ObjectArray
<
CacheObject
>
getAllChanged
()
{
public
ArrayList
<
CacheObject
>
getAllChanged
()
{
// if(Database.CHECK) {
// testConsistency();
// }
ObjectArray
<
CacheObject
>
list
=
ObjectArray
.
newInstance
();
ArrayList
<
CacheObject
>
list
=
New
.
arrayList
();
CacheObject
rec
=
head
.
cacheNext
;
while
(
rec
!=
head
)
{
if
(
rec
.
isChanged
())
{
...
...
@@ -370,7 +371,7 @@ public class CacheLRU implements Cache {
//
// public ObjectArray getAllChanged() {
// Iterator it = values().iterator();
// ObjectArray list =
ObjectArray.newInstance
();
// ObjectArray list =
New.arrayList
();
// while(it.hasNext()) {
// Record rec = (Record)it.next();
// if(rec.isChanged()) {
...
...
h2/src/main/org/h2/util/CacheObject.java
浏览文件 @
00083108
...
...
@@ -6,6 +6,8 @@
*/
package
org
.
h2
.
util
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
org.h2.constant.SysProperties
;
...
...
@@ -80,8 +82,8 @@ public abstract class CacheObject {
*
* @param recordList the list of cache objects
*/
public
static
void
sort
(
ObjectArray
<
CacheObject
>
recordList
)
{
recordList
.
sort
(
new
CacheComparator
());
public
static
void
sort
(
ArrayList
<
CacheObject
>
recordList
)
{
Collections
.
sort
(
recordList
,
new
CacheComparator
());
}
public
void
setPos
(
int
pos
)
{
...
...
h2/src/main/org/h2/util/CacheSecondLevel.java
浏览文件 @
00083108
...
...
@@ -7,6 +7,7 @@
package
org
.
h2
.
util
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.Map
;
/**
...
...
@@ -44,7 +45,7 @@ class CacheSecondLevel implements Cache {
return
ret
;
}
public
ObjectArray
<
CacheObject
>
getAllChanged
()
{
public
ArrayList
<
CacheObject
>
getAllChanged
()
{
return
baseCache
.
getAllChanged
();
}
...
...
h2/src/main/org/h2/util/ObjectArray.java
deleted
100644 → 0
浏览文件 @
8094d423
/*
* Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
util
;
import
java.util.Collection
;
import
java.util.Comparator
;
import
java.util.Iterator
;
import
org.h2.constant.SysProperties
;
/**
* The object array is basically the same as ArrayList.
* It is a bit faster than ArrayList in some versions of Java.
*
* @param <T> the element type
*/
public
class
ObjectArray
<
T
>
implements
Iterable
<
T
>
{
private
static
final
int
CAPACITY_INIT
=
4
,
CAPACITY_SHRINK
=
256
;
int
size
;
private
T
[]
data
;
private
ObjectArray
(
int
capacity
)
{
data
=
createArray
(
capacity
);
}
private
ObjectArray
(
Collection
<
T
>
collection
)
{
size
=
collection
.
size
();
data
=
createArray
(
size
);
Iterator
<
T
>
it
=
collection
.
iterator
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
data
[
i
]
=
it
.
next
();
}
}
/**
* Create a new object with the given initial capacity.
*
* @param capacity the initial capacity
* @return the object
*/
public
static
<
T
>
ObjectArray
<
T
>
newInstance
(
int
capacity
)
{
return
new
ObjectArray
<
T
>(
capacity
);
}
/**
* Create a new object with the given values.
*
* @param list the initial elements
* @return the object
*/
public
static
<
T
>
ObjectArray
<
T
>
newInstance
(
T
...
list
)
{
ObjectArray
<
T
>
t
=
new
ObjectArray
<
T
>(
CAPACITY_INIT
);
for
(
T
x
:
list
)
{
t
.
add
(
x
);
}
return
t
;
}
/**
* Create a new object with the default initial capacity.
*
* @return the object
*/
public
static
<
T
>
ObjectArray
<
T
>
newInstance
()
{
return
new
ObjectArray
<
T
>(
CAPACITY_INIT
);
}
/**
* Create a new object with all elements of the given collection.
*
* @param collection the collection with all elements
* @return the object
*/
public
static
<
T
>
ObjectArray
<
T
>
newInstance
(
Collection
<
T
>
collection
)
{
return
new
ObjectArray
<
T
>(
collection
);
}
@SuppressWarnings
(
"unchecked"
)
private
T
[]
createArray
(
int
capacity
)
{
return
(
T
[])
new
Object
[
capacity
>
1
?
capacity
:
1
];
}
private
void
throwException
(
int
index
)
{
throw
new
ArrayIndexOutOfBoundsException
(
"i="
+
index
+
" size="
+
size
);
}
/**
* Append an object at the end of the list.
*
* @param value the value
*/
public
void
add
(
T
value
)
{
if
(
size
>=
data
.
length
)
{
ensureCapacity
(
size
);
}
data
[
size
++]
=
value
;
}
/**
* Get the object at the given index.
*
* @param index the index
* @return the value
*/
public
T
get
(
int
index
)
{
if
(
SysProperties
.
CHECK2
&&
index
>=
size
)
{
throwException
(
index
);
}
return
data
[
index
];
}
/**
* Remove the object at the given index.
*
* @param index the index
* @return the removed object
*/
public
Object
remove
(
int
index
)
{
// TODO performance: the app should (where possible)
// remove from end to start, to avoid O(n^2)
if
(
SysProperties
.
CHECK2
&&
index
>=
size
)
{
throwException
(
index
);
}
Object
value
=
data
[
index
];
System
.
arraycopy
(
data
,
index
+
1
,
data
,
index
,
size
-
index
-
1
);
size
--;
data
[
size
]
=
null
;
// TODO optimization / lib: could shrink ObjectArray on element remove
return
value
;
}
/**
* Remove a number of elements from the given start and end index.
*
* @param from the start index
* @param to the end index
*/
public
void
removeRange
(
int
from
,
int
to
)
{
if
(
SysProperties
.
CHECK2
&&
(
to
>
size
||
from
>
to
))
{
throw
new
ArrayIndexOutOfBoundsException
(
"to="
+
to
+
" from="
+
from
+
" size="
+
size
);
}
System
.
arraycopy
(
data
,
to
,
data
,
from
,
size
-
to
);
size
-=
to
-
from
;
for
(
int
i
=
size
+
(
to
-
from
)
-
1
;
i
>=
size
;
i
--)
{
data
[
i
]
=
null
;
}
}
/**
* Fill the list with empty elements until it reaches the given size.
*
* @param size the new size
*/
public
void
setSize
(
int
size
)
{
ensureCapacity
(
size
);
this
.
size
=
size
;
}
private
void
ensureCapacity
(
int
i
)
{
while
(
i
>=
data
.
length
)
{
T
[]
d
=
createArray
(
Math
.
max
(
CAPACITY_INIT
,
data
.
length
*
2
));
System
.
arraycopy
(
data
,
0
,
d
,
0
,
size
);
data
=
d
;
}
}
/**
* Shrink the array to the required size.
*/
public
void
trimToSize
()
{
T
[]
d
=
createArray
(
size
);
System
.
arraycopy
(
data
,
0
,
d
,
0
,
size
);
data
=
d
;
}
/**
* Insert an element at the given position. The element at this position and
* all elements with a higher index move one element.
*
* @param index the index where to insert the object
* @param value the object to insert
*/
public
void
add
(
int
index
,
T
value
)
{
if
(
SysProperties
.
CHECK2
&&
index
>
size
)
{
throwException
(
index
);
}
ensureCapacity
(
size
);
if
(
index
==
size
)
{
add
(
value
);
}
else
{
System
.
arraycopy
(
data
,
index
,
data
,
index
+
1
,
size
-
index
);
data
[
index
]
=
value
;
size
++;
}
}
/**
* Update the object at the given index.
*
* @param index the index
* @param value the new value
*/
public
void
set
(
int
index
,
T
value
)
{
if
(
SysProperties
.
CHECK2
&&
index
>=
size
)
{
throwException
(
index
);
}
data
[
index
]
=
value
;
}
/**
* Get the size of the list.
*
* @return the size
*/
public
int
size
()
{
return
size
;
}
/**
* Convert this list to an array. The target array must be big enough.
*
* @param array the target array
* @return the array
*/
public
T
[]
toArray
(
T
[]
array
)
{
System
.
arraycopy
(
data
,
0
,
array
,
0
,
size
);
return
array
;
}
/**
* Remove all elements from the list.
*/
public
void
clear
()
{
if
(
data
.
length
>
CAPACITY_SHRINK
)
{
data
=
createArray
(
CAPACITY_INIT
);
}
else
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
data
[
i
]
=
null
;
}
}
size
=
0
;
}
/**
* Get the index of the given object, or -1 if not found.
*
* @param o the object to search
* @return the index
*/
public
int
indexOf
(
Object
o
)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
if
(
data
[
i
]
==
o
)
{
return
i
;
}
}
return
-
1
;
}
/**
* Add all objects from the given list.
*
* @param list the list
*/
public
void
addAll
(
ObjectArray
<
?
extends
T
>
list
)
{
for
(
int
i
=
0
;
i
<
list
.
size
;
i
++)
{
add
(
list
.
data
[
i
]);
}
}
private
void
swap
(
int
l
,
int
r
)
{
T
t
=
data
[
r
];
data
[
r
]
=
data
[
l
];
data
[
l
]
=
t
;
}
/**
* Sort the elements using the given comparator.
*
* @param comp the comparator
*/
public
void
sort
(
Comparator
<
T
>
comp
)
{
sort
(
comp
,
0
,
size
-
1
);
}
/**
* Sort using the quicksort algorithm.
*
* @param comp the comparator
* @param l the first element (left)
* @param r the last element (right)
*/
private
void
sort
(
Comparator
<
T
>
comp
,
int
left
,
int
right
)
{
T
[]
d
=
data
;
while
(
right
-
left
>
12
)
{
// randomized pivot to avoid worst case
int
i
=
MathUtils
.
randomInt
(
right
-
left
-
4
)
+
left
+
2
;
// d[left]: smallest, d[i]: highest, d[right]: median
if
(
comp
.
compare
(
d
[
left
],
d
[
i
])
>
0
)
{
swap
(
left
,
i
);
}
if
(
comp
.
compare
(
d
[
left
],
d
[
right
])
>
0
)
{
swap
(
left
,
right
);
}
if
(
comp
.
compare
(
d
[
right
],
d
[
i
])
>
0
)
{
swap
(
right
,
i
);
}
T
p
=
d
[
right
];
i
=
left
-
1
;
int
j
=
right
;
while
(
true
)
{
do
{
++
i
;
}
while
(
comp
.
compare
(
d
[
i
],
p
)
<
0
);
do
{
--
j
;
}
while
(
comp
.
compare
(
d
[
j
],
p
)
>
0
);
if
(
i
>=
j
)
{
break
;
}
swap
(
i
,
j
);
}
swap
(
i
,
right
);
sort
(
comp
,
left
,
i
-
1
);
left
=
i
+
1
;
}
for
(
int
j
,
i
=
left
+
1
;
i
<=
right
;
i
++)
{
T
t
=
data
[
i
];
for
(
j
=
i
-
1
;
j
>=
left
&&
(
comp
.
compare
(
data
[
j
],
t
)
>
0
);
j
--)
{
data
[
j
+
1
]
=
data
[
j
];
}
data
[
j
+
1
]
=
t
;
}
}
/**
* The iterator for this list.
*/
class
ObjectArrayIterator
implements
Iterator
<
T
>
{
private
int
index
;
public
boolean
hasNext
()
{
return
index
<
size
;
}
public
T
next
()
{
return
get
(
index
++);
}
public
void
remove
()
{
throw
new
RuntimeException
();
}
}
public
Iterator
<
T
>
iterator
()
{
return
new
ObjectArrayIterator
();
}
public
String
toString
()
{
StatementBuilder
buff
=
new
StatementBuilder
(
"{"
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
buff
.
appendExceptFirst
(
", "
);
T
t
=
get
(
i
);
buff
.
append
(
t
==
null
?
""
:
t
.
toString
());
}
return
buff
.
append
(
'}'
).
toString
();
}
}
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
00083108
...
...
@@ -288,10 +288,10 @@ java org.h2.test.TestAll timer
/*
check client jar file size
simplify Message / ErrorCode / Resource
remove
ObjectArray,
BitField
flatten package hierarchy
remove BitField
flatten package hierarchy
(remove constant package)
Constants.FILE_BLOCK_SIZE and others
simplify SysProperties
simplify SysProperties
; combine with Constants
remove SortedProperties
remove TempFileDeleter (UndoLog, ResultDiskBuffer, RowList, ValueLob)
combine small classes (StringCache / utils...)
...
...
h2/src/tools/org/h2/dev/util/CacheTQ.java
浏览文件 @
00083108
...
...
@@ -7,7 +7,7 @@
package
org
.
h2
.
dev
.
util
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Constants
;
import
org.h2.message.Message
;
...
...
@@ -16,7 +16,7 @@ import org.h2.util.CacheHead;
import
org.h2.util.CacheObject
;
import
org.h2.util.CacheWriter
;
import
org.h2.util.MathUtils
;
import
org.h2.util.
ObjectArray
;
import
org.h2.util.
New
;
/**
* A cache implementation based on the 2Q algorithm.
...
...
@@ -175,7 +175,7 @@ class CacheTQ implements Cache {
private
void
removeOld
()
throws
SQLException
{
int
i
=
0
;
ObjectArray
<
CacheObject
>
changed
=
ObjectArray
.
newInstance
();
ArrayList
<
CacheObject
>
changed
=
New
.
arrayList
();
int
si
=
sizeIn
,
sm
=
sizeMain
,
rc
=
recordCount
;
CacheObject
inNext
=
headIn
.
cacheNext
,
mainNext
=
headMain
.
cacheNext
;
while
(((
si
*
4
>
maxIn
*
3
)
||
(
sm
*
4
>
maxMain
*
3
))
...
...
@@ -276,8 +276,8 @@ class CacheTQ implements Cache {
}
}
public
ObjectArray
<
CacheObject
>
getAllChanged
()
{
ObjectArray
<
CacheObject
>
list
=
ObjectArray
.
newInstance
();
public
ArrayList
<
CacheObject
>
getAllChanged
()
{
ArrayList
<
CacheObject
>
list
=
New
.
arrayList
();
for
(
CacheObject
o
=
headMain
.
cacheNext
;
o
!=
headMain
;
o
=
o
.
cacheNext
)
{
if
(
o
.
isChanged
())
{
list
.
add
(
o
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论