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

com.netflix.astyanax.recipes.functions.ColumnCounterFunction 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;

/**
 * Very basic function to count the total number of columns
 * 
 * @author elandau
 *
 * @param 
 * @param 
 */
public class ColumnCounterFunction implements Function, Boolean> {

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

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy