Class CachingFactory<CreatedT extends @NonNull Object>

java.lang.Object
org.apache.beam.sdk.schemas.CachingFactory<CreatedT>
All Implemented Interfaces:
Serializable, Factory<CreatedT>

public class CachingFactory<CreatedT extends @NonNull Object> extends Object implements Factory<CreatedT>
A wrapper around a Factory that assumes the schema parameter never changes.

Factory objects take the schema as a parameter, as often the returned type varies by schema (e.g. sometimes the returned-type is a list that must be in schema-field order). However in many cases it's known by the caller that the schema parameter is always the same across all calls to create. In these cases we want to save the cost of Schema comparison (which can be significant for larger schemas) on each lookup. This wrapper caches the value returned by the inner factory, so the schema comparison only need happen on the first lookup.

See Also: