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

the lucene index was always recreated and never closed

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