commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark R. Diggory" <>
Subject Re: [Math] Cloning statistics
Date Wed, 12 May 2004 03:30:04 GMT
Serialization interfaces were added to support (de)serialization 
(from)to file for persistence. Serialization actually uses the the 
methods outlined in the Java Tutorial

and is facilitated through the methods.

private void writeObject(ObjectOutputStream s) throws IOException;
private void readObject(ObjectInputStream s) throws IOException;

I believe this is quite independent of cloning. If I'm correct, 
implementing the clone method on these classes shouldn't effect 
serialization. But we should have consistent and comperable behavior for 
both cloning and serialization

You know, we might also consider that the default clone method on 
java.lang.Object returns a shallow copy. We should clarify the behavior 
of our cloning, especially in the case where trying to copy a complex 
network of objects.

I think we would be very interested in anything which would clarify the 
cloning behavior of Math library.


Ken Geis wrote:
> I'm playing with commons-math to implement a data mining algorithm and I 
> am having a performance problem.
> I am doing running statistics over an ordered set of data, storing the 
> statistics at each new value I come across.  One way of doing this would 
> be to have an array of SummaryStatistics and do
> for (int i = 0; i < length; i++)
> {
>     for (int j = i; j < length; j++)
>     {
>         statsArray[j].addValue(values[i]);
>     }
> }
> another way is to do
> for (int i = 0; i < length; i++)
> {
>     stats.addValue(values[i]);
>     statsArray[i] = SerializationUtils.clone(stats);
> }
> A lot of these objects are marked Serializable, but clone methods do not 
> exist.  That's why I use commons-lang SerializationUtils. Unfortunately, 
> that makes the cloning take up 50% of my runtime because 
> (de)serialization is expensive.
> I will probably patch the statistics classes, implementing enough of 
> clone() to make me happy.  Would you like this patch?
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Mark Diggory
Software Developer
Harvard MIT Data Center

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message