Interface RDF4JDataset
- All Superinterfaces:
AutoCloseable
,org.apache.commons.rdf.api.Dataset
,org.apache.commons.rdf.api.GraphLike<org.apache.commons.rdf.api.Quad>
,RDF4JGraphLike<org.apache.commons.rdf.api.Quad>
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionStream
<org.apache.commons.rdf.api.BlankNodeOrIRI> ClosableIterable
<org.apache.commons.rdf.api.Quad> iterate()
ClosableIterable
<org.apache.commons.rdf.api.Quad> iterate
(Optional<org.apache.commons.rdf.api.BlankNodeOrIRI> graphName, org.apache.commons.rdf.api.BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, org.apache.commons.rdf.api.RDFTerm object) stream()
Methods inherited from interface org.apache.commons.rdf.api.Dataset
add, add, clear, close, contains, contains, getGraph, getGraph, remove, remove, size
Methods inherited from interface org.apache.commons.rdfrdf4j.RDF4JGraphLike
asModel, asRepository
-
Method Details
-
getGraphNames
Stream<org.apache.commons.rdf.api.BlankNodeOrIRI> getGraphNames()Note that for datasets backed by a repository (
RDF4JGraphLike.asRepository()
is present), the stream must be closed withBaseStream.close()
.This can generally achieved using a try-with-resources block, e.g.:
int graphs; try (Stream<BlankNodeOrIRI> s : graph.stream()) { graphs = s.count() }
- Specified by:
getGraphNames
in interfaceorg.apache.commons.rdf.api.Dataset
-
iterate
ClosableIterable<org.apache.commons.rdf.api.Quad> iterate()Note that for datasets backed by a repository (
RDF4JGraphLike.asRepository()
is present), the iterable must be closed withAutoCloseable.close()
.This can generally achieved using a try-with-resources block, e.g.:
try (ClosableIterable<Quad> s : graph.iterate()) { for (Quad q : quads) { return q; // OK to terminate for-loop early } }
If you don't use a try-with-resources block, the iterator will attempt to close the ClosableIterable when reaching the end of the iteration.- Specified by:
iterate
in interfaceorg.apache.commons.rdf.api.Dataset
- Specified by:
iterate
in interfaceorg.apache.commons.rdf.api.GraphLike<org.apache.commons.rdf.api.Quad>
-
iterate
ClosableIterable<org.apache.commons.rdf.api.Quad> iterate(Optional<org.apache.commons.rdf.api.BlankNodeOrIRI> graphName, org.apache.commons.rdf.api.BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, org.apache.commons.rdf.api.RDFTerm object) Note that for datasets backed by a repository (
RDF4JGraphLike.asRepository()
is present), the iterable must be closed withAutoCloseable.close()
.This can generally achieved using a try-with-resources block, e.g.:
try (ClosableIterable<Quad> s : graph.iterate(g,s,p,o)) { for (Quad q : quads) { return q; // OK to terminate for-loop early } }
If you don't use a try-with-resources block, the iterator will attempt to close the ClosableIterable when reaching the end of the iteration.- Specified by:
iterate
in interfaceorg.apache.commons.rdf.api.Dataset
-
stream
Note that for datasets backed by a repository (
RDF4JGraphLike.asRepository()
is present), the stream must be closed withBaseStream.close()
.This can generally achieved using a try-with-resources block, e.g.:
int subjects; try (Stream<RDF4JQuad> s : graph.stream()) { subjects = s.map(RDF4JQuad::getSubject).distinct().count() }
- Specified by:
stream
in interfaceorg.apache.commons.rdf.api.Dataset
- Specified by:
stream
in interfaceorg.apache.commons.rdf.api.GraphLike<org.apache.commons.rdf.api.Quad>
-
stream
Stream<RDF4JQuad> stream(Optional<org.apache.commons.rdf.api.BlankNodeOrIRI> graphName, org.apache.commons.rdf.api.BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, org.apache.commons.rdf.api.RDFTerm object) Note that for datasets backed by a repository (
RDF4JGraphLike.asRepository()
is present), the stream must be closed withBaseStream.close()
.This can generally achieved using a try-with-resources block, e.g.:
int subjects; try (Stream<RDF4JQuad> s : graph.stream()) { subjects = s.map(RDF4JQuad::getSubject).distinct().count() }
- Specified by:
stream
in interfaceorg.apache.commons.rdf.api.Dataset
-