Database Reference
In-Depth Information
each(System. currentTimeMillis (),key,value,cmd);
}
}
The Command<E> interface, covered in the next section, contains a single
function that is used to implement operations in a client. The Expirer
interface is similar and used by clients that can implement an optional
expiration feature.
NOTE
The aggregation driver assumes that messages are delivered with a
timestamp. This allows for messages to be delivered out-of-order or
even with significant delay, but still be delivered to the correct “time
bucket” of the back-end store. It also implements a simpler version of
each that simply uses the current time.
Implementing Clients
Implementing a client that uses the aggregation driver usually means
implementing a series of Command<E> interfaces as anonymous classes.
These are wrapped inside a method to implement a multi-resolution version
of the method. The following example prints the multi-resolution key and
value to the console:
public void doSomething( long timestamp,String
key,String value) {
aggregator.each(timestamp, key, value, new
Command<String>() {
public String execute( long timestamp, long
quantized,
String quantizedString, String key, String
value) {
String k = key+":"+quantizedString;
System. out .println(k+"="+value);
return k;
}
Search WWH ::




Custom Search