This project has retired. For details please refer to its Attic page.
PObjectImpl (Apache Crunch 0.9.0 API)

org.apache.crunch.materialize.pobject
Class PObjectImpl<S,T>

java.lang.Object
  extended by org.apache.crunch.materialize.pobject.PObjectImpl<S,T>
Type Parameters:
S - The type contained in the underlying PCollection.
T - The type encapsulated by this PObject.
All Implemented Interfaces:
PObject<T>
Direct Known Subclasses:
CollectionPObject, FirstElementPObject, MapPObject

public abstract class PObjectImpl<S,T>
extends Object
implements PObject<T>

An abstract implementation of PObject that is backed by a PCollection. Clients creating a concrete implementation should override the method process(Iterable), which transforms the backing PCollection into the singleton value encapsulated by the PObject. Once this {code PObject}'s value has been calculated, the value is cached to prevent subsequent materializations of the backing PCollection.


Constructor Summary
PObjectImpl(PCollection<S> collect)
          Constructs a new instance of this PObject implementation.
 
Method Summary
 T getValue()
          Gets the value associated with this PObject.
protected abstract  T process(Iterable<S> input)
          Transforms the provided Iterable, obtained from the backing PCollection, into the value encapsulated by this PObject.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PObjectImpl

public PObjectImpl(PCollection<S> collect)
Constructs a new instance of this PObject implementation.

Parameters:
collect - The backing PCollection for this PObject.
Method Detail

toString

public String toString()

Overrides:
toString in class Object

getValue

public final T getValue()
Gets the value associated with this PObject. Calling this method will trigger whatever computation is necessary to obtain the value and block until that computation succeeds.

Specified by:
getValue in interface PObject<T>
Returns:
The value associated with this PObject.

process

protected abstract T process(Iterable<S> input)
Transforms the provided Iterable, obtained from the backing PCollection, into the value encapsulated by this PObject.

Parameters:
input - An Iterable whose elements correspond to those of the backing PCollection.
Returns:
The value of this PObject.


Copyright © 2014 The Apache Software Foundation. All Rights Reserved.