Fixed nullpointer bug in rare circumstances with empty VCs (#33)
Change-Id: Id43e6e427ed258be03494b1e82b0d504ac5a8cc9
diff --git a/Changes b/Changes
index 0768a6a..ad32006 100644
--- a/Changes
+++ b/Changes
@@ -1,9 +1,12 @@
-0.55.8 2017-07-04
+0.55.8 2017-09-05
- [feature] Retrieve and display pagebreaks (diewald)
- [bugfix] Handle invalid dates in input (diewald)
- [feature] Support availability meta data (diewald)
- [bugfix] Do not respond with a "match all" VC if the
VC data (e.g. JSON) is wrong (diewald)
+ - [cleanup] Improved test suite for queries/VC with wildcards
+ and regexes (margaretha, diewald)
+ - [bugfix] Ignore zero-bit bitset segments in searching (diewald)
0.55.7 2017-01-24
- [bugfix] Sorted results in unordered element distance query
diff --git a/src/main/java/de/ids_mannheim/korap/KrillIndex.java b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
index 7c52a10..4a82670 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
@@ -1351,7 +1351,12 @@
* Todo: There may be a way to know early if the bitset is emty
* by using LongBitSet - but this may not be as fast as I think.
*/
- final Bits bitset = collection.bits(atomic);
+ final FixedBitSet bitset = collection.bits(atomic);
+
+ if (bitset.nextSetBit(0) == DocIdSetIterator.NO_MORE_DOCS) {
+ continue;
+ };
+
final PositionsToOffset pto = new PositionsToOffset(atomic,
field);
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
index 745ef05..2e88db8 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
@@ -398,6 +398,8 @@
.getResource("/queries/bugs/cosmas_wildcards_qao.jsonld")
.getFile());
krill = new Krill(json);
+ assertEquals(krill.getCollection().toString(),
+ "QueryWrapperFilter(availability:/QAO.*/)");
kr = krill.apply(sample);
assertEquals(4, kr.getMatches().size());
}