From 217286b44a2598d7cbe6b87723fa679aed6f8951 Mon Sep 17 00:00:00 2001 From: StephanEwen Date: Thu, 13 Jun 2013 07:12:22 +0200 Subject: [PATCH] Minor cleanup and corrections in API classes. --- .../nephele/configuration/Configuration.java | 2 +- .../pact/common/stubs/CoGroupStub.java | 6 ++--- .../pact/common/stubs/CrossStub.java | 2 +- .../pact/common/stubs/MapStub.java | 2 -- .../pact/common/util/InstantiationUtil.java | 22 +++++++++++++++++++ .../pact/generic/stub/GenericCoGrouper.java | 6 ++--- .../pact/generic/stub/GenericCrosser.java | 2 +- .../pact/runtime/task/util/TaskConfig.java | 2 +- 8 files changed, 32 insertions(+), 12 deletions(-) diff --git a/nephele/nephele-common/src/main/java/eu/stratosphere/nephele/configuration/Configuration.java b/nephele/nephele-common/src/main/java/eu/stratosphere/nephele/configuration/Configuration.java index 788e2fa8316..8c12c8af8c7 100644 --- a/nephele/nephele-common/src/main/java/eu/stratosphere/nephele/configuration/Configuration.java +++ b/nephele/nephele-common/src/main/java/eu/stratosphere/nephele/configuration/Configuration.java @@ -90,7 +90,7 @@ public class Configuration implements IOReadableWritable { * @see #setClass(String, Class) */ @SuppressWarnings("unchecked") - public Class getClass(String key, Class defaultValue, Class ancestor) { + public Class getClass(String key, Class defaultValue, Class ancestor) { String className = getStringInternal(key); if (className == null) { return (Class) defaultValue; diff --git a/pact/pact-common/src/main/java/eu/stratosphere/pact/common/stubs/CoGroupStub.java b/pact/pact-common/src/main/java/eu/stratosphere/pact/common/stubs/CoGroupStub.java index 5486ac20370..ec573d8001e 100644 --- a/pact/pact-common/src/main/java/eu/stratosphere/pact/common/stubs/CoGroupStub.java +++ b/pact/pact-common/src/main/java/eu/stratosphere/pact/common/stubs/CoGroupStub.java @@ -48,7 +48,7 @@ public abstract class CoGroupStub extends AbstractStub implements GenericCoGroup * decide whether to retry the task execution. */ @Override - public abstract void coGroup(Iterator records1, Iterator records2, Collector out); + public abstract void coGroup(Iterator records1, Iterator records2, Collector out) throws Exception; /** * This method must be overridden by CoGoup UDFs that want to make use of the combining feature @@ -64,7 +64,7 @@ public abstract class CoGroupStub extends AbstractStub implements GenericCoGroup * decide whether to retry the combiner execution. */ @Override - public void combineFirst(Iterator records, Collector out) { + public void combineFirst(Iterator records, Collector out) throws Exception { throw new UnsupportedOperationException(); } @@ -82,7 +82,7 @@ public abstract class CoGroupStub extends AbstractStub implements GenericCoGroup * decide whether to retry the combiner execution. */ @Override - public void combineSecond(Iterator records, Collector out) { + public void combineSecond(Iterator records, Collector out) throws Exception { throw new UnsupportedOperationException(); } } diff --git a/pact/pact-common/src/main/java/eu/stratosphere/pact/common/stubs/CrossStub.java b/pact/pact-common/src/main/java/eu/stratosphere/pact/common/stubs/CrossStub.java index 65d0eaf122a..09cbe1c8c39 100644 --- a/pact/pact-common/src/main/java/eu/stratosphere/pact/common/stubs/CrossStub.java +++ b/pact/pact-common/src/main/java/eu/stratosphere/pact/common/stubs/CrossStub.java @@ -44,5 +44,5 @@ public abstract class CrossStub extends AbstractStub implements GenericCrosser

out); + public abstract void cross(PactRecord record1, PactRecord record2, Collector out) throws Exception; } diff --git a/pact/pact-common/src/main/java/eu/stratosphere/pact/common/stubs/MapStub.java b/pact/pact-common/src/main/java/eu/stratosphere/pact/common/stubs/MapStub.java index de0e815e98c..0dadbf98706 100644 --- a/pact/pact-common/src/main/java/eu/stratosphere/pact/common/stubs/MapStub.java +++ b/pact/pact-common/src/main/java/eu/stratosphere/pact/common/stubs/MapStub.java @@ -25,8 +25,6 @@ import eu.stratosphere.pact.generic.stub.GenericMapper; * For details on the Map PACT read the documentation of the PACT programming model. *

* For a mapper implementation, the map() method must be implemented. - * - * @author Fabian Hueske */ public abstract class MapStub extends AbstractStub implements GenericMapper { diff --git a/pact/pact-common/src/main/java/eu/stratosphere/pact/common/util/InstantiationUtil.java b/pact/pact-common/src/main/java/eu/stratosphere/pact/common/util/InstantiationUtil.java index 0e4a3503a40..373f790f629 100644 --- a/pact/pact-common/src/main/java/eu/stratosphere/pact/common/util/InstantiationUtil.java +++ b/pact/pact-common/src/main/java/eu/stratosphere/pact/common/util/InstantiationUtil.java @@ -15,9 +15,14 @@ package eu.stratosphere.pact.common.util; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.ObjectInputStream; import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; +import eu.stratosphere.nephele.configuration.Configuration; + /** * Utility class to create instances from class objects and checking failure reasons. @@ -164,6 +169,23 @@ public class InstantiationUtil { } } + public static Object readObjectFormConfig(Configuration config, String key) throws IOException, ClassNotFoundException { + byte[] bytes = config.getBytes(key, null); + if (bytes == null) { + return null; + } + + ObjectInputStream oois = null; + try { + oois = new ObjectInputStream(new ByteArrayInputStream(bytes)); + return oois.readObject(); + } finally { + if (oois != null) { + oois.close(); + } + } + } + // -------------------------------------------------------------------------------------------- /** diff --git a/pact/pact-common/src/main/java/eu/stratosphere/pact/generic/stub/GenericCoGrouper.java b/pact/pact-common/src/main/java/eu/stratosphere/pact/generic/stub/GenericCoGrouper.java index c5754f03957..4cad7f4dc52 100644 --- a/pact/pact-common/src/main/java/eu/stratosphere/pact/generic/stub/GenericCoGrouper.java +++ b/pact/pact-common/src/main/java/eu/stratosphere/pact/generic/stub/GenericCoGrouper.java @@ -22,9 +22,9 @@ import eu.stratosphere.pact.common.stubs.Stub; public interface GenericCoGrouper extends Stub { - public abstract void coGroup(Iterator records1, Iterator records2, Collector out); + public abstract void coGroup(Iterator records1, Iterator records2, Collector out) throws Exception; - public abstract void combineFirst(Iterator records, Collector out); + public void combineFirst(Iterator records, Collector out) throws Exception; - public abstract void combineSecond(Iterator records, Collector out); + public void combineSecond(Iterator records, Collector out) throws Exception; } diff --git a/pact/pact-common/src/main/java/eu/stratosphere/pact/generic/stub/GenericCrosser.java b/pact/pact-common/src/main/java/eu/stratosphere/pact/generic/stub/GenericCrosser.java index 60ce2c49cc9..5bc132321f3 100644 --- a/pact/pact-common/src/main/java/eu/stratosphere/pact/generic/stub/GenericCrosser.java +++ b/pact/pact-common/src/main/java/eu/stratosphere/pact/generic/stub/GenericCrosser.java @@ -21,5 +21,5 @@ import eu.stratosphere.pact.common.stubs.Stub; public interface GenericCrosser extends Stub { - void cross(V1 record1, V2 record2, Collector out); + void cross(V1 record1, V2 record2, Collector out) throws Exception; } diff --git a/pact/pact-runtime/src/main/java/eu/stratosphere/pact/runtime/task/util/TaskConfig.java b/pact/pact-runtime/src/main/java/eu/stratosphere/pact/runtime/task/util/TaskConfig.java index aab3cb0e424..081e8b68e42 100644 --- a/pact/pact-runtime/src/main/java/eu/stratosphere/pact/runtime/task/util/TaskConfig.java +++ b/pact/pact-runtime/src/main/java/eu/stratosphere/pact/runtime/task/util/TaskConfig.java @@ -1083,7 +1083,7 @@ public class TaskConfig { } @Override - public Class getClass(String key, Class defaultValue, Class ancestor) { + public Class getClass(String key, Class defaultValue, Class ancestor) { return this.backingConfig.getClass(this.prefix + key, defaultValue, ancestor); } -- GitLab