-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
store.get() and store.sparql() return different values for similar blank nodes #134
Comments
Hello @ehupin! Thank you for that code snippet, I can confirm I am able to reproduce this. It's weird, the correct behavior is the one you're getting from As a temporary workaround you can skolemise blank nodes into named nodes, which I would recommend anyway as blank nodes can be rather confusing. @rubensworks is this expected behavior in Comunica? Quadstore returns blank nodes with the same labels they had when inserted, which leads me to think that something in Comunica's handling of blank nodes might be causing this. |
The client shouldn't expect stable blank nodes though. That's what URIs are for :) |
Just for clarify and set expectations: although blank node labels are not guaranteed to be stable, quads and the relationships between quads are. The issue, here, is not that the labels change between |
Thanks all for your answers! |
Scratch my latest reply. I didn't read the issue well enough. Links between blank nodes are only defined within the context of a single document or query execution. However, no meaning should be attached to their concrete labels, as these can change at any time. In that sense, the output of |
I should be able to look into this within a week from today. Apologies for the latency, I'm having a couple of very intense weeks. |
@rubensworks I've managed to reproduce the problem with I've modified the script provided by @ehupin to be able to easily switch between
Is there something in how I am packaging Comunica that might trigger this? import {Quadstore} from "./lib/quadstore";
import {newEngine} from "quadstore-comunica";
import {BindingArrayResult, QuadArrayResult} from './lib/types';
import leveldown from 'leveldown';
import {DataFactory} from 'rdf-data-factory';
import { Store as N3Store } from 'n3';
// const rdf = require('rdf-ext')
import { ArrayIterator, wrap } from 'asynciterator';
import { streamToArray } from './lib/utils';
import {Algebra, translate} from 'sparqlalgebrajs';
async function test() {
const rdf = new DataFactory();
const engine = newEngine();
const store = new N3Store();
// const db = leveldown('test');
// const store = new Quadstore({
// backend: db,
// comunica: newEngine(),
// dataFactory: rdf
// });
// await store.open();
const intermediaryNode = rdf.blankNode();
const quads = [
rdf.quad(
rdf.namedNode('http://example.org/from'),
rdf.namedNode('http://example.org/link'),
intermediaryNode
),
rdf.quad(
intermediaryNode,
rdf.namedNode('http://example.org/link'),
rdf.namedNode('http://example.org/to'),
)
]
await new Promise((resolve, reject) => {
store.import(new ArrayIterator(quads))
.on('end', resolve)
.on('err', reject)
;
});
// @ts-ignore
const storeQuads: Quad[] = await streamToArray(store.match());
console.log(storeQuads);
const sparqlQuery = 'SELECT * WHERE { ?s ?p ?o}';
const sparqlOperation = translate(sparqlQuery, { quads: true, dataFactory: rdf });
const sparqlResult = await engine.query(sparqlOperation, { source: store });
// @ts-ignore
const sparqlBindings = (await sparqlResult.bindings()).map(b => b.toObject());
console.log(sparqlBindings);
}
test().catch((err) => {
console.error(err);
process.exit(1);
}); |
Hmm, that's not good. Now that I think of it, this sounds similar to comunica/comunica#773, which I initially thought to be a parsing issue, but may very well have the same cause as here. |
@rubensworks I'll see whether I can replicate this in a new test within Comunica's test suite and open an issue over there if so. |
Opened issue upstream: comunica/comunica#795 |
For posterity: this has required some work in both Comunica and sparqlee, the latter being Comunica’s SPARQL expression evaluator. I think we’re relatively close to fixing this and the fix will surely be included in the next version of quadstore. Relevant issues and PRs:
|
Released in |
Hi,
I am quite new to the RDF world and I am currently testing node-quadstore as a solution to persist triples.
During my tests I found what seems to be a weird behavior, as the returned values for blank nodes differ when they are fetch using
store.get()
vsstore.sparql()
.Here is a script to reproduce this:
What bugs me here is that the blank node I created is returned as a single one (
b1
) when I usestore.get()
, but it is returned as two different ones (b11
andb12
) when I usestore.sparql()
.Am I missing something about how this work, and should I change the way I create/store/fetch my data to prevent such a behavior?
Here are the versions I use:
The text was updated successfully, but these errors were encountered: