Class Create<T>

java.lang.Object
org.apache.beam.sdk.transforms.Create<T>
Type Parameters:
T - the type of the elements of the resulting PCollection

public class Create<T> extends Object
Create<T> takes a collection of elements of type T known when the pipeline is constructed and returns a PCollection<T> containing the elements.

Example of use:


 Pipeline p = ...;

 PCollection<Integer> pc = p.apply(Create.of(3, 4, 5).withCoder(BigEndianIntegerCoder.of()));

 Map<String, Integer> map = ...;
 PCollection<KV<String, Integer>> pt =
     p.apply(Create.of(map)
      .withCoder(KvCoder.of(StringUtf8Coder.of(),
                            BigEndianIntegerCoder.of())));
 

Create can automatically determine the Coder to use if all elements have the same run-time class, and a default coder is registered for that class. See CoderRegistry for details on how defaults are determined.

If a coder can not be inferred, Create.Values.withCoder(org.apache.beam.sdk.coders.Coder<T>) must be called explicitly to set the encoding of the resulting PCollection.

A good use for Create is when a PCollection needs to be created without dependencies on files or other external entities. This is especially useful during testing.

Caveat: Create only supports small in-memory datasets.