/** * Returns an empty {@link PCollectionList} that is part of the given {@link Pipeline}. * * <p>Longer {@link PCollectionList PCollectionLists} can be created by calling {@link #and} on * the result. */ public static <T> PCollectionList<T> empty(Pipeline pipeline) { return new PCollectionList<>(pipeline); }
/** * Returns a singleton {@link PCollectionList} containing the given {@link PCollection}. * * <p>Longer {@link PCollectionList PCollectionLists} can be created by calling {@link #and} on * the result. */ public static <T> PCollectionList<T> of(PCollection<T> pc) { return new PCollectionList<T>(pc.getPipeline()).and(pc); }
/** * Returns a {@link PCollectionList} containing the given {@link PCollection PCollections}, in * order. * * <p>The argument list cannot be empty. * * <p>All the {@link PCollection PCollections} in the resulting {@link PCollectionList} must be * part of the same {@link Pipeline}. * * <p>Longer PCollectionLists can be created by calling {@link #and} on the result. */ public static <T> PCollectionList<T> of(Iterable<PCollection<T>> pcs) { Iterator<PCollection<T>> pcsIter = pcs.iterator(); if (!pcsIter.hasNext()) { throw new IllegalArgumentException( "must either have a non-empty list of PCollections, " + "or must first call empty(Pipeline)"); } return new PCollectionList<T>(pcsIter.next().getPipeline()).and(pcs); }
/** * Returns a new {@link PCollectionList} that has all the {@link PCollection PCollections} of this * {@link PCollectionList} plus the given {@link PCollection PCollections} appended to the end, in * order. * * <p>All the {@link PCollection PCollections} in the resulting {@link PCollectionList} must be * part of the same {@link Pipeline}. */ public PCollectionList<T> and(Iterable<PCollection<T>> pcs) { ImmutableList.Builder<TaggedPValue> builder = ImmutableList.builder(); builder.addAll(pcollections); for (PCollection<T> pc : pcs) { if (pc.getPipeline() != pipeline) { throw new IllegalArgumentException("PCollections come from different Pipelines"); } builder.add(TaggedPValue.of(new TupleTag<T>(), pc)); } return new PCollectionList<>(pipeline, builder.build()); }
/** * Returns a new {@link PCollectionList} that has all the {@link PCollection PCollections} of this * {@link PCollectionList} plus the given {@link PCollection} appended to the end. * * <p>All the {@link PCollection PCollections} in the resulting {@link PCollectionList} must be * part of the same {@link Pipeline}. */ public PCollectionList<T> and(PCollection<T> pc) { if (pc.getPipeline() != pipeline) { throw new IllegalArgumentException("PCollections come from different Pipelines"); } return new PCollectionList<>( pipeline, ImmutableList.<TaggedPValue>builder() .addAll(pcollections) .add(TaggedPValue.of(new TupleTag<T>(), pc)) .build()); }