com.atlassian.bonnie.index
Class TempIndexWriter

java.lang.Object
  extended by com.atlassian.bonnie.index.TempIndexWriter

public class TempIndexWriter
extends java.lang.Object

Index writer that is able to write to one or more temporary indices. This writer is typically used to:


Nested Class Summary
protected  class TempIndexWriter.WriterData
           
 
Field Summary
protected static org.apache.log4j.Category log
           
 
Constructor Summary
TempIndexWriter(org.apache.lucene.analysis.Analyzer analyzerForIndexing, java.lang.String tmpDir)
           
TempIndexWriter(org.apache.lucene.analysis.Analyzer analyzerForIndexing, java.lang.String tmpDir, ILuceneConnection.Configuration configuration)
          Constructs a temp index writer.
 
Method Summary
 void addDocument(java.lang.String key, org.apache.lucene.document.Document doc)
          Add a document to an index.
 void close(java.lang.String prefix)
          Delete the respective temp indices.
 void closeAll()
          Delete the respective temp indices.
protected  boolean delete(java.io.File directory)
           
 java.lang.String getTmpDir()
           
 void merge(org.apache.lucene.index.IndexWriter writer)
          Close all temporary writers, and merge all temporary indices to the writer provided.
 void merge(java.lang.String prefix, org.apache.lucene.index.IndexWriter writer)
          Close relevant temporary writers, and merge temporary indices identified by keys which start with the provided prefix to the writer provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Category log
Constructor Detail

TempIndexWriter

public TempIndexWriter(org.apache.lucene.analysis.Analyzer analyzerForIndexing,
                       java.lang.String tmpDir)

TempIndexWriter

public TempIndexWriter(org.apache.lucene.analysis.Analyzer analyzerForIndexing,
                       java.lang.String tmpDir,
                       ILuceneConnection.Configuration configuration)
Constructs a temp index writer.

Parameters:
analyzerForIndexing - analyzer used by IndexWriters created and managed by this temp index writer. Required parameter.
tmpDir - directory where temporary directories will be created in. Required parameter.
configuration - allows configuration of the IndexWriters created and managed by this temp index writer. Only the batch settings will be used (as the assumption here is that TempIndexWriters will be used for batch indexing purposes only).
Throws:
java.lang.IllegalArgumentException - if analyzerForIndexing, tmpDir or configuration are null
Method Detail

addDocument

public void addDocument(java.lang.String key,
                        org.apache.lucene.document.Document doc)
                 throws java.io.IOException
Add a document to an index.

Parameters:
key - key representing which index to write to. A new writer will be created if no writer exists for the key.
doc - document to add
Throws:
java.io.IOException

close

public void close(java.lang.String prefix)
           throws java.io.IOException
Delete the respective temp indices.

Parameters:
prefix -
Throws:
java.io.IOException

closeAll

public void closeAll()
              throws java.io.IOException
Delete the respective temp indices.

Throws:
java.io.IOException

merge

public void merge(org.apache.lucene.index.IndexWriter writer)
           throws java.io.IOException
Close all temporary writers, and merge all temporary indices to the writer provided.

Parameters:
writer -
Throws:
java.io.IOException

merge

public void merge(java.lang.String prefix,
                  org.apache.lucene.index.IndexWriter writer)
           throws java.io.IOException
Close relevant temporary writers, and merge temporary indices identified by keys which start with the provided prefix to the writer provided.

Parameters:
prefix - key prefix
writer -
Throws:
java.io.IOException

delete

protected final boolean delete(java.io.File directory)

getTmpDir

public java.lang.String getTmpDir()


Copyright © 2006-2008 Atlassian Software Systems Pty Ltd. All Rights Reserved.