-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Values/Filter)-push-down optimization
- Loading branch information
1 parent
72cde10
commit b5faae6
Showing
22 changed files
with
467 additions
and
237 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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
47 changes: 47 additions & 0 deletions
47
sage/query_engine/optimizer/logical/visitors/filter_variables_extractor.py
This file contains 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,47 @@ | ||
from typing import Set | ||
from rdflib.term import Variable | ||
from rdflib.plugins.sparql.parserutils import Expr | ||
|
||
from sage.query_engine.optimizer.logical.plan_visitor import LogicalPlanVisitor, RDFTerm | ||
|
||
|
||
class FilterVariablesExtractor(LogicalPlanVisitor): | ||
|
||
def visit_rdfterm(self, node: RDFTerm) -> Set[str]: | ||
if isinstance(node, Variable): | ||
return set([node.n3()]) | ||
else: | ||
return set() | ||
|
||
def visit_conditional_and_expression(self, node: Expr) -> Set[str]: | ||
variables = self.visit(node.expr) | ||
for other in node.other: | ||
variables.update(self.visit(other)) | ||
return variables | ||
|
||
def visit_conditional_or_expression(self, node: Expr) -> Set[str]: | ||
variables = self.visit(node.expr) | ||
for other in node.other: | ||
variables.update(self.visit(other)) | ||
return variables | ||
|
||
def visit_relational_expression(self, node: Expr) -> Set[str]: | ||
return self.visit(node.expr) | ||
|
||
def visit_additive_expression(self, node: Expr) -> Set[str]: | ||
variables = self.visit(node.expr) | ||
for other in node.other: | ||
variables.update(self.visit(other)) | ||
return variables | ||
|
||
def visit_regex_expression(self, node: Expr) -> Set[str]: | ||
return self.visit(node.text) | ||
|
||
def visit_not_exists_expression(self, node: Expr) -> Set[str]: | ||
return self.visit(node.expr) | ||
|
||
def visit_str_expression(self, node: Expr) -> Set[str]: | ||
return self.visit(node.arg) | ||
|
||
def visit_unary_not_expression(self, node: Expr) -> Set[str]: | ||
return self.visit(node.expr) |
This file contains 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 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.