pyjelly 0.7.1__cp311-cp311-macosx_11_0_x86_64.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.
- cb523b6bada1c6eba8b4__mypyc.cpython-311-darwin.so +0 -0
- pyjelly/__init__.py +0 -0
- pyjelly/_proto/grpc.proto +33 -0
- pyjelly/_proto/patch.proto +165 -0
- pyjelly/_proto/rdf.proto +384 -0
- pyjelly/errors.py +10 -0
- pyjelly/integrations/__init__.py +0 -0
- pyjelly/integrations/generic/__init__.py +0 -0
- pyjelly/integrations/generic/generic_sink.py +202 -0
- pyjelly/integrations/generic/parse.py +412 -0
- pyjelly/integrations/generic/serialize.cpython-311-darwin.so +0 -0
- pyjelly/integrations/generic/serialize.py +402 -0
- pyjelly/integrations/rdflib/__init__.py +24 -0
- pyjelly/integrations/rdflib/parse.py +560 -0
- pyjelly/integrations/rdflib/serialize.py +408 -0
- pyjelly/jelly/__init__.py +5 -0
- pyjelly/jelly/rdf_pb2.py +70 -0
- pyjelly/jelly/rdf_pb2.pyi +231 -0
- pyjelly/options.py +141 -0
- pyjelly/parse/__init__.py +0 -0
- pyjelly/parse/decode.cpython-311-darwin.so +0 -0
- pyjelly/parse/decode.py +447 -0
- pyjelly/parse/ioutils.cpython-311-darwin.so +0 -0
- pyjelly/parse/ioutils.py +115 -0
- pyjelly/parse/lookup.cpython-311-darwin.so +0 -0
- pyjelly/parse/lookup.py +70 -0
- pyjelly/serialize/__init__.py +0 -0
- pyjelly/serialize/encode.cpython-311-darwin.so +0 -0
- pyjelly/serialize/encode.py +397 -0
- pyjelly/serialize/flows.py +196 -0
- pyjelly/serialize/ioutils.cpython-311-darwin.so +0 -0
- pyjelly/serialize/ioutils.py +13 -0
- pyjelly/serialize/lookup.cpython-311-darwin.so +0 -0
- pyjelly/serialize/lookup.py +137 -0
- pyjelly/serialize/streams.cpython-311-darwin.so +0 -0
- pyjelly/serialize/streams.py +281 -0
- pyjelly-0.7.1.dist-info/METADATA +114 -0
- pyjelly-0.7.1.dist-info/RECORD +41 -0
- pyjelly-0.7.1.dist-info/WHEEL +6 -0
- pyjelly-0.7.1.dist-info/entry_points.txt +7 -0
- pyjelly-0.7.1.dist-info/licenses/LICENSE +201 -0
|
Binary file
|
pyjelly/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package eu.ostrzyciel.jelly.core.proto.v1;
|
|
3
|
+
|
|
4
|
+
// Jelly gRPC streaming protocol.
|
|
5
|
+
// Specification document: https://w3id.org/jelly/1.0.0/specification/streaming
|
|
6
|
+
// Protocol version: 1.0.0
|
|
7
|
+
|
|
8
|
+
import "rdf.proto";
|
|
9
|
+
|
|
10
|
+
// Subscribe command sent by the client to the server.
|
|
11
|
+
message RdfStreamSubscribe {
|
|
12
|
+
// The topic to which the client wants to subscribe (UTF-8 encoded).
|
|
13
|
+
string topic = 1;
|
|
14
|
+
// Optional: the stream options requested by the client.
|
|
15
|
+
// The server should respond with a stream that matches these options.
|
|
16
|
+
// In case that is not possible, the server must respond with the
|
|
17
|
+
// INVALID_ARGUMENT error.
|
|
18
|
+
RdfStreamOptions requested_options = 2;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Acknowledgement of receiving a stream sent by the server to the client.
|
|
22
|
+
message RdfStreamReceived {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Pub/Sub service for RDF streams, to be implemented by the server.
|
|
26
|
+
service RdfStreamService {
|
|
27
|
+
// Subscribe to an RDF stream.
|
|
28
|
+
rpc SubscribeRdf (RdfStreamSubscribe) returns (stream RdfStreamFrame);
|
|
29
|
+
// Publish an RDF stream.
|
|
30
|
+
// In case the server cannot process the stream, it must respond with
|
|
31
|
+
// the INVALID_ARGUMENT error.
|
|
32
|
+
rpc PublishRdf (stream RdfStreamFrame) returns (RdfStreamReceived);
|
|
33
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package eu.ostrzyciel.jelly.core.proto.v1.patch;
|
|
3
|
+
|
|
4
|
+
// EXPERIMENTAL FEATURE -- the API and format may change.
|
|
5
|
+
|
|
6
|
+
// RDF Patch implementation based on Jelly
|
|
7
|
+
// RDF Patch spec: https://afs.github.io/rdf-delta/rdf-patch.html
|
|
8
|
+
// Jelly-Patch spec: https://w3id.org/jelly/1.1.0/specification/patch
|
|
9
|
+
|
|
10
|
+
import "rdf.proto";
|
|
11
|
+
|
|
12
|
+
message RdfPatchTransactionStart {
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
message RdfPatchTransactionCommit {
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
message RdfPatchTransactionAbort {
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
message RdfPatchNamespace {
|
|
22
|
+
// Short name of the namespace (e.g., "ex")
|
|
23
|
+
// Do NOT include the colon.
|
|
24
|
+
string name = 1;
|
|
25
|
+
// IRI of the namespace (e.g., "http://example.org/").
|
|
26
|
+
// Optional in the "prefix delete" (PD) operation,
|
|
27
|
+
// but required in the "prefix add" (PA) operation.
|
|
28
|
+
RdfIri value = 2;
|
|
29
|
+
// Graph name for the namespace declaration.
|
|
30
|
+
//
|
|
31
|
+
// This is required for the statement type QUADS, and disallowed for
|
|
32
|
+
// the statement type TRIPLES.
|
|
33
|
+
//
|
|
34
|
+
// This is used to achieve full 1:1 replication in systems that associate
|
|
35
|
+
// namespaces with specific graphs (e.g., Apache Jena).
|
|
36
|
+
//
|
|
37
|
+
// Repeated term compression IS supported for this field.
|
|
38
|
+
// The repeated terms are shared between the namespace and statement rows.
|
|
39
|
+
oneof graph {
|
|
40
|
+
// IRI
|
|
41
|
+
RdfIri g_iri = 3;
|
|
42
|
+
// Blank node
|
|
43
|
+
string g_bnode = 4;
|
|
44
|
+
// Default graph
|
|
45
|
+
RdfDefaultGraph g_default_graph = 5;
|
|
46
|
+
// Literal – only valid for generalized RDF streams
|
|
47
|
+
RdfLiteral g_literal = 6;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Metadata header for RDF Patch.
|
|
52
|
+
// Header rows must occur at the start of the patch frame.
|
|
53
|
+
message RdfPatchHeader {
|
|
54
|
+
// Header key (required)
|
|
55
|
+
string key = 1;
|
|
56
|
+
// Header value (required)
|
|
57
|
+
// Repeated term compression is not supported for header values.
|
|
58
|
+
// This oneof must always be set to a valid RDF term.
|
|
59
|
+
oneof value {
|
|
60
|
+
// IRI
|
|
61
|
+
RdfIri h_iri = 2;
|
|
62
|
+
// Blank node
|
|
63
|
+
string h_bnode = 3;
|
|
64
|
+
// Literal
|
|
65
|
+
RdfLiteral h_literal = 4;
|
|
66
|
+
// RDF-star quoted triple
|
|
67
|
+
RdfTriple h_triple_term = 5;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
message RdfPatchPunctuation {
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// RDF Patch stream options
|
|
75
|
+
message RdfPatchOptions {
|
|
76
|
+
// Type of statements in the stream (required)
|
|
77
|
+
PatchStatementType statement_type = 1;
|
|
78
|
+
// Type of the stream (required)
|
|
79
|
+
PatchStreamType stream_type = 2;
|
|
80
|
+
// Whether the stream may contain generalized triples, quads, or datasets
|
|
81
|
+
bool generalized_statements = 3;
|
|
82
|
+
// Whether the stream may contain RDF-star statements
|
|
83
|
+
bool rdf_star = 4;
|
|
84
|
+
// Maximum size of the name lookup table
|
|
85
|
+
// (required, must be >= 8)
|
|
86
|
+
uint32 max_name_table_size = 9;
|
|
87
|
+
// Maximum size of the prefix lookup table
|
|
88
|
+
// (required if the prefix lookup is used)
|
|
89
|
+
uint32 max_prefix_table_size = 10;
|
|
90
|
+
// Maximum size of the datatype lookup table
|
|
91
|
+
// (required if datatype literals are used)
|
|
92
|
+
uint32 max_datatype_table_size = 11;
|
|
93
|
+
// Protocol version (required)
|
|
94
|
+
// For Jelly-Patch 1.0.x (based on Jelly-RDF 1.1.x), the value must be 1.
|
|
95
|
+
// For custom extensions, the value must be 10000 or higher.
|
|
96
|
+
uint32 version = 15;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Type of statements in the stream.
|
|
100
|
+
// This determines whether the statements are interpreted as triples or quads.
|
|
101
|
+
enum PatchStatementType {
|
|
102
|
+
// Unspecified stream type – invalid
|
|
103
|
+
PATCH_STATEMENT_TYPE_UNSPECIFIED = 0;
|
|
104
|
+
// RDF triples
|
|
105
|
+
PATCH_STATEMENT_TYPE_TRIPLES = 1;
|
|
106
|
+
// RDF quads
|
|
107
|
+
PATCH_STATEMENT_TYPE_QUADS = 2;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Type of the stream.
|
|
111
|
+
// This determines whether each RdfPatchFrame is a complete patch by itself,
|
|
112
|
+
// or part of a larger patch.
|
|
113
|
+
enum PatchStreamType {
|
|
114
|
+
// Unspecified stream type – invalid
|
|
115
|
+
PATCH_STREAM_TYPE_UNSPECIFIED = 0;
|
|
116
|
+
// Each RdfPatchFrame is a complete patch.
|
|
117
|
+
// In this case, transactions cannot span multiple frames.
|
|
118
|
+
PATCH_STREAM_TYPE_FRAME = 1;
|
|
119
|
+
// Entire stream is a single patch.
|
|
120
|
+
// Transactions may span multiple frames.
|
|
121
|
+
PATCH_STREAM_TYPE_FLAT = 2;
|
|
122
|
+
// Stream contains multiple patches separated by punctuation marks.
|
|
123
|
+
// Patches and transactions may span multiple frames.
|
|
124
|
+
// Each frame must contain at most one patch.
|
|
125
|
+
PATCH_STREAM_TYPE_PUNCTUATED = 3;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// A row in an RDF Patch stream
|
|
129
|
+
message RdfPatchRow {
|
|
130
|
+
oneof row {
|
|
131
|
+
// Stream options. Must be the first row in the stream.
|
|
132
|
+
RdfPatchOptions options = 1;
|
|
133
|
+
// Add a triple/quad statement (A)
|
|
134
|
+
RdfQuad statement_add = 2;
|
|
135
|
+
// Delete a triple/quad statement (D)
|
|
136
|
+
RdfQuad statement_delete = 3;
|
|
137
|
+
// Add a namespace/prefix declaration (PA)
|
|
138
|
+
RdfPatchNamespace namespace_add = 4;
|
|
139
|
+
// Delete a namespace/prefix declaration (PD)
|
|
140
|
+
RdfPatchNamespace namespace_delete = 5;
|
|
141
|
+
// Transaction start (TX)
|
|
142
|
+
RdfPatchTransactionStart transaction_start = 6;
|
|
143
|
+
// Transaction commit (TC)
|
|
144
|
+
RdfPatchTransactionCommit transaction_commit = 7;
|
|
145
|
+
// Transaction abort (TA)
|
|
146
|
+
RdfPatchTransactionAbort transaction_abort = 8;
|
|
147
|
+
// Entry in the name lookup table.
|
|
148
|
+
RdfNameEntry name = 11;
|
|
149
|
+
// Entry in the prefix lookup table.
|
|
150
|
+
RdfPrefixEntry prefix = 12;
|
|
151
|
+
// Entry in the datatype lookup table.
|
|
152
|
+
RdfDatatypeEntry datatype = 13;
|
|
153
|
+
// Header entry (H)
|
|
154
|
+
RdfPatchHeader header = 14;
|
|
155
|
+
// Punctuation mark, only used in stream type PUNCTUATED
|
|
156
|
+
// Indicates the end of a patch.
|
|
157
|
+
RdfPatchPunctuation punctuation = 15;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// A batch of RDF patch rows.
|
|
162
|
+
message RdfPatchFrame {
|
|
163
|
+
// Patch rows
|
|
164
|
+
repeated RdfPatchRow rows = 1;
|
|
165
|
+
}
|
pyjelly/_proto/rdf.proto
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package eu.ostrzyciel.jelly.core.proto.v1;
|
|
3
|
+
|
|
4
|
+
// Jelly RDF serialization with Protocol Buffers.
|
|
5
|
+
// Specification document:
|
|
6
|
+
// https://w3id.org/jelly/1.1.1/specification/serialization
|
|
7
|
+
// Protocol version: 1.1.1
|
|
8
|
+
|
|
9
|
+
// RDF IRIs
|
|
10
|
+
// The IRIs are reconstructed by the consumer using the prefix and name
|
|
11
|
+
// lookup tables.
|
|
12
|
+
message RdfIri {
|
|
13
|
+
// 1-based, refers to an entry in the prefix lookup.
|
|
14
|
+
//
|
|
15
|
+
// 0 signifies "use the same prefix_id as in the previous IRI".
|
|
16
|
+
// For this to work, IRIs must be processed strictly in order: firstly by
|
|
17
|
+
// stream row, then by term (subject, predicate, object, graph). This also
|
|
18
|
+
// applies recursively to RDF-star quoted triples.
|
|
19
|
+
//
|
|
20
|
+
// If 0 appears in the first IRI of the stream (and in any subsequent IRI),
|
|
21
|
+
// this should be interpreted as an empty ("") prefix. This is for example
|
|
22
|
+
// used when the prefix lookup table is disabled.
|
|
23
|
+
uint32 prefix_id = 1;
|
|
24
|
+
|
|
25
|
+
// 1-based, refers to an entry in the name lookup.
|
|
26
|
+
//
|
|
27
|
+
// 0 signifies "use the previous name_id + 1". This requires the same order
|
|
28
|
+
// guarantees as prefixes.
|
|
29
|
+
//
|
|
30
|
+
// If 0 appears in the first IRI of the stream, it should be interpreted as
|
|
31
|
+
// name_id = 1.
|
|
32
|
+
uint32 name_id = 2;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// RDF literals
|
|
36
|
+
message RdfLiteral {
|
|
37
|
+
// The lexical form of the literal (required).
|
|
38
|
+
string lex = 1;
|
|
39
|
+
|
|
40
|
+
// Literal kind – at most one of these field may be set.
|
|
41
|
+
// If none is set, then it's a simple literal.
|
|
42
|
+
oneof literalKind {
|
|
43
|
+
// Language-tagged string.
|
|
44
|
+
string langtag = 2;
|
|
45
|
+
// Typed literal. The datatype is a reference to an entry in the
|
|
46
|
+
// datatype lookup. This value is 1-based and the value of 0
|
|
47
|
+
// is invalid (in contrast to prefix_id and name_id in RdfIri).
|
|
48
|
+
uint32 datatype = 3;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Empty message indicating the default RDF graph.
|
|
53
|
+
message RdfDefaultGraph {
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// RDF triple
|
|
57
|
+
//
|
|
58
|
+
// For each term (subject, predicate, object), the fields are repeated for
|
|
59
|
+
// performance reasons. This is to avoid the need for boxing each term in a
|
|
60
|
+
// separate message.
|
|
61
|
+
//
|
|
62
|
+
// Note: this message allows for representing generalized RDF triples (for
|
|
63
|
+
// example, with literals as predicates). Whether this is used in the stream
|
|
64
|
+
// is determined by the stream options (see RdfStreamOptions).
|
|
65
|
+
//
|
|
66
|
+
// If no field in a given oneof is set, the term is interpreted as a repeated
|
|
67
|
+
// term – the same as the term in the same position in the previous triple.
|
|
68
|
+
// In the first triple of the stream, all terms must be set.
|
|
69
|
+
// All terms must also be set in quoted triples (RDF-star).
|
|
70
|
+
message RdfTriple {
|
|
71
|
+
// Triple subject
|
|
72
|
+
oneof subject {
|
|
73
|
+
// IRI
|
|
74
|
+
RdfIri s_iri = 1;
|
|
75
|
+
// Blank node
|
|
76
|
+
string s_bnode = 2;
|
|
77
|
+
// Literal
|
|
78
|
+
// Only valid in a generalized RDF stream.
|
|
79
|
+
RdfLiteral s_literal = 3;
|
|
80
|
+
// RDF-star quoted triple
|
|
81
|
+
RdfTriple s_triple_term = 4;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Triple predicate
|
|
85
|
+
oneof predicate {
|
|
86
|
+
// IRI
|
|
87
|
+
RdfIri p_iri = 5;
|
|
88
|
+
// Blank node
|
|
89
|
+
// Only valid in a generalized RDF stream.
|
|
90
|
+
string p_bnode = 6;
|
|
91
|
+
// Literal
|
|
92
|
+
// Only valid in a generalized RDF stream.
|
|
93
|
+
RdfLiteral p_literal = 7;
|
|
94
|
+
// RDF-star quoted triple
|
|
95
|
+
RdfTriple p_triple_term = 8;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Triple object
|
|
99
|
+
oneof object {
|
|
100
|
+
// IRI
|
|
101
|
+
RdfIri o_iri = 9;
|
|
102
|
+
// Blank node
|
|
103
|
+
string o_bnode = 10;
|
|
104
|
+
// Literal
|
|
105
|
+
RdfLiteral o_literal = 11;
|
|
106
|
+
// RDF-star quoted triple
|
|
107
|
+
RdfTriple o_triple_term = 12;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// RDF quad
|
|
112
|
+
//
|
|
113
|
+
// Fields 1–12 are repeated from RdfTriple for performance reasons.
|
|
114
|
+
//
|
|
115
|
+
// Similarly to RdfTriple, this message allows for representing generalized
|
|
116
|
+
// RDF quads (for example, with literals as predicates). Whether this is used
|
|
117
|
+
// in the stream is determined by the stream options (see RdfStreamOptions).
|
|
118
|
+
//
|
|
119
|
+
// If no field in a given oneof is set, the term is interpreted as a repeated
|
|
120
|
+
// term – the same as the term in the same position in the previous quad.
|
|
121
|
+
// In the first quad of the stream, all terms must be set.
|
|
122
|
+
message RdfQuad {
|
|
123
|
+
// Quad subject
|
|
124
|
+
oneof subject {
|
|
125
|
+
// IRI
|
|
126
|
+
RdfIri s_iri = 1;
|
|
127
|
+
// Blank node
|
|
128
|
+
string s_bnode = 2;
|
|
129
|
+
// Literal
|
|
130
|
+
// Only valid in a generalized RDF stream.
|
|
131
|
+
RdfLiteral s_literal = 3;
|
|
132
|
+
// RDF-star quoted triple
|
|
133
|
+
RdfTriple s_triple_term = 4;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Quad predicate
|
|
137
|
+
oneof predicate {
|
|
138
|
+
// IRI
|
|
139
|
+
RdfIri p_iri = 5;
|
|
140
|
+
// Blank node
|
|
141
|
+
// Only valid in a generalized RDF stream.
|
|
142
|
+
string p_bnode = 6;
|
|
143
|
+
// Literal
|
|
144
|
+
// Only valid in a generalized RDF stream.
|
|
145
|
+
RdfLiteral p_literal = 7;
|
|
146
|
+
// RDF-star quoted triple
|
|
147
|
+
RdfTriple p_triple_term = 8;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Quad object
|
|
151
|
+
oneof object {
|
|
152
|
+
// IRI
|
|
153
|
+
RdfIri o_iri = 9;
|
|
154
|
+
// Blank node
|
|
155
|
+
string o_bnode = 10;
|
|
156
|
+
// Literal
|
|
157
|
+
RdfLiteral o_literal = 11;
|
|
158
|
+
// RDF-star quoted triple
|
|
159
|
+
RdfTriple o_triple_term = 12;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Quad graph
|
|
163
|
+
oneof graph {
|
|
164
|
+
// IRI
|
|
165
|
+
RdfIri g_iri = 13;
|
|
166
|
+
// Blank node
|
|
167
|
+
string g_bnode = 14;
|
|
168
|
+
// Default graph
|
|
169
|
+
RdfDefaultGraph g_default_graph = 15;
|
|
170
|
+
// Literal – only valid for generalized RDF streams
|
|
171
|
+
RdfLiteral g_literal = 16;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Start of a graph in a GRAPHS stream
|
|
176
|
+
//
|
|
177
|
+
// In contrast to RdfQuad, setting the graph oneof to some value
|
|
178
|
+
// is always required. No repeated terms are allowed.
|
|
179
|
+
message RdfGraphStart {
|
|
180
|
+
oneof graph {
|
|
181
|
+
// IRI
|
|
182
|
+
RdfIri g_iri = 1;
|
|
183
|
+
// Blank node
|
|
184
|
+
string g_bnode = 2;
|
|
185
|
+
// Default graph
|
|
186
|
+
RdfDefaultGraph g_default_graph = 3;
|
|
187
|
+
// Literal – only valid for generalized RDF streams
|
|
188
|
+
RdfLiteral g_literal = 4;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// End of a graph in a GRAPHS stream
|
|
193
|
+
message RdfGraphEnd {
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Explicit namespace declaration
|
|
197
|
+
//
|
|
198
|
+
// This does not correspond to any construct in the RDF Abstract Syntax.
|
|
199
|
+
// Rather, it is a hint to the consumer that the given IRI prefix (namespace)
|
|
200
|
+
// may be associated with a shorter name, like in Turtle syntax:
|
|
201
|
+
// PREFIX ex: <http://example.org/>
|
|
202
|
+
//
|
|
203
|
+
// These short names (here "ex:") are NOT used in the RDF statement encoding.
|
|
204
|
+
// This is a purely cosmetic feature useful in cases where you want to
|
|
205
|
+
// preserve the namespace declarations from the original RDF document.
|
|
206
|
+
// These declarations have nothing in common with the prefix lookup table.
|
|
207
|
+
message RdfNamespaceDeclaration {
|
|
208
|
+
// Short name of the namespace (e.g., "ex")
|
|
209
|
+
// Do NOT include the colon.
|
|
210
|
+
string name = 1;
|
|
211
|
+
// IRI of the namespace (e.g., "http://example.org/")
|
|
212
|
+
RdfIri value = 2;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Entry in the name lookup table
|
|
216
|
+
message RdfNameEntry {
|
|
217
|
+
// 1-based identifier
|
|
218
|
+
// If id=0, it should be interpreted as previous_id + 1.
|
|
219
|
+
// If id=0 appears in the first RdfNameEntry of the stream, it should be
|
|
220
|
+
// interpreted as 1.
|
|
221
|
+
uint32 id = 1;
|
|
222
|
+
// Value of the name (UTF-8 encoded)
|
|
223
|
+
string value = 2;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Entry in the prefix lookup table
|
|
227
|
+
//
|
|
228
|
+
// Note: the prefixes in the lookup table can be arbitrary strings, and are
|
|
229
|
+
// NOT meant to be user-facing. They are only used for IRI compression.
|
|
230
|
+
// To transmit user-facing namespace declarations for cosmetic purposes, use
|
|
231
|
+
// RdfNamespaceDeclaration.
|
|
232
|
+
message RdfPrefixEntry {
|
|
233
|
+
// 1-based identifier
|
|
234
|
+
// If id=0, it should be interpreted as previous_id + 1.
|
|
235
|
+
// If id=0 appears in the first RdfPrefixEntry of the stream, it should be
|
|
236
|
+
// interpreted as 1.
|
|
237
|
+
uint32 id = 1;
|
|
238
|
+
// Value of the prefix (UTF-8 encoded)
|
|
239
|
+
string value = 2;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Entry in the datatype lookup table
|
|
243
|
+
message RdfDatatypeEntry {
|
|
244
|
+
// 1-based identifier
|
|
245
|
+
// If id=0, it should be interpreted as previous_id + 1.
|
|
246
|
+
// If id=0 appears in the first RdfDatatypeEntry of the stream, it should be
|
|
247
|
+
// interpreted as 1.
|
|
248
|
+
uint32 id = 1;
|
|
249
|
+
// Value of the datatype (UTF-8 encoded)
|
|
250
|
+
string value = 2;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// RDF stream options
|
|
254
|
+
message RdfStreamOptions {
|
|
255
|
+
// Name of the stream (completely optional).
|
|
256
|
+
// This may be used for, e.g., topic names in a pub/sub system.
|
|
257
|
+
string stream_name = 1;
|
|
258
|
+
// Type of the stream (required)
|
|
259
|
+
PhysicalStreamType physical_type = 2;
|
|
260
|
+
// Whether the stream may contain generalized triples, quads, or datasets
|
|
261
|
+
bool generalized_statements = 3;
|
|
262
|
+
// Whether the stream may contain RDF-star statements
|
|
263
|
+
bool rdf_star = 4;
|
|
264
|
+
// Maximum size of the name lookup table
|
|
265
|
+
// (required, must be >= 8)
|
|
266
|
+
uint32 max_name_table_size = 9;
|
|
267
|
+
// Maximum size of the prefix lookup table
|
|
268
|
+
// (required if the prefix lookup is used)
|
|
269
|
+
uint32 max_prefix_table_size = 10;
|
|
270
|
+
// Maximum size of the datatype lookup table
|
|
271
|
+
// (required if datatype literals are used)
|
|
272
|
+
uint32 max_datatype_table_size = 11;
|
|
273
|
+
// Logical (RDF-STaX-based) stream type
|
|
274
|
+
// In contrast to the physical type, this field is entirely optional.
|
|
275
|
+
LogicalStreamType logical_type = 14;
|
|
276
|
+
// Protocol version (required)
|
|
277
|
+
// For Jelly 1.0.x value must be 1.
|
|
278
|
+
// For Jelly 1.1.x value must be 2.
|
|
279
|
+
// For custom extensions, the value must be 10000 or higher.
|
|
280
|
+
uint32 version = 15;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Physical stream type
|
|
284
|
+
// This determines how the data is encoded in the stream, not the logical
|
|
285
|
+
// structure of the data. See LogicalStreamType for the latter.
|
|
286
|
+
enum PhysicalStreamType {
|
|
287
|
+
// Unspecified stream type – invalid
|
|
288
|
+
PHYSICAL_STREAM_TYPE_UNSPECIFIED = 0;
|
|
289
|
+
// RDF triples
|
|
290
|
+
PHYSICAL_STREAM_TYPE_TRIPLES = 1;
|
|
291
|
+
// RDF quads
|
|
292
|
+
PHYSICAL_STREAM_TYPE_QUADS = 2;
|
|
293
|
+
// RDF triples grouped in graphs
|
|
294
|
+
PHYSICAL_STREAM_TYPE_GRAPHS = 3;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Logical stream type, according to the RDF Stream Taxonomy (RDF-STaX).
|
|
298
|
+
// Type 0 is reserved for the unspecified stream type.
|
|
299
|
+
// The rest of the type numbers follow the taxonomical structure of RDF-STaX.
|
|
300
|
+
// For example: 1 is a subtype of 0, 13 and 23 are subtypes of 3,
|
|
301
|
+
// 114 is a subtype of 14, etc.
|
|
302
|
+
//
|
|
303
|
+
// Types 1–4 correspond to the four base concrete stream types. Their
|
|
304
|
+
// subtypes can be in most cases simply processed in the same way as
|
|
305
|
+
// the base types.
|
|
306
|
+
// Therefore, implementations can take the modulo 10 of the stream
|
|
307
|
+
// type to determine the base type of the stream and use this information
|
|
308
|
+
// to select the appropriate processing logic.
|
|
309
|
+
//
|
|
310
|
+
// RDF-STaX version: 1.1.2
|
|
311
|
+
// https://w3id.org/stax/1.1.2
|
|
312
|
+
//
|
|
313
|
+
// ^ The above URL is used to automatically determine the version of RDF-STaX
|
|
314
|
+
// in the Jelly protocol specification. Please keep it up-to-date and in the
|
|
315
|
+
// same format.
|
|
316
|
+
enum LogicalStreamType {
|
|
317
|
+
// Unspecified stream type – invalid
|
|
318
|
+
LOGICAL_STREAM_TYPE_UNSPECIFIED = 0;
|
|
319
|
+
// Flat RDF triple stream
|
|
320
|
+
// https://w3id.org/stax/ontology#flatTripleStream
|
|
321
|
+
LOGICAL_STREAM_TYPE_FLAT_TRIPLES = 1;
|
|
322
|
+
// Flat RDF quad stream
|
|
323
|
+
// https://w3id.org/stax/ontology#flatQuadStream
|
|
324
|
+
LOGICAL_STREAM_TYPE_FLAT_QUADS = 2;
|
|
325
|
+
// RDF graph stream
|
|
326
|
+
// https://w3id.org/stax/ontology#graphStream
|
|
327
|
+
LOGICAL_STREAM_TYPE_GRAPHS = 3;
|
|
328
|
+
// RDF dataset stream
|
|
329
|
+
// https://w3id.org/stax/ontology#datasetStream
|
|
330
|
+
LOGICAL_STREAM_TYPE_DATASETS = 4;
|
|
331
|
+
|
|
332
|
+
// RDF subject graph stream (subtype of RDF graph stream)
|
|
333
|
+
// https://w3id.org/stax/ontology#subjectGraphStream
|
|
334
|
+
LOGICAL_STREAM_TYPE_SUBJECT_GRAPHS = 13;
|
|
335
|
+
|
|
336
|
+
// RDF named graph stream (subtype of RDF dataset stream)
|
|
337
|
+
// https://w3id.org/stax/ontology#namedGraphStream
|
|
338
|
+
LOGICAL_STREAM_TYPE_NAMED_GRAPHS = 14;
|
|
339
|
+
// RDF timestamped named graph stream (subtype of RDF dataset stream)
|
|
340
|
+
// https://w3id.org/stax/ontology#timestampedNamedGraphStream
|
|
341
|
+
LOGICAL_STREAM_TYPE_TIMESTAMPED_NAMED_GRAPHS = 114;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// RDF stream row
|
|
345
|
+
message RdfStreamRow {
|
|
346
|
+
// Exactly one of these fields must be set.
|
|
347
|
+
oneof row {
|
|
348
|
+
// Stream options. Must occur at the start of the stream.
|
|
349
|
+
RdfStreamOptions options = 1;
|
|
350
|
+
// RDF triple statement.
|
|
351
|
+
// Valid in streams of physical type TRIPLES or GRAPHS.
|
|
352
|
+
RdfTriple triple = 2;
|
|
353
|
+
// RDF quad statement.
|
|
354
|
+
// Only valid in streams of physical type QUADS.
|
|
355
|
+
RdfQuad quad = 3;
|
|
356
|
+
// Graph boundary: ends the currently transmitted graph and starts a new one
|
|
357
|
+
// Only valid in streams of physical type GRAPHS.
|
|
358
|
+
RdfGraphStart graph_start = 4;
|
|
359
|
+
// Explicit end of a graph.
|
|
360
|
+
// Signals the consumer that the transmitted graph is complete.
|
|
361
|
+
// Only valid in streams of physical type GRAPHS.
|
|
362
|
+
RdfGraphEnd graph_end = 5;
|
|
363
|
+
// Explicit namespace declaration.
|
|
364
|
+
RdfNamespaceDeclaration namespace = 6;
|
|
365
|
+
// Entry in the name lookup table.
|
|
366
|
+
RdfNameEntry name = 9;
|
|
367
|
+
// Entry in the prefix lookup table.
|
|
368
|
+
RdfPrefixEntry prefix = 10;
|
|
369
|
+
// Entry in the datatype lookup table.
|
|
370
|
+
RdfDatatypeEntry datatype = 11;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// RDF stream frame – base message for RDF streams.
|
|
375
|
+
message RdfStreamFrame {
|
|
376
|
+
// Stream rows
|
|
377
|
+
repeated RdfStreamRow rows = 1;
|
|
378
|
+
// Arbitrary metadata
|
|
379
|
+
// The keys are UTF-8 encoded strings, the values are byte arrays.
|
|
380
|
+
// This may be used by implementations in any way they see fit.
|
|
381
|
+
// The metadata does not affect the RDF data in any way, treat it
|
|
382
|
+
// as comments in a text file.
|
|
383
|
+
map<string, bytes> metadata = 15;
|
|
384
|
+
}
|
pyjelly/errors.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class JellyConformanceError(Exception):
|
|
2
|
+
"""Raised when Jelly conformance is violated."""
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class JellyAssertionError(AssertionError):
|
|
6
|
+
"""Raised when a recommended assertion from the specification fails."""
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class JellyNotImplementedError(NotImplementedError):
|
|
10
|
+
"""Raised when a future feature is not yet implemented."""
|
|
File without changes
|
|
File without changes
|