-
Notifications
You must be signed in to change notification settings - Fork 65
FILTER keyword for latest anchor queries (planner/memory) #150
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
Merged
thiagovas
merged 26 commits into
google:master
from
rogerlucena:filter-latest-planner-memory
Oct 16, 2020
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
449c3a8
Add three new triples to the ?test graph of "planner_test.go" (to bet…
rogerlucena e30c7cd
Add tests for FILTER with latest anchor (in "planner_test.go")
rogerlucena eb5a1ec
Add "filters" to the "queryPlan" type
rogerlucena 1720236
Update String method of queryPlan to show filters as well
rogerlucena 929af59
Add FilterOptions to LookupOptions in "storage.go"
rogerlucena 97fe2cc
Add support for FILTER clauses in the planner
rogerlucena cbfffae
Make the volatile driver consume lo.FilterOptions (focusing on latest…
rogerlucena 1da2253
Update String method of LookupOptions to show FilterOptions as well
rogerlucena e2a2a61
Minor renaming inside "memory_test.go" to avoid confusion
rogerlucena e0003e2
Fix problem with partial predicate UUIDs in the volatile driver and m…
rogerlucena 4310646
Add tests for the FILTER execution in the volatile driver (in "memory…
rogerlucena b572365
Allow user to specify for which bindings in the clause each filter ca…
rogerlucena 079a781
Use a closure to make planner more performant (especially with the ad…
rogerlucena 901d807
Use an "enum" instead of a "string" for filter operations (less error…
rogerlucena a861175
Update "memory.go" and "memory_test.go" since filter operations are "…
rogerlucena ebd7b24
Update "hooks_test.go" and "semantic_test.go" since filter operations…
rogerlucena 0f1dfc8
Move "storage.FilteringOptions" to "filter.go" as "filter.StorageOpti…
rogerlucena d5f8ff8
Add a String method for filter.StorageOptions
rogerlucena d62e88b
Use an "enum" instead of a "string" for filter fields (less error-pro…
rogerlucena 960ec7b
Update "memory.go" and "memory_test.go" since filter fields are "enum…
rogerlucena caf9d85
Add an "isEmpty" method for "filter.Operation"
rogerlucena d480b9d
Update comments for "semantic.FilterClause" and "filter.StorageOptions"
rogerlucena 5f7962a
Refactor "WhereFilterClauseHook" to make it clearer (separating code …
rogerlucena 0c8c422
Use "t.Run" for FILTER tests in "memory_test.go", and make it cleaner
rogerlucena 5fd5a95
Do not use naked returns inside "compatibleBindingsInClauseForFilterO…
rogerlucena ea887b7
Return "compatibleBindingsInClause" directly for each switch case ins…
rogerlucena 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| // Copyright 2020 Google Inc. All rights reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| // Package filter isolates core FILTER related implementation. | ||
| package filter | ||
|
|
||
| import ( | ||
| "fmt" | ||
| ) | ||
|
|
||
| // Operation represents a filter operation supported in BadWolf. | ||
| type Operation int | ||
|
|
||
| // List of supported filter operations. | ||
| const ( | ||
| Latest Operation = iota + 1 | ||
| ) | ||
|
|
||
| // Field represents the position of the semantic.GraphClause that will be operated by the filter at storage level. | ||
| type Field int | ||
|
|
||
| // List of filter fields. | ||
| const ( | ||
| SubjectField Field = iota + 1 | ||
| PredicateField | ||
| ObjectField | ||
| ) | ||
|
|
||
| // SupportedOperations maps suported filter operation strings to their correspondant Operation. | ||
| // Note that the string keys here must be in lowercase letters only (for compatibility with the WhereFilterClauseHook). | ||
| var SupportedOperations = map[string]Operation{ | ||
| "latest": Latest, | ||
| } | ||
|
|
||
| // StorageOptions represent the storage level specifications for the filtering to be executed. | ||
| // Operation below refers to the filter function being applied (eg: Latest), Field refers to the position of the graph clause it | ||
| // will be applied to (subject, predicate, or object) and Value, when specified, contains the second argument of the filter | ||
| // function (not applicable for all Operations - some like Latest do not use it while others like GreaterThan do, see Issue 129). | ||
| type StorageOptions struct { | ||
| Operation Operation | ||
| Field Field | ||
| Value string | ||
| } | ||
|
|
||
| // String returns the string representation of Operation. | ||
| func (op Operation) String() string { | ||
| switch op { | ||
| case Latest: | ||
| return "latest" | ||
| default: | ||
| return fmt.Sprintf(`not defined filter operation "%d"`, op) | ||
| } | ||
| } | ||
|
|
||
| // IsEmpty returns true if the Operation was not set yet. | ||
| func (op Operation) IsEmpty() bool { | ||
| return op == Operation(0) | ||
| } | ||
|
|
||
| // String returns the string representation of Field. | ||
| func (f Field) String() string { | ||
| switch f { | ||
| case SubjectField: | ||
| return "subject field" | ||
| case PredicateField: | ||
| return "predicate field" | ||
| case ObjectField: | ||
| return "object field" | ||
| default: | ||
| return fmt.Sprintf(`not defined filter field "%d"`, f) | ||
| } | ||
| } | ||
|
|
||
| // String returns the string representation of StorageOptions. | ||
| func (so *StorageOptions) String() string { | ||
| return fmt.Sprintf("%+v", *so) | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.