diff --git a/core/src/main/protobuf_shared b/core/src/main/protobuf_shared index 6cc9d302..824931de 160000 --- a/core/src/main/protobuf_shared +++ b/core/src/main/protobuf_shared @@ -1 +1 @@ -Subproject commit 6cc9d302786ee9e111c9305b60fe0f4938a08b32 +Subproject commit 824931de973b4179417d31152fba7d70283c3ca2 diff --git a/core/src/main/scala/eu/ostrzyciel/jelly/core/JellyOptions.scala b/core/src/main/scala/eu/ostrzyciel/jelly/core/JellyOptions.scala index ec12b497..4606c7f4 100644 --- a/core/src/main/scala/eu/ostrzyciel/jelly/core/JellyOptions.scala +++ b/core/src/main/scala/eu/ostrzyciel/jelly/core/JellyOptions.scala @@ -28,6 +28,14 @@ object JellyOptions: def bigGeneralized: RdfStreamOptions = bigStrict.withGeneralizedStatements(true) + /** + * "Big" preset suitable for high-volume streams and larger machines. + * Allows RDF-star statements. + * @return + */ + def bigRdfStar: RdfStreamOptions = + bigStrict.withRdfStar(true) + /** * "Small" preset suitable for low-volume streams and smaller machines. * Does not allow generalized RDF statements. @@ -47,3 +55,11 @@ object JellyOptions: */ def smallGeneralized: RdfStreamOptions = smallStrict.withGeneralizedStatements(true) + + /** + * "Small" preset suitable for low-volume streams and smaller machines. + * Allows RDF-star statements. + * @return + */ + def smallRdfStar: RdfStreamOptions = + smallStrict.withRdfStar(true) diff --git a/integration-tests/src/test/scala/eu/ostrzyciel/jelly/integration_tests/io/IoSerDesSpec.scala b/integration-tests/src/test/scala/eu/ostrzyciel/jelly/integration_tests/io/IoSerDesSpec.scala index d57411f3..37f46db6 100644 --- a/integration-tests/src/test/scala/eu/ostrzyciel/jelly/integration_tests/io/IoSerDesSpec.scala +++ b/integration-tests/src/test/scala/eu/ostrzyciel/jelly/integration_tests/io/IoSerDesSpec.scala @@ -29,9 +29,10 @@ class IoSerDesSpec extends AnyWordSpec, Matchers, ScalaFutures: val presets: Seq[(RdfStreamOptions, Int, String)] = Seq( (JellyOptions.smallGeneralized, 1, "small generalized"), - (JellyOptions.smallGeneralized, 1_000_000, "small generalized"), + (JellyOptions.smallRdfStar, 1_000_000, "small RDF-star"), (JellyOptions.smallStrict, 30, "small strict"), (JellyOptions.bigGeneralized, 256, "big generalized"), + (JellyOptions.bigRdfStar, 10_000, "big RDF-star"), (JellyOptions.bigStrict, 3, "big strict"), ) diff --git a/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyFormat.scala b/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyFormat.scala index 6d00098f..b4fdb0b6 100644 --- a/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyFormat.scala +++ b/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyFormat.scala @@ -21,12 +21,16 @@ final class JellyFormatVariant( object JellyFormat: val JELLY_SMALL_STRICT = new RDFFormat(JELLY, JellyFormatVariant(JellyOptions.smallStrict)) val JELLY_SMALL_GENERALIZED = new RDFFormat(JELLY, JellyFormatVariant(JellyOptions.smallGeneralized)) + val JELLY_SMALL_RDF_STAR = new RDFFormat(JELLY, JellyFormatVariant(JellyOptions.smallRdfStar)) val JELLY_BIG_STRICT = new RDFFormat(JELLY, JellyFormatVariant(JellyOptions.bigStrict)) val JELLY_BIG_GENERALIZED = new RDFFormat(JELLY, JellyFormatVariant(JellyOptions.bigGeneralized)) + val JELLY_BIG_RDF_STAR = new RDFFormat(JELLY, JellyFormatVariant(JellyOptions.bigRdfStar)) val allFormats = List( JELLY_SMALL_STRICT, JELLY_SMALL_GENERALIZED, + JELLY_SMALL_RDF_STAR, JELLY_BIG_STRICT, - JELLY_BIG_GENERALIZED + JELLY_BIG_GENERALIZED, + JELLY_BIG_RDF_STAR ) diff --git a/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyLanguage.scala b/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyLanguage.scala index 5d44ad12..aeb09b50 100644 --- a/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyLanguage.scala +++ b/jena/src/main/scala/eu/ostrzyciel/jelly/convert/jena/riot/JellyLanguage.scala @@ -16,7 +16,7 @@ object JellyLanguage: RDFLanguages.register(JELLY) // Default serialization format - RDFWriterRegistry.register(JELLY, JellyFormat.JELLY_SMALL_GENERALIZED) + RDFWriterRegistry.register(JELLY, JellyFormat.JELLY_SMALL_STRICT) // Register the writers for format <- JellyFormat.allFormats do RDFWriterRegistry.register(format, JellyGraphWriterFactory) diff --git a/rdf4j/src/main/scala/eu/ostrzyciel/jelly/convert/rdf4j/rio/JellyWriter.scala b/rdf4j/src/main/scala/eu/ostrzyciel/jelly/convert/rdf4j/rio/JellyWriter.scala index ec57c8ed..d56263e2 100644 --- a/rdf4j/src/main/scala/eu/ostrzyciel/jelly/convert/rdf4j/rio/JellyWriter.scala +++ b/rdf4j/src/main/scala/eu/ostrzyciel/jelly/convert/rdf4j/rio/JellyWriter.scala @@ -28,6 +28,7 @@ final class JellyWriter(out: OutputStream) extends AbstractRDFWriter: s.add(STREAM_TYPE) s.add(ALLOW_GENERALIZED_STATEMENTS) s.add(USE_REPEAT) + s.add(ALLOW_RDF_STAR) s.add(MAX_NAME_TABLE_SIZE) s.add(MAX_PREFIX_TABLE_SIZE) s.add(MAX_DATATYPE_TABLE_SIZE) @@ -42,6 +43,7 @@ final class JellyWriter(out: OutputStream) extends AbstractRDFWriter: streamType = c.get(STREAM_TYPE), generalizedStatements = c.get(ALLOW_GENERALIZED_STATEMENTS).booleanValue(), useRepeat = c.get(USE_REPEAT).booleanValue(), + rdfStar = c.get(ALLOW_RDF_STAR).booleanValue(), maxNameTableSize = c.get(MAX_NAME_TABLE_SIZE).toInt, maxPrefixTableSize = c.get(MAX_PREFIX_TABLE_SIZE).toInt, maxDatatypeTableSize = c.get(MAX_DATATYPE_TABLE_SIZE).toInt, diff --git a/rdf4j/src/main/scala/eu/ostrzyciel/jelly/convert/rdf4j/rio/JellyWriterSettings.scala b/rdf4j/src/main/scala/eu/ostrzyciel/jelly/convert/rdf4j/rio/JellyWriterSettings.scala index 618fc0c4..c4f2e870 100644 --- a/rdf4j/src/main/scala/eu/ostrzyciel/jelly/convert/rdf4j/rio/JellyWriterSettings.scala +++ b/rdf4j/src/main/scala/eu/ostrzyciel/jelly/convert/rdf4j/rio/JellyWriterSettings.scala @@ -46,6 +46,12 @@ object JellyWriterSettings: "Whether to compress repeating values (recommended)", true ) + + val ALLOW_RDF_STAR = new BooleanRioSetting( + "eu.ostrzyciel.jelly.convert.rdf4j.rio.allowRdfStar", + "Allow RDF-star statements", + false + ) val MAX_NAME_TABLE_SIZE = new LongRioSetting( "eu.ostrzyciel.jelly.convert.rdf4j.rio.maxNameTableSize", diff --git a/stream/src/main/scala/eu/ostrzyciel/jelly/stream/JellyOptionsFromTypesafe.scala b/stream/src/main/scala/eu/ostrzyciel/jelly/stream/JellyOptionsFromTypesafe.scala index c4d7d950..dc383520 100644 --- a/stream/src/main/scala/eu/ostrzyciel/jelly/stream/JellyOptionsFromTypesafe.scala +++ b/stream/src/main/scala/eu/ostrzyciel/jelly/stream/JellyOptionsFromTypesafe.scala @@ -13,6 +13,7 @@ object JellyOptionsFromTypesafe: |stream-type = UNSPECIFIED |generalized-statements = false |use-repeat = true + |rdf-star = false |name-table-size = 128 |prefix-table-size = 16 |dt-table-size = 16 @@ -25,6 +26,7 @@ object JellyOptionsFromTypesafe: * - "stream-type", either UNSPECIFIED, TRIPLES, QUADS, or GRAPHS. Default: UNSPECIFIED. * - "generalized-statements", boolean. Default: false. * - "use-repeat", boolean. Default: true. + * - "rdf-star", boolean. Default: false. * - "name-table-size", integer. Default: 128. * - "prefix-table-size", integer. Default: 16. * - "dt-table-size", integer. Default: 16. @@ -43,6 +45,7 @@ object JellyOptionsFromTypesafe: ), generalizedStatements = merged.getBoolean("generalized-statements"), useRepeat = merged.getBoolean("use-repeat"), + rdfStar = merged.getBoolean("rdf-star"), maxNameTableSize = merged.getInt("name-table-size"), maxPrefixTableSize = merged.getInt("prefix-table-size"), maxDatatypeTableSize = merged.getInt("dt-table-size"), diff --git a/stream/src/test/scala/eu/ostrzyciel/jelly/stream/JellyOptionsFromTypesafeSpec.scala b/stream/src/test/scala/eu/ostrzyciel/jelly/stream/JellyOptionsFromTypesafeSpec.scala index 4f1201e1..a498f2ab 100644 --- a/stream/src/test/scala/eu/ostrzyciel/jelly/stream/JellyOptionsFromTypesafeSpec.scala +++ b/stream/src/test/scala/eu/ostrzyciel/jelly/stream/JellyOptionsFromTypesafeSpec.scala @@ -22,6 +22,7 @@ class JellyOptionsFromTypesafeSpec extends AnyWordSpec, Matchers: |jelly.stream-type = GRAPHS |jelly.generalized-statements = true |jelly.use-repeat = false + |jelly.rdf-star = true |jelly.name-table-size = 1024 |jelly.prefix-table-size = 64 |jelly.dt-table-size = 8 @@ -30,6 +31,7 @@ class JellyOptionsFromTypesafeSpec extends AnyWordSpec, Matchers: opt.streamType should be (RdfStreamType.RDF_STREAM_TYPE_GRAPHS) opt.generalizedStatements should be (true) opt.useRepeat should be (false) + opt.rdfStar should be (true) opt.maxNameTableSize should be (1024) opt.maxPrefixTableSize should be (64) opt.maxDatatypeTableSize should be (8) @@ -45,6 +47,7 @@ class JellyOptionsFromTypesafeSpec extends AnyWordSpec, Matchers: opt.streamType should be (RdfStreamType.RDF_STREAM_TYPE_QUADS) opt.generalizedStatements should be (false) opt.useRepeat should be (true) + opt.rdfStar should be (false) opt.maxNameTableSize should be (1024) opt.maxPrefixTableSize should be (64) opt.maxDatatypeTableSize should be (16)