annotate src/goodjava/lucene/logging/OpDoer.java @ 1550:0dc3be25ad20

use_long_strings
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 03 Oct 2020 23:08:36 -0600
parents 41c32da4cbd1
children 9cc4cee39b8b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 package goodjava.lucene.logging;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 import java.io.IOException;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 import java.util.Map;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 import org.apache.lucene.search.Query;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 import org.apache.lucene.index.IndexReader;
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
7 import goodjava.lucene.api.GoodIndexWriter;
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
10 public class OpDoer {
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
11 protected final GoodIndexWriter writer;
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 protected boolean isActive = true;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
14 protected OpDoer(GoodIndexWriter writer) {
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 this.writer = writer;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 public IndexReader openReader() throws IOException {
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 return writer.openReader();
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 public void commit() throws IOException {
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 writer.commit();
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
28 public void deleteAll(long time) throws IOException {
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 writer.deleteAll();
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
34 public void deleteDocuments(long time,Query query) throws IOException {
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 writer.deleteDocuments(query);
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
40 public void addDocument(long time,Map<String,Object> storedFields) throws IOException {
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 writer.addDocument(storedFields);
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
46 public void updateDocument(long time,String keyFieldName,Map<String,Object> storedFields) throws IOException {
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 writer.updateDocument(keyFieldName,storedFields);
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
52 public void tag(long time,String tag) throws IOException {}
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54 }