コード例 #1
0
ファイル: listLength.java プロジェクト: hmottestad/jena
 private QueryIterator length(
     Binding binding, Graph graph, Node listNode, Var varLength, ExecutionContext execCxt) {
   int x = GraphList.length(new GNode(graph, listNode));
   if (x < 0) return IterLib.noResults(execCxt);
   Node n = NodeFactoryExtra.intToNode(x);
   return IterLib.oneResult(binding, varLength, n, execCxt);
 }
コード例 #2
0
ファイル: listLength.java プロジェクト: hmottestad/jena
  private QueryIterator verify(
      Binding binding, Graph graph, Node listNode, Node length, ExecutionContext execCxt) {
    int x = GraphList.length(new GNode(graph, listNode));
    int len = NodeFactoryExtra.nodeToInt(length);

    if (x == len) return IterLib.result(binding, execCxt);
    return IterLib.noResults(execCxt);
  }
コード例 #3
0
ファイル: TextQueryPF.java プロジェクト: enderunal/jena
  private QueryIterator concreteSubject(
      Binding binding, Node s, Node score, Node literal, StrMatch match, ExecutionContext execCxt) {
    if (!s.isURI()) {
      log.warn("Subject not a URI: " + s);
      return IterLib.noResults(execCxt);
    }

    String qs = match.getQueryString();
    ListMultimap<String, TextHit> x =
        query(match.getProperty(), match.getQueryString(), -1, execCxt);

    if (x == null) // null return value - empty result
    return IterLib.noResults(execCxt);

    List<TextHit> r = x.get(s.getURI());

    return resultsToQueryIterator(binding, s, score, literal, r, execCxt);
  }
コード例 #4
0
ファイル: TextQueryPF.java プロジェクト: enderunal/jena
  @Override
  public QueryIterator exec(
      Binding binding,
      PropFuncArg argSubject,
      Node predicate,
      PropFuncArg argObject,
      ExecutionContext execCxt) {
    if (textIndex == null) {
      if (!warningIssued) {
        Log.warn(getClass(), "No text index - no text search performed");
        warningIssued = true;
      }
      // Not a text dataset - no-op
      return IterLib.result(binding, execCxt);
    }

    DatasetGraph dsg = execCxt.getDataset();

    argSubject = Substitute.substitute(argSubject, binding);
    argObject = Substitute.substitute(argObject, binding);

    Node s = null;
    Node score = null;
    Node literal = null;

    if (argSubject.isList()) {
      // Length checked in build()
      s = argSubject.getArg(0);
      score = argSubject.getArg(1);

      if (!score.isVariable())
        throw new QueryExecException("Hit score is not a variable: " + argSubject);

      if (argSubject.getArgListSize() > 2) {
        literal = argSubject.getArg(2);
        if (!literal.isVariable())
          throw new QueryExecException("Hit literal is not a variable: " + argSubject);
      }
    } else {
      s = argSubject.getArg();
    }

    if (s.isLiteral())
      // Does not match
      return IterLib.noResults(execCxt);

    StrMatch match = objectToStruct(argObject, true);
    if (match == null) {
      // can't match
      return IterLib.noResults(execCxt);
    }

    // ----

    QueryIterator qIter =
        (Var.isVar(s))
            ? variableSubject(binding, s, score, literal, match, execCxt)
            : concreteSubject(binding, s, score, literal, match, execCxt);
    if (match.getLimit() >= 0) qIter = new QueryIterSlice(qIter, 0, match.getLimit(), execCxt);
    return qIter;
  }