本文整理匯總了Java中org.apache.beam.sdk.coders.VoidCoder.of方法的典型用法代碼示例。如果您正苦於以下問題:Java VoidCoder.of方法的具體用法?Java VoidCoder.of怎麽用?Java VoidCoder.of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.beam.sdk.coders.VoidCoder
的用法示例。
在下文中一共展示了VoidCoder.of方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: inferCoderFromObject
import org.apache.beam.sdk.coders.VoidCoder; //導入方法依賴的package包/類
/**
* Attempt to infer the type for some very common Apache Beam parameterized types.
*
* <p>TODO: Instead, build a TypeDescriptor so that the {@link CoderRegistry} is invoked
* for the type instead of hard coding the coders for common types.
*/
private static Coder<?> inferCoderFromObject(CoderRegistry registry, Object o)
throws CannotProvideCoderException {
if (o == null) {
return VoidCoder.of();
} else if (o instanceof TimestampedValue) {
return TimestampedValueCoder.of(
inferCoderFromObject(registry, ((TimestampedValue) o).getValue()));
} else if (o instanceof List) {
return ListCoder.of(inferCoderFromObjects(registry, ((Iterable) o)));
} else if (o instanceof Set) {
return SetCoder.of(inferCoderFromObjects(registry, ((Iterable) o)));
} else if (o instanceof Collection) {
return CollectionCoder.of(inferCoderFromObjects(registry, ((Iterable) o)));
} else if (o instanceof Iterable) {
return IterableCoder.of(inferCoderFromObjects(registry, ((Iterable) o)));
} else if (o instanceof Map) {
return MapCoder.of(
inferCoderFromObjects(registry, ((Map) o).keySet()),
inferCoderFromObjects(registry, ((Map) o).entrySet()));
} else if (o instanceof KV) {
return KvCoder.of(
inferCoderFromObject(registry, ((KV) o).getKey()),
inferCoderFromObject(registry, ((KV) o).getValue()));
} else {
return registry.getCoder(o.getClass());
}
}
示例2: getDefaultCoder
import org.apache.beam.sdk.coders.VoidCoder; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private <T> Coder<T> getDefaultCoder(Class<T> c) {
if (Writable.class.isAssignableFrom(c)) {
Class<? extends Writable> writableClass = (Class<? extends Writable>) c;
return (Coder<T>) WritableCoder.of(writableClass);
} else if (Void.class.equals(c)) {
return (Coder<T>) VoidCoder.of();
}
// TODO: how to use registered coders here?
throw new IllegalStateException("Cannot find coder for " + c);
}
示例3: getAccumulatorCoder
import org.apache.beam.sdk.coders.VoidCoder; //導入方法依賴的package包/類
@Override
public Coder<Void> getAccumulatorCoder(CoderRegistry registry, Coder<Integer> inputCoder) {
return (Coder) VoidCoder.of();
}