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

georgia-tech-db / eva / 7c1c5cb7-cb1e-4c69-985c-b642250357b6

28 Oct 2023 10:44PM UTC coverage: 76.956% (-1.7%) from 78.704%
7c1c5cb7-cb1e-4c69-985c-b642250357b6

push

circle-ci

xzdandy
Fix list

8990 of 11682 relevant lines covered (76.96%)

1.73 hits per line

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

74.42
/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
2✔
16
from collections import deque
2✔
17
from typing import TYPE_CHECKING, Any, Generator, Iterable, List, TypeVar
2✔
18

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

25
AbstractExecutor = TypeVar("AbstractExecutor")
2✔
26

27

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

35
    def __init__(self, db: EvaDBDatabase, node: AbstractPlan):
2✔
36
        self._db = db
2✔
37
        self._node = node
2✔
38
        self._children = []
2✔
39

40
    # @lru_cache(maxsize=None)
41
    def catalog(self) -> "CatalogManager":
2✔
42
        """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()"""
43
        return self._db.catalog() if self._db else None
2✔
44

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

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

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

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

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

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

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

84
    def __call__(self, *args, **kwargs) -> Generator[Batch, None, None]:
2✔
85
        yield from self.exec(*args, **kwargs)
×
86

87
    def bfs(self):
2✔
88
        """Returns a generator which visits all nodes in execution tree in
89
        breadth-first search (BFS) traversal order.
90

91
        Returns:
92
            the generator object.
93
        """
94
        queue = deque([self])
×
95
        while queue:
×
96
            node = queue.popleft()
×
97
            yield node
×
98
            for child in node.children:
×
99
                queue.append(child)
×
100

101
    def find_all(self, execution_type: Any):
2✔
102
        """Returns a generator which visits all the nodes in execution tree and yields one that matches the passed `execution_type`.
103

104
        Args:
105
            execution_type (Any): execution type to match with
106

107
        Returns:
108
            the generator object.
109
        """
110

111
        for node in self.bfs():
×
112
            if isinstance(node, execution_type):
×
113
                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

© 2026 Coveralls, Inc