crunch-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwi...@apache.org
Subject git commit: Tiny fix: Remove some unused imports and make the exception thrown by Writables.records more obvious about what failed
Date Wed, 06 Mar 2013 22:49:01 GMT
Updated Branches:
  refs/heads/master 65a1d26f2 -> 9b0b9eb63


Tiny fix: Remove some unused imports and make the exception thrown by Writables.records more
obvious about what failed


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

Branch: refs/heads/master
Commit: 9b0b9eb633e11872072db32ea63cb09a20a39148
Parents: 65a1d26
Author: Josh Wills <jwills@apache.org>
Authored: Wed Mar 6 14:48:47 2013 -0800
Committer: Josh Wills <jwills@apache.org>
Committed: Wed Mar 6 14:48:47 2013 -0800

----------------------------------------------------------------------
 .../apache/crunch/types/writable/Writables.java    |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/crunch/blob/9b0b9eb6/crunch/src/main/java/org/apache/crunch/types/writable/Writables.java
----------------------------------------------------------------------
diff --git a/crunch/src/main/java/org/apache/crunch/types/writable/Writables.java b/crunch/src/main/java/org/apache/crunch/types/writable/Writables.java
index 25ae370..78cf3ae 100644
--- a/crunch/src/main/java/org/apache/crunch/types/writable/Writables.java
+++ b/crunch/src/main/java/org/apache/crunch/types/writable/Writables.java
@@ -30,12 +30,8 @@ import org.apache.crunch.Tuple4;
 import org.apache.crunch.TupleN;
 import org.apache.crunch.fn.CompositeMapFn;
 import org.apache.crunch.fn.IdentityFn;
-import org.apache.crunch.types.CollectionDeepCopier;
-import org.apache.crunch.types.DeepCopier;
-import org.apache.crunch.types.MapDeepCopier;
 import org.apache.crunch.types.PType;
 import org.apache.crunch.types.PTypes;
-import org.apache.crunch.types.TupleDeepCopier;
 import org.apache.crunch.types.TupleFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.BooleanWritable;
@@ -248,7 +244,12 @@ public class Writables {
     if (EXTENSIONS.containsKey(clazz)) {
       return (WritableType<T, W>) EXTENSIONS.get(clazz);
     }
-    return (WritableType<T, W>) writables(clazz.asSubclass(Writable.class));
+    if (Writable.class.isAssignableFrom(clazz)) {
+      return (WritableType<T, W>) writables(clazz.asSubclass(Writable.class));
+    } else {
+      throw new IllegalArgumentException(
+          "Cannot create Writable records from non-Writable class"+ clazz.getCanonicalName());
+    }
   }
 
   public static <W extends Writable> WritableType<W, W> writables(Class<W>
clazz) {
@@ -581,8 +582,6 @@ public class Writables {
     return PTypes.jsonString(clazz, WritableTypeFamily.getInstance());
   }
 
-
-
   // Not instantiable
   private Writables() {
   }


Mime
View raw message