use of com.vaticle.typedb.core.common.parameters.Label in project grakn by graknlabs.
the class TypeGraph method getType.
public TypeVertex getType(String label, @Nullable String scope) {
assert storage.isOpen();
String scopedLabel = scopedLabel(label, scope);
try {
if (!isReadOnly) {
multiLabelLock.readLock().lock();
singleLabelLocks.computeIfAbsent(scopedLabel, x -> newReadWriteLock()).readLock().lock();
}
TypeVertex vertex = typesByLabel.get(scopedLabel);
if (vertex != null)
return vertex;
IndexIID.Type index = IndexIID.Type.Label.of(label, scope);
ByteArray iid = storage.get(index);
if (iid != null) {
vertex = typesByIID.computeIfAbsent(VertexIID.Type.of(iid), i -> new TypeVertexImpl.Persisted(this, i, label, scope));
typesByLabel.putIfAbsent(scopedLabel, vertex);
}
return vertex;
} finally {
if (!isReadOnly) {
singleLabelLocks.get(scopedLabel).readLock().unlock();
multiLabelLock.readLock().unlock();
}
}
}
use of com.vaticle.typedb.core.common.parameters.Label in project grakn by graknlabs.
the class LogicManager method getRule.
public Rule getRule(String label) {
Rule rule = logicCache.rule().getIfPresent(label);
if (rule != null)
return rule;
RuleStructure structure = graphMgr.schema().rules().get(label);
if (structure != null)
return logicCache.rule().get(structure.label(), l -> Rule.of(this, structure));
return null;
}
use of com.vaticle.typedb.core.common.parameters.Label in project grakn by graknlabs.
the class TypeInference method propagateLabels.
private void propagateLabels(Conjunction conj) {
iterate(conj.variables()).filter(v -> v.isType() && v.asType().label().isPresent()).forEachRemaining(typeVar -> {
Label label = typeVar.asType().label().get().properLabel();
if (label.scope().isPresent()) {
Set<Label> labels = graphMgr.schema().resolveRoleTypeLabels(label);
if (labels.isEmpty())
throw TypeDBException.of(ROLE_TYPE_NOT_FOUND, label.name(), label.scope().get());
typeVar.addInferredTypes(labels);
} else {
if (graphMgr.schema().getType(label) == null)
throw TypeDBException.of(TYPE_NOT_FOUND, label);
typeVar.addInferredTypes(label);
}
});
}
Aggregations