simpledb.materialize
Class CountFn

java.lang.Object
  extended by simpledb.materialize.CountFn
All Implemented Interfaces:
AggregationFn

public class CountFn
extends Object
implements AggregationFn

The count aggregation function.

Author:
Edward Sciore

Constructor Summary
CountFn(String fldname)
          Creates a count aggregation function for the specified field.
 
Method Summary
 String fieldName()
          Returns the field's name, prepended by "countof".
 void processFirst(Scan s)
          Starts a new count.
 void processNext(Scan s)
          Since SimpleDB does not support null values, this method always increments the count, regardless of the field.
 Constant value()
          Returns the current count.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CountFn

public CountFn(String fldname)
Creates a count aggregation function for the specified field.

Parameters:
fldname - the name of the aggregated field
Method Detail

processFirst

public void processFirst(Scan s)
Starts a new count. Since SimpleDB does not support null values, every record will be counted, regardless of the field. The current count is thus set to 1.

Specified by:
processFirst in interface AggregationFn
Parameters:
s - the scan to aggregate over.
See Also:
AggregationFn.processFirst(simpledb.query.Scan)

processNext

public void processNext(Scan s)
Since SimpleDB does not support null values, this method always increments the count, regardless of the field.

Specified by:
processNext in interface AggregationFn
Parameters:
s - the scan to aggregate over.
See Also:
AggregationFn.processNext(simpledb.query.Scan)

fieldName

public String fieldName()
Returns the field's name, prepended by "countof".

Specified by:
fieldName in interface AggregationFn
Returns:
the name of the new aggregation field
See Also:
AggregationFn.fieldName()

value

public Constant value()
Returns the current count.

Specified by:
value in interface AggregationFn
Returns:
the computed aggregation value
See Also:
AggregationFn.value()


Copyright © 2011. All Rights Reserved.