Skip to content

Commit ee8138b

Browse files
committed
Interpret triplecount-exactness in ExternalHdtDatasource
1 parent 5ced848 commit ee8138b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

config/config-composite.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"type": "CompositeDatasource",
88
"description": "A test composite datasource",
99
"settings": {
10-
"references": [ "hdt", "ttl", "jsonld" ]
10+
"references": [ "hdt", "ttl", "jsonld", "hdtext" ]
1111
}
1212
},
1313
"hdt": {
@@ -30,6 +30,13 @@
3030
"type": "JsonLdDatasource",
3131
"description": "A test jsonld datasource",
3232
"settings": { "file": "test/assets/test.jsonld" }
33+
},
34+
"hdtext": {
35+
"hide": true,
36+
"title": "HDT-EXT",
37+
"type": "ExternalHdtDatasource",
38+
"description": "A blank test HDT datasource",
39+
"settings": { "file": "test/assets/test-blank.hdt" }
3340
}
3441
}
3542
}

lib/datasources/ExternalHdtDatasource.js

Lines changed: 3 additions & 2 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;
46+
var parser = new N3Parser(), tripleCount = 0, estimatedTotalCount = 0, exactCount = 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: false });
56+
metadataCallback({ totalCount: estimatedTotalCount, exactCount: exactCount });
5757
tripleStream.push(null);
5858
}
5959
});
@@ -62,6 +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;
6566
});
6667

6768
// Report query errors

0 commit comments

Comments
 (0)