Skip to content

API: Extract superclass from StrictMetricsEvaluator - #17511

Open
nastra wants to merge 1 commit into
apache:mainfrom
nastra:strict-eval-visitor
Open

API: Extract superclass from StrictMetricsEvaluator#17511
nastra wants to merge 1 commit into
apache:mainfrom
nastra:strict-eval-visitor

Conversation

@nastra

@nastra nastra commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Similar to #17201 this extracts the strict evaluation logic from StrictMetricsEvaluator into a new superclass. StrictMetricsEvaluator now uses the visitor superclass and implements methods to access metrics by ID. This is in preparation for adding a strict stats visitor that consumes ContentStats directly.

@github-actions github-actions Bot added the API label Aug 4, 2026
Extract the strict evaluation logic from StrictMetricsEvaluator into a new
superclass, StrictEvalVisitor. StrictMetricsEvaluator now uses the visitor
superclass and implements methods to access metrics by ID. This is in
preparation for adding a strict stats visitor that consumes ContentStats
directly.
* <p>Unlike {@link #mayContainNull(int)}, this returns false when a null count is unavailable for
* the field but is available for other fields.
*/
protected abstract boolean canContainNulls(int id);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There might be abstract-method contract asymmetry with the inclusive twin. StrictEvalVisitor declares 8 abstract methods; whereas the merged InclusiveEvalVisitor declares only 4. The two extra semantic methods (canContainNulls(int id) and canContainNaNs(int id)) carry a subtly stricter contract than their mayContain* counterparts: canContainNulls returns false when the nullCounts map exists but has no entry for the field (where mayContainNull returns true in that case), and canContainNaNs returns false whenever a NaN count is unavailable.

Can this create friction when the downstream v4 strict ContentStats evaluator is written, since its author must satisfy a materially larger contract than the corresponding inclusive visitor? Perhaps we should either add a comment to StrictEvalVisitor explaining why the strict visitor's contract diverges from InclusiveEvalVisitor's, or if the inclusive stats path will also need these finer-grained predicates then adding canContainNulls/canContainNaNs to InclusiveEvalVisitor now while both visitors are being actively designed.

WDYT? @nastra

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

canContainNulls and canContainNaNs are only temporarily needed and will be removed with nastra@9ebe146 in a follow-up. I wanted to have this PR be a pure refactoring PR and then add nastra@9ebe146 on top of that, which then results in an API that aligns with the InclusiveEvalVisitor

@anoopj anoopj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The refactor looks correct to me. One small comment.

* Return true if the NaN count is known and non-zero, false otherwise.
*
* <p>Unlike {@link #mayContainNaN(int)}, this returns false when the NaN count is unavailable.
* NaN counts are not tracked for non-floating point fields or by early writers.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: we can just remove this line, as it's describing the format behavior. I know we are going to remove it anyway, per the other comment thread.

@nastra nastra moved this to In review in V4: metadata tree Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants