pyjelly 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyjelly might be problematic. Click here for more details.

@@ -0,0 +1,233 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Generator, Iterable
4
+ from typing import IO, Any
5
+ from typing_extensions import Never, override
6
+
7
+ import rdflib
8
+ from rdflib.graph import DATASET_DEFAULT_GRAPH_ID, Dataset, Graph
9
+ from rdflib.parser import InputSource
10
+ from rdflib.parser import Parser as RDFLibParser
11
+ from rdflib.store import Store
12
+
13
+ from pyjelly import jelly
14
+ from pyjelly.errors import JellyConformanceError
15
+ from pyjelly.options import StreamOptions
16
+ from pyjelly.parse.decode import Adapter, Decoder
17
+ from pyjelly.parse.ioutils import get_options_and_frames
18
+
19
+
20
+ class RDFLibAdapter(Adapter):
21
+ @override
22
+ def iri(self, iri: str) -> rdflib.URIRef:
23
+ return rdflib.URIRef(iri)
24
+
25
+ @override
26
+ def bnode(self, bnode: str) -> rdflib.BNode:
27
+ return rdflib.BNode(bnode)
28
+
29
+ @override
30
+ def default_graph(self) -> rdflib.URIRef:
31
+ return DATASET_DEFAULT_GRAPH_ID
32
+
33
+ @override
34
+ def literal(
35
+ self,
36
+ lex: str,
37
+ language: str | None = None,
38
+ datatype: str | None = None,
39
+ ) -> rdflib.Literal:
40
+ return rdflib.Literal(lex, lang=language, datatype=datatype)
41
+
42
+
43
+ def _adapter_missing(feature: str, *, options: StreamOptions) -> Never:
44
+ physical_type_name = jelly.PhysicalStreamType.Name(
45
+ options.stream_types.physical_type
46
+ )
47
+ logical_type_name = jelly.LogicalStreamType.Name(options.stream_types.logical_type)
48
+ msg = (
49
+ f"adapter with {physical_type_name} and {logical_type_name} "
50
+ f"does not implement {feature}"
51
+ )
52
+ raise NotImplementedError(msg)
53
+
54
+
55
+ class RDFLibTriplesAdapter(RDFLibAdapter):
56
+ graph: Graph
57
+
58
+ def __init__(self, graph: Graph, options: StreamOptions) -> None:
59
+ super().__init__(options=options)
60
+ self.graph = graph
61
+
62
+ @override
63
+ def triple(self, terms: Iterable[Any]) -> Any:
64
+ self.graph.add(terms) # type: ignore[arg-type]
65
+
66
+ @override
67
+ def namespace_declaration(self, name: str, iri: str) -> None:
68
+ self.graph.bind(name, self.iri(iri))
69
+
70
+ def frame(self) -> Graph | None:
71
+ if self.options.stream_types.logical_type == jelly.LOGICAL_STREAM_TYPE_GRAPHS:
72
+ this_graph = self.graph
73
+ self.graph = Graph(store=self.graph.store)
74
+ return this_graph
75
+ if self.options.stream_types.logical_type in (
76
+ jelly.LOGICAL_STREAM_TYPE_UNSPECIFIED,
77
+ jelly.LOGICAL_STREAM_TYPE_FLAT_TRIPLES,
78
+ ):
79
+ return None
80
+ return _adapter_missing("interpreting frames", options=self.options)
81
+
82
+
83
+ class RDFLibQuadsBaseAdapter(RDFLibAdapter):
84
+ def __init__(self, dataset: Dataset, options: StreamOptions) -> None:
85
+ super().__init__(options=options)
86
+ self.dataset = dataset
87
+
88
+ @override
89
+ def frame(self) -> Dataset | None:
90
+ if self.options.stream_types.logical_type == jelly.LOGICAL_STREAM_TYPE_DATASETS:
91
+ this_dataset = self.dataset
92
+ self.dataset = Dataset(store=self.dataset.store)
93
+ return this_dataset
94
+ if self.options.stream_types.logical_type in (
95
+ jelly.LOGICAL_STREAM_TYPE_UNSPECIFIED,
96
+ jelly.LOGICAL_STREAM_TYPE_FLAT_QUADS,
97
+ ):
98
+ return None
99
+ return _adapter_missing("interpreting frames", options=self.options)
100
+
101
+
102
+ class RDFLibQuadsAdapter(RDFLibQuadsBaseAdapter):
103
+ @override
104
+ def namespace_declaration(self, name: str, iri: str) -> None:
105
+ self.dataset.bind(name, self.iri(iri))
106
+
107
+ @override
108
+ def quad(self, terms: Iterable[Any]) -> Any:
109
+ self.dataset.add(terms) # type: ignore[arg-type]
110
+
111
+
112
+ class RDFLibGraphsAdapter(RDFLibQuadsBaseAdapter):
113
+ _graph: Graph | None = None
114
+
115
+ def __init__(self, dataset: Dataset, options: StreamOptions) -> None:
116
+ super().__init__(dataset=dataset, options=options)
117
+ self._graph = None
118
+
119
+ @property
120
+ def graph(self) -> Graph:
121
+ if self._graph is None:
122
+ msg = "new graph was not started"
123
+ raise JellyConformanceError(msg)
124
+ return self._graph
125
+
126
+ @override
127
+ def graph_start(self, graph_id: str) -> None:
128
+ self._graph = Graph(store=self.dataset.store, identifier=graph_id)
129
+
130
+ @override
131
+ def namespace_declaration(self, name: str, iri: str) -> None:
132
+ self.graph.bind(name, self.iri(iri))
133
+
134
+ @override
135
+ def triple(self, terms: Iterable[Any]) -> None:
136
+ self.graph.add(terms) # type: ignore[arg-type]
137
+
138
+ @override
139
+ def graph_end(self) -> None:
140
+ self.dataset.store.add_graph(self.graph)
141
+ self._graph = None
142
+
143
+ def frame(self) -> Dataset | None:
144
+ if self.options.stream_types.logical_type == jelly.LOGICAL_STREAM_TYPE_DATASETS:
145
+ this_dataset = self.dataset
146
+ self._graph = None
147
+ self.dataset = Dataset(store=self.dataset.store)
148
+ return this_dataset
149
+ return super().frame()
150
+
151
+
152
+ def parse_flat_stream(
153
+ frames: Iterable[jelly.RdfStreamFrame],
154
+ sink: Graph,
155
+ options: StreamOptions,
156
+ ) -> Dataset | Graph:
157
+ assert options.stream_types.flat
158
+ ds = None
159
+
160
+ adapter: Adapter
161
+ if options.stream_types.physical_type == jelly.PHYSICAL_STREAM_TYPE_TRIPLES:
162
+ adapter = RDFLibTriplesAdapter(graph=sink, options=options)
163
+ else:
164
+ ds = Dataset(store=sink.store, default_union=True)
165
+ ds.default_context = sink
166
+
167
+ if options.stream_types.physical_type == jelly.PHYSICAL_STREAM_TYPE_QUADS:
168
+ adapter = RDFLibQuadsAdapter(dataset=ds, options=options)
169
+
170
+ else: # jelly.PHYSICAL_STREAM_TYPE_GRAPHS
171
+ adapter = RDFLibGraphsAdapter(dataset=ds, options=options)
172
+ decoder = Decoder(adapter=adapter)
173
+ for frame in frames:
174
+ decoder.decode_frame(frame=frame)
175
+ return ds or sink
176
+
177
+
178
+ def parse_grouped_graph_stream(
179
+ frames: Iterable[jelly.RdfStreamFrame],
180
+ sink: Graph,
181
+ options: StreamOptions,
182
+ ) -> Dataset:
183
+ adapter = RDFLibTriplesAdapter(graph=sink, options=options)
184
+ ds = Dataset(store=sink.store, default_union=True)
185
+ ds.default_context = sink
186
+ decoder = Decoder(adapter=adapter)
187
+ for frame in frames:
188
+ graph = decoder.decode_frame(frame=frame)
189
+ ds.add_graph(graph)
190
+ return ds
191
+
192
+
193
+ def parse_grouped_dataset_stream(
194
+ frames: Iterable[jelly.RdfStreamFrame],
195
+ options: StreamOptions,
196
+ store: Store | str = "default",
197
+ ) -> Generator[Dataset]:
198
+ adapter = RDFLibGraphsAdapter(dataset=Dataset(store=store), options=options)
199
+ decoder = Decoder(adapter=adapter)
200
+ for frame in frames:
201
+ yield decoder.decode_frame(frame=frame)
202
+
203
+
204
+ def graph_or_dataset_from_jelly(
205
+ inp: IO[bytes],
206
+ sink: Graph,
207
+ ) -> Dataset | Graph:
208
+ options, frames = get_options_and_frames(inp)
209
+
210
+ if options.stream_types.flat:
211
+ return parse_flat_stream(frames=frames, sink=sink, options=options)
212
+
213
+ if options.stream_types.physical_type == jelly.PHYSICAL_STREAM_TYPE_TRIPLES:
214
+ return parse_grouped_graph_stream(frames=frames, sink=sink, options=options)
215
+
216
+ msg = (
217
+ "the stream contains multiple datasets and cannot be parsed into "
218
+ "a single dataset"
219
+ )
220
+ raise NotImplementedError(msg)
221
+
222
+
223
+ class RDFLibJellyParser(RDFLibParser):
224
+ def parse(
225
+ self,
226
+ source: InputSource,
227
+ sink: Graph,
228
+ ) -> None:
229
+ inp = source.getByteStream() # type: ignore[no-untyped-call]
230
+ if inp is None:
231
+ msg = "expected source to be a stream of bytes"
232
+ raise TypeError(msg)
233
+ graph_or_dataset_from_jelly(inp, sink=sink)
@@ -0,0 +1,119 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Generator
4
+ from functools import singledispatch
5
+ from typing import IO, Any
6
+ from typing_extensions import override
7
+
8
+ import rdflib
9
+ from rdflib.graph import DATASET_DEFAULT_GRAPH_ID, Dataset, Graph, QuotedGraph
10
+ from rdflib.serializer import Serializer as RDFLibSerializer
11
+
12
+ from pyjelly import jelly
13
+ from pyjelly.serialize.encode import RowsAndTerm, Slot, TermEncoder
14
+ from pyjelly.serialize.ioutils import write_delimited, write_single
15
+ from pyjelly.serialize.streams import GraphStream, QuadStream, Stream, TripleStream
16
+
17
+
18
+ class RDFLibTermEncoder(TermEncoder):
19
+ def encode_any(self, term: object, slot: Slot) -> RowsAndTerm:
20
+ if slot is Slot.graph and term == DATASET_DEFAULT_GRAPH_ID:
21
+ return self.encode_default_graph()
22
+
23
+ if isinstance(term, rdflib.URIRef):
24
+ return self.encode_iri(term)
25
+
26
+ if isinstance(term, rdflib.Literal):
27
+ return self.encode_literal(
28
+ lex=str(term),
29
+ language=term.language,
30
+ # `datatype` is cast to `str` explicitly because
31
+ # `URIRef.__eq__` overrides `str.__eq__` in an incompatible manner
32
+ datatype=term.datatype and str(term.datatype),
33
+ )
34
+
35
+ if isinstance(term, rdflib.BNode):
36
+ return self.encode_bnode(str(term))
37
+
38
+ return super().encode_any(term, slot) # error if not handled
39
+
40
+
41
+ def namespace_declarations(store: Graph, stream: Stream) -> None:
42
+ for prefix, namespace in store.namespaces():
43
+ stream.namespace_declaration(name=prefix, iri=namespace)
44
+
45
+
46
+ @singledispatch
47
+ def stream_frames(stream: Stream, data: Graph) -> Generator[jelly.RdfStreamFrame]: # noqa: ARG001
48
+ msg = f"invalid stream implementation {stream}"
49
+ raise TypeError(msg)
50
+
51
+
52
+ @stream_frames.register
53
+ def triples_stream(
54
+ stream: TripleStream,
55
+ data: Graph,
56
+ ) -> Generator[jelly.RdfStreamFrame]:
57
+ assert not isinstance(data, Dataset)
58
+ stream.enroll()
59
+ if stream.options.namespace_declarations:
60
+ namespace_declarations(data, stream)
61
+ for terms in data:
62
+ if frame := stream.triple(terms):
63
+ yield frame
64
+ if frame := stream.flow.to_stream_frame():
65
+ yield frame
66
+
67
+
68
+ @stream_frames.register
69
+ def quads_stream(stream: QuadStream, data: Graph) -> Generator[jelly.RdfStreamFrame]:
70
+ assert isinstance(data, Dataset)
71
+ stream.enroll()
72
+ if stream.options.namespace_declarations:
73
+ namespace_declarations(data, stream)
74
+ for terms in data.quads():
75
+ if frame := stream.quad(terms):
76
+ yield frame
77
+ if frame := stream.flow.to_stream_frame():
78
+ yield frame
79
+
80
+
81
+ @stream_frames.register
82
+ def graphs_stream(stream: GraphStream, data: Graph) -> Generator[jelly.RdfStreamFrame]:
83
+ assert isinstance(data, Dataset)
84
+ stream.enroll()
85
+ if stream.options.namespace_declarations:
86
+ namespace_declarations(data, stream)
87
+ for graph in data.graphs():
88
+ yield from stream.graph(graph_id=graph.identifier, graph=graph)
89
+ if frame := stream.flow.to_stream_frame():
90
+ yield frame
91
+
92
+
93
+ class RDFLibJellySerializer(RDFLibSerializer):
94
+ """
95
+ RDFLib serializer for writing graphs in Jelly RDF stream format.
96
+
97
+ Handles streaming RDF terms into Jelly frames using internal encoders.
98
+ Supports only graphs and datasets (not quoted graphs).
99
+
100
+ """
101
+
102
+ def __init__(self, store: Graph) -> None:
103
+ if isinstance(store, QuotedGraph):
104
+ msg = "N3 format is not supported"
105
+ raise NotImplementedError(msg)
106
+ super().__init__(store)
107
+
108
+ @override
109
+ def serialize( # type: ignore[override]
110
+ self,
111
+ out: IO[bytes],
112
+ /,
113
+ *,
114
+ stream: Stream,
115
+ **unused: Any,
116
+ ) -> None:
117
+ write = write_delimited if stream.options.delimited else write_single
118
+ for stream_frame in stream_frames(stream, self.store):
119
+ write(stream_frame, out)
@@ -0,0 +1,5 @@
1
+ from pyjelly.jelly import rdf_pb2
2
+ from pyjelly.jelly.rdf_pb2 import *
3
+
4
+ # workaround for mypyc
5
+ globals().update(vars(rdf_pb2))
@@ -0,0 +1,70 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: rdf.proto
5
+ # Protobuf Python Version: 5.29.0
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 5,
15
+ 29,
16
+ 0,
17
+ '',
18
+ 'rdf.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+
26
+
27
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\trdf.proto\x12!eu.ostrzyciel.jelly.core.proto.v1\",\n\x06RdfIri\x12\x11\n\tprefix_id\x18\x01 \x01(\r\x12\x0f\n\x07name_id\x18\x02 \x01(\r\"O\n\nRdfLiteral\x12\x0b\n\x03lex\x18\x01 \x01(\t\x12\x11\n\x07langtag\x18\x02 \x01(\tH\x00\x12\x12\n\x08\x64\x61tatype\x18\x03 \x01(\rH\x00\x42\r\n\x0bliteralKind\"\x11\n\x0fRdfDefaultGraph\"\xbb\x05\n\tRdfTriple\x12:\n\x05s_iri\x18\x01 \x01(\x0b\x32).eu.ostrzyciel.jelly.core.proto.v1.RdfIriH\x00\x12\x11\n\x07s_bnode\x18\x02 \x01(\tH\x00\x12\x42\n\ts_literal\x18\x03 \x01(\x0b\x32-.eu.ostrzyciel.jelly.core.proto.v1.RdfLiteralH\x00\x12\x45\n\rs_triple_term\x18\x04 \x01(\x0b\x32,.eu.ostrzyciel.jelly.core.proto.v1.RdfTripleH\x00\x12:\n\x05p_iri\x18\x05 \x01(\x0b\x32).eu.ostrzyciel.jelly.core.proto.v1.RdfIriH\x01\x12\x11\n\x07p_bnode\x18\x06 \x01(\tH\x01\x12\x42\n\tp_literal\x18\x07 \x01(\x0b\x32-.eu.ostrzyciel.jelly.core.proto.v1.RdfLiteralH\x01\x12\x45\n\rp_triple_term\x18\x08 \x01(\x0b\x32,.eu.ostrzyciel.jelly.core.proto.v1.RdfTripleH\x01\x12:\n\x05o_iri\x18\t \x01(\x0b\x32).eu.ostrzyciel.jelly.core.proto.v1.RdfIriH\x02\x12\x11\n\x07o_bnode\x18\n \x01(\tH\x02\x12\x42\n\to_literal\x18\x0b \x01(\x0b\x32-.eu.ostrzyciel.jelly.core.proto.v1.RdfLiteralH\x02\x12\x45\n\ro_triple_term\x18\x0c \x01(\x0b\x32,.eu.ostrzyciel.jelly.core.proto.v1.RdfTripleH\x02\x42\t\n\x07subjectB\x0b\n\tpredicateB\x08\n\x06object\"\xa4\x07\n\x07RdfQuad\x12:\n\x05s_iri\x18\x01 \x01(\x0b\x32).eu.ostrzyciel.jelly.core.proto.v1.RdfIriH\x00\x12\x11\n\x07s_bnode\x18\x02 \x01(\tH\x00\x12\x42\n\ts_literal\x18\x03 \x01(\x0b\x32-.eu.ostrzyciel.jelly.core.proto.v1.RdfLiteralH\x00\x12\x45\n\rs_triple_term\x18\x04 \x01(\x0b\x32,.eu.ostrzyciel.jelly.core.proto.v1.RdfTripleH\x00\x12:\n\x05p_iri\x18\x05 \x01(\x0b\x32).eu.ostrzyciel.jelly.core.proto.v1.RdfIriH\x01\x12\x11\n\x07p_bnode\x18\x06 \x01(\tH\x01\x12\x42\n\tp_literal\x18\x07 \x01(\x0b\x32-.eu.ostrzyciel.jelly.core.proto.v1.RdfLiteralH\x01\x12\x45\n\rp_triple_term\x18\x08 \x01(\x0b\x32,.eu.ostrzyciel.jelly.core.proto.v1.RdfTripleH\x01\x12:\n\x05o_iri\x18\t \x01(\x0b\x32).eu.ostrzyciel.jelly.core.proto.v1.RdfIriH\x02\x12\x11\n\x07o_bnode\x18\n \x01(\tH\x02\x12\x42\n\to_literal\x18\x0b \x01(\x0b\x32-.eu.ostrzyciel.jelly.core.proto.v1.RdfLiteralH\x02\x12\x45\n\ro_triple_term\x18\x0c \x01(\x0b\x32,.eu.ostrzyciel.jelly.core.proto.v1.RdfTripleH\x02\x12:\n\x05g_iri\x18\r \x01(\x0b\x32).eu.ostrzyciel.jelly.core.proto.v1.RdfIriH\x03\x12\x11\n\x07g_bnode\x18\x0e \x01(\tH\x03\x12M\n\x0fg_default_graph\x18\x0f \x01(\x0b\x32\x32.eu.ostrzyciel.jelly.core.proto.v1.RdfDefaultGraphH\x03\x12\x42\n\tg_literal\x18\x10 \x01(\x0b\x32-.eu.ostrzyciel.jelly.core.proto.v1.RdfLiteralH\x03\x42\t\n\x07subjectB\x0b\n\tpredicateB\x08\n\x06objectB\x07\n\x05graph\"\xfa\x01\n\rRdfGraphStart\x12:\n\x05g_iri\x18\x01 \x01(\x0b\x32).eu.ostrzyciel.jelly.core.proto.v1.RdfIriH\x00\x12\x11\n\x07g_bnode\x18\x02 \x01(\tH\x00\x12M\n\x0fg_default_graph\x18\x03 \x01(\x0b\x32\x32.eu.ostrzyciel.jelly.core.proto.v1.RdfDefaultGraphH\x00\x12\x42\n\tg_literal\x18\x04 \x01(\x0b\x32-.eu.ostrzyciel.jelly.core.proto.v1.RdfLiteralH\x00\x42\x07\n\x05graph\"\r\n\x0bRdfGraphEnd\"a\n\x17RdfNamespaceDeclaration\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x38\n\x05value\x18\x02 \x01(\x0b\x32).eu.ostrzyciel.jelly.core.proto.v1.RdfIri\")\n\x0cRdfNameEntry\x12\n\n\x02id\x18\x01 \x01(\r\x12\r\n\x05value\x18\x02 \x01(\t\"+\n\x0eRdfPrefixEntry\x12\n\n\x02id\x18\x01 \x01(\r\x12\r\n\x05value\x18\x02 \x01(\t\"-\n\x10RdfDatatypeEntry\x12\n\n\x02id\x18\x01 \x01(\r\x12\r\n\x05value\x18\x02 \x01(\t\"\xe1\x02\n\x10RdfStreamOptions\x12\x13\n\x0bstream_name\x18\x01 \x01(\t\x12L\n\rphysical_type\x18\x02 \x01(\x0e\x32\x35.eu.ostrzyciel.jelly.core.proto.v1.PhysicalStreamType\x12\x1e\n\x16generalized_statements\x18\x03 \x01(\x08\x12\x10\n\x08rdf_star\x18\x04 \x01(\x08\x12\x1b\n\x13max_name_table_size\x18\t \x01(\r\x12\x1d\n\x15max_prefix_table_size\x18\n \x01(\r\x12\x1f\n\x17max_datatype_table_size\x18\x0b \x01(\r\x12J\n\x0clogical_type\x18\x0e \x01(\x0e\x32\x34.eu.ostrzyciel.jelly.core.proto.v1.LogicalStreamType\x12\x0f\n\x07version\x18\x0f \x01(\r\"\x87\x05\n\x0cRdfStreamRow\x12\x46\n\x07options\x18\x01 \x01(\x0b\x32\x33.eu.ostrzyciel.jelly.core.proto.v1.RdfStreamOptionsH\x00\x12>\n\x06triple\x18\x02 \x01(\x0b\x32,.eu.ostrzyciel.jelly.core.proto.v1.RdfTripleH\x00\x12:\n\x04quad\x18\x03 \x01(\x0b\x32*.eu.ostrzyciel.jelly.core.proto.v1.RdfQuadH\x00\x12G\n\x0bgraph_start\x18\x04 \x01(\x0b\x32\x30.eu.ostrzyciel.jelly.core.proto.v1.RdfGraphStartH\x00\x12\x43\n\tgraph_end\x18\x05 \x01(\x0b\x32..eu.ostrzyciel.jelly.core.proto.v1.RdfGraphEndH\x00\x12O\n\tnamespace\x18\x06 \x01(\x0b\x32:.eu.ostrzyciel.jelly.core.proto.v1.RdfNamespaceDeclarationH\x00\x12?\n\x04name\x18\t \x01(\x0b\x32/.eu.ostrzyciel.jelly.core.proto.v1.RdfNameEntryH\x00\x12\x43\n\x06prefix\x18\n \x01(\x0b\x32\x31.eu.ostrzyciel.jelly.core.proto.v1.RdfPrefixEntryH\x00\x12G\n\x08\x64\x61tatype\x18\x0b \x01(\x0b\x32\x33.eu.ostrzyciel.jelly.core.proto.v1.RdfDatatypeEntryH\x00\x42\x05\n\x03row\"\xd3\x01\n\x0eRdfStreamFrame\x12=\n\x04rows\x18\x01 \x03(\x0b\x32/.eu.ostrzyciel.jelly.core.proto.v1.RdfStreamRow\x12Q\n\x08metadata\x18\x0f \x03(\x0b\x32?.eu.ostrzyciel.jelly.core.proto.v1.RdfStreamFrame.MetadataEntry\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c:\x02\x38\x01*\x9d\x01\n\x12PhysicalStreamType\x12$\n PHYSICAL_STREAM_TYPE_UNSPECIFIED\x10\x00\x12 \n\x1cPHYSICAL_STREAM_TYPE_TRIPLES\x10\x01\x12\x1e\n\x1aPHYSICAL_STREAM_TYPE_QUADS\x10\x02\x12\x1f\n\x1bPHYSICAL_STREAM_TYPE_GRAPHS\x10\x03*\xc4\x02\n\x11LogicalStreamType\x12#\n\x1fLOGICAL_STREAM_TYPE_UNSPECIFIED\x10\x00\x12$\n LOGICAL_STREAM_TYPE_FLAT_TRIPLES\x10\x01\x12\"\n\x1eLOGICAL_STREAM_TYPE_FLAT_QUADS\x10\x02\x12\x1e\n\x1aLOGICAL_STREAM_TYPE_GRAPHS\x10\x03\x12 \n\x1cLOGICAL_STREAM_TYPE_DATASETS\x10\x04\x12&\n\"LOGICAL_STREAM_TYPE_SUBJECT_GRAPHS\x10\r\x12$\n LOGICAL_STREAM_TYPE_NAMED_GRAPHS\x10\x0e\x12\x30\n,LOGICAL_STREAM_TYPE_TIMESTAMPED_NAMED_GRAPHS\x10rb\x06proto3')
28
+
29
+ _globals = globals()
30
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
31
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'rdf_pb2', _globals)
32
+ if not _descriptor._USE_C_DESCRIPTORS:
33
+ DESCRIPTOR._loaded_options = None
34
+ _globals['_RDFSTREAMFRAME_METADATAENTRY']._loaded_options = None
35
+ _globals['_RDFSTREAMFRAME_METADATAENTRY']._serialized_options = b'8\001'
36
+ _globals['_PHYSICALSTREAMTYPE']._serialized_start=3554
37
+ _globals['_PHYSICALSTREAMTYPE']._serialized_end=3711
38
+ _globals['_LOGICALSTREAMTYPE']._serialized_start=3714
39
+ _globals['_LOGICALSTREAMTYPE']._serialized_end=4038
40
+ _globals['_RDFIRI']._serialized_start=48
41
+ _globals['_RDFIRI']._serialized_end=92
42
+ _globals['_RDFLITERAL']._serialized_start=94
43
+ _globals['_RDFLITERAL']._serialized_end=173
44
+ _globals['_RDFDEFAULTGRAPH']._serialized_start=175
45
+ _globals['_RDFDEFAULTGRAPH']._serialized_end=192
46
+ _globals['_RDFTRIPLE']._serialized_start=195
47
+ _globals['_RDFTRIPLE']._serialized_end=894
48
+ _globals['_RDFQUAD']._serialized_start=897
49
+ _globals['_RDFQUAD']._serialized_end=1829
50
+ _globals['_RDFGRAPHSTART']._serialized_start=1832
51
+ _globals['_RDFGRAPHSTART']._serialized_end=2082
52
+ _globals['_RDFGRAPHEND']._serialized_start=2084
53
+ _globals['_RDFGRAPHEND']._serialized_end=2097
54
+ _globals['_RDFNAMESPACEDECLARATION']._serialized_start=2099
55
+ _globals['_RDFNAMESPACEDECLARATION']._serialized_end=2196
56
+ _globals['_RDFNAMEENTRY']._serialized_start=2198
57
+ _globals['_RDFNAMEENTRY']._serialized_end=2239
58
+ _globals['_RDFPREFIXENTRY']._serialized_start=2241
59
+ _globals['_RDFPREFIXENTRY']._serialized_end=2284
60
+ _globals['_RDFDATATYPEENTRY']._serialized_start=2286
61
+ _globals['_RDFDATATYPEENTRY']._serialized_end=2331
62
+ _globals['_RDFSTREAMOPTIONS']._serialized_start=2334
63
+ _globals['_RDFSTREAMOPTIONS']._serialized_end=2687
64
+ _globals['_RDFSTREAMROW']._serialized_start=2690
65
+ _globals['_RDFSTREAMROW']._serialized_end=3337
66
+ _globals['_RDFSTREAMFRAME']._serialized_start=3340
67
+ _globals['_RDFSTREAMFRAME']._serialized_end=3551
68
+ _globals['_RDFSTREAMFRAME_METADATAENTRY']._serialized_start=3504
69
+ _globals['_RDFSTREAMFRAME_METADATAENTRY']._serialized_end=3551
70
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,230 @@
1
+ from google.protobuf.internal import containers as _containers
2
+ from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
3
+ from google.protobuf import descriptor as _descriptor
4
+ from google.protobuf import message as _message
5
+ from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union
6
+
7
+ DESCRIPTOR: _descriptor.FileDescriptor
8
+
9
+ class PhysicalStreamType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
10
+ __slots__ = ()
11
+ PHYSICAL_STREAM_TYPE_UNSPECIFIED: _ClassVar[PhysicalStreamType]
12
+ PHYSICAL_STREAM_TYPE_TRIPLES: _ClassVar[PhysicalStreamType]
13
+ PHYSICAL_STREAM_TYPE_QUADS: _ClassVar[PhysicalStreamType]
14
+ PHYSICAL_STREAM_TYPE_GRAPHS: _ClassVar[PhysicalStreamType]
15
+
16
+ class LogicalStreamType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
17
+ __slots__ = ()
18
+ LOGICAL_STREAM_TYPE_UNSPECIFIED: _ClassVar[LogicalStreamType]
19
+ LOGICAL_STREAM_TYPE_FLAT_TRIPLES: _ClassVar[LogicalStreamType]
20
+ LOGICAL_STREAM_TYPE_FLAT_QUADS: _ClassVar[LogicalStreamType]
21
+ LOGICAL_STREAM_TYPE_GRAPHS: _ClassVar[LogicalStreamType]
22
+ LOGICAL_STREAM_TYPE_DATASETS: _ClassVar[LogicalStreamType]
23
+ LOGICAL_STREAM_TYPE_SUBJECT_GRAPHS: _ClassVar[LogicalStreamType]
24
+ LOGICAL_STREAM_TYPE_NAMED_GRAPHS: _ClassVar[LogicalStreamType]
25
+ LOGICAL_STREAM_TYPE_TIMESTAMPED_NAMED_GRAPHS: _ClassVar[LogicalStreamType]
26
+ PHYSICAL_STREAM_TYPE_UNSPECIFIED: PhysicalStreamType
27
+ PHYSICAL_STREAM_TYPE_TRIPLES: PhysicalStreamType
28
+ PHYSICAL_STREAM_TYPE_QUADS: PhysicalStreamType
29
+ PHYSICAL_STREAM_TYPE_GRAPHS: PhysicalStreamType
30
+ LOGICAL_STREAM_TYPE_UNSPECIFIED: LogicalStreamType
31
+ LOGICAL_STREAM_TYPE_FLAT_TRIPLES: LogicalStreamType
32
+ LOGICAL_STREAM_TYPE_FLAT_QUADS: LogicalStreamType
33
+ LOGICAL_STREAM_TYPE_GRAPHS: LogicalStreamType
34
+ LOGICAL_STREAM_TYPE_DATASETS: LogicalStreamType
35
+ LOGICAL_STREAM_TYPE_SUBJECT_GRAPHS: LogicalStreamType
36
+ LOGICAL_STREAM_TYPE_NAMED_GRAPHS: LogicalStreamType
37
+ LOGICAL_STREAM_TYPE_TIMESTAMPED_NAMED_GRAPHS: LogicalStreamType
38
+
39
+ class RdfIri(_message.Message):
40
+ __slots__ = ("prefix_id", "name_id")
41
+ PREFIX_ID_FIELD_NUMBER: _ClassVar[int]
42
+ NAME_ID_FIELD_NUMBER: _ClassVar[int]
43
+ prefix_id: int
44
+ name_id: int
45
+ def __init__(self, prefix_id: _Optional[int] = ..., name_id: _Optional[int] = ...) -> None: ...
46
+
47
+ class RdfLiteral(_message.Message):
48
+ __slots__ = ("lex", "langtag", "datatype")
49
+ LEX_FIELD_NUMBER: _ClassVar[int]
50
+ LANGTAG_FIELD_NUMBER: _ClassVar[int]
51
+ DATATYPE_FIELD_NUMBER: _ClassVar[int]
52
+ lex: str
53
+ langtag: str
54
+ datatype: int
55
+ def __init__(self, lex: _Optional[str] = ..., langtag: _Optional[str] = ..., datatype: _Optional[int] = ...) -> None: ...
56
+
57
+ class RdfDefaultGraph(_message.Message):
58
+ __slots__ = ()
59
+ def __init__(self) -> None: ...
60
+
61
+ class RdfTriple(_message.Message):
62
+ __slots__ = ("s_iri", "s_bnode", "s_literal", "s_triple_term", "p_iri", "p_bnode", "p_literal", "p_triple_term", "o_iri", "o_bnode", "o_literal", "o_triple_term")
63
+ S_IRI_FIELD_NUMBER: _ClassVar[int]
64
+ S_BNODE_FIELD_NUMBER: _ClassVar[int]
65
+ S_LITERAL_FIELD_NUMBER: _ClassVar[int]
66
+ S_TRIPLE_TERM_FIELD_NUMBER: _ClassVar[int]
67
+ P_IRI_FIELD_NUMBER: _ClassVar[int]
68
+ P_BNODE_FIELD_NUMBER: _ClassVar[int]
69
+ P_LITERAL_FIELD_NUMBER: _ClassVar[int]
70
+ P_TRIPLE_TERM_FIELD_NUMBER: _ClassVar[int]
71
+ O_IRI_FIELD_NUMBER: _ClassVar[int]
72
+ O_BNODE_FIELD_NUMBER: _ClassVar[int]
73
+ O_LITERAL_FIELD_NUMBER: _ClassVar[int]
74
+ O_TRIPLE_TERM_FIELD_NUMBER: _ClassVar[int]
75
+ s_iri: RdfIri
76
+ s_bnode: str
77
+ s_literal: RdfLiteral
78
+ s_triple_term: RdfTriple
79
+ p_iri: RdfIri
80
+ p_bnode: str
81
+ p_literal: RdfLiteral
82
+ p_triple_term: RdfTriple
83
+ o_iri: RdfIri
84
+ o_bnode: str
85
+ o_literal: RdfLiteral
86
+ o_triple_term: RdfTriple
87
+ def __init__(self, s_iri: _Optional[_Union[RdfIri, _Mapping]] = ..., s_bnode: _Optional[str] = ..., s_literal: _Optional[_Union[RdfLiteral, _Mapping]] = ..., s_triple_term: _Optional[_Union[RdfTriple, _Mapping]] = ..., p_iri: _Optional[_Union[RdfIri, _Mapping]] = ..., p_bnode: _Optional[str] = ..., p_literal: _Optional[_Union[RdfLiteral, _Mapping]] = ..., p_triple_term: _Optional[_Union[RdfTriple, _Mapping]] = ..., o_iri: _Optional[_Union[RdfIri, _Mapping]] = ..., o_bnode: _Optional[str] = ..., o_literal: _Optional[_Union[RdfLiteral, _Mapping]] = ..., o_triple_term: _Optional[_Union[RdfTriple, _Mapping]] = ...) -> None: ...
88
+
89
+ class RdfQuad(_message.Message):
90
+ __slots__ = ("s_iri", "s_bnode", "s_literal", "s_triple_term", "p_iri", "p_bnode", "p_literal", "p_triple_term", "o_iri", "o_bnode", "o_literal", "o_triple_term", "g_iri", "g_bnode", "g_default_graph", "g_literal")
91
+ S_IRI_FIELD_NUMBER: _ClassVar[int]
92
+ S_BNODE_FIELD_NUMBER: _ClassVar[int]
93
+ S_LITERAL_FIELD_NUMBER: _ClassVar[int]
94
+ S_TRIPLE_TERM_FIELD_NUMBER: _ClassVar[int]
95
+ P_IRI_FIELD_NUMBER: _ClassVar[int]
96
+ P_BNODE_FIELD_NUMBER: _ClassVar[int]
97
+ P_LITERAL_FIELD_NUMBER: _ClassVar[int]
98
+ P_TRIPLE_TERM_FIELD_NUMBER: _ClassVar[int]
99
+ O_IRI_FIELD_NUMBER: _ClassVar[int]
100
+ O_BNODE_FIELD_NUMBER: _ClassVar[int]
101
+ O_LITERAL_FIELD_NUMBER: _ClassVar[int]
102
+ O_TRIPLE_TERM_FIELD_NUMBER: _ClassVar[int]
103
+ G_IRI_FIELD_NUMBER: _ClassVar[int]
104
+ G_BNODE_FIELD_NUMBER: _ClassVar[int]
105
+ G_DEFAULT_GRAPH_FIELD_NUMBER: _ClassVar[int]
106
+ G_LITERAL_FIELD_NUMBER: _ClassVar[int]
107
+ s_iri: RdfIri
108
+ s_bnode: str
109
+ s_literal: RdfLiteral
110
+ s_triple_term: RdfTriple
111
+ p_iri: RdfIri
112
+ p_bnode: str
113
+ p_literal: RdfLiteral
114
+ p_triple_term: RdfTriple
115
+ o_iri: RdfIri
116
+ o_bnode: str
117
+ o_literal: RdfLiteral
118
+ o_triple_term: RdfTriple
119
+ g_iri: RdfIri
120
+ g_bnode: str
121
+ g_default_graph: RdfDefaultGraph
122
+ g_literal: RdfLiteral
123
+ def __init__(self, s_iri: _Optional[_Union[RdfIri, _Mapping]] = ..., s_bnode: _Optional[str] = ..., s_literal: _Optional[_Union[RdfLiteral, _Mapping]] = ..., s_triple_term: _Optional[_Union[RdfTriple, _Mapping]] = ..., p_iri: _Optional[_Union[RdfIri, _Mapping]] = ..., p_bnode: _Optional[str] = ..., p_literal: _Optional[_Union[RdfLiteral, _Mapping]] = ..., p_triple_term: _Optional[_Union[RdfTriple, _Mapping]] = ..., o_iri: _Optional[_Union[RdfIri, _Mapping]] = ..., o_bnode: _Optional[str] = ..., o_literal: _Optional[_Union[RdfLiteral, _Mapping]] = ..., o_triple_term: _Optional[_Union[RdfTriple, _Mapping]] = ..., g_iri: _Optional[_Union[RdfIri, _Mapping]] = ..., g_bnode: _Optional[str] = ..., g_default_graph: _Optional[_Union[RdfDefaultGraph, _Mapping]] = ..., g_literal: _Optional[_Union[RdfLiteral, _Mapping]] = ...) -> None: ...
124
+
125
+ class RdfGraphStart(_message.Message):
126
+ __slots__ = ("g_iri", "g_bnode", "g_default_graph", "g_literal")
127
+ G_IRI_FIELD_NUMBER: _ClassVar[int]
128
+ G_BNODE_FIELD_NUMBER: _ClassVar[int]
129
+ G_DEFAULT_GRAPH_FIELD_NUMBER: _ClassVar[int]
130
+ G_LITERAL_FIELD_NUMBER: _ClassVar[int]
131
+ g_iri: RdfIri
132
+ g_bnode: str
133
+ g_default_graph: RdfDefaultGraph
134
+ g_literal: RdfLiteral
135
+ def __init__(self, g_iri: _Optional[_Union[RdfIri, _Mapping]] = ..., g_bnode: _Optional[str] = ..., g_default_graph: _Optional[_Union[RdfDefaultGraph, _Mapping]] = ..., g_literal: _Optional[_Union[RdfLiteral, _Mapping]] = ...) -> None: ...
136
+
137
+ class RdfGraphEnd(_message.Message):
138
+ __slots__ = ()
139
+ def __init__(self) -> None: ...
140
+
141
+ class RdfNamespaceDeclaration(_message.Message):
142
+ __slots__ = ("name", "value")
143
+ NAME_FIELD_NUMBER: _ClassVar[int]
144
+ VALUE_FIELD_NUMBER: _ClassVar[int]
145
+ name: str
146
+ value: RdfIri
147
+ def __init__(self, name: _Optional[str] = ..., value: _Optional[_Union[RdfIri, _Mapping]] = ...) -> None: ...
148
+
149
+ class RdfNameEntry(_message.Message):
150
+ __slots__ = ("id", "value")
151
+ ID_FIELD_NUMBER: _ClassVar[int]
152
+ VALUE_FIELD_NUMBER: _ClassVar[int]
153
+ id: int
154
+ value: str
155
+ def __init__(self, id: _Optional[int] = ..., value: _Optional[str] = ...) -> None: ...
156
+
157
+ class RdfPrefixEntry(_message.Message):
158
+ __slots__ = ("id", "value")
159
+ ID_FIELD_NUMBER: _ClassVar[int]
160
+ VALUE_FIELD_NUMBER: _ClassVar[int]
161
+ id: int
162
+ value: str
163
+ def __init__(self, id: _Optional[int] = ..., value: _Optional[str] = ...) -> None: ...
164
+
165
+ class RdfDatatypeEntry(_message.Message):
166
+ __slots__ = ("id", "value")
167
+ ID_FIELD_NUMBER: _ClassVar[int]
168
+ VALUE_FIELD_NUMBER: _ClassVar[int]
169
+ id: int
170
+ value: str
171
+ def __init__(self, id: _Optional[int] = ..., value: _Optional[str] = ...) -> None: ...
172
+
173
+ class RdfStreamOptions(_message.Message):
174
+ __slots__ = ("stream_name", "physical_type", "generalized_statements", "rdf_star", "max_name_table_size", "max_prefix_table_size", "max_datatype_table_size", "logical_type", "version")
175
+ STREAM_NAME_FIELD_NUMBER: _ClassVar[int]
176
+ PHYSICAL_TYPE_FIELD_NUMBER: _ClassVar[int]
177
+ GENERALIZED_STATEMENTS_FIELD_NUMBER: _ClassVar[int]
178
+ RDF_STAR_FIELD_NUMBER: _ClassVar[int]
179
+ MAX_NAME_TABLE_SIZE_FIELD_NUMBER: _ClassVar[int]
180
+ MAX_PREFIX_TABLE_SIZE_FIELD_NUMBER: _ClassVar[int]
181
+ MAX_DATATYPE_TABLE_SIZE_FIELD_NUMBER: _ClassVar[int]
182
+ LOGICAL_TYPE_FIELD_NUMBER: _ClassVar[int]
183
+ VERSION_FIELD_NUMBER: _ClassVar[int]
184
+ stream_name: str
185
+ physical_type: PhysicalStreamType
186
+ generalized_statements: bool
187
+ rdf_star: bool
188
+ max_name_table_size: int
189
+ max_prefix_table_size: int
190
+ max_datatype_table_size: int
191
+ logical_type: LogicalStreamType
192
+ version: int
193
+ def __init__(self, stream_name: _Optional[str] = ..., physical_type: _Optional[_Union[PhysicalStreamType, str]] = ..., generalized_statements: bool = ..., rdf_star: bool = ..., max_name_table_size: _Optional[int] = ..., max_prefix_table_size: _Optional[int] = ..., max_datatype_table_size: _Optional[int] = ..., logical_type: _Optional[_Union[LogicalStreamType, str]] = ..., version: _Optional[int] = ...) -> None: ...
194
+
195
+ class RdfStreamRow(_message.Message):
196
+ __slots__ = ("options", "triple", "quad", "graph_start", "graph_end", "namespace", "name", "prefix", "datatype")
197
+ OPTIONS_FIELD_NUMBER: _ClassVar[int]
198
+ TRIPLE_FIELD_NUMBER: _ClassVar[int]
199
+ QUAD_FIELD_NUMBER: _ClassVar[int]
200
+ GRAPH_START_FIELD_NUMBER: _ClassVar[int]
201
+ GRAPH_END_FIELD_NUMBER: _ClassVar[int]
202
+ NAMESPACE_FIELD_NUMBER: _ClassVar[int]
203
+ NAME_FIELD_NUMBER: _ClassVar[int]
204
+ PREFIX_FIELD_NUMBER: _ClassVar[int]
205
+ DATATYPE_FIELD_NUMBER: _ClassVar[int]
206
+ options: RdfStreamOptions
207
+ triple: RdfTriple
208
+ quad: RdfQuad
209
+ graph_start: RdfGraphStart
210
+ graph_end: RdfGraphEnd
211
+ namespace: RdfNamespaceDeclaration
212
+ name: RdfNameEntry
213
+ prefix: RdfPrefixEntry
214
+ datatype: RdfDatatypeEntry
215
+ def __init__(self, options: _Optional[_Union[RdfStreamOptions, _Mapping]] = ..., triple: _Optional[_Union[RdfTriple, _Mapping]] = ..., quad: _Optional[_Union[RdfQuad, _Mapping]] = ..., graph_start: _Optional[_Union[RdfGraphStart, _Mapping]] = ..., graph_end: _Optional[_Union[RdfGraphEnd, _Mapping]] = ..., namespace: _Optional[_Union[RdfNamespaceDeclaration, _Mapping]] = ..., name: _Optional[_Union[RdfNameEntry, _Mapping]] = ..., prefix: _Optional[_Union[RdfPrefixEntry, _Mapping]] = ..., datatype: _Optional[_Union[RdfDatatypeEntry, _Mapping]] = ...) -> None: ...
216
+
217
+ class RdfStreamFrame(_message.Message):
218
+ __slots__ = ("rows", "metadata")
219
+ class MetadataEntry(_message.Message):
220
+ __slots__ = ("key", "value")
221
+ KEY_FIELD_NUMBER: _ClassVar[int]
222
+ VALUE_FIELD_NUMBER: _ClassVar[int]
223
+ key: str
224
+ value: bytes
225
+ def __init__(self, key: _Optional[str] = ..., value: _Optional[bytes] = ...) -> None: ...
226
+ ROWS_FIELD_NUMBER: _ClassVar[int]
227
+ METADATA_FIELD_NUMBER: _ClassVar[int]
228
+ rows: _containers.RepeatedCompositeFieldContainer[RdfStreamRow]
229
+ metadata: _containers.ScalarMap[str, bytes]
230
+ def __init__(self, rows: _Optional[_Iterable[_Union[RdfStreamRow, _Mapping]]] = ..., metadata: _Optional[_Mapping[str, bytes]] = ...) -> None: ...