flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [1/6] flink git commit: [FLINK-3267] Disable reference tracking in Kryo fallback serializer
Date Mon, 25 Jan 2016 14:22:00 GMT
Repository: flink
Updated Branches:
  refs/heads/master 257f0b1e3 -> ed3810b12


[FLINK-3267] Disable reference tracking in Kryo fallback serializer

Before this commit, Kryo runs extra logic to track and resolve repeated references to
the same object (similar as JavaSerialization)

This disables reference tracking because
  - reference tracking is costly
  - it is virtually always unnecessary in the datatypes used in Flink
  - it is inconsistent with Flink's own serialization (which does not do reference tracking)
  - it may have problems if elements are read in a different order than they are written.

This closes #1528


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

Branch: refs/heads/master
Commit: ed3810b1282dfba80d63b1f43a0c202925a3b11c
Parents: 10eb16a
Author: Stephan Ewen <sewen@apache.org>
Authored: Wed Jan 20 16:26:58 2016 +0100
Committer: Stephan Ewen <sewen@apache.org>
Committed: Mon Jan 25 15:07:16 2016 +0100

----------------------------------------------------------------------
 .../api/java/typeutils/runtime/kryo/KryoSerializer.java   |  4 ++++
 .../runtime/kryo/KryoGenericTypeSerializerTest.java       | 10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/ed3810b1/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
index f1287fa..276ffc4 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
@@ -323,6 +323,10 @@ public class KryoSerializer<T> extends TypeSerializer<T>
{
 		if (this.kryo == null) {
 			this.kryo = getKryoInstance();
 
+			// disable reference tracking. reference tracking is costly, usually unnecessary, and
+			// inconsistent with Flink's own serialization (which does not do reference tracking)
+			kryo.setReferences(false);
+			
 			// Throwable and all subclasses should be serialized via java serialization
 			kryo.addDefaultSerializer(Throwable.class, new JavaSerializer());
 

http://git-wip-us.apache.org/repos/asf/flink/blob/ed3810b1/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
index 384657f..4b6e432 100644
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
+++ b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
@@ -20,6 +20,7 @@ package org.apache.flink.api.java.typeutils.runtime.kryo;
 
 import static org.junit.Assert.*;
 
+import com.esotericsoftware.kryo.Kryo;
 import org.apache.flink.api.common.ExecutionConfig;
 import org.apache.flink.api.common.typeutils.ComparatorTestBase;
 import org.apache.flink.api.java.typeutils.runtime.AbstractGenericTypeSerializerTest;
@@ -168,4 +169,11 @@ public class KryoGenericTypeSerializerTest extends AbstractGenericTypeSerializer
 			fail(e.getMessage());
 		}
 	}
-}
+
+	@Test
+	public void validateReferenceMappingDisabled() {
+		KryoSerializer<String> serializer = new KryoSerializer<>(String.class, new
ExecutionConfig());
+		Kryo kryo = serializer.getKryo();
+		assertFalse(kryo.getReferences());
+	}
+}
\ No newline at end of file


Mime
View raw message