Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
a51ece58
Unverified
提交
a51ece58
authored
7 年前
作者:
Noel Grandin
提交者:
GitHub
7 年前
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #968 from katzyn/misc
Assorted changes
上级
606eebb5
988fa69b
隐藏空白字符变更
内嵌
并排
正在显示
40 个修改的文件
包含
205 行增加
和
161 行删除
+205
-161
Bits.class
h2/src/java9/precompiled/org/h2/util/Bits.class
+0
-0
Bits.java
h2/src/java9/src/org/h2/util/Bits.java
+41
-0
Command.java
h2/src/main/org/h2/command/Command.java
+2
-2
Query.java
h2/src/main/org/h2/command/dml/Query.java
+1
-1
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+1
-3
Constants.java
h2/src/main/org/h2/engine/Constants.java
+5
-5
Database.java
h2/src/main/org/h2/engine/Database.java
+1
-2
DbSettings.java
h2/src/main/org/h2/engine/DbSettings.java
+2
-2
Session.java
h2/src/main/org/h2/engine/Session.java
+2
-5
SysProperties.java
h2/src/main/org/h2/engine/SysProperties.java
+2
-2
AggregateDataMedian.java
h2/src/main/org/h2/expression/AggregateDataMedian.java
+1
-1
Function.java
h2/src/main/org/h2/expression/Function.java
+2
-2
IndexCondition.java
h2/src/main/org/h2/index/IndexCondition.java
+1
-2
PageDataIndex.java
h2/src/main/org/h2/index/PageDataIndex.java
+1
-1
FileStore.java
h2/src/main/org/h2/mvstore/FileStore.java
+1
-1
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+1
-1
ObjectDataType.java
h2/src/main/org/h2/mvstore/type/ObjectDataType.java
+1
-1
WebApp.java
h2/src/main/org/h2/server/web/WebApp.java
+1
-1
Data.java
h2/src/main/org/h2/store/Data.java
+12
-12
LobStorageBackend.java
h2/src/main/org/h2/store/LobStorageBackend.java
+1
-1
FilePathNioMapped.java
h2/src/main/org/h2/store/fs/FilePathNioMapped.java
+1
-1
TableLink.java
h2/src/main/org/h2/table/TableLink.java
+1
-1
CompressTool.java
h2/src/main/org/h2/tools/CompressTool.java
+5
-5
Bits.java
h2/src/main/org/h2/util/Bits.java
+62
-0
DateTimeUtils.java
h2/src/main/org/h2/util/DateTimeUtils.java
+34
-34
MathUtils.java
h2/src/main/org/h2/util/MathUtils.java
+1
-1
ThreadDeadlockDetector.java
h2/src/main/org/h2/util/ThreadDeadlockDetector.java
+1
-1
ToDateParser.java
h2/src/main/org/h2/util/ToDateParser.java
+2
-2
Utils.java
h2/src/main/org/h2/util/Utils.java
+0
-54
Transfer.java
h2/src/main/org/h2/value/Transfer.java
+4
-4
ValueBytes.java
h2/src/main/org/h2/value/ValueBytes.java
+3
-2
ValueDecimal.java
h2/src/main/org/h2/value/ValueDecimal.java
+1
-1
ValueJavaObject.java
h2/src/main/org/h2/value/ValueJavaObject.java
+2
-2
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+2
-1
ValueLobDb.java
h2/src/main/org/h2/value/ValueLobDb.java
+2
-1
ValueTime.java
h2/src/main/org/h2/value/ValueTime.java
+1
-1
ValueTimestamp.java
h2/src/main/org/h2/value/ValueTimestamp.java
+1
-1
ValueUuid.java
h2/src/main/org/h2/value/ValueUuid.java
+1
-1
DirectInsert.java
h2/src/test/org/h2/samples/DirectInsert.java
+1
-1
SpellChecker.java
h2/src/tools/org/h2/build/doc/SpellChecker.java
+1
-2
没有找到文件。
h2/src/java9/precompiled/org/h2/util/Bits.class
浏览文件 @
a51ece58
No preview for this file type
This diff is collapsed.
Click to expand it.
h2/src/java9/src/org/h2/util/Bits.java
浏览文件 @
a51ece58
...
@@ -8,6 +8,7 @@ package org.h2.util;
...
@@ -8,6 +8,7 @@ package org.h2.util;
import
java.lang.invoke.MethodHandles
;
import
java.lang.invoke.MethodHandles
;
import
java.lang.invoke.VarHandle
;
import
java.lang.invoke.VarHandle
;
import
java.nio.ByteOrder
;
import
java.nio.ByteOrder
;
import
java.util.Arrays
;
import
java.util.UUID
;
import
java.util.UUID
;
/**
/**
...
@@ -28,6 +29,46 @@ public final class Bits {
...
@@ -28,6 +29,46 @@ public final class Bits {
*/
*/
private
static
final
VarHandle
LONG_VH
=
MethodHandles
.
byteArrayViewVarHandle
(
long
[].
class
,
ByteOrder
.
BIG_ENDIAN
);
private
static
final
VarHandle
LONG_VH
=
MethodHandles
.
byteArrayViewVarHandle
(
long
[].
class
,
ByteOrder
.
BIG_ENDIAN
);
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the content
* or length of the second array is smaller than the first array, 1 is returned.
* If the contents and lengths are the same, 0 is returned.
*
* <p>
* This method interprets bytes as signed.
* </p>
*
* @param data1
* the first byte array (must not be null)
* @param data2
* the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public
static
int
compareNotNullSigned
(
byte
[]
data1
,
byte
[]
data2
)
{
return
Integer
.
signum
(
Arrays
.
compare
(
data1
,
data2
));
}
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the content
* or length of the second array is smaller than the first array, 1 is returned.
* If the contents and lengths are the same, 0 is returned.
*
* <p>
* This method interprets bytes as unsigned.
* </p>
*
* @param data1
* the first byte array (must not be null)
* @param data2
* the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public
static
int
compareNotNullUnsigned
(
byte
[]
data1
,
byte
[]
data2
)
{
return
Integer
.
signum
(
Arrays
.
compareUnsigned
(
data1
,
data2
));
}
/**
/**
* Reads a int value from the byte array at the given position in big-endian
* Reads a int value from the byte array at the given position in big-endian
* order.
* order.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/Command.java
浏览文件 @
a51ece58
...
@@ -311,7 +311,7 @@ public abstract class Command implements CommandInterface {
...
@@ -311,7 +311,7 @@ public abstract class Command implements CommandInterface {
errorCode
!=
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
)
{
errorCode
!=
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
)
{
throw
e
;
throw
e
;
}
}
long
now
=
System
.
nanoTime
()
/
1
000
000
;
long
now
=
System
.
nanoTime
()
/
1
_000_
000
;
if
(
start
!=
0
&&
now
-
start
>
session
.
getLockTimeout
())
{
if
(
start
!=
0
&&
now
-
start
>
session
.
getLockTimeout
())
{
throw
DbException
.
get
(
ErrorCode
.
LOCK_TIMEOUT_1
,
e
.
getCause
(),
""
);
throw
DbException
.
get
(
ErrorCode
.
LOCK_TIMEOUT_1
,
e
.
getCause
(),
""
);
}
}
...
@@ -327,7 +327,7 @@ public abstract class Command implements CommandInterface {
...
@@ -327,7 +327,7 @@ public abstract class Command implements CommandInterface {
}
catch
(
InterruptedException
e1
)
{
}
catch
(
InterruptedException
e1
)
{
// ignore
// ignore
}
}
long
slept
=
System
.
nanoTime
()
/
1
000
000
-
now
;
long
slept
=
System
.
nanoTime
()
/
1
_000_
000
-
now
;
if
(
slept
>=
sleep
)
{
if
(
slept
>=
sleep
)
{
break
;
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
a51ece58
...
@@ -149,7 +149,7 @@ public abstract class Query extends Prepared {
...
@@ -149,7 +149,7 @@ public abstract class Query extends Prepared {
public
int
getCostAsExpression
()
{
public
int
getCostAsExpression
()
{
// ensure the cost is not larger than 1 million,
// ensure the cost is not larger than 1 million,
// so that adding other values can't overflow
// so that adding other values can't overflow
return
(
int
)
Math
.
min
(
1
000000.0
,
10.0
+
10.0
*
getCost
());
return
(
int
)
Math
.
min
(
1
_000_000
d
,
10
d
+
10
d
*
getCost
());
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
a51ece58
...
@@ -445,9 +445,7 @@ public class ConnectionInfo implements Cloneable {
...
@@ -445,9 +445,7 @@ public class ConnectionInfo implements Cloneable {
* @return the property keys
* @return the property keys
*/
*/
String
[]
getKeys
()
{
String
[]
getKeys
()
{
String
[]
keys
=
new
String
[
prop
.
size
()];
return
prop
.
keySet
().
toArray
(
new
String
[
prop
.
size
()]);
prop
.
keySet
().
toArray
(
keys
);
return
keys
;
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Constants.java
浏览文件 @
a51ece58
...
@@ -246,12 +246,12 @@ public class Constants {
...
@@ -246,12 +246,12 @@ public class Constants {
/**
/**
* The default value for the MAX_MEMORY_UNDO setting.
* The default value for the MAX_MEMORY_UNDO setting.
*/
*/
public
static
final
int
DEFAULT_MAX_MEMORY_UNDO
=
50000
;
public
static
final
int
DEFAULT_MAX_MEMORY_UNDO
=
50
_
000
;
/**
/**
* The default for the setting MAX_OPERATION_MEMORY.
* The default for the setting MAX_OPERATION_MEMORY.
*/
*/
public
static
final
int
DEFAULT_MAX_OPERATION_MEMORY
=
100000
;
public
static
final
int
DEFAULT_MAX_OPERATION_MEMORY
=
100
_
000
;
/**
/**
* The default page size to use for new databases.
* The default page size to use for new databases.
...
@@ -312,7 +312,7 @@ public class Constants {
...
@@ -312,7 +312,7 @@ public class Constants {
/**
/**
* The highest possible parameter index.
* The highest possible parameter index.
*/
*/
public
static
final
int
MAX_PARAMETER_INDEX
=
100000
;
public
static
final
int
MAX_PARAMETER_INDEX
=
100
_
000
;
/**
/**
* The memory needed by a object of class Data
* The memory needed by a object of class Data
...
@@ -404,7 +404,7 @@ public class Constants {
...
@@ -404,7 +404,7 @@ public class Constants {
/**
/**
* The number of distinct values to keep in memory when running ANALYZE.
* The number of distinct values to keep in memory when running ANALYZE.
*/
*/
public
static
final
int
SELECTIVITY_DISTINCT_COUNT
=
10000
;
public
static
final
int
SELECTIVITY_DISTINCT_COUNT
=
10
_
000
;
/**
/**
* The default directory name of the server properties file for the H2
* The default directory name of the server properties file for the H2
...
@@ -512,7 +512,7 @@ public class Constants {
...
@@ -512,7 +512,7 @@ public class Constants {
* The maximum time in milliseconds to keep the cost of a view.
* The maximum time in milliseconds to keep the cost of a view.
* 10000 means 10 seconds.
* 10000 means 10 seconds.
*/
*/
public
static
final
int
VIEW_COST_CACHE_MAX_AGE
=
10000
;
public
static
final
int
VIEW_COST_CACHE_MAX_AGE
=
10
_
000
;
/**
/**
* The name of the index cache that is used for temporary view (subqueries
* The name of the index cache that is used for temporary view (subqueries
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Database.java
浏览文件 @
a51ece58
...
@@ -1234,8 +1234,7 @@ public class Database implements DataHandler {
...
@@ -1234,8 +1234,7 @@ public class Database implements DataHandler {
}
}
private
synchronized
void
closeAllSessionsException
(
Session
except
)
{
private
synchronized
void
closeAllSessionsException
(
Session
except
)
{
Session
[]
all
=
new
Session
[
userSessions
.
size
()];
Session
[]
all
=
userSessions
.
toArray
(
new
Session
[
userSessions
.
size
()]);
userSessions
.
toArray
(
all
);
for
(
Session
s
:
all
)
{
for
(
Session
s
:
all
)
{
if
(
s
!=
except
)
{
if
(
s
!=
except
)
{
try
{
try
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/DbSettings.java
浏览文件 @
a51ece58
...
@@ -54,7 +54,7 @@ public class DbSettings extends SettingsBase {
...
@@ -54,7 +54,7 @@ public class DbSettings extends SettingsBase {
* Database setting <code>ANALYZE_SAMPLE</code> (default: 10000).<br />
* Database setting <code>ANALYZE_SAMPLE</code> (default: 10000).<br />
* The default sample size when analyzing a table.
* The default sample size when analyzing a table.
*/
*/
public
final
int
analyzeSample
=
get
(
"ANALYZE_SAMPLE"
,
10000
);
public
final
int
analyzeSample
=
get
(
"ANALYZE_SAMPLE"
,
10
_
000
);
/**
/**
* Database setting <code>DATABASE_TO_UPPER</code> (default: true).<br />
* Database setting <code>DATABASE_TO_UPPER</code> (default: true).<br />
...
@@ -144,7 +144,7 @@ public class DbSettings extends SettingsBase {
...
@@ -144,7 +144,7 @@ public class DbSettings extends SettingsBase {
* times out. After the timeout, the LOB is no longer accessible using this
* times out. After the timeout, the LOB is no longer accessible using this
* reference.
* reference.
*/
*/
public
final
int
lobTimeout
=
get
(
"LOB_TIMEOUT"
,
300000
);
public
final
int
lobTimeout
=
get
(
"LOB_TIMEOUT"
,
300
_
000
);
/**
/**
* Database setting <code>MAX_COMPACT_COUNT</code>
* Database setting <code>MAX_COMPACT_COUNT</code>
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Session.java
浏览文件 @
a51ece58
...
@@ -352,9 +352,7 @@ public class Session extends SessionWithState {
...
@@ -352,9 +352,7 @@ public class Session extends SessionWithState {
if
(
variables
==
null
)
{
if
(
variables
==
null
)
{
return
new
String
[
0
];
return
new
String
[
0
];
}
}
String
[]
list
=
new
String
[
variables
.
size
()];
return
variables
.
keySet
().
toArray
(
new
String
[
variables
.
size
()]);
variables
.
keySet
().
toArray
(
list
);
return
list
;
}
}
/**
/**
...
@@ -835,8 +833,7 @@ public class Session extends SessionWithState {
...
@@ -835,8 +833,7 @@ public class Session extends SessionWithState {
}
}
}
}
if
(
savepoints
!=
null
)
{
if
(
savepoints
!=
null
)
{
String
[]
names
=
new
String
[
savepoints
.
size
()];
String
[]
names
=
savepoints
.
keySet
().
toArray
(
new
String
[
savepoints
.
size
()]);
savepoints
.
keySet
().
toArray
(
names
);
for
(
String
name
:
names
)
{
for
(
String
name
:
names
)
{
Savepoint
sp
=
savepoints
.
get
(
name
);
Savepoint
sp
=
savepoints
.
get
(
name
);
int
savepointIndex
=
sp
.
logIndex
;
int
savepointIndex
=
sp
.
logIndex
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/SysProperties.java
浏览文件 @
a51ece58
...
@@ -129,7 +129,7 @@ public class SysProperties {
...
@@ -129,7 +129,7 @@ public class SysProperties {
* been set for the database.
* been set for the database.
*/
*/
public
static
final
int
COLLATOR_CACHE_SIZE
=
public
static
final
int
COLLATOR_CACHE_SIZE
=
Utils
.
getProperty
(
"h2.collatorCacheSize"
,
32000
);
Utils
.
getProperty
(
"h2.collatorCacheSize"
,
32
_
000
);
/**
/**
* System property <code>h2.consoleTableIndexes</code>
* System property <code>h2.consoleTableIndexes</code>
...
@@ -260,7 +260,7 @@ public class SysProperties {
...
@@ -260,7 +260,7 @@ public class SysProperties {
* The default maximum number of rows to be kept in memory in a result set.
* The default maximum number of rows to be kept in memory in a result set.
*/
*/
public
static
final
int
MAX_MEMORY_ROWS
=
public
static
final
int
MAX_MEMORY_ROWS
=
getAutoScaledForMemoryProperty
(
"h2.maxMemoryRows"
,
40000
);
getAutoScaledForMemoryProperty
(
"h2.maxMemoryRows"
,
40
_
000
);
/**
/**
* System property <code>h2.maxTraceDataLength</code>
* System property <code>h2.maxTraceDataLength</code>
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/AggregateDataMedian.java
浏览文件 @
a51ece58
...
@@ -259,7 +259,7 @@ class AggregateDataMedian extends AggregateData {
...
@@ -259,7 +259,7 @@ class AggregateDataMedian extends AggregateData {
nanos
+=
DateTimeUtils
.
NANOS_PER_DAY
/
2
;
nanos
+=
DateTimeUtils
.
NANOS_PER_DAY
/
2
;
}
}
if
((
offset
&
1
)
!=
0
)
{
if
((
offset
&
1
)
!=
0
)
{
nanos
+=
30
L
*
1000000000
;
nanos
+=
30
_000_000_000L
;
}
}
if
(
nanos
>=
DateTimeUtils
.
NANOS_PER_DAY
)
{
if
(
nanos
>=
DateTimeUtils
.
NANOS_PER_DAY
)
{
nanos
-=
DateTimeUtils
.
NANOS_PER_DAY
;
nanos
-=
DateTimeUtils
.
NANOS_PER_DAY
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/Function.java
浏览文件 @
a51ece58
...
@@ -2234,10 +2234,10 @@ public class Function extends Expression implements FunctionCall {
...
@@ -2234,10 +2234,10 @@ public class Function extends Expression implements FunctionCall {
}
}
private
static
double
roundMagic
(
double
d
)
{
private
static
double
roundMagic
(
double
d
)
{
if
((
d
<
0.000
0000000001
)
&&
(
d
>
-
0.000000000000
1
))
{
if
((
d
<
0.000
_000_000_000_1
)
&&
(
d
>
-
0.000_000_000_000_
1
))
{
return
0.0
;
return
0.0
;
}
}
if
((
d
>
1
000000000000
.)
||
(
d
<
-
1000000000000
.
))
{
if
((
d
>
1
_000_000_000_000
d
)
||
(
d
<
-
1_000_000_000_000
d
))
{
return
d
;
return
d
;
}
}
StringBuilder
s
=
new
StringBuilder
();
StringBuilder
s
=
new
StringBuilder
();
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/IndexCondition.java
浏览文件 @
a51ece58
...
@@ -155,8 +155,7 @@ public class IndexCondition {
...
@@ -155,8 +155,7 @@ public class IndexCondition {
v
=
column
.
convert
(
v
);
v
=
column
.
convert
(
v
);
valueSet
.
add
(
v
);
valueSet
.
add
(
v
);
}
}
Value
[]
array
=
new
Value
[
valueSet
.
size
()];
Value
[]
array
=
valueSet
.
toArray
(
new
Value
[
valueSet
.
size
()]);
valueSet
.
toArray
(
array
);
final
CompareMode
mode
=
session
.
getDatabase
().
getCompareMode
();
final
CompareMode
mode
=
session
.
getDatabase
().
getCompareMode
();
Arrays
.
sort
(
array
,
new
Comparator
<
Value
>()
{
Arrays
.
sort
(
array
,
new
Comparator
<
Value
>()
{
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/index/PageDataIndex.java
浏览文件 @
a51ece58
...
@@ -143,7 +143,7 @@ public class PageDataIndex extends PageIndex {
...
@@ -143,7 +143,7 @@ public class PageDataIndex extends PageIndex {
if
(
add
==
0
)
{
if
(
add
==
0
)
{
// in the first re-try add a small random number,
// in the first re-try add a small random number,
// to avoid collisions after a re-start
// to avoid collisions after a re-start
row
.
setKey
((
long
)
(
row
.
getKey
()
+
Math
.
random
()
*
10000
));
row
.
setKey
((
long
)
(
row
.
getKey
()
+
Math
.
random
()
*
10
_
000
));
}
else
{
}
else
{
row
.
setKey
(
row
.
getKey
()
+
add
);
row
.
setKey
(
row
.
getKey
()
+
add
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/FileStore.java
浏览文件 @
a51ece58
...
@@ -314,7 +314,7 @@ public class FileStore {
...
@@ -314,7 +314,7 @@ public class FileStore {
* @return the retention time
* @return the retention time
*/
*/
public
int
getDefaultRetentionTime
()
{
public
int
getDefaultRetentionTime
()
{
return
45000
;
return
45
_
000
;
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
a51ece58
...
@@ -141,7 +141,7 @@ public final class MVStore {
...
@@ -141,7 +141,7 @@ public final class MVStore {
* Used to mark a chunk as free, when it was detected that live bookkeeping
* Used to mark a chunk as free, when it was detected that live bookkeeping
* is incorrect.
* is incorrect.
*/
*/
private
static
final
int
MARKED_FREE
=
10
000
000
;
private
static
final
int
MARKED_FREE
=
10
_000_
000
;
/**
/**
* The background thread, if any.
* The background thread, if any.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/mvstore/type/ObjectDataType.java
浏览文件 @
a51ece58
...
@@ -1479,7 +1479,7 @@ public class ObjectDataType implements DataType {
...
@@ -1479,7 +1479,7 @@ public class ObjectDataType implements DataType {
*/
*/
static
class
SerializedObjectType
extends
AutoDetectDataType
{
static
class
SerializedObjectType
extends
AutoDetectDataType
{
private
int
averageSize
=
10000
;
private
int
averageSize
=
10
_
000
;
SerializedObjectType
(
ObjectDataType
base
)
{
SerializedObjectType
(
ObjectDataType
base
)
{
super
(
base
,
TYPE_SERIALIZED_OBJECT
);
super
(
base
,
TYPE_SERIALIZED_OBJECT
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/WebApp.java
浏览文件 @
a51ece58
...
@@ -1775,7 +1775,7 @@ public class WebApp {
...
@@ -1775,7 +1775,7 @@ public class WebApp {
String
d
=
rs
.
getString
(
columnIndex
);
String
d
=
rs
.
getString
(
columnIndex
);
if
(
d
==
null
)
{
if
(
d
==
null
)
{
return
"<i>null</i>"
;
return
"<i>null</i>"
;
}
else
if
(
d
.
length
()
>
100000
)
{
}
else
if
(
d
.
length
()
>
100
_
000
)
{
String
s
;
String
s
;
if
(
isBinary
(
rs
.
getMetaData
().
getColumnType
(
columnIndex
)))
{
if
(
isBinary
(
rs
.
getMetaData
().
getColumnType
(
columnIndex
)))
{
s
=
PageParser
.
escapeHtml
(
d
.
substring
(
0
,
6
))
+
s
=
PageParser
.
escapeHtml
(
d
.
substring
(
0
,
6
))
+
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/Data.java
浏览文件 @
a51ece58
...
@@ -491,8 +491,8 @@ public class Data {
...
@@ -491,8 +491,8 @@ public class Data {
writeByte
((
byte
)
LOCAL_TIME
);
writeByte
((
byte
)
LOCAL_TIME
);
ValueTime
t
=
(
ValueTime
)
v
;
ValueTime
t
=
(
ValueTime
)
v
;
long
nanos
=
t
.
getNanos
();
long
nanos
=
t
.
getNanos
();
long
millis
=
nanos
/
1
000
000
;
long
millis
=
nanos
/
1
_000_
000
;
nanos
-=
millis
*
1
000
000
;
nanos
-=
millis
*
1
_000_
000
;
writeVarLong
(
millis
);
writeVarLong
(
millis
);
writeVarLong
(
nanos
);
writeVarLong
(
nanos
);
}
else
{
}
else
{
...
@@ -519,15 +519,15 @@ public class Data {
...
@@ -519,15 +519,15 @@ public class Data {
long
dateValue
=
ts
.
getDateValue
();
long
dateValue
=
ts
.
getDateValue
();
writeVarLong
(
dateValue
);
writeVarLong
(
dateValue
);
long
nanos
=
ts
.
getTimeNanos
();
long
nanos
=
ts
.
getTimeNanos
();
long
millis
=
nanos
/
1
000
000
;
long
millis
=
nanos
/
1
_000_
000
;
nanos
-=
millis
*
1
000
000
;
nanos
-=
millis
*
1
_000_
000
;
writeVarLong
(
millis
);
writeVarLong
(
millis
);
writeVarLong
(
nanos
);
writeVarLong
(
nanos
);
}
else
{
}
else
{
Timestamp
ts
=
v
.
getTimestamp
();
Timestamp
ts
=
v
.
getTimestamp
();
writeByte
((
byte
)
type
);
writeByte
((
byte
)
type
);
writeVarLong
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
ts
));
writeVarLong
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
ts
));
writeVarInt
(
ts
.
getNanos
()
%
1
000
000
);
writeVarInt
(
ts
.
getNanos
()
%
1
_000_
000
);
}
}
break
;
break
;
}
}
...
@@ -758,7 +758,7 @@ public class Data {
...
@@ -758,7 +758,7 @@ public class Data {
return
ValueDate
.
fromMillis
(
DateTimeUtils
.
getTimeUTCWithoutDst
(
x
));
return
ValueDate
.
fromMillis
(
DateTimeUtils
.
getTimeUTCWithoutDst
(
x
));
}
}
case
LOCAL_TIME:
{
case
LOCAL_TIME:
{
long
nanos
=
readVarLong
()
*
1
000
000
+
readVarLong
();
long
nanos
=
readVarLong
()
*
1
_000_
000
+
readVarLong
();
return
ValueTime
.
fromNanos
(
nanos
);
return
ValueTime
.
fromNanos
(
nanos
);
}
}
case
Value
.
TIME
:
case
Value
.
TIME
:
...
@@ -767,7 +767,7 @@ public class Data {
...
@@ -767,7 +767,7 @@ public class Data {
DateTimeUtils
.
getTimeUTCWithoutDst
(
readVarLong
()));
DateTimeUtils
.
getTimeUTCWithoutDst
(
readVarLong
()));
case
LOCAL_TIMESTAMP:
{
case
LOCAL_TIMESTAMP:
{
long
dateValue
=
readVarLong
();
long
dateValue
=
readVarLong
();
long
nanos
=
readVarLong
()
*
1
000
000
+
readVarLong
();
long
nanos
=
readVarLong
()
*
1
_000_
000
+
readVarLong
();
return
ValueTimestamp
.
fromDateValueAndNanos
(
dateValue
,
nanos
);
return
ValueTimestamp
.
fromDateValueAndNanos
(
dateValue
,
nanos
);
}
}
case
Value
.
TIMESTAMP
:
{
case
Value
.
TIMESTAMP
:
{
...
@@ -1003,8 +1003,8 @@ public class Data {
...
@@ -1003,8 +1003,8 @@ public class Data {
case
Value
.
TIME
:
case
Value
.
TIME
:
if
(
STORE_LOCAL_TIME
)
{
if
(
STORE_LOCAL_TIME
)
{
long
nanos
=
((
ValueTime
)
v
).
getNanos
();
long
nanos
=
((
ValueTime
)
v
).
getNanos
();
long
millis
=
nanos
/
1
000
000
;
long
millis
=
nanos
/
1
_000_
000
;
nanos
-=
millis
*
1
000
000
;
nanos
-=
millis
*
1
_000_
000
;
return
1
+
getVarLongLen
(
millis
)
+
getVarLongLen
(
nanos
);
return
1
+
getVarLongLen
(
millis
)
+
getVarLongLen
(
nanos
);
}
}
return
1
+
getVarLongLen
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
v
.
getTime
()));
return
1
+
getVarLongLen
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
v
.
getTime
()));
...
@@ -1021,14 +1021,14 @@ public class Data {
...
@@ -1021,14 +1021,14 @@ public class Data {
ValueTimestamp
ts
=
(
ValueTimestamp
)
v
;
ValueTimestamp
ts
=
(
ValueTimestamp
)
v
;
long
dateValue
=
ts
.
getDateValue
();
long
dateValue
=
ts
.
getDateValue
();
long
nanos
=
ts
.
getTimeNanos
();
long
nanos
=
ts
.
getTimeNanos
();
long
millis
=
nanos
/
1
000
000
;
long
millis
=
nanos
/
1
_000_
000
;
nanos
-=
millis
*
1
000
000
;
nanos
-=
millis
*
1
_000_
000
;
return
1
+
getVarLongLen
(
dateValue
)
+
getVarLongLen
(
millis
)
+
return
1
+
getVarLongLen
(
dateValue
)
+
getVarLongLen
(
millis
)
+
getVarLongLen
(
nanos
);
getVarLongLen
(
nanos
);
}
}
Timestamp
ts
=
v
.
getTimestamp
();
Timestamp
ts
=
v
.
getTimestamp
();
return
1
+
getVarLongLen
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
ts
))
+
return
1
+
getVarLongLen
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
ts
))
+
getVarIntLen
(
ts
.
getNanos
()
%
1
000
000
);
getVarIntLen
(
ts
.
getNanos
()
%
1
_000_
000
);
}
}
case
Value
.
TIMESTAMP_TZ
:
{
case
Value
.
TIMESTAMP_TZ
:
{
ValueTimestampTimeZone
ts
=
(
ValueTimestampTimeZone
)
v
;
ValueTimestampTimeZone
ts
=
(
ValueTimestampTimeZone
)
v
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/LobStorageBackend.java
浏览文件 @
a51ece58
...
@@ -78,7 +78,7 @@ public class LobStorageBackend implements LobStorageInterface {
...
@@ -78,7 +78,7 @@ public class LobStorageBackend implements LobStorageInterface {
/**
/**
* The size of the chunks we use when storing LOBs inside the database file.
* The size of the chunks we use when storing LOBs inside the database file.
*/
*/
private
static
final
int
BLOCK_LENGTH
=
20000
;
private
static
final
int
BLOCK_LENGTH
=
20
_
000
;
/**
/**
* The size of cache for lob block hashes. Each entry needs 2 longs (16
* The size of cache for lob block hashes. Each entry needs 2 longs (16
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/fs/FilePathNioMapped.java
浏览文件 @
a51ece58
...
@@ -44,7 +44,7 @@ public class FilePathNioMapped extends FilePathNio {
...
@@ -44,7 +44,7 @@ public class FilePathNioMapped extends FilePathNio {
*/
*/
class
FileNioMapped
extends
FileBase
{
class
FileNioMapped
extends
FileBase
{
private
static
final
long
GC_TIMEOUT_MS
=
10000
;
private
static
final
long
GC_TIMEOUT_MS
=
10
_
000
;
private
final
String
name
;
private
final
String
name
;
private
final
MapMode
mode
;
private
final
MapMode
mode
;
private
RandomAccessFile
file
;
private
RandomAccessFile
file
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/table/TableLink.java
浏览文件 @
a51ece58
...
@@ -47,7 +47,7 @@ public class TableLink extends Table {
...
@@ -47,7 +47,7 @@ public class TableLink extends Table {
private
static
final
int
MAX_RETRY
=
2
;
private
static
final
int
MAX_RETRY
=
2
;
private
static
final
long
ROW_COUNT_APPROXIMATION
=
100000
;
private
static
final
long
ROW_COUNT_APPROXIMATION
=
100
_
000
;
private
final
String
originalSchema
;
private
final
String
originalSchema
;
private
String
driver
,
url
,
user
,
password
,
originalTable
,
qualifiedTableName
;
private
String
driver
,
url
,
user
,
password
,
originalTable
,
qualifiedTableName
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/CompressTool.java
浏览文件 @
a51ece58
...
@@ -181,13 +181,13 @@ public class CompressTool {
...
@@ -181,13 +181,13 @@ public class CompressTool {
buff
[
pos
++]
=
(
byte
)
(
0x80
|
(
x
>>
8
));
buff
[
pos
++]
=
(
byte
)
(
0x80
|
(
x
>>
8
));
buff
[
pos
]
=
(
byte
)
x
;
buff
[
pos
]
=
(
byte
)
x
;
return
2
;
return
2
;
}
else
if
(
x
<
0x200000
)
{
}
else
if
(
x
<
0x20
_
0000
)
{
buff
[
pos
++]
=
(
byte
)
(
0xc0
|
(
x
>>
16
));
buff
[
pos
++]
=
(
byte
)
(
0xc0
|
(
x
>>
16
));
buff
[
pos
++]
=
(
byte
)
(
x
>>
8
);
buff
[
pos
++]
=
(
byte
)
(
x
>>
8
);
buff
[
pos
]
=
(
byte
)
x
;
buff
[
pos
]
=
(
byte
)
x
;
return
3
;
return
3
;
}
else
if
(
x
<
0x10000000
)
{
}
else
if
(
x
<
0x1000
_
0000
)
{
Bits
.
writeInt
(
buff
,
pos
,
x
|
0xe0000000
);
Bits
.
writeInt
(
buff
,
pos
,
x
|
0xe000
_
0000
);
return
4
;
return
4
;
}
else
{
}
else
{
buff
[
pos
++]
=
(
byte
)
0xf0
;
buff
[
pos
++]
=
(
byte
)
0xf0
;
...
@@ -210,9 +210,9 @@ public class CompressTool {
...
@@ -210,9 +210,9 @@ public class CompressTool {
return
1
;
return
1
;
}
else
if
(
x
<
0x4000
)
{
}
else
if
(
x
<
0x4000
)
{
return
2
;
return
2
;
}
else
if
(
x
<
0x200000
)
{
}
else
if
(
x
<
0x20
_
0000
)
{
return
3
;
return
3
;
}
else
if
(
x
<
0x10000000
)
{
}
else
if
(
x
<
0x1000
_
0000
)
{
return
4
;
return
4
;
}
else
{
}
else
{
return
5
;
return
5
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/Bits.java
浏览文件 @
a51ece58
...
@@ -20,6 +20,68 @@ public final class Bits {
...
@@ -20,6 +20,68 @@ public final class Bits {
* h2/src/java9/precompiled/org/h2/util/Bits.class.
* h2/src/java9/precompiled/org/h2/util/Bits.class.
*/
*/
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the content
* or length of the second array is smaller than the first array, 1 is returned.
* If the contents and lengths are the same, 0 is returned.
*
* <p>
* This method interprets bytes as signed.
* </p>
*
* @param data1
* the first byte array (must not be null)
* @param data2
* the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public
static
int
compareNotNullSigned
(
byte
[]
data1
,
byte
[]
data2
)
{
if
(
data1
==
data2
)
{
return
0
;
}
int
len
=
Math
.
min
(
data1
.
length
,
data2
.
length
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
byte
b
=
data1
[
i
];
byte
b2
=
data2
[
i
];
if
(
b
!=
b2
)
{
return
b
>
b2
?
1
:
-
1
;
}
}
return
Integer
.
signum
(
data1
.
length
-
data2
.
length
);
}
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the content
* or length of the second array is smaller than the first array, 1 is returned.
* If the contents and lengths are the same, 0 is returned.
*
* <p>
* This method interprets bytes as unsigned.
* </p>
*
* @param data1
* the first byte array (must not be null)
* @param data2
* the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public
static
int
compareNotNullUnsigned
(
byte
[]
data1
,
byte
[]
data2
)
{
if
(
data1
==
data2
)
{
return
0
;
}
int
len
=
Math
.
min
(
data1
.
length
,
data2
.
length
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
b
=
data1
[
i
]
&
0xff
;
int
b2
=
data2
[
i
]
&
0xff
;
if
(
b
!=
b2
)
{
return
b
>
b2
?
1
:
-
1
;
}
}
return
Integer
.
signum
(
data1
.
length
-
data2
.
length
);
}
/**
/**
* Reads a int value from the byte array at the given position in big-endian
* Reads a int value from the byte array at the given position in big-endian
* order.
* order.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/DateTimeUtils.java
浏览文件 @
a51ece58
...
@@ -50,7 +50,7 @@ public class DateTimeUtils {
...
@@ -50,7 +50,7 @@ public class DateTimeUtils {
/**
/**
* The number of nanoseconds per day.
* The number of nanoseconds per day.
*/
*/
public
static
final
long
NANOS_PER_DAY
=
MILLIS_PER_DAY
*
1
000
000
;
public
static
final
long
NANOS_PER_DAY
=
MILLIS_PER_DAY
*
1
_000_
000
;
private
static
final
int
SHIFT_YEAR
=
9
;
private
static
final
int
SHIFT_YEAR
=
9
;
private
static
final
int
SHIFT_MONTH
=
5
;
private
static
final
int
SHIFT_MONTH
=
5
;
...
@@ -229,10 +229,10 @@ public class DateTimeUtils {
...
@@ -229,10 +229,10 @@ public class DateTimeUtils {
cal
.
clear
();
cal
.
clear
();
cal
.
setLenient
(
true
);
cal
.
setLenient
(
true
);
long
nanos
=
t
.
getNanos
();
long
nanos
=
t
.
getNanos
();
long
millis
=
nanos
/
1
000
000
;
long
millis
=
nanos
/
1
_000_
000
;
nanos
-=
millis
*
1
000
000
;
nanos
-=
millis
*
1
_000_
000
;
long
s
=
millis
/
1000
;
long
s
=
millis
/
1
_
000
;
millis
-=
s
*
1000
;
millis
-=
s
*
1
_
000
;
long
m
=
s
/
60
;
long
m
=
s
/
60
;
s
-=
m
*
60
;
s
-=
m
*
60
;
long
h
=
m
/
60
;
long
h
=
m
/
60
;
...
@@ -257,10 +257,10 @@ public class DateTimeUtils {
...
@@ -257,10 +257,10 @@ public class DateTimeUtils {
cal
.
setLenient
(
true
);
cal
.
setLenient
(
true
);
long
dateValue
=
ts
.
getDateValue
();
long
dateValue
=
ts
.
getDateValue
();
long
nanos
=
ts
.
getTimeNanos
();
long
nanos
=
ts
.
getTimeNanos
();
long
millis
=
nanos
/
1
000
000
;
long
millis
=
nanos
/
1
_000_
000
;
nanos
-=
millis
*
1
000
000
;
nanos
-=
millis
*
1
_000_
000
;
long
s
=
millis
/
1000
;
long
s
=
millis
/
1
_
000
;
millis
-=
s
*
1000
;
millis
-=
s
*
1
_
000
;
long
m
=
s
/
60
;
long
m
=
s
/
60
;
s
-=
m
*
60
;
s
-=
m
*
60
;
long
h
=
m
/
60
;
long
h
=
m
/
60
;
...
@@ -269,7 +269,7 @@ public class DateTimeUtils {
...
@@ -269,7 +269,7 @@ public class DateTimeUtils {
monthFromDateValue
(
dateValue
),
dayFromDateValue
(
dateValue
),
monthFromDateValue
(
dateValue
),
dayFromDateValue
(
dateValue
),
(
int
)
h
,
(
int
)
m
,
(
int
)
s
,
(
int
)
millis
);
(
int
)
h
,
(
int
)
m
,
(
int
)
s
,
(
int
)
millis
);
Timestamp
x
=
new
Timestamp
(
ms
);
Timestamp
x
=
new
Timestamp
(
ms
);
x
.
setNanos
((
int
)
(
nanos
+
millis
*
1
000
000
));
x
.
setNanos
((
int
)
(
nanos
+
millis
*
1
_000_
000
));
return
x
;
return
x
;
}
}
...
@@ -323,7 +323,7 @@ public class DateTimeUtils {
...
@@ -323,7 +323,7 @@ public class DateTimeUtils {
cal
.
setTimeInMillis
(
x
.
getTime
());
cal
.
setTimeInMillis
(
x
.
getTime
());
long
dateValue
=
dateValueFromCalendar
(
cal
);
long
dateValue
=
dateValueFromCalendar
(
cal
);
long
nanos
=
nanosFromCalendar
(
cal
);
long
nanos
=
nanosFromCalendar
(
cal
);
nanos
+=
x
.
getNanos
()
%
1
000
000
;
nanos
+=
x
.
getNanos
()
%
1
_000_
000
;
return
ValueTimestamp
.
fromDateValueAndNanos
(
dateValue
,
nanos
);
return
ValueTimestamp
.
fromDateValueAndNanos
(
dateValue
,
nanos
);
}
}
...
@@ -408,14 +408,14 @@ public class DateTimeUtils {
...
@@ -408,14 +408,14 @@ public class DateTimeUtils {
String
n
=
(
s
.
substring
(
s3
+
1
,
end
)
+
"000000000"
).
substring
(
0
,
9
);
String
n
=
(
s
.
substring
(
s3
+
1
,
end
)
+
"000000000"
).
substring
(
0
,
9
);
nanos
=
Integer
.
parseInt
(
n
);
nanos
=
Integer
.
parseInt
(
n
);
}
}
if
(
hour
>=
2
000
000
||
minute
<
0
||
minute
>=
60
||
second
<
0
if
(
hour
>=
2
_000_
000
||
minute
<
0
||
minute
>=
60
||
second
<
0
||
second
>=
60
)
{
||
second
>=
60
)
{
throw
new
IllegalArgumentException
(
s
);
throw
new
IllegalArgumentException
(
s
);
}
}
if
(
timeOfDay
&&
hour
>=
24
)
{
if
(
timeOfDay
&&
hour
>=
24
)
{
throw
new
IllegalArgumentException
(
s
);
throw
new
IllegalArgumentException
(
s
);
}
}
nanos
+=
((((
hour
*
60L
)
+
minute
)
*
60
)
+
second
)
*
1
000000
000
;
nanos
+=
((((
hour
*
60L
)
+
minute
)
*
60
)
+
second
)
*
1
_000_000_
000
;
return
negative
?
-
nanos
:
nanos
;
return
negative
?
-
nanos
:
nanos
;
}
}
...
@@ -507,13 +507,13 @@ public class DateTimeUtils {
...
@@ -507,13 +507,13 @@ public class DateTimeUtils {
if
(
tz
!=
null
)
{
if
(
tz
!=
null
)
{
if
(
withTimeZone
)
{
if
(
withTimeZone
)
{
if
(
tz
!=
UTC
)
{
if
(
tz
!=
UTC
)
{
long
millis
=
convertDateTimeValueToMillis
(
tz
,
dateValue
,
nanos
/
1
000
000
);
long
millis
=
convertDateTimeValueToMillis
(
tz
,
dateValue
,
nanos
/
1
_000_
000
);
tzMinutes
=
(
short
)
(
tz
.
getOffset
(
millis
)
/
1000
/
60
);
tzMinutes
=
(
short
)
(
tz
.
getOffset
(
millis
)
/
1000
/
60
);
}
}
}
else
{
}
else
{
long
millis
=
convertDateTimeValueToMillis
(
tz
,
dateValue
,
nanos
/
1
000
000
);
long
millis
=
convertDateTimeValueToMillis
(
tz
,
dateValue
,
nanos
/
1
_000_
000
);
dateValue
=
dateValueFromDate
(
millis
);
dateValue
=
dateValueFromDate
(
millis
);
nanos
=
nanos
%
1
000
000
+
nanosFromDate
(
millis
);
nanos
=
nanos
%
1
_000_
000
+
nanosFromDate
(
millis
);
}
}
}
}
}
}
...
@@ -1031,9 +1031,9 @@ public class DateTimeUtils {
...
@@ -1031,9 +1031,9 @@ public class DateTimeUtils {
* @return the time
* @return the time
*/
*/
public
static
Time
convertNanoToTime
(
long
nanosSinceMidnight
)
{
public
static
Time
convertNanoToTime
(
long
nanosSinceMidnight
)
{
long
millis
=
nanosSinceMidnight
/
1
000
000
;
long
millis
=
nanosSinceMidnight
/
1
_000_
000
;
long
s
=
millis
/
1000
;
long
s
=
millis
/
1
_
000
;
millis
-=
s
*
1000
;
millis
-=
s
*
1
_
000
;
long
m
=
s
/
60
;
long
m
=
s
/
60
;
s
-=
m
*
60
;
s
-=
m
*
60
;
long
h
=
m
/
60
;
long
h
=
m
/
60
;
...
@@ -1246,7 +1246,7 @@ public class DateTimeUtils {
...
@@ -1246,7 +1246,7 @@ public class DateTimeUtils {
y
--;
y
--;
m
+=
12
;
m
+=
12
;
}
}
long
a
=
((
y
*
2922L
)
>>
3
)
+
DAYS_OFFSET
[
m
-
3
]
+
d
-
719484
;
long
a
=
((
y
*
2922L
)
>>
3
)
+
DAYS_OFFSET
[
m
-
3
]
+
d
-
719
_
484
;
if
(
y
<=
1582
&&
((
y
<
1582
)
||
(
m
*
100
+
d
<
1015
)))
{
if
(
y
<=
1582
&&
((
y
<
1582
)
||
(
m
*
100
+
d
<
1015
)))
{
// Julian calendar (cutover at 1582-10-04 / 1582-10-15)
// Julian calendar (cutover at 1582-10-04 / 1582-10-15)
a
+=
13
;
a
+=
13
;
...
@@ -1272,7 +1272,7 @@ public class DateTimeUtils {
...
@@ -1272,7 +1272,7 @@ public class DateTimeUtils {
y
--;
y
--;
m
+=
12
;
m
+=
12
;
}
}
long
a
=
((
y
*
2922L
)
>>
3
)
+
DAYS_OFFSET
[
m
-
3
]
+
d
-
719484
;
long
a
=
((
y
*
2922L
)
>>
3
)
+
DAYS_OFFSET
[
m
-
3
]
+
d
-
719
_
484
;
if
(
y
<
1901
||
y
>
2099
)
{
if
(
y
<
1901
||
y
>
2099
)
{
// Slow mode
// Slow mode
a
+=
(
y
/
400
)
-
(
y
/
100
)
+
15
;
a
+=
(
y
/
400
)
-
(
y
/
100
)
+
15
;
...
@@ -1287,19 +1287,19 @@ public class DateTimeUtils {
...
@@ -1287,19 +1287,19 @@ public class DateTimeUtils {
* @return the date value
* @return the date value
*/
*/
public
static
long
dateValueFromAbsoluteDay
(
long
absoluteDay
)
{
public
static
long
dateValueFromAbsoluteDay
(
long
absoluteDay
)
{
long
d
=
absoluteDay
+
719468
;
long
d
=
absoluteDay
+
719
_
468
;
long
y100
=
0
,
offset
;
long
y100
=
0
,
offset
;
if
(
d
>
578040
)
{
if
(
d
>
578
_
040
)
{
// Gregorian calendar
// Gregorian calendar
long
y400
=
d
/
146097
;
long
y400
=
d
/
146
_
097
;
d
-=
y400
*
146097
;
d
-=
y400
*
146
_
097
;
y100
=
d
/
36524
;
y100
=
d
/
36
_
524
;
d
-=
y100
*
36524
;
d
-=
y100
*
36
_
524
;
offset
=
y400
*
400
+
y100
*
100
;
offset
=
y400
*
400
+
y100
*
100
;
}
else
{
}
else
{
// Julian calendar
// Julian calendar
d
+=
292
200000
002L
;
d
+=
292
_200_000_
002L
;
offset
=
-
800
000
000
;
offset
=
-
800
_000_
000
;
}
}
long
y4
=
d
/
1461
;
long
y4
=
d
/
1461
;
d
-=
y4
*
1461
;
d
-=
y4
*
1461
;
...
@@ -1330,7 +1330,7 @@ public class DateTimeUtils {
...
@@ -1330,7 +1330,7 @@ public class DateTimeUtils {
int
y
=
yearFromDateValue
(
dateValue
);
int
y
=
yearFromDateValue
(
dateValue
);
int
m
=
monthFromDateValue
(
dateValue
);
int
m
=
monthFromDateValue
(
dateValue
);
int
d
=
dayFromDateValue
(
dateValue
);
int
d
=
dayFromDateValue
(
dateValue
);
if
(
y
>
0
&&
y
<
10000
)
{
if
(
y
>
0
&&
y
<
10
_
000
)
{
StringUtils
.
appendZeroPadded
(
buff
,
4
,
y
);
StringUtils
.
appendZeroPadded
(
buff
,
4
,
y
);
}
else
{
}
else
{
buff
.
append
(
y
);
buff
.
append
(
y
);
...
@@ -1358,10 +1358,10 @@ public class DateTimeUtils {
...
@@ -1358,10 +1358,10 @@ public class DateTimeUtils {
* get correct result. The simplest way to do this with such constraints is to
* get correct result. The simplest way to do this with such constraints is to
* divide -nanos by -1000000.
* divide -nanos by -1000000.
*/
*/
long
ms
=
-
nanos
/
-
1
000
000
;
long
ms
=
-
nanos
/
-
1
_000_
000
;
nanos
-=
ms
*
1
000
000
;
nanos
-=
ms
*
1
_000_
000
;
long
s
=
ms
/
1000
;
long
s
=
ms
/
1
_
000
;
ms
-=
s
*
1000
;
ms
-=
s
*
1
_
000
;
long
m
=
s
/
60
;
long
m
=
s
/
60
;
s
-=
m
*
60
;
s
-=
m
*
60
;
long
h
=
m
/
60
;
long
h
=
m
/
60
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/MathUtils.java
浏览文件 @
a51ece58
...
@@ -224,7 +224,7 @@ public class MathUtils {
...
@@ -224,7 +224,7 @@ public class MathUtils {
public
static
int
nextPowerOf2
(
int
x
)
throws
IllegalArgumentException
{
public
static
int
nextPowerOf2
(
int
x
)
throws
IllegalArgumentException
{
if
(
x
==
0
)
{
if
(
x
==
0
)
{
return
1
;
return
1
;
}
else
if
(
x
<
0
||
x
>
0x40000000
)
{
}
else
if
(
x
<
0
||
x
>
0x4000
_
0000
)
{
throw
new
IllegalArgumentException
(
"Argument out of range"
throw
new
IllegalArgumentException
(
"Argument out of range"
+
" [0x0-0x40000000]. Argument was: "
+
x
);
+
" [0x0-0x40000000]. Argument was: "
+
x
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/ThreadDeadlockDetector.java
浏览文件 @
a51ece58
...
@@ -44,7 +44,7 @@ public class ThreadDeadlockDetector {
...
@@ -44,7 +44,7 @@ public class ThreadDeadlockDetector {
public
void
run
()
{
public
void
run
()
{
checkForDeadlocks
();
checkForDeadlocks
();
}
}
},
10
,
10000
);
},
10
,
10
_
000
);
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/ToDateParser.java
浏览文件 @
a51ece58
...
@@ -126,8 +126,8 @@ public class ToDateParser {
...
@@ -126,8 +126,8 @@ public class ToDateParser {
if
(
timeZone
==
null
)
{
if
(
timeZone
==
null
)
{
timeZone
=
TimeZone
.
getDefault
();
timeZone
=
TimeZone
.
getDefault
();
}
}
long
millis
=
DateTimeUtils
.
convertDateTimeValueToMillis
(
timeZone
,
dateValue
,
nanos
/
1
000
000
);
long
millis
=
DateTimeUtils
.
convertDateTimeValueToMillis
(
timeZone
,
dateValue
,
nanos
/
1
_000_
000
);
offset
=
(
short
)
(
timeZone
.
getOffset
(
millis
)
/
1000
/
6
0
);
offset
=
(
short
)
(
timeZone
.
getOffset
(
millis
)
/
60_00
0
);
}
}
return
ValueTimestampTimeZone
.
fromDateValueAndNanos
(
dateValue
,
ts
.
getTimeNanos
(),
offset
);
return
ValueTimestampTimeZone
.
fromDateValueAndNanos
(
dateValue
,
ts
.
getTimeNanos
(),
offset
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/Utils.java
浏览文件 @
a51ece58
...
@@ -138,60 +138,6 @@ public class Utils {
...
@@ -138,60 +138,6 @@ public class Utils {
return
bits
==
0
;
return
bits
==
0
;
}
}
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the
* content or length of the second array is smaller than the first array, 1
* is returned. If the contents and lengths are the same, 0 is returned.
* <p>
* This method interprets bytes as signed.
*
* @param data1 the first byte array (must not be null)
* @param data2 the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public
static
int
compareNotNullSigned
(
byte
[]
data1
,
byte
[]
data2
)
{
if
(
data1
==
data2
)
{
return
0
;
}
int
len
=
Math
.
min
(
data1
.
length
,
data2
.
length
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
byte
b
=
data1
[
i
];
byte
b2
=
data2
[
i
];
if
(
b
!=
b2
)
{
return
b
>
b2
?
1
:
-
1
;
}
}
return
Integer
.
signum
(
data1
.
length
-
data2
.
length
);
}
/**
* Compare the contents of two byte arrays. If the content or length of the
* first array is smaller than the second array, -1 is returned. If the
* content or length of the second array is smaller than the first array, 1
* is returned. If the contents and lengths are the same, 0 is returned.
* <p>
* This method interprets bytes as unsigned.
*
* @param data1 the first byte array (must not be null)
* @param data2 the second byte array (must not be null)
* @return the result of the comparison (-1, 1 or 0)
*/
public
static
int
compareNotNullUnsigned
(
byte
[]
data1
,
byte
[]
data2
)
{
if
(
data1
==
data2
)
{
return
0
;
}
int
len
=
Math
.
min
(
data1
.
length
,
data2
.
length
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
b
=
data1
[
i
]
&
0xff
;
int
b2
=
data2
[
i
]
&
0xff
;
if
(
b
!=
b2
)
{
return
b
>
b2
?
1
:
-
1
;
}
}
return
Integer
.
signum
(
data1
.
length
-
data2
.
length
);
}
/**
/**
* Copy the contents of the source array to the target array. If the size if
* Copy the contents of the source array to the target array. If the size if
* the target array is too small, a larger array is created.
* the target array is too small, a larger array is created.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/Transfer.java
浏览文件 @
a51ece58
...
@@ -372,11 +372,11 @@ public class Transfer {
...
@@ -372,11 +372,11 @@ public class Transfer {
}
else
if
(
version
>=
Constants
.
TCP_PROTOCOL_VERSION_7
)
{
}
else
if
(
version
>=
Constants
.
TCP_PROTOCOL_VERSION_7
)
{
Timestamp
ts
=
v
.
getTimestamp
();
Timestamp
ts
=
v
.
getTimestamp
();
writeLong
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
ts
));
writeLong
(
DateTimeUtils
.
getTimeLocalWithoutDst
(
ts
));
writeInt
(
ts
.
getNanos
()
%
1
000
000
);
writeInt
(
ts
.
getNanos
()
%
1
_000_
000
);
}
else
{
}
else
{
Timestamp
ts
=
v
.
getTimestamp
();
Timestamp
ts
=
v
.
getTimestamp
();
writeLong
(
ts
.
getTime
());
writeLong
(
ts
.
getTime
());
writeInt
(
ts
.
getNanos
()
%
1
000
000
);
writeInt
(
ts
.
getNanos
()
%
1
_000_
000
);
}
}
break
;
break
;
}
}
...
@@ -573,10 +573,10 @@ public class Transfer {
...
@@ -573,10 +573,10 @@ public class Transfer {
}
else
if
(
version
>=
Constants
.
TCP_PROTOCOL_VERSION_7
)
{
}
else
if
(
version
>=
Constants
.
TCP_PROTOCOL_VERSION_7
)
{
return
ValueTimestamp
.
fromMillisNanos
(
return
ValueTimestamp
.
fromMillisNanos
(
DateTimeUtils
.
getTimeUTCWithoutDst
(
readLong
()),
DateTimeUtils
.
getTimeUTCWithoutDst
(
readLong
()),
readInt
()
%
1
000
000
);
readInt
()
%
1
_000_
000
);
}
}
return
ValueTimestamp
.
fromMillisNanos
(
readLong
(),
return
ValueTimestamp
.
fromMillisNanos
(
readLong
(),
readInt
()
%
1
000
000
);
readInt
()
%
1
_000_
000
);
}
}
case
Value
.
TIMESTAMP_TZ
:
{
case
Value
.
TIMESTAMP_TZ
:
{
return
ValueTimestampTimeZone
.
fromDateValueAndNanos
(
readLong
(),
return
ValueTimestampTimeZone
.
fromDateValueAndNanos
(
readLong
(),
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueBytes.java
浏览文件 @
a51ece58
...
@@ -10,6 +10,7 @@ import java.sql.SQLException;
...
@@ -10,6 +10,7 @@ import java.sql.SQLException;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
org.h2.engine.SysProperties
;
import
org.h2.engine.SysProperties
;
import
org.h2.util.Bits
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Utils
;
import
org.h2.util.Utils
;
...
@@ -93,9 +94,9 @@ public class ValueBytes extends Value {
...
@@ -93,9 +94,9 @@ public class ValueBytes extends Value {
protected
int
compareSecure
(
Value
v
,
CompareMode
mode
)
{
protected
int
compareSecure
(
Value
v
,
CompareMode
mode
)
{
byte
[]
v2
=
((
ValueBytes
)
v
).
value
;
byte
[]
v2
=
((
ValueBytes
)
v
).
value
;
if
(
mode
.
isBinaryUnsigned
())
{
if
(
mode
.
isBinaryUnsigned
())
{
return
Util
s
.
compareNotNullUnsigned
(
value
,
v2
);
return
Bit
s
.
compareNotNullUnsigned
(
value
,
v2
);
}
}
return
Util
s
.
compareNotNullSigned
(
value
,
v2
);
return
Bit
s
.
compareNotNullSigned
(
value
,
v2
);
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueDecimal.java
浏览文件 @
a51ece58
...
@@ -48,7 +48,7 @@ public class ValueDecimal extends Value {
...
@@ -48,7 +48,7 @@ public class ValueDecimal extends Value {
/**
/**
* The maximum scale of a BigDecimal value.
* The maximum scale of a BigDecimal value.
*/
*/
private
static
final
int
BIG_DECIMAL_SCALE_MAX
=
100000
;
private
static
final
int
BIG_DECIMAL_SCALE_MAX
=
100
_
000
;
private
final
BigDecimal
value
;
private
final
BigDecimal
value
;
private
String
valueString
;
private
String
valueString
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueJavaObject.java
浏览文件 @
a51ece58
...
@@ -11,6 +11,7 @@ import java.sql.Types;
...
@@ -11,6 +11,7 @@ import java.sql.Types;
import
org.h2.engine.SysProperties
;
import
org.h2.engine.SysProperties
;
import
org.h2.store.DataHandler
;
import
org.h2.store.DataHandler
;
import
org.h2.util.Bits
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.Utils
;
import
org.h2.util.Utils
;
...
@@ -131,8 +132,7 @@ public class ValueJavaObject extends ValueBytes {
...
@@ -131,8 +132,7 @@ public class ValueJavaObject extends ValueBytes {
if
(
o1
.
equals
(
o2
))
{
if
(
o1
.
equals
(
o2
))
{
return
0
;
return
0
;
}
}
return
Bits
.
compareNotNullSigned
(
getBytesNoCopy
(),
v
.
getBytesNoCopy
());
return
Utils
.
compareNotNullSigned
(
getBytesNoCopy
(),
v
.
getBytesNoCopy
());
}
}
return
h1
>
h2
?
1
:
-
1
;
return
h1
>
h2
?
1
:
-
1
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
a51ece58
...
@@ -26,6 +26,7 @@ import org.h2.store.FileStoreOutputStream;
...
@@ -26,6 +26,7 @@ import org.h2.store.FileStoreOutputStream;
import
org.h2.store.RangeInputStream
;
import
org.h2.store.RangeInputStream
;
import
org.h2.store.RangeReader
;
import
org.h2.store.RangeReader
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.util.Bits
;
import
org.h2.util.IOUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.SmallLRUCache
;
import
org.h2.util.SmallLRUCache
;
...
@@ -674,7 +675,7 @@ public class ValueLob extends Value {
...
@@ -674,7 +675,7 @@ public class ValueLob extends Value {
return
Integer
.
signum
(
getString
().
compareTo
(
v
.
getString
()));
return
Integer
.
signum
(
getString
().
compareTo
(
v
.
getString
()));
}
}
byte
[]
v2
=
v
.
getBytesNoCopy
();
byte
[]
v2
=
v
.
getBytesNoCopy
();
return
Utils
.
compareNotNullSigned
(
getBytes
(),
v2
);
return
Bits
.
compareNotNullSigned
(
getBytesNoCopy
(),
v2
);
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueLobDb.java
浏览文件 @
a51ece58
...
@@ -27,6 +27,7 @@ import org.h2.store.LobStorageFrontend;
...
@@ -27,6 +27,7 @@ import org.h2.store.LobStorageFrontend;
import
org.h2.store.LobStorageInterface
;
import
org.h2.store.LobStorageInterface
;
import
org.h2.store.RangeReader
;
import
org.h2.store.RangeReader
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.util.Bits
;
import
org.h2.util.IOUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.StringUtils
;
import
org.h2.util.StringUtils
;
...
@@ -363,7 +364,7 @@ public class ValueLobDb extends Value implements Value.ValueClob,
...
@@ -363,7 +364,7 @@ public class ValueLobDb extends Value implements Value.ValueClob,
return
Integer
.
signum
(
getString
().
compareTo
(
v
.
getString
()));
return
Integer
.
signum
(
getString
().
compareTo
(
v
.
getString
()));
}
}
byte
[]
v2
=
v
.
getBytesNoCopy
();
byte
[]
v2
=
v
.
getBytesNoCopy
();
return
Utils
.
compareNotNullSigned
(
getBytes
(),
v2
);
return
Bits
.
compareNotNullSigned
(
getBytesNoCopy
(),
v2
);
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueTime.java
浏览文件 @
a51ece58
...
@@ -70,7 +70,7 @@ public class ValueTime extends Value {
...
@@ -70,7 +70,7 @@ public class ValueTime extends Value {
*/
*/
public
static
ValueTime
fromNanos
(
long
nanos
)
{
public
static
ValueTime
fromNanos
(
long
nanos
)
{
if
(!
SysProperties
.
UNLIMITED_TIME_RANGE
)
{
if
(!
SysProperties
.
UNLIMITED_TIME_RANGE
)
{
if
(
nanos
<
0L
||
nanos
>=
86400000000000L
)
{
if
(
nanos
<
0L
||
nanos
>=
DateTimeUtils
.
NANOS_PER_DAY
)
{
StringBuilder
builder
=
new
StringBuilder
();
StringBuilder
builder
=
new
StringBuilder
();
DateTimeUtils
.
appendTime
(
builder
,
nanos
);
DateTimeUtils
.
appendTime
(
builder
,
nanos
);
throw
DbException
.
get
(
ErrorCode
.
INVALID_DATETIME_CONSTANT_2
,
throw
DbException
.
get
(
ErrorCode
.
INVALID_DATETIME_CONSTANT_2
,
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueTimestamp.java
浏览文件 @
a51ece58
...
@@ -88,7 +88,7 @@ public class ValueTimestamp extends Value {
...
@@ -88,7 +88,7 @@ public class ValueTimestamp extends Value {
*/
*/
public
static
ValueTimestamp
get
(
Timestamp
timestamp
)
{
public
static
ValueTimestamp
get
(
Timestamp
timestamp
)
{
long
ms
=
timestamp
.
getTime
();
long
ms
=
timestamp
.
getTime
();
long
nanos
=
timestamp
.
getNanos
()
%
1
000
000
;
long
nanos
=
timestamp
.
getNanos
()
%
1
_000_
000
;
long
dateValue
=
DateTimeUtils
.
dateValueFromDate
(
ms
);
long
dateValue
=
DateTimeUtils
.
dateValueFromDate
(
ms
);
nanos
+=
DateTimeUtils
.
nanosFromDate
(
ms
);
nanos
+=
DateTimeUtils
.
nanosFromDate
(
ms
);
return
fromDateValueAndNanos
(
dateValue
,
nanos
);
return
fromDateValueAndNanos
(
dateValue
,
nanos
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueUuid.java
浏览文件 @
a51ece58
...
@@ -54,7 +54,7 @@ public class ValueUuid extends Value {
...
@@ -54,7 +54,7 @@ public class ValueUuid extends Value {
// version 4 (random)
// version 4 (random)
high
=
(
high
&
(~
0xf000
L
))
|
0x4000
L
;
high
=
(
high
&
(~
0xf000
L
))
|
0x4000
L
;
// variant (Leach-Salz)
// variant (Leach-Salz)
low
=
(
low
&
0x3fff
ffffffffffff
L
)
|
0x800000000000
0000
L
;
low
=
(
low
&
0x3fff
_ffff_ffff_ffff
L
)
|
0x8000_0000_0000_
0000
L
;
return
new
ValueUuid
(
high
,
low
);
return
new
ValueUuid
(
high
,
low
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/DirectInsert.java
浏览文件 @
a51ece58
...
@@ -30,7 +30,7 @@ public class DirectInsert {
...
@@ -30,7 +30,7 @@ public class DirectInsert {
Class
.
forName
(
"org.h2.Driver"
);
Class
.
forName
(
"org.h2.Driver"
);
DeleteDbFiles
.
execute
(
"~"
,
"test"
,
true
);
DeleteDbFiles
.
execute
(
"~"
,
"test"
,
true
);
String
url
=
"jdbc:h2:~/test"
;
String
url
=
"jdbc:h2:~/test"
;
initialInsert
(
url
,
200000
);
initialInsert
(
url
,
200
_
000
);
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
createAsSelect
(
url
,
true
);
createAsSelect
(
url
,
true
);
createAsSelect
(
url
,
false
);
createAsSelect
(
url
,
false
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/build/doc/SpellChecker.java
浏览文件 @
a51ece58
...
@@ -81,8 +81,7 @@ public class SpellChecker {
...
@@ -81,8 +81,7 @@ public class SpellChecker {
// System.out.println(unused);
// System.out.println(unused);
if
(
printDictionary
)
{
if
(
printDictionary
)
{
System
.
out
.
println
(
"USED WORDS"
);
System
.
out
.
println
(
"USED WORDS"
);
String
[]
list
=
new
String
[
used
.
size
()];
String
[]
list
=
used
.
toArray
(
new
String
[
used
.
size
()]);
used
.
toArray
(
list
);
Arrays
.
sort
(
list
);
Arrays
.
sort
(
list
);
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
for
(
String
s
:
list
)
{
for
(
String
s
:
list
)
{
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论