Skip to content

Specialize ValueCountAggregator depending on type of ValuesSource #36752

Closed
@polyfractal

Description

@polyfractal

The value_count aggregation uses the bytesValue() of its ValuesSource. This is simple/convenient since all the different types implement it, and ValueCount doesn't need to specify what kind of ValuesSource it expects.

But the downside is that when value_count is counting up float/doubles or longs we are converting the numerics to Strings first.

This is pretty slow, and creates a ton of temporary garbage due to all the string manipulation:

image

Since value_count doesn't actually need the value, just the count of values in the field, it wouldn't be too difficult to specialize the aggregator so that slightly different versions are used for each type of ValuesSource. Then it can call the appropriate method (doubleValues(), etc) and avoid all the string casting.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions