Skip to content

Conversation

@MechCoder
Copy link
Contributor

Implementing methods equals hashcode and equals for Matrix

@MechCoder
Copy link
Contributor Author

cc @mengxr . Please review.

@MechCoder
Copy link
Contributor Author

@mengxr

  1. Is there any reason why forEachActive is private? It took me some time to realize that it existed (and I already wrote my implementation by then)
  2. The hashcode in this PR is just a generalization of that in the Vectors. I'm unable to understand why it is implemented in this specific way. Would be great if you could give me some idea.

@SparkQA
Copy link

SparkQA commented Mar 18, 2015

Test build #28781 has finished for PR 5081 at commit 4041b59.

  • This patch fails MiMa tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Mar 18, 2015

Test build #28783 has finished for PR 5081 at commit b5033b5.

  • This patch fails MiMa tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@MechCoder
Copy link
Contributor Author

Also, I'm not sure what the failed tests are about.

@SparkQA
Copy link

SparkQA commented Mar 18, 2015

Test build #28785 has finished for PR 5081 at commit bf0e0e7.

  • This patch fails MiMa tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen
Copy link
Member

srowen commented Mar 18, 2015

What's the use case for comparing matrices for equality? I think it's rarer than for vectors. Is it just for testing, mostly?

@MechCoder
Copy link
Contributor Author

Yes, I required it in this PR #5048 (which is required in #4986) to test that the matrices after serializing and deserializing are the same. (Also given the fact that it was already implemented for DenseMatrices, I just refactored it and added support for SparseMatrices)

@mengxr
Copy link
Contributor

mengxr commented Mar 18, 2015

The hashCode implementation was taken from Effective Java: http://stackoverflow.com/questions/10915309/need-explanation-for-hashcode-example-in-effective-java-textbook

foreachActive is a private API because we need to consider what operators to expose together.

@srowen It may help if we implement hashCode and content equals for both vectors and matrices. It is mostly used for testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hash numRows and numCols separately.

@mengxr
Copy link
Contributor

mengxr commented Mar 18, 2015

@srowen There are two approaches:

  1. implement hashCode/equals
  2. use the default implementation and use toArray to compare matrices in unit tests

Which do you prefer?

@MechCoder
Copy link
Contributor Author

I'm starting to think we should just test if .toArray is equal and this PR might be overkill if it is just for testing purposes.

@mengxr
Copy link
Contributor

mengxr commented Mar 18, 2015

Okay, let's keep this PR open and could you update the MatrixUDT PR to use .toArray?

@MechCoder
Copy link
Contributor Author

Done already 👍

@SparkQA
Copy link

SparkQA commented Apr 27, 2015

Test build #31050 has started for PR 5081 at commit bf0e0e7.

  • This patch does not merge cleanly.

@andrewor14
Copy link
Contributor

@mengxr @MechCoder what is the status on this PR? It seems to fairly outdated at this point. Should we move forward or close it?

@MechCoder
Copy link
Contributor Author

Please do not. We just had a discussion about this yesterday.

@SparkQA
Copy link

SparkQA commented Jun 19, 2015

Test build #35250 has finished for PR 5081 at commit e6b4cc5.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@MechCoder
Copy link
Contributor Author

@mengxr Please have a look at #6904 This will help in ruling out some cases with minimum code repetition.

@SparkQA
Copy link

SparkQA commented Jun 19, 2015

Test build #35299 has finished for PR 5081 at commit 9d29561.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jun 19, 2015

Test build #35303 has finished for PR 5081 at commit 7f46d17.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@MechCoder
Copy link
Contributor Author

There seems to be a unrelated whitespace error in L30 in /spark/examples/src/main/scala/org/apache/spark/examples/DFSReadWriteTest.scala

@JoshRosen
Copy link
Contributor

Yep, we're fixing it now via a hotfix.

@andrewor14
Copy link
Contributor

should be fixed now. retest this please

@SparkQA
Copy link

SparkQA commented Jun 19, 2015

Test build #35305 has finished for PR 5081 at commit 7f46d17.

  • This patch fails MiMa tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@MechCoder MechCoder closed this Aug 13, 2015
@MechCoder MechCoder deleted the spark-6364 branch August 13, 2015 15:56
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.

6 participants