You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (JIRA)" <ji...@apache.org> on 2015/10/13 14:43:05 UTC

[jira] [Assigned] (SPARK-11084) SparseVector.__getitem__ should check if value can be non-zero before executing searchsorted

     [ https://issues.apache.org/jira/browse/SPARK-11084?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Apache Spark reassigned SPARK-11084:
------------------------------------

    Assignee: Apache Spark

> SparseVector.__getitem__ should check if value can be non-zero before executing searchsorted
> --------------------------------------------------------------------------------------------
>
>                 Key: SPARK-11084
>                 URL: https://issues.apache.org/jira/browse/SPARK-11084
>             Project: Spark
>          Issue Type: Improvement
>          Components: MLlib, PySpark
>    Affects Versions: 1.3.0, 1.4.0, 1.5.0, 1.6.0
>            Reporter: Maciej Szymkiewicz
>            Assignee: Apache Spark
>            Priority: Minor
>
> At this moment SparseVector.\_\_getitem\_\_ executes np.searchsorted first and checks if result is in an expected range after that:
> {code}
> insert_index = np.searchsorted(inds, index)
> if insert_index >= inds.size:
>     return 0.
> row_ind = inds[insert_index]
> ...
> {code}
> See: https://issues.apache.org/jira/browse/SPARK-10973
> It is possible to check if index can contain non-zero value before binary search: 
> {code}
> if (inds.size == 0) or (index > inds.item(-1)):
>     return 0.
> insert_index = np.searchsorted(inds, index)
> row_ind = inds[insert_index]
> ...
> {code}
> It is not a huge improvement but should save some work on large vectors.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org