-
Notifications
You must be signed in to change notification settings - Fork 15
Add analyze endpoint and query structure #231
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
krishnangovindraj
wants to merge
50
commits into
typedb:master
Choose a base branch
from
krishnangovindraj:query-structure
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
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 04fad54
Add kind, links can have multiple role-players
krishnangovindraj 71bf044
Add query-structure into header & provenance into row
krishnangovindraj 7b606d8
Update BUILD files
krishnangovindraj 97e193b
Fix build files
krishnangovindraj 2396bab
Add constraint span
krishnangovindraj 9f9bd41
Add exactness to Isa, Sub and other speculatively
krishnangovindraj b10129f
Fix label to be a concept
krishnangovindraj 8b77d2a
Fix value to be oneof
krishnangovindraj 315168e
Fix owns field names
krishnangovindraj e7160ba
Make expression assigned repeated for future-proofing
krishnangovindraj aee5da4
Extend QueryVariable to possibly be unavailable
krishnangovindraj 7de1479
Some minor renaming
krishnangovindraj 1d00ae0
Add span for each role-player
krishnangovindraj 0eaf900
Flatten links roleplayers
krishnangovindraj 0a5eb80
Reflect naming
krishnangovindraj b912759
Make labels only accept type
krishnangovindraj 0586271
Reflect renaming again
krishnangovindraj cff738f
Remove query structure from ConceptRowStream, making it currently unused
krishnangovindraj c8b975a
Try filling in analyze proto
krishnangovindraj b197dc2
Do I have to add it to the filegroup?
krishnangovindraj 98ba00c
Rename Constraint to structureConstraint for consistency
krishnangovindraj e7b9671
And one for the build.rs
krishnangovindraj e8f9bc3
Add constraint nested patterns + sort direction
krishnangovindraj 1a3bbee
Rename inner to conjunction
krishnangovindraj 90e977e
Rename Disjunction -> or etc for consistency
krishnangovindraj 373db61
Make StructureVertex Label support unresolved labels
krishnangovindraj 7b77360
Forgot oneoef
krishnangovindraj a2cd43a
Introduce Analyze req & res into transaction rpc
krishnangovindraj c9b4bf5
Variables deserve their own message
krishnangovindraj 3fb64f1
Oopsies. I forgot about annotations
krishnangovindraj f59677e
Forgot the fields in res
krishnangovindraj ec84d80
Make return reducer field plural
krishnangovindraj e185176
Add kind & label constraints; comparator
krishnangovindraj 574bc32
Rename Value(Constraint)::type -> attribute_type
krishnangovindraj 9fba4c5
Rename Iid field: var -> concenpt
krishnangovindraj daa9860
Fix build
krishnangovindraj a3cd5d5
WIP: Add conjunction annotations; next fetch
krishnangovindraj 6729f15
Add fetch annotations
krishnangovindraj f731396
Add function annotations & update
krishnangovindraj a3e548f
Add returns_stream to function annotations
krishnangovindraj 9f0f388
Fix function annotations
krishnangovindraj 4d51f8f
Support Thing & Type
krishnangovindraj a45dc23
Bad field name in ConceptVariableAnnotations
krishnangovindraj 8e7077e
Oopsies. Do analyze errors properly
krishnangovindraj 8095df4
Remove TOOD
krishnangovindraj ba56e09
Rename Label.label::(failedInference to unresolved)
krishnangovindraj deae655
Move StructureVertex::Label::unresolved to a new Label::NamedRole var…
krishnangovindraj bf98739
Add unresolved as a variant in vertex
krishnangovindraj f2aa192
Rename conjunction.proto to structure.proto
krishnangovindraj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
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; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?