/** * Returns a new {@code Create.Values} transform that produces an empty {@link PCollection}. * * <p>The elements will have a timestamp of negative infinity, see {@link Create#timestamped} for * a way of creating a {@code PCollection} with timestamped elements. * * <p>Since there are no elements, the {@code Coder} cannot be automatically determined. Instead, * the {@code Coder} is provided via the {@code coder} argument. */ public static <T> Values<T> empty(Coder<T> coder) { return new Values<>(new ArrayList<>(), Optional.of(coder), Optional.absent()); }
/** * Returns a new {@code Create.Values} transform that produces an empty {@link PCollection}. * * <p>The elements will have a timestamp of negative infinity, see {@link Create#timestamped} for * a way of creating a {@code PCollection} with timestamped elements. * * <p>Since there are no elements, the {@code Coder} cannot be automatically determined. Instead, * the {@code Coder} is determined from given {@code TypeDescriptor<T>}. Note that a default coder * must be registered for the class described in the {@code TypeDescriptor<T>}. */ public static <T> Values<T> empty(TypeDescriptor<T> type) { return new Values<>(new ArrayList<>(), Optional.absent(), Optional.of(type)); }
/** * Returns a new {@code Create.Values} transform that produces a {@link PCollection} containing * elements of the provided {@code Iterable}. * * <p>The argument should not be modified after this is called. * * <p>The elements of the output {@link PCollection} will have a timestamp of negative infinity, * see {@link Create#timestamped} for a way of creating a {@code PCollection} with timestamped * elements. * * <p>By default, {@code Create.Values} can automatically determine the {@code Coder} to use if * all elements have the same non-parameterized run-time class, and a default coder is registered * for that class. See {@link CoderRegistry} for details on how defaults are determined. * Otherwise, use {@link Create.Values#withCoder} to set the coder explicitly. */ public static <T> Values<T> of(Iterable<T> elems) { return new Values<>(elems, Optional.absent(), Optional.absent()); }
/** * Returns a {@link Create.Values} PTransform like this one that uses the given {@code * TypeDescriptor<T>} to determine the {@code Coder} to use to decode each of the objects into a * value of type {@code T}. Note that a default coder must be registered for the class described * in the {@code TypeDescriptor<T>}. * * <p>By default, {@code Create.Values} can automatically determine the {@code Coder} to use if * all elements have the same non-parameterized run-time class, and a default coder is * registered for that class. See {@link CoderRegistry} for details on how defaults are * determined. * * <p>Note that for {@link Create.Values} with no elements, the {@link VoidCoder} is used. */ public Values<T> withType(TypeDescriptor<T> type) { return new Values<>(elems, coder, Optional.of(type)); }
/** * Returns a {@link Create.Values} PTransform like this one that uses the given {@code Coder<T>} * to decode each of the objects into a value of type {@code T}. * * <p>By default, {@code Create.Values} can automatically determine the {@code Coder} to use if * all elements have the same non-parameterized run-time class, and a default coder is * registered for that class. See {@link CoderRegistry} for details on how defaults are * determined. * * <p>Note that for {@link Create.Values} with no elements, the {@link VoidCoder} is used. */ public Values<T> withCoder(Coder<T> coder) { return new Values<>(elems, Optional.of(coder), typeDescriptor); }