MoveLuceneSmall
package com.yulong.lucene.biz;
import java.io.File;
import org.apache.lucene.index.IndexWriter; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory;
import com.yulong.lucene.core.LuceneContacts; import com.yulong.lucene.util.RequestUtil;
/**
-
LUCENE小文件移动到大文件中的任务调度 *
-
@author fyh */ public class MoveLuceneSmall { private String path = "";
public MoveLuceneSmall(String path) { this.path = RequestUtil.ChangePath(path); this.move(); }
/**
- 开始转移 *
- @return */ @SuppressWarnings("deprecation") public boolean move() { IndexWriter iw = null; try { File file = new File(path+"small/"); if (file.exists()) { try{ Directory directory = FSDirectory.open(file); iw =LuceneContacts.iwpool.get(path +"index/", this.toString()); if(iw != null){ iw.addIndexes(new Directory{directory}); IndexWriter iwcc = LuceneContacts.iwpool.get(path +"small/", this.toString()); iwcc.deleteAll(); iwcc.close(); } }catch (Exception e) { } } iw.close(); } catch (Exception e) { e.printStackTrace(); return false; } LuceneContacts.iwpool.over(path +"index/", this.toString()); LuceneContacts.iwpool.over(path +"small/", this.toString()); return true; }
}