Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ object RdfToJelly extends RdfSerDesCommand[RdfToJellyOptions, RdfFormat.Readable
options.inputFormat,
remainingArgs.remaining.headOption,
)
if !isQuietMode then checkAndWarnTypeCombination()

override def matchFormatToAction(
format: RdfFormat.Readable,
Expand Down Expand Up @@ -191,6 +192,29 @@ object RdfToJelly extends RdfSerDesCommand[RdfToJellyOptions, RdfFormat.Readable
}
}

private def checkAndWarnTypeCombination(): Unit = {
val rdfStreamOptions = getOptions.jellySerializationOptions.asRdfStreamOptions

val physicalType = rdfStreamOptions.getPhysicalType
val isPhysicalTriple = physicalType == PhysicalStreamType.TRIPLES

val logicalType = rdfStreamOptions.getLogicalType
val logicalTripleTypes = Seq(
LogicalStreamType.GRAPHS,
LogicalStreamType.SUBJECT_GRAPHS,
LogicalStreamType.FLAT_TRIPLES,
)
val isLogicalTriple = logicalTripleTypes.contains(logicalType)

if isPhysicalTriple != isLogicalTriple then
printLine(
s"WARNING: Selected combination of logical/physical stream types ($logicalType/$physicalType) is unsupported. " +
"Use --quiet to silence this warning.",
true,
)

}

/** Check if the logical type is defined and grouped.
* @param jellyOpt
* the Jelly options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,4 +685,46 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers:
e.code should be(1)
}
}

"emit a warning" when {
"requesting an unsupported logical / physical combination" in withFullJenaFile { f =>
val (out, err) =
RdfToJelly.runTestCommand(
List(
"rdf",
"to-jelly",
"--opt.logical-type=SUBJECT_GRAPHS",
"--opt.physical-type=QUADS",
f,
),
)
err should (
include("WARNING") and
include("unsupported") and
include("SUBJECT_GRAPHS/QUADS")
)
}
}

"not emit a warning" when {
"requesting an unsupported logical / physical combination with --quiet flag" in withFullJenaFile {
f =>
val (out, err) =
RdfToJelly.runTestCommand(
List(
"rdf",
"to-jelly",
"--quiet",
"--opt.logical-type=SUBJECT_GRAPHS",
"--opt.physical-type=QUADS",
f,
),
)
err should not(
include("WARNING") and
include("unsupported") and
include("SUBJECT_GRAPHS/QUADS"),
)
}
}
}