Created
June 5, 2011 13:28
-
-
Save 0x6e6562/1008960 to your computer and use it in GitHub Desktop.
Lucene disk buffering test with small heap (-Xmx32m) using Lucene 3.2.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
import org.apache.lucene.document.Document | |
import org.apache.lucene.document.Field | |
import com.eaio.uuid.UUID | |
import org.apache.lucene.store.FSDirectory | |
import java.io.File | |
import org.apache.lucene.index.IndexWriter | |
import org.apache.lucene.analysis.WhitespaceAnalyzer | |
object LuceneRollbackTest { | |
// Run with -Xmx32m | |
def main(args: Array[String]) { | |
val dir = FSDirectory.open(new File("/tmp/foo")) | |
val writer = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED) | |
for (i <- 1 to 10000000) { | |
if (i % 10000 == 0) println("Indexing %sth document".format(i)) | |
val doc = new Document() | |
doc.add(new Field("foo", new UUID().toString, Field.Store.YES, Field.Index.ANALYZED)) | |
doc.add(new Field("bar", new UUID().toString, Field.Store.YES, Field.Index.ANALYZED)) | |
doc.add(new Field("baz", new UUID().toString, Field.Store.YES, Field.Index.ANALYZED)) | |
writer.addDocument(doc); | |
} | |
writer.rollback() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment