[
https://issues.apache.org/jira/browse/OAK-855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13675822#comment-13675822
]
Jukka Zitting commented on OAK-855:
-----------------------------------
bq. isn't by definition the ModifiedNodeState never equal to a non-modified
one, unless there are no changes?
No. A ModifiedNodeState is typically (though not always) non-equal to the
unmodified base state, but there's no guarantee that the state passed to
{{equals()}} would necessarily be that base state.
bq. Instead of overriding the equals method, I wonder if we should use another
mechanism.
Yes, that might be better.
However, more generally the {{equals()}} method shouldn't really be needed that
much. It's defined and used mostly because that was originally the best way to
implement {{AbstractNodeState.compareAgainstBaseState()}} in a reasonably
efficient manner until we could agree on the related {{MicroKernel.diff()}}
semantics (see OAK-227).
Thus instead of focusing too much on {{equals()}} I think we'd get better
results by looking at where and why it's being called and optimizing those
cases instead. It could well be that the {{equals}} calls wouldn't even be
needed after that.
> NodeState.equals is sometimes very slow
> ---------------------------------------
>
> Key: OAK-855
> URL: https://issues.apache.org/jira/browse/OAK-855
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: core
> Reporter: Thomas Mueller
>
> The method NodeState.equals seems to be very slow sometimes, for example if a
> KernelNodeState is compared against a ModifiedNodeState. A recursive
> traversal is used in this case. I found this problem when running the
> integration tests (-PintegrationTesting). I guess it's specially a problem if
> there are many child nodes.
> I wonder if we could use a shortcut when comparing a ModifiedNodeState
> against a non-modified one: isn't by definition the ModifiedNodeState _never_
> equal to a non-modified one, unless there are no changes?
> When comparing two ModifiedNodeState objects (not sure if that's a common use
> case), then a simple optimization would also be possible.
> What's also not nice is: it seems multiple NodeState classes implement
> equals, but not hashCode. Instead of overriding the equals method, I wonder
> if we should use another mechanism.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira