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

Make CostCalculator to calculate cumulatively #11689

Closed

Conversation

sopel39
Copy link
Contributor

@sopel39 sopel39 commented Oct 10, 2018

This enables:

  • incorporating peak memory computation as part of CostCalculator
    (and not CachingCostProvider which has different responsibility)
  • simplifying CostProvider and StatsProvider into single
    interface, e.g: TraitProvider<T>
  • simplifying CachingCostProvider and CachingStatsProvider into
    single class, e.g: CachingTraitProvider<T>

This should enable cleaner approach for #11591

This enables:
- incorporating peak memory computation as part of CostCalculator
(and not CachingCostProvider which has different responsibility)
- simplifying CostProvider and StatsProvider into single
interface, e.g: TraitProvider<T>
- simplifying CachingCostProvider and CachingStatsProvider into
single class, e.g: CachingTraitProvider<T>
Copy link
Contributor

@findepi findepi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sopel39 i encourage you to rebase your refactor on top of #11591. I have already spend quite some time in #11591 and don't want to rework all this.

@sopel39
Copy link
Contributor Author

sopel39 commented Jan 30, 2019

TraitCalculator could also be extracted:

interface TraitCalculator<T> {
    T calculateTrait(
            PlanNode node,
            TraitProvider<T> sourceTraits,
            Lookup lookup,
            Session session,
            TypeProvider types);
}

TraitProvider<T> TraitProvider#of(TraitCalculator<T> calculator, ...)

// with caching
TraitCalculator<T> calculator = SomeCachingTraitCalculator.of(calculator);
TraitProvider<T> provider = TraitProvider.of(calculator);

Note: TraitCalculator could use trait rules to compute desired traits.

Memo should be caching decorator of TraitCalculator, so that it can purge entries when groups are changed:

interface Memo {
  ...
  TraitCalculator<T> cache(TraitCalculator<T> calculator, boolean groupTrait);
  ...
}

When groupTrait==false then cached traits for parent groups are purged when group is changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants