kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guozh...@apache.org
Subject kafka git commit: MINOR: add equals and hashCode to Windowed
Date Tue, 26 Jan 2016 00:22:35 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 30d3cc631 -> 942074b77


MINOR: add equals and hashCode to Windowed

guozhangwang

Author: Yasuhiro Matsuda <yasuhiro@confluent.io>

Reviewers: Guozhang Wang

Closes #808 from ymatsuda/windowed_key


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/942074b7
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/942074b7
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/942074b7

Branch: refs/heads/trunk
Commit: 942074b77b1b1162acdd1bf7a3ee299bd0113886
Parents: 30d3cc6
Author: Yasuhiro Matsuda <yasuhiro@confluent.io>
Authored: Mon Jan 25 16:22:32 2016 -0800
Committer: Guozhang Wang <wangguoz@gmail.com>
Committed: Mon Jan 25 16:22:32 2016 -0800

----------------------------------------------------------------------
 .../apache/kafka/streams/kstream/Windowed.java   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/942074b7/streams/src/main/java/org/apache/kafka/streams/kstream/Windowed.java
----------------------------------------------------------------------
diff --git a/streams/src/main/java/org/apache/kafka/streams/kstream/Windowed.java b/streams/src/main/java/org/apache/kafka/streams/kstream/Windowed.java
index 10afc73..845f9e9 100644
--- a/streams/src/main/java/org/apache/kafka/streams/kstream/Windowed.java
+++ b/streams/src/main/java/org/apache/kafka/streams/kstream/Windowed.java
@@ -40,4 +40,23 @@ public class Windowed<T> {
     public String toString() {
         return "[" + value + "@" + window.start() + "]";
     }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this)
+            return true;
+
+        if (!(obj instanceof Windowed))
+            return false;
+
+        Windowed<?> that = (Windowed) obj;
+
+        return this.window.equals(that.window) && this.value.equals(that.value);
+    }
+
+    @Override
+    public int hashCode() {
+        long n = ((long) window.hashCode() << 32) | value.hashCode();
+        return (int) (n % 0xFFFFFFFFL);
+    }
 }


Mime
View raw message