• 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/group.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
from __future__ import annotations
×
16

17
from typing import Dict, List
×
18

19
from evadb.constants import UNDEFINED_GROUP_ID
×
20
from evadb.optimizer.group_expression import GroupExpression
×
21
from evadb.optimizer.property import Property
×
22
from evadb.utils.logging_manager import logger
×
23

24

25
class Winner:
×
26
    def __init__(self, grp_expr: GroupExpression, cost: float):
×
27
        self._cost = cost
×
28
        self._grp_expr = grp_expr
×
29

30
    @property
×
31
    def cost(self):
×
32
        return self._cost
×
33

34
    @property
×
35
    def grp_expr(self):
×
36
        return self._grp_expr
×
37

38

39
class Group:
×
40
    def __init__(self, group_id: int, aliases: List[str] = None):
×
41
        self._group_id = group_id
×
42
        self._aliases = aliases
×
43
        self._logical_exprs = []
×
44
        self._physical_exprs = []
×
45
        self._winner_exprs: Dict[Property, Winner] = {}
×
46
        self._is_explored = False
×
47

48
    @property
×
49
    def group_id(self):
×
50
        return self._group_id
×
51

52
    @property
×
53
    def aliases(self):
×
54
        return self._aliases
×
55

56
    @property
×
57
    def logical_exprs(self):
×
58
        return self._logical_exprs
×
59

60
    @property
×
61
    def physical_exprs(self):
×
62
        return self._physical_exprs
×
63

64
    def is_explored(self):
×
65
        return self._is_explored
×
66

67
    def mark_explored(self):
×
68
        self._is_explored = True
×
69

70
    def __str__(self) -> str:
×
71
        return "%s(%s)" % (
×
72
            type(self).__name__,
73
            ", ".join("%s=%s" % item for item in vars(self).items()),
74
        )
75

76
    def add_expr(self, expr: GroupExpression):
×
77
        if expr.group_id == UNDEFINED_GROUP_ID:
×
78
            expr.group_id = self.group_id
×
79

80
        if expr.group_id != self.group_id:
×
81
            logger.error(
×
82
                "Expected group id {}, found {}".format(self.group_id, expr.group_id)
83
            )
84
            return
×
85

86
        if expr.opr.is_logical():
×
87
            self._add_logical_expr(expr)
×
88
        else:
89
            self._add_physical_expr(expr)
×
90

91
    def get_best_expr(self, property: Property) -> GroupExpression:
×
92
        winner = self._winner_exprs.get(property, None)
×
93
        if winner:
×
94
            return winner.grp_expr
×
95
        else:
96
            return None
×
97

98
    def get_best_expr_cost(self, property: Property):
×
99
        winner = self._winner_exprs.get(property, None)
×
100
        if winner:
×
101
            return winner.cost
×
102
        else:
103
            return None
×
104

105
    def add_expr_cost(self, expr: GroupExpression, property, cost):
×
106
        existing_winner = self._winner_exprs.get(property, None)
×
107
        if not existing_winner or existing_winner.cost > cost:
×
108
            self._winner_exprs[property] = Winner(expr, cost)
×
109

110
    def clear_grp_exprs(self):
×
111
        self._logical_exprs.clear()
×
112
        self._physical_exprs.clear()
×
113

114
    def _add_logical_expr(self, expr: GroupExpression):
×
115
        self._logical_exprs.append(expr)
×
116

117
    def _add_physical_expr(self, expr: GroupExpression):
×
118
        self._physical_exprs.append(expr)
×
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