com.netflix.astyanax.recipes.functions.ColumnCounterFunction Maven / Gradle / Ivy
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);
}
}