use of com.b2international.collections.longs.LongSet in project snow-owl by b2ihealthcare.
the class LongOpenHashSetTest method create_one_fill_factor.
@Test
public void create_one_fill_factor() {
LongSet longSet = PrimitiveSets.newLongOpenHashSetWithExpectedSize(10, 1.0d);
assertTrue("Long set should be empty.", longSet.isEmpty());
}
use of com.b2international.collections.longs.LongSet in project snow-owl by b2ihealthcare.
the class IconIdUpdater method getParentIcon.
private Optional<String> getParentIcon(String id, TaxonomyGraph taxonomyGraph) {
if (id == null || !taxonomyGraph.containsNode(Long.parseLong(id))) {
return Optional.empty();
}
final Set<String> visitedNodes = Sets.newHashSet();
final Set<String> candidates = Sets.newTreeSet();
final Deque<String> toVisit = new ArrayDeque<>();
toVisit.add(id);
while (!toVisit.isEmpty()) {
final String currentId = toVisit.removeFirst();
if (!visitedNodes.add(currentId)) {
continue;
}
if (availableImages.contains(currentId)) {
candidates.add(currentId);
} else {
// XXX: we stop looking further "up" this hierarchy if there is any image present for the visited concept
final LongSet ancestorNodeIds = taxonomyGraph.getAncestorNodeIds(Long.parseLong(currentId));
toVisit.addAll(LongSets.toStringList(ancestorNodeIds));
}
}
return candidates.stream().findFirst();
}
use of com.b2international.collections.longs.LongSet in project snow-owl by b2ihealthcare.
the class InternalSctIdMultimap method get.
@Override
public LongSet get(final long key) {
final int internalId = internalIdMap.getInternalId(key);
if (internalId == InternalIdMap.NO_INTERNAL_ID) {
return PrimitiveSets.newLongOpenHashSet();
}
final IntSet values = internalIdMultimap.get(internalId);
if (values == null) {
return PrimitiveSets.newLongOpenHashSet();
} else {
final LongSet sctIdValues = PrimitiveSets.newLongOpenHashSetWithExpectedSize(values.size());
for (final IntIterator itr = values.iterator(); itr.hasNext(); ) /*empty*/
{
final int valueInternalId = itr.next();
final long valueSctId = internalIdMap.getSctId(valueInternalId);
sctIdValues.add(valueSctId);
}
return sctIdValues;
}
}
use of com.b2international.collections.longs.LongSet in project snow-owl by b2ihealthcare.
the class InternalSctIdMultimap method keySet.
@Override
public LongSet keySet() {
final LongSet keySet = PrimitiveSets.newLongOpenHashSetWithExpectedSize(internalIdMultimap.size());
for (final IntIterator itr = internalIdMultimap.keySet().iterator(); itr.hasNext(); ) /*empty*/
{
final int keyInternalId = itr.next();
final long keySctId = internalIdMap.getSctId(keyInternalId);
keySet.add(keySctId);
}
return keySet;
}
use of com.b2international.collections.longs.LongSet in project snow-owl by b2ihealthcare.
the class ReasonerTaxonomyInferrer method processNode.
private NodeSet<OWLClass> processNode(final Node<OWLClass> node, Set<Node<OWLClass>> deferredNodes) {
// Stop the walk if the node has already been visited
if (isNodeProcessed(node)) {
return EMPTY_NODE_SET;
}
// Check first if the current node is the "bottom" one, as all OWL classes are superclasses of owl:Nothing
final LongSet conceptIds = collectConceptIds(node, PrimitiveSets.newLongOpenHashSet());
// Stop the walk if we are at the bottom (we should only reach the bottom node once)
if (node.isBottomNode()) {
addUnsatisfiableConcepts(conceptIds);
processedConceptIds.addAll(conceptIds);
iterationOrder.addAll(conceptIds);
return EMPTY_NODE_SET;
}
// All parents must be visited before this item can be processed; if not, the same node will appear later again, so stop walking
final NodeSet<OWLClass> parentNodeSet = reasoner.getSuperClasses(node.getRepresentativeElement(), true);
for (final Node<OWLClass> parentNode : parentNodeSet) {
if (!isNodeProcessed(parentNode)) {
deferredNodes.add(node);
return EMPTY_NODE_SET;
}
}
// Nodes that contain more than one concept are an indication of equivalence
if (conceptIds.size() > 1) {
addEquivalentConcepts(conceptIds);
}
// Extract parents and ancestors using the reasoner
final LongSet parentConceptIds = PrimitiveSets.newLongOpenHashSet();
for (final Node<OWLClass> parentNode : parentNodeSet) {
collectConceptIds(parentNode, parentConceptIds);
}
addEdges(conceptIds, parentConceptIds);
processedConceptIds.addAll(conceptIds);
iterationOrder.addAll(conceptIds);
return computeNextNodeSet(node);
}
Aggregations