[
https://issues.apache.org/jira/browse/JENA-1965?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17195712#comment-17195712
]
Andy Seaborne commented on JENA-1965:
-------------------------------------
Is this what you want?
[io/streaming-io.html|https://jena.apache.org/documentation/io/streaming-io.html]
{noformat}
StreamRDF writer = StreamRDFWriter.getWriterStream(output, lang) ;
{noformat}
then send data to the {{StreamRDF}}.
If you want to send data from different graphs etc which will duplicate
prefixes excessively, then add a {{StreamRDF}} around the {{writer}} to track
and suppress duplicates.
{noformat}
// Send a graph
StreamOps.graphToStream(writer, graph);
{noformat}
and other helpers in {{StreamOps}}.
> Writing streams of RDF
> ----------------------
>
> Key: JENA-1965
> URL: https://issues.apache.org/jira/browse/JENA-1965
> Project: Apache Jena
> Issue Type: New Feature
> Components: RIOT
> Affects Versions: Jena 3.16.0
> Reporter: Claus Stadler
> Priority: Major
>
> For streams of Model and Datesets (or Graphs and DatasetGraphs) there does
> not appear to be a 'push'-based RDF Writer.
> Although there exists the deprecated method:
> {code:java}
> WriterDatasetRIOT ds =
> RDFDataMgr.createDatasetWriter(RDFFormat.TURTLE_PRETTY);
> {code}
> The documentation states that the returned object is for one-time use only.
> The feature request is to make it possible to write out streams of Datasets
> in a push-based manner. Thereby the writer should maintain state information
> such that prefixes and base IRIs are not written out redundantly.
> {code:java}
> try(OutputStream out = ...} {
> StreamWriterDatasetRIOT sink = RDFDataMgr.createStreamDatasetWriter(out,
> RDFFormat.TURTLE_PRETTY);
> sink.start(); // May immediately trigger a write on the output stream
> for (Dataset ds : streamOfDatasets) {
> sink.send(ds);
> sink.flush();
> }
> sink.finish(); // Write out footer and free resources
> // Is tthere is a need for sink.close()?
> } // close resources
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)