Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make materialization errors less annoying

  • Loading branch information...
commit 3711cea61bded4c90b235a01163ae5f855089917 1 parent 521b231
@jwills jwills authored
View
16 src/main/java/com/cloudera/crunch/materialize/MaterializableIterable.java
@@ -21,6 +21,7 @@
import org.apache.commons.logging.LogFactory;
import com.cloudera.crunch.Pipeline;
+import com.cloudera.crunch.impl.mr.run.CrunchRuntimeException;
import com.cloudera.crunch.io.ReadableSourceTarget;
public class MaterializableIterable<E> implements Iterable<E> {
@@ -43,8 +44,11 @@ public MaterializableIterable(Pipeline pipeline, ReadableSourceTarget<E> source)
@Override
public Iterator<E> iterator() {
- checkMaterialized();
- return materialized.iterator();
+ if (materialized == null) {
+ pipeline.run();
+ materialize();
+ }
+ return materialized.iterator();
}
public void materialize() {
@@ -52,13 +56,7 @@ public void materialize() {
materialized = sourceTarget.read(pipeline.getConfiguration());
} catch (IOException e) {
LOG.error("Could not materialize: " + sourceTarget, e);
+ throw new CrunchRuntimeException(e);
}
}
-
- private void checkMaterialized() {
- if (materialized == null) {
- pipeline.run();
- materialize();
- }
- }
}
Please sign in to comment.
Something went wrong with that request. Please try again.