1 package com.atlassian.bonnie.index;
2
3 import com.atlassian.bonnie.ILuceneConnection;
4 import com.atlassian.core.util.ProgressMeter;
5 import com.atlassian.core.util.ProgressWrapper;
6 import org.apache.lucene.analysis.Analyzer;
7 import org.apache.lucene.document.Document;
8
9 import java.io.IOException;
10
11 /**
12 * Performs batch operations on an index.
13 */
14 public interface BatchOpIndexer
15 {
16 /**
17 * Indexes objects in batch.
18 *
19 * @param queue queue of objects to index
20 * @param documentWritingScheme document writing scheme to use
21 * @param progress progress meter indicating index progress
22 * @param truncate should the original index be truncated?
23 * @throws IOException
24 */
25 public void reindex(ObjectQueue queue, DocumentWritingScheme documentWritingScheme,
26 ProgressMeter progress, boolean truncate) throws IOException;
27
28 /**
29 * Truncate the index. Depending on implementations, this can mean deleting the documents one by one,
30 * or other more efficient ways of removing documents from the index. Either way, this method results in an
31 * empty (but valid) Lucene index.
32 *
33 * @throws IOException
34 */
35 void truncateIndex() throws IOException;
36
37 /**
38 * Get analyzer used for indexing.
39 */
40 Analyzer getAnalyzer();
41
42 /**
43 * <p>Writes documents. Possible implementations include
44 * adding documents to a writer directly or adding them to a queue.</p>
45 * <p>{@link ObjectQueue.Processor}s create Documents, and will pass them in to this interface for
46 * writing.
47 * </p>
48 */
49 public interface DocumentWritingScheme
50 {
51 /**
52 * Write a created document.
53 *
54 * @param doc
55 */
56 void write(Document doc);
57
58 /**
59 * Signify that the {@link QueueProcessingRunnableImpl} has completed.
60 */
61 void runComplete();
62
63 /**
64 * Release any open resources.
65 */
66 void close(ILuceneConnection conn) throws IOException;
67
68 void setProgressWrapper(ProgressWrapper progress);
69 }
70 }