com.bigdata.bop.rdf.aggregate
Class COUNT

java.lang.Object
  extended by com.bigdata.bop.CoreBaseBOp
      extended by com.bigdata.bop.BOpBase
          extended by com.bigdata.bop.ImmutableBOp
              extended by com.bigdata.bop.aggregate.AggregateBase<IV>
                  extended by com.bigdata.bop.rdf.aggregate.COUNT
All Implemented Interfaces:
IAggregate<IV>, BOp, IValueExpression<IV>, IPropertySet, Serializable, Cloneable

public class COUNT
extends AggregateBase<IV>

Operator computes the number of non-null values over the presented binding sets for the given variable.

Note: COUNT(*) is the cardinality of the solution multiset. COUNT(DISTINCT *) is the cardinality of the distinct solutions in the solution multiset. These semantics are not directly handled by this class. It relies on the aggregation operator to compute those values.

Author:
thompsonbry
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.bigdata.bop.aggregate.AggregateBase
AggregateBase.Annotations
 
Field Summary
 
Fields inherited from class com.bigdata.bop.aggregate.AggregateBase
EMPTY_LITERAL, ZERO
 
Fields inherited from class com.bigdata.bop.CoreBaseBOp
DEFAULT_INITIAL_CAPACITY
 
Fields inherited from interface com.bigdata.bop.BOp
NOANNS, NOARGS
 
Constructor Summary
COUNT(boolean distinct, IValueExpression<IV> expr)
           
COUNT(BOp[] args, Map<String,Object> annotations)
           
COUNT(COUNT op)
           
 
Method Summary
 IV done()
          Return the final value.
 IV get(IBindingSet bindingSet)
          Return the current value of the aggregate (this has a side-effect on the internal state of the IAggregate operator).
 INeedsMaterialization.Requirement getRequirement()
          COUNT does not need to actually see the materialized values, or even the IVs.
 void reset()
          Reset the aggregate's internal state.
 
Methods inherited from class com.bigdata.bop.aggregate.AggregateBase
isDistinct, isWildcard
 
Methods inherited from class com.bigdata.bop.ImmutableBOp
_clearProperty, _setProperty
 
Methods inherited from class com.bigdata.bop.BOpBase
_set, annotations, annotationsCopy, annotationsEqual, annotationsRef, argIterator, args, argsCopy, arity, clearAnnotations, clearProperty, deepCopy, deepCopy, get, getProperty, setArg, setProperty, setUnboundProperty, toArray, toArray
 
Methods inherited from class com.bigdata.bop.CoreBaseBOp
annotationsEqual, annotationsToString, checkArgs, clone, equals, getEvaluationContext, getId, getProperty, getRequiredProperty, hashCode, indent, isController, toShortString, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.bigdata.bop.BOp
annotations, argIterator, args, arity, clone, get, getEvaluationContext, getId, getProperty, getRequiredProperty, isController, setProperty, toArray, toArray, toShortString, toString
 
Methods inherited from interface cutthecrap.utils.striterators.IPropertySet
getProperty
 

Constructor Detail

COUNT

public COUNT(COUNT op)

COUNT

public COUNT(BOp[] args,
             Map<String,Object> annotations)

COUNT

public COUNT(boolean distinct,
             IValueExpression<IV> expr)
Method Detail

get

public IV get(IBindingSet bindingSet)
Return the current value of the aggregate (this has a side-effect on the internal state of the IAggregate operator). Functions which can not produce an intermediate result, such as AVERAGE, MAY return null.

Note: If evaluation of the IAggregate throws an error, then that error must be "sticky" and reported out by IAggregate.done() as well. This contract is relied on to correctly propagate errors within a group when using incremental (pipelined) evaluation of IAggregates. The error state is cleared by IAggregate.reset().

Operation is not implemented by this class and must be overridden if the AggregateBase is to be directly evaluated. However, note that the computation of aggregate functions is often based on hard coded recognition of the appropriate function code.

Note: DISTINCT is merely carried as a marker on COUNT (and the other aggregate functions). The application of DISTINCT to the inner expression to form a column projection is handled by the driving evaluation logic rather than by AggregateBase.get(IBindingSet).

Note: COUNT() returns ZERO if there are no non-error solutions presented. This assumes that the ZERO will be an xsd:long.

Specified by:
get in interface IAggregate<IV>
Specified by:
get in interface IValueExpression<IV>
Overrides:
get in class AggregateBase<IV>
Parameters:
bindingSet - The binding set.
Returns:
The as bound value of the constant, variable, or expression.

reset

public void reset()
Description copied from interface: IAggregate
Reset the aggregate's internal state.


done

public IV done()
Description copied from interface: IAggregate
Return the final value.


getRequirement

public INeedsMaterialization.Requirement getRequirement()
COUNT does not need to actually see the materialized values, or even the IVs. COUNT(DISTINCT) does need to see the IVs, but they still do not need to be materialized.



Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.