Skip to content

Extend ConceptRow return with QueryStructure #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: 3.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions grpc/java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ java_grpc_library(
"//proto:logic-proto",
"//proto:options-proto",
"//proto:query-proto",
"//proto:query-structure-proto",
"//proto:transaction-proto",
"//proto:version-proto",
],
Expand Down
1 change: 1 addition & 0 deletions grpc/nodejs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ts_grpc_compile(
"//proto:logic-proto",
"//proto:options-proto",
"//proto:query-proto",
"//proto:query-structure-proto",
"//proto:transaction-proto",
"//proto:version-proto",
]
Expand Down
1 change: 1 addition & 0 deletions grpc/rust/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ rust_tonic_compile(
"//proto:logic-proto",
"//proto:options-proto",
"//proto:query-proto",
"//proto:query-structure-proto",
"//proto:transaction-proto",
"//proto:version-proto",
]
Expand Down
9 changes: 9 additions & 0 deletions proto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ proto_library(
":logic-proto",
":options-proto",
":concept-proto",
":query-structure-proto",
],
)

proto_library(
name = "query-structure-proto",
srcs = ["query-structure.proto"],
deps = [
":concept-proto",
],
)

Expand Down
67 changes: 67 additions & 0 deletions proto/query-structure.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

syntax = "proto3";

import "proto/concept.proto";

package typedb.protocol;

message QueryStructure {
map<uint64, Branch> branches = 1;

message Branch {
repeated StructureEdge constraints = 1;
}

message StructureEdge {
EdgeType edge_type = 1;
StructureVertex from = 2;
StructureVertex to = 3;
EdgeParameter param = 4;

enum EdgeType {
ISA = 0;
HAS = 1;
LINKS = 2;

SUB = 3;
OWNS = 4;
RELATES = 5;
PLAYS = 6;

FUNCTION_ARG = 7;
FUNCTION_RES = 8;

EXPR_ARG = 9;
EXPR_RESULT = 10;

COMPARATOR = 11;
}

message EdgeParameter {
oneof edge_parameter {
uint64 position = 1; // for variable role-types
string label = 3; // Constant role-types
uint64 index = 2; // Arguments & returns
}
}
}

message StructureVertex {
oneof vertex {
uint64 variable_position = 1;
string label = 2;
Value value = 3;
DerivedVertex derived = 4;
}


message DerivedVertex {
uint64 function_id = 1; // Uniquely represents the constraint in the query.
string label = 2; // Function name or full expression
repeated uint64 variable_positions = 3; // Arguments (and return values)
}
}
}
2 changes: 2 additions & 0 deletions proto/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ syntax = "proto3";
import "proto/answer.proto";
import "proto/options.proto";
import "proto/concept.proto";
import "proto/query-structure.proto";

package typedb.protocol;

Expand Down Expand Up @@ -51,6 +52,7 @@ message Query {
// TODO: network optimisation: replace types (== mostly constant strings) with a IDs, sending types in the header to rebuild on the client side
repeated string column_variable_names = 1;
Type query_type = 2;
QueryStructure query_structure = 3;
}
}
}
Expand Down