Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ed6735a0
Unverified
提交
ed6735a0
authored
5月 20, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
5月 20, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1147 from katzyn/misc
Assorted minor optimizations
上级
07e67c2d
d32637cc
显示空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
68 行增加
和
89 行删除
+68
-89
Insert.java
h2/src/main/org/h2/command/dml/Insert.java
+1
-1
Select.java
h2/src/main/org/h2/command/dml/Select.java
+1
-1
Function.java
h2/src/main/org/h2/expression/Function.java
+1
-1
FullTextSettings.java
h2/src/main/org/h2/fulltext/FullTextSettings.java
+3
-3
PageDataIndex.java
h2/src/main/org/h2/index/PageDataIndex.java
+1
-2
ScanIndex.java
h2/src/main/org/h2/index/ScanIndex.java
+1
-2
MVPrimaryIndex.java
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
+1
-1
MVSecondaryIndex.java
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
+2
-2
TcpServer.java
h2/src/main/org/h2/server/TcpServer.java
+3
-2
FilePath.java
h2/src/main/org/h2/store/fs/FilePath.java
+3
-6
SynchronizedVerifier.java
h2/src/main/org/h2/util/SynchronizedVerifier.java
+3
-8
ToDateParser.java
h2/src/main/org/h2/util/ToDateParser.java
+1
-1
ToDateTokenizer.java
h2/src/main/org/h2/util/ToDateTokenizer.java
+34
-45
CachedPreparedStatements.java
h2/src/test/org/h2/samples/CachedPreparedStatements.java
+2
-6
TriggerPassData.java
h2/src/test/org/h2/samples/TriggerPassData.java
+3
-5
TestFuzzOptimizations.java
h2/src/test/org/h2/test/synth/TestFuzzOptimizations.java
+6
-1
SQLDialect.java
h2/src/tools/org/h2/jaqu/SQLDialect.java
+2
-2
没有找到文件。
h2/src/main/org/h2/command/dml/Insert.java
浏览文件 @
ed6735a0
...
...
@@ -415,7 +415,7 @@ public class Insert extends Prepared implements ResultTarget {
for
(
Column
column
:
duplicateKeyAssignmentMap
.
keySet
())
{
buff
.
appendExceptFirst
(
", "
);
Expression
ex
=
duplicateKeyAssignmentMap
.
get
(
column
);
buff
.
append
(
column
.
getSQL
()).
append
(
"="
).
append
(
ex
.
getSQL
());
buff
.
append
(
column
.
getSQL
()).
append
(
'='
).
append
(
ex
.
getSQL
());
}
buff
.
append
(
" WHERE "
);
Index
foundIndex
=
(
Index
)
de
.
getSource
();
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
ed6735a0
...
...
@@ -1164,7 +1164,7 @@ public class Select extends Query {
buff
.
appendExceptFirst
(
","
);
buff
.
append
(
c
.
getName
());
}
buff
.
append
(
") AS "
).
append
(
t
.
getSQL
()).
append
(
"\n"
);
buff
.
append
(
") AS "
).
append
(
t
.
getSQL
()).
append
(
'\n'
);
}
}
}
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
ed6735a0
...
...
@@ -2492,7 +2492,7 @@ public class Function extends Expression implements FunctionCall {
StatementBuilder
buff
=
new
StatementBuilder
(
info
.
name
);
if
(
info
.
type
==
CASE
)
{
if
(
args
[
0
]
!=
null
)
{
buff
.
append
(
" "
).
append
(
args
[
0
].
getSQL
());
buff
.
append
(
' '
).
append
(
args
[
0
].
getSQL
());
}
for
(
int
i
=
1
,
len
=
args
.
length
-
1
;
i
<
len
;
i
+=
2
)
{
buff
.
append
(
" WHEN "
).
append
(
args
[
i
].
getSQL
());
...
...
h2/src/main/org/h2/fulltext/FullTextSettings.java
浏览文件 @
ed6735a0
...
...
@@ -10,11 +10,12 @@ import java.sql.PreparedStatement;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.h2.util.SoftHashMap
;
/**
...
...
@@ -45,8 +46,7 @@ final class FullTextSettings {
/**
* The set of indexes in this database.
*/
private
final
Map
<
Integer
,
IndexInfo
>
indexes
=
Collections
.
synchronizedMap
(
new
HashMap
<
Integer
,
IndexInfo
>());
private
final
ConcurrentHashMap
<
Integer
,
IndexInfo
>
indexes
=
new
ConcurrentHashMap
<>();
/**
* The prepared statement cache.
...
...
h2/src/main/org/h2/index/PageDataIndex.java
浏览文件 @
ed6735a0
...
...
@@ -491,8 +491,7 @@ public class PageDataIndex extends PageIndex {
Iterator
<
Row
>
getDelta
()
{
if
(
delta
==
null
)
{
List
<
Row
>
e
=
Collections
.
emptyList
();
return
e
.
iterator
();
return
Collections
.
emptyIterator
();
}
return
delta
.
iterator
();
}
...
...
h2/src/main/org/h2/index/ScanIndex.java
浏览文件 @
ed6735a0
...
...
@@ -251,8 +251,7 @@ public class ScanIndex extends BaseIndex {
Iterator
<
Row
>
getDelta
()
{
if
(
delta
==
null
)
{
List
<
Row
>
e
=
Collections
.
emptyList
();
return
e
.
iterator
();
return
Collections
.
emptyIterator
();
}
return
delta
.
iterator
();
}
...
...
h2/src/main/org/h2/mvstore/db/MVPrimaryIndex.java
浏览文件 @
ed6735a0
...
...
@@ -258,7 +258,7 @@ public class MVPrimaryIndex extends BaseIndex {
ValueLong
v
=
(
ValueLong
)
(
first
?
map
.
firstKey
()
:
map
.
lastKey
());
if
(
v
==
null
)
{
return
new
MVStoreCursor
(
session
,
Collections
.<
Entry
<
Value
,
Value
>>
empty
List
().
i
terator
());
Collections
.<
Entry
<
Value
,
Value
>>
empty
I
terator
());
}
Value
value
=
map
.
get
(
v
);
Entry
<
Value
,
Value
>
e
=
new
AbstractMap
.
SimpleImmutableEntry
<
Value
,
Value
>(
v
,
value
);
...
...
h2/src/main/org/h2/mvstore/db/MVSecondaryIndex.java
浏览文件 @
ed6735a0
...
...
@@ -307,7 +307,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
}
if
(
min
==
null
)
{
return
new
MVStoreCursor
(
session
,
Collections
.<
Value
>
empty
List
().
i
terator
(),
null
);
Collections
.<
Value
>
empty
I
terator
(),
null
);
}
}
return
new
MVStoreCursor
(
session
,
map
.
keyIterator
(
min
),
last
);
...
...
@@ -394,7 +394,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
while
(
true
)
{
if
(
key
==
null
)
{
return
new
MVStoreCursor
(
session
,
Collections
.<
Value
>
empty
List
().
i
terator
(),
null
);
Collections
.<
Value
>
empty
I
terator
(),
null
);
}
if
(((
ValueArray
)
key
).
getList
()[
0
]
!=
ValueNull
.
INSTANCE
)
{
break
;
...
...
h2/src/main/org/h2/server/TcpServer.java
浏览文件 @
ed6735a0
...
...
@@ -21,6 +21,8 @@ import java.util.HashSet;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.h2.Driver
;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Constants
;
...
...
@@ -49,8 +51,7 @@ public class TcpServer implements Service {
*/
private
static
final
String
MANAGEMENT_DB_PREFIX
=
"management_db_"
;
private
static
final
Map
<
Integer
,
TcpServer
>
SERVERS
=
Collections
.
synchronizedMap
(
new
HashMap
<
Integer
,
TcpServer
>());
private
static
final
ConcurrentHashMap
<
Integer
,
TcpServer
>
SERVERS
=
new
ConcurrentHashMap
<>();
private
int
port
;
private
boolean
portIsSet
;
...
...
h2/src/main/org/h2/store/fs/FilePath.java
浏览文件 @
ed6735a0
...
...
@@ -9,10 +9,8 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.nio.channels.FileChannel
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.
concurrent.ConcurrentHash
Map
;
import
org.h2.util.MathUtils
;
/**
...
...
@@ -25,7 +23,7 @@ public abstract class FilePath {
private
static
FilePath
defaultProvider
;
private
static
Map
<
String
,
FilePath
>
providers
;
private
static
ConcurrentHash
Map
<
String
,
FilePath
>
providers
;
/**
* The prefix for temporary files.
...
...
@@ -66,8 +64,7 @@ public abstract class FilePath {
private
static
void
registerDefaultProviders
()
{
if
(
providers
==
null
||
defaultProvider
==
null
)
{
Map
<
String
,
FilePath
>
map
=
Collections
.
synchronizedMap
(
new
HashMap
<
String
,
FilePath
>());
ConcurrentHashMap
<
String
,
FilePath
>
map
=
new
ConcurrentHashMap
<>();
for
(
String
c
:
new
String
[]
{
"org.h2.store.fs.FilePathDisk"
,
"org.h2.store.fs.FilePathMem"
,
...
...
h2/src/main/org/h2/util/SynchronizedVerifier.java
浏览文件 @
ed6735a0
...
...
@@ -5,10 +5,7 @@
*/
package
org
.
h2
.
util
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.IdentityHashMap
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.atomic.AtomicBoolean
;
/**
...
...
@@ -17,10 +14,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
public
class
SynchronizedVerifier
{
private
static
volatile
boolean
enabled
;
private
static
final
Map
<
Class
<?>,
AtomicBoolean
>
DETECT
=
Collections
.
synchronizedMap
(
new
HashMap
<
Class
<?>,
AtomicBoolean
>());
private
static
final
Map
<
Object
,
Object
>
CURRENT
=
Collections
.
synchronizedMap
(
new
IdentityHashMap
<>());
private
static
final
ConcurrentHashMap
<
Class
<?>,
AtomicBoolean
>
DETECT
=
new
ConcurrentHashMap
<>();
private
static
final
ConcurrentHashMap
<
Object
,
Object
>
CURRENT
=
new
ConcurrentHashMap
<>();
/**
* Enable or disable detection for a given class.
...
...
h2/src/main/org/h2/util/ToDateParser.java
浏览文件 @
ed6735a0
...
...
@@ -265,7 +265,7 @@ public class ToDateParser {
while
(
p
.
hasToParseData
())
{
List
<
ToDateTokenizer
.
FormatTokenEnum
>
tokenList
=
ToDateTokenizer
.
FormatTokenEnum
.
getTokensInQuestion
(
p
.
getFormatStr
());
if
(
tokenList
.
isEmpty
()
)
{
if
(
tokenList
==
null
)
{
p
.
removeFirstChar
();
continue
;
}
...
...
h2/src/main/org/h2/util/ToDateTokenizer.java
浏览文件 @
ed6735a0
...
...
@@ -9,9 +9,7 @@ import static java.lang.String.format;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.TimeZone
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
...
...
@@ -616,10 +614,9 @@ class ToDateTokenizer {
// where "T" and "Z" are inlined
INLINE
(
PARSLET_INLINE
,
PATTERN_INLINE
);
private
static
final
List
<
FormatTokenEnum
>
EMPTY_LIST
=
Collections
.
emptyList
();
private
static
final
List
<
FormatTokenEnum
>
INLINE_LIST
=
Collections
.
singletonList
(
INLINE
);
private
static
final
Map
<
Character
,
List
<
FormatTokenEnum
>>
CACHE
=
new
HashMap
<>(
64
)
;
private
static
List
<
FormatTokenEnum
>[]
TOKENS
;
private
final
ToDateParslet
toDateParslet
;
private
final
Pattern
patternToUse
;
...
...
@@ -648,60 +645,52 @@ class ToDateTokenizer {
/**
* Optimization: Only return a list of {@link FormatTokenEnum} that
* share the same 1st char using the 1st char of the 'to parse'
* formatStr. Or return
empty list
if no match.
* formatStr. Or return
{@code null}
if no match.
*
* @param formatStr the format string
* @return the list of tokens
* @return the list of tokens
, or {@code null}
*/
static
List
<
FormatTokenEnum
>
getTokensInQuestion
(
String
formatStr
)
{
List
<
FormatTokenEnum
>
result
=
EMPTY_LIST
;
if
(
CACHE
.
size
()
<=
0
)
{
initCache
();
}
if
(
formatStr
!=
null
&&
formatStr
.
length
()
>
0
)
{
Character
key
=
Character
.
toUpperCase
(
formatStr
.
charAt
(
0
));
switch
(
key
)
{
case
'"'
:
result
=
new
ArrayList
<>();
result
.
add
(
INLINE
);
break
;
default
:
result
=
CACHE
.
get
(
key
);
char
key
=
Character
.
toUpperCase
(
formatStr
.
charAt
(
0
));
if
(
key
>=
'A'
&&
key
<=
'Y'
)
{
List
<
FormatTokenEnum
>[]
tokens
=
TOKENS
;
if
(
tokens
==
null
)
{
tokens
=
initTokens
();
}
return
tokens
[
key
-
'A'
];
}
else
if
(
key
==
'"'
)
{
return
INLINE_LIST
;
}
if
(
result
==
null
)
{
result
=
EMPTY_LIST
;
}
return
result
;
return
null
;
}
private
static
synchronized
void
initCache
()
{
if
(
CACHE
.
size
()
<=
0
)
{
@SuppressWarnings
(
"unchecked"
)
private
static
List
<
FormatTokenEnum
>[]
initTokens
()
{
List
<
FormatTokenEnum
>[]
tokens
=
new
List
[
25
];
for
(
FormatTokenEnum
token
:
FormatTokenEnum
.
values
())
{
List
<
Character
>
tokenKeys
=
new
ArrayList
<>();
if
(
token
.
name
().
contains
(
"_"
))
{
String
[]
tokens
=
token
.
name
().
split
(
"_"
);
for
(
String
tokenLets
:
tokens
)
{
tokenKeys
.
add
(
tokenLets
.
toUpperCase
().
charAt
(
0
));
String
name
=
token
.
name
();
if
(
name
.
indexOf
(
'_'
)
>=
0
)
{
for
(
String
tokenLets
:
name
.
split
(
"_"
))
{
putToCache
(
tokens
,
token
,
tokenLets
);
}
}
else
{
tokenKeys
.
add
(
token
.
name
().
toUpperCase
().
charAt
(
0
));
putToCache
(
tokens
,
token
,
name
);
}
}
return
TOKENS
=
tokens
;
}
for
(
Character
tokenKey
:
tokenKeys
)
{
List
<
FormatTokenEnum
>
l
=
CACHE
.
get
(
tokenKey
);
private
static
void
putToCache
(
List
<
FormatTokenEnum
>[]
cache
,
FormatTokenEnum
token
,
String
name
)
{
int
idx
=
Character
.
toUpperCase
(
name
.
charAt
(
0
))
-
'A'
;
List
<
FormatTokenEnum
>
l
=
cache
[
idx
];
if
(
l
==
null
)
{
l
=
new
ArrayList
<>(
1
);
CACHE
.
put
(
tokenKey
,
l
)
;
cache
[
idx
]
=
l
;
}
l
.
add
(
token
);
}
}
}
}
/**
* Parse the format-string with passed token of {@link FormatTokenEnum}.
...
...
h2/src/test/org/h2/samples/CachedPreparedStatements.java
浏览文件 @
ed6735a0
...
...
@@ -10,9 +10,7 @@ import java.sql.DriverManager;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* This sample application shows how to cache prepared statements.
...
...
@@ -21,9 +19,7 @@ public class CachedPreparedStatements {
private
Connection
conn
;
private
Statement
stat
;
private
final
Map
<
String
,
PreparedStatement
>
prepared
=
Collections
.
synchronizedMap
(
new
HashMap
<
String
,
PreparedStatement
>());
private
final
ConcurrentHashMap
<
String
,
PreparedStatement
>
prepared
=
new
ConcurrentHashMap
<>();
/**
* This method is called when executing this sample application from the
...
...
h2/src/test/org/h2/samples/TriggerPassData.java
浏览文件 @
ed6735a0
...
...
@@ -10,9 +10,8 @@ import java.sql.DriverManager;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.h2.api.Trigger
;
/**
...
...
@@ -21,8 +20,7 @@ import org.h2.api.Trigger;
*/
public
class
TriggerPassData
implements
Trigger
{
private
static
final
Map
<
String
,
TriggerPassData
>
TRIGGERS
=
Collections
.
synchronizedMap
(
new
HashMap
<
String
,
TriggerPassData
>());
private
static
final
ConcurrentHashMap
<
String
,
TriggerPassData
>
TRIGGERS
=
new
ConcurrentHashMap
<>();
private
String
triggerData
;
/**
...
...
h2/src/test/org/h2/test/synth/TestFuzzOptimizations.java
浏览文件 @
ed6735a0
...
...
@@ -117,11 +117,16 @@ public class TestFuzzOptimizations extends TestBase {
}
executeAndCompare
(
condition
,
params
,
message
);
}
if
(!
config
.
mvStore
)
{
if
(!
config
.
mvStore
&&
config
.
travis
)
{
/*
* Travis tests have problems with automatic garbage collection, so request a GC
* explicitly and print its results.
*/
try
{
Thread
.
sleep
(
100
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
println
((
Utils
.
getMemoryUsed
()
>>
10
)
+
" MiB used"
);
}
}
...
...
h2/src/tools/org/h2/jaqu/SQLDialect.java
浏览文件 @
ed6735a0
...
...
@@ -98,12 +98,12 @@ public interface SQLDialect {
buff
.
append
(
index
.
indexName
);
buff
.
append
(
" ON "
);
buff
.
append
(
table
);
buff
.
append
(
"("
);
buff
.
append
(
'('
);
for
(
String
col
:
index
.
columnNames
)
{
buff
.
appendExceptFirst
(
", "
);
buff
.
append
(
col
);
}
buff
.
append
(
")"
);
buff
.
append
(
')'
);
return
buff
.
toString
();
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论