Skip to content

Commit 29bcf74

Browse files
committed
only lookup the mask or target if lookup is supported
1 parent 9b62ea9 commit 29bcf74

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

colormipsearch-persist/src/itest/java/org/janelia/colormipsearch/dao/mongo/PPPMatchesMongoDaoITest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.janelia.colormipsearch.dao.mongo;
22

33
import java.util.ArrayList;
4-
import java.util.Arrays;
54
import java.util.Collections;
65
import java.util.List;
76

@@ -18,7 +17,6 @@
1817
import static org.junit.Assert.assertNotNull;
1918
import static org.junit.Assert.assertNotSame;
2019
import static org.junit.Assert.assertNull;
21-
import static org.junit.Assert.assertSame;
2220

2321
public class PPPMatchesMongoDaoITest extends AbstractMongoDaoITest {
2422

colormipsearch-persist/src/main/java/org/janelia/colormipsearch/dao/mongo/AbstractNeuronMatchesMongoDao.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,22 +333,26 @@ protected List<Bson> createQueryPipeline(NeuronsMatchFilter<R> matchFilter,
333333
);
334334
}
335335

336-
pipeline.add(maskLookup);
337-
pipeline.add(targetLookup);
336+
if (supportsMaskLookup()) {
337+
pipeline.add(maskLookup);
338+
pipeline.add(Aggregates.unwind(
339+
"$maskImage",
340+
new UnwindOptions().preserveNullAndEmptyArrays(false)));
341+
}
338342

339-
pipeline.add(Aggregates.unwind(
340-
"$maskImage",
341-
new UnwindOptions().preserveNullAndEmptyArrays(preserveNullsWhenUnwindingMasks())));
342-
pipeline.add(Aggregates.unwind(
343-
"$image",
344-
new UnwindOptions().preserveNullAndEmptyArrays(preserveNullsWhenUnwindingTargets())));
343+
if (supportsTargetLookup()) {
344+
pipeline.add(targetLookup);
345+
pipeline.add(Aggregates.unwind(
346+
"$image",
347+
new UnwindOptions().preserveNullAndEmptyArrays(false)));
348+
}
345349

346350
return pipeline;
347351
}
348352

349-
abstract boolean preserveNullsWhenUnwindingMasks();
353+
abstract boolean supportsMaskLookup();
350354

351-
abstract boolean preserveNullsWhenUnwindingTargets();
355+
abstract boolean supportsTargetLookup();
352356

353357
private boolean hasBothImageRefs(R match) {
354358
return match.hasMaskImageRefId() && match.hasMatchedImageRefId();

colormipsearch-persist/src/main/java/org/janelia/colormipsearch/dao/mongo/CDMatchesMongoDao.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ public CDMatchesMongoDao(MongoDatabase mongoDatabase, IdGenerator idGenerator, b
1313
}
1414

1515
@Override
16-
boolean preserveNullsWhenUnwindingMasks() {
17-
return false;
16+
boolean supportsMaskLookup() {
17+
return true;
1818
}
1919

2020
@Override
21-
boolean preserveNullsWhenUnwindingTargets() {
22-
return false;
21+
boolean supportsTargetLookup() {
22+
return true;
2323
}
2424
}

colormipsearch-persist/src/main/java/org/janelia/colormipsearch/dao/mongo/PPPMatchesMongoDao.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ protected void createDocumentIndexes(boolean createAllIndexes) {
2626
}
2727

2828
@Override
29-
boolean preserveNullsWhenUnwindingMasks() {
30-
return false;
29+
boolean supportsMaskLookup() {
30+
return true;
3131
}
3232

3333
@Override
34-
boolean preserveNullsWhenUnwindingTargets() {
35-
return true;
34+
boolean supportsTargetLookup() {
35+
return false;
3636
}
3737
}

0 commit comments

Comments
 (0)