Database Reference
In-Depth Information
SimpleDateFormat sdf =
formatForMillis (resolutionMillis);
return sdf .format( new Date(time));
}
Aggregation Driver
After aggregates have been defined, a driver is needed to apply them to
specific functions. This is done inside of the Aggregator class by
implementing an each method that computes each of the quantized values
and then executes a command:
public class Aggregator {
ArrayList<Aggregate> aggregates = new
ArrayList<Aggregate>();
public Aggregator aggregate(Aggregate e) {
aggregates.add(e);
return this ;
}
Expirer expirer = null ;
public Aggregator expirer(Expirer expirer) {
this .expirer = expirer;
return this ;
}
public <E> void each( long timestamp,String key,
E value,Command<E> cmd) {
for (Aggregate a : aggregates) {
long quantized = a.quantize(timestamp);
String quantizedString =
a.quantizeString(timestamp);
String expireKey = cmd.execute(timestamp,
quantized,quantizedString,key, value);
if (expireKey != null && expirer != null ) {
expirer.expire(expireKey, a.expire(timestamp));
}
}
}
public <E> void each(String key,E value,Command<E>
cmd) {
Search WWH ::




Custom Search