crunch-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwi...@apache.org
Subject git commit: CRUNCH-320: Fix PObjectImpl materialization logic.
Date Tue, 14 Jan 2014 22:13:38 GMT
Updated Branches:
  refs/heads/master 52da56301 -> cf388fe8b


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/cf388fe8
Tree: http://git-wip-us.apache.org/repos/asf/crunch/tree/cf388fe8
Diff: http://git-wip-us.apache.org/repos/asf/crunch/diff/cf388fe8

Branch: refs/heads/master
Commit: cf388fe8bd620eaa0a41c891bebf1fb2edcc5adb
Parents: 52da563
Author: Josh Wills <jwills@apache.org>
Authored: Tue Jan 7 10:47:26 2014 -0800
Committer: Josh Wills <jwills@apache.org>
Committed: Tue Jan 14 14:10:46 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/cf388fe8/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;


Mime
View raw message