Github user afs commented on a diff in the pull request:
https://github.com/apache/jena/pull/72#discussion_r31388541
--- Diff:
jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java ---
@@ -165,37 +176,48 @@ public QueryIterator exec(Binding binding,
PropFuncArg argSubject, Node predicat
// ----
QueryIterator qIter = (Var.isVar(s))
- ? variableSubject(binding, s, match, execCxt)
- : concreteSubject(binding, s, match, execCxt) ;
+ ? variableSubject(binding, s, score, match, execCxt)
+ : concreteSubject(binding, s, score, match, execCxt) ;
if (match.getLimit() >= 0)
qIter = new QueryIterSlice(qIter, 0, match.getLimit(),
execCxt) ;
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) ;
+ Function<TextHit,Binding> converter = new
TextHitConverter(binding, sVar, scoreVar);
+ Iterator<Binding> bIter = new Map1Iterator<TextHit,
Binding>(converter, r.iterator());
--- End diff --
There is a library of iterator utilities:
```
Iterator<Binding> bIter = Iter.map(r.iterator(), converter) ;
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---