Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
fcad7590
提交
fcad7590
authored
9月 10, 2014
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Documentation / formatting
上级
bbb79bc6
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
931 行增加
和
911 行删除
+931
-911
changelog.html
h2/src/docsrc/html/changelog.html
+2
-1
_docs_en.utf8.txt
h2/src/docsrc/text/_docs_en.utf8.txt
+292
-283
_docs_ja.utf8.txt
h2/src/docsrc/text/_docs_ja.utf8.txt
+292
-283
_docs_en.properties
h2/src/docsrc/textbase/_docs_en.properties
+286
-283
Driver.java
h2/src/main/org/h2/Driver.java
+1
-1
help.csv
h2/src/main/org/h2/res/help.csv
+1
-1
Csv.java
h2/src/main/org/h2/tools/Csv.java
+2
-2
TestOptimizations.java
h2/src/test/org/h2/test/db/TestOptimizations.java
+3
-3
TestPerfectHash.java
h2/src/test/org/h2/test/unit/TestPerfectHash.java
+18
-18
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-3
MinimalPerfectHash.java
h2/src/tools/org/h2/dev/hash/MinimalPerfectHash.java
+33
-33
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
fcad7590
...
...
@@ -17,7 +17,8 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Issue 579: Conditions on the "_rowid_" pseudo-column didn't use an index
<ul><li>
Descending indexes on MVStore tables did not work properly.
</li><li>
Issue 579: Conditions on the "_rowid_" pseudo-column didn't use an index
when using the MVStore.
</li><li>
Fixed documentation that "offset" and "fetch" are also keywords since version 1.4.x.
</li><li>
The Long.MIN_VALUE could not be parsed for auto-increment (identity) columns.
...
...
h2/src/docsrc/text/_docs_en.utf8.txt
浏览文件 @
fcad7590
差异被折叠。
点击展开。
h2/src/docsrc/text/_docs_ja.utf8.txt
浏览文件 @
fcad7590
差异被折叠。
点击展开。
h2/src/docsrc/textbase/_docs_en.properties
浏览文件 @
fcad7590
差异被折叠。
点击展开。
h2/src/main/org/h2/Driver.java
浏览文件 @
fcad7590
...
...
@@ -179,7 +179,7 @@ public class Driver implements java.sql.Driver {
}
/**
* INTERNAL
* INTERNAL
* Sets, on a per-thread basis, the default-connection for
* user-defined functions.
*/
...
...
h2/src/main/org/h2/res/help.csv
浏览文件 @
fcad7590
...
...
@@ -22,7 +22,7 @@ Inserts a new row / new rows into a table."
UPDATE tableName [ [ AS ] newTableAlias ] SET
{ { columnName = { DEFAULT | expression } } [,...] } |
{ ( columnName [,...] ) = ( select ) }
[ WHERE expression ] [
LIMIT expression ] [ ORDER BY order [,...]
]
[ WHERE expression ] [
ORDER BY order [,...] ] [ LIMIT expression
]
","
Updates data in a table."
"Commands (DML)","DELETE","
...
...
h2/src/main/org/h2/tools/Csv.java
浏览文件 @
fcad7590
...
...
@@ -774,7 +774,7 @@ public class Csv implements SimpleRowSource {
}
/**
* Set the line separator.
* Set the line separator
used for writing
.
*
* @param lineSeparator the line separator
*/
...
...
@@ -783,7 +783,7 @@ public class Csv implements SimpleRowSource {
}
/**
* Get the
current line separator
.
* Get the
line separator used for writing
.
*
* @return the line separator
*/
...
...
h2/src/test/org/h2/test/db/TestOptimizations.java
浏览文件 @
fcad7590
...
...
@@ -79,13 +79,13 @@ public class TestOptimizations extends TestBase {
testConvertOrToIn
();
deleteDb
(
"optimizations"
);
}
private
void
testFastRowIdCondition
()
throws
Exception
{
Connection
conn
=
getConnection
(
"optimizations"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
executeUpdate
(
"create table many(id int) "
+
stat
.
executeUpdate
(
"create table many(id int) "
+
"as select x from system_range(1, 10000)"
);
ResultSet
rs
=
stat
.
executeQuery
(
"explain analyze select * from many "
+
ResultSet
rs
=
stat
.
executeQuery
(
"explain analyze select * from many "
+
"where _rowid_ = 400"
);
rs
.
next
();
assertContains
(
rs
.
getString
(
1
),
"/* scanCount: 2 */"
);
...
...
h2/src/test/org/h2/test/unit/TestPerfectHash.java
浏览文件 @
fcad7590
...
...
@@ -35,7 +35,7 @@ public class TestPerfectHash extends TestBase {
test
.
test
();
test
.
measure
();
}
private
static
void
largeFile
()
throws
IOException
{
String
fileName
=
System
.
getProperty
(
"user.home"
)
+
"/temp/enwiki-20140811-all-titles.txt"
;
RandomAccessFile
f
=
new
RandomAccessFile
(
fileName
,
"r"
);
...
...
@@ -47,7 +47,7 @@ public class TestPerfectHash extends TestBase {
public
int
hashCode
(
Text
o
,
int
index
,
int
seed
)
{
return
o
.
hashCode
(
index
,
seed
);
}
};
HashSet
<
Text
>
set
=
new
HashSet
<
Text
>();
Text
t
=
new
Text
(
data
,
0
);
...
...
@@ -86,18 +86,18 @@ public class TestPerfectHash extends TestBase {
s
=
testMinimalWithString
(
size
);
time
=
System
.
currentTimeMillis
()
-
time
;
System
.
out
.
println
((
double
)
s
/
size
+
" bits/key (minimal; String keys) in "
+
" bits/key (minimal; String keys) in "
+
time
+
" ms"
);
time
=
System
.
currentTimeMillis
();
s
=
test
(
size
,
true
);
time
=
System
.
currentTimeMillis
()
-
time
;
System
.
out
.
println
((
double
)
s
/
size
+
" bits/key (minimal old) in "
+
System
.
out
.
println
((
double
)
s
/
size
+
" bits/key (minimal old) in "
+
time
+
" ms"
);
time
=
System
.
currentTimeMillis
();
s
=
test
(
size
,
false
);
time
=
System
.
currentTimeMillis
()
-
time
;
System
.
out
.
println
((
double
)
s
/
size
+
" bits/key (not minimal) in "
+
System
.
out
.
println
((
double
)
s
/
size
+
" bits/key (not minimal) in "
+
time
+
" ms"
);
}
...
...
@@ -119,7 +119,7 @@ public class TestPerfectHash extends TestBase {
test
(
i
,
false
);
}
}
private
void
testBrokenHashFunction
()
{
int
size
=
10000
;
Random
r
=
new
Random
(
10000
);
...
...
@@ -138,7 +138,7 @@ public class TestPerfectHash extends TestBase {
}
return
StringHash
.
getFastHash
(
o
,
index
,
seed
);
}
};
byte
[]
desc
=
MinimalPerfectHash
.
generate
(
set
,
badHash
);
testMinimal
(
desc
,
set
,
badHash
);
...
...
@@ -190,7 +190,7 @@ public class TestPerfectHash extends TestBase {
assertEquals
(
size
-
1
,
max
);
return
desc
.
length
*
8
;
}
private
int
testMinimalWithString
(
int
size
)
{
Random
r
=
new
Random
(
size
);
HashSet
<
String
>
set
=
new
HashSet
<
String
>(
size
);
...
...
@@ -218,30 +218,30 @@ public class TestPerfectHash extends TestBase {
}
return
max
;
}
/**
* A text.
*/
static
class
Text
{
/**
* The byte data (may be shared, so must not be modified).
*/
final
byte
[]
data
;
/**
* The start location.
*/
final
int
start
;
Text
(
byte
[]
data
,
int
start
)
{
this
.
data
=
data
;
this
.
start
=
start
;
}
/**
* The hash code (using a universal hash function).
*
*
* @param index the hash function index
* @param seed the random seed
* @return the hash code
...
...
@@ -257,7 +257,7 @@ public class TestPerfectHash extends TestBase {
break
;
}
x
=
31
+
x
*
0x9f3b
;
result
^=
x
*
(
1
+
c
);
result
^=
x
*
(
1
+
c
);
}
return
result
;
}
...
...
@@ -272,12 +272,12 @@ public class TestPerfectHash extends TestBase {
}
return
end
;
}
@Override
public
int
hashCode
()
{
return
hashCode
(
0
,
0
);
}
@Override
public
boolean
equals
(
Object
other
)
{
if
(
other
==
this
)
{
...
...
@@ -299,7 +299,7 @@ public class TestPerfectHash extends TestBase {
}
return
true
;
}
@Override
public
String
toString
()
{
return
new
String
(
data
,
start
,
getEnd
()
-
start
);
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
fcad7590
...
...
@@ -762,8 +762,6 @@ exploit noise ongoing disclaimers shrinks remedy party desirable timely construe
deque synchronizers affero kevent nikolaj hohmuth grajcar jens fogh hostnames
operate resized jni yjp ownable starvation reaper biased introduce epoll hangs
compaction aggressive powerful traversing pietrzak michi karl rewriting consequences
linearly patching perfect hole sip enwiki
flooding uniformly recursions happening
linearly patching perfect hole sip enwiki flooding uniformly recursions happening
h2/src/tools/org/h2/dev/hash/MinimalPerfectHash.java
浏览文件 @
fcad7590
...
...
@@ -66,7 +66,7 @@ import java.util.zip.Inflater;
* theory, by patching the hash function description. With a small change,
* non-minimal perfect hash functions can be calculated (for example 1.22 bits
* per key at a fill rate of 81%).
*
*
* @param <K> the key type
*/
public
class
MinimalPerfectHash
<
K
>
{
...
...
@@ -99,7 +99,7 @@ public class MinimalPerfectHash<K> {
* The minimum output value for a small bucket of a given size.
*/
private
static
final
int
[]
SIZE_OFFSETS
=
new
int
[
MAX_OFFSETS
.
length
+
1
];
/**
* A secure random generator.
*/
...
...
@@ -113,7 +113,7 @@ public class MinimalPerfectHash<K> {
}
SIZE_OFFSETS
[
SIZE_OFFSETS
.
length
-
1
]
=
last
;
}
/**
* The universal hash function.
*/
...
...
@@ -124,7 +124,7 @@ public class MinimalPerfectHash<K> {
* key.
*/
private
final
byte
[]
data
;
/**
* The random seed.
*/
...
...
@@ -141,7 +141,7 @@ public class MinimalPerfectHash<K> {
* speed up calculating the hash of a key.
*/
private
final
int
[]
rootPos
;
/**
* The hash function level at the root of the tree. Typically 0, except if
* the hash function at that level didn't split the entries as expected
...
...
@@ -158,9 +158,9 @@ public class MinimalPerfectHash<K> {
public
MinimalPerfectHash
(
byte
[]
desc
,
UniversalHash
<
K
>
hash
)
{
this
.
hash
=
hash
;
byte
[]
b
=
data
=
expand
(
desc
);
seed
=
((
b
[
0
]
&
255
)
<<
24
)
|
((
b
[
1
]
&
255
)
<<
16
)
|
((
b
[
2
]
&
255
)
<<
8
)
|
seed
=
((
b
[
0
]
&
255
)
<<
24
)
|
((
b
[
1
]
&
255
)
<<
16
)
|
((
b
[
2
]
&
255
)
<<
8
)
|
(
b
[
3
]
&
255
);
if
(
b
[
4
]
==
SPLIT_MANY
)
{
rootLevel
=
b
[
b
.
length
-
1
]
&
255
;
...
...
@@ -182,7 +182,7 @@ public class MinimalPerfectHash<K> {
rootPos
=
null
;
}
}
/**
* Calculate the hash value for the given key.
*
...
...
@@ -196,7 +196,7 @@ public class MinimalPerfectHash<K> {
/**
* Get the hash value for the given key, starting at a certain position and
* level.
*
*
* @param pos the start position
* @param x the key
* @param isRoot whether this is the root of the tree
...
...
@@ -234,10 +234,10 @@ public class MinimalPerfectHash<K> {
}
return
s
+
get
(
pos
,
x
,
false
,
level
+
1
);
}
/**
* Get the position of the next sibling.
*
*
* @param pos the position of this branch
* @return the position of the next sibling
*/
...
...
@@ -259,10 +259,10 @@ public class MinimalPerfectHash<K> {
}
return
pos
;
}
/**
* The sum of the sizes between the start and end position.
*
*
* @param start the start position
* @param end the end position (excluding)
* @return the sizes
...
...
@@ -331,7 +331,7 @@ public class MinimalPerfectHash<K> {
* @param seed the random seed
* @param out the output stream
*/
static
<
K
>
void
generate
(
ArrayList
<
K
>
list
,
UniversalHash
<
K
>
hash
,
static
<
K
>
void
generate
(
ArrayList
<
K
>
list
,
UniversalHash
<
K
>
hash
,
int
level
,
int
seed
,
ByteArrayOutputStream
out
)
{
int
size
=
list
.
size
();
if
(
size
<=
1
)
{
...
...
@@ -339,7 +339,7 @@ public class MinimalPerfectHash<K> {
return
;
}
if
(
level
>
32
)
{
throw
new
IllegalStateException
(
"Too many recursions; "
+
throw
new
IllegalStateException
(
"Too many recursions; "
+
" incorrect universal hash function?"
);
}
if
(
size
<=
MAX_SIZE
)
{
...
...
@@ -381,7 +381,7 @@ public class MinimalPerfectHash<K> {
K
x
=
list
.
get
(
i
);
ArrayList
<
K
>
l
=
lists
.
get
(
hash
(
x
,
hash
,
level
,
seed
,
0
,
split
));
l
.
add
(
x
);
if
(
isRoot
&&
split
>=
SPLIT_MANY
&&
if
(
isRoot
&&
split
>=
SPLIT_MANY
&&
l
.
size
()
>
36
*
DIVIDE
*
10
)
{
// a bad hash function or attack was detected
level
++;
...
...
@@ -491,7 +491,7 @@ public class MinimalPerfectHash<K> {
x
=
(
x
>>>
16
)
^
x
;
return
Math
.
abs
(
x
%
size
);
}
private
static
<
K
>
int
hash
(
int
x
,
int
level
,
int
offset
,
int
size
)
{
x
+=
level
+
offset
*
16
;
x
=
((
x
>>>
16
)
^
x
)
*
0x45d9f3b
;
...
...
@@ -586,7 +586,7 @@ public class MinimalPerfectHash<K> {
}
return
out
.
toByteArray
();
}
/**
* An interface that can calculate multiple hash values for an object. The
* returned hash value of two distinct objects may be the same for a given
...
...
@@ -594,14 +594,14 @@ public class MinimalPerfectHash<K> {
* those objects, the returned value must eventually be different.
* <p>
* The returned value does not need to be uniformly distributed.
*
*
* @param <T> the type
*/
public
interface
UniversalHash
<
T
>
{
/**
* Calculate the hash of the given object.
*
*
* @param o the object
* @param index the hash function index (index 0 is used first, so the
* method should be very fast with index 0; index 1 and so on
...
...
@@ -610,9 +610,9 @@ public class MinimalPerfectHash<K> {
* @return the hash value
*/
int
hashCode
(
T
o
,
int
index
,
int
seed
);
}
/**
* A sample hash implementation for long keys.
*/
...
...
@@ -633,7 +633,7 @@ public class MinimalPerfectHash<K> {
int
shift
=
(
index
&
1
)
*
32
;
return
(
int
)
(
o
.
longValue
()
>>>
shift
);
}
}
/**
...
...
@@ -661,7 +661,7 @@ public class MinimalPerfectHash<K> {
/**
* A cryptographically weak hash function. It is supposed to be fast.
*
*
* @param o the string
* @param index the hash function index
* @param seed the seed
...
...
@@ -672,15 +672,15 @@ public class MinimalPerfectHash<K> {
int
result
=
seed
+
o
.
length
();
for
(
int
i
=
0
;
i
<
o
.
length
();
i
++)
{
x
=
31
+
x
*
0x9f3b
;
result
^=
x
*
(
1
+
o
.
charAt
(
i
));
}
result
^=
x
*
(
1
+
o
.
charAt
(
i
));
}
return
result
;
}
/**
* A cryptographically relatively secure hash function. It is supposed
* to protected against hash-flooding denial-of-service attacks.
*
*
* @param o the string
* @param k0 key 0
* @param k1 key 1
...
...
@@ -690,11 +690,11 @@ public class MinimalPerfectHash<K> {
byte
[]
b
=
o
.
getBytes
(
UTF8
);
return
getSipHash24
(
b
,
0
,
b
.
length
,
k0
,
k1
);
}
/**
* A cryptographically relatively secure hash function. It is supposed
* to protected against hash-flooding denial-of-service attacks.
*
*
* @param b the data
* @param start the start position
* @param end the end position plus one
...
...
@@ -746,7 +746,7 @@ public class MinimalPerfectHash<K> {
}
return
(
int
)
(
v0
^
v1
^
v2
^
v3
);
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论