提交 21ec14d4 authored 作者: Thomas Mueller's avatar Thomas Mueller

the lucene index was always recreated and never closed

上级 c92f4f7b
......@@ -17,7 +17,8 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>Support for overloaded Java methods. A user defined function can now be bound to
<li>The Lucene fulltext index was always re-created when opening a database with fulltext index enabled.
</li><li>Support for overloaded Java methods. A user defined function can now be bound to
multiple Java methods, if the Java methods have the same name but a different number
of parameters. Thanks to Gary Tong for providing a patch!
</li></ul>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -93,7 +93,7 @@
90070=Role {0} not found
90071=User or role {0} not found
90072=Roles and rights cannot be mixed
90073=Right not found
90073=Matching Java methods must have different parameter counts\: {0} and {1}
90074=Role {0} already granted
90075=Column is part of the index {0}
90076=Function alias {0} already exists
......
......@@ -68,6 +68,7 @@ implements Trigger, CloseListener
private int[] indexColumns;
private String[] columnNames;
private int[] dataTypes;
private String indexPath;
private IndexModifier indexer;
//## Java 1.4 end ##
......@@ -160,6 +161,13 @@ implements Trigger, CloseListener
stat.execute("CREATE ALIAS IF NOT EXISTS FTL_SEARCH_DATA FOR \"" + FullTextLucene.class.getName() + ".searchData\"");
stat.execute("CREATE ALIAS IF NOT EXISTS FTL_REINDEX FOR \"" + FullTextLucene.class.getName() + ".reindex\"");
stat.execute("CREATE ALIAS IF NOT EXISTS FTL_DROP_ALL FOR \"" + FullTextLucene.class.getName() + ".dropAll\"");
String path = getIndexPath(conn);
IndexModifier indexer = openIndexModifier(path, true);
try {
indexer.close();
} catch (Exception e) {
throw convertException(e);
}
}
//## Java 1.4 end ##
......@@ -171,6 +179,7 @@ implements Trigger, CloseListener
init(conn);
this.schemaName = schemaName;
this.tableName = tableName;
this.indexPath = getIndexPath(conn);
this.indexer = getIndexModifier(conn);
ArrayList keyList = new ArrayList();
DatabaseMetaData meta = conn.getMetaData();
......@@ -569,19 +578,23 @@ implements Trigger, CloseListener
}
private static IndexModifier getIndexModifier(Connection conn) throws SQLException {
try {
String path = getIndexPath(conn);
IndexModifier indexer;
synchronized (indexers) {
indexer = (IndexModifier) indexers.get(path);
if (indexer == null) {
Analyzer analyzer = new StandardAnalyzer();
boolean create = !IndexReader.indexExists(path);
indexer = new IndexModifier(path, analyzer, create);
indexers.put(path, indexer);
}
String path = getIndexPath(conn);
IndexModifier indexer;
synchronized (indexers) {
indexer = (IndexModifier) indexers.get(path);
if (indexer == null) {
boolean recreate = !IndexReader.indexExists(path);
indexer = openIndexModifier(path, recreate);
indexers.put(path, indexer);
}
return indexer;
}
return indexer;
}
private static IndexModifier openIndexModifier(String path, boolean recreate) throws SQLException {
try {
Analyzer analyzer = new StandardAnalyzer();
return new IndexModifier(path, analyzer, recreate);
} catch (IOException e) {
throw convertException(e);
}
......@@ -621,6 +634,7 @@ implements Trigger, CloseListener
if (indexer != null) {
indexer.flush();
indexer.close();
indexers.remove(indexPath);
indexer = null;
}
} catch (Exception e) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论