Search in sources :

Example 1 with PatternScheduler

use of fr.lirmm.graphik.graal.homomorphism.scheduler.PatternScheduler in project graal by graphik-team.

the class BacktrackIteratorData method preprocessing.

private void preprocessing(Set<Variable> variablesToParameterize, Profiler profiler) throws HomomorphismException {
    profiler.start("preprocessingTime");
    // Compute order on query variables and atoms
    if (variablesToParameterize != null && !variablesToParameterize.isEmpty()) {
        assert this.scheduler instanceof PatternScheduler;
        PatternScheduler sched = (PatternScheduler) this.scheduler;
        this.varsOrder = sched.execute(this.query, variablesToParameterize, ans, this.data, this.compilation);
    } else {
        this.varsOrder = this.scheduler.execute(this.query, ans, this.data, this.compilation);
    }
    this.levelMax = varsOrder.length - 2;
    // PROFILING
    if (profiler.isProfilingEnabled()) {
        this.profilingVarOrder(this.varsOrder, profiler);
    }
    // Index Var structures by original variable object
    this.index = new TreeMap<Variable, Integer>();
    for (VarSharedData v : this.varsOrder) {
        if (v.value != null) {
            // 
            this.index.put(v.value, v.level);
        }
    }
    if (this.ans.isEmpty()) {
        this.varsOrder[this.levelMax + 1].previousLevel = -1;
    }
    computeAtomOrder(this.query, this.varsOrder, this.index);
    this.fc.init(this.varsOrder, this.index);
    this.bj.init(this.varsOrder);
    Set<Variable> allVarsFromH = query.getVariables();
    for (InMemoryAtomSet negPart : this.negParts) {
        Set<Variable> frontier = SetUtils.intersection(allVarsFromH, negPart.getVariables());
        this.varsOrder[maxLevel(frontier)].negatedPartsToCheck.add(BacktrackHomomorphismPattern.instance().prepareHomomorphism(new DefaultConjunctiveQuery(negPart, Collections.<Term>emptyList()), frontier, this.data, this.compilation));
    }
    profiler.stop("preprocessingTime");
}
Also used : DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) Variable(fr.lirmm.graphik.graal.api.core.Variable) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) PatternScheduler(fr.lirmm.graphik.graal.homomorphism.scheduler.PatternScheduler)

Aggregations

InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)1 Variable (fr.lirmm.graphik.graal.api.core.Variable)1 DefaultConjunctiveQuery (fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery)1 PatternScheduler (fr.lirmm.graphik.graal.homomorphism.scheduler.PatternScheduler)1