[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16153976#comment-16153976 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user asfgit closed the pull request at: https://github.com/apache/tinkerpop/pull/699 > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > Fix For: 3.2.7, 3.3.1 > > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16153972#comment-16153972 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user robertdale commented on the issue: https://github.com/apache/tinkerpop/pull/699 VOTE +1 > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16153616#comment-16153616 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user robertdale commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/699#discussion_r136983503 --- Diff: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_Traverser.java --- @@ -62,10 +62,12 @@ public void setStepId(final String stepId) { this.future = stepId; } +protected final boolean equals(final B_O_Traverser other) { +return super.equals(other) && other.future.equals(this.future); +} + @Override --- End diff -- I agree with @okram. There should be an explicit `hashCode()` so it doesn't look like it is mistakenly forgotten. > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16147653#comment-16147653 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user okram commented on the issue: https://github.com/apache/tinkerpop/pull/699 I'm scared -- VOTE +1. > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16147426#comment-16147426 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user dkuppitz commented on the issue: https://github.com/apache/tinkerpop/pull/699 `docker/build.sh -t -n -i` still succeeds after recent changes. Still VOTE: +1 > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16144610#comment-16144610 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user dkuppitz commented on the issue: https://github.com/apache/tinkerpop/pull/699 I can rename them or just make them package private. I'd prefer the latter. In fact that's what I've at first... I changed it to prevent your "please make that final protected" comment ;) > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16144607#comment-16144607 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user dkuppitz commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/699#discussion_r135670549 --- Diff: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_P_S_SE_SL_Traverser.java --- @@ -106,17 +106,18 @@ public void dropPath() { @Override public int hashCode() { -return super.hashCode() + this.path.hashCode(); +if (carriesUnmergeableSack()) { --- End diff -- Be glad that your agreeability score is 1. Mine is 3, thus I won't start a discussion about these 2 variants ending up having the same bytecode. Will change that tomorrow. > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16144605#comment-16144605 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user dkuppitz commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/699#discussion_r135670162 --- Diff: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_Traverser.java --- @@ -62,10 +62,12 @@ public void setStepId(final String stepId) { this.future = stepId; } +protected final boolean equals(final B_O_Traverser other) { +return super.equals(other) && other.future.equals(this.future); +} + @Override --- End diff -- That's intentional. B_O_Traverser's hashcode is the same as O_Traverser's. Same story below. In both cases equals() will do the "deep" check, but hashcode() ignores fields that are unlikely different. > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16144392#comment-16144392 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user okram commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/699#discussion_r135642938 --- Diff: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_S_SE_SL_Traverser.java --- @@ -110,17 +112,22 @@ public void merge(final Traverser.Admin other) { / +final boolean carriesUnmergeableSack() { +// hmmm... serialization in OLAP destroys the transient sideEffects +return null != this.sack && (null == this.sideEffects || null == this.sideEffects.getSackMerger()); +} + @Override public int hashCode() { -return this.t.hashCode() + this.future.hashCode() + this.loops; +return carriesUnmergeableSack() ? System.identityHashCode(this) : (super.hashCode() ^ this.loops); +} + +protected final boolean equals(final B_O_S_SE_SL_Traverser other) { --- End diff -- I'm a little scared of this "double equals()" definition. @spmallette -- do you have any thoughts on this matter? Note that there is an `equals(Object)` method like always, but then there is this added `protected final equals(SpecificClass)`. I have a feeling that this could get screwy for languages like Groovy. Perhaps there is a better way to do what is needed without overloading `equals()`? > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16144389#comment-16144389 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user okram commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/699#discussion_r135642562 --- Diff: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/O_Traverser.java --- @@ -23,6 +23,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.AbstractTraverser; --- End diff -- There is no `hashCode()` method for this class either like `B_O_...`. Again, its just `return t.hashCode()` > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16144388#comment-16144388 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user okram commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/699#discussion_r135642343 --- Diff: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/LP_O_OB_P_S_SE_SL_Traverser.java --- @@ -106,17 +106,18 @@ public void dropPath() { @Override public int hashCode() { -return super.hashCode() + this.path.hashCode(); +if (carriesUnmergeableSack()) { --- End diff -- Can you use inline `returns carriesUnmergableSack() ? ... : ...` please? > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16144386#comment-16144386 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user okram commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/699#discussion_r135642190 --- Diff: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/B_O_Traverser.java --- @@ -62,10 +62,12 @@ public void setStepId(final String stepId) { this.future = stepId; } +protected final boolean equals(final B_O_Traverser other) { +return super.equals(other) && other.future.equals(this.future); +} + @Override --- End diff -- This class does not have a `hashCode()` method. It should since it implements `equals()`. Its easy, its just `this.t.hashCode()`. > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16144098#comment-16144098 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user dkuppitz commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/699#discussion_r135584747 --- Diff: tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/TinkerGraphPerformanceTest.java --- @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tinkerpop.gremlin.tinkergraph.process.traversal; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; +import org.apache.tinkerpop.gremlin.util.TimeUtil; +import org.junit.Test; + +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; + +/** + * @author Daniel Kuppitz (http://gremlin.guru) + */ +public class TinkerGraphPerformanceTest { + +/** + * Check the traverser's hashcode() implementation if this test fails. hashcode() should + * not generate too many hash collisions. + */ +@Test +public void sacksWithoutMergerShouldBeFast() { --- End diff -- Hmm, I'm not sure how to rewrite the test using the `inject()` approach. The following snippet shows no performance issues at all: ``` strategies = new DefaultTraversalStrategies() strategies.addStrategies(SackStrategy.build().initialValue({1}).create()) t = __.inject((1..8192).toArray()).barrier(); [] t.asAdmin().setStrategies(strategies) t.asAdmin().applyStrategies() t.iterate() ``` > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16144054#comment-16144054 ] ASF GitHub Bot commented on TINKERPOP-1759: --- Github user okram commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/699#discussion_r135576162 --- Diff: tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/TinkerGraphPerformanceTest.java --- @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tinkerpop.gremlin.tinkergraph.process.traversal; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph; +import org.apache.tinkerpop.gremlin.util.TimeUtil; +import org.junit.Test; + +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; + +/** + * @author Daniel Kuppitz (http://gremlin.guru) + */ +public class TinkerGraphPerformanceTest { + +/** + * Check the traverser's hashcode() implementation if this test fails. hashcode() should + * not generate too many hash collisions. + */ +@Test +public void sacksWithoutMergerShouldBeFast() { --- End diff -- This should be in a class called `SackStrategyTest` as `SackStrategy` is what is being analyzed. This would be analogous to how we do timing tests in `RepeatUnrollStrategyTest`. > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (TINKERPOP-1759) Improve hashcode and equals for Traverser implementations
[ https://issues.apache.org/jira/browse/TINKERPOP-1759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16143976#comment-16143976 ] ASF GitHub Bot commented on TINKERPOP-1759: --- GitHub user dkuppitz opened a pull request: https://github.com/apache/tinkerpop/pull/699 TINKERPOP-1759 Improve hashcode and equals for Traverser implementations https://issues.apache.org/jira/browse/TINKERPOP-1759 Improved `hashcode()` and `equals()` for all Traverser implementations and added a performance test to ensure that things don't get reverted when someone thinks that the hashcode implementations could be rewritten. `docker/build.sh -t -i` succeeded. VOTE: +1 You can merge this pull request into a Git repository by running: $ git pull https://github.com/apache/tinkerpop TINKERPOP-1759 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/tinkerpop/pull/699.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #699 commit d0659e379bf59a164b4c3d87cc83de545d433547 Author: Daniel KuppitzDate: 2017-08-24T20:51:41Z Improved `hashcode()` and `equals()` for all Traverser implementations. commit ea4fcdfffabdf8dc8c8a5ce11f983161f6287aef Author: Daniel Kuppitz Date: 2017-08-25T14:13:01Z Added TinkerGraphPerformanceTest to ensure that the latest changes in hashcode() implementations don't get reverted some day. commit f8626ce6d3f6be4dddba09b74c38b49e8d379eb7 Author: Daniel Kuppitz Date: 2017-08-25T15:43:33Z Improved equals() inheritance chain in Traverser implementations. We now have fewer checks and fewer casts. Cool! > Improve hashcode and equals for Traverser implementations > - > > Key: TINKERPOP-1759 > URL: https://issues.apache.org/jira/browse/TINKERPOP-1759 > Project: TinkerPop > Issue Type: Improvement > Components: process >Affects Versions: 3.2.6 >Reporter: Daniel Kuppitz >Assignee: Daniel Kuppitz > -- This message was sent by Atlassian JIRA (v6.4.14#64029)