You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@storm.apache.org by "Jackson, Aubrey" <au...@here.com> on 2016/10/10 15:36:02 UTC

Fields Grouping Calculation

Hello,

I’ve tried to use the information below to generate the hash, mod it, and in turn calculate the correct consuming destination task index, but without success. I’ve scoured the Internet where someone as an example of a hand calculation of this nature and have turned up empty. I must be missing something in my hand calc, so I’m hoping someone on the list can help me out.

I have field grouped as follows:

.fieldsGrouping(EXAMPLE_BOLT, EXAMPLE_BOLT_STREAM, new Fields(TopologyConstants.EXAMPLE_FIELD_GROUPING_ID))

My EXAMPLE_BOLT emits as shown here:

collector.emit(TopologyConstants.EXAMPLE_BOLT_STREAM, new Values(EXAMPLE_FIELD_GROUPING_ID_VALUE, EXAMPLE_DATA_INSTANCE));

I preform the calculation as follows:

int numberOfConsumingTasks = x;
Integer EXAMPLE_FIELD_GROUPING_ID_VALUE = y;

ArrayList<Object> alist = new ArrayList<>();

alist.add(EXAMPLE_FIELD_GROUPING_ID_VALUE);

int hashCode = Arrays.deepHashCode(alist.toArray());

int targetTaskIndex = Math.abs(hashCode) % numberOfConsumingTasks;

The resulting targetTaskIndex value from this calculation does not match the value produced by Storm.

Can someone tell me what I’m doing wrong?

Thanks,


Aubrey