Skip to content

Conversation

@ForeverAngry
Copy link
Contributor

Closes #2147

  • Implement ResidualEvaluatorCache with LRU eviction and thread safety
  • Cache evaluators by partition spec, expression, case sensitivity, and schema

Rationale for this change

For queries, the same combinations of (partition spec, expression, case sensitivity, schema) are evaluated repeatedly, causing unnecessary computational overhead and increased query latency.

Are these changes tested?

Yes, using the existing test cases as they seemed sufficient for the changes.

Are there any user-facing changes?

No.

Fixes apache#2147

- Implement ResidualEvaluatorCache with LRU eviction and thread safety
- Cache evaluators by partition spec, expression, case sensitivity, and schema
- Fix mypy type annotations and add type ignore for cachetools decorator
@ForeverAngry ForeverAngry force-pushed the feat-cache-residual-evaluator branch from 55e53d0 to 0ec381e Compare November 7, 2025 14:41
Comment on lines +2084 to +2086
cached = _residual_evaluator_cache.get(spec, expr, case_sensitive, schema)
if cached is not None:
return cached
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We certainly can, it would have been much simpler. My main motivation was really about implementing something that was more extensible, readable (so that people dont have to dig to deep to see whats actually happening) that users could have more control over.

Im happy to simplify it. Let me know what you think.

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.

Cache ResidualEvaluator

2 participants