You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by gr...@apache.org on 2017/07/26 14:32:09 UTC

[4/5] flink git commit: [FLINK-6648] [gelly] Transforms for Gelly examples

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/transform/Transform.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/transform/Transform.java b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/transform/Transform.java
new file mode 100644
index 0000000..7d65cbb
--- /dev/null
+++ b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/transform/Transform.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.graph.drivers.transform;
+
+import org.apache.flink.graph.drivers.parameter.Parameterized;
+
+/**
+ * A transform is executed both before and after algorithm execution. Multiple
+ * transforms may be applied and the order of execution is as listed by the
+ * input then algorithm components. The input is transformed in given order and
+ * the algorithm result is transformed in reverse order.
+ *
+ * @param <II> input transformation input type
+ * @param <IO> input transformation output type
+ * @param <RI> result transformation input type
+ * @param <RO> input transformation output type
+ */
+public interface Transform<II, IO, RI, RO>
+extends Parameterized {
+
+	/**
+	 * A human-readable identifier summarizing the transform and configuration.
+	 *
+	 * @return the transform identifier
+	 */
+	String getIdentity();
+
+	/**
+	 * Apply the forward transformation to the input graph.
+	 *
+	 * @param input transformation input
+	 * @return transformation output
+	 * @throws Exception
+	 */
+	IO transformInput(II input) throws Exception;
+
+	/**
+	 * Apply the reverse transformation to the algorithm result.
+	 *
+	 * @param result transformation input
+	 * @return transformation output
+	 * @throws Exception
+	 */
+	RO transformResult(RI result) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/transform/Transformable.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/transform/Transformable.java b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/transform/Transformable.java
new file mode 100644
index 0000000..d60f043
--- /dev/null
+++ b/flink-libraries/flink-gelly-examples/src/main/java/org/apache/flink/graph/drivers/transform/Transformable.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.flink.graph.drivers.transform;
+
+import java.util.List;
+
+/**
+ * A transformable input or algorithm returns a list of {@link Transform} to be
+ * applied before and after execution of the algorithm.
+ */
+public interface Transformable {
+
+	/**
+	 * Get the list of transforms.
+	 *
+	 * @return the list of transforms
+	 */
+	List<Transform> getTransformers();
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/AdamicAdarITCase.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/AdamicAdarITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/AdamicAdarITCase.java
index c36dcb5..b048f08 100644
--- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/AdamicAdarITCase.java
+++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/AdamicAdarITCase.java
@@ -39,7 +39,7 @@ extends CopyableValueDriverBaseITCase {
 
 	private String[] parameters(int scale, String output, String... additionalParameters) {
 		String[] parameters = new String[] {
-			"--algorithm", "AdamicAdar",
+			"--algorithm", "AdamicAdar", "--mirror_results",
 			"--input", "RMatGraph", "--scale", Integer.toString(scale), "--type", idType, "--simplify", "undirected",
 			"--output", output};
 
@@ -63,6 +63,6 @@ extends CopyableValueDriverBaseITCase {
 
 		expectedCount(
 			parameters(7, "print"),
-			5694);
+			11388);
 	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/ClusteringCoefficientITCase.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/ClusteringCoefficientITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/ClusteringCoefficientITCase.java
index ce8cb3b..6bcab6b 100644
--- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/ClusteringCoefficientITCase.java
+++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/ClusteringCoefficientITCase.java
@@ -56,29 +56,8 @@ extends CopyableValueDriverBaseITCase {
 
 	@Test
 	public void testHashWithSmallDirectedRMatGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "short":
-			case "char":
-			case "integer":
-				checksum = 0x0000003621c62ca1L;
-				break;
-
-			case "long":
-				checksum = 0x0000003b74c6719bL;
-				break;
-
-			case "string":
-				checksum = 0x0000003ab67abea8L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		String expected = "\n" +
-			new Checksum(117, checksum) + "\n" +
+			new Checksum(117, 0x0000003621c62ca1L) + "\n\n" +
 			"triplet count: 29286, triangle count: 11466, global clustering coefficient: 0.39151813[0-9]+\n" +
 			"vertex count: 117, average clustering coefficient: 0.45125697[0-9]+\n";
 
@@ -87,39 +66,14 @@ extends CopyableValueDriverBaseITCase {
 
 	@Test
 	public void testHashWithSmallUndirectedRMatGraph() throws Exception {
-		long directedChecksum;
-		long undirectedChecksum;
-		switch (idType) {
-			case "byte":
-			case "short":
-			case "char":
-			case "integer":
-				directedChecksum = 0x0000003875b38c43L;
-				undirectedChecksum = 0x0000003c20344c75L;
-				break;
-
-			case "long":
-				directedChecksum = 0x0000003671970c59L;
-				undirectedChecksum = 0x0000003939645d8cL;
-				break;
-
-			case "string":
-				directedChecksum = 0x0000003be109a770L;
-				undirectedChecksum = 0x0000003b8c98d14aL;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
-		String expected = "\n" +
+		String expected = "\n\n" +
 			"triplet count: 29286, triangle count: 11466, global clustering coefficient: 0.39151813[0-9]+\n" +
 			"vertex count: 117, average clustering coefficient: 0.57438679[0-9]+\n";
 
 		expectedOutput(parameters(7, "directed", "undirected", "hash"),
-			"\n" + new Checksum(117, directedChecksum) + expected);
+			"\n" + new Checksum(117, 0x0000003875b38c43L) + expected);
 		expectedOutput(parameters(7, "undirected", "undirected", "hash"),
-			"\n" + new Checksum(117, undirectedChecksum) + expected);
+			"\n" + new Checksum(117, 0x0000003c20344c75L) + expected);
 	}
 
 	@Test
@@ -127,31 +81,11 @@ extends CopyableValueDriverBaseITCase {
 		// computation is too large for collection mode
 		Assume.assumeFalse(mode == TestExecutionMode.COLLECTION);
 
-		long checksum;
-		switch (idType) {
-			case "byte":
-				return;
-
-			case "short":
-			case "char":
-			case "integer":
-				checksum = 0x0000067a9d18e7f3L;
-				break;
-
-			case "long":
-				checksum = 0x00000694a90ee6d4L;
-				break;
-
-			case "string":
-				checksum = 0x000006893e3b314fL;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
+		// skip 'byte' which cannot store vertex IDs for scale > 8
+		Assume.assumeFalse(idType.equals("byte") || idType.equals("nativeByte"));
 
 		String expected = "\n" +
-			new Checksum(3349, checksum) + "\n" +
+			new Checksum(3349, 0x0000067a9d18e7f3L) + "\n\n" +
 			"triplet count: 9276207, triangle count: 1439454, global clustering coefficient: 0.15517700[0-9]+\n" +
 			"vertex count: 3349, average clustering coefficient: 0.24571815[0-9]+\n";
 
@@ -163,40 +97,16 @@ extends CopyableValueDriverBaseITCase {
 		// computation is too large for collection mode
 		Assume.assumeFalse(mode == TestExecutionMode.COLLECTION);
 
-		long directedChecksum;
-		long undirectedChecksum;
-		switch (idType) {
-			case "byte":
-				return;
-
-			case "short":
-			case "char":
-			case "integer":
-				directedChecksum = 0x00000681fad1587eL;
-				undirectedChecksum = 0x0000068713b3b7f1L;
-				break;
-
-			case "long":
-				directedChecksum = 0x000006928a6301b1L;
-				undirectedChecksum = 0x000006a399edf0e6L;
-				break;
-
-			case "string":
-				directedChecksum = 0x000006749670a2f7L;
-				undirectedChecksum = 0x0000067f19c6c4d5L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
+		// skip 'byte' which cannot store vertex IDs for scale > 8
+		Assume.assumeFalse(idType.equals("byte") || idType.equals("nativeByte"));
 
-		String expected = "\n" +
+		String expected = "\n\n" +
 			"triplet count: 9276207, triangle count: 1439454, global clustering coefficient: 0.15517700[0-9]+\n" +
 			"vertex count: 3349, average clustering coefficient: 0.33029442[0-9]+\n";
 
 		expectedOutput(parameters(12, "directed", "undirected", "hash"),
-			"\n" + new Checksum(3349, directedChecksum) + expected);
+			"\n" + new Checksum(3349, 0x00000681fad1587eL) + expected);
 		expectedOutput(parameters(12, "undirected", "undirected", "hash"),
-			"\n" + new Checksum(3349, undirectedChecksum) + expected);
+			"\n" + new Checksum(3349, 0x0000068713b3b7f1L) + expected);
 	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/ConnectedComponentsITCase.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/ConnectedComponentsITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/ConnectedComponentsITCase.java
index cbb5c9d..d6913c4 100644
--- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/ConnectedComponentsITCase.java
+++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/ConnectedComponentsITCase.java
@@ -31,7 +31,7 @@ import org.junit.runners.Parameterized;
  */
 @RunWith(Parameterized.class)
 public class ConnectedComponentsITCase
-extends DriverBaseITCase {
+extends NonTransformableDriverBaseITCase {
 
 	public ConnectedComponentsITCase(String idType, TestExecutionMode mode) {
 		super(idType, mode);
@@ -57,34 +57,7 @@ extends DriverBaseITCase {
 
 	@Test
 	public void testHashWithSmallRMatGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x0000000000033e88L;
-				break;
-
-			case "long":
-				checksum = 0x0000000000057848L;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x000000000254a4c3L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
-		expectedChecksum(parameters(7, "hash"), 106, checksum);
+		expectedChecksum(parameters(7, "hash"), 106, 0x0000000000033e88L);
 	}
 
 	@Test
@@ -92,36 +65,10 @@ extends DriverBaseITCase {
 		// computation is too large for collection mode
 		Assume.assumeFalse(mode == TestExecutionMode.COLLECTION);
 
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-				return;
-
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x00000003094ffba2L;
-				break;
-
-			case "long":
-				checksum = 0x000000030b68e522L;
-				break;
+		// skip 'byte' which cannot store vertex IDs for scale > 8
+		Assume.assumeFalse(idType.equals("byte") || idType.equals("nativeByte"));
 
-			case "string":
-			case "nativeString":
-				checksum = 0x00001839ad14edb1L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
-		expectedChecksum(parameters(15, "hash"), 25572, checksum);
+		expectedChecksum(parameters(15, "hash"), 25572, 0x00000003094ffba2L);
 	}
 
 	@Test
@@ -129,28 +76,6 @@ extends DriverBaseITCase {
 		// skip 'char' since it is not printed as a number
 		Assume.assumeFalse(idType.equals("char") || idType.equals("nativeChar"));
 
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "integer":
-			case "nativeInteger":
-			case "long":
-			case "nativeLong":
-				checksum = 0x00000024edd0568dL;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x000000232d8bf58dL;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
-		expectedOutputChecksum(parameters(7, "print"), new Checksum(106, checksum));
+		expectedOutputChecksum(parameters(7, "print"), new Checksum(106, 0x00000024edd0568dL));
 	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/CopyableValueDriverBaseITCase.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/CopyableValueDriverBaseITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/CopyableValueDriverBaseITCase.java
index bc09820..b01fd88 100644
--- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/CopyableValueDriverBaseITCase.java
+++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/CopyableValueDriverBaseITCase.java
@@ -41,7 +41,7 @@ extends DriverBaseITCase {
 	public static Collection<Object[]> executionModes() {
 		List<Object[]> executionModes = new ArrayList<>();
 
-		for (String idType : new String[] {"byte", "short", "char", "integer", "long", "string"}) {
+		for (String idType : new String[] {"byte", "short", "char", "integer", "long", "float", "double", "string"}) {
 			for (TestExecutionMode executionMode : TestExecutionMode.values()) {
 				executionModes.add(new Object[] {idType, executionMode});
 			}

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/DriverBaseITCase.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/DriverBaseITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/DriverBaseITCase.java
index 670968c..749998d 100644
--- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/DriverBaseITCase.java
+++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/DriverBaseITCase.java
@@ -61,7 +61,8 @@ extends MultipleProgramsTestBase {
 		List<Object[]> executionModes = new ArrayList<>();
 
 		for (String idType : new String[] {"byte", "nativeByte", "short", "nativeShort", "char", "nativeChar",
-								"integer", "nativeInteger", "long", "nativeLong", "string", "nativeString"}) {
+				"integer", "nativeInteger", "long", "nativeLong", "float", "nativeFloat", "double", "nativeDouble",
+				"string", "nativeString"}) {
 			for (TestExecutionMode executionMode : TestExecutionMode.values()) {
 				executionModes.add(new Object[] {idType, executionMode});
 			}

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/EdgeListITCase.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/EdgeListITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/EdgeListITCase.java
index a56a19b..2f8eb0d 100644
--- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/EdgeListITCase.java
+++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/EdgeListITCase.java
@@ -32,7 +32,7 @@ import org.junit.runners.Parameterized;
  */
 @RunWith(Parameterized.class)
 public class EdgeListITCase
-extends DriverBaseITCase {
+extends NonTransformableDriverBaseITCase {
 
 	public EdgeListITCase(String idType, TestExecutionMode mode) {
 		super(idType, mode);
@@ -48,37 +48,20 @@ extends DriverBaseITCase {
 	}
 
 	@Test
-	public void testHashWithCirculantGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x000000000001ae80L;
-				break;
-
-			case "long":
-				checksum = 0x0000000000053580L;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x0000000000656880L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
+	public void testLongDescription() throws Exception {
+		String expected = regexSubstring(new EdgeList().getLongDescription());
+
+		expectedOutputFromException(
+			new String[]{"--algorithm", "EdgeList"},
+			expected,
+			ProgramParametrizationException.class);
+	}
 
+	@Test
+	public void testHashWithCirculantGraph() throws Exception {
 		expectedChecksum(
 			parameters("CirculantGraph", "hash", "--vertex_count", "42", "--range0", "13:4"),
-			168, checksum);
+			168, 0x000000000001ae80);
 	}
 
 	@Test
@@ -92,47 +75,10 @@ extends DriverBaseITCase {
 	}
 
 	@Test
-	public void testLongDescription() throws Exception {
-		String expected = regexSubstring(new EdgeList().getLongDescription());
-
-		expectedOutputFromException(
-			new String[]{"--algorithm", "EdgeList"},
-			expected,
-			ProgramParametrizationException.class);
-	}
-
-	@Test
 	public void testHashWithCompleteGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x0000000000113ca0L;
-				break;
-
-			case "long":
-				checksum = 0x0000000000356460L;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x00000000040f6f20L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		expectedChecksum(
 			parameters("CompleteGraph", "hash", "--vertex_count", "42"),
-			1722, checksum);
+			1722, 0x0000000000113ca0L);
 	}
 
 	@Test
@@ -147,36 +93,9 @@ extends DriverBaseITCase {
 
 	@Test
 	public void testHashWithCycleGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x000000000000d740L;
-				break;
-
-			case "long":
-				checksum = 0x0000000000029ac0L;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x000000000032b440L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		expectedChecksum(
 			parameters("CycleGraph", "hash", "--vertex_count", "42"),
-			84, checksum);
+			84, 0x000000000000d740L);
 	}
 
 	@Test
@@ -191,36 +110,9 @@ extends DriverBaseITCase {
 
 	@Test
 	public void testHashWithEchoGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x0000000000057720L;
-				break;
-
-			case "long":
-				checksum = 0x000000000010ede0L;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x00000000014993a0L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		expectedChecksum(
 			parameters("EchoGraph", "hash", "--vertex_count", "42", "--vertex_degree", "13"),
-			546, checksum);
+			546, 0x0000000000057720L);
 	}
 
 	@Test
@@ -242,36 +134,9 @@ extends DriverBaseITCase {
 
 	@Test
 	public void testHashWithGridGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x000000000000eba0L;
-				break;
-
-			case "long":
-				checksum = 0x000000000003a660L;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x0000000000430ee0L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		expectedChecksum(
 			parameters("GridGraph", "hash", "--dim0", "2:true", "--dim1", "3:false", "--dim2", "5:true"),
-			130, checksum);
+			130, 0x000000000000eba0L);
 	}
 
 	@Test
@@ -286,36 +151,9 @@ extends DriverBaseITCase {
 
 	@Test
 	public void testHashWithHypercubeGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x00000000001bc800L;
-				break;
-
-			case "long":
-				checksum = 0x00000000002e9800L;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x00000000143c1500L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		expectedChecksum(
 			parameters("HypercubeGraph", "hash", "--dimensions", "7"),
-			896, checksum);
+			896, 0x00000000001bc800L);
 	}
 
 	@Test
@@ -330,36 +168,9 @@ extends DriverBaseITCase {
 
 	@Test
 	public void testHashWithPathGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x000000000000d220L;
-				break;
-
-			case "long":
-				checksum = 0x0000000000028ae0L;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x000000000031dea0L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		expectedChecksum(
 			parameters("PathGraph", "hash", "--vertex_count", "42"),
-			82, checksum);
+			82, 0x000000000000d220L);
 	}
 
 	@Test
@@ -374,36 +185,9 @@ extends DriverBaseITCase {
 
 	@Test
 	public void testHashWithRMatGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x00000000001ee529L;
-				break;
-
-			case "long":
-				checksum = 0x000000000049e529L;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x000000000b8c9aa3L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		expectedChecksum(
 			parameters("RMatGraph", "hash", "--scale", "7"),
-			2048, checksum);
+			2048, 0x00000000001ee529);
 	}
 
 	@Test
@@ -418,36 +202,9 @@ extends DriverBaseITCase {
 
 	@Test
 	public void testHashWithDirectedRMatGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x00000000001579bdL;
-				break;
-
-			case "long":
-				checksum = 0x00000000002dffbdL;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x0000000009213f1fL;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		expectedChecksum(
 			parameters("RMatGraph", "hash", "--scale", "7", "--simplify", "directed"),
-			1168, checksum);
+			1168, 0x00000000001579bdL);
 	}
 
 	@Test
@@ -462,36 +219,9 @@ extends DriverBaseITCase {
 
 	@Test
 	public void testHashWithUndirectedRMatGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x0000000000242920L;
-				break;
-
-			case "long":
-				checksum = 0x00000000004b1660L;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x000000000fcbc080L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		expectedChecksum(
 			parameters("RMatGraph", "hash", "--scale", "7", "--simplify", "undirected"),
-			1854, checksum);
+			1854, 0x0000000000242920L);
 	}
 
 	@Test
@@ -506,36 +236,9 @@ extends DriverBaseITCase {
 
 	@Test
 	public void testHashWithSingletonEdgeGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x000000000001b3c0L;
-				break;
-
-			case "long":
-				checksum = 0x0000000000037740L;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x00000000003ca2c0L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		expectedChecksum(
 			parameters("SingletonEdgeGraph", "hash", "--vertex_pair_count", "42"),
-			84, checksum);
+			84, 0x000000000001b3c0L);
 	}
 
 	@Test
@@ -550,36 +253,9 @@ extends DriverBaseITCase {
 
 	@Test
 	public void testHashWithStarGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "nativeByte":
-			case "short":
-			case "nativeShort":
-			case "char":
-			case "nativeChar":
-			case "integer":
-			case "nativeInteger":
-			case "nativeLong":
-				checksum = 0x0000000000006ba0L;
-				break;
-
-			case "long":
-				checksum = 0x0000000000022460L;
-				break;
-
-			case "string":
-			case "nativeString":
-				checksum = 0x00000000001a4a20L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		expectedChecksum(
 			parameters("StarGraph", "hash", "--vertex_count", "42"),
-			82, checksum);
+			82, 0x0000000000006ba0L);
 	}
 
 	@Test

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/JaccardIndexITCase.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/JaccardIndexITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/JaccardIndexITCase.java
index a8b0111..25eec22 100644
--- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/JaccardIndexITCase.java
+++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/JaccardIndexITCase.java
@@ -59,28 +59,7 @@ extends CopyableValueDriverBaseITCase {
 
 	@Test
 	public void testHashWithSmallRMatGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "short":
-			case "char":
-			case "integer":
-				checksum = 0x0000164757052eebL;
-				break;
-
-			case "long":
-				checksum = 0x000016337a6a7270L;
-				break;
-
-			case "string":
-				checksum = 0x00001622a522a290L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
-		expectedChecksum(parameters(7, "hash"), 11388, checksum);
+		expectedChecksum(parameters(7, "hash"), 11388, 0x0000164757052eebL);
 	}
 
 	@Test
@@ -88,30 +67,10 @@ extends CopyableValueDriverBaseITCase {
 		// computation is too large for collection mode
 		Assume.assumeFalse(mode == TestExecutionMode.COLLECTION);
 
-		long checksum;
-		switch (idType) {
-			case "byte":
-				return;
-
-			case "short":
-			case "char":
-			case "integer":
-				checksum = 0x0021ce158d811c4eL;
-				break;
-
-			case "long":
-				checksum = 0x0021d20fb3904720L;
-				break;
-
-			case "string":
-				checksum = 0x0021cd8fafec1524L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
+		// skip 'byte' which cannot store vertex IDs for scale > 8
+		Assume.assumeFalse(idType.equals("byte") || idType.equals("nativeByte"));
 
-		expectedChecksum(parameters(12, "hash"), 4432058, checksum);
+		expectedChecksum(parameters(12, "hash"), 4432058, 0x0021ce158d811c4eL);
 	}
 
 	@Test

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/NonTransformableDriverBaseITCase.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/NonTransformableDriverBaseITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/NonTransformableDriverBaseITCase.java
new file mode 100644
index 0000000..2238a35
--- /dev/null
+++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/NonTransformableDriverBaseITCase.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.flink.graph.drivers;
+
+import org.junit.runners.Parameterized;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Base class for drivers requiring the key ID to hash to the same value
+ * without transformation of the algorithm result to a common output type. This
+ * class overrides {@link DriverBaseITCase} to restrict the tested ID types.
+ */
+public abstract class NonTransformableDriverBaseITCase
+extends DriverBaseITCase {
+
+	protected NonTransformableDriverBaseITCase(String idType, TestExecutionMode mode) {
+		super(idType, mode);
+	}
+
+	// limit tests to types using a proper and consistent hashCode
+	@Parameterized.Parameters(name = "ID type = {0}, Execution mode = {1}")
+	public static Collection<Object[]> executionModes() {
+		List<Object[]> executionModes = new ArrayList<>();
+
+		for (String idType : new String[] {"byte", "nativeByte", "short", "nativeShort", "char", "nativeChar",
+			"integer", "nativeInteger", "nativeLong"}) {
+			for (TestExecutionMode executionMode : TestExecutionMode.values()) {
+				executionModes.add(new Object[] {idType, executionMode});
+			}
+		}
+
+		return executionModes;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/TriangleListingITCase.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/TriangleListingITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/TriangleListingITCase.java
index c691922..687610e 100644
--- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/TriangleListingITCase.java
+++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/TriangleListingITCase.java
@@ -40,7 +40,7 @@ extends CopyableValueDriverBaseITCase {
 
 	private String[] parameters(int scale, String order, String output) {
 		String[] parameters =  new String[] {
-			"--algorithm", "TriangleListing", "--order", order,
+			"--algorithm", "TriangleListing", "--order", order, "--permute_results",
 			"--input", "RMatGraph", "--scale", Integer.toString(scale), "--type", idType, "--simplify", order,
 			"--output", output};
 
@@ -63,29 +63,8 @@ extends CopyableValueDriverBaseITCase {
 
 	@Test
 	public void testHashWithSmallDirectedRMatGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "short":
-			case "char":
-			case "integer":
-				checksum = 0x00000784d2c336cdL;
-				break;
-
-			case "long":
-				checksum = 0x0000078e5ebf2927L;
-				break;
-
-			case "string":
-				checksum = 0x0000077eddf67481L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		String expected = "\n" +
-			new Checksum(3822, checksum) + "\n" +
+			new Checksum(22932, 0x00002cdfb573650dL) + "\n\n" +
 			"Triadic census:\n" +
 			"  003: 178,989\n" +
 			"  012: 47,736\n" +
@@ -109,29 +88,8 @@ extends CopyableValueDriverBaseITCase {
 
 	@Test
 	public void testHashWithSmallUndirectedRMatGraph() throws Exception {
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "short":
-			case "char":
-			case "integer":
-				checksum = 0x0000075b6b9a0ad0L;
-				break;
-
-			case "long":
-				checksum = 0x00000761619e7f3cL;
-				break;
-
-			case "string":
-				checksum = 0x0000079b15eb30acL;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
 		String expected = "\n" +
-			new Checksum(3822, checksum) + "\n" +
+			new Checksum(22932, 0x00002c7fb95ec78eL) + "\n\n" +
 			"Triadic census:\n" +
 			"  03: 178,989\n" +
 			"  12: 59,499\n" +
@@ -146,31 +104,11 @@ extends CopyableValueDriverBaseITCase {
 		// computation is too large for collection mode
 		Assume.assumeFalse(mode == TestExecutionMode.COLLECTION);
 
-		long checksum;
-		switch (idType) {
-			case "byte":
-				return;
-
-			case "short":
-			case "char":
-			case "integer":
-				checksum = 0x0003a986d6bedc53L;
-				break;
-
-			case "long":
-				checksum = 0x0003a8d91c92b884L;
-				break;
-
-			case "string":
-				checksum = 0x0003a88fffc33f27L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
+		// skip 'byte' which cannot store vertex IDs for scale > 8
+		Assume.assumeFalse(idType.equals("byte") || idType.equals("nativeByte"));
 
 		String expected = "\n" +
-			new Checksum(479818, checksum) + "\n" +
+			new Checksum(2878908, 0x0015f77b8984c7caL) + "\n\n" +
 			"Triadic census:\n" +
 			"  003: 6,101,196,568\n" +
 			"  012: 132,051,207\n" +
@@ -197,31 +135,11 @@ extends CopyableValueDriverBaseITCase {
 		// computation is too large for collection mode
 		Assume.assumeFalse(mode == TestExecutionMode.COLLECTION);
 
-		long checksum;
-		switch (idType) {
-			case "byte":
-				return;
-
-			case "short":
-			case "char":
-			case "integer":
-				checksum = 0x0003a95630aae344L;
-				break;
-
-			case "long":
-				checksum = 0x0003a9b1e055d59dL;
-				break;
-
-			case "string":
-				checksum = 0x0003aa1e3d8f2c6bL;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
+		// skip 'byte' which cannot store vertex IDs for scale > 8
+		Assume.assumeFalse(idType.equals("byte") || idType.equals("nativeByte"));
 
 		String expected = "\n" +
-			new Checksum(479818, checksum) + "\n" +
+			new Checksum(2878908, 0x0015f51b1336df61L) + "\n\n" +
 			"Triadic census:\n" +
 			"  03: 6,101,196,568\n" +
 			"  12: 145,166,335\n" +
@@ -236,24 +154,7 @@ extends CopyableValueDriverBaseITCase {
 		// skip 'char' since it is not printed as a number
 		Assume.assumeFalse(idType.equals("char") || idType.equals("nativeChar"));
 
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "short":
-			case "integer":
-			case "long":
-				checksum = 0x00000764227995aaL;
-				break;
-
-			case "string":
-				checksum = 0x000007643d93c30aL;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
-		expectedOutputChecksum(parameters(7, "directed", "print"), new Checksum(3822, checksum));
+		expectedOutputChecksum(parameters(7, "directed", "print"), new Checksum(22932, 0x00002ce58634cf58L));
 	}
 
 	@Test
@@ -261,23 +162,6 @@ extends CopyableValueDriverBaseITCase {
 		// skip 'char' since it is not printed as a number
 		Assume.assumeFalse(idType.equals("char") || idType.equals("nativeChar"));
 
-		long checksum;
-		switch (idType) {
-			case "byte":
-			case "short":
-			case "integer":
-			case "long":
-				checksum = 0x0000077d1582e206L;
-				break;
-
-			case "string":
-				checksum = 0x0000077a49cb5268L;
-				break;
-
-			default:
-				throw new IllegalArgumentException("Unknown type: " + idType);
-		}
-
-		expectedOutputChecksum(parameters(7, "undirected", "print"), new Checksum(3822, checksum));
+		expectedOutputChecksum(parameters(7, "undirected", "print"), new Checksum(22932, 0x00002d208304e7c4L));
 	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/input/GeneratedGraphTest.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/input/GeneratedGraphTest.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/input/GeneratedGraphTest.java
deleted file mode 100644
index 1608f95..0000000
--- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/input/GeneratedGraphTest.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.graph.drivers.input;
-
-import org.apache.flink.graph.asm.translate.TranslateFunction;
-import org.apache.flink.graph.drivers.input.GeneratedGraph.LongValueToChar;
-import org.apache.flink.graph.drivers.input.GeneratedGraph.LongValueToCharValue;
-import org.apache.flink.graph.drivers.input.GeneratedGraph.LongValueToLong;
-import org.apache.flink.graph.drivers.input.GeneratedGraph.LongValueToString;
-import org.apache.flink.graph.drivers.input.GeneratedGraph.LongValueToUnsignedByte;
-import org.apache.flink.graph.drivers.input.GeneratedGraph.LongValueToUnsignedByteValue;
-import org.apache.flink.graph.drivers.input.GeneratedGraph.LongValueToUnsignedInt;
-import org.apache.flink.graph.drivers.input.GeneratedGraph.LongValueToUnsignedShort;
-import org.apache.flink.graph.drivers.input.GeneratedGraph.LongValueToUnsignedShortValue;
-import org.apache.flink.types.ByteValue;
-import org.apache.flink.types.CharValue;
-import org.apache.flink.types.LongValue;
-import org.apache.flink.types.ShortValue;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests for {@link GeneratedGraph}.
- */
-public class GeneratedGraphTest {
-
-	private TranslateFunction<LongValue, ByteValue> byteValueTranslator = new LongValueToUnsignedByteValue();
-	private TranslateFunction<LongValue, Byte> byteTranslator = new LongValueToUnsignedByte();
-	private TranslateFunction<LongValue, ShortValue> shortValueTranslator = new LongValueToUnsignedShortValue();
-	private TranslateFunction<LongValue, Short> shortTranslator = new LongValueToUnsignedShort();
-	private TranslateFunction<LongValue, CharValue> charValueTranslator = new LongValueToCharValue();
-	private TranslateFunction<LongValue, Character> charTranslator = new LongValueToChar();
-	private TranslateFunction<LongValue, Integer> intTranslator = new LongValueToUnsignedInt();
-	private TranslateFunction<LongValue, Long> longTranslator = new LongValueToLong();
-	private TranslateFunction<LongValue, String> stringTranslator = new LongValueToString();
-
-	private ByteValue byteValue = new ByteValue();
-	private ShortValue shortValue = new ShortValue();
-	private CharValue charValue = new CharValue();
-
-	// ByteValue
-
-	@Test
-	public void testByteValueTranslation() throws Exception {
-		assertEquals(new ByteValue((byte) 0), byteValueTranslator.translate(new LongValue(0L), byteValue));
-		assertEquals(new ByteValue(Byte.MIN_VALUE), byteValueTranslator.translate(new LongValue((long) Byte.MAX_VALUE + 1), byteValue));
-		assertEquals(new ByteValue((byte) -1), byteValueTranslator.translate(new LongValue((1L << 8) - 1), byteValue));
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testByteValueTranslationUpperOutOfRange() throws Exception {
-		byteValueTranslator.translate(new LongValue(1L << 8), byteValue);
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testByteValueTranslationLowerOutOfRange() throws Exception {
-		byteValueTranslator.translate(new LongValue(-1), byteValue);
-	}
-
-	// Byte
-
-	@Test
-	public void testByteTranslation() throws Exception {
-		assertEquals(Byte.valueOf((byte) 0), byteTranslator.translate(new LongValue(0L), null));
-		assertEquals(Byte.valueOf(Byte.MIN_VALUE), byteTranslator.translate(new LongValue((long) Byte.MAX_VALUE + 1), null));
-		assertEquals(Byte.valueOf((byte) -1), byteTranslator.translate(new LongValue((1L << 8) - 1), null));
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testByteTranslationUpperOutOfRange() throws Exception {
-		byteTranslator.translate(new LongValue(1L << 8), null);
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testByteTranslationLowerOutOfRange() throws Exception {
-		byteTranslator.translate(new LongValue(-1), null);
-	}
-
-	// ShortValue
-
-	@Test
-	public void testShortValueTranslation() throws Exception {
-		assertEquals(new ShortValue((short) 0), shortValueTranslator.translate(new LongValue(0L), shortValue));
-		assertEquals(new ShortValue(Short.MIN_VALUE), shortValueTranslator.translate(new LongValue((long) Short.MAX_VALUE + 1), shortValue));
-		assertEquals(new ShortValue((short) -1), shortValueTranslator.translate(new LongValue((1L << 16) - 1), shortValue));
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testShortValueTranslationUpperOutOfRange() throws Exception {
-		shortValueTranslator.translate(new LongValue(1L << 16), shortValue);
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testShortValueTranslationLowerOutOfRange() throws Exception {
-		shortValueTranslator.translate(new LongValue(-1), shortValue);
-	}
-
-	// Short
-
-	@Test
-	public void testShortTranslation() throws Exception {
-		assertEquals(Short.valueOf((short) 0), shortTranslator.translate(new LongValue(0L), null));
-		assertEquals(Short.valueOf(Short.MIN_VALUE), shortTranslator.translate(new LongValue((long) Short.MAX_VALUE + 1), null));
-		assertEquals(Short.valueOf((short) -1), shortTranslator.translate(new LongValue((1L << 16) - 1), null));
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testShortTranslationUpperOutOfRange() throws Exception {
-		shortTranslator.translate(new LongValue(1L << 16), null);
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testShortTranslationLowerOutOfRange() throws Exception {
-		shortTranslator.translate(new LongValue(-1), null);
-	}
-
-	// CharValue
-
-	@Test
-	public void testCharValueTranslation() throws Exception {
-		assertEquals(new CharValue((char) 0), charValueTranslator.translate(new LongValue(0L), charValue));
-		assertEquals(new CharValue(Character.MAX_VALUE), charValueTranslator.translate(new LongValue((long) Character.MAX_VALUE), charValue));
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testCharValueTranslationUpperOutOfRange() throws Exception {
-		charValueTranslator.translate(new LongValue(1L << 16), charValue);
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testCharValueTranslationLowerOutOfRange() throws Exception {
-		charValueTranslator.translate(new LongValue(-1), charValue);
-	}
-
-	// Character
-
-	@Test
-	public void testCharacterTranslation() throws Exception {
-		assertEquals(Character.valueOf((char) 0), charTranslator.translate(new LongValue(0L), null));
-		assertEquals(Character.valueOf(Character.MAX_VALUE), charTranslator.translate(new LongValue((long) Character.MAX_VALUE), null));
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testCharacterTranslationUpperOutOfRange() throws Exception {
-		charTranslator.translate(new LongValue(1L << 16), null);
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testCharacterTranslationLowerOutOfRange() throws Exception {
-		charTranslator.translate(new LongValue(-1), null);
-	}
-
-	// Integer
-
-	@Test
-	public void testIntegerTranslation() throws Exception {
-		assertEquals(Integer.valueOf(0), intTranslator.translate(new LongValue(0L), null));
-		assertEquals(Integer.valueOf(Integer.MIN_VALUE), intTranslator.translate(new LongValue((long) Integer.MAX_VALUE + 1), null));
-		assertEquals(Integer.valueOf(-1), intTranslator.translate(new LongValue((1L << 32) - 1), null));
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testIntegerTranslationUpperOutOfRange() throws Exception {
-		intTranslator.translate(new LongValue(1L << 32), null);
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void testIntegerTranslationLowerOutOfRange() throws Exception {
-		intTranslator.translate(new LongValue(-1), null);
-	}
-
-	// Long
-
-	@Test
-	public void testLongTranslation() throws Exception {
-		assertEquals(Long.valueOf(0L), longTranslator.translate(new LongValue(0L), null));
-		assertEquals(Long.valueOf(Long.MIN_VALUE), longTranslator.translate(new LongValue(Long.MIN_VALUE), null));
-		assertEquals(Long.valueOf(Long.MAX_VALUE), longTranslator.translate(new LongValue(Long.MAX_VALUE), null));
-	}
-
-	// String
-
-	@Test
-	public void testStringTranslation() throws Exception {
-		assertEquals("0", stringTranslator.translate(new LongValue(0L), null));
-		assertEquals("-9223372036854775808", stringTranslator.translate(new LongValue(Long.MIN_VALUE), null));
-		assertEquals("9223372036854775807", stringTranslator.translate(new LongValue(Long.MAX_VALUE), null));
-	}
-}

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/transform/GraphKeyTypeTransformTest.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/transform/GraphKeyTypeTransformTest.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/transform/GraphKeyTypeTransformTest.java
new file mode 100644
index 0000000..2a93911
--- /dev/null
+++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/drivers/transform/GraphKeyTypeTransformTest.java
@@ -0,0 +1,534 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.flink.graph.drivers.transform;
+
+import org.apache.flink.graph.asm.translate.TranslateFunction;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.DoubleToLongValueWithProperHashCode;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.DoubleValueToLongValueWithProperHashCode;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToChar;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToCharValue;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToDouble;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToDoubleValue;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToLong;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToLongValueWithProperHashCode;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToString;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToUnsignedByte;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToUnsignedByteValue;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToUnsignedFloat;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToUnsignedFloatValue;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToUnsignedInt;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToUnsignedShort;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToUnsignedShortValue;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.StringToLongValueWithProperHashCode;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.StringValueToLongValueWithProperHashCode;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.UnsignedByteToLongValueWithProperHashCode;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.UnsignedByteValueToLongValueWithProperHashCode;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.UnsignedFloatToLongValueWithProperHashCode;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.UnsignedFloatValueToLongValueWithProperHashCode;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.UnsignedIntToLongValueWithProperHashCode;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.UnsignedShortToLongValueWithProperHashCode;
+import org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.UnsignedShortValueToLongValueWithProperHashCode;
+import org.apache.flink.types.ByteValue;
+import org.apache.flink.types.CharValue;
+import org.apache.flink.types.DoubleValue;
+import org.apache.flink.types.FloatValue;
+import org.apache.flink.types.LongValue;
+import org.apache.flink.types.ShortValue;
+import org.apache.flink.types.StringValue;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests for {@link GraphKeyTypeTransform}.
+ */
+public class GraphKeyTypeTransformTest {
+
+	private ByteValue byteValue = new ByteValue();
+	private ShortValue shortValue = new ShortValue();
+	private CharValue charValue = new CharValue();
+	private FloatValue floatValue = new FloatValue();
+	private DoubleValue doubleValue = new DoubleValue();
+	private LongValueWithProperHashCode longValueWithProperHashCode = new LongValueWithProperHashCode();
+
+	// ByteValue
+
+	@Test
+	public void testToByteValue() throws Exception {
+		TranslateFunction<LongValue, ByteValue> translator = new LongValueToUnsignedByteValue();
+
+		Assert.assertEquals(new ByteValue((byte) 0),
+			translator.translate(new LongValue(0L), byteValue));
+
+		Assert.assertEquals(new ByteValue(Byte.MIN_VALUE),
+			translator.translate(new LongValue(Byte.MAX_VALUE + 1), byteValue));
+
+		Assert.assertEquals(new ByteValue((byte) -1),
+			translator.translate(new LongValue(LongValueToUnsignedByteValue.MAX_VERTEX_COUNT - 1), byteValue));
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToByteValueUpperOutOfRange() throws Exception {
+		new LongValueToUnsignedByteValue().translate(new LongValue(LongValueToUnsignedByteValue.MAX_VERTEX_COUNT), byteValue);
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToByteValueLowerOutOfRange() throws Exception {
+		new LongValueToUnsignedByteValue().translate(new LongValue(-1), byteValue);
+	}
+
+	@Test
+	public void testFromByteValue() throws Exception {
+		TranslateFunction<ByteValue, LongValueWithProperHashCode> translator = new UnsignedByteValueToLongValueWithProperHashCode();
+
+		Assert.assertEquals(new LongValueWithProperHashCode(0L),
+			translator.translate(new ByteValue((byte) 0), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Byte.MAX_VALUE + 1),
+			translator.translate(new ByteValue(Byte.MIN_VALUE), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedByteValue.MAX_VERTEX_COUNT - 1),
+			translator.translate(new ByteValue((byte) -1), longValueWithProperHashCode));
+	}
+
+	// Byte
+
+	@Test
+	public void testToByte() throws Exception {
+		TranslateFunction<LongValue, Byte> translator = new LongValueToUnsignedByte();
+
+		Assert.assertEquals(Byte.valueOf((byte) 0),
+			translator.translate(new LongValue(0L), null));
+
+		Assert.assertEquals(Byte.valueOf(Byte.MIN_VALUE),
+			translator.translate(new LongValue((long) Byte.MAX_VALUE + 1), null));
+
+		Assert.assertEquals(Byte.valueOf((byte) -1),
+			translator.translate(new LongValue(LongValueToUnsignedByte.MAX_VERTEX_COUNT - 1), null));
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToByteUpperOutOfRange() throws Exception {
+		new LongValueToUnsignedByte().translate(new LongValue(LongValueToUnsignedByte.MAX_VERTEX_COUNT), null);
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToByteLowerOutOfRange() throws Exception {
+		new LongValueToUnsignedByte().translate(new LongValue(-1), null);
+	}
+
+	@Test
+	public void testFromByte() throws Exception {
+		TranslateFunction<Byte, LongValueWithProperHashCode> translator = new UnsignedByteToLongValueWithProperHashCode();
+
+		Assert.assertEquals(new LongValueWithProperHashCode(0L),
+			translator.translate((byte) 0, longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Byte.MAX_VALUE + 1),
+			translator.translate(Byte.MIN_VALUE, longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedByte.MAX_VERTEX_COUNT - 1),
+			translator.translate((byte) -1, longValueWithProperHashCode));
+	}
+
+	// ShortValue
+
+	@Test
+	public void testToShortValue() throws Exception {
+		TranslateFunction<LongValue, ShortValue> translator = new LongValueToUnsignedShortValue();
+
+		Assert.assertEquals(new ShortValue((short) 0),
+			translator.translate(new LongValue(0L), shortValue));
+
+		Assert.assertEquals(new ShortValue(Short.MIN_VALUE),
+			translator.translate(new LongValue((long) Short.MAX_VALUE + 1), shortValue));
+
+		Assert.assertEquals(new ShortValue((short) -1),
+			translator.translate(new LongValue(LongValueToUnsignedShortValue.MAX_VERTEX_COUNT - 1), shortValue));
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToShortValueUpperOutOfRange() throws Exception {
+		new LongValueToUnsignedShortValue().translate(new LongValue(LongValueToUnsignedShortValue.MAX_VERTEX_COUNT), shortValue);
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToShortValueLowerOutOfRange() throws Exception {
+		new LongValueToUnsignedShortValue().translate(new LongValue(-1), shortValue);
+	}
+
+	@Test
+	public void testFromShortValue() throws Exception {
+		TranslateFunction<ShortValue, LongValueWithProperHashCode> translator = new UnsignedShortValueToLongValueWithProperHashCode();
+
+		Assert.assertEquals(new LongValueWithProperHashCode(0L),
+			translator.translate(new ShortValue((short) 0), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Short.MAX_VALUE + 1),
+			translator.translate(new ShortValue(Short.MIN_VALUE), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedShortValue.MAX_VERTEX_COUNT - 1),
+			translator.translate(new ShortValue((short) -1), longValueWithProperHashCode));
+	}
+
+	// Short
+
+	@Test
+	public void testToShort() throws Exception {
+		TranslateFunction<LongValue, Short> translator = new LongValueToUnsignedShort();
+
+		Assert.assertEquals(Short.valueOf((short) 0),
+			translator.translate(new LongValue(0L), null));
+
+		Assert.assertEquals(Short.valueOf(Short.MIN_VALUE),
+			translator.translate(new LongValue((long) Short.MAX_VALUE + 1), null));
+
+		Assert.assertEquals(Short.valueOf((short) -1),
+			translator.translate(new LongValue(LongValueToUnsignedShort.MAX_VERTEX_COUNT - 1), null));
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToShortUpperOutOfRange() throws Exception {
+		new LongValueToUnsignedShort().translate(new LongValue(LongValueToUnsignedShort.MAX_VERTEX_COUNT), null);
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToShortLowerOutOfRange() throws Exception {
+		new LongValueToUnsignedShort().translate(new LongValue(-1), null);
+	}
+
+	@Test
+	public void testFromShort() throws Exception {
+		TranslateFunction<Short, LongValueWithProperHashCode> translator = new UnsignedShortToLongValueWithProperHashCode();
+
+		Assert.assertEquals(new LongValueWithProperHashCode(0L),
+			translator.translate((short) 0, longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Short.MAX_VALUE + 1),
+			translator.translate(Short.MIN_VALUE, longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedShort.MAX_VERTEX_COUNT - 1),
+			translator.translate((short) -1, longValueWithProperHashCode));
+	}
+
+	// CharValue
+
+	@Test
+	public void testToCharValue() throws Exception {
+		TranslateFunction<LongValue, CharValue> translator = new LongValueToCharValue();
+
+		Assert.assertEquals(new CharValue((char) 0),
+			translator.translate(new LongValue(0L), charValue));
+
+		Assert.assertEquals(new CharValue(Character.MAX_VALUE),
+			translator.translate(new LongValue(LongValueToCharValue.MAX_VERTEX_COUNT - 1), charValue));
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToCharValueUpperOutOfRange() throws Exception {
+		new LongValueToCharValue().translate(new LongValue(LongValueToCharValue.MAX_VERTEX_COUNT), charValue);
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToCharValueLowerOutOfRange() throws Exception {
+		new LongValueToCharValue().translate(new LongValue(-1), charValue);
+	}
+
+	// Character
+
+	@Test
+	public void testToCharacter() throws Exception {
+		TranslateFunction<LongValue, Character> translator = new LongValueToChar();
+
+		Assert.assertEquals(Character.valueOf((char) 0),
+			translator.translate(new LongValue(0L), null));
+
+		Assert.assertEquals(Character.valueOf(Character.MAX_VALUE),
+			translator.translate(new LongValue(LongValueToChar.MAX_VERTEX_COUNT - 1), null));
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToCharacterUpperOutOfRange() throws Exception {
+		new LongValueToChar().translate(new LongValue(LongValueToChar.MAX_VERTEX_COUNT), null);
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToCharacterLowerOutOfRange() throws Exception {
+		new LongValueToChar().translate(new LongValue(-1), null);
+	}
+
+	// Integer
+
+	@Test
+	public void testToInt() throws Exception {
+		TranslateFunction<LongValue, Integer> translator = new LongValueToUnsignedInt();
+
+		Assert.assertEquals(Integer.valueOf(0),
+			translator.translate(new LongValue(0L), null));
+
+		Assert.assertEquals(Integer.valueOf(Integer.MIN_VALUE),
+			translator.translate(new LongValue((long) Integer.MAX_VALUE + 1), null));
+
+		Assert.assertEquals(Integer.valueOf(-1),
+			translator.translate(new LongValue(LongValueToUnsignedInt.MAX_VERTEX_COUNT - 1), null));
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToIntUpperOutOfRange() throws Exception {
+		new LongValueToUnsignedInt().translate(new LongValue(LongValueToUnsignedInt.MAX_VERTEX_COUNT), null);
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToIntLowerOutOfRange() throws Exception {
+		new LongValueToUnsignedInt().translate(new LongValue(-1), null);
+	}
+
+	@Test
+	public void testFromInt() throws Exception {
+		TranslateFunction<Integer, LongValueWithProperHashCode> translator = new UnsignedIntToLongValueWithProperHashCode();
+
+		Assert.assertEquals(new LongValueWithProperHashCode(0L),
+			translator.translate(0, longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode((long) Integer.MAX_VALUE + 1),
+			translator.translate(Integer.MIN_VALUE, longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedInt.MAX_VERTEX_COUNT - 1),
+			translator.translate(-1, longValueWithProperHashCode));
+	}
+
+	// LongValue
+
+	@Test
+	public void testFromLongValue() throws Exception {
+		TranslateFunction<LongValue, LongValueWithProperHashCode> translator = new LongValueToLongValueWithProperHashCode();
+
+		Assert.assertEquals(new LongValueWithProperHashCode(0L),
+			translator.translate(new LongValue(0), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Long.MIN_VALUE),
+			translator.translate(new LongValue(Long.MIN_VALUE), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Long.MAX_VALUE),
+			translator.translate(new LongValue(Long.MAX_VALUE), longValueWithProperHashCode));
+	}
+
+	// Long
+
+	@Test
+	public void testLongValueToLongTranslation() throws Exception {
+		TranslateFunction<LongValue, Long> translator = new LongValueToLong();
+
+		Assert.assertEquals(Long.valueOf(0L),
+			translator.translate(new LongValue(0L), null));
+
+		Assert.assertEquals(Long.valueOf(Long.MIN_VALUE),
+			translator.translate(new LongValue(Long.MIN_VALUE), null));
+
+		Assert.assertEquals(Long.valueOf(Long.MAX_VALUE),
+			translator.translate(new LongValue(Long.MAX_VALUE), null));
+	}
+
+	// FloatValue
+
+	@Test
+	public void testToFloatValue() throws Exception {
+		TranslateFunction<LongValue, FloatValue> translator = new LongValueToUnsignedFloatValue();
+
+		Assert.assertEquals(new FloatValue(Float.intBitsToFloat(0)),
+			translator.translate(new LongValue(0L), floatValue));
+
+		Assert.assertEquals(new FloatValue(Float.intBitsToFloat(Integer.MIN_VALUE)),
+			translator.translate(new LongValue((long) Integer.MAX_VALUE + 1), floatValue));
+
+		Assert.assertEquals(new FloatValue(Float.intBitsToFloat(-1)),
+			translator.translate(new LongValue(LongValueToUnsignedFloatValue.MAX_VERTEX_COUNT - 1), floatValue));
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToFloatValueUpperOutOfRange() throws Exception {
+		new LongValueToUnsignedFloatValue().translate(new LongValue(LongValueToUnsignedFloatValue.MAX_VERTEX_COUNT), floatValue);
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToFloatValueLowerOutOfRange() throws Exception {
+		new LongValueToUnsignedFloatValue().translate(new LongValue(-1), floatValue);
+	}
+
+	@Test
+	public void testFromFloatValue() throws Exception {
+		TranslateFunction<FloatValue, LongValueWithProperHashCode> translator = new UnsignedFloatValueToLongValueWithProperHashCode();
+
+		Assert.assertEquals(new LongValueWithProperHashCode(0L),
+			translator.translate(new FloatValue(Float.intBitsToFloat(0)), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode((long) Integer.MAX_VALUE + 1),
+			translator.translate(new FloatValue(Float.intBitsToFloat(Integer.MIN_VALUE)), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedFloatValue.MAX_VERTEX_COUNT - 1),
+			translator.translate(new FloatValue(Float.intBitsToFloat(-1)), longValueWithProperHashCode));
+	}
+
+	// Float
+
+	@Test
+	public void testToFloat() throws Exception {
+		TranslateFunction<LongValue, Float> translator = new LongValueToUnsignedFloat();
+
+		Assert.assertEquals(Float.valueOf(Float.intBitsToFloat(0)),
+			translator.translate(new LongValue(0L), null));
+
+		Assert.assertEquals(Float.valueOf(Float.intBitsToFloat(Integer.MIN_VALUE)),
+			translator.translate(new LongValue((long) Integer.MAX_VALUE + 1), null));
+
+		Assert.assertEquals(Float.valueOf(Float.intBitsToFloat(-1)),
+			translator.translate(new LongValue(LongValueToUnsignedFloat.MAX_VERTEX_COUNT - 1), null));
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToFloatUpperOutOfRange() throws Exception {
+		new LongValueToUnsignedFloat().translate(new LongValue(LongValueToUnsignedFloat.MAX_VERTEX_COUNT), null);
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testToFloatLowerOutOfRange() throws Exception {
+		new LongValueToUnsignedFloat().translate(new LongValue(-1), null);
+	}
+
+	@Test
+	public void testFromFloat() throws Exception {
+		TranslateFunction<Float, LongValueWithProperHashCode> translator = new UnsignedFloatToLongValueWithProperHashCode();
+
+		Assert.assertEquals(new LongValueWithProperHashCode(0L),
+			translator.translate(Float.intBitsToFloat(0), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode((long) Integer.MAX_VALUE + 1),
+			translator.translate(Float.intBitsToFloat(Integer.MIN_VALUE), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedFloat.MAX_VERTEX_COUNT - 1),
+			translator.translate(Float.intBitsToFloat(-1), longValueWithProperHashCode));
+	}
+
+	// DoubleValue
+
+	@Test
+	public void testToDoubleValue() throws Exception {
+		TranslateFunction<LongValue, DoubleValue> translator = new LongValueToDoubleValue();
+
+		Assert.assertEquals(new DoubleValue(Double.longBitsToDouble(0L)),
+			translator.translate(new LongValue(0L), doubleValue));
+
+		Assert.assertEquals(new DoubleValue(Double.longBitsToDouble(Long.MIN_VALUE)),
+			translator.translate(new LongValue(Long.MIN_VALUE), doubleValue));
+
+		Assert.assertEquals(new DoubleValue(Double.longBitsToDouble(Long.MAX_VALUE)),
+			translator.translate(new LongValue(Long.MAX_VALUE), doubleValue));
+	}
+
+	@Test
+	public void testFromDoubleValue() throws Exception {
+		TranslateFunction<DoubleValue, LongValueWithProperHashCode> translator = new DoubleValueToLongValueWithProperHashCode();
+
+		Assert.assertEquals(new LongValueWithProperHashCode(0L),
+			translator.translate(new DoubleValue(Double.longBitsToDouble(0L)), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Long.MIN_VALUE),
+			translator.translate(new DoubleValue(Double.longBitsToDouble(Long.MIN_VALUE)), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Long.MAX_VALUE),
+			translator.translate(new DoubleValue(Double.longBitsToDouble(Long.MAX_VALUE)), longValueWithProperHashCode));
+	}
+
+	// Double
+
+	@Test
+	public void testToDouble() throws Exception {
+		TranslateFunction<LongValue, Double> translator = new LongValueToDouble();
+
+		Assert.assertEquals(Double.valueOf(Double.longBitsToDouble(0L)),
+			translator.translate(new LongValue(0L), null));
+
+		Assert.assertEquals(Double.valueOf(Double.longBitsToDouble(Long.MIN_VALUE)),
+			translator.translate(new LongValue(Long.MIN_VALUE), null));
+
+		Assert.assertEquals(Double.valueOf(Double.longBitsToDouble(Long.MAX_VALUE)),
+			translator.translate(new LongValue(Long.MAX_VALUE), null));
+	}
+
+	@Test
+	public void testFromDouble() throws Exception {
+		TranslateFunction<Double, LongValueWithProperHashCode> translator = new DoubleToLongValueWithProperHashCode();
+
+		Assert.assertEquals(new LongValueWithProperHashCode(0L),
+			translator.translate(Double.longBitsToDouble(0L), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Long.MIN_VALUE),
+			translator.translate(Double.longBitsToDouble(Long.MIN_VALUE), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Long.MAX_VALUE),
+			translator.translate(Double.longBitsToDouble(Long.MAX_VALUE), longValueWithProperHashCode));
+	}
+
+	// StringValue
+
+	@Test
+	public void testFromStringValue() throws Exception {
+		TranslateFunction<StringValue, LongValueWithProperHashCode> translator = new StringValueToLongValueWithProperHashCode();
+
+		Assert.assertEquals(new LongValueWithProperHashCode(0L),
+			translator.translate(new StringValue("0"), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Long.MIN_VALUE),
+			translator.translate(new StringValue("-9223372036854775808"), longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Long.MAX_VALUE),
+			translator.translate(new StringValue("9223372036854775807"), longValueWithProperHashCode));
+	}
+
+	// String
+
+	@Test
+	public void testLongValueToStringTranslation() throws Exception {
+		TranslateFunction<LongValue, String> translator = new LongValueToString();
+
+		Assert.assertEquals("0",
+			translator.translate(new LongValue(0L), null));
+
+		Assert.assertEquals("-9223372036854775808",
+			translator.translate(new LongValue(Long.MIN_VALUE), null));
+
+		Assert.assertEquals("9223372036854775807",
+			translator.translate(new LongValue(Long.MAX_VALUE), null));
+	}
+
+	@Test
+	public void testFromString() throws Exception {
+		TranslateFunction<String, LongValueWithProperHashCode> translator = new StringToLongValueWithProperHashCode();
+
+		Assert.assertEquals(new LongValueWithProperHashCode(0L),
+			translator.translate("0", longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Long.MIN_VALUE),
+			translator.translate("-9223372036854775808", longValueWithProperHashCode));
+
+		Assert.assertEquals(new LongValueWithProperHashCode(Long.MAX_VALUE),
+			translator.translate("9223372036854775807", longValueWithProperHashCode));
+	}
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/BinaryResult.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/BinaryResult.java b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/BinaryResult.java
index f41268c..21a226c 100644
--- a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/BinaryResult.java
+++ b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/BinaryResult.java
@@ -26,8 +26,10 @@ import java.io.Serializable;
 
 /**
  * A {@link GraphAlgorithm} result for a pair vertices.
+ *
+ * @param <K> graph ID type
  */
-public interface BinaryResult<T>
+public interface BinaryResult<K>
 extends Serializable {
 
 	/**
@@ -35,33 +37,33 @@ extends Serializable {
 	 *
 	 * @return first vertex ID
 	 */
-	T getVertexId0();
+	K getVertexId0();
 
 	/**
 	 * Set the first vertex ID.
 	 *
-	 * @param value new vertex ID
+	 * @param vertexId0 new vertex ID
 	 */
-	void setVertexId0(T value);
+	void setVertexId0(K vertexId0);
 
 	/**
 	 * Get the second vertex ID.
 	 *
 	 * @return second vertex ID
 	 */
-	T getVertexId1();
+	K getVertexId1();
 
 	/**
 	 * Set the second vertex ID.
 	 *
-	 * @param value new vertex ID
+	 * @param vertexId1 new vertex ID
 	 */
-	void setVertexId1(T value);
+	void setVertexId1(K vertexId1);
 
 	/**
 	 * Output each input and a second result with the vertex order flipped.
 	 *
-	 * @param <T> ID type
+	 * @param <T> graph ID type
 	 * @param <RT> result type
 	 */
 	class MirrorResult<T, RT extends BinaryResult<T>>

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/BinaryResultBase.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/BinaryResultBase.java b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/BinaryResultBase.java
index 45791ee..1275075 100644
--- a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/BinaryResultBase.java
+++ b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/BinaryResultBase.java
@@ -18,6 +18,9 @@
 
 package org.apache.flink.graph.asm.result;
 
+import org.apache.flink.graph.asm.translate.TranslateFunction;
+import org.apache.flink.util.Collector;
+
 /**
  * Base class for algorithm results for a pair of vertices.
  *
@@ -25,7 +28,7 @@ package org.apache.flink.graph.asm.result;
  */
 public abstract class BinaryResultBase<K>
 extends ResultBase
-implements BinaryResult<K> {
+implements BinaryResult<K>, TranslatableResult<K> {
 
 	private K vertexId0;
 
@@ -50,4 +53,43 @@ implements BinaryResult<K> {
 	public void setVertexId1(K vertexId1) {
 		this.vertexId1 = vertexId1;
 	}
+
+	@Override
+	public <T> TranslatableResult<T> translate(TranslateFunction<K, T> translator, TranslatableResult<T> reuse, Collector<TranslatableResult<T>> out)
+			throws Exception {
+		if (reuse == null) {
+			reuse = new BasicBinaryResult<>();
+		}
+
+		K vertexId0 = this.getVertexId0();
+		K vertexId1 = this.getVertexId1();
+
+		BinaryResult<T> translatable = (BinaryResult<T>) reuse;
+		BinaryResult<T> translated = (BinaryResult<T>) this;
+
+		translated.setVertexId0(translator.translate(this.getVertexId0(), translatable.getVertexId0()));
+		translated.setVertexId1(translator.translate(this.getVertexId1(), translatable.getVertexId1()));
+
+		out.collect((TranslatableResult<T>) translated);
+
+		this.setVertexId0(vertexId0);
+		this.setVertexId1(vertexId1);
+
+		return reuse;
+	}
+
+	/**
+	 * Simple override of {@code BinaryResultBase}. This holds no additional
+	 * values but is used by {@link BinaryResultBase#translate} as the reuse
+	 * object for translating vertex IDs.
+	 *
+	 * @param <U> result ID type
+	 */
+	private static class BasicBinaryResult<U>
+	extends BinaryResultBase<U> {
+		@Override
+		public String toString() {
+			return "(" + getVertexId0() + "," + getVertexId1() + ")";
+		}
+	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TertiaryResult.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TertiaryResult.java b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TertiaryResult.java
index a546387..61e1fb9 100644
--- a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TertiaryResult.java
+++ b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TertiaryResult.java
@@ -24,8 +24,10 @@ import java.io.Serializable;
 
 /**
  * A {@link GraphAlgorithm} result for three vertices.
+ *
+ * @param <K> graph ID type
  */
-public interface TertiaryResult<T>
+public interface TertiaryResult<K>
 extends Serializable {
 
 	/**
@@ -33,40 +35,40 @@ extends Serializable {
 	 *
 	 * @return first vertex ID
 	 */
-	T getVertexId0();
+	K getVertexId0();
 
 	/**
 	 * Set the first vertex ID.
 	 *
-	 * @param value new vertex ID
+	 * @param vertexId0 new vertex ID
 	 */
-	void setVertexId0(T value);
+	void setVertexId0(K vertexId0);
 
 	/**
 	 * Get the second vertex ID.
 	 *
 	 * @return second vertex ID
 	 */
-	T getVertexId1();
+	K getVertexId1();
 
 	/**
 	 * Set the second vertex ID.
 	 *
-	 * @param value new vertex ID
+	 * @param vertexId1 new vertex ID
 	 */
-	void setVertexId1(T value);
+	void setVertexId1(K vertexId1);
 
 	/**
 	 * Get the third vertex ID.
 	 *
 	 * @return third vertex ID
 	 */
-	T getVertexId2();
+	K getVertexId2();
 
 	/**
 	 * Set the third vertex ID.
 	 *
-	 * @param value new vertex ID
+	 * @param vertexId2 new vertex ID
 	 */
-	void setVertexId2(T value);
+	void setVertexId2(K vertexId2);
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TertiaryResultBase.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TertiaryResultBase.java b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TertiaryResultBase.java
index eb505b8..a63cf90 100644
--- a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TertiaryResultBase.java
+++ b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TertiaryResultBase.java
@@ -19,6 +19,9 @@
 
 package org.apache.flink.graph.asm.result;
 
+import org.apache.flink.graph.asm.translate.TranslateFunction;
+import org.apache.flink.util.Collector;
+
 /**
  * Base class for algorithm results for three vertices.
  *
@@ -26,7 +29,7 @@ package org.apache.flink.graph.asm.result;
  */
 public abstract class TertiaryResultBase<K>
 extends ResultBase
-implements TertiaryResult<K> {
+implements TertiaryResult<K>, TranslatableResult<K> {
 
 	private K vertexId0;
 
@@ -63,4 +66,46 @@ implements TertiaryResult<K> {
 	public void setVertexId2(K vertexId2) {
 		this.vertexId2 = vertexId2;
 	}
+
+	@Override
+	public <T> TranslatableResult<T> translate(TranslateFunction<K, T> translator, TranslatableResult<T> reuse, Collector<TranslatableResult<T>> out)
+			throws Exception {
+		if (reuse == null) {
+			reuse = new BasicTertiaryResult<>();
+		}
+
+		K vertexId0 = this.getVertexId0();
+		K vertexId1 = this.getVertexId1();
+		K vertexId2 = this.getVertexId2();
+
+		TertiaryResult<T> translatable = (TertiaryResult<T>) reuse;
+		TertiaryResult<T> translated = (TertiaryResult<T>) this;
+
+		translated.setVertexId0(translator.translate(this.getVertexId0(), translatable.getVertexId0()));
+		translated.setVertexId1(translator.translate(this.getVertexId1(), translatable.getVertexId1()));
+		translated.setVertexId2(translator.translate(this.getVertexId2(), translatable.getVertexId2()));
+
+		out.collect((TranslatableResult<T>) translated);
+
+		this.setVertexId0(vertexId0);
+		this.setVertexId1(vertexId1);
+		this.setVertexId2(vertexId2);
+
+		return reuse;
+	}
+
+	/**
+	 * Simple override of {@code TertiaryResultBase}. This holds no additional
+	 * values but is used by {@link TertiaryResultBase#translate} as the reuse
+	 * object for translating vertex IDs.
+	 *
+	 * @param <U> result ID type
+	 */
+	private static class BasicTertiaryResult<U>
+	extends TertiaryResultBase<U> {
+		@Override
+		public String toString() {
+			return "(" + getVertexId0() + "," + getVertexId1() + "," + getVertexId2() + ")";
+		}
+	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TranslatableResult.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TranslatableResult.java b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TranslatableResult.java
new file mode 100644
index 0000000..3bd2a1e
--- /dev/null
+++ b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/TranslatableResult.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.graph.asm.result;
+
+import org.apache.flink.graph.asm.translate.TranslateFunction;
+import org.apache.flink.util.Collector;
+
+/**
+ * A transformable result can transform its ID type.
+ *
+ * @param <K> graph ID type
+ */
+public interface TranslatableResult<K> {
+
+	/**
+	 * Output the result after transforming the vertex ID type.
+	 *
+	 * @param translator translates type {@code K} to type {@code T}
+	 * @param reuse reusable value
+	 * @param out output collector
+	 * @return reusable result
+	 * @throws Exception on error
+	 *
+	 * @param <T> ID output type
+	 */
+	<T> TranslatableResult<T> translate(TranslateFunction<K, T> translator, TranslatableResult<T> reuse, Collector<TranslatableResult<T>> out) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/UnaryResult.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/UnaryResult.java b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/UnaryResult.java
index d861b43..88e6c00 100644
--- a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/UnaryResult.java
+++ b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/UnaryResult.java
@@ -24,8 +24,10 @@ import java.io.Serializable;
 
 /**
  * A {@link GraphAlgorithm} result for a single vertex.
+ *
+ * @param <K> graph ID type
  */
-public interface UnaryResult<T>
+public interface UnaryResult<K>
 extends Serializable {
 
 	/**
@@ -33,12 +35,12 @@ extends Serializable {
 	 *
 	 * @return first vertex ID
 	 */
-	T getVertexId0();
+	K getVertexId0();
 
 	/**
 	 * Set the first vertex ID.
 	 *
-	 * @param value new vertex ID
+	 * @param vertexId0 new vertex ID
 	 */
-	void setVertexId0(T value);
+	void setVertexId0(K vertexId0);
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/UnaryResultBase.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/UnaryResultBase.java b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/UnaryResultBase.java
index 5bd3229..727f82c 100644
--- a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/UnaryResultBase.java
+++ b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/result/UnaryResultBase.java
@@ -19,6 +19,9 @@
 
 package org.apache.flink.graph.asm.result;
 
+import org.apache.flink.graph.asm.translate.TranslateFunction;
+import org.apache.flink.util.Collector;
+
 /**
  * Base class for algorithm results for a single vertex.
  *
@@ -26,7 +29,7 @@ package org.apache.flink.graph.asm.result;
  */
 public abstract class UnaryResultBase<K>
 extends ResultBase
-implements UnaryResult<K> {
+implements UnaryResult<K>, TranslatableResult<K> {
 
 	private K vertexId0;
 
@@ -39,4 +42,40 @@ implements UnaryResult<K> {
 	public void setVertexId0(K vertexId0) {
 		this.vertexId0 = vertexId0;
 	}
+
+	@Override
+	public <T> TranslatableResult<T> translate(TranslateFunction<K, T> translator, TranslatableResult<T> reuse, Collector<TranslatableResult<T>> out)
+			throws Exception {
+		if (reuse == null) {
+			reuse = new BasicUnaryResult<>();
+		}
+
+		K vertexId0 = this.getVertexId0();
+
+		UnaryResult<T> translatable = (UnaryResult<T>) reuse;
+		UnaryResult<T> translated = (UnaryResult<T>) this;
+
+		translated.setVertexId0(translator.translate(this.getVertexId0(), translatable.getVertexId0()));
+
+		out.collect((TranslatableResult<T>) translated);
+
+		this.setVertexId0(vertexId0);
+
+		return reuse;
+	}
+
+	/**
+	 * Simple override of {@code UnaryResultBase}. This holds no additional
+	 * values but is used by {@link UnaryResultBase#translate} as the reuse
+	 * object for translating vertex IDs.
+	 *
+	 * @param <U> result ID type
+	 */
+	private static class BasicUnaryResult<U>
+	extends UnaryResultBase<U> {
+		@Override
+		public String toString() {
+			return "(" + getVertexId0() + ")";
+		}
+	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/8695a210/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/translate/translators/LongValueToUnsignedIntValue.java
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/translate/translators/LongValueToUnsignedIntValue.java b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/translate/translators/LongValueToUnsignedIntValue.java
index d7896d3..c495b25 100644
--- a/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/translate/translators/LongValueToUnsignedIntValue.java
+++ b/flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/asm/translate/translators/LongValueToUnsignedIntValue.java
@@ -43,10 +43,9 @@ implements TranslateFunction<LongValue, IntValue> {
 
 		if (l < 0 || l >= MAX_VERTEX_COUNT) {
 			throw new IllegalArgumentException("Cannot cast long value " + value + " to integer.");
-		} else {
-			reuse.setValue((int) (l & (MAX_VERTEX_COUNT - 1)));
 		}
 
+		reuse.setValue((int) (l & (MAX_VERTEX_COUNT - 1)));
 		return reuse;
 	}
 }