Package org.apache.ignite.internal.processors.query.stat

## Class IgniteStatisticsHelper

- java.lang.Object
- - org.apache.ignite.internal.processors.query.stat.IgniteStatisticsHelper

    public class IgniteStatisticsHelper
    extends Object

Utility methods to statistics messages generation.

### Constructor Summary

Constructors
`IgniteStatisticsHelper​(UUID locNodeId, SchemaManager schemaMgr, Function<Class<?>,​IgniteLogger> logSupplier)` Constructor.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static ObjectStatisticsImpl` `aggregateLocalStatistics​(GridQueryTypeDescriptor tbl, StatisticsObjectConfiguration cfg, Collection<? extends ObjectStatisticsImpl> stats, IgniteLogger log)` Aggregate partition level statistics to local level one or local statistics to global one.
`ObjectStatisticsImpl` `aggregateLocalStatistics​(StatisticsObjectConfiguration cfg, Collection<? extends ObjectStatisticsImpl> stats)` Aggregate specified partition level statistics to local level statistics.
`static StatisticsObjectConfiguration[]` `buildDefaultConfigurations​(StatisticsTarget... targets)` Build object configurations array with all default parameters from specified targets.
`static long` `calculateRowCount​(StatisticsObjectConfiguration cfg, long actualRowCnt)` Calculate effective row count.
`static List<T2<Integer,​String>>` `filterColumns​(GridQueryTypeDescriptor typeDescriptor, @Nullable Collection<String> colNames)` Filter columns by specified names.
`List<StatisticsAddressedRequest>` `generateGatheringRequests​(StatisticsTarget target, StatisticsObjectConfiguration cfg)` Generate local statistics requests.
`CacheGroupContext` `groupContext​(StatisticsKey key)` Get cache group context by specified statistics key.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### IgniteStatisticsHelper

    public IgniteStatisticsHelper​(UUID locNodeId,
                                  SchemaManager schemaMgr,
                                  Function<Class<?>,​IgniteLogger> logSupplier)

Constructor.

Parameters:
  `locNodeId` - Local node id.
  `schemaMgr` - Schema manager.
  `logSupplier` - Ignite logger supplier to get logger from.

### Method Detail

#### groupContext

    public CacheGroupContext groupContext​(StatisticsKey key)
                                   throws IgniteCheckedException

Get cache group context by specified statistics key.

Parameters:
  `key` - Statistics key to get context by.
Returns:
  Cache group context for the given key.
Throws:
  `IgniteCheckedException` - If unable to find table by specified key.

#### generateGatheringRequests

    public List<StatisticsAddressedRequest> generateGatheringRequests​(StatisticsTarget target,
                                                                      StatisticsObjectConfiguration cfg)
                                                               throws IgniteCheckedException

Generate local statistics requests.

Parameters:
  `target` - Statistics target to request local statistics by.
  `cfg` - Statistics configuration.
Returns:
  Collection of statistics request.
Throws:
  `IgniteCheckedException`

#### aggregateLocalStatistics

    public ObjectStatisticsImpl aggregateLocalStatistics​(StatisticsObjectConfiguration cfg,
                                                         Collection<? extends ObjectStatisticsImpl> stats)

Aggregate specified partition level statistics to local level statistics.

Parameters:
  `cfg` - Statistics object configuration.
  `stats` - Collection of all local partition level or local level statistics by specified key to aggregate.
Returns:
  Local level aggregated statistics.

#### aggregateLocalStatistics

    public static ObjectStatisticsImpl aggregateLocalStatistics​(GridQueryTypeDescriptor tbl,
                                                                StatisticsObjectConfiguration cfg,
                                                                Collection<? extends ObjectStatisticsImpl> stats,
                                                                IgniteLogger log)

Aggregate partition level statistics to local level one or local statistics to global one.

Parameters:
  `tbl` - Table to aggregate statistics by.
  `cfg` - Statistics object configuration.
  `stats` - Collection of partition level or local level statistics to aggregate.
  `log` - Logger.
Returns:
  Local level statistics.

#### calculateRowCount

    public static long calculateRowCount​(StatisticsObjectConfiguration cfg,
                                         long actualRowCnt)

Calculate effective row count. If there are some overrides in statistics configuration - maximum value will be choosen. If not - will return `actualRowCnt`.

Parameters:
  `cfg` - Statistics configuration to dig overrides row count from.
  `actualRowCnt` - Actual row count.
Returns:
  Effective row count.

#### buildDefaultConfigurations

    public static StatisticsObjectConfiguration[] buildDefaultConfigurations​(StatisticsTarget... targets)

Build object configurations array with all default parameters from specified targets.

Parameters:
  `targets` - Targets to build configurations from.
Returns:
  StatisticsObjectConfiguration array.

#### filterColumns

    public static List<T2<Integer,​String>> filterColumns​(GridQueryTypeDescriptor typeDescriptor,
                                                               @Nullable
                                                               @Nullable Collection<String> colNames)

Filter columns by specified names.

Parameters:
  `typeDescriptor` - Table descriptor.
  `colNames` - Column names.
Returns:
  Column with specified names.