Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Counter extends WrappingIterator {
- Key top_key;
- Value top_value;
- @Override
- public boolean hasTop() {
- return top_key != null;
- }
- @Override
- public Key getTopKey() {
- return this.top_key;
- }
- @Override
- public Value getTopValue() {
- return this.top_value;
- }
- @Override
- public void next() {
- top_key = null;
- long count = 0L;
- while(this.source.hasTop()) {
- top_key = this.source.getTopKey();
- Value v = this.source.getTopValue();
- MyObject thing = deserialize(v.get());
- count += thing.count();
- this.source.next();
- }
- this.top_value = new Value(Long.toString(count).getBytes());
- }
- @Override
- public Counter deepCopy(IteratorEnvironment env) {
- Counter c = new Counter();
- c.setSource(getSource().deepCopy(env));
- return c;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement