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

com.netflix.astyanax.recipes.functions.RowCounterFunction Maven / Gradle / Ivy

There is a newer version: 3.8.0-bv14
Show newest version
package com.netflix.astyanax.recipes.functions;

import java.util.concurrent.atomic.AtomicLong;

import com.google.common.base.Function;
import com.netflix.astyanax.model.Row;

/**
 * Simple function to counter the number of rows
 * 
 * @author elandau
 *
 * @param 
 * @param 
 */
public class RowCounterFunction implements Function, Boolean> {

    private final AtomicLong counter = new AtomicLong(0);
    
    @Override
    public Boolean apply(Row input) {
        counter.incrementAndGet();
        return true;
    }
    
    public long getCount() {
        return counter.get();
    }

    public void reset() {
        counter.set(0);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy