Documentation ¶
Overview ¶
Package transform contains methods to transform json trees as specified by the config.
Index ¶
- type DefaultTransformer
- func (t *DefaultTransformer) HasPostProcessProjector() bool
- func (t *DefaultTransformer) JSONtoJSON(in json.RawMessage) (json.RawMessage, error)
- func (t *DefaultTransformer) LoadMappingConfig(config *dhpb.DataHarmonizationConfig) (*mappb.MappingConfig, error)
- func (t *DefaultTransformer) LoadProjectors(projectors []*mappb.ProjectorDefinition) error
- func (t *DefaultTransformer) ParseJSON(in json.RawMessage) (jsonutil.JSONToken, error)
- func (t *DefaultTransformer) Project(projector string, args ...jsonutil.JSONMetaNode) (res jsonutil.JSONToken, err error)
- func (t *DefaultTransformer) RegisterProjector(name string, proj types.Projector) error
- func (t *DefaultTransformer) Registry() *types.Registry
- func (t *DefaultTransformer) Transform(in jsonutil.JSONToken) (res jsonutil.JSONToken, err error)
- type Option
- type Options
- type TransformationConfig
- type Transformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultTransformer ¶
type DefaultTransformer struct {
// contains filtered or unexported fields
}
DefaultTransformer contains projectors initialized for a specific config, and receiver methods to perform transformations.
func NewDefaultTransformer ¶
func NewDefaultTransformer(ctx context.Context, config *dhpb.DataHarmonizationConfig, tconfig TransformationConfig, setters ...Option) (*DefaultTransformer, error)
NewDefaultTransformer creates and initializes a default transformer.
func (*DefaultTransformer) HasPostProcessProjector ¶
func (t *DefaultTransformer) HasPostProcessProjector() bool
HasPostProcessProjector returns true iff a post process projector is set.
func (*DefaultTransformer) JSONtoJSON ¶
func (t *DefaultTransformer) JSONtoJSON(in json.RawMessage) (json.RawMessage, error)
JSONtoJSON converts the byte array (JSON format) using the specified config.
func (*DefaultTransformer) LoadMappingConfig ¶
func (t *DefaultTransformer) LoadMappingConfig(config *dhpb.DataHarmonizationConfig) (*mappb.MappingConfig, error)
LoadMappingConfig loads the mapping config inline or from a GCS path.
func (*DefaultTransformer) LoadProjectors ¶
func (t *DefaultTransformer) LoadProjectors(projectors []*mappb.ProjectorDefinition) error
LoadProjectors registers all given projectors.
func (*DefaultTransformer) ParseJSON ¶
func (t *DefaultTransformer) ParseJSON(in json.RawMessage) (jsonutil.JSONToken, error)
ParseJSON parses the given JSON into a JSONToken.
func (*DefaultTransformer) Project ¶
func (t *DefaultTransformer) Project(projector string, args ...jsonutil.JSONMetaNode) (res jsonutil.JSONToken, err error)
Project is a convenience function to call a single projector out of context.
func (*DefaultTransformer) RegisterProjector ¶
func (t *DefaultTransformer) RegisterProjector(name string, proj types.Projector) error
RegisterProjector adds the given Projector to this transformer's registry.
func (*DefaultTransformer) Registry ¶
func (t *DefaultTransformer) Registry() *types.Registry
Registry returns the registry in DefaultTransformer.
type Option ¶
type Option func(*Options)
Option is a setter function for Options.
func CloudFunctions ¶
CloudFunctions initializes the CloudFunctions transform option.
func FetchConfigs ¶
FetchConfigs initializes the FetchConfigs transform option.
func GCSClient ¶
func GCSClient(c gcsutil.StorageClient) Option
GCSClient sets the GCSClient in the transform option.
type Options ¶
type Options struct { // CloudFunctions enables support for cloud functions within the transform library. CloudFunctions bool // FetchConfigs enables support for fetch configurations wtihin the transform library. FetchConfigs bool // Parallel enables support for parallelization within the transform library. Parallel bool // GCSClient is a client for downloading from GCS. If unset, the default third party GCS client will be used. GCSClient gcsutil.StorageClient }
Options for initializing Data Harmonization transform library
type TransformationConfig ¶
TransformationConfig contains metadata used during transformation.
type Transformer ¶
type Transformer interface { // Transform transforms given JSONToken (parsed JSON) into a target JSONToken using the // config. Transform(jsonutil.JSONToken) (jsonutil.JSONToken, error) // JSONtoJSON transforms given raw JSON into a target raw JSON using the config. JSONtoJSON(json.RawMessage) (json.RawMessage, error) // ParseJSON parses given raw JSON into a JSONToken. ParseJSON(json.RawMessage) (jsonutil.JSONToken, error) // LoadProjectors registers all given projectors in the config. LoadProjectors([]*mappb.ProjectorDefinition) error // Registry returns the registry used in Transformer. Registry() *types.Registry // HasPostProcessProjector returns true iff a post process projector is set. HasPostProcessProjector() bool }
Transformer defines an interface to perform transformations.
func NewTransformer ¶
func NewTransformer(ctx context.Context, config *dhpb.DataHarmonizationConfig, tconfig TransformationConfig, setters ...Option) (Transformer, error)
NewTransformer creates and initializes a transformer, and returns a new DefaultTransformer by default.