diff --git a/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyReader.scala b/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyReader.scala index f5972543..3dc2495b 100644 --- a/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyReader.scala +++ b/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyReader.scala @@ -31,16 +31,16 @@ object JellyReader extends ReaderRIOT: val decoder = JenaConverterFactory.anyStatementDecoder(Some(supportedOptions)) output.start() try { - while in.available() > 0 do - val frame = RdfStreamFrame.parseDelimitedFrom(in) - frame match - case Some(f) => - for row <- f.rows do - decoder.ingestRow(row) match - case Some(st: Triple) => output.triple(st) - case Some(st: Quad) => output.quad(st) - case None => () - case None => () + Iterator.continually(RdfStreamFrame.parseDelimitedFrom(in)) + .takeWhile(_.isDefined) + .foreach { maybeFrame => + val frame = maybeFrame.get + for row <- frame.rows do + decoder.ingestRow(row) match + case Some(st: Triple) => output.triple(st) + case Some(st: Quad) => output.quad(st) + case None => () + } } finally { output.finish() diff --git a/rdf4j/src/main/scala/eu/ostrzyciel/jelly/convert/rdf4j/rio/JellyParser.scala b/rdf4j/src/main/scala/eu/ostrzyciel/jelly/convert/rdf4j/rio/JellyParser.scala index 3f663187..53677ca9 100644 --- a/rdf4j/src/main/scala/eu/ostrzyciel/jelly/convert/rdf4j/rio/JellyParser.scala +++ b/rdf4j/src/main/scala/eu/ostrzyciel/jelly/convert/rdf4j/rio/JellyParser.scala @@ -38,15 +38,15 @@ final class JellyParser extends AbstractRDFParser: rdfHandler.startRDF() try { - while in.available() > 0 do - val frame = RdfStreamFrame.parseDelimitedFrom(in) - frame match - case Some(f) => - for row <- f.rows do - decoder.ingestRow(row) match - case Some(st) => rdfHandler.handleStatement(st) - case None => () - case None => () + Iterator.continually(RdfStreamFrame.parseDelimitedFrom(in)) + .takeWhile(_.isDefined) + .foreach { maybeFrame => + val frame = maybeFrame.get + for row <- frame.rows do + decoder.ingestRow(row) match + case Some(st) => rdfHandler.handleStatement(st) + case None => () + } } finally { rdfHandler.endRDF()