All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lumiomedical.flow.stream.StreamAccumulator Maven / Gradle / Ivy

Go to download

A library providing an opinionated way of structuring data processing programs such as ETLs

The newest version!
package com.lumiomedical.flow.stream;

import com.lumiomedical.flow.FlowOut;
import com.lumiomedical.flow.Join;
import com.lumiomedical.flow.Pipe;
import com.lumiomedical.flow.Sink;
import com.lumiomedical.flow.actor.accumulator.Accumulator;
import com.lumiomedical.flow.actor.generator.Generator;
import com.lumiomedical.flow.actor.loader.Loader;
import com.lumiomedical.flow.actor.transformer.BiTransformer;
import com.lumiomedical.flow.actor.transformer.Transformer;
import com.lumiomedical.flow.io.output.Recipient;
import com.lumiomedical.flow.node.SimpleNode;

import java.util.function.Function;

/**
 * @author Pierre Lecerf ([email protected])
 * Created on 2020/12/03
 */
public class StreamAccumulator  extends SimpleNode> implements StreamIn, FlowOut
{
    /**
     * @param actor
     */
    public StreamAccumulator(Accumulator actor)
    {
        super(actor);
    }

    @Override
    public  Pipe into(Transformer transformer)
    {
        var pipe = new Pipe<>(transformer);
        this.bind(pipe);
        return pipe;
    }

    @Override
    public Sink into(Loader loader)
    {
        var sink = new Sink<>(loader);
        this.bind(sink);
        return sink;
    }

    @Override
    public  Join join(FlowOut input, BiTransformer transformer)
    {
        return new Join<>(this, input, transformer);
    }

    @Override
    public  StreamGenerator stream(Function> generatorSupplier)
    {
        var pipe = new StreamGenerator<>(generatorSupplier);
        this.bind(pipe);
        return pipe;
    }

    /**
     *
     * @param loader
     * @return
     */
    public StreamAccumulator driftSink(Loader loader)
    {
        this.into(loader);
        return this;
    }

    @Override
    public Recipient collect(String name)
    {
        Recipient recipient = new Recipient<>(name);
        this.bind(recipient);
        return recipient;
    }

    /**
     *
     * @param name
     * @return
     */
    public StreamAccumulator sample(String name)
    {
        this.collect(name);
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy