Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resolvers +=
"Sonatype OSS Snapshots" at "https://s01.oss.sonatype.org/content/repositories/snapshots"

lazy val jenaV = "5.3.0"
lazy val jellyV = "2.9.1"
lazy val jellyV = "2.9.1+8-58db074b-SNAPSHOT"

addCommandAlias("fixAll", "scalafixAll; scalafmtAll")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ case class RdfToJellyOptions(
"Default: false",
)
enableNamespaceDeclarations: Boolean = false,
@HelpMessage(
"Whether the output should be delimited. Setting it to false will force the output to be a single " +
"frame – make sure you know what you are doing. Default: true",
)
delimited: Boolean = true,
) extends HasJellyCommandOptions

object RdfToJelly extends RdfCommand[RdfToJellyOptions, RdfFormat.Jena.Readable]:
Expand Down Expand Up @@ -85,6 +90,7 @@ object RdfToJelly extends RdfCommand[RdfToJellyOptions, RdfFormat.Jena.Readable]
JellyLanguage.SYMBOL_ENABLE_NAMESPACE_DECLARATIONS,
getOptions.enableNamespaceDeclarations,
)
.set(JellyLanguage.SYMBOL_DELIMITED_OUTPUT, getOptions.delimited)
val jellyWriter = StreamRDFWriter.getWriterStream(
outputStream,
JellyLanguage.JELLY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package eu.neverblink.jelly.cli.command.rdf
import eu.neverblink.jelly.cli.command.helpers.{DataGenHelper, TestFixtureHelper}
import eu.neverblink.jelly.cli.{ExitException, InvalidArgument, InvalidFormatSpecified}
import eu.ostrzyciel.jelly.convert.jena.riot.JellyLanguage
import eu.ostrzyciel.jelly.core.JellyOptions
import eu.ostrzyciel.jelly.core.{IoUtils, JellyOptions}
import eu.ostrzyciel.jelly.core.proto.v1.{LogicalStreamType, RdfStreamFrame}
import org.apache.jena.rdf.model.{Model, ModelFactory}
import org.apache.jena.riot.{RDFLanguages, RDFParser}
Expand Down Expand Up @@ -43,8 +43,10 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
"a file to output stream" in withFullJenaFile { f =>
val (out, err) =
RdfToJelly.runTestCommand(List("rdf", "to-jelly", f))
val newIn = new ByteArrayInputStream(RdfToJelly.getOutBytes)
val content = translateJellyBack(newIn)
val bytes = RdfToJelly.getOutBytes
// Make sure it's written in the delimited format
IoUtils.autodetectDelimiting(new ByteArrayInputStream(bytes))._1 should be(true)
val content = translateJellyBack(ByteArrayInputStream(bytes))
content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements())
}

Expand Down Expand Up @@ -187,6 +189,26 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
opts.version should be(2)
}
}

"a file to file, non-delimited output" in withFullJenaFile { f =>
withEmptyJellyFile { j =>
val (out, err) =
RdfToJelly.runTestCommand(
List(
"rdf",
"to-jelly",
f,
"--delimited=false",
"--to",
j,
),
)
val (delimited, is) = IoUtils.autodetectDelimiting(new FileInputStream(j))
delimited should be(false)
val frame = RdfStreamFrame.parseFrom(is)
frame.rows.size should be > 0
}
}
}
"handle conversion of other formats to Jelly" when {
"NTriples" in {
Expand Down
Loading