mahout-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Dunning <ted.dunn...@gmail.com>
Subject Re: ArrayIndexOutOfBoundsException SparseMatrix
Date Sun, 09 Sep 2012 19:07:49 GMT
You are using lots of threads but the sparse matrix structure is not thread
safe.  Setting a value in the SparseMatrix causes mutation to internal data
structures.

If you can have each thread do all the updates for a single thread, that
would be much better.  Another option is to synchronize on the matrix where
you call set.  Another option is synchronize on the row somehow.
 Synchronizing on row might give you the highest performance, but would be
slightly trickier to arrange and it would still include lots of uncontended
lock overhead.

Is multi-threading really what you want?  Why?  Does each value take a long
time to compute?

Can you use a lockless container to collect all of the values to insert and
insert them using a single thread?  This last is probably the fastest of
all of the options.

On Sun, Sep 9, 2012 at 11:29 AM, PEDRO MANUEL JIMENEZ RODRIGUEZ <
pmjimenez1983@hotmail.com> wrote:

>
> Hi all,
>
> I'm trying to set all values of a SparseMatrix structure using multiple
> threads but I'm getting an error of "ArrayIndexOutBoundsException" even
> when access indexes are correct. In fact, when I subtitude SparseMatrix
> structure for a double array I didn't get any error.
>
> Does any one have any idea what could be the problem?
>
> Error:
>      matrixK.set(
>                         index,
>                         j,
>                         Math.exp((-1 * (matrixD.get(index, j) *
> matrixD.get(
>                                 index, j))) / epsilon));
>
>
> No error:
>         matrixK[index][j] = Math.exp((-1 * (matrixD.get(index, j) *
> matrixD.get(
>                         index, j))) / epsilon);
>
> Thanks a lot.
>
> Pedro.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message