jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [04/13] jena git commit: Merge branch 'master' of https://github.com/apache/jena
Date Tue, 02 Jun 2015 12:56:26 GMT
Merge branch 'master' of https://github.com/apache/jena

Conflicts:
	jena-text/src/main/java/org/apache/jena/query/text/TextIndex.java
	jena-text/src/main/java/org/apache/jena/query/text/TextIndexSolr.java
	jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/1b125934
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/1b125934
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/1b125934

Branch: refs/heads/master
Commit: 1b125934f585aba3e267f77a36cc03a6771aaaaa
Parents: 3f0c517 e789e9f
Author: Osma Suominen <osma.suominen@aalto.fi>
Authored: Fri May 29 15:42:27 2015 +0300
Committer: Osma Suominen <osma.suominen@aalto.fi>
Committed: Fri May 29 15:42:27 2015 +0300

----------------------------------------------------------------------
 .../org/apache/jena/riot/lang/ReaderTriX.java   |   3 +-
 .../jena/datatypes/xsd/impl/RDFLangString.java  |   2 +-
 .../apache/jena/graph/test/NodeCreateUtils.java |   4 +-
 jena-fuseki1/soh                                |   2 +-
 jena-fuseki2/apache-jena-fuseki/bin/s-delete    |  16 ++-
 jena-fuseki2/apache-jena-fuseki/bin/s-get       |  16 ++-
 jena-fuseki2/apache-jena-fuseki/bin/s-head      |  16 ++-
 jena-fuseki2/apache-jena-fuseki/bin/s-post      |  16 ++-
 jena-fuseki2/apache-jena-fuseki/bin/s-put       |  16 ++-
 jena-fuseki2/apache-jena-fuseki/bin/s-query     |  16 ++-
 jena-fuseki2/apache-jena-fuseki/bin/s-update    |  16 ++-
 .../apache-jena-fuseki/bin/s-update-form        |  16 ++-
 jena-fuseki2/apache-jena-fuseki/bin/soh         |  16 ++-
 .../jena/fuseki/servlets/SPARQL_Protocol.java   |   9 +-
 .../jena/fuseki/servlets/SPARQL_Query.java      |   9 +-
 .../jena/fuseki/servlets/SPARQL_Update.java     |   7 +-
 .../org/apache/jena/query/text/TextIndex.java   |   4 +-
 .../apache/jena/query/text/TextIndexLucene.java |  24 ++--
 .../query/text/TextIndexParseException.java     |  40 +++++++
 .../apache/jena/query/text/TextIndexSolr.java   | 119 +++++++++----------
 .../org/apache/jena/query/text/TextQueryPF.java |  74 +++++++-----
 21 files changed, 269 insertions(+), 172 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/1b125934/jena-text/src/main/java/org/apache/jena/query/text/TextIndex.java
----------------------------------------------------------------------
diff --cc jena-text/src/main/java/org/apache/jena/query/text/TextIndex.java
index b57db5b,fe19b7b..a34e87a
--- a/jena-text/src/main/java/org/apache/jena/query/text/TextIndex.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/TextIndex.java
@@@ -45,10 -45,12 +45,12 @@@ public interface TextIndex extends Clos
      //** score
      // Need to have more complex results.
      
-     /** Access the index - limit if -1 for as many as possible */ 
+     /** Access the index - limit if -1 for as many as possible 
+      * Throw QueryParseException for syntax errors in the query string.
+      */ 
 -    List<Node> query(String qs, int limit) ;
 +    List<TextHit> query(String qs, int limit) ;
      
 -    List<Node> query(String qs) ;
 +    List<TextHit> query(String qs) ;
  
      EntityDefinition getDocDef() ;
  }

http://git-wip-us.apache.org/repos/asf/jena/blob/1b125934/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/jena/blob/1b125934/jena-text/src/main/java/org/apache/jena/query/text/TextIndexSolr.java
----------------------------------------------------------------------
diff --cc jena-text/src/main/java/org/apache/jena/query/text/TextIndexSolr.java
index 69848d8,718d4c7..b9bddaf
--- a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexSolr.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/TextIndexSolr.java
@@@ -183,38 -178,36 +178,35 @@@ public class TextIndexSolr implements T
      }
  
      @Override
 -    public List<Node> query(String qs) { return query(qs, 0) ; } 
 +    public List<TextHit> query(String qs) { return query(qs, 0) ; } 
  
      @Override
-     public List<TextHit> query(String qs, int limit)
-     {
 -    public List<Node> query(String qs, int limit) {
++    public List<TextHit> query(String qs, int limit) {
          SolrDocumentList solrResults = solrQuery(qs, limit) ;
 -        List<Node> results = new ArrayList<>() ;
 +        List<TextHit> results = new ArrayList<>() ;
  
-         for ( SolrDocument sd : solrResults )
-         {
+         for ( SolrDocument sd : solrResults ) {
 -            // ** score
 -            // 'score' field.
              String str = (String)sd.getFieldValue(docDef.getEntityField()) ;
-             //log.info("Entity: "+uriStr) ;
+             // log.info("Entity: "+uriStr) ;
              Node n = TextQueryFuncs.stringToNode(str) ;
 -            results.add(n) ;
 +            Float score = (Float) sd.getFirstValue("score");
 +            TextHit hit = new TextHit(n, score.floatValue());
 +            results.add(hit) ;
          }
  
          if ( limit > 0 && results.size() > limit )
              results = results.subList(0, limit) ;
  
-         return results ; 
+         return results ;
      }
  
-     private SolrDocumentList solrQuery(String qs, int limit)
-     {
+     private SolrDocumentList solrQuery(String qs, int limit) {
          SolrQuery sq = new SolrQuery(qs) ;
 -        // ** score
 -        // sq.setIncludeScore(true) ;
 +        sq.setIncludeScore(true) ;
          if ( limit > 0 )
              sq.setRows(limit) ;
-         else 
-             sq.setRows(MAX_N) ;   // The Solr default is 10.
+         else
+             sq.setRows(MAX_N) ; // The Solr default is 10.
          try {
              // Set default field.
              sq.add(CommonParams.DF, docDef.getPrimaryField()) ;

http://git-wip-us.apache.org/repos/asf/jena/blob/1b125934/jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java
----------------------------------------------------------------------
diff --cc jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java
index 4b37d95,5a48add..587f562
--- a/jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java
@@@ -52,12 -47,12 +52,10 @@@ import org.slf4j.LoggerFactory 
  public class TextQueryPF extends PropertyFunctionBase {
      private static Logger log = LoggerFactory.getLogger(TextQueryPF.class) ;
      /*
--     * ?uri :queryPF (property? "string" limit? score?) 
--     * (?uri ?score) not implemented
--     * Look for "//** score" in TextQueryPF, TextIndexLucene and TextIndexSolr
++     * (?uri ?score) :queryPF (property? "string" limit? score?) 
       */
  
-     private TextIndex     server        = null ;
+     private TextIndex     textIndex        = null ;
      private boolean       warningIssued = false ;
  
      public TextQueryPF() {}
@@@ -67,20 -62,16 +65,15 @@@
      @Override
      public void build(PropFuncArg argSubject, Node predicate, PropFuncArg argObject, ExecutionContext
execCxt) {
          super.build(argSubject, predicate, argObject, execCxt) ;
--        //** score
--        // Subject possibilities become ?foo or (?foo ?score) 
          DatasetGraph dsg = execCxt.getDataset() ;
-         server = chooseTextIndex(dsg) ;
+         textIndex = chooseTextIndex(dsg) ;
 -        if (!argSubject.isNode())
 -            throw new QueryBuildException("Subject is not a single node: " + argSubject)
;
 +
 +        if (argSubject.isList() && argSubject.getArgListSize() != 2)
 +            throw new QueryBuildException("Subject has "+argSubject.getArgList().size()+"
elements, not 2: "+argSubject);
  
          if (argObject.isList()) {
-             //extract of extra lang arg if present and if is usable.
-             //arg is removed from the list to avoid conflict with order and args length
-             langArg = extractArg("lang", argObject);
- 
              List<Node> list = argObject.getArgList() ;
+ 
              if (list.size() == 0)
                  throw new QueryBuildException("Zero-length argument list") ;
  
@@@ -181,17 -172,12 +183,13 @@@
          return qIter ;
      }
  
 -    private QueryIterator variableSubject(Binding binding, Node s, StrMatch match, ExecutionContext
execCxt) {
 -        Var v = Var.alloc(s) ;
 -        List<Node> r = query(match.getQueryString(), match.getLimit(), execCxt) ;
 -        // Make distinct. Note interaction with limit is imperfect
 -        r = Iter.iter(r).distinct().toList() ;
 -        QueryIterator qIter = new QueryIterExtendByVar(binding, v, r.iterator(), execCxt)
;
 +    private QueryIterator variableSubject(Binding binding, Node s, Node score, StrMatch
match, ExecutionContext execCxt) {
 +        Var sVar = Var.alloc(s) ;
 +        Var scoreVar = (score==null) ? null : Var.alloc(score) ;
 +        List<TextHit> r = query(match.getQueryString(), match.getLimit(), execCxt)
;
-         // Make distinct. Note interaction with limit is imperfect
- /*        r = Iter.iter(r).distinct().toList() ;
-         QueryIterator qIter = new QueryIterExtendByVar(binding, v, r.iterator(), execCxt)
;
- */
 +        Function<TextHit,Binding> converter = new TextHitConverter(binding, sVar,
scoreVar);
 +        Iterator<Binding> bIter = new Map1Iterator<TextHit, Binding>(converter,
r.iterator());
 +        QueryIterator qIter = new QueryIterPlainWrapper(bIter, execCxt);
          return qIter ;
      }
  
@@@ -201,27 -187,17 +199,27 @@@
              return IterLib.noResults(execCxt) ;
          }
  
 +        Var scoreVar = (score==null) ? null : Var.alloc(score) ;
          String qs = match.getQueryString() ;
 -        List<Node> x = query(match.getQueryString(), -1, execCxt) ;
 -        if ( x == null || ! x.contains(s) )
 +        List<TextHit> x = query(match.getQueryString(), -1, execCxt) ;
 +        
 +        if ( x == null ) // null return value - empty result
              return IterLib.noResults(execCxt) ;
 -        else
 -            return IterLib.result(binding, execCxt) ;
 +        
 +        for (TextHit hit : x ) {
 +            if (hit.getNode().equals(s)) {
 +                // found the node among the hits
 +                return IterLib.oneResult(binding, scoreVar, NodeFactoryExtra.floatToNode(hit.getScore()),
execCxt) ;
 +            }
 +        }
 +
 +        // node was not among the hits - empty result
 +        return IterLib.noResults(execCxt) ;
      }
  
 -    private List<Node> query(String queryString, int limit, ExecutionContext execCxt)
{
 +    private List<TextHit> query(String queryString, int limit, ExecutionContext execCxt)
{
          // use the graph information in the text index if possible
-         if (server.getDocDef().getGraphField() != null
+         if (textIndex.getDocDef().getGraphField() != null
              && execCxt.getActiveGraph() instanceof GraphView) {
              GraphView activeGraph = (GraphView)execCxt.getActiveGraph() ;
              if (!Quad.isUnionGraph(activeGraph.getGraphName())) {


Mime
View raw message