Class ThriftSchema

All Implemented Interfaces:
Serializable, SchemaProvider

public final class ThriftSchema extends GetterBasedSchemaProviderV2
Schema provider for generated thrift types.

The mapping logic relies on the available thrift metadata introspection and tries to make as few assumptions about the generated code as possible (i.e. does not rely on accessor naming convention, as the thrift compiler supports options such as "beans" or "fullcamel"/"nocamel".
However, the following strong assumptions are made by this class:

  • All thrift generated classes implement TBase, except for enums which become java enums implementing TEnum.
  • All TUnion types provide static factory methods for each of the supported field types, with the same name as the field itself and only one such method taking a single parameter exists.
  • All non-union types have a corresponding java field with the same name for every field in the original thrift source file.

Thrift typedefs for container types (and possibly others) do not preserve the full type information. For this reason, this class allows for manual registration of such "lossy" typedefs with their corresponding beam types.

Note: Thrift encoding and decoding are not fully symmetrical, i.e. the isSet flag may not be preserved upon converting a thrift object to a beam row and back. On encoding, we extract all thrift values, no matter if the fields are set or not. On decoding, we set all non-null beam row values to the corresponding thrift fields, leaving the rest unset.

See Also: