Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement hash functions in Ad operators #1179

Closed
keileg opened this issue Jun 7, 2024 · 1 comment
Closed

Implement hash functions in Ad operators #1179

keileg opened this issue Jun 7, 2024 · 1 comment
Assignees
Labels
user group Issue to be worked on in the internal user group.

Comments

@keileg
Copy link
Contributor

keileg commented Jun 7, 2024

Overview

We should implement hash functions for all Ad operators. The motivation is primarily to allow us to identify operators that are identical and thereby save time and memory during operator tree parsing. The hash will also allow us to store values of operators.

The implementation itself should be easy, see below. The potentially hard part will be to decide a way to define a suitable hash key for all types of operators.

Prototype implementation

A few ideas are sketched below, but the code may well contain logical flaws

class MergedOperator:

    def __key(self):
      tmp = [g.id for g in self.domain]
      tmp += [self.key]   # self.key and self.__key() is problematic
      tmp += [self.discr.keyword]
      return tuple(tmp)

    def __hash__(self):
        return hash(self.__key())

class Operator:

    def __key(self):
      tmp = [child for child in self.children]
      tmp += [self.operation]
      return tuple(tmp)

    def __hash__(self):
        return hash(self.__key())
@keileg keileg added the user group Issue to be worked on in the internal user group. label Jun 7, 2024
@jwboth
Copy link
Contributor

jwboth commented Aug 15, 2024

Task: Identify a suitable hash function for all Ad operators, with identical values iff evaluation can be stored and reused. Implement. Design suggestions are available in #1179. Proper test coverage is critical.

Outcome: Implementation of hash functions, with testing. Design principles are available for new classes of Ad operators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user group Issue to be worked on in the internal user group.
Projects
None yet
Development

No branches or pull requests

3 participants