Skip to content

Commit 6a7db71

Browse files
committed
rename exactCount to hasExactCount
1 parent ee8138b commit 6a7db71

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

lib/datasources/CompositeDatasource.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,16 @@ CompositeDatasource.prototype._getDatasourceInfo = function(query, absoluteOffse
8989
};
9090
return findRecursive(0, absoluteOffset, -1, -1, 0, cb, true);
9191

92-
function findRecursive(datasourceIndex, offset, chosenDatasource, chosenOffset, totalCount, exactCount) {
92+
function findRecursive(datasourceIndex, offset, chosenDatasource, chosenOffset, totalCount, hasExactCount) {
9393
if (datasourceIndex >= self._datasourceNames.length) {
9494
// We checked all datasources, return our accumulated information
95-
cb(chosenDatasource, chosenOffset, totalCount, exactCount);
95+
cb(chosenDatasource, chosenOffset, totalCount, hasExactCount);
9696
} else {
9797
var emptyTripleStream = { push: noop };
9898
var datasource = self._getDatasourceById(datasourceIndex);
9999
datasource._executeQuery(emptyQuery, emptyTripleStream, function (metadata) {
100100
var count = metadata.totalCount;
101-
var exact = metadata.exactCount;
101+
var exact = metadata.hasExactCount;
102102
// If we are still looking for an appropriate datasource, we need exact counts!
103103
if (offset > 0 && !exact) {
104104
self._getExactCount(datasource, query, function(exactCount) {
@@ -115,13 +115,13 @@ CompositeDatasource.prototype._getDatasourceInfo = function(query, absoluteOffse
115115
// We can start querying from this datasource
116116
setImmediate(function () {
117117
findRecursive(datasourceIndex + 1, offset - count, datasourceIndex, offset,
118-
totalCount + count, exactCount && exact);
118+
totalCount + count, hasExactCount && exact);
119119
});
120120
} else {
121121
// We forward our accumulated information and go check the next datasource
122122
setImmediate(function () {
123123
findRecursive(datasourceIndex + 1, offset - count, chosenDatasource, chosenOffset,
124-
totalCount + count, exactCount && exact);
124+
totalCount + count, hasExactCount && exact);
125125
});
126126
}
127127
}
@@ -136,14 +136,14 @@ function noop() {}
136136
CompositeDatasource.prototype._executeQuery = function (query, tripleStream, metadataCallback) {
137137
var offset = query.offset || 0, limit = query.limit || Infinity;
138138
var self = this;
139-
this._getDatasourceInfo(query, offset, function(datasourceIndex, relativeOffset, totalCount, exactCount) {
139+
this._getDatasourceInfo(query, offset, function(datasourceIndex, relativeOffset, totalCount, hasExactCount) {
140140
if (datasourceIndex < 0) {
141141
// No valid datasource has been found
142-
metadataCallback({ totalCount: totalCount, exactCount: exactCount });
142+
metadataCallback({ totalCount: totalCount, hasExactCount: hasExactCount });
143143
tripleStream.push(null);
144144
} else {
145145
// Send query to first applicable datasource and optionally emit triples from consecutive datasources
146-
metadataCallback({ totalCount: totalCount, exactCount: exactCount });
146+
metadataCallback({ totalCount: totalCount, hasExactCount: hasExactCount });
147147
var emitted = 0;
148148

149149
// Modify our triple stream so that if all results from one datasource have arrived,

lib/datasources/ExternalHdtDatasource.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ExternalHdtDatasource.prototype._executeQuery = function (query, tripleStream, m
4343
'--', hdtFile], { stdio: ['ignore', 'pipe', 'ignore'] });
4444
// Parse the result triples
4545
hdt.stdout.setEncoding('utf8');
46-
var parser = new N3Parser(), tripleCount = 0, estimatedTotalCount = 0, exactCount = true;
46+
var parser = new N3Parser(), tripleCount = 0, estimatedTotalCount = 0, hasExactCount = true;
4747
parser.parse(hdt.stdout, function (error, triple) {
4848
if (error)
4949
tripleStream.emit('error', new Error('Invalid query result: ' + error.message));
@@ -53,7 +53,7 @@ ExternalHdtDatasource.prototype._executeQuery = function (query, tripleStream, m
5353
// Ensure the estimated total count is as least as large as the number of triples
5454
if (tripleCount && estimatedTotalCount < offset + tripleCount)
5555
estimatedTotalCount = offset + (tripleCount < query.limit ? tripleCount : 2 * tripleCount);
56-
metadataCallback({ totalCount: estimatedTotalCount, exactCount: exactCount });
56+
metadataCallback({ totalCount: estimatedTotalCount, hasExactCount: hasExactCount });
5757
tripleStream.push(null);
5858
}
5959
});
@@ -62,7 +62,7 @@ ExternalHdtDatasource.prototype._executeQuery = function (query, tripleStream, m
6262
// Extract the estimated number of total matches from the first (comment) line
6363
hdt.stdout.once('data', function (header) {
6464
estimatedTotalCount = parseInt(header.match(/\d+/), 10) || 0;
65-
exactCount = header.indexOf("Exact") > -1;
65+
hasExactCount = header.indexOf("estimated") < 0;
6666
});
6767

6868
// Report query errors

lib/datasources/HdtDatasource.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ HdtDatasource.prototype._initialize = function (done) {
3333
HdtDatasource.prototype._executeQuery = function (query, tripleStream, metadataCallback) {
3434
this._hdtDocument.search(query.subject, query.predicate, query.object,
3535
{ limit: query.limit, offset: query.offset },
36-
function (error, triples, estimatedTotalCount, exactCount) {
36+
function (error, triples, estimatedTotalCount, hasExactCount) {
3737
if (error) return tripleStream.emit('error', error);
3838
// Ensure the estimated total count is as least as large as the number of triples
3939
var tripleCount = triples.length, offset = query.offset || 0;
4040
if (tripleCount && estimatedTotalCount < offset + tripleCount)
4141
estimatedTotalCount = offset + (tripleCount < query.limit ? tripleCount : 2 * tripleCount);
42-
metadataCallback({ totalCount: estimatedTotalCount, exactCount: exactCount });
42+
metadataCallback({ totalCount: estimatedTotalCount, hasExactCount: hasExactCount });
4343
// Add the triples to the stream
4444
for (var i = 0; i < tripleCount; i++)
4545
tripleStream.push(triples[i]);

lib/datasources/MemoryDatasource.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ MemoryDatasource.prototype._executeQuery = function (query, tripleStream, metada
2929
var offset = query.offset || 0, limit = query.limit || Infinity,
3030
triples = this._tripleStore.findByIRI(query.subject, query.predicate, query.object);
3131
// Send the metadata
32-
metadataCallback({ totalCount: triples.length, exactCount: true });
32+
metadataCallback({ totalCount: triples.length, hasExactCount: true });
3333
// Send the requested subset of triples
3434
for (var i = offset, l = Math.min(offset + limit, triples.length); i < l; i++)
3535
tripleStream.push(triples[i]);

lib/datasources/SparqlDatasource.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ SparqlDatasource.prototype._executeQuery = function (query, tripleStream, metada
5555
// Determine the total number of matching triples
5656
this._getPatternCount(sparqlPattern, function (error, totalCount) {
5757
if (error) emitError(error);
58-
else if (typeof totalCount === 'number') metadataCallback({ totalCount: totalCount, exactCount: true });
58+
else if (typeof totalCount === 'number') metadataCallback({ totalCount: totalCount, hasExactCount: true });
5959
});
6060

6161
// Emits an error on the triple stream

0 commit comments

Comments
 (0)