Skip to content

Commit 7ae0794

Browse files
committed
Update to HDT-Node 3.x.x
1 parent ab80f13 commit 7ae0794

File tree

4 files changed

+13
-22
lines changed

4 files changed

+13
-22
lines changed

packages/datasource-hdt/lib/datasources/ExternalHdtDatasource.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ let Datasource = require('@ldf/core').datasources.Datasource,
55
fs = require('fs'),
66
path = require('path'),
77
N3Parser = require('n3').Parser,
8-
RdfString = require('rdf-string'),
98
spawn = require('child_process').spawn;
109

1110
let hdtUtility = path.join(__dirname, '../../node_modules/.bin/hdt');
@@ -51,12 +50,12 @@ class ExternalHdtDatasource extends Datasource {
5150
], { stdio: ['ignore', 'pipe', 'ignore'] });
5251
// Parse the result triples
5352
hdt.stdout.setEncoding('utf8');
54-
let parser = new N3Parser(), tripleCount = 0, estimatedTotalCount = 0, hasExactCount = true, dataFactory = this.dataFactory;
53+
let parser = new N3Parser(), tripleCount = 0, estimatedTotalCount = 0, hasExactCount = true;
5554
parser.parse(hdt.stdout, (error, triple) => {
5655
if (error)
5756
destination.emit('error', new Error('Invalid query result: ' + error.message));
5857
else if (triple)
59-
tripleCount++, destination._push(RdfString.stringQuadToQuad(triple, dataFactory));
58+
tripleCount++, destination._push(triple);
6059
else {
6160
// Ensure the estimated total count is as least as large as the number of triples
6261
if (tripleCount && estimatedTotalCount < offset + tripleCount)

packages/datasource-hdt/lib/datasources/HdtDatasource.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
let Datasource = require('@ldf/core').datasources.Datasource,
55
hdt = require('hdt'),
6-
ExternalHdtDatasource = require('./ExternalHdtDatasource'),
7-
RdfString = require('rdf-string');
6+
ExternalHdtDatasource = require('./ExternalHdtDatasource');
87

98
// Creates a new HdtDatasource
109
class HdtDatasource extends Datasource {
@@ -21,7 +20,7 @@ class HdtDatasource extends Datasource {
2120

2221
// Loads the HDT datasource
2322
async _initialize() {
24-
this._hdtDocument = await hdt.fromFile(this._hdtFile);
23+
this._hdtDocument = await hdt.fromFile(this._hdtFile, { dataFactory: this.dataFactory });
2524
}
2625

2726
// Writes the results of the query to the given quad stream
@@ -32,10 +31,7 @@ class HdtDatasource extends Datasource {
3231
destination.close();
3332
return;
3433
}
35-
let dataFactory = this.dataFactory;
36-
this._hdtDocument.searchTriples(query.subject ? RdfString.termToString(query.subject) : null,
37-
query.predicate ? RdfString.termToString(query.predicate) : null,
38-
query.object ? RdfString.termToString(query.object) : null,
34+
this._hdtDocument.searchTriples(query.subject, query.predicate, query.object,
3935
{ limit: query.limit, offset: query.offset })
4036
.then((result) => {
4137
let triples = result.triples,
@@ -48,7 +44,7 @@ class HdtDatasource extends Datasource {
4844
destination.setProperty('metadata', { totalCount: estimatedTotalCount, hasExactCount: hasExactCount });
4945
// Add the triples to the output
5046
for (let i = 0; i < tripleCount; i++)
51-
destination._push(RdfString.stringQuadToQuad(triples[i], dataFactory));
47+
destination._push(triples[i]);
5248
destination.close();
5349
},
5450
(error) => { destination.emit('error', error); });

packages/datasource-hdt/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838
"@ldf/core": "^3.0.7"
3939
},
4040
"optionalDependencies": {
41-
"hdt": "^2.2.2"
41+
"hdt": "^3.0.1"
4242
}
4343
}

yarn.lock

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3187,14 +3187,15 @@ hasha@^5.0.0:
31873187
is-stream "^2.0.0"
31883188
type-fest "^0.8.0"
31893189

3190-
hdt@^2.2.2:
3191-
version "2.2.2"
3192-
resolved "https://registry.yarnpkg.com/hdt/-/hdt-2.2.2.tgz#4e570250a42043050a345dc7b84d2838c40fa7ca"
3193-
integrity sha512-CaGQ6z/ncMgL9BXBAbBcjAxEZhozfQKXFi/1Ov2gz7WwYH3muv1PGsml7r8FdhtErRf45owKkITEfpJ2h8+64w==
3190+
hdt@^3.0.1:
3191+
version "3.0.1"
3192+
resolved "https://registry.yarnpkg.com/hdt/-/hdt-3.0.1.tgz#2180e7d1942133da083bc1d55ee8aca8e9f6a2c1"
3193+
integrity sha512-SMHwNMEVwET8r2cPvIJR3TBUByA73kzD15XANjnfZdxnqSZlvj8FIlHftNBuNMDegM/ClrBNZTcY1BRnc0SE3w==
31943194
dependencies:
31953195
minimist "^1.1.0"
3196-
n3 "^0.11.2"
3196+
n3 "^1.3.5"
31973197
nan "^2.14.0"
3198+
rdf-string "^1.3.1"
31983199

31993200
32003201
version "1.2.0"
@@ -4488,11 +4489,6 @@ mz@^2.5.0:
44884489
object-assign "^4.0.1"
44894490
thenify-all "^1.0.0"
44904491

4491-
n3@^0.11.2:
4492-
version "0.11.3"
4493-
resolved "https://registry.yarnpkg.com/n3/-/n3-0.11.3.tgz#8e587495240dd21408c2c3aae385ec1651a837f8"
4494-
integrity sha512-Hk5GSXBeAZrYoqi+NeS/U0H47Hx0Lzj7K6nLWCZpC9E04iUwEwBcrlMb/5foAli7QF4newPNQQQGgM6IAxTxGg==
4495-
44964492
n3@^0.9.1:
44974493
version "0.9.1"
44984494
resolved "https://registry.yarnpkg.com/n3/-/n3-0.9.1.tgz#430b547d58dc7381408c45784dd8058171903932"

0 commit comments

Comments
 (0)