提交 2c4da91e authored 作者: Thomas Mueller's avatar Thomas Mueller

fulltext search now supports clob (but doesn't use reader yet)

上级 bfdaa836
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
*/ */
package org.h2.fulltext; package org.h2.fulltext;
import java.io.IOException;
import java.io.Reader;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
...@@ -29,8 +31,10 @@ import org.h2.expression.Expression; ...@@ -29,8 +31,10 @@ import org.h2.expression.Expression;
import org.h2.expression.ExpressionColumn; import org.h2.expression.ExpressionColumn;
import org.h2.expression.ValueExpression; import org.h2.expression.ValueExpression;
import org.h2.jdbc.JdbcConnection; import org.h2.jdbc.JdbcConnection;
import org.h2.message.Message;
import org.h2.tools.SimpleResultSet; import org.h2.tools.SimpleResultSet;
import org.h2.util.ByteUtils; import org.h2.util.ByteUtils;
import org.h2.util.IOUtils;
import org.h2.util.ObjectUtils; import org.h2.util.ObjectUtils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -440,7 +444,11 @@ public class FullText implements Trigger { ...@@ -440,7 +444,11 @@ public class FullText implements Trigger {
case Types.VARCHAR: case Types.VARCHAR:
return data.toString(); return data.toString();
case Types.CLOB: case Types.CLOB:
int test; try {
return IOUtils.readStringAndClose((Reader) data, -1);
} catch (IOException e) {
throw Message.convert(e);
}
case Types.VARBINARY: case Types.VARBINARY:
case Types.LONGVARBINARY: case Types.LONGVARBINARY:
case Types.BINARY: case Types.BINARY:
...@@ -488,7 +496,6 @@ public class FullText implements Trigger { ...@@ -488,7 +496,6 @@ public class FullText implements Trigger {
case Types.BINARY: case Types.BINARY:
return quoteBinary((byte[]) data); return quoteBinary((byte[]) data);
case Types.CLOB: case Types.CLOB:
int test;
case Types.JAVA_OBJECT: case Types.JAVA_OBJECT:
case Types.OTHER: case Types.OTHER:
case Types.BLOB: case Types.BLOB:
...@@ -503,7 +510,7 @@ public class FullText implements Trigger { ...@@ -503,7 +510,7 @@ public class FullText implements Trigger {
return ""; return "";
} }
} }
private static void addWords(FullTextSettings setting, HashSet set, String text) { private static void addWords(FullTextSettings setting, HashSet set, String text) {
StringTokenizer tokenizer = new StringTokenizer(text, " \t\n\r\f+\"*%&/()=?'!,.;:-_#@|^~`{}[]"); StringTokenizer tokenizer = new StringTokenizer(text, " \t\n\r\f+\"*%&/()=?'!,.;:-_#@|^~`{}[]");
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
......
...@@ -8,6 +8,7 @@ package org.h2.fulltext; ...@@ -8,6 +8,7 @@ package org.h2.fulltext;
//## Java 1.4 begin ## //## Java 1.4 begin ##
import java.io.IOException; import java.io.IOException;
import java.io.Reader;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
...@@ -36,9 +37,11 @@ import org.h2.command.Parser; ...@@ -36,9 +37,11 @@ import org.h2.command.Parser;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.expression.ExpressionColumn; import org.h2.expression.ExpressionColumn;
import org.h2.jdbc.JdbcConnection; import org.h2.jdbc.JdbcConnection;
import org.h2.message.Message;
import org.h2.store.fs.FileSystem; import org.h2.store.fs.FileSystem;
import org.h2.tools.SimpleResultSet; import org.h2.tools.SimpleResultSet;
import org.h2.util.ByteUtils; import org.h2.util.ByteUtils;
import org.h2.util.IOUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
//## Java 1.4 end ## //## Java 1.4 end ##
...@@ -426,7 +429,11 @@ implements Trigger ...@@ -426,7 +429,11 @@ implements Trigger
case Types.VARCHAR: case Types.VARCHAR:
return data.toString(); return data.toString();
case Types.CLOB: case Types.CLOB:
int todo; try {
return IOUtils.readStringAndClose((Reader) data, -1);
} catch (IOException e) {
throw Message.convert(e);
}
case Types.VARBINARY: case Types.VARBINARY:
case Types.LONGVARBINARY: case Types.LONGVARBINARY:
case Types.BINARY: case Types.BINARY:
...@@ -473,7 +480,6 @@ implements Trigger ...@@ -473,7 +480,6 @@ implements Trigger
case Types.BINARY: case Types.BINARY:
return quoteBinary((byte[]) data); return quoteBinary((byte[]) data);
case Types.CLOB: case Types.CLOB:
int test;
case Types.JAVA_OBJECT: case Types.JAVA_OBJECT:
case Types.OTHER: case Types.OTHER:
case Types.BLOB: case Types.BLOB:
......
...@@ -24,15 +24,13 @@ public class TestFullText extends TestBase { ...@@ -24,15 +24,13 @@ public class TestFullText extends TestBase {
return; return;
} }
test(false, "VARCHAR"); test(false, "VARCHAR");
int test; test(false, "CLOB");
test(false, "VARCHAR");
testPerformance(false); testPerformance(false);
String luceneFullTextClassName = "org.h2.fulltext.FullTextLucene"; String luceneFullTextClassName = "org.h2.fulltext.FullTextLucene";
try { try {
Class.forName(luceneFullTextClassName); Class.forName(luceneFullTextClassName);
test(true, "VARCHAR"); test(true, "VARCHAR");
int test2; test(true, "CLOB");
test(true, "VARCHAR");
testPerformance(true); testPerformance(true);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
println("Class not found, not tested: " + luceneFullTextClassName); println("Class not found, not tested: " + luceneFullTextClassName);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论