コード例 #1
0
ファイル: LPInterpreter.java プロジェクト: hmottestad/jena
  /**
   * Constructor.
   *
   * @param engine the engine which is calling this interpreter
   * @param goal the query to be satisfied
   * @param clauses the set of code blocks needed to implement this goal
   * @param isTop true if this is a top level call from the outside iterator, false means it is an
   *     internal generator call which means we don't need to insert an tabled call
   */
  public LPInterpreter(
      LPBRuleEngine engine, TriplePattern goal, List<RuleClauseCode> clauses, boolean isTop) {
    this.engine = engine;
    this.goal = goal; // Used for debug only

    // Construct dummy top environemnt which is a call into the clauses for this goal
    if (engine.getDerivationLogging()) {
      envFrame = new EnvironmentFrameWithDerivation(RuleClauseCode.returnCodeBlock);
    } else {
      envFrame = new EnvironmentFrame(RuleClauseCode.returnCodeBlock);
    }
    envFrame.allocate(RuleClauseCode.MAX_PERMANENT_VARS);
    HashMap<Node, Node> mappedVars = new HashMap<>();
    envFrame.pVars[0] = argVars[0] = standardize(goal.getSubject(), mappedVars);
    envFrame.pVars[1] = argVars[1] = standardize(goal.getPredicate(), mappedVars);
    envFrame.pVars[2] = argVars[2] = standardize(goal.getObject(), mappedVars);
    if (engine.getDerivationLogging()) {
      ((EnvironmentFrameWithDerivation) envFrame).initDerivationRecord(argVars);
    }

    if (clauses != null && clauses.size() > 0) {
      if (isTop && engine.getRuleStore().isTabled(goal)) {
        setupTabledCall(0, 0);
        //                setupClauseCall(0, 0, clauses);
      } else {
        setupClauseCall(0, 0, clauses, goal.isGround());
      }
    }

    //        TripleMatchFrame tmFrame = new TripleMatchFrame(this);
    topTMFrame = new TopLevelTripleMatchFrame(this, goal);
    topTMFrame.linkTo(cpFrame);
    topTMFrame.setContinuation(0, 0);
    cpFrame = topTMFrame;
  }
コード例 #2
0
ファイル: LPInterpreter.java プロジェクト: hmottestad/jena
 /** Return a dereferenced copy of a triple. */
 public static Triple deref(TriplePattern t) {
   if (t == null) return null;
   return new Triple(deref(t.getSubject()), deref(t.getPredicate()), deref(t.getObject()));
 }