flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject flink git commit: [core] Use instanceof for equality check in Value types
Date Mon, 22 Jun 2015 12:02:52 GMT
Repository: flink
Updated Branches:
  refs/heads/master ab40e5d9a -> a42c641bf


[core] Use instanceof for equality check in Value types

This closes #850.


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

Branch: refs/heads/master
Commit: a42c641bf96b485c3b25ca4e21b0ac63b21797c2
Parents: ab40e5d
Author: Ufuk Celebi <uce@apache.org>
Authored: Mon Jun 22 14:01:43 2015 +0200
Committer: Ufuk Celebi <uce@apache.org>
Committed: Mon Jun 22 14:01:44 2015 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/flink/types/BooleanValue.java |  2 +-
 .../main/java/org/apache/flink/types/ByteValue.java    |  2 +-
 .../main/java/org/apache/flink/types/CharValue.java    |  2 +-
 .../main/java/org/apache/flink/types/DoubleValue.java  |  2 +-
 .../main/java/org/apache/flink/types/FloatValue.java   |  2 +-
 .../src/main/java/org/apache/flink/types/IntValue.java |  2 +-
 .../main/java/org/apache/flink/types/LongValue.java    |  2 +-
 .../main/java/org/apache/flink/types/ShortValue.java   |  2 +-
 .../main/java/org/apache/flink/types/StringValue.java  |  2 +-
 .../flink/runtime/io/disk/SpillingBufferTest.java      | 13 ++++++-------
 10 files changed, 15 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/a42c641b/flink-core/src/main/java/org/apache/flink/types/BooleanValue.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/types/BooleanValue.java b/flink-core/src/main/java/org/apache/flink/types/BooleanValue.java
index 5209a17..071e650 100644
--- a/flink-core/src/main/java/org/apache/flink/types/BooleanValue.java
+++ b/flink-core/src/main/java/org/apache/flink/types/BooleanValue.java
@@ -89,7 +89,7 @@ public class BooleanValue implements NormalizableKey<BooleanValue>,
ResettableVa
 	
 	@Override
 	public boolean equals(Object obj) {
-		if (obj != null && obj.getClass() == BooleanValue.class) {
+		if (obj instanceof BooleanValue) {
 			return ((BooleanValue) obj).value == this.value;
 		}
 		return false;

http://git-wip-us.apache.org/repos/asf/flink/blob/a42c641b/flink-core/src/main/java/org/apache/flink/types/ByteValue.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/types/ByteValue.java b/flink-core/src/main/java/org/apache/flink/types/ByteValue.java
index 10c2eda..c2f1f10 100644
--- a/flink-core/src/main/java/org/apache/flink/types/ByteValue.java
+++ b/flink-core/src/main/java/org/apache/flink/types/ByteValue.java
@@ -108,7 +108,7 @@ public class ByteValue implements NormalizableKey<ByteValue>, ResettableValue<By
 
 	@Override
 	public boolean equals(final Object obj) {
-		if (obj != null && obj.getClass() == ByteValue.class) {
+		if (obj instanceof ByteValue) {
 			return ((ByteValue) obj).value == this.value;
 		}
 		return false;

http://git-wip-us.apache.org/repos/asf/flink/blob/a42c641b/flink-core/src/main/java/org/apache/flink/types/CharValue.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/types/CharValue.java b/flink-core/src/main/java/org/apache/flink/types/CharValue.java
index 30e758e..3fd9f29 100644
--- a/flink-core/src/main/java/org/apache/flink/types/CharValue.java
+++ b/flink-core/src/main/java/org/apache/flink/types/CharValue.java
@@ -108,7 +108,7 @@ public class CharValue implements NormalizableKey<CharValue>, ResettableValue<Ch
 
 	@Override
 	public boolean equals(final Object obj) {
-		if (obj != null && obj.getClass() == CharValue.class) {
+		if (obj instanceof CharValue) {
 			return ((CharValue) obj).value == this.value;
 		}
 		return false;

http://git-wip-us.apache.org/repos/asf/flink/blob/a42c641b/flink-core/src/main/java/org/apache/flink/types/DoubleValue.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/types/DoubleValue.java b/flink-core/src/main/java/org/apache/flink/types/DoubleValue.java
index 0472fc8..abcbcf5 100644
--- a/flink-core/src/main/java/org/apache/flink/types/DoubleValue.java
+++ b/flink-core/src/main/java/org/apache/flink/types/DoubleValue.java
@@ -109,7 +109,7 @@ public class DoubleValue implements Key<DoubleValue>, ResettableValue<DoubleValu
 
 	@Override
 	public boolean equals(final Object obj) {
-		if (obj != null && obj.getClass() == DoubleValue.class) {
+		if (obj instanceof DoubleValue) {
 			final DoubleValue other = (DoubleValue) obj;
 			return Double.doubleToLongBits(this.value) == Double.doubleToLongBits(other.value);
 		}

http://git-wip-us.apache.org/repos/asf/flink/blob/a42c641b/flink-core/src/main/java/org/apache/flink/types/FloatValue.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/types/FloatValue.java b/flink-core/src/main/java/org/apache/flink/types/FloatValue.java
index 8026ac9..d57c74b 100644
--- a/flink-core/src/main/java/org/apache/flink/types/FloatValue.java
+++ b/flink-core/src/main/java/org/apache/flink/types/FloatValue.java
@@ -108,7 +108,7 @@ public class FloatValue implements Key<FloatValue>, ResettableValue<FloatValue>,
 
 	@Override
 	public boolean equals(final Object obj) {
-		if (obj != null && obj.getClass() == FloatValue.class) {
+		if (obj instanceof FloatValue) {
 			final FloatValue other = (FloatValue) obj;
 			return Float.floatToIntBits(this.value) == Float.floatToIntBits(other.value);
 		}

http://git-wip-us.apache.org/repos/asf/flink/blob/a42c641b/flink-core/src/main/java/org/apache/flink/types/IntValue.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/types/IntValue.java b/flink-core/src/main/java/org/apache/flink/types/IntValue.java
index 93f70ca..423c8c1 100644
--- a/flink-core/src/main/java/org/apache/flink/types/IntValue.java
+++ b/flink-core/src/main/java/org/apache/flink/types/IntValue.java
@@ -108,7 +108,7 @@ public class IntValue implements NormalizableKey<IntValue>, ResettableValue<IntV
 
 	@Override
 	public boolean equals(final Object obj) {
-		if (obj != null && obj.getClass() == IntValue.class) {
+		if (obj instanceof IntValue) {
 			return ((IntValue) obj).value == this.value;
 		}
 		return false;

http://git-wip-us.apache.org/repos/asf/flink/blob/a42c641b/flink-core/src/main/java/org/apache/flink/types/LongValue.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/types/LongValue.java b/flink-core/src/main/java/org/apache/flink/types/LongValue.java
index 981ba8f..e8fcd53 100644
--- a/flink-core/src/main/java/org/apache/flink/types/LongValue.java
+++ b/flink-core/src/main/java/org/apache/flink/types/LongValue.java
@@ -116,7 +116,7 @@ public class LongValue implements NormalizableKey<LongValue>, ResettableValue<Lo
 	 */
 	@Override
 	public boolean equals(final Object obj) {
-		if (obj != null && obj.getClass() == LongValue.class) {
+		if (obj instanceof LongValue) {
 			return ((LongValue) obj).value == this.value;
 		}
 		return false;

http://git-wip-us.apache.org/repos/asf/flink/blob/a42c641b/flink-core/src/main/java/org/apache/flink/types/ShortValue.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/types/ShortValue.java b/flink-core/src/main/java/org/apache/flink/types/ShortValue.java
index 8688b02..ec03497 100644
--- a/flink-core/src/main/java/org/apache/flink/types/ShortValue.java
+++ b/flink-core/src/main/java/org/apache/flink/types/ShortValue.java
@@ -108,7 +108,7 @@ public class ShortValue implements NormalizableKey<ShortValue>,
ResettableValue<
 
 	@Override
 	public boolean equals(final Object obj) {
-		if (obj != null && obj.getClass() == ShortValue.class) {
+		if (obj instanceof ShortValue) {
 			return ((ShortValue) obj).value == this.value;
 		}
 		return false;

http://git-wip-us.apache.org/repos/asf/flink/blob/a42c641b/flink-core/src/main/java/org/apache/flink/types/StringValue.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/types/StringValue.java b/flink-core/src/main/java/org/apache/flink/types/StringValue.java
index 8d4a878..db0f184 100644
--- a/flink-core/src/main/java/org/apache/flink/types/StringValue.java
+++ b/flink-core/src/main/java/org/apache/flink/types/StringValue.java
@@ -581,7 +581,7 @@ public class StringValue implements NormalizableKey<StringValue>,
CharSequence,
 			return true;
 		}
 		
-		if (obj != null && obj.getClass() == StringValue.class) {
+		if (obj instanceof StringValue) {
 			final StringValue other = (StringValue) obj;
 			int len = this.len;
 			

http://git-wip-us.apache.org/repos/asf/flink/blob/a42c641b/flink-runtime/src/test/java/org/apache/flink/runtime/io/disk/SpillingBufferTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/io/disk/SpillingBufferTest.java
b/flink-runtime/src/test/java/org/apache/flink/runtime/io/disk/SpillingBufferTest.java
index 22c40f6..6a9a20a 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/io/disk/SpillingBufferTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/io/disk/SpillingBufferTest.java
@@ -19,13 +19,8 @@
 
 package org.apache.flink.runtime.io.disk;
 
-import java.io.EOFException;
-import java.util.ArrayList;
-
-import org.junit.Assert;
 import org.apache.flink.core.memory.DataInputView;
 import org.apache.flink.core.memory.MemorySegment;
-import org.apache.flink.runtime.io.disk.SpillingBuffer;
 import org.apache.flink.runtime.io.disk.iomanager.IOManager;
 import org.apache.flink.runtime.io.disk.iomanager.IOManagerAsync;
 import org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable;
@@ -34,15 +29,19 @@ import org.apache.flink.runtime.memorymanager.ListMemorySegmentSource;
 import org.apache.flink.runtime.memorymanager.MemoryManager;
 import org.apache.flink.runtime.operators.testutils.DummyInvokable;
 import org.apache.flink.runtime.operators.testutils.TestData;
-import org.apache.flink.runtime.operators.testutils.TestData.Key;
-import org.apache.flink.runtime.operators.testutils.TestData.Value;
 import org.apache.flink.runtime.operators.testutils.TestData.Generator.KeyMode;
 import org.apache.flink.runtime.operators.testutils.TestData.Generator.ValueMode;
+import org.apache.flink.runtime.operators.testutils.TestData.Key;
+import org.apache.flink.runtime.operators.testutils.TestData.Value;
 import org.apache.flink.types.Record;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import java.io.EOFException;
+import java.util.ArrayList;
+
 
 public class SpillingBufferTest {
 	


Mime
View raw message