Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
560d0380
提交
560d0380
authored
8月 18, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Lucene 3.x support was added in the source code, however it is not yet enabled by default.
上级
55d3d9e1
全部展开
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
240 行增加
和
61 行删除
+240
-61
FullTextLucene.java
h2/src/main/org/h2/fulltext/FullTextLucene.java
+176
-40
TestFullText.java
h2/src/test/org/h2/test/db/TestFullText.java
+39
-13
Build.java
h2/src/tools/org/h2/build/Build.java
+25
-8
没有找到文件。
h2/src/main/org/h2/fulltext/FullTextLucene.java
浏览文件 @
560d0380
差异被折叠。
点击展开。
h2/src/test/org/h2/test/db/TestFullText.java
浏览文件 @
560d0380
...
@@ -23,6 +23,11 @@ import org.h2.test.TestBase;
...
@@ -23,6 +23,11 @@ import org.h2.test.TestBase;
*/
*/
public
class
TestFullText
extends
TestBase
{
public
class
TestFullText
extends
TestBase
{
/**
* The words used in this test.
*/
static
final
String
[]
KNOWN_WORDS
=
{
"skiing"
,
"balance"
,
"storage"
,
"water"
,
"train"
};
/**
/**
* Run just this test.
* Run just this test.
*
*
...
@@ -38,7 +43,8 @@ public class TestFullText extends TestBase {
...
@@ -38,7 +43,8 @@ public class TestFullText extends TestBase {
if
(
config
.
memory
)
{
if
(
config
.
memory
)
{
return
;
return
;
}
}
testMultiThreaded
();
testMultiThreaded
(
true
);
testMultiThreaded
(
false
);
testStreamLob
();
testStreamLob
();
test
(
false
,
"VARCHAR"
);
test
(
false
,
"VARCHAR"
);
test
(
false
,
"CLOB"
);
test
(
false
,
"CLOB"
);
...
@@ -79,6 +85,8 @@ public class TestFullText extends TestBase {
...
@@ -79,6 +85,8 @@ public class TestFullText extends TestBase {
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
stat
.
execute
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1, 'Hello World')"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1, 'Hello World')"
);
stat
.
execute
(
"CALL "
+
prefix
+
"_CREATE_INDEX('PUBLIC', 'TEST', NULL)"
);
stat
.
execute
(
"CALL "
+
prefix
+
"_CREATE_INDEX('PUBLIC', 'TEST', NULL)"
);
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"_SEARCH('Hello', 0, 0)"
);
assertTrue
(
rs
.
next
());
stat
.
execute
(
"UPDATE TEST SET NAME=NULL WHERE ID=1"
);
stat
.
execute
(
"UPDATE TEST SET NAME=NULL WHERE ID=1"
);
stat
.
execute
(
"UPDATE TEST SET NAME='Hello World' WHERE ID=1"
);
stat
.
execute
(
"UPDATE TEST SET NAME='Hello World' WHERE ID=1"
);
conn
.
setAutoCommit
(
false
);
conn
.
setAutoCommit
(
false
);
...
@@ -87,7 +95,7 @@ public class TestFullText extends TestBase {
...
@@ -87,7 +95,7 @@ public class TestFullText extends TestBase {
conn
.
close
();
conn
.
close
();
conn
=
getConnection
(
"fullTextTransaction"
);
conn
=
getConnection
(
"fullTextTransaction"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"_SEARCH('Hello', 0, 0)"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"_SEARCH('Hello', 0, 0)"
);
assertTrue
(
rs
.
next
());
assertTrue
(
rs
.
next
());
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"_SEARCH('Moon', 0, 0)"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"_SEARCH('Moon', 0, 0)"
);
assertFalse
(
rs
.
next
());
assertFalse
(
rs
.
next
());
...
@@ -97,7 +105,9 @@ public class TestFullText extends TestBase {
...
@@ -97,7 +105,9 @@ public class TestFullText extends TestBase {
FileSystem
.
getInstance
(
getBaseDir
()).
deleteRecursive
(
getBaseDir
()
+
"/fullTextTransaction"
,
false
);
FileSystem
.
getInstance
(
getBaseDir
()).
deleteRecursive
(
getBaseDir
()
+
"/fullTextTransaction"
,
false
);
}
}
private
void
testMultiThreaded
()
throws
Exception
{
private
void
testMultiThreaded
(
boolean
lucene
)
throws
Exception
{
final
String
prefix
=
lucene
?
"FTL"
:
"FT"
;
trace
(
"Testing multithreaded "
+
prefix
);
deleteDb
(
"fullText"
);
deleteDb
(
"fullText"
);
final
boolean
[]
stop
=
{
false
};
final
boolean
[]
stop
=
{
false
};
final
Exception
[]
exception
=
{
null
};
final
Exception
[]
exception
=
{
null
};
...
@@ -108,49 +118,67 @@ public class TestFullText extends TestBase {
...
@@ -108,49 +118,67 @@ public class TestFullText extends TestBase {
// getConnection("fullText;MULTI_THREADED=1;LOCK_TIMEOUT=10000");
// getConnection("fullText;MULTI_THREADED=1;LOCK_TIMEOUT=10000");
final
Connection
conn
=
getConnection
(
"fullText"
);
final
Connection
conn
=
getConnection
(
"fullText"
);
Statement
stat
=
conn
.
createStatement
();
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FT_INIT FOR \"org.h2.fulltext.FullText.init\""
);
String
className
=
lucene
?
"FullTextLucene"
:
"FullText"
;
stat
.
execute
(
"CALL FT_INIT()"
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS "
+
prefix
+
"_INIT FOR \"org.h2.fulltext."
+
className
+
".init\""
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FT_INIT FOR \"org.h2.fulltext.FullText.init\""
);
stat
.
execute
(
"CALL "
+
prefix
+
"_INIT()"
);
stat
.
execute
(
"CALL FT_INIT()"
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS "
+
prefix
+
"_INIT FOR \"org.h2.fulltext."
+
className
+
".init\""
);
stat
.
execute
(
"CALL "
+
prefix
+
"_INIT()"
);
final
String
tableName
=
"TEST"
+
i
;
final
String
tableName
=
"TEST"
+
i
;
stat
.
execute
(
"CREATE TABLE "
+
tableName
+
"(ID INT PRIMARY KEY, DATA VARCHAR)"
);
stat
.
execute
(
"CREATE TABLE "
+
tableName
+
"(ID INT PRIMARY KEY, DATA VARCHAR)"
);
FullText
.
createIndex
(
conn
,
"PUBLIC"
,
tableName
,
null
);
stat
.
execute
(
"CALL "
+
prefix
+
"_CREATE_INDEX('PUBLIC', '"
+
tableName
+
"', NULL)"
);
threads
[
i
]
=
new
Thread
()
{
threads
[
i
]
=
new
Thread
()
{
public
void
run
()
{
public
void
run
()
{
trace
(
"starting thread "
+
Thread
.
currentThread
());
try
{
try
{
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO "
+
tableName
+
" VALUES(?, ?)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"INSERT INTO "
+
tableName
+
" VALUES(?, ?)"
);
Statement
stat
=
conn
.
createStatement
();
Random
random
=
new
Random
();
Random
random
=
new
Random
();
int
x
=
0
;
int
x
=
0
;
while
(!
stop
[
0
])
{
while
(!
stop
[
0
])
{
trace
(
"stop[0] = "
+
stop
[
0
]
+
" for "
+
Thread
.
currentThread
());
StringBuilder
buff
=
new
StringBuilder
();
StringBuilder
buff
=
new
StringBuilder
();
for
(
int
j
=
0
;
j
<
1000
;
j
++)
{
for
(
int
j
=
0
;
j
<
1000
;
j
++)
{
buff
.
append
(
" "
+
random
.
nextInt
(
10000
));
buff
.
append
(
" "
).
append
(
random
.
nextInt
(
10000
));
buff
.
append
(
" x"
+
j
);
buff
.
append
(
" x"
).
append
(
j
);
buff
.
append
(
" "
).
append
(
KNOWN_WORDS
[
j
%
KNOWN_WORDS
.
length
]);
}
}
prep
.
setInt
(
1
,
x
);
prep
.
setInt
(
1
,
x
);
prep
.
setString
(
2
,
buff
.
toString
());
prep
.
setString
(
2
,
buff
.
toString
());
prep
.
execute
();
prep
.
execute
();
x
++;
x
++;
for
(
String
knownWord
:
KNOWN_WORDS
)
{
trace
(
"searching for "
+
knownWord
+
" with "
+
Thread
.
currentThread
());
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"_SEARCH('"
+
knownWord
+
"', 0, 0)"
);
assertTrue
(
rs
.
next
());
}
}
}
trace
(
"closing connection"
);
conn
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
exception
[
0
]
=
e
;
exception
[
0
]
=
e
;
}
finally
{
trace
(
"completed thread "
+
Thread
.
currentThread
());
}
}
}
}
};
};
}
}
for
(
Thread
t
:
threads
)
{
for
(
Thread
t
:
threads
)
{
t
.
setDaemon
(
true
);
t
.
start
();
t
.
start
();
}
}
trace
(
"sleeping"
);
Thread
.
sleep
(
1000
);
Thread
.
sleep
(
1000
);
trace
(
"setting stop to true"
);
stop
[
0
]
=
true
;
stop
[
0
]
=
true
;
for
(
Thread
t
:
threads
)
{
for
(
Thread
t
:
threads
)
{
trace
(
"joining "
+
t
);
t
.
join
();
t
.
join
();
trace
(
"done joining "
+
t
);
}
}
if
(
exception
[
0
]
!=
null
)
{
if
(
exception
[
0
]
!=
null
)
{
throw
exception
[
0
];
throw
exception
[
0
];
}
}
}
}
private
void
testStreamLob
()
throws
SQLException
{
private
void
testStreamLob
()
throws
SQLException
{
...
@@ -374,8 +402,6 @@ public class TestFullText extends TestBase {
...
@@ -374,8 +402,6 @@ public class TestFullText extends TestBase {
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 0, 0)"
);
rs
=
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 0, 0)"
);
stat
.
execute
(
"CALL "
+
prefix
+
"DROP_ALL()"
);
stat
.
executeQuery
(
"SELECT * FROM "
+
prefix
+
"SEARCH('World', 2, 1)"
);
stat
.
execute
(
"CALL "
+
prefix
+
"DROP_ALL()"
);
stat
.
execute
(
"CALL "
+
prefix
+
"DROP_ALL()"
);
conn
.
close
();
conn
.
close
();
...
...
h2/src/tools/org/h2/build/Build.java
浏览文件 @
560d0380
...
@@ -105,7 +105,7 @@ public class Build extends BuildBase {
...
@@ -105,7 +105,7 @@ public class Build extends BuildBase {
File
.
pathSeparator
+
"ext/emma-2.0.5312.jar"
+
File
.
pathSeparator
+
"ext/emma-2.0.5312.jar"
+
File
.
pathSeparator
+
"ext/postgresql-8.3-603.jdbc3.jar"
+
File
.
pathSeparator
+
"ext/postgresql-8.3-603.jdbc3.jar"
+
File
.
pathSeparator
+
"ext/servlet-api-2.4.jar"
+
File
.
pathSeparator
+
"ext/servlet-api-2.4.jar"
+
File
.
pathSeparator
+
"ext/
lucene-core-2.2.0.jar"
+
File
.
pathSeparator
+
"ext/
"
+
getLuceneJar
()
+
File
.
pathSeparator
+
"ext/org.osgi.core-1.2.0.jar"
+
File
.
pathSeparator
+
"ext/org.osgi.core-1.2.0.jar"
+
File
.
pathSeparator
+
"ext/slf4j-api-1.5.0.jar"
;
File
.
pathSeparator
+
"ext/slf4j-api-1.5.0.jar"
;
exec
(
"java"
,
args
(
"-Xmx128m"
,
"-cp"
,
cp
,
"emma"
,
"run"
,
exec
(
"java"
,
args
(
"-Xmx128m"
,
"-cp"
,
cp
,
"emma"
,
"run"
,
...
@@ -127,6 +127,9 @@ public class Build extends BuildBase {
...
@@ -127,6 +127,9 @@ public class Build extends BuildBase {
}
else
{
}
else
{
SwitchSource
.
main
(
"-dir"
,
"src"
,
"-version"
,
version
);
SwitchSource
.
main
(
"-dir"
,
"src"
,
"-version"
,
version
);
}
}
if
(
System
.
getProperty
(
"lucene"
)
!=
null
)
{
SwitchSource
.
main
(
"-dir"
,
"src"
,
"-LUCENE2"
,
"-LUCENE3"
,
"+LUCENE"
+
getLuceneVersion
());
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
...
@@ -139,7 +142,7 @@ public class Build extends BuildBase {
...
@@ -139,7 +142,7 @@ public class Build extends BuildBase {
download
();
download
();
String
classpath
=
"temp"
+
String
classpath
=
"temp"
+
File
.
pathSeparator
+
"ext/servlet-api-2.4.jar"
+
File
.
pathSeparator
+
"ext/servlet-api-2.4.jar"
+
File
.
pathSeparator
+
"ext/
lucene-core-2.2.0.jar"
+
File
.
pathSeparator
+
"ext/
"
+
getLuceneJar
()
+
File
.
pathSeparator
+
"ext/slf4j-api-1.5.0.jar"
+
File
.
pathSeparator
+
"ext/slf4j-api-1.5.0.jar"
+
File
.
pathSeparator
+
"ext/org.osgi.core-1.2.0.jar"
+
File
.
pathSeparator
+
"ext/org.osgi.core-1.2.0.jar"
+
File
.
pathSeparator
+
System
.
getProperty
(
"java.home"
)
+
"/../lib/tools.jar"
;
File
.
pathSeparator
+
System
.
getProperty
(
"java.home"
)
+
"/../lib/tools.jar"
;
...
@@ -218,9 +221,15 @@ public class Build extends BuildBase {
...
@@ -218,9 +221,15 @@ public class Build extends BuildBase {
download
(
"ext/servlet-api-2.4.jar"
,
download
(
"ext/servlet-api-2.4.jar"
,
"http://repo1.maven.org/maven2/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar"
,
"http://repo1.maven.org/maven2/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar"
,
"3fc542fe8bb8164e8d3e840fe7403bc0518053c0"
);
"3fc542fe8bb8164e8d3e840fe7403bc0518053c0"
);
if
(
getLuceneVersion
()
==
3
)
{
download
(
"ext/lucene-core-3.0.2.jar"
,
"http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/3.0.2/lucene-core-3.0.2.jar"
,
"c2b48995ab855c1b9ea13867a0f976c994e0105d"
);
}
else
{
download
(
"ext/lucene-core-2.2.0.jar"
,
download
(
"ext/lucene-core-2.2.0.jar"
,
"http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/2.2.0/lucene-core-2.2.0.jar"
,
"http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/2.2.0/lucene-core-2.2.0.jar"
,
"47b6eee2e17bd68911e7045896a1c09de0b2dda8"
);
"47b6eee2e17bd68911e7045896a1c09de0b2dda8"
);
}
download
(
"ext/slf4j-api-1.5.0.jar"
,
download
(
"ext/slf4j-api-1.5.0.jar"
,
"http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.5.0/slf4j-api-1.5.0.jar"
,
"http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.5.0/slf4j-api-1.5.0.jar"
,
"b2df265d02350ecfe87b6c1773c7c4fab2b33505"
);
"b2df265d02350ecfe87b6c1773c7c4fab2b33505"
);
...
@@ -240,6 +249,14 @@ public class Build extends BuildBase {
...
@@ -240,6 +249,14 @@ public class Build extends BuildBase {
return
getStaticValue
(
"org.h2.engine.Constants"
,
"getVersion"
);
return
getStaticValue
(
"org.h2.engine.Constants"
,
"getVersion"
);
}
}
private
String
getLuceneJar
()
{
return
"lucene-core-"
+
(
getLuceneVersion
()
==
2
?
"2.2.0"
:
"3.0.2"
)
+
".jar"
;
}
private
int
getLuceneVersion
()
{
return
Integer
.
parseInt
(
System
.
getProperty
(
"lucene"
,
"2"
));
}
private
String
getJarSuffix
()
{
private
String
getJarSuffix
()
{
return
"-"
+
getVersion
()
+
".jar"
;
return
"-"
+
getVersion
()
+
".jar"
;
}
}
...
@@ -382,7 +399,7 @@ public class Build extends BuildBase {
...
@@ -382,7 +399,7 @@ public class Build extends BuildBase {
mkdir
(
"docs/javadoc"
);
mkdir
(
"docs/javadoc"
);
javadoc
(
"-sourcepath"
,
"src/main"
,
"org.h2.jdbc"
,
"org.h2.jdbcx"
,
javadoc
(
"-sourcepath"
,
"src/main"
,
"org.h2.jdbc"
,
"org.h2.jdbcx"
,
"org.h2.tools"
,
"org.h2.api"
,
"org.h2.constant"
,
"org.h2.fulltext"
,
"org.h2.tools"
,
"org.h2.api"
,
"org.h2.constant"
,
"org.h2.fulltext"
,
"-classpath"
,
"ext/
lucene-core-2.2.0.jar"
,
"-classpath"
,
"ext/
"
+
getLuceneJar
()
,
"-docletpath"
,
"bin"
+
File
.
pathSeparator
+
"temp"
,
"-docletpath"
,
"bin"
+
File
.
pathSeparator
+
"temp"
,
"-doclet"
,
"org.h2.build.doclet.Doclet"
);
"-doclet"
,
"org.h2.build.doclet.Doclet"
);
copy
(
"docs/javadoc"
,
files
(
"src/docsrc/javadoc"
),
"src/docsrc/javadoc"
);
copy
(
"docs/javadoc"
,
files
(
"src/docsrc/javadoc"
),
"src/docsrc/javadoc"
);
...
@@ -402,7 +419,7 @@ public class Build extends BuildBase {
...
@@ -402,7 +419,7 @@ public class Build extends BuildBase {
"/../lib/tools.jar"
+
"/../lib/tools.jar"
+
File
.
pathSeparator
+
"ext/slf4j-api-1.5.0.jar"
+
File
.
pathSeparator
+
"ext/slf4j-api-1.5.0.jar"
+
File
.
pathSeparator
+
"ext/servlet-api-2.4.jar"
+
File
.
pathSeparator
+
"ext/servlet-api-2.4.jar"
+
File
.
pathSeparator
+
"ext/
lucene-core-2.2.0.jar"
+
File
.
pathSeparator
+
"ext/
"
+
getLuceneJar
()
+
File
.
pathSeparator
+
"ext/org.osgi.core-1.2.0.jar"
,
File
.
pathSeparator
+
"ext/org.osgi.core-1.2.0.jar"
,
"-subpackages"
,
"org.h2"
,
"-subpackages"
,
"org.h2"
,
"-exclude"
,
"org.h2.test.jaqu:org.h2.jaqu"
);
"-exclude"
,
"org.h2.test.jaqu:org.h2.jaqu"
);
...
@@ -412,7 +429,7 @@ public class Build extends BuildBase {
...
@@ -412,7 +429,7 @@ public class Build extends BuildBase {
"-classpath"
,
System
.
getProperty
(
"java.home"
)
+
"/../lib/tools.jar"
+
"-classpath"
,
System
.
getProperty
(
"java.home"
)
+
"/../lib/tools.jar"
+
File
.
pathSeparator
+
"ext/slf4j-api-1.5.0.jar"
+
File
.
pathSeparator
+
"ext/slf4j-api-1.5.0.jar"
+
File
.
pathSeparator
+
"ext/servlet-api-2.4.jar"
+
File
.
pathSeparator
+
"ext/servlet-api-2.4.jar"
+
File
.
pathSeparator
+
"ext/
lucene-core-2.2.0.jar"
+
File
.
pathSeparator
+
"ext/
"
+
getLuceneJar
()
+
File
.
pathSeparator
+
"ext/org.osgi.core-1.2.0.jar"
,
File
.
pathSeparator
+
"ext/org.osgi.core-1.2.0.jar"
,
"-subpackages"
,
"org.h2"
,
"-subpackages"
,
"org.h2"
,
"-exclude"
,
"org.h2.test.jaqu:org.h2.jaqu"
,
"-exclude"
,
"org.h2.test.jaqu:org.h2.jaqu"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论