Hi, there
As Kang Xiao indicated, the problem is the int hashcode overflow and index
is a negative value.
I compare CustomStreamGrouping with fieldsGrouping. In fieldsGrouping, it
computing the hashcode of the grouping fields list: ArrayList<Object>
values. Here is the code:
public int hashCode() {
int hashCode = 1;
for (E e : this)
hashCode = 31*hashCode + (e==null ? 0 : e.hashCode());
return hashCode;
}
I am wondering why this works fine? Won't the hashCode overflow this way?
Regards
2014-03-07 8:53 GMT+08:00 肖康(Kang Xiao) <[email protected]>:
> It maybe that hashcode and index is less than zero. You can add debug log
> to print the two vars to verify.
>
> --
> Best Regards!
> 肖康(Kang Xiao)
>
> 在 2014年3月6日星期四,22:51,James Xu 写道:
>
> What is _targetTasks is empty?
>
> On 2014年3月6日, at 下午10:28, 李家宏 <[email protected]> wrote:
>
> hi, all
> i'am using CustomStreamGrouping with very simple mod selection. it thrown
> IndexOutOfBoundsException. From the trace below:
>
> Caused by: java.lang.IndexOutOfBoundsException: null
> at clojure.lang.PersistentVector.arrayFor(PersistentVector.java:106)
> ~[clojure-1.4.0.jar:na]
> at clojure.lang.PersistentVector.nth(PersistentVector.java:110)
> ~[clojure-1.4.0.jar:na]
> at clojure.lang.APersistentVector.get(APersistentVector.java:167)
> ~[clojure-1.4.0.jar:na]
> at bolts.PingPongGrouping.chooseTasks(PingPongGrouping.java:37)
> ~[stormjar.jar:na]
>
> We locate the problem to the CustomStreamGrouping.chooseTasks() function
> which looks like:
>
> @Override
> public List<Integer> chooseTasks(int i, List<Object> values) {
> ArrayList<Integer> boltIds = new ArrayList<Integer>();
> if (values.size() > 0) {
> int hashcode = values.get(0).hashCode();
> int index = hashcode % _targetTasks.size();
> *boltIds.add( _targetTasks.get(index)); // here is the
> problem*
> } else {
> boltIds.add( _targetTasks.get(0));
> }
> return boltIds;
> }
>
> @Override
> public void prepare(WorkerTopologyContext context, GlobalStreamId
> streamId, List<Integer> targetTasks) {
> this._targetTasks = targetTasks;
> }
>
> How can it be out of bounds ?
>
> Regards
>
>
> --
>
> ======================================================
>
> Gvain
>
> Email: [email protected]
>
>
>
>
--
======================================================
Gvain
Email: [email protected]