[
https://issues.apache.org/jira/browse/MAHOUT-1155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13596800#comment-13596800
]
Ted Dunning commented on MAHOUT-1155:
-------------------------------------
In this patch fragment:
+ @Override
+ public Centroid clone() {
+ return new Centroid(super.clone());
+ }
Doesn't this double allocate? The Centroid(Vector) constructor is patched
thusly:
public Centroid(WeightedVector original) {
- super(original.getWeight(), original.getIndex());
- delegate = original.getVector().like();
- delegate.assign(original);
+ super(original.getVector().like().assign(original), original.getWeight(),
original.getIndex());
}
And this seems to allocate a new vector with the like(). That means that the
argument here which was cloned is now liked.
This is different from the WeightedVector case because the DelegatingVector
constructor only retains a reference rather than reallocate its argument.
Can the clone in Centroid just clone super and return it with a cast?
> Make MatrixSlice a Vector and fix Centroid cloning
> --------------------------------------------------
>
> Key: MAHOUT-1155
> URL: https://issues.apache.org/jira/browse/MAHOUT-1155
> Project: Mahout
> Issue Type: Improvement
> Components: Math
> Affects Versions: 0.8
> Reporter: Dan Filimon
> Priority: Minor
> Attachments: MAHOUT_1155.patch
>
>
> There are two changes in this issue:
> - making MatrixSlice a Vector by extending DelegatingVector;
> - making a few changes to the vector cloning code so that when cloning a
> Centroid, the result is also a Centroid.
> This is part of the changes in
> https://issues.apache.org/jira/browse/MAHOUT-1154
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira