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

georgia-tech-db / eva / #754

04 Sep 2023 09:54PM UTC coverage: 74.807% (-5.5%) from 80.336%
#754

push

circle-ci

jiashenC
update case

8727 of 11666 relevant lines covered (74.81%)

0.75 hits per line

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

75.0
/evadb/executor/abstract_executor.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 abc import ABC, abstractmethod
1✔
16
from collections import deque
1✔
17
from typing import TYPE_CHECKING, Any, Generator, Iterable, List, TypeVar
1✔
18

19
if TYPE_CHECKING:
20
    from evadb.catalog.catalog_manager import CatalogManager
21
from evadb.configuration.configuration_manager import ConfigurationManager
1✔
22
from evadb.database import EvaDBDatabase
1✔
23
from evadb.models.storage.batch import Batch
1✔
24
from evadb.plan_nodes.abstract_plan import AbstractPlan
1✔
25

26
AbstractExecutor = TypeVar("AbstractExecutor")
1✔
27

28

29
class AbstractExecutor(ABC):
1✔
30
    """
31
    An abstract class for the executor engine
32
    Arguments:
33
        node (AbstractPlan): Plan node corresponding to this executor
34
    """
35

36
    def __init__(self, db: EvaDBDatabase, node: AbstractPlan):
1✔
37
        self._db = db
1✔
38
        self._node = node
1✔
39
        self._config: ConfigurationManager = db.config if db else None
1✔
40
        self._children = []
1✔
41

42
    def catalog(self) -> "CatalogManager":
1✔
43
        """The object is intentionally generated on demand to prevent serialization issues. Having a SQLAlchemy object as a member variable can cause problems with multiprocessing. See get_catalog_instance()"""
44
        return self._db.catalog() if self._db else None
1✔
45

46
    def append_child(self, child: AbstractExecutor):
1✔
47
        """
48
        appends a child executor node
49

50
        Arguments:
51
            child {AbstractExecutor} -- child node
52
        """
53
        self._children.append(child)
1✔
54

55
    @property
1✔
56
    def children(self) -> List[AbstractExecutor]:
1✔
57
        """
58
        Returns the list of child executor
59
        Returns:
60
            [] -- list of children
61
        """
62
        return self._children
1✔
63

64
    @children.setter
1✔
65
    def children(self, children):
1✔
66
        self._children = children
×
67

68
    @property
1✔
69
    def node(self) -> AbstractPlan:
1✔
70
        return self._node
1✔
71

72
    @property
1✔
73
    def db(self) -> EvaDBDatabase:
1✔
74
        return self._db
1✔
75

76
    @property
1✔
77
    def config(self) -> ConfigurationManager:
1✔
78
        return self._config
×
79

80
    @abstractmethod
1✔
81
    def exec(self, *args, **kwargs) -> Iterable[Batch]:
1✔
82
        """
83
        This method is implemented by every executor.
84
        Contains logic for that executor;
85
        For retrieval based executor : It fetches frame batches from
86
        child nodes and emits it to parent node.
87
        """
88

89
    def __call__(self, *args, **kwargs) -> Generator[Batch, None, None]:
1✔
90
        yield from self.exec(*args, **kwargs)
×
91

92
    def bfs(self):
1✔
93
        """Returns a generator which visits all nodes in execution tree in
94
        breadth-first search (BFS) traversal order.
95

96
        Returns:
97
            the generator object.
98
        """
99
        queue = deque([self])
×
100
        while queue:
×
101
            node = queue.popleft()
×
102
            yield node
×
103
            for child in node.children:
×
104
                queue.append(child)
×
105

106
    def find_all(self, execution_type: Any):
1✔
107
        """Returns a generator which visits all the nodes in execution tree and yields one that matches the passed `execution_type`.
108

109
        Args:
110
            execution_type (Any): execution type to match with
111

112
        Returns:
113
            the generator object.
114
        """
115

116
        for node in self.bfs():
×
117
            if isinstance(node, execution_type):
×
118
                yield node
×
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