File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed
elastiknn-lucene/src/main/java
com/klibisz/elastiknn/search Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change
1
+ package com .klibisz .elastiknn .search ;
2
+
3
+ import org .apache .lucene .search .KthGreatest ;
4
+
5
+ public final class EmptyHitCounter implements HitCounter {
6
+ @ Override
7
+ public void increment (int key , short count ) {}
8
+
9
+ @ Override
10
+ public void increment (int key , int count ) {}
11
+
12
+ @ Override
13
+ public boolean isEmpty () {
14
+ return true ;
15
+ }
16
+
17
+ @ Override
18
+ public short get (int key ) {
19
+ return 0 ;
20
+ }
21
+
22
+ @ Override
23
+ public int numHits () {
24
+ return 0 ;
25
+ }
26
+
27
+ @ Override
28
+ public int capacity () {
29
+ return 0 ;
30
+ }
31
+
32
+ @ Override
33
+ public int minKey () {
34
+ return 0 ;
35
+ }
36
+
37
+ @ Override
38
+ public int maxKey () {
39
+ return 0 ;
40
+ }
41
+
42
+ @ Override
43
+ public KthGreatest .Result kthGreatest (int k ) {
44
+ return new KthGreatest .Result ((short ) 0 , 0 , 0 );
45
+ }
46
+ }
Original file line number Diff line number Diff line change 2
2
3
3
import com .klibisz .elastiknn .models .HashAndFreq ;
4
4
import com .klibisz .elastiknn .search .ArrayHitCounter ;
5
+ import com .klibisz .elastiknn .search .EmptyHitCounter ;
5
6
import com .klibisz .elastiknn .search .HitCounter ;
6
7
import org .apache .lucene .index .*;
7
8
import org .apache .lucene .util .BytesRef ;
@@ -58,7 +59,7 @@ private HitCounter countHits(LeafReader reader) throws IOException {
58
59
Terms terms = reader .terms (field );
59
60
// terms seem to be null after deleting docs. https://github.com/alexklibisz/elastiknn/issues/158
60
61
if (terms == null ) {
61
- return new ArrayHitCounter ( 0 );
62
+ return new EmptyHitCounter ( );
62
63
} else {
63
64
TermsEnum termsEnum = terms .iterator ();
64
65
PostingsEnum docs = null ;
You can’t perform that action at this time.
0 commit comments