Search in sources :

Example 1 with GroupByTransform

use of org.apache.hop.beam.core.transform.GroupByTransform in project hop by apache.

the class BeamGroupByTransformHandler method handleTransform.

@Override
public void handleTransform(ILogChannel log, IVariables variables, IBeamPipelineEngineRunConfiguration runConfiguration, IHopMetadataProvider metadataProvider, PipelineMeta pipelineMeta, List<String> transformPluginClasses, List<String> xpPluginClasses, TransformMeta transformMeta, Map<String, PCollection<HopRow>> transformCollectionMap, Pipeline pipeline, IRowMeta rowMeta, List<TransformMeta> previousTransforms, PCollection<HopRow> input) throws HopException {
    MemoryGroupByMeta meta = new MemoryGroupByMeta();
    loadTransformMetadata(meta, transformMeta, metadataProvider, pipelineMeta);
    String[] aggregates = new String[meta.getAggregateType().length];
    for (int i = 0; i < aggregates.length; i++) {
        aggregates[i] = MemoryGroupByMeta.getTypeDesc(meta.getAggregateType()[i]);
    }
    PTransform<PCollection<HopRow>, PCollection<HopRow>> transformTransform = new GroupByTransform(transformMeta.getName(), // The io row
    JsonRowMeta.toJson(rowMeta), transformPluginClasses, xpPluginClasses, meta.getGroupField(), meta.getSubjectField(), aggregates, meta.getAggregateField());
    // Apply the transform transform to the previous io transform PCollection(s)
    // 
    PCollection<HopRow> transformPCollection = input.apply(transformMeta.getName(), transformTransform);
    // Save this in the map
    // 
    transformCollectionMap.put(transformMeta.getName(), transformPCollection);
    log.logBasic("Handled Group By (TRANSFORM) : " + transformMeta.getName() + ", gets data from " + previousTransforms.size() + " previous transform(s)");
}
Also used : MemoryGroupByMeta(org.apache.hop.pipeline.transforms.memgroupby.MemoryGroupByMeta) PCollection(org.apache.beam.sdk.values.PCollection) HopRow(org.apache.hop.beam.core.HopRow) GroupByTransform(org.apache.hop.beam.core.transform.GroupByTransform)

Aggregations

PCollection (org.apache.beam.sdk.values.PCollection)1 HopRow (org.apache.hop.beam.core.HopRow)1 GroupByTransform (org.apache.hop.beam.core.transform.GroupByTransform)1 MemoryGroupByMeta (org.apache.hop.pipeline.transforms.memgroupby.MemoryGroupByMeta)1