Skip to content

Conversation

@ksobolew
Copy link
Contributor

Description

The issue is that Pattern does not implement hashCode so we can't use it directly for hashing. It also doesn't implement equals, but it's already properly handled in SelectorSpec's equals method - we should do the analogous thing in hashCode as well. As a bonus, do that in toString, too.

Also, call addNamedGroups for queryText criterion in StaticSelector.

Additional context and related issues

Follow-up to #27129.

Release notes

(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`issuenumber`)

The issue is that `Pattern` does not implement `hashCode` so we can't
use it directly for hashing. It also doesn't implement `equals`, but
it's already properly handled in `SelectorSpec`'s `equals` method - we
should do the analogous thing in `hashCode` as well. As a bonus, do that
in `toString`, too.
This is what we do for all the other `Pattern` selection criteria.
sourceRegex.map(Pattern::flags),
queryText,
queryText.map(Pattern::pattern),
queryText.map(Pattern::flags),
Copy link
Member

Choose a reason for hiding this comment

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

Or maybe SelectorSpec should not implement equals/hashcode at all?
what's the use of it anyway?

(potential follow-up)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or maybe SelectorSpec should not implement equals/hashcode at all?
what's the use of it anyway?

Sadly, I don't know the answer to that question

Copy link
Contributor

Choose a reason for hiding this comment

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

me neither, might be best to keep it this way

Copy link
Member

Choose a reason for hiding this comment

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

if the equals is meaningless, there is no point in keeping things like this.

@gertjanal
Copy link
Contributor

gertjanal commented Dec 10, 2025

Thanks for your fixes, I noticed them today when using the classes. Can you rename queryText to queryTextRegex in the selectorspec? That seems consistent with the other patterns. (Note the textual rename on line 58)

@gertjanal gertjanal self-requested a review December 10, 2025 18:58
@wendigo wendigo merged commit ef1853d into trinodb:master Dec 11, 2025
40 of 42 checks passed
@github-actions github-actions bot added this to the 479 milestone Dec 11, 2025
@ksobolew
Copy link
Contributor Author

Can you rename queryText to queryTextRegex in the selectorspec? That seems consistent with the other patterns.

Yeah, I noticed that. I love consistency too, but I think it's low priority this time :)

@ksobolew ksobolew deleted the kudi/query-text-pattern-fixes branch December 11, 2025 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants