diff --git a/reasoner/reasoner-hybrid/src/main/java/dev/ikm/tinkar/reasoner/hybrid/HybridReasonerService.java b/reasoner/reasoner-hybrid/src/main/java/dev/ikm/tinkar/reasoner/hybrid/HybridReasonerService.java index 6edce6a5a..293a5305f 100644 --- a/reasoner/reasoner-hybrid/src/main/java/dev/ikm/tinkar/reasoner/hybrid/HybridReasonerService.java +++ b/reasoner/reasoner-hybrid/src/main/java/dev/ikm/tinkar/reasoner/hybrid/HybridReasonerService.java @@ -96,8 +96,8 @@ public void processIncremental(DiTreeEntity definition, int conceptNid, Tracking public void buildNecessaryNormalForm(TrackingCallable progressUpdater) { //TODO: refactor to use primitive collections directly. nnfb = NecessaryNormalFormBuilder.create(sso.getOntology(), - convertToLongMap(sso.getSuperConcepts()), - convertToLongMap(sso.getSuperRoleTypes(false)), + sso.getSuperConcepts(), + sso.getSuperRoleTypes(false), TinkarTerm.ROOT_VERTEX.nid(), (workDone, max) -> progressUpdater.updateProgress(workDone, max)); nnfb.generate(); @@ -124,26 +124,21 @@ private MutableLongObjectMap convertToLongMap(HashMap eqs = sso.getEquivalentConcepts(id); - MutableIntSet eqsInt = IntSets.mutable.empty(); - eqs.stream().mapToInt(Long::intValue).forEach(eqsInt::add); - return eqsInt.toImmutable(); + MutableLongSet eqs = sso.getEquivalentConcepts(id); + return toIntSet(eqs); } @Override public ImmutableIntSet getParents(int id) { - Set supers = sso.getSuperConcepts(id); - MutableIntSet eqsInt = IntSets.mutable.empty(); - supers.stream().mapToInt(Long::intValue).forEach(eqsInt::add); - return eqsInt.toImmutable(); + MutableLongSet supers = sso.getSuperConcepts(id); + return toIntSet(supers); } @Override public ImmutableIntSet getChildren(int id) { - Set subs = sso.getSubConcepts(id); - MutableIntSet eqsInt = IntSets.mutable.empty(); - subs.stream().mapToInt(Long::intValue).forEach(eqsInt::add); - return eqsInt.toImmutable(); + MutableLongSet subs = sso.getSubConcepts(id); + return toIntSet(subs); + } } diff --git a/reasoner/reasoner-hybrid/src/test/java/dev/ikm/tinkar/reasoner/hybrid/HybridClassifierWithoutAbsentTestBase.java b/reasoner/reasoner-hybrid/src/test/java/dev/ikm/tinkar/reasoner/hybrid/HybridClassifierWithoutAbsentTestBase.java index 82be8ad2e..909a11344 100644 --- a/reasoner/reasoner-hybrid/src/test/java/dev/ikm/tinkar/reasoner/hybrid/HybridClassifierWithoutAbsentTestBase.java +++ b/reasoner/reasoner-hybrid/src/test/java/dev/ikm/tinkar/reasoner/hybrid/HybridClassifierWithoutAbsentTestBase.java @@ -28,6 +28,7 @@ import org.eclipse.collections.api.list.primitive.MutableLongList; import org.eclipse.collections.api.set.primitive.ImmutableLongSet; +import org.eclipse.collections.api.set.primitive.MutableLongSet; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,8 +51,8 @@ public abstract class HybridClassifierWithoutAbsentTestBase extends HybridReason private HashMap nid_sctid_map; - private Set toSctids(Set nids) { - return nids.stream().map(x -> nid_sctid_map.get(x.intValue())).collect(Collectors.toSet()); + private Set toSctids(MutableLongSet mutableLongSet) { + return mutableLongSet.collect(x -> nid_sctid_map.get((int) x)); } /** @@ -103,7 +104,7 @@ public void isas() throws Exception { assertTrue(parents.isEmpty()); // has a parent in the db assertEquals(1, sups.size()); - assertEquals(TinkarTerm.PHENOMENON.nid(), sso.getSuperConcepts(nid).iterator().next()); + assertEquals(TinkarTerm.PHENOMENON.nid(), sso.getSuperConcepts(nid).longIterator().next()); continue; } else { assertNotNull(parents); @@ -135,8 +136,7 @@ public void isas() throws Exception { LOG.error("Sno: " + par); LOG.error("Elk: " + sup); if (sups.contains(null)) { - sso.getSuperConcepts(nid) - .forEach(sup_nid -> LOG.error(" : " + PrimitiveData.text((sup_nid.intValue())))); + sso.getSuperConcepts(nid).forEach(sup_nid -> LOG.error(" : " + PrimitiveData.text((int) sup_nid))); } } LOG.error("Miss cnt: " + miss_cnt);