annotate src/goodjava/lucene/logging/BasicOpDoer.java @ 1551:9cc4cee39b8b

add LuanOpDoer
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 04 Oct 2020 16:29:54 -0600
parents src/goodjava/lucene/logging/OpDoer.java@41c32da4cbd1
children 52241b69c339
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;
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
6 import goodjava.lucene.api.GoodIndexWriter;
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8
1551
9cc4cee39b8b add LuanOpDoer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1549
diff changeset
9 public class BasicOpDoer implements OpDoer {
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
10 protected final GoodIndexWriter writer;
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 protected boolean isActive = true;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
1551
9cc4cee39b8b add LuanOpDoer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1549
diff changeset
13 public BasicOpDoer(GoodIndexWriter writer) {
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 this.writer = writer;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16
1551
9cc4cee39b8b add LuanOpDoer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1549
diff changeset
17 public GoodIndexWriter writer() {
9cc4cee39b8b add LuanOpDoer
Franklin Schmidt <fschmidt@gmail.com>
parents: 1549
diff changeset
18 return writer;
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 }
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 public void commit() throws IOException {
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 writer.commit();
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
27 public void deleteAll(long time) throws IOException {
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 writer.deleteAll();
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
33 public void deleteDocuments(long time,Query query) throws IOException {
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 writer.deleteDocuments(query);
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
39 public void addDocument(long time,Map<String,Object> storedFields) throws IOException {
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 writer.addDocument(storedFields);
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
45 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
46 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 writer.updateDocument(keyFieldName,storedFields);
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
51 public void tag(long time,String tag) throws IOException {}
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 }