robertwb commented on code in PR #17699:
URL: https://github.com/apache/beam/pull/17699#discussion_r876519272
##########
sdks/typescript/src/apache_beam/coders/coders.ts:
##########
@@ -38,16 +38,34 @@ interface Class<T> {
*/
class CoderRegistry {
internal_registry = {};
- get(urn: string): Class<Coder<unknown>> {
- const constructor: Class<Coder<unknown>> = this.internal_registry[urn];
+
+ getCoder(
+ urn: string,
+ payload: Uint8Array | undefined = undefined,
+ ...components: Coder<unknown>[]
+ ) {
+ const constructor: (...args) => Coder<unknown> =
+ this.internal_registry[urn];
if (constructor === undefined) {
throw new Error("Could not find coder for URN " + urn);
}
- return constructor;
+ if (payload && payload.length > 0) {
+ return constructor(payload, ...components);
+ } else {
+ return constructor(...components);
+ }
+ }
+
+ register(urn: string, constructorOrClass: Class<Coder<any>>) {
Review Comment:
The intent was to accept both here, but I wasn't able to figure out how to
cleanly distinguish between the two. Dropping a TODO for now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]