Search in sources :

Example 1 with LongKeyLongMap

use of com.b2international.collections.longs.LongKeyLongMap in project snow-owl by b2ihealthcare.

the class LongTarjanTest method smallBatchSize.

@Test
public void smallBatchSize() throws Exception {
    final LongKeyLongMap followerMap = PrimitiveMaps.newLongKeyLongOpenHashMap();
    followerMap.put(1, 2);
    followerMap.put(2, 3);
    followerMap.put(3, 4);
    followerMap.put(4, 1);
    followerMap.put(5, 3);
    followerMap.put(6, 2);
    followerMap.put(7, 8);
    followerMap.put(8, 6);
    final LongTarjan tarjan = new LongTarjan(3, currentId -> LongCollections.singletonSet(followerMap.get(currentId)));
    final List<LongSet> actual = tarjan.run(followerMap.keySet());
    assertEquals(ImmutableList.of(PrimitiveSets.newLongOpenHashSet(1L, 2L, 3L, 4L), PrimitiveSets.newLongOpenHashSet(5L, 6L, 8L), PrimitiveSets.newLongOpenHashSet(7L)), actual);
}
Also used : LongSet(com.b2international.collections.longs.LongSet) LongKeyLongMap(com.b2international.collections.longs.LongKeyLongMap) LongTarjan(com.b2international.commons.graph.LongTarjan) Test(org.junit.Test)

Example 2 with LongKeyLongMap

use of com.b2international.collections.longs.LongKeyLongMap in project snow-owl by b2ihealthcare.

the class EquivalencyChecker method processResults.

@Override
protected LongKeyLongMap processResults(final String classificationId) {
    final Set<String> conceptIdsToCheck = additionalConcepts.stream().map(SnomedConcept::getId).collect(Collectors.toSet());
    final LongKeyLongMap equivalentConceptMap = PrimitiveMaps.newLongKeyLongOpenHashMap();
    final ClassificationTask classificationTask = ClassificationRequests.prepareGetClassification(classificationId).setExpand("equivalentConceptSets()").build(repositoryId).execute(getEventBus()).getSync();
    if (!ClassificationStatus.COMPLETED.equals(classificationTask.getStatus())) {
        throw new ReasonerApiException("Selected reasoner could not start or failed to finish its job.");
    }
    if (!classificationTask.getEquivalentConceptsFound()) {
        return equivalentConceptMap;
    }
    final EquivalentConceptSets equivalentConceptSets = classificationTask.getEquivalentConceptSets();
    registerEquivalentConcepts(equivalentConceptSets, conceptIdsToCheck, equivalentConceptMap);
    return equivalentConceptMap;
}
Also used : ClassificationTask(com.b2international.snowowl.snomed.reasoner.domain.ClassificationTask) EquivalentConceptSets(com.b2international.snowowl.snomed.reasoner.domain.EquivalentConceptSets) LongKeyLongMap(com.b2international.collections.longs.LongKeyLongMap) ReasonerApiException(com.b2international.snowowl.snomed.reasoner.exceptions.ReasonerApiException)

Aggregations

LongKeyLongMap (com.b2international.collections.longs.LongKeyLongMap)2 LongSet (com.b2international.collections.longs.LongSet)1 LongTarjan (com.b2international.commons.graph.LongTarjan)1 ClassificationTask (com.b2international.snowowl.snomed.reasoner.domain.ClassificationTask)1 EquivalentConceptSets (com.b2international.snowowl.snomed.reasoner.domain.EquivalentConceptSets)1 ReasonerApiException (com.b2international.snowowl.snomed.reasoner.exceptions.ReasonerApiException)1 Test (org.junit.Test)1