一次查询出100条,一次保存到lucene(你上边写一条就要打开关闭一次lucene当然慢了).然后清空内存.
然后在查询下100条.在一次保存到lucene..........................
和读大文件原理一样
然后在查询下100条.在一次保存到lucene..........................
和读大文件原理一样
解决方案 »
- SSH2 开启客户端校验出错
- 迷茫,小弟在看java web,发现我的API里面没有javax.servlet.http.*;
- 如何用java代码实现Rss订阅 请高手指教 在线等
- 关于hibernate实体映射生成数据类型的处理!!!
- java客户端访问.Net webservice服务
- java写的数字证书
- SPRING HIBERATRE 解决中文问题
- JBoss4.0.1访问http://localhost:8080/web-console的问题!!!
- jboss中打开html页面中文是乱码
- 提问关于CMP2.0的Entity Bean和Oracle8.0.5的Lang字段问题! 很急!!!
- 关于Lucene中多线程访问Hits的问题
- activemq的配置问题
public class ResultIndexDao { /**
* @param args
*/
public static void main(String arg[]) {
ConnectionOracle ts=null; try{ FSDirectory directory = FSDirectory.getDirectory( "D:\\eclipse 3.2\\JavaScape\\HXAIC\\Index\\Index ");
IndexWriter writer = new IndexWriter(directory, getAnalyzer(), true); int i=0;int j=0;int m=0;
while(rs.next())
{
HashMap hap=new HashMap();
hap.put( "fbz ", rs.getString( "fBZ "));
Document doc=writerIndex(hap);
writer.addDocument(doc);
hap=null;
}
writer.optimize();
writer.close(); ts.transactionCommit(false); }catch(Exception e){e.printStackTrace();
ts.transactionRollback(false);} } public static Document writerIndex(HashMap hmp)
{
Document doc=new Document();
try{
if(hmp.get( "fbz ")!=null)
doc.add(new Field( "fbz ", (String)hmp.get( "fbz "),Field.Store.YES,Field.Index.NO));
else
doc.add(new Field( "fbz ", " ",Field.Store.YES,Field.Index.NO));
}catch(Exception e){e.printStackTrace();} return doc;
}
这样就基本上解决了所有问题,基本上一秒半跑一百条数据。再次谢谢各位了
public IndexSearcher(String path) throws IOException ...{
this(IndexReader.open(path), true);
} /** *//** Creates a searcher searching the index in the provided directory. */
public IndexSearcher(Directory directory) throws IOException ...{
this(IndexReader.open(directory), true);
} /** *//** Creates a searcher searching the provided index. */
public IndexSearcher(IndexReader r) ...{
this(r, false);
}
private IndexSearcher(IndexReader r, boolean closeReader) ...{
reader = r;
this.closeReader = closeReader;
}在lucene应用中也许很多人都遇到这种情况。当索引太大(大于10G),搜索时用前两种构造方法声明IndexSearcher对象,这样每构造一个IndexSearcher对象,都要声明一个索引对象(实际上是一个索引的多次连接),而每个索引对象都要占用一定量的系统资源(主要是内存)。当大量用户访问系统时,就会看到系统内存直线增长,致使产生“java heap space”内存耗尽或内存溢出(.net)。这个问题可以通过以下方法解决:终极解决方法:
联系方式: [email protected] , [email protected]