Package org.apache.beam.sdk.schemas
Class CachingFactory<CreatedT>
- java.lang.Object
-
- org.apache.beam.sdk.schemas.CachingFactory<CreatedT>
-
- All Implemented Interfaces:
java.io.Serializable
,Factory<CreatedT>
public class CachingFactory<CreatedT> extends java.lang.Object implements Factory<CreatedT>
A wrapper around aFactory
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CachingFactory(Factory<CreatedT> innerFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CreatedT
create(java.lang.Class<?> clazz, Schema schema)
boolean
equals(@Nullable java.lang.Object o)
int
hashCode()
-