irvingc / dbscan-on-spark

An implementation of DBSCAN runing on top of Apache Spark
Apache License 2.0
183 stars 58 forks source link

ArrayIndexOutOfBoundsException: 1 if my vector has only one dimension #2

Closed invenis-paris closed 6 years ago

invenis-paris commented 8 years ago

When testing with a vector like (0, 0, 10, 10, 10, 0, 0) it fails. You try to take the "y" component which does not exist.

java.lang.ArrayIndexOutOfBoundsException: 1 at org.apache.spark.mllib.linalg.DenseVector.apply(Vectors.scala:597) at dbscan.DBSCANPoint.y(DBSCANPoint.scala:24) at dbscan.DBSCAN.dbscan$DBSCAN$$toMinimumBoundingRectangle(DBSCAN.scala:295) at dbscan.DBSCAN$$anonfun$3.apply(DBSCAN.scala:85) at dbscan.DBSCAN$$anonfun$3.apply(DBSCAN.scala:85) ...

BTW, does this library works with more than 2 dimensions ?

irvingc commented 8 years ago

Hi,

Sorry for the delay in answering. Thanks for reporting the issue! You are right, a better exception should be thrown instead of just the IndexOutOfBoundsException, since the library really expects 2 dimensions to work properly. Answering your question, only 2 dimensions are supported. Will write a fix in the upcoming days for this.

irvingc commented 6 years ago

closing this as a dup of #3. I am keeping #3 open because it has more discussion.