Skip to content

Instantly share code, notes, and snippets.

@jindrichmynarz
Created October 6, 2016 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jindrichmynarz/2ee1cb5ae56a2ca92297aa633443f13b to your computer and use it in GitHub Desktop.
Save jindrichmynarz/2ee1cb5ae56a2ca92297aa633443f13b to your computer and use it in GitHub Desktop.
Fuse resources by key
PREFIX : <http://example.com/>
DELETE {
?r ?outP ?outO .
?inS ?inP ?r .
}
INSERT {
?sampleR ?outP ?outO .
?inS ?inP ?sampleR .
}
WHERE {
{
SELECT ?class ?name (SAMPLE(?r) AS ?sampleR)
WHERE {
# Select resources to fuse.
?r a ?class ;
:name ?name .
}
# Group by key(s)
GROUP BY ?class ?name
}
?r a ?class ;
:name ?name .
FILTER (!sameTerm(?r, ?sampleR))
?r ?outP ?outO .
OPTIONAL {
?inS ?inP ?r .
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment