You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Joseph K. Bradley (JIRA)" <ji...@apache.org> on 2015/10/17 00:54:05 UTC

[jira] [Resolved] (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 ]

Joseph K. Bradley resolved SPARK-11084.
---------------------------------------
       Resolution: Fixed
    Fix Version/s: 1.6.0

Issue resolved by pull request 9098
[https://github.com/apache/spark/pull/9098]

> 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: Maciej Szymkiewicz
>            Priority: Minor
>             Fix For: 1.6.0
>
>
> 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