@@ -62,25 +62,28 @@ CompositeDatasource.prototype._getDatasourceInfo = function(query, absoluteOffse
62
62
offset : 0 , limit : 1 ,
63
63
subject : query . subject , predicate : query . predicate , object : query . object
64
64
} ;
65
- return findRecursive ( 0 , absoluteOffset , - 1 , - 1 , 0 , cb ) ;
65
+ return findRecursive ( 0 , absoluteOffset , - 1 , - 1 , 0 , cb , true ) ;
66
66
67
- function findRecursive ( datasourceIndex , offset , chosenDatasource , chosenOffset , totalCount ) {
67
+ function findRecursive ( datasourceIndex , offset , chosenDatasource , chosenOffset , totalCount , exactCount ) {
68
68
if ( datasourceIndex >= self . _datasourceNames . length ) {
69
69
// We checked all datasources, return our accumulated information
70
- cb ( chosenDatasource , chosenOffset , totalCount ) ;
70
+ cb ( chosenDatasource , chosenOffset , totalCount , exactCount ) ;
71
71
} else {
72
72
var emptyTripleStream = { push : noop } ;
73
73
self . _getDatasourceById ( datasourceIndex ) . _executeQuery ( emptyQuery , emptyTripleStream , function ( metadata ) {
74
74
var count = metadata . totalCount ;
75
+ var exact = metadata . exactCount ;
75
76
if ( chosenDatasource < 0 && offset < count ) {
76
77
// We can start querying from this datasource
77
78
setImmediate ( function ( ) {
78
- findRecursive ( datasourceIndex + 1 , offset - count , datasourceIndex , offset , totalCount + count ) ;
79
+ findRecursive ( datasourceIndex + 1 , offset - count , datasourceIndex , offset ,
80
+ totalCount + count , exactCount && exact ) ;
79
81
} ) ;
80
82
} else {
81
83
// We forward our accumulated information and go check the next datasource
82
84
setImmediate ( function ( ) {
83
- findRecursive ( datasourceIndex + 1 , offset - count , chosenDatasource , chosenOffset , totalCount + count ) ;
85
+ findRecursive ( datasourceIndex + 1 , offset - count , chosenDatasource , chosenOffset ,
86
+ totalCount + count , exactCount && exact ) ;
84
87
} ) ;
85
88
}
86
89
} ) ;
@@ -94,14 +97,14 @@ function noop() {}
94
97
CompositeDatasource . prototype . _executeQuery = function ( query , tripleStream , metadataCallback ) {
95
98
var offset = query . offset || 0 , limit = query . limit || Infinity ;
96
99
var self = this ;
97
- this . _getDatasourceInfo ( query , offset , function ( datasourceIndex , relativeOffset , totalCount ) {
100
+ this . _getDatasourceInfo ( query , offset , function ( datasourceIndex , relativeOffset , totalCount , exactCount ) {
98
101
if ( datasourceIndex < 0 ) {
99
102
// No valid datasource has been found
100
- metadataCallback ( { totalCount : totalCount } ) ;
103
+ metadataCallback ( { totalCount : totalCount , exactCount : exactCount } ) ;
101
104
tripleStream . push ( null ) ;
102
105
} else {
103
106
// Send query to first applicable datasource and optionally emit triples from consecutive datasources
104
- metadataCallback ( { totalCount : totalCount } ) ;
107
+ metadataCallback ( { totalCount : totalCount , exactCount : exactCount } ) ;
105
108
var emitted = 0 ;
106
109
107
110
// Modify our triple stream so that if all results from one datasource have arrived,
0 commit comments