Skip to content
Draft
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9a6a022
WIP: Flush out QueryStructure
krishnangovindraj May 12, 2025
04fad54
Add kind, links can have multiple role-players
krishnangovindraj May 12, 2025
71bf044
Add query-structure into header & provenance into row
krishnangovindraj May 12, 2025
7b606d8
Update BUILD files
krishnangovindraj May 12, 2025
97e193b
Fix build files
krishnangovindraj May 12, 2025
2396bab
Add constraint span
krishnangovindraj May 12, 2025
9f9bd41
Add exactness to Isa, Sub and other speculatively
krishnangovindraj May 12, 2025
b10129f
Fix label to be a concept
krishnangovindraj May 12, 2025
8b77d2a
Fix value to be oneof
krishnangovindraj May 12, 2025
315168e
Fix owns field names
krishnangovindraj May 12, 2025
e7160ba
Make expression assigned repeated for future-proofing
krishnangovindraj May 12, 2025
aee5da4
Extend QueryVariable to possibly be unavailable
krishnangovindraj May 12, 2025
7de1479
Some minor renaming
krishnangovindraj May 12, 2025
1d00ae0
Add span for each role-player
krishnangovindraj May 13, 2025
0eaf900
Flatten links roleplayers
krishnangovindraj May 13, 2025
0a5eb80
Reflect naming
krishnangovindraj May 16, 2025
b912759
Make labels only accept type
krishnangovindraj May 16, 2025
0586271
Reflect renaming again
krishnangovindraj May 19, 2025
cff738f
Remove query structure from ConceptRowStream, making it currently unused
krishnangovindraj Sep 12, 2025
c8b975a
Try filling in analyze proto
krishnangovindraj Sep 12, 2025
b197dc2
Do I have to add it to the filegroup?
krishnangovindraj Sep 15, 2025
98ba00c
Rename Constraint to structureConstraint for consistency
krishnangovindraj Sep 15, 2025
e7b9671
And one for the build.rs
krishnangovindraj Sep 15, 2025
e8f9bc3
Add constraint nested patterns + sort direction
krishnangovindraj Sep 15, 2025
1a3bbee
Rename inner to conjunction
krishnangovindraj Sep 15, 2025
90e977e
Rename Disjunction -> or etc for consistency
krishnangovindraj Sep 15, 2025
373db61
Make StructureVertex Label support unresolved labels
krishnangovindraj Sep 22, 2025
7b77360
Forgot oneoef
krishnangovindraj Sep 22, 2025
a2cd43a
Introduce Analyze req & res into transaction rpc
krishnangovindraj Sep 24, 2025
c9b4bf5
Variables deserve their own message
krishnangovindraj Sep 24, 2025
3fb64f1
Oopsies. I forgot about annotations
krishnangovindraj Sep 24, 2025
f59677e
Forgot the fields in res
krishnangovindraj Sep 24, 2025
ec84d80
Make return reducer field plural
krishnangovindraj Sep 24, 2025
e185176
Add kind & label constraints; comparator
krishnangovindraj Sep 24, 2025
574bc32
Rename Value(Constraint)::type -> attribute_type
krishnangovindraj Sep 24, 2025
9fba4c5
Rename Iid field: var -> concenpt
krishnangovindraj Sep 24, 2025
daa9860
Fix build
krishnangovindraj Sep 29, 2025
a3cd5d5
WIP: Add conjunction annotations; next fetch
krishnangovindraj Sep 29, 2025
6729f15
Add fetch annotations
krishnangovindraj Sep 29, 2025
f731396
Add function annotations & update
krishnangovindraj Oct 2, 2025
a3e548f
Add returns_stream to function annotations
krishnangovindraj Oct 2, 2025
9f0f388
Fix function annotations
krishnangovindraj Oct 2, 2025
4d51f8f
Support Thing & Type
krishnangovindraj Oct 2, 2025
a45dc23
Bad field name in ConceptVariableAnnotations
krishnangovindraj Oct 2, 2025
8e7077e
Oopsies. Do analyze errors properly
krishnangovindraj Oct 2, 2025
8095df4
Remove TOOD
krishnangovindraj Oct 6, 2025
ba56e09
Rename Label.label::(failedInference to unresolved)
krishnangovindraj Oct 6, 2025
deae655
Move StructureVertex::Label::unresolved to a new Label::NamedRole var…
krishnangovindraj Oct 6, 2025
bf98739
Add unresolved as a variant in vertex
krishnangovindraj Oct 6, 2025
f2aa192
Rename conjunction.proto to structure.proto
krishnangovindraj Oct 9, 2025
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
2 changes: 2 additions & 0 deletions grpc/java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ java_grpc_library(
"//proto:options-proto",
"//proto:query-proto",
"//proto:transaction-proto",
"//proto:analyze-proto",
"//proto:conjunction-proto",
"//proto:version-proto",
],
# TypeDB Core bundles JARs by maven coordinate, we can remove this when Core is rewritten in Rust
Expand Down
2 changes: 2 additions & 0 deletions grpc/nodejs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ ts_grpc_compile(
"//proto:options-proto",
"//proto:query-proto",
"//proto:transaction-proto",
"//proto:analyze-proto",
"//proto:conjunction-proto",
"//proto:version-proto",
]
)
Expand Down
2 changes: 2 additions & 0 deletions grpc/rust/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ rust_tonic_compile(
"//proto:options-proto",
"//proto:query-proto",
"//proto:transaction-proto",
"//proto:analyze-proto",
"//proto:conjunction-proto",
"//proto:version-proto",
]
)
Expand Down
2 changes: 2 additions & 0 deletions grpc/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

fn main() -> std::io::Result<()> {
let protos = vec![
"../../proto/analyze.proto",
"../../proto/answer.proto",
"../../proto/authentication.proto",
"../../proto/concept.proto",
"../../proto/connection.proto",
"../../proto/conjunction.proto",
"../../proto/database.proto",
"../../proto/error.proto",
"../../proto/migration.proto",
Expand Down
19 changes: 19 additions & 0 deletions proto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ proto_library(
]
)

proto_library(
name = "analyze-proto",
srcs = ["analyze.proto"],
deps = [
":conjunction-proto",
],
)

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

proto_library(
name = "version-proto",
srcs = ["version.proto"],
Expand All @@ -114,9 +131,11 @@ proto_library(
filegroup(
name = "proto-raw-buffers",
srcs = [
"analyze.proto",
"answer.proto",
"concept.proto",
"connection.proto",
"conjunction.proto",
"options.proto",
"query.proto",
"transaction.proto",
Expand Down
129 changes: 129 additions & 0 deletions proto/analyze.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// 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/conjunction.proto";

package typedb.protocol;

message Analyze {

message Req {
string query = 1;
}

message Res {
PipelineStructure query = 1;
repeated FunctionStructure preamble = 2;

message FunctionStructure {
PipelineStructure body = 1;
repeated uint32 arguments = 2;
oneof returns {// TODO: Does this need to be flattened up?
ReturnOpStream stream = 3;
ReturnOpSingle single = 4;
ReturnOpCheck check = 5;
ReturnOpReduce reduce = 6;
};

message ReturnOpStream {
repeated uint32 variables = 1;
}
message ReturnOpSingle {
string selector = 1;
repeated uint32 variables = 2;
}
message ReturnOpCheck {}
message ReturnOpReduce {
repeated Reducer reducer = 1;
}
}

message PipelineStructure {
repeated ConjunctionStructure conjunctions = 1;
repeated PipelineStage stages = 2;
map<uint32, VariableInfo> variable_info = 3;
repeated uint32 outputs = 4;

message VariableInfo {
string name = 1;
}

message PipelineStage {
oneof stage {
Match match = 1;
Insert insert = 2;
Put put = 3;
Update update = 4;
Delete delete = 5;
Select select = 6;
Sort sort = 7;
Require require = 8;
Offset offset = 9;
Limit limit = 10;
Distinct distinct = 11;
Reduce reduce = 12;
}

// They're all the same structure. Should we just use one?
message Match {
uint32 block = 1;
}
message Insert {
uint32 block = 1;
}
message Put {
uint32 block = 1;
}
message Update {
uint32 block = 1;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Match, insert, put and update are just one block. They could all be represented by the message.
Should we or just keep them separate?

message Delete {
uint32 block = 1;
repeated uint32 deleted_variables = 2;
}

message Select {
repeated uint32 variables = 1;
}
message Sort {
repeated SortVariable sort_variables = 1;
message SortVariable {
uint32 variable = 1;
SortDirection direction = 2;
enum SortDirection {
ASC = 0;
DESC = 1;
}
}
}
message Require {
repeated uint32 variables = 1;
}
message Offset {
uint64 offset = 1;
}
message Limit {
uint64 limit = 1;
}
message Distinct {}
message Reduce {
repeated ReduceAssign reducers = 1;
repeated uint32 groupby = 2;

message ReduceAssign {
uint32 assigned = 1;
Reducer reducer = 2;
}
}
}
}

message Reducer {
string reducer = 1;
repeated uint32 variables = 2;
}
}
}
1 change: 1 addition & 0 deletions proto/answer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package typedb.protocol;

message ConceptRow {
repeated RowEntry row = 1;
bytes involved_blocks = 2;
}

message RowEntry {
Expand Down
154 changes: 154 additions & 0 deletions proto/conjunction.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
// 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/answer.proto";
import "proto/concept.proto";

package typedb.protocol;

message ConjunctionStructure {
repeated StructureConstraint constraints = 1;

message StructureVertex {
oneof vertex {
uint32 variable = 1;
Type label = 2;
Value value = 3;
}
}

message StructureConstraint {
ConstraintSpan span = 1;
oneof constraint {
Or or = 2;
Not not = 3;
Try try = 4;

// Thing
Isa isa = 5;
Has has = 6;
Links links = 7;

// Type
Kind kind = 8;
Sub sub = 9;
Owns owns = 10;
Relates relates = 11;
Plays plays = 12;

// Function
Comparison comparison = 13;
Expression expression = 14;
FunctionCall function_call = 15;

// Special
Is is = 16;
IID iid = 17;
}

message ConstraintSpan {
uint64 begin = 1;
uint64 end = 2;
}

enum ConstraintExactness {
EXACT = 0;
SUBTYPES = 1;
}

// Nested
message Or {
repeated uint32 branches = 1;
}

message Not {
uint32 conjunction = 1;
}

message Try {
uint32 conjunction = 1;
}

// Edges
message Isa {
StructureVertex thing = 1;
StructureVertex type = 2;
ConstraintExactness exactness = 3;
};

message Has {
StructureVertex owner = 1;
StructureVertex attribute = 2;
ConstraintExactness exactness = 3;
};

message Links {
StructureVertex relation = 1;
StructureVertex player = 2;
StructureVertex role = 3;
ConstraintExactness exactness = 4;
};

// Type
message Kind {
protocol.ConceptDocument.Node.Leaf.Kind kind = 1;
StructureVertex type = 2;
}

message Sub {
StructureVertex subtype = 1;
StructureVertex supertype = 2;
ConstraintExactness exactness = 3;
};

message Owns {
StructureVertex owner = 1;
StructureVertex attribute = 2;
ConstraintExactness exactness = 3;
};

message Relates {
StructureVertex relation = 1;
StructureVertex role = 2;
ConstraintExactness exactness = 3;
};

message Plays {
StructureVertex player = 1;
StructureVertex role = 2;
ConstraintExactness exactness = 3;
};

// Function
message Comparison {
StructureVertex lhs = 1;
StructureVertex rhs = 2;
};

message Expression {
string text = 1;
repeated StructureVertex assigned = 2;
repeated StructureVertex arguments = 3; // Treats constants as part of the text.
};

message FunctionCall {
string name = 1;
repeated StructureVertex assigned = 2;
repeated StructureVertex arguments = 3; // Include constants, since variables are schema-objects
};

// Special
message Is {
StructureVertex lhs = 1;
StructureVertex rhs = 2;
};

message IID {
StructureVertex var = 1;
bytes IID = 2;
};
}
}