Skip to content

Commit 14a9392

Browse files
Update protocol with ConceptMap -> AnswerRow
1 parent cd505da commit 14a9392

File tree

6 files changed

+69
-38
lines changed

6 files changed

+69
-38
lines changed

proto/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ proto_library(
7474
],
7575
)
7676

77-
7877
proto_library(
7978
name = "transaction-proto",
8079
srcs = ["transaction.proto"],

proto/answer.proto

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,31 @@ import "proto/concept.proto";
88

99
package typedb.protocol;
1010

11-
message ConceptMap {
12-
map<string, Concept> map = 1;
11+
message AnswerRow {
12+
repeated Answer row = 1;
1313
// Explainables explainables = 2;
1414
}
15+
16+
message Answer {
17+
oneof answer {
18+
Empty empty = 1;
19+
Concept concept = 2;
20+
Value value = 3;
21+
ConceptList concept_list = 4;
22+
ValueList value_list = 5;
23+
}
24+
25+
message Empty {}
26+
27+
message ConceptList {
28+
repeated Concept concepts = 1;
29+
}
30+
31+
message ValueList {
32+
repeated Value values = 1;
33+
}
34+
}
35+
1536
//
1637
//message Explainables {
1738
// map<string, Explainable> relations = 1;

proto/concept.proto

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ message Concept {
1616
Entity entity = 5;
1717
Relation relation = 6;
1818
Attribute attribute = 7;
19-
20-
Value value = 8;
2119
}
2220
}
2321

@@ -31,17 +29,23 @@ message Thing {
3129

3230
message Entity {
3331
bytes iid = 1;
34-
EntityType entity_type = 2; // TODO: not sure we should include types by default, since now they can get quite large with annotations included in every single response!
32+
// TODO: not sure we should include types by default, since now they can get quite large with annotations included in every single response!
33+
// perhaps it's a query option?
34+
optional EntityType entity_type = 2;
3535
}
3636

3737
message Relation {
3838
bytes iid = 1;
39-
RelationType relation_type = 2; // TODO: not sure we should include types by default, since now they can get quite large with annotations included in every single response!
39+
// TODO: not sure we should include types by default, since now they can get quite large with annotations included in every single response!
40+
// perhaps it's a query option?
41+
optional RelationType relation_type = 2;
4042
}
4143

4244
message Attribute {
4345
bytes iid = 1;
44-
AttributeType attribute_type = 2; // TODO: not sure we should include types by default, since now they can get quite large with annotations included in every single response!
46+
// TODO: not sure we should include types by default, since now they can get quite large with annotations included in every single response!
47+
// perhaps it's a query option?
48+
optional AttributeType attribute_type = 2;
4549
Value value = 3;
4650
}
4751

@@ -105,7 +109,7 @@ message Type {
105109
}
106110

107111
message RoleType {
108-
string label = 1;
112+
string name = 1;
109113
string scope = 2;
110114
repeated Annotation annotations = 3;
111115
}
@@ -122,7 +126,7 @@ message RelationType {
122126

123127
message AttributeType {
124128
string label = 1;
125-
ValueType value_type = 2;
129+
optional ValueType value_type = 2;
126130
repeated Annotation annotations = 3;
127131
}
128132

@@ -134,8 +138,8 @@ message ValueType {
134138
Decimal decimal = 4;
135139
String string = 5;
136140
Date date = 6;
137-
Datetime datetime = 7;
138-
Datetime_TZ datetime_tz = 8;
141+
DateTime datetime = 7;
142+
DateTime_TZ datetime_tz = 8;
139143
Duration duration = 9;
140144
Struct struct = 10;
141145
}
@@ -145,8 +149,8 @@ message ValueType {
145149
message Decimal {};
146150
message String {};
147151
message Date {};
148-
message Datetime {};
149-
message Datetime_TZ {};
152+
message DateTime {};
153+
message DateTime_TZ {};
150154
message Duration {};
151155
message Struct {
152156
string name = 1;

proto/logic.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ message Rule {
9494
message Explanation {
9595
Rule rule = 1;
9696
map<string, VarList> var_mapping = 2;
97-
ConceptMap condition = 3;
98-
ConceptMap conclusion = 4;
97+
AnswerRow condition = 3;
98+
AnswerRow conclusion = 4;
9999

100100
message VarList {
101101
repeated string vars = 1;

proto/query.proto

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
syntax = "proto3";
66

77
import "proto/answer.proto";
8-
//import "proto/logic.proto";
98
import "proto/options.proto";
109
import "proto/concept.proto";
1110

@@ -19,15 +18,17 @@ message Query {
1918
}
2019

2120
message Res {
22-
Error error = 1;
23-
Ok ok = 2;
21+
oneof res {
22+
Error error = 1;
23+
Ok ok = 2;
24+
}
2425

2526
message Ok {
2627
oneof ok {
2728
Empty empty = 1;
2829
Values values = 2;
2930
ReadableConceptTreeStream readable_concept_tree_stream = 3;
30-
ConceptMapStream concept_map_stream = 4;
31+
AnswerRowStream concept_map_stream = 4;
3132
}
3233

3334
message Empty {
@@ -47,8 +48,8 @@ message Query {
4748
// note: we could use this first response to record debug info, type annotations, warnings, etc
4849
}
4950

50-
message ConceptMapStream {
51-
// note: we could use this first response to record debug info, type annotations, warnings, etc
51+
message AnswerRowStream {
52+
repeated string column_variable_names = 1;
5253
}
5354
}
5455
}
@@ -58,16 +59,17 @@ message Query {
5859

5960
message Res {
6061
oneof res {
61-
Error error = 1;
6262
ReadableConceptTree tree = 2;
63-
ConceptMap concept_map = 3;
63+
AnswerRow answer_row = 3;
6464
}
6565
}
6666
}
67+
}
6768

68-
message Error {
69-
string source_code = 1;
70-
string message = 2; // TODO: stack trace?
71-
// TODO
72-
}
69+
// This is an emulation of the google ErrorDetails message. Sometimes we submit ErrorDetails via the GRPC error mechanism
70+
// and sometimes (in streams) we have to manually send errors
71+
message Error {
72+
string error_code = 1;
73+
string domain = 2;
74+
repeated string stack_trace = 3;
7375
}

proto/transaction.proto

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ message Transaction {
3030
oneof req {
3131
Open.Req open_req = 3;
3232
Query.Req query_req = 4;
33-
Stream.Req stream_req = 5;
33+
StreamSignal.Req stream_req = 5;
3434
Commit.Req commit_req = 6;
3535
Rollback.Req rollback_req = 7;
3636
Close.Req close_req = 8;
@@ -49,8 +49,10 @@ message Transaction {
4949

5050
message ResPart {
5151
bytes req_id = 1;
52-
Query.ResPart res = 2;
53-
Stream.ResPart stream_res = 4;
52+
oneof res_part {
53+
Query.ResPart query_res = 2;
54+
StreamSignal.ResPart stream_res = 3;
55+
}
5456
}
5557

5658
enum Type {
@@ -96,16 +98,19 @@ message Transaction {
9698
string message = 2;
9799
}
98100

99-
message Stream {
101+
message StreamSignal {
100102
message Req {}
101103

102104
message ResPart {
103-
State state = 1;
104-
105-
enum State {
106-
CONTINUE = 0;
107-
DONE = 1;
105+
oneof state {
106+
Continue continue = 1;
107+
Done done = 2;
108+
Error error = 3;
108109
}
110+
111+
message Continue {}
112+
113+
message Done {}
109114
}
110115
}
111116
}

0 commit comments

Comments
 (0)