lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cheng <zhoucheng2...@gmail.com>
Subject Shared IndexWriter does not increase speed
Date Sat, 07 Jan 2012 03:43:31 GMT
Hi,

I am trying to use a shared IndexWriter instance for a multi-thread
application. Surprisingly, this under performs by creating a writer
instance within a thread.

My code is as follow. Can someone help explain why? Thanks.


Scenario 1: shared IndexWriter instance

RAMDirectory ramDir = new RAMDirectory();
IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_35,  new
IKAnalyzer() );
IndexWriter iw = new IndexWriter(ramDir, iwc);

ExecutorService executor = Executors
.newFixedThreadPool(20);

for(int i=0; i<10000; i++){
   Runnable runable = new MyRunnable(iw, ramDir);
}

Scenario 2: create IndexWriter instance with MyRunnable()

public MyRunnable implements Runnable{

......

public void run(){
RAMDirectory ramDir = new RAMDirectory();
IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_35,  new
IKAnalyzer() );
IndexWriter iw = new IndexWriter(ramDir, iwc);
}


}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message