You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by "zhonghongfei@yy.com" <zh...@yy.com> on 2015/05/21 09:30:23 UTC

some confuse about SSVD in class ABtDenseOutJob

I've run the SSVDCLI with "-q 1" parameter, but I've got an java.lang.ArrayIndexOutOfBoundsException. 

I found that it's because when it's not a dense vector, i is the index of an Vector.Element and this index is an item id,so it exceeds the vector size.
My question is if there is a bug in ABtDenseOutJob?

the following code is in ABtDenseOutJob --> ABtMapper --> map() : 

if (vec.isDense()) { 
for (int i = 0; i < vecSize; i++) { 
extendAColIfNeeded(i, aRowCount + 1); 
aCols[i].setQuick(aRowCount, vec.getQuick(i)); 
} 
} else if (vec.size() > 0) { 
for (Vector.Element vecEl : vec.nonZeroes()) { 
int i = vecEl.index(); // i is item id , so it will exceed the vec.size() usually, when extendAColIfNeeded(i, aRowCount + 1) is called it will get an error
extendAColIfNeeded(i, aRowCount + 1); 
aCols[i].setQuick(aRowCount, vecEl.get()); 
} 
}

So how to fix this proplem ?

Re:回复: Re:some confuse about SSVD in class ABtDenseOutJob

Posted by lastarsenal <la...@163.com>.
VectorWritable need to set a Vector instance. Vector is a abstract class, so you should know what is the real Vector class in details. for example, it may be RandomAccessSparseVector


the index() method return the itemID, it should NOT exceed vector size.

At 2015-05-21 18:01:23, "zhonghongfei@yy.com" <zh...@yy.com> wrote:
>hi  lastarsenal, thank you for your reply
>First of all, the input to ABtDenseOutJob is a rating matrix, where row key is item id and value is VectorWritable, I want to know if the input format is right or not ?
>And then if it's right, so definitely the code below :
>
>int i = vecEl.index();
>
>i will be the item id and it may larger than the vector size , so I think it's some kind of bug or I can't quite understand the orginal logic
>
>------------------------------------------------------------------------------------------------
>Hi, HongFei,
> 
> 
>   
>   You can print some variable like aRowCount, vecSize to check whey ArrayIndexOutOfBoundsException
> 
> 
> 
>At 2015-05-21 15:30:23, "zhonghongfei@yy.com" <zh...@yy.com> wrote:
>>I've run the SSVDCLI with "-q 1" parameter, but I've got an java.lang.ArrayIndexOutOfBoundsException. 
>>
>>I found that it's because when it's not a dense vector, i is the index of an Vector.Element and this index is an item id,so it exceeds the vector size.
>>My question is if there is a bug in ABtDenseOutJob?
>>
>>the following code is in ABtDenseOutJob --> ABtMapper --> map() : 
>>
>>if (vec.isDense()) { 
>>for (int i = 0; i < vecSize; i++) { 
>>extendAColIfNeeded(i, aRowCount + 1); 
>>aCols[i].setQuick(aRowCount, vec.getQuick(i)); 
>>} 
>>} else if (vec.size() > 0) { 
>>for (Vector.Element vecEl : vec.nonZeroes()) { 
>>int i = vecEl.index(); // i is item id , so it will exceed the vec.size() usually, when extendAColIfNeeded(i, aRowCount + 1) is called it will get an error
>>extendAColIfNeeded(i, aRowCount + 1); 
>>aCols[i].setQuick(aRowCount, vecEl.get()); 
>>} 
>>}
>>
>>So how to fix this proplem ?

回复: Re:some confuse about SSVD in class ABtDenseOutJob

Posted by "zhonghongfei@yy.com" <zh...@yy.com>.
hi  lastarsenal, thank you for your reply
First of all, the input to ABtDenseOutJob is a rating matrix, where row key is item id and value is VectorWritable, I want to know if the input format is right or not ?
And then if it's right, so definitely the code below :

int i = vecEl.index();

i will be the item id and it may larger than the vector size , so I think it's some kind of bug or I can't quite understand the orginal logic

------------------------------------------------------------------------------------------------
Hi, HongFei,
 
 
   
   You can print some variable like aRowCount, vecSize to check whey ArrayIndexOutOfBoundsException
 
 
 
At 2015-05-21 15:30:23, "zhonghongfei@yy.com" <zh...@yy.com> wrote:
>I've run the SSVDCLI with "-q 1" parameter, but I've got an java.lang.ArrayIndexOutOfBoundsException. 
>
>I found that it's because when it's not a dense vector, i is the index of an Vector.Element and this index is an item id,so it exceeds the vector size.
>My question is if there is a bug in ABtDenseOutJob?
>
>the following code is in ABtDenseOutJob --> ABtMapper --> map() : 
>
>if (vec.isDense()) { 
>for (int i = 0; i < vecSize; i++) { 
>extendAColIfNeeded(i, aRowCount + 1); 
>aCols[i].setQuick(aRowCount, vec.getQuick(i)); 
>} 
>} else if (vec.size() > 0) { 
>for (Vector.Element vecEl : vec.nonZeroes()) { 
>int i = vecEl.index(); // i is item id , so it will exceed the vec.size() usually, when extendAColIfNeeded(i, aRowCount + 1) is called it will get an error
>extendAColIfNeeded(i, aRowCount + 1); 
>aCols[i].setQuick(aRowCount, vecEl.get()); 
>} 
>}
>
>So how to fix this proplem ?

Re:some confuse about SSVD in class ABtDenseOutJob

Posted by lastarsenal <la...@163.com>.
Hi, HongFei,


   
   You can print some variable like aRowCount, vecSize to check whey ArrayIndexOutOfBoundsException



At 2015-05-21 15:30:23, "zhonghongfei@yy.com" <zh...@yy.com> wrote:
>I've run the SSVDCLI with "-q 1" parameter, but I've got an java.lang.ArrayIndexOutOfBoundsException. 
>
>I found that it's because when it's not a dense vector, i is the index of an Vector.Element and this index is an item id,so it exceeds the vector size.
>My question is if there is a bug in ABtDenseOutJob?
>
>the following code is in ABtDenseOutJob --> ABtMapper --> map() : 
>
>if (vec.isDense()) { 
>for (int i = 0; i < vecSize; i++) { 
>extendAColIfNeeded(i, aRowCount + 1); 
>aCols[i].setQuick(aRowCount, vec.getQuick(i)); 
>} 
>} else if (vec.size() > 0) { 
>for (Vector.Element vecEl : vec.nonZeroes()) { 
>int i = vecEl.index(); // i is item id , so it will exceed the vec.size() usually, when extendAColIfNeeded(i, aRowCount + 1) is called it will get an error
>extendAColIfNeeded(i, aRowCount + 1); 
>aCols[i].setQuick(aRowCount, vecEl.get()); 
>} 
>}
>
>So how to fix this proplem ?