Skip to content

Commit df498a2

Browse files
committed
Corrections for query and better estimate
1 parent 52480b3 commit df498a2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/org/linkeddatafragments/datasource/JenaTDBDataSource.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,18 @@ public TriplePatternFragment getFragment(Resource subject, Property predicate, R
5050
Model triples = ModelFactory.createDefaultModel();
5151
qexec.execConstruct(triples);
5252

53-
// For now, fake the estimate
53+
// Try to get an estimate
5454
long size = triples.size();
55-
long estimate = (size == limit) ? offset + limit + 1 : offset + size;
56-
// Try to get a better estimate
55+
long estimate = -1;
56+
5757
GraphStatisticsHandler stats = model.getGraph().getStatisticsHandler();
5858
if (stats != null) {
5959
estimate = stats.getStatistic(subject.asNode(), predicate.asNode(), object.asNode());
6060
}
61+
// No estimate or incorrect
62+
if (estimate < offset + size) {
63+
estimate = (size == limit) ? offset + size + 1 : offset + size;
64+
}
6165

6266
tdb.end();
6367

0 commit comments

Comments
 (0)