I have two questions related to coder issues I am facing with my Dataflow pipeline.
Any help regarding these two items would be helpful as I am kind of stuck on this for sometime now.
Custom code comes in many shapes and forms. Often, custom code is used to connect two systems together, which is known as point-to-point integration. Point-to-point integration requires developers to build custom code between numerous applications, systems, data and devices within the enterprise.
You can include code examples in your HTML by using the <code> tag. This automatically uses a monospaced font and also semantically labels our code as what it is.
Custom code entered in the Head code section appears before the closing </head> tag in your site's HTML markup and applies to your entire site.
In the Home menu, click Settings, click Advanced, then click Code Injection. Add valid HTML or scripts into the appropriate Code Injection fields for the header, footer, lock page, or order confirmation page. After adding your code, click Save.
It looks like you have been bitten by two issues. Thanks for bringing them to our attention! Fortunately, there are easy workarounds for both while we improve things.
The first issue is that the default coder registry does not have an entry for mapping Set.class
to SetCoder
. We have filed GitHub issue #56 to track its resolution. In the meantime, you can use the following code to perform the needed registration:
pipeline.getCoderRegistry().registerCoder(Set.class, SetCoder.class);
The second issue is that parameterized types currently require advanced treatment in the coder registry, so the @DefaultCoder
will not be honored. We have filed Github issue #57 to track this. The best way to ensure that SerializableCoder
is used everywhere for CustomType
is to register a CoderFactory
for your type that will return a SerializableCoder
. Supposing your type is something like this:
public class CustomType<T extends Serializable> implements Serializable {
T field;
}
Then the following code registers a CoderFactory
that produces appropriate SerializableCoder
instances:
pipeline.getCoderRegistry().registerCoder(CustomType.class, new CoderFactory() {
@Override
public Coder<?> create(List<? extends Coder<?>>) {
// No matter what the T is, return SerializableCoder
return SerializableCoder.of(CustomType.class);
}
@Override
public List<Object> getInstanceComponents(Object value) {
// Return the T inside your CustomType<T> to enable coder inference for Create
return Collections.singletonList(((CustomType<Object>) value).field);
}
});
Now, whenever you use CustomType
in your pipeline, the coder registry will produce a SerializableCoder
.
Note that SerializableCoder
is not deterministic (the bytes of encoded objects are not necessarily equal for objects that are equals()
) so values encoded using this coder cannot be used as keys in a GroupByKey
operation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With