use of com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.ThreadTrace in project grakn by graknlabs.
the class Undefiner method execute.
public void execute() {
try (ThreadTrace ignored = traceOnThread(TRACE_PREFIX + "execute")) {
rules.forEach(this::undefine);
variables.forEach(this::undefine);
}
}
use of com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.ThreadTrace in project grakn by graknlabs.
the class Definer method defineRelates.
private void defineRelates(RelationType relationType, Set<RelatesConstraint> relatesConstraints) {
try (ThreadTrace ignored = traceOnThread(TRACE_PREFIX + "define_relates")) {
relatesConstraints.forEach(relates -> {
String roleTypeLabel = relates.role().label().get().label();
if (relates.overridden().isPresent()) {
String overriddenTypeLabel = relates.overridden().get().label().get().label();
relationType.setRelates(roleTypeLabel, overriddenTypeLabel);
defined.add(relates.overridden().get());
} else {
relationType.setRelates(roleTypeLabel);
}
defined.add(relates.role());
});
}
}
use of com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.ThreadTrace in project grakn by graknlabs.
the class Conjunction method create.
public static Conjunction create(com.vaticle.typeql.lang.pattern.Conjunction<Conjunctable> typeql, @Nullable VariableRegistry bounds) {
try (ThreadTrace ignored = traceOnThread(TRACE_PREFIX + "create")) {
List<BoundVariable> typeQLVariables = new ArrayList<>();
List<com.vaticle.typeql.lang.pattern.Negation<?>> typeQLNegations = new ArrayList<>();
typeql.patterns().forEach(conjunctable -> {
if (conjunctable.isVariable())
typeQLVariables.add(conjunctable.asVariable());
else if (conjunctable.isNegation())
typeQLNegations.add(conjunctable.asNegation());
else
throw TypeDBException.of(ILLEGAL_STATE);
});
if (typeQLVariables.isEmpty() && !typeQLNegations.isEmpty())
throw TypeDBException.of(UNBOUNDED_NEGATION);
VariableRegistry registry = VariableRegistry.createFromVariables(typeQLVariables, bounds);
List<Negation> typeDBNegations = typeQLNegations.isEmpty() ? list() : typeQLNegations.stream().map(n -> Negation.create(n, registry)).collect(toList());
return new Conjunction(registry.variables(), typeDBNegations);
}
}
use of com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.ThreadTrace in project grakn by graknlabs.
the class Negation method create.
public static Negation create(com.vaticle.typeql.lang.pattern.Negation<?> typeql, VariableRegistry bounds) {
try (ThreadTrace ignored = traceOnThread(TRACE_PREFIX + "create")) {
Disjunction disjunction = Disjunction.create(typeql.normalise().pattern(), bounds);
disjunction.conjunctions().forEach(conjunction -> {
if (iterate(conjunction.variables()).map(Variable::reference).filter(Reference::isName).noneMatch(bounds::contains)) {
throw TypeDBException.of(UNBOUNDED_NEGATION);
}
});
return new Negation(disjunction);
}
}
Aggregations