handle Lists and primitive array types
Project: http://git-wip-us.apache.org/repos/asf/storm/repo Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/17c74ce2 Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/17c74ce2 Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/17c74ce2 Branch: refs/heads/0.10.x-branch Commit: 17c74ce246e3f1f898dcbafa9e8605067c647c2e Parents: 10eb798 Author: Derek Dagit <der...@yahoo-inc.com> Authored: Wed Jul 22 12:17:39 2015 -0500 Committer: Jungtaek Lim <kabh...@gmail.com> Committed: Tue Aug 4 13:07:48 2015 +0900 ---------------------------------------------------------------------- .../storm/grouping/PartialKeyGrouping.java | 24 ++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/storm/blob/17c74ce2/storm-core/src/jvm/backtype/storm/grouping/PartialKeyGrouping.java ---------------------------------------------------------------------- diff --git a/storm-core/src/jvm/backtype/storm/grouping/PartialKeyGrouping.java b/storm-core/src/jvm/backtype/storm/grouping/PartialKeyGrouping.java index 456a8ef..43ad5a0 100644 --- a/storm-core/src/jvm/backtype/storm/grouping/PartialKeyGrouping.java +++ b/storm-core/src/jvm/backtype/storm/grouping/PartialKeyGrouping.java @@ -66,10 +66,30 @@ public class PartialKeyGrouping implements CustomStreamGrouping, Serializable { List<Object> selectedFields = outFields.select(fields, values); ByteBuffer out = ByteBuffer.allocate(selectedFields.size() * 4); for (Object o: selectedFields) { - if (o instanceof Object[]) { + if (o instanceof List) { + out.putInt(Arrays.deepHashCode(((List)o).toArray())); + } else if (o instanceof Object[]) { out.putInt(Arrays.deepHashCode((Object[])o)); - } else { + } else if (o instanceof byte[]) { + out.putInt(Arrays.hashCode((byte[]) o)); + } else if (o instanceof short[]) { + out.putInt(Arrays.hashCode((short[]) o)); + } else if (o instanceof int[]) { + out.putInt(Arrays.hashCode((int[]) o)); + } else if (o instanceof long[]) { + out.putInt(Arrays.hashCode((long[]) o)); + } else if (o instanceof char[]) { + out.putInt(Arrays.hashCode((char[]) o)); + } else if (o instanceof float[]) { + out.putInt(Arrays.hashCode((float[]) o)); + } else if (o instanceof double[]) { + out.putInt(Arrays.hashCode((double[]) o)); + } else if (o instanceof boolean[]) { + out.putInt(Arrays.hashCode((boolean[]) o)); + } else if (o != null) { out.putInt(o.hashCode()); + } else { + out.putInt(0); } } raw = out.array();