From 94f8994be96e1fca5e67856c7dafc05f44ecdb1b Mon Sep 17 00:00:00 2001 From: Karolina Bogacka Date: Tue, 13 May 2025 08:58:52 +0200 Subject: [PATCH 1/4] Add tests --- .../jelly/cli/command/rdf/RdfToJelly.scala | 3 +- .../cli/command/rdf/RdfToJellySpec.scala | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala index c4f223c..d404de3 100644 --- a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala +++ b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala @@ -129,8 +129,7 @@ object RdfToJelly extends RdfSerDesCommand[RdfToJellyOptions, RdfFormat.Readable .set( JellyLanguage.SYMBOL_ENABLE_NAMESPACE_DECLARATIONS, getOptions.enableNamespaceDeclarations, - ) - .set(JellyLanguage.SYMBOL_DELIMITED_OUTPUT, getOptions.delimited) + ).set(JellyLanguage.SYMBOL_DELIMITED_OUTPUT, getOptions.delimited) StreamRDFWriter.getWriterStream( outputStream, JellyLanguage.JELLY, diff --git a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala index ebbe451..5c3707f 100644 --- a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala +++ b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala @@ -227,6 +227,35 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers: } } + "a file to file, modified logical type to LOGICAL_STREAM_TYPE_GRAPHS" in withFullJenaFile { + f => + withEmptyJellyFile { j => + val (out, err) = + RdfToJelly.runTestCommand( + List( + "rdf", + "to-jelly", + f, + "--opt.logical-type=GRAPHS", + "--to", + j, + ), + ) + val content = translateJellyBack(new FileInputStream(j)) + content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements()) + val frames = readJellyFile(new FileInputStream(j)) + val opts = frames.head.rows.head.row.options + opts.streamName should be("") + opts.generalizedStatements should be(true) + opts.rdfStar should be(true) + opts.maxNameTableSize should be(JellyOptions.bigStrict.maxNameTableSize) + opts.maxPrefixTableSize should be(JellyOptions.bigStrict.maxPrefixTableSize) + opts.maxDatatypeTableSize should be(JellyOptions.bigStrict.maxDatatypeTableSize) + opts.logicalType should be(LogicalStreamType.GRAPHS) + opts.version should be(1) + } + } + "a file to file, lowered number of rows per frame" in withFullJenaFile { f => withEmptyJellyFile { j => val (out, err) = From bcfa63729b2b8caa5fc5ae13f7d155b3513f259c Mon Sep 17 00:00:00 2001 From: Karolina Bogacka Date: Tue, 13 May 2025 18:18:03 +0200 Subject: [PATCH 2/4] Fix the bug by avoiding the autodetect --- .../jelly/cli/command/rdf/RdfToJelly.scala | 42 ++++++--- .../cli/command/rdf/RdfToJellySpec.scala | 92 +++++++++++++------ 2 files changed, 92 insertions(+), 42 deletions(-) diff --git a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala index d404de3..54298d6 100644 --- a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala +++ b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala @@ -5,7 +5,7 @@ import eu.neverblink.jelly.cli.* import eu.neverblink.jelly.cli.command.rdf.util.* import eu.neverblink.jelly.cli.command.rdf.util.RdfFormat.* import eu.neverblink.jelly.cli.util.jena.riot.JellyStreamWriterGraphs -import eu.ostrzyciel.jelly.convert.jena.riot.{JellyFormatVariant, JellyLanguage} +import eu.ostrzyciel.jelly.convert.jena.riot.{JellyFormatVariant, JellyLanguage, JellyStreamWriter} import eu.ostrzyciel.jelly.core.proto.v1.{LogicalStreamType, RdfStreamFrame} import org.apache.jena.riot.system.StreamRDFWriter import org.apache.jena.riot.{Lang, RDFParser, RIOT} @@ -120,21 +120,33 @@ object RdfToJelly extends RdfSerDesCommand[RdfToJellyOptions, RdfFormat.Readable ) else // TRIPLES or QUADS - val writerContext = RIOT.getContext.copy() - .set( - JellyLanguage.SYMBOL_STREAM_OPTIONS, - jellyOpt, + if jellyOpt.physicalType.isUnspecified then + // If the physical type is unspecified, we want to autodetect it through getWriterStream + val writerContext = RIOT.getContext.copy() + .set( + JellyLanguage.SYMBOL_STREAM_OPTIONS, + jellyOpt, + ) + .set(JellyLanguage.SYMBOL_FRAME_SIZE, getOptions.rowsPerFrame) + .set( + JellyLanguage.SYMBOL_ENABLE_NAMESPACE_DECLARATIONS, + getOptions.enableNamespaceDeclarations, + ).set(JellyLanguage.SYMBOL_DELIMITED_OUTPUT, getOptions.delimited) + StreamRDFWriter.getWriterStream( + outputStream, + JellyLanguage.JELLY, + writerContext, ) - .set(JellyLanguage.SYMBOL_FRAME_SIZE, getOptions.rowsPerFrame) - .set( - JellyLanguage.SYMBOL_ENABLE_NAMESPACE_DECLARATIONS, - getOptions.enableNamespaceDeclarations, - ).set(JellyLanguage.SYMBOL_DELIMITED_OUTPUT, getOptions.delimited) - StreamRDFWriter.getWriterStream( - outputStream, - JellyLanguage.JELLY, - writerContext, - ) + else + // If the physical type is specified, we can just construct the writer + val variant = JellyFormatVariant( + opt = jellyOpt, + frameSize = getOptions.rowsPerFrame, + enableNamespaceDeclarations = getOptions.enableNamespaceDeclarations, + delimited = getOptions.delimited, + ) + JellyStreamWriter(variant, outputStream) + RDFParser.source(inputStream).lang(jenaLang).parse(jellyWriter) /** Convert Jelly text to Jelly binary. diff --git a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala index 5c3707f..bd53c09 100644 --- a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala +++ b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala @@ -4,7 +4,7 @@ import eu.neverblink.jelly.cli.command.helpers.{DataGenHelper, TestFixtureHelper import eu.neverblink.jelly.cli.command.rdf.util.RdfFormat import eu.neverblink.jelly.cli.* import eu.ostrzyciel.jelly.convert.jena.riot.JellyLanguage -import eu.ostrzyciel.jelly.core.proto.v1.{LogicalStreamType, RdfStreamFrame} +import eu.ostrzyciel.jelly.core.proto.v1.{LogicalStreamType, PhysicalStreamType, RdfStreamFrame} import eu.ostrzyciel.jelly.core.{IoUtils, JellyOptions} import org.apache.jena.rdf.model.{Model, ModelFactory} import org.apache.jena.riot.{RDFLanguages, RDFParser} @@ -227,8 +227,8 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers: } } - "a file to file, modified logical type to LOGICAL_STREAM_TYPE_GRAPHS" in withFullJenaFile { - f => + "a file to file, physical type set to TRIPLES, logical type to GRAPHS" in withFullJenaFile( + testCode = { f => withEmptyJellyFile { j => val (out, err) = RdfToJelly.runTestCommand( @@ -236,6 +236,7 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers: "rdf", "to-jelly", f, + "--opt.physical-type=TRIPLES", "--opt.logical-type=GRAPHS", "--to", j, @@ -251,34 +252,71 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers: opts.maxNameTableSize should be(JellyOptions.bigStrict.maxNameTableSize) opts.maxPrefixTableSize should be(JellyOptions.bigStrict.maxPrefixTableSize) opts.maxDatatypeTableSize should be(JellyOptions.bigStrict.maxDatatypeTableSize) + opts.physicalType should be(PhysicalStreamType.TRIPLES) opts.logicalType should be(LogicalStreamType.GRAPHS) opts.version should be(1) } - } + }, + jenaLang = RDFLanguages.NTRIPLES, + ) - "a file to file, lowered number of rows per frame" in withFullJenaFile { f => - withEmptyJellyFile { j => - val (out, err) = - RdfToJelly.runTestCommand( - List( - "rdf", - "to-jelly", - f, - "--rows-per-frame=10", - "--to", - j, - ), - ) - val content = translateJellyBack(new FileInputStream(j)) - content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements()) - val frames = readJellyFile(new FileInputStream(j)) - frames.size should be > 3 - for frame <- frames do - // The encoder may slightly overshoot the target if it needs to pack the lookup entries - // together with the triple. - frame.rows.size should be <= 15 - } - } + "a file to file, physical type unspecified, logical type set to GRAPHS" in withFullJenaFile( + testCode = { f => + withEmptyJellyFile { j => + val (out, err) = + RdfToJelly.runTestCommand( + List( + "rdf", + "to-jelly", + f, + "--opt.logical-type=GRAPHS", + "--to", + j, + ), + ) + val content = translateJellyBack(new FileInputStream(j)) + content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements()) + val frames = readJellyFile(new FileInputStream(j)) + val opts = frames.head.rows.head.row.options + opts.streamName should be("") + opts.generalizedStatements should be(true) + opts.rdfStar should be(true) + opts.maxNameTableSize should be(JellyOptions.bigStrict.maxNameTableSize) + opts.maxPrefixTableSize should be(JellyOptions.bigStrict.maxPrefixTableSize) + opts.maxDatatypeTableSize should be(JellyOptions.bigStrict.maxDatatypeTableSize) + opts.logicalType should be(LogicalStreamType.FLAT_TRIPLES) + opts.version should be(1) + } + }, + jenaLang = RDFLanguages.NTRIPLES, + ) + + "a file to file, lowered number of rows per frame" in withFullJenaFile( + testCode = { f => + withEmptyJellyFile { j => + val (out, err) = + RdfToJelly.runTestCommand( + List( + "rdf", + "to-jelly", + f, + "--rows-per-frame=10", + "--to", + j, + ), + ) + val content = translateJellyBack(new FileInputStream(j)) + content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements()) + val frames = readJellyFile(new FileInputStream(j)) + frames.size should be > 3 + for frame <- frames do + // The encoder may slightly overshoot the target if it needs to pack the lookup entries + // together with the triple. + frame.rows.size should be <= 15 + } + }, + jenaLang = RDFLanguages.NTRIPLES, + ) "a file to file, enabled namespace declarations" in withFullJenaFile { f => withEmptyJellyFile { j => From faee6c59915336255e3b40787d72b39a92cfa2d4 Mon Sep 17 00:00:00 2001 From: Karolina Bogacka Date: Tue, 13 May 2025 19:11:45 +0200 Subject: [PATCH 3/4] Add more tests --- .../jelly/cli/command/rdf/RdfToJelly.scala | 22 +- .../cli/command/rdf/RdfToJellySpec.scala | 188 +++++++++++------- 2 files changed, 131 insertions(+), 79 deletions(-) diff --git a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala index 54298d6..f9f1e83 100644 --- a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala +++ b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala @@ -6,7 +6,7 @@ import eu.neverblink.jelly.cli.command.rdf.util.* import eu.neverblink.jelly.cli.command.rdf.util.RdfFormat.* import eu.neverblink.jelly.cli.util.jena.riot.JellyStreamWriterGraphs import eu.ostrzyciel.jelly.convert.jena.riot.{JellyFormatVariant, JellyLanguage, JellyStreamWriter} -import eu.ostrzyciel.jelly.core.proto.v1.{LogicalStreamType, RdfStreamFrame} +import eu.ostrzyciel.jelly.core.proto.v1.{LogicalStreamType, RdfStreamFrame, RdfStreamOptions} import org.apache.jena.riot.system.StreamRDFWriter import org.apache.jena.riot.{Lang, RDFParser, RIOT} @@ -121,7 +121,14 @@ object RdfToJelly extends RdfSerDesCommand[RdfToJellyOptions, RdfFormat.Readable else // TRIPLES or QUADS if jellyOpt.physicalType.isUnspecified then - // If the physical type is unspecified, we want to autodetect it through getWriterStream + if !isQuietMode && isLogicalComplex(jellyOpt) then + printLine( + "WARNING: The physical type is unspecified, but the logical type is complex and requires framing. " + + "This may lead to unexpected results. " + + "Please specify the physical type explicitly. " + + "Use --quiet to silence this warning.", + true, + ) val writerContext = RIOT.getContext.copy() .set( JellyLanguage.SYMBOL_STREAM_OPTIONS, @@ -174,6 +181,17 @@ object RdfToJelly extends RdfSerDesCommand[RdfToJellyOptions, RdfFormat.Readable } } + /** Check if the logical type is more complex than FLAT_TRIPLES or FLAT_QUADS. + * @param jellyOpt + * the Jelly options + * @return + * true if the logical type is specified and expects framing + */ + private def isLogicalComplex( + jellyOpt: RdfStreamOptions, + ): Boolean = + !(jellyOpt.logicalType.isFlatQuads || jellyOpt.logicalType.isFlatTriples || jellyOpt.logicalType.isUnspecified) + /** Iterate over a Jelly text stream and return the frames as strings to be parsed. * @param reader * the reader to read from diff --git a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala index bd53c09..72a0dce 100644 --- a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala +++ b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala @@ -42,7 +42,7 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers: } "rdf to-jelly command" should { - "handle conversion of NTriples to Jelly" when { + "handle conversion of NQuads to Jelly" when { "a file to output stream" in withFullJenaFile { f => val (out, err) = RdfToJelly.runTestCommand(List("rdf", "to-jelly", f)) @@ -227,41 +227,8 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers: } } - "a file to file, physical type set to TRIPLES, logical type to GRAPHS" in withFullJenaFile( - testCode = { f => - withEmptyJellyFile { j => - val (out, err) = - RdfToJelly.runTestCommand( - List( - "rdf", - "to-jelly", - f, - "--opt.physical-type=TRIPLES", - "--opt.logical-type=GRAPHS", - "--to", - j, - ), - ) - val content = translateJellyBack(new FileInputStream(j)) - content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements()) - val frames = readJellyFile(new FileInputStream(j)) - val opts = frames.head.rows.head.row.options - opts.streamName should be("") - opts.generalizedStatements should be(true) - opts.rdfStar should be(true) - opts.maxNameTableSize should be(JellyOptions.bigStrict.maxNameTableSize) - opts.maxPrefixTableSize should be(JellyOptions.bigStrict.maxPrefixTableSize) - opts.maxDatatypeTableSize should be(JellyOptions.bigStrict.maxDatatypeTableSize) - opts.physicalType should be(PhysicalStreamType.TRIPLES) - opts.logicalType should be(LogicalStreamType.GRAPHS) - opts.version should be(1) - } - }, - jenaLang = RDFLanguages.NTRIPLES, - ) - - "a file to file, physical type unspecified, logical type set to GRAPHS" in withFullJenaFile( - testCode = { f => + "a file to file, physical type set to QUADS, logical type to DATASET STREAM" in withFullJenaFile { + f => withEmptyJellyFile { j => val (out, err) = RdfToJelly.runTestCommand( @@ -269,7 +236,8 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers: "rdf", "to-jelly", f, - "--opt.logical-type=GRAPHS", + "--opt.physical-type=QUADS", + "--opt.logical-type=DATASETS", "--to", j, ), @@ -284,39 +252,35 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers: opts.maxNameTableSize should be(JellyOptions.bigStrict.maxNameTableSize) opts.maxPrefixTableSize should be(JellyOptions.bigStrict.maxPrefixTableSize) opts.maxDatatypeTableSize should be(JellyOptions.bigStrict.maxDatatypeTableSize) - opts.logicalType should be(LogicalStreamType.FLAT_TRIPLES) + opts.physicalType should be(PhysicalStreamType.QUADS) + opts.logicalType should be(LogicalStreamType.DATASETS) opts.version should be(1) } - }, - jenaLang = RDFLanguages.NTRIPLES, - ) + } - "a file to file, lowered number of rows per frame" in withFullJenaFile( - testCode = { f => - withEmptyJellyFile { j => - val (out, err) = - RdfToJelly.runTestCommand( - List( - "rdf", - "to-jelly", - f, - "--rows-per-frame=10", - "--to", - j, - ), - ) - val content = translateJellyBack(new FileInputStream(j)) - content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements()) - val frames = readJellyFile(new FileInputStream(j)) - frames.size should be > 3 - for frame <- frames do - // The encoder may slightly overshoot the target if it needs to pack the lookup entries - // together with the triple. - frame.rows.size should be <= 15 - } - }, - jenaLang = RDFLanguages.NTRIPLES, - ) + "a file to file, lowered number of rows per frame" in withFullJenaFile { f => + withEmptyJellyFile { j => + val (out, err) = + RdfToJelly.runTestCommand( + List( + "rdf", + "to-jelly", + f, + "--rows-per-frame=10", + "--to", + j, + ), + ) + val content = translateJellyBack(new FileInputStream(j)) + content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements()) + val frames = readJellyFile(new FileInputStream(j)) + frames.size should be > 3 + for frame <- frames do + // The encoder may slightly overshoot the target if it needs to pack the lookup entries + // together with the triple. + frame.rows.size should be <= 15 + } + } "a file to file, enabled namespace declarations" in withFullJenaFile { f => withEmptyJellyFile { j => @@ -364,16 +328,86 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers: } "handle conversion of other formats to Jelly" when { - "NTriples" in { - val input = DataGenHelper.generateJenaInputStream(testCardinality, RDFLanguages.NTRIPLES) - RdfToJelly.setStdIn(input) - val (out, err) = - RdfToJelly.runTestCommand( - List("rdf", "to-jelly", "--in-format", RdfFormat.NTriples.cliOptions.head), - ) - val newIn = new ByteArrayInputStream(RdfToJelly.getOutBytes) - val content = translateJellyBack(newIn) - content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements()) + "NTriples" when { + "base functionality expected" in { + val input = DataGenHelper.generateJenaInputStream(testCardinality, RDFLanguages.NTRIPLES) + RdfToJelly.setStdIn(input) + val (out, err) = + RdfToJelly.runTestCommand( + List("rdf", "to-jelly", "--in-format", RdfFormat.NTriples.cliOptions.head), + ) + val newIn = new ByteArrayInputStream(RdfToJelly.getOutBytes) + val content = translateJellyBack(newIn) + content.containsAll(DataGenHelper.generateTripleModel(testCardinality).listStatements()) + } + "a file to file, physical type set to TRIPLES, logical type to GRAPHS" in withFullJenaFile( + testCode = { f => + withEmptyJellyFile { j => + val (out, err) = + RdfToJelly.runTestCommand( + List( + "rdf", + "to-jelly", + f, + "--opt.physical-type=TRIPLES", + "--opt.logical-type=GRAPHS", + "--to", + j, + ), + ) + val content = translateJellyBack(new FileInputStream(j)) + content.containsAll( + DataGenHelper.generateTripleModel(testCardinality).listStatements(), + ) + val frames = readJellyFile(new FileInputStream(j)) + val opts = frames.head.rows.head.row.options + opts.streamName should be("") + opts.generalizedStatements should be(true) + opts.rdfStar should be(true) + opts.maxNameTableSize should be(JellyOptions.bigStrict.maxNameTableSize) + opts.maxPrefixTableSize should be(JellyOptions.bigStrict.maxPrefixTableSize) + opts.maxDatatypeTableSize should be(JellyOptions.bigStrict.maxDatatypeTableSize) + opts.physicalType should be(PhysicalStreamType.TRIPLES) + opts.logicalType should be(LogicalStreamType.GRAPHS) + opts.version should be(1) + } + }, + jenaLang = RDFLanguages.NTRIPLES, + ) + + "a file to file, physical type unspecified, logical type set to GRAPHS" in withFullJenaFile( + testCode = { f => + withEmptyJellyFile { j => + val (out, err) = + RdfToJelly.runTestCommand( + List( + "rdf", + "to-jelly", + f, + "--opt.logical-type=GRAPHS", + "--to", + j, + ), + ) + val content = translateJellyBack(new FileInputStream(j)) + content.containsAll( + DataGenHelper.generateTripleModel(testCardinality).listStatements(), + ) + val frames = readJellyFile(new FileInputStream(j)) + val opts = frames.head.rows.head.row.options + opts.streamName should be("") + opts.generalizedStatements should be(true) + opts.rdfStar should be(true) + opts.maxNameTableSize should be(JellyOptions.bigStrict.maxNameTableSize) + opts.maxPrefixTableSize should be(JellyOptions.bigStrict.maxPrefixTableSize) + opts.maxDatatypeTableSize should be(JellyOptions.bigStrict.maxDatatypeTableSize) + opts.logicalType should be(LogicalStreamType.FLAT_TRIPLES) + opts.version should be(1) + RdfToJelly.getErrString should include("WARNING: The physical type is unspecified") + } + }, + jenaLang = RDFLanguages.NTRIPLES, + ) } "Turtle" in { val input = DataGenHelper.generateJenaInputStream(testCardinality, RDFLanguages.TURTLE) From 12d29c5bb0989d63bf43992ecd1850f5f7242fbe Mon Sep 17 00:00:00 2001 From: Karolina Bogacka Date: Tue, 13 May 2025 20:30:57 +0200 Subject: [PATCH 4/4] Fix review comments --- .../neverblink/jelly/cli/command/rdf/RdfToJelly.scala | 11 +++++------ .../jelly/cli/command/rdf/RdfToJellySpec.scala | 4 +++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala index f9f1e83..ce47dc3 100644 --- a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala +++ b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala @@ -121,11 +121,10 @@ object RdfToJelly extends RdfSerDesCommand[RdfToJellyOptions, RdfFormat.Readable else // TRIPLES or QUADS if jellyOpt.physicalType.isUnspecified then - if !isQuietMode && isLogicalComplex(jellyOpt) then + if !isQuietMode && isLogicalGrouped(jellyOpt) then printLine( - "WARNING: The physical type is unspecified, but the logical type is complex and requires framing. " + - "This may lead to unexpected results. " + - "Please specify the physical type explicitly. " + + "WARNING: Logical type setting ignored because physical type is not set. " + + "Set the physical type to properly pass on the logical type." + "Use --quiet to silence this warning.", true, ) @@ -181,13 +180,13 @@ object RdfToJelly extends RdfSerDesCommand[RdfToJellyOptions, RdfFormat.Readable } } - /** Check if the logical type is more complex than FLAT_TRIPLES or FLAT_QUADS. + /** Check if the logical type is defined and grouped. * @param jellyOpt * the Jelly options * @return * true if the logical type is specified and expects framing */ - private def isLogicalComplex( + private def isLogicalGrouped( jellyOpt: RdfStreamOptions, ): Boolean = !(jellyOpt.logicalType.isFlatQuads || jellyOpt.logicalType.isFlatTriples || jellyOpt.logicalType.isUnspecified) diff --git a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala index 72a0dce..7aee84c 100644 --- a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala +++ b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala @@ -403,7 +403,9 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers: opts.maxDatatypeTableSize should be(JellyOptions.bigStrict.maxDatatypeTableSize) opts.logicalType should be(LogicalStreamType.FLAT_TRIPLES) opts.version should be(1) - RdfToJelly.getErrString should include("WARNING: The physical type is unspecified") + RdfToJelly.getErrString should include( + "WARNING: Logical type setting ignored because physical type is not set.", + ) } }, jenaLang = RDFLanguages.NTRIPLES,