I'm working on a little library to wrap domain objects into Rows (using
RowWithGetters) and am trying to implement a new LogicalType.  I'm
struggling to understand how it's supposed to interact with RowWithGetters
however.

Let's say that my LogicalType has a java type of MyLogicalType.Value, and
base type of byte[].  This means my I have something like:

class MyLogicalType extends Schema.LogicalType<MyLogicalType.Value, byte[]>

Importantly here, I need to implement a toInputType function that takes a
byte[] and returns MyLogicalType.Value.

What I'm trying to figure out is, if I construct a RowWithGetters, it seems
like my getter for the logical type field needs to first convert from my
domain value to a byte[], which will next be converted from a byte[] ->
MyLogicalType.Value (in toInputType), and then (in the context of the
SchemaCoder), be one more time converted from MyLogicalType.Value -> byte[]
(in toBaseType).  This seems like there's an extra round trip in here that
there shouldn't be.  For reference, the first part takes place in
RowWithGetters.getValue [1]

More confusingly, OneOfType seems to be special cased to NOT do that, and
instead expects the getter to directly return a OneOfType.Value.  If it
followed the generic case, I would expect the getter to return a Row here
instead.

Any thoughts on this?

[1]
https://github.com/apache/beam/blob/b853f9c7aa3662eb707290ded4c22f86befeda68/sdks/java/core/src/main/java/org/apache/beam/sdk/values/RowWithGetters.java#L140

Reply via email to