You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by ka...@apache.org on 2015/07/23 01:39:47 UTC

[4/7] storm git commit: handle Lists and primitive array types

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/639f6a78
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/639f6a78
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/639f6a78

Branch: refs/heads/master
Commit: 639f6a78cb1fc462590d9fe9c0fd7bbbd959505c
Parents: 70cdda2
Author: Derek Dagit <de...@yahoo-inc.com>
Authored: Wed Jul 22 12:17:39 2015 -0500
Committer: Derek Dagit <de...@yahoo-inc.com>
Committed: Wed Jul 22 12:17:39 2015 -0500

----------------------------------------------------------------------
 .../storm/grouping/PartialKeyGrouping.java      | 24 ++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/639f6a78/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();