Skip to content

Commit 88fb6c0

Browse files
committed
Result size should be 0 if there are no matches.
1 parent 2e22edd commit 88fb6c0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/org/linkeddatafragments/datasource/HdtDataSource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public BasicLinkedDataFragment getFragment(Resource subject, Property predicate,
4646
if (subjectId < 0 || predicateId < 0 || objectId < 0)
4747
return new BasicLinkedDataFragmentBase();
4848
final IteratorTripleID result = datasource.getTriples().search(new TripleID(subjectId, predicateId, objectId));
49+
// estimates can be wrong; ensure 0 is returned if and only if there are no results
50+
final long totalSize = result.hasNext() ? Math.max(result.estimatedNumResults(), 1) : 0;
4951

5052
// create the fragment
5153
return new BasicLinkedDataFragment() {
@@ -79,9 +81,7 @@ public Model getTriples() {
7981
}
8082

8183
@Override
82-
public long getTotalSize() {
83-
return result.estimatedNumResults();
84-
}
84+
public long getTotalSize() { return totalSize; }
8585
};
8686
}
8787

0 commit comments

Comments
 (0)