crunch-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwi...@apache.org
Subject git commit: CRUNCH-229: Better error handling for incompatible Target/PType combinations.
Date Sat, 29 Jun 2013 15:36:02 GMT
Updated Branches:
  refs/heads/master 38a97e54c -> 246109962


CRUNCH-229: Better error handling for incompatible Target/PType combinations.


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

Branch: refs/heads/master
Commit: 2461099628d83b8f4693c562e7f961eeab941c22
Parents: 38a97e5
Author: Josh Wills <jwills@apache.org>
Authored: Fri Jun 28 17:00:05 2013 -0700
Committer: Josh Wills <jwills@apache.org>
Committed: Fri Jun 28 17:00:05 2013 -0700

----------------------------------------------------------------------
 .../org/apache/crunch/io/avro/TextToAvroIT.java | 41 ++++++++++++++++++++
 .../crunch/impl/mr/plan/MSCROutputHandler.java  |  6 ++-
 2 files changed, 46 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/crunch/blob/24610996/crunch-core/src/it/java/org/apache/crunch/io/avro/TextToAvroIT.java
----------------------------------------------------------------------
diff --git a/crunch-core/src/it/java/org/apache/crunch/io/avro/TextToAvroIT.java b/crunch-core/src/it/java/org/apache/crunch/io/avro/TextToAvroIT.java
new file mode 100644
index 0000000..d285939
--- /dev/null
+++ b/crunch-core/src/it/java/org/apache/crunch/io/avro/TextToAvroIT.java
@@ -0,0 +1,41 @@
+/**
+ * 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.crunch.io.avro;
+
+import org.apache.crunch.CrunchRuntimeException;
+import org.apache.crunch.Pipeline;
+import org.apache.crunch.impl.mr.MRPipeline;
+import org.apache.crunch.io.From;
+import org.apache.crunch.io.To;
+import org.apache.crunch.test.TemporaryPath;
+import org.apache.crunch.test.TemporaryPaths;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class TextToAvroIT {
+  @Rule
+  public transient TemporaryPath tmpDir = TemporaryPaths.create();
+  
+  @Test(expected=CrunchRuntimeException.class)
+  public void testTextToAvro() throws Exception {
+    String shakes = tmpDir.copyResourceFileName("shakes.txt");
+    Pipeline pipeline = new MRPipeline(TextToAvroIT.class, tmpDir.getDefaultConfiguration());
+    pipeline.read(From.textFile(shakes)).write(To.avroFile("output"));
+    pipeline.run();
+  }
+}

http://git-wip-us.apache.org/repos/asf/crunch/blob/24610996/crunch-core/src/main/java/org/apache/crunch/impl/mr/plan/MSCROutputHandler.java
----------------------------------------------------------------------
diff --git a/crunch-core/src/main/java/org/apache/crunch/impl/mr/plan/MSCROutputHandler.java
b/crunch-core/src/main/java/org/apache/crunch/impl/mr/plan/MSCROutputHandler.java
index 36c565e..24090e7 100644
--- a/crunch-core/src/main/java/org/apache/crunch/impl/mr/plan/MSCROutputHandler.java
+++ b/crunch-core/src/main/java/org/apache/crunch/impl/mr/plan/MSCROutputHandler.java
@@ -19,6 +19,7 @@ package org.apache.crunch.impl.mr.plan;
 
 import java.util.Map;
 
+import org.apache.crunch.CrunchRuntimeException;
 import org.apache.crunch.Target;
 import org.apache.crunch.io.MapReduceTarget;
 import org.apache.crunch.io.OutputHandler;
@@ -48,7 +49,10 @@ public class MSCROutputHandler implements OutputHandler {
 
   public void configureNode(DoNode node, Target target) {
     workingNode = node;
-    target.accept(this, node.getPType());
+    if (!target.accept(this, node.getPType())) {
+      throw new CrunchRuntimeException("Target " + target + " cannot serialize PType of class:
" +
+          node.getPType().getClass());
+    }
   }
 
   public boolean configure(Target target, PType<?> ptype) {


Mime
View raw message