kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guozh...@apache.org
Subject [kafka] branch trunk updated: KAFKA 6673: Implemented missing override equals method (#4745)
Date Wed, 09 May 2018 17:34:48 GMT
This is an automated email from the ASF dual-hosted git repository.

guozhang pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 5ca9ed5  KAFKA 6673: Implemented missing override equals method (#4745)
5ca9ed5 is described below

commit 5ca9ed5ede4f03cdef54cdbce70be3fdf052157d
Author: asutosh936 <asutosh.pandya@hotmail.com>
AuthorDate: Wed May 9 12:34:44 2018 -0500

    KAFKA 6673: Implemented missing override equals method (#4745)
    
    Reviewers: Guozhang Wang <guozhang@confluent.io>, Bill Bejeck <bill@confluent.io>
---
 .../streams/processor/internals/PunctuationSchedule.java | 10 ++++++++++
 .../kafka/streams/processor/internals/Stamped.java       | 16 ++++++++++++++++
 .../apache/kafka/streams/state/internals/Segment.java    | 14 ++++++++++++++
 3 files changed, 40 insertions(+)

diff --git a/streams/src/main/java/org/apache/kafka/streams/processor/internals/PunctuationSchedule.java
b/streams/src/main/java/org/apache/kafka/streams/processor/internals/PunctuationSchedule.java
index 9c0ec88..b222e4c 100644
--- a/streams/src/main/java/org/apache/kafka/streams/processor/internals/PunctuationSchedule.java
+++ b/streams/src/main/java/org/apache/kafka/streams/processor/internals/PunctuationSchedule.java
@@ -85,6 +85,16 @@ public class PunctuationSchedule extends Stamped<ProcessorNode> {
         return nextSchedule;
     }
 
+    @Override
+    public boolean equals(Object other) {
+        return super.equals(other);
+    }
+
+    @Override
+    public int hashCode() {
+        return super.hashCode();
+    }
+
     private static class RepointableCancellable implements Cancellable {
         private PunctuationSchedule schedule;
 
diff --git a/streams/src/main/java/org/apache/kafka/streams/processor/internals/Stamped.java
b/streams/src/main/java/org/apache/kafka/streams/processor/internals/Stamped.java
index 4965238..0d05265 100644
--- a/streams/src/main/java/org/apache/kafka/streams/processor/internals/Stamped.java
+++ b/streams/src/main/java/org/apache/kafka/streams/processor/internals/Stamped.java
@@ -16,6 +16,8 @@
  */
 package org.apache.kafka.streams.processor.internals;
 
+import java.util.Objects;
+
 public class Stamped<V> implements Comparable {
 
     public final V value;
@@ -34,4 +36,18 @@ public class Stamped<V> implements Comparable {
         else if (timestamp > otherTimestamp) return 1;
         return 0;
     }
+
+    @Override
+    public boolean equals(Object other) {
+
+        if (other == null || getClass() != other.getClass()) return false;
+
+        long otherTimestamp = ((Stamped<?>) other).timestamp;
+        return Long.compare(timestamp, otherTimestamp) == 0;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(timestamp);
+    }
 }
diff --git a/streams/src/main/java/org/apache/kafka/streams/state/internals/Segment.java b/streams/src/main/java/org/apache/kafka/streams/state/internals/Segment.java
index 7b2b803..dbe470e 100644
--- a/streams/src/main/java/org/apache/kafka/streams/state/internals/Segment.java
+++ b/streams/src/main/java/org/apache/kafka/streams/state/internals/Segment.java
@@ -20,6 +20,7 @@ import org.apache.kafka.common.utils.Utils;
 import org.apache.kafka.streams.processor.ProcessorContext;
 
 import java.io.IOException;
+import java.util.Objects;
 
 class Segment extends RocksDBStore implements Comparable<Segment> {
     public final long id;
@@ -48,4 +49,17 @@ class Segment extends RocksDBStore implements Comparable<Segment>
{
     public String toString() {
         return "Segment(id=" + id + ", name=" + name() + ")";
     }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null || getClass() != obj.getClass()) return false;
+
+        Segment segment = (Segment) obj;
+        return Long.compare(id, segment.id) == 0;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id);
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
guozhang@apache.org.

Mime
View raw message