• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

georgia-tech-db / eva / #758

04 Sep 2023 08:37PM UTC coverage: 0.0% (-78.3%) from 78.333%
#758

push

circle-ci

hershd23
Increased underline length in at line 75 in text_summarization.rst
	modified:   docs/source/benchmarks/text_summarization.rst

0 of 11303 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/evadb/optimizer/binder.py
1
# coding=utf-8
2
# Copyright 2018-2023 EvaDB
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
import copy
×
16
import itertools
×
17

18
from evadb.optimizer.group_expression import GroupExpression
×
19
from evadb.optimizer.memo import Memo
×
20
from evadb.optimizer.operators import Dummy, Operator, OperatorType
×
21
from evadb.optimizer.rules.pattern import Pattern
×
22

23

24
class Binder:
×
25
    def __init__(self, grp_expr: GroupExpression, pattern: Pattern, memo: Memo):
×
26
        self._grp_expr = grp_expr
×
27
        self._pattern = pattern
×
28
        self._memo = memo
×
29

30
    @staticmethod
×
31
    def _grp_binder(idx: int, pattern: Pattern, memo: Memo):
×
32
        grp = memo.groups[idx]
×
33

34
        for expr in grp.logical_exprs:
×
35
            yield from Binder._binder(expr, pattern, memo)
×
36

37
    @staticmethod
×
38
    def _binder(expr: GroupExpression, pattern: Pattern, memo: Memo):
×
39
        assert isinstance(expr, GroupExpression)
×
40
        curr_iterator = iter(())
×
41
        child_binders = []
×
42
        if pattern.opr_type is not OperatorType.DUMMY:
×
43
            curr_iterator = iter([expr.opr])
×
44
            if expr.opr.opr_type != pattern.opr_type:
×
45
                return
×
46

47
            if len(pattern.children) != len(expr.children):
×
48
                return
×
49

50
            for child_grp, pattern_child in zip(expr.children, pattern.children):
×
51
                child_binders.append(Binder._grp_binder(child_grp, pattern_child, memo))
×
52
        else:
53
            # record the group id in a Dummy Operator
54
            curr_iterator = iter([Dummy(expr.group_id, expr.opr)])
×
55

56
        yield from itertools.product(curr_iterator, *child_binders)
×
57

58
    @staticmethod
×
59
    def build_opr_tree_from_pre_order_repr(pre_order_repr: tuple) -> Operator:
×
60
        opr_tree = pre_order_repr[0]
×
61
        assert isinstance(
×
62
            opr_tree, Operator
63
        ), f"Unknown operator encountered, expected Operator found {type(opr_tree)}"
64
        # We should not modify the operator in the group
65
        # expression as it might be used in later rules. Hack:
66
        # Creating a copy of the match Potential fix: Store only
67
        # the content in the group expression and manage the
68
        # parent-child relationship separately. Refer
69
        # optimizer_context:_xform_opr_to_group_expr
70
        opr_tree = copy.copy(opr_tree)
×
71
        opr_tree.children.clear()
×
72
        if len(pre_order_repr) > 1:
×
73
            # remove old children
74
            for child in pre_order_repr[1:]:
×
75
                opr_tree.append_child(Binder.build_opr_tree_from_pre_order_repr(child))
×
76
        return opr_tree
×
77

78
    def __iter__(self):
×
79
        # the iterator only returns one match, which stems from the root node
80
        for match in Binder._binder(self._grp_expr, self._pattern, self._memo):
×
81
            x = Binder.build_opr_tree_from_pre_order_repr(match)
×
82
            yield x
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc