Updated Branches: refs/heads/apache-crunch-0.8 54cef7b17 -> e0efefdf4
CRUNCH-320: Fix PObjectImpl materialization logic. Project: http://git-wip-us.apache.org/repos/asf/crunch/repo Commit: http://git-wip-us.apache.org/repos/asf/crunch/commit/e0efefdf Tree: http://git-wip-us.apache.org/repos/asf/crunch/tree/e0efefdf Diff: http://git-wip-us.apache.org/repos/asf/crunch/diff/e0efefdf Branch: refs/heads/apache-crunch-0.8 Commit: e0efefdf43fafbc65fd7b6bdb6da8fdce8e4d580 Parents: 54cef7b Author: Josh Wills <[email protected]> Authored: Tue Jan 7 10:47:26 2014 -0800 Committer: Josh Wills <[email protected]> Committed: Tue Jan 14 14:13:58 2014 -0800 ---------------------------------------------------------------------- .../crunch/materialize/pobject/PObjectImpl.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/crunch/blob/e0efefdf/crunch-core/src/main/java/org/apache/crunch/materialize/pobject/PObjectImpl.java ---------------------------------------------------------------------- diff --git a/crunch-core/src/main/java/org/apache/crunch/materialize/pobject/PObjectImpl.java b/crunch-core/src/main/java/org/apache/crunch/materialize/pobject/PObjectImpl.java index 59c2ba2..9adf4b1 100644 --- a/crunch-core/src/main/java/org/apache/crunch/materialize/pobject/PObjectImpl.java +++ b/crunch-core/src/main/java/org/apache/crunch/materialize/pobject/PObjectImpl.java @@ -19,8 +19,6 @@ package org.apache.crunch.materialize.pobject; import org.apache.crunch.PCollection; import org.apache.crunch.PObject; -import org.apache.crunch.Pipeline; -import org.apache.crunch.Target; /** * An abstract implementation of {@link PObject} that is backed by a {@link PCollection}. @@ -35,9 +33,11 @@ import org.apache.crunch.Target; */ public abstract class PObjectImpl<S, T> implements PObject<T> { - // The underlying PCollection whose contents will be used to generate the value for this - // PObject. - private PCollection<S> collection; + // The name of the collection, used as the name for this instance as well. + private String name; + + // A referenced to the materialized contents of a PCollection. + private Iterable<S> iterable; // A variable to hold a cached copy of the value of this {@code PObject}, // to prevent unnecessary materializations of the backing {@code PCollection}. @@ -52,7 +52,8 @@ public abstract class PObjectImpl<S, T> implements PObject<T> { * @param collect The backing {@code PCollection} for this {@code PObject}. */ public PObjectImpl(PCollection<S> collect) { - this.collection = collect; + this.name = collect.toString(); + this.iterable = collect.materialize(); this.cachedValue = null; this.isCached = false; } @@ -60,14 +61,14 @@ public abstract class PObjectImpl<S, T> implements PObject<T> { /** {@inheritDoc} */ @Override public String toString() { - return collection.toString(); + return name; } /** {@inheritDoc} */ @Override public final T getValue() { if (!isCached) { - cachedValue = process(collection.materialize()); + cachedValue = process(iterable); isCached = true; } return cachedValue;
