Counts all elements that are associated with the given key in the element map with the specified identifier and satisfy the filter condition (if specified).
Effectively, this function does the same as the following expression:
However, it will work much faster than this.findElementsByKey ( elementMapId, key, filterQuery ).count()
Parameters:
elementMapId
The element map identifier.Note: When the element map with such an identifier does not exist, the generator raises an error.
key
The hash key
filterQuery
This parameter allows you to specify an additional condition on the counted elements.When specified, this should be a boolean subquery created with
BooleanQuery()
function. The subquery will be processed against each initially selected element and should returntrue
if the element must be counted andfalse
otherwise. The tested element is passed as the generator context element.
uniqueKeyQuery
This parameter allows you to specify a different method of filtering the counted elements -- by unique keys -- which will work in addition to the direct filtering specified with thefilterQuery
parameter (above).When specified, this should be a subquery created with
FlexQuery()
function. The subquery will be executed for each tested element (initially passed thefilterQuery
condition) to generate a certain key associated with that element. The elements whose keys are repeating will be excluded from the counting.The tested element is passed to the subquery as the generator context element. The value returned by the subquery should be an object good to be a hash key. The
null
value is also allowed.Note: The
null
value in this parameter will be treated as no filtering by keys is specified.Note: When you need to filter elements by several keys with different types so that only the whole set of keys generated for each element must be unique, you can do it by creating a single compound filtering key using
HashKey()
function.
Returns:
The number of counted elements.
See Also:
findElementsByKey(), BooleanQuery()