Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
301ae834
提交
301ae834
authored
4月 09, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Shrink the javascript documentation search index
上级
d42b9406
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
66 行增加
和
15 行删除
+66
-15
Indexer.java
h2/src/tools/org/h2/build/indexer/Indexer.java
+32
-14
Page.java
h2/src/tools/org/h2/build/indexer/Page.java
+4
-0
Weight.java
h2/src/tools/org/h2/build/indexer/Weight.java
+5
-0
Word.java
h2/src/tools/org/h2/build/indexer/Word.java
+25
-1
没有找到文件。
h2/src/tools/org/h2/build/indexer/Indexer.java
浏览文件 @
301ae834
...
...
@@ -16,7 +16,6 @@ import java.util.Comparator;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.StringTokenizer
;
import
org.h2.util.IOUtils
;
import
org.h2.util.StringUtils
;
...
...
@@ -30,6 +29,10 @@ public class Indexer {
private
static
final
int
MAX_RELATIONS
=
20
;
private
ArrayList
pages
=
new
ArrayList
();
/**
* Lower case word to Word map.
*/
private
HashMap
words
=
new
HashMap
();
private
HashSet
noIndex
=
new
HashSet
();
private
ArrayList
wordList
;
...
...
@@ -87,20 +90,35 @@ public class Indexer {
}
private
void
sortWords
()
{
ArrayList
names
=
new
ArrayList
(
words
.
keySet
());
for
(
int
i
=
0
;
i
<
names
.
size
();
i
++)
{
String
name
=
(
String
)
names
.
get
(
i
);
if
(
name
.
endsWith
(
"s"
))
{
String
singular
=
name
.
substring
(
0
,
name
.
length
()
-
1
);
if
(
words
.
containsKey
(
singular
))
{
Word
wp
=
(
Word
)
words
.
get
(
name
);
Word
ws
=
(
Word
)
words
.
get
(
singular
);
ws
.
addAll
(
wp
);
words
.
remove
(
name
);
}
}
else
if
(
name
.
startsWith
(
"abc"
))
{
words
.
remove
(
name
);
}
}
wordList
=
new
ArrayList
(
words
.
values
());
//
TODO support ignored key
words (to shrink the index)
//
String ignored = "";
// for(int i=0; i<
wordList.size(); i++) {
//
Word word = (Word) wordList.get(i);
// if(word.pages.size() >= pages.size()/
4) {
//
wordList.remove(i);
// if(ignored.length()==
0) {
//
ignored += ",";
//
}
//
ignored += word.name;
//
i--;
//
}
//
}
//
ignored very common
words (to shrink the index)
String
ignored
=
""
;
for
(
int
i
=
0
;
i
<
wordList
.
size
();
i
++)
{
Word
word
=
(
Word
)
wordList
.
get
(
i
);
if
(
word
.
pages
.
size
()
>=
pages
.
size
()
/
4
)
{
wordList
.
remove
(
i
);
if
(
ignored
.
length
()
>
0
)
{
ignored
+=
","
;
}
ignored
+=
word
.
name
;
i
--;
}
}
// output.println("var ignored = '" + convertUTF(ignored) + "'");
// TODO support A, B, C,... class links in the index file and use them
// for combined AND searches
...
...
h2/src/tools/org/h2/build/indexer/Page.java
浏览文件 @
301ae834
...
...
@@ -42,4 +42,8 @@ public class Page {
this
.
fileName
=
fileName
;
}
public
String
toString
()
{
return
"p"
+
id
+
"("
+
fileName
+
")"
;
}
}
h2/src/tools/org/h2/build/indexer/Weight.java
浏览文件 @
301ae834
...
...
@@ -35,4 +35,9 @@ public class Weight {
* The weight value.
*/
int
value
;
public
String
toString
()
{
return
""
+
value
;
}
}
h2/src/tools/org/h2/build/indexer/Word.java
浏览文件 @
301ae834
...
...
@@ -10,6 +10,8 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
/**
* Represents a word of the full text index.
...
...
@@ -21,7 +23,11 @@ public class Word {
*/
String
name
;
private
HashMap
pages
=
new
HashMap
();
/**
* The pages map.
*/
HashMap
pages
=
new
HashMap
();
private
ArrayList
weightList
;
Word
(
String
name
)
{
...
...
@@ -45,6 +51,24 @@ public class Word {
page
.
relations
++;
}
public
String
toString
()
{
return
name
+
":"
+
pages
;
}
/**
* Add all data of the other word to this word.
*
* @param other the other word
*/
void
addAll
(
Word
other
)
{
for
(
Iterator
it
=
other
.
pages
.
entrySet
().
iterator
();
it
.
hasNext
();)
{
Map
.
Entry
entry
=
(
Map
.
Entry
)
it
.
next
();
Page
p
=
(
Page
)
entry
.
getKey
();
Weight
w
=
(
Weight
)
entry
.
getValue
();
addPage
(
p
,
w
.
value
);
}
}
ArrayList
getSortedWeights
()
{
if
(
weightList
==
null
)
{
weightList
=
new
ArrayList
(
pages
.
values
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论