basic memory setup does not result in consistent results
lgazo opened this issue · comments
Hi,
I have set up basic Quadstore setup according to the example with:
import { MemoryLevel } from 'memory-level'; // 1.0.0
import { DataFactory } from 'rdf-data-factory'; // 1.1.1
import { Quad, Quadstore } from 'quadstore'; // 11.0.6
import { Engine } from 'quadstore-comunica'; //3.0.7
I have ingested with
await store.multiPut(graph_json);
following graph_json
:
[
{
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://pa.ca/art/c1"
},
"predicate": {
"termType": "NamedNode",
"value": "http://pa.ca/p/h_dref"
},
"object": {
"termType": "NamedNode",
"value": "http://pa.ca/ref/lM5PAa-HbfoElOxqgohbR"
},
"graph": {
"termType": "NamedNode",
"value": "http://pa.ca/c/ucomp"
}
},
{
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://pa.ca/ref/lM5PAa-HbfoElOxqgohbR"
},
"predicate": {
"termType": "NamedNode",
"value": "http://pa.ca/p/ktt"
},
"object": "http://pa.ca/kt/dgn",
"graph": {
"termType": "NamedNode",
"value": "http: //pa.ca/c/ucomp"
}
},
{
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://pa.ca/ref/lM5PAa-HbfoElOxqgohbR"
},
"predicate": {
"termType": "NamedNode",
"value": "http://pa.ca/p/h_lid"
},
"object": {
"termType": "NamedNode",
"value": "http://pa.ca/lid/zagIRCBf_rBFcp3sJokX-1"
},
"graph": {
"termType": "NamedNode",
"value": "http://pa.ca/c/ucomp"
}
},
{
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://pa.ca/ref/lM5PAa-HbfoElOxqgohbR"
},
"predicate": {
"termType": "NamedNode",
"value": "http://pa.ca/p/h_sub"
},
"object": {
"termType": "NamedNode",
"value": "http://pa.ca/sub/nfkR9TN59wZLjoe3wRwf"
},
"graph": {
"termType": "NamedNode",
"value": "http://pa.ca/c/ucomp"
}
}
]
When I run:
const { items } = await store.get({});
I get following corrupted results:
[
{
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://pa.ca/art/c1"
},
"predicate": {
"termType": "NamedNode",
"value": "http://pa.ca/p/h_dref"
},
"object": {
"termType": "NamedNode",
"value": "http://pa.ca/ref/lM5PAa-HbfoElOxqgohbR"
},
"graph": {
"termType": "NamedNode",
"value": "http://pa.ca/c/ucomp"
}
},
{
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://pa.ca/ref/lM5PAa-HbfoElOxqgohbR"
},
"predicate": {
"termType": "NamedNode",
"value": "http://pa.ca/p/h_lid"
},
"object": {
"termType": "NamedNode",
"value": "http://pa.ca/lid/zagIRCBf_rBFcp3sJokX-1"
},
"graph": {
"termType": "NamedNode",
"value": "http://pa.ca/c/ucomp"
}
},
{
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://pa.ca/ref/lM5PAa-HbfoElOxqgohbR"
},
"predicate": {
"termType": "NamedNode",
"value": "http://pa.ca/p/h_sub"
},
"object": {
"termType": "NamedNode",
"value": "http://pa.ca/sub/nfkR9TN59wZLjoe3wRwf"
},
"graph": {
"termType": "NamedNode",
"value": "http://pa.ca/c/ucomp"
}
},
{
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://pa.ca/ref/lM5PAa-HbfoElOxqgohbR"
},
"predicate": {
"termType": "NamedNode",
"value": "http://pa.ca/p/ktt"
},
"object": {
"termType": "NamedNode",
"value": "\\u0000\\u0000http://pa.ca/c/uco"
},
"graph": {
"termType": "NamedNode",
"value": ""
}
}
]
You can see that the last item has different graph
and also weird value
in object
.
I have also tried it with default graph, but no difference.
SPARQL engine query like
const query = await engine.query('SELECT * WHERE { GRAPH <http://pa.ca/c/ucomp> {?s <http://pa.ca/p/ktt> ?o }}');
leads to weird results as well.
I have double-checked the code, versions and also cleaned the node_modules to ensure proper environment. I had trimmed the length of named node values as it seemed it corrupted the encoding (more quads had \\u0000\\u0000
prepended).
Would you be so kind and investigate what might be wrong?
Thx.
I found out where the problem was:
"object": "http://pa.ca/kt/dgn",
Is not correct. It should be a NamedNode:
"object": {
"termType": "NamedNode",
"value": "http://pa.ca/kt/dgn"
}
Then it works as expected.
Hello @lgazo ! Yes, quadstore expects all quads and terms to implement the RDF/JS Data Model interfaces. I see you've already found the issue but perhaps we can improve developer experience by adding a few checks to make sure inputs are correct. I'll close this issue and open a dedicated one.