루틴에 대한 코드인데 거기에 문제가 있는지 모르겠어요.
// , 10 , 10 ,
public class IndexCreateThread {
public static void main(String[] args) throws CorruptIndexException,
LockObtainFailedException, IOException, InterruptedException {
IndexWriter writer = new IndexWriter(FSDirectory.getDirectory("E:/Lucene/Index6"), new StandardAnalyzer(), true);
LinkedList<RAMDirectory> list = new LinkedList<RAMDirectory>();
Runnable indexListThread = new IndexListThread(list,writer);
new Thread(indexListThread).start();
Runnable ramIndexCreateThread = null;
for (int i = 0; i < 15; i++) {
ramIndexCreateThread = new RamIndexCreateThread(list);
new Thread(ramIndexCreateThread).start();
Thread.sleep(i*3);
}
Thread.sleep(5000*10);
while (true) {
if (list != null && list.size() == 0) {
System.out.println(writer.docCount());
writer.optimize();
writer.flush();
writer.close();
System.out.println("over....");
System.exit(0);
} else {
Thread.sleep(1000);
}
}
}
}
class IndexListThread implements Runnable{
private LinkedList<RAMDirectory> list = null;
private IndexWriter writer = null;
public IndexListThread(LinkedList<RAMDirectory> list, IndexWriter writer) {
super();
this.list = list;
this.writer = writer;
}
@Override
public void run() {
while(true){
RAMDirectory r = null;
try {
Thread.sleep(5);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
if(list != null && list.size() > 0){
r = list.get(0);
try {
this.writer.addIndexes(new Directory[]{r});
} catch (CorruptIndexException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
list.remove(r);
System.out.println("list ");
}
}
}
}
class RamIndexCreateThread implements Runnable {
private LinkedList<RAMDirectory> list = null;
public RamIndexCreateThread(LinkedList<RAMDirectory> list) {
this.list = list;
}
@Override
public void run() {
IndexWriter ramWriter = null;
try {
RAMDirectory ram = new RAMDirectory();
ramWriter = new IndexWriter(ram,new StandardAnalyzer(), true);
List<Authors> list = new DBOperation().getAuthorses();
for(Authors s : list){
Field f1 = new Field("id",s.getAu_id(),Field.Store.YES,Field.Index.UN_TOKENIZED);
Field f2 = new Field("lname",s.getAu_lname(),Field.Store.YES,Field.Index.TOKENIZED);
Field f3 = new Field("fname",s.getAu_fname(),Field.Store.YES,Field.Index.UN_TOKENIZED);
Field f4 = new Field("phone",s.getPhone(),Field.Store.YES,Field.Index.TOKENIZED);
Field f5 = new Field("address",s.getAddress(),Field.Store.YES,Field.Index.TOKENIZED);
Field f6 = new Field("city",s.getCity(),Field.Store.YES,Field.Index.TOKENIZED);
Field f7 = new Field("zip",s.getZip(),Field.Store.YES,Field.Index.TOKENIZED);
Field f8 = new Field("state",s.getState(),Field.Store.YES,Field.Index.TOKENIZED);
Field f9 = new Field("contract",s.getContract()+"",Field.Store.YES,Field.Index.TOKENIZED);
Document doc = new Document();
doc.add(f1);
doc.add(f2);
doc.add(f3);
doc.add(f4);
doc.add(f5);
doc.add(f6);
doc.add(f7);
doc.add(f8);
doc.add(f9);
ramWriter.addDocument(doc);
}
ramWriter.flush();
this.list.add(ram);
System.out.println("list ");
} catch (CorruptIndexException e) {
e.printStackTrace();
} catch (LockObtainFailedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}finally{
try {
ramWriter.close();
} catch (CorruptIndexException e) {
} catch (IOException e) {
}
}
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Exception in thread main java.lang. NoClassDefFoundError 오류 해결 방법즉,/home/hadoop/jarfile) 시스템은 Hello World 패키지 아래의class라는 클래스 파일을 실행하고 있다고 오인하여 시스템의 CLASSPATH 아래 (일반적으로 현재 디렉터리를 포함) Hell...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.