Skip to content

Commit 5a74896

Browse files
committed
Short circuit count=0 and cutoff=true
Change-Id: If46ffeff677e8d28fedfd24a664d6a7833f810a0
1 parent 776976b commit 5a74896

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

Changes

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
0.63.3 2024-09-24
2+
- [performance] Improve short circuit on count=0 and
3+
cutoff=true (diewald)
4+
15
0.63.2 2024-08-02
26
- [bugfix] Fix empty DocIdSetIterator (margaretha)
37
- [bugfix] Don't throw warnings on expansion failure (diewald)

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
<groupId>de.ids-mannheim.korap.krill</groupId>
3737
<artifactId>Krill</artifactId>
38-
<version>0.63.2</version>
38+
<version>0.63.3</version>
3939
<packaging>jar</packaging>
4040

4141
<name>Krill</name>

src/main/java/de/ids_mannheim/korap/KrillIndex.java

+6
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,12 @@ public Result search (Krill ks) {
14231423
return kr;
14241424
};
14251425

1426+
if (cutoff && count == 0) {
1427+
kr.setTotalResults(-1);
1428+
kr.setTotalResources(-1);
1429+
return kr;
1430+
};
1431+
14261432
// Collect matches from atomic readers
14271433
final ArrayList<Match> atomicMatches = new ArrayList<Match>(
14281434
kr.getItemsPerPage());

src/test/java/de/ids_mannheim/korap/search/TestKrill.java

+11
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,20 @@ public void searchIndex () throws IOException {
136136
assertEquals(kr.getItemsPerPage(), 0);
137137
assertEquals(kr.getMatches().size(), 0);
138138

139+
// Handle count=0 correctly
140+
meta = ks.getMeta();
141+
meta.setCount(0);
142+
meta.setCutOff(true);
143+
144+
kr = ks.apply(ki);
145+
assertEquals(kr.getTotalResults(), -1);
146+
assertEquals(kr.getItemsPerPage(), 0);
147+
assertEquals(kr.getMatches().size(), 0);
148+
139149
// Handle tokens=true and
140150
// snippet=false correctly
141151
meta = ks.getMeta();
152+
meta.setCutOff(false);
142153
meta.setCount(1);
143154
meta.setTokens(true);
144155
meta.setSnippets(false);

0 commit comments

Comments
 (0)