Search in sources :

Example 11 with ThreadTrace

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);
    }
}
Also used : ThreadTrace(com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.ThreadTrace)

Example 12 with ThreadTrace

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());
        });
    }
}
Also used : ThreadTrace(com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.ThreadTrace)

Example 13 with ThreadTrace

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);
    }
}
Also used : BoundVariable(com.vaticle.typeql.lang.pattern.variable.BoundVariable) ArrayList(java.util.ArrayList) VariableRegistry(com.vaticle.typedb.core.pattern.variable.VariableRegistry) ThreadTrace(com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.ThreadTrace)

Example 14 with ThreadTrace

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);
    }
}
Also used : Variable(com.vaticle.typedb.core.pattern.variable.Variable) ThreadTrace(com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.ThreadTrace)

Aggregations

ThreadTrace (com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.ThreadTrace)14 ThingType (com.vaticle.typedb.core.concept.type.ThingType)6 LabelConstraint (com.vaticle.typedb.core.pattern.constraint.type.LabelConstraint)5 AttributeType (com.vaticle.typedb.core.concept.type.AttributeType)3 RoleType (com.vaticle.typedb.core.concept.type.RoleType)3 VariableRegistry (com.vaticle.typedb.core.pattern.variable.VariableRegistry)3 FactoryTracingThreadStatic.traceOnThread (com.vaticle.factory.tracing.client.FactoryTracingThreadStatic.traceOnThread)2 TYPE_NOT_FOUND (com.vaticle.typedb.core.common.exception.ErrorMessage.TypeRead.TYPE_NOT_FOUND)2 ROLE_DEFINED_OUTSIDE_OF_RELATION (com.vaticle.typedb.core.common.exception.ErrorMessage.TypeWrite.ROLE_DEFINED_OUTSIDE_OF_RELATION)2 TYPE_CONSTRAINT_UNACCEPTED (com.vaticle.typedb.core.common.exception.ErrorMessage.TypeWrite.TYPE_CONSTRAINT_UNACCEPTED)2 TypeDBException (com.vaticle.typedb.core.common.exception.TypeDBException)2 Context (com.vaticle.typedb.core.common.parameters.Context)2 ConceptManager (com.vaticle.typedb.core.concept.ConceptManager)2 ValueType (com.vaticle.typedb.core.concept.type.AttributeType.ValueType)2 RelationType (com.vaticle.typedb.core.concept.type.RelationType)2 LogicManager (com.vaticle.typedb.core.logic.LogicManager)2 OwnsConstraint (com.vaticle.typedb.core.pattern.constraint.type.OwnsConstraint)2 PlaysConstraint (com.vaticle.typedb.core.pattern.constraint.type.PlaysConstraint)2 RegexConstraint (com.vaticle.typedb.core.pattern.constraint.type.RegexConstraint)2 RelatesConstraint (com.vaticle.typedb.core.pattern.constraint.type.RelatesConstraint)2