annotate src/goodjava/lucene/logging/BasicOpDoer.java @ 1640:570f3d483a31

host - move https.luan into src
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 21 Dec 2021 16:54:26 -0700
parents 52241b69c339
children
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
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 public void commit() throws IOException {
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 writer.commit();
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
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
23 public void deleteAll(long time) throws IOException {
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 writer.deleteAll();
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
29 public void deleteDocuments(long time,Query query) throws IOException {
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 writer.deleteDocuments(query);
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
35 public void addDocument(long time,Map<String,Object> storedFields) throws IOException {
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 writer.addDocument(storedFields);
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
41 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
42 if( !isActive )
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 return;
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 writer.updateDocument(keyFieldName,storedFields);
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46
1549
41c32da4cbd1 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
47 public void tag(long time,String tag) throws IOException {}
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 }