Skip to content

Commit ffd785c

Browse files
committed
fix: For empty bitmaps use EmptyFormula.INSTANCE!
1 parent 6fc208b commit ffd785c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

evita_engine/src/main/java/io/evitadb/core/query/filter/translator/attribute/AttributeIsTranslator.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* | __/\ V /| | || (_| | |_| | |_) |
77
* \___| \_/ |_|\__\__,_|____/|____/
88
*
9-
* Copyright (c) 2023-2024
9+
* Copyright (c) 2023-2025
1010
*
1111
* Licensed under the Business Source License, Version 1.1 (the "License");
1212
* you may not use this file except in compliance with the License.
@@ -46,6 +46,7 @@
4646
import io.evitadb.index.EntityIndex;
4747
import io.evitadb.index.attribute.FilterIndex;
4848
import io.evitadb.index.attribute.UniqueIndex;
49+
import io.evitadb.index.bitmap.Bitmap;
4950

5051
import javax.annotation.Nonnull;
5152
import java.util.Objects;
@@ -243,7 +244,10 @@ private static Formula translateIsNotNull(
243244
attributeKey,
244245
filterByVisitor.applyOnGlobalUniqueIndexes(
245246
globalAttributeSchema,
246-
index -> new ConstantFormula(index.getRecordIds(filterByVisitor.getEntityType()))
247+
index -> {
248+
final Bitmap recordIds = index.getRecordIds(filterByVisitor.getEntityType());
249+
return recordIds.isEmpty() ? EmptyFormula.INSTANCE : new ConstantFormula(recordIds);
250+
}
247251
)
248252
);
249253
} else if (scopes.stream().anyMatch(attributeDefinition::isUniqueInScope)) {
@@ -252,7 +256,10 @@ private static Formula translateIsNotNull(
252256
attributeKey,
253257
filterByVisitor.applyOnUniqueIndexes(
254258
attributeDefinition,
255-
index -> new ConstantFormula(index.getRecordIds())
259+
index -> {
260+
final Bitmap recordIds = index.getRecordIds();
261+
return recordIds.isEmpty() ? EmptyFormula.INSTANCE : new ConstantFormula(recordIds);
262+
}
256263
)
257264
);
258265
} else {

0 commit comments

Comments
 (0)