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

com.tinkerpop.pipes.sideeffect.CountPipe Maven / Gradle / Ivy

package com.tinkerpop.pipes.sideeffect;

import com.tinkerpop.pipes.AbstractPipe;
import com.tinkerpop.pipes.util.PipeHelper;


/**
 * The CountPipe produces a side effect that is the total number of objects that have passed through it.
 *
 * @author Marko A. Rodriguez (http://markorodriguez.com)
 */
public class CountPipe extends AbstractPipe implements SideEffectPipe {

    private Long counter = 0l;

    protected S processNextStart() {
        final S s = this.starts.next();
        this.counter++;
        return s;
    }

    public Long getSideEffect() {
        return this.counter;
    }

    public void reset() {
        this.counter = 0l;
        super.reset();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy