[ 
https://issues.apache.org/jira/browse/MAHOUT-65?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12727378#action_12727378
 ] 

M. Arshad Khan commented on MAHOUT-65:
--------------------------------------

Hi All

Looking at the implementation of clone method in SparseVector, it seems that 
the "name" field is not being copied to the new instance. As a result, for 
example, when the the "idField" parameter is passed to 
org.apache.mahout.util.vectors.Driver, the output does not contain any id 
field. A fix as follows solves the problem:

Index: core/src/main/java/org/apache/mahout/matrix/SparseVector.java
===================================================================
--- core/src/main/java/org/apache/mahout/matrix/SparseVector.java       
(revision 791354)
+++ core/src/main/java/org/apache/mahout/matrix/SparseVector.java       
(working copy)
@@ -73,6 +73,7 @@
   public SparseVector clone() {
     SparseVector result = like();
     result.values = (OrderedIntDoubleMapping) values.clone();
+    result.setName(this.name);
     return result;
   }

Not sure if other classes like SparseMatrix also require a similar fix. 
Comments?

Regards
Arshad


> Add Element Labels to Vectors and Matrices
> ------------------------------------------
>
>                 Key: MAHOUT-65
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-65
>             Project: Mahout
>          Issue Type: New Feature
>          Components: Matrix
>    Affects Versions: 0.1
>            Reporter: Jeff Eastman
>            Assignee: Jeff Eastman
>         Attachments: MAHOUT-65-name.patch, MAHOUT-65-name.patch, 
> MAHOUT-65-name.patch, MAHOUT-65.patch, MAHOUT-65b.patch, MAHOUT-65c.patch, 
> MAHOUT-65d.patch
>
>
> Many applications can benefit by accessing elements in vectors and matrices 
> using String labels in addition to numeric indices. Investigate adding such a 
> capability.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to