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

## Class StatisticsUtils

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

    public class StatisticsUtils
    extends Object

Utilities to convert statistics from/to messages, validate configurations with statistics and so on.

### Constructor Summary

Constructors
`StatisticsUtils()`

### Method Summary

All Methods Static Methods Concrete Methods
`static int` `compareVersions​(StatisticsObjectConfiguration cfg, Map<String,​Long> versions)` Test if secified statistics configuration is fit to all required versions.
`static int` `compareVersions​(ObjectStatisticsImpl stat, Map<String,​Long> versions)` Test if specified statistics are fit to all required versions.
`static StatisticsTarget` `statisticsTarget​(StatisticsKeyMessage msg)` Create statistics target from statistics key message.
`static ColumnStatistics` `toColumnStatistics​(GridKernalContext ctx, StatisticsColumnData data)` Convert statistics column data message to column statistics object.
`static BigDecimal` `toDecimal​(Object obj)`
`static StatisticsKeyMessage` `toMessage​(String schema, String obj, String... colNames)` Build stats key message.
`static StatisticsColumnData` `toMessage​(ColumnStatistics stat)` Convert ColumnStatistics to StaticColumnData message.
`static StatisticsObjectData` `toObjectData​(StatisticsKeyMessage keyMsg, StatisticsType type, ObjectStatisticsImpl stat)` Build statistics object data from values.
`static ObjectPartitionStatisticsImpl` `toObjectPartitionStatistics​(GridKernalContext ctx, StatisticsObjectData objData)` Convert StatsObjectData message to ObjectPartitionStatistics.
`static ObjectStatisticsImpl` `toObjectStatistics​(GridKernalContext ctx, StatisticsObjectData data)` Convert statistics object data message to object statistics impl.

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

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

### Constructor Detail

#### StatisticsUtils

    public StatisticsUtils()

### Method Detail

#### toMessage

    public static StatisticsColumnData toMessage​(ColumnStatistics stat)
                                          throws IgniteCheckedException

Convert ColumnStatistics to StaticColumnData message.

Parameters:
  `stat` - Column statistics to convert.
Returns:
  Converted stats column data message.
Throws:
  `IgniteCheckedException` - In case of errors.

#### toColumnStatistics

    public static ColumnStatistics toColumnStatistics​(GridKernalContext ctx,
                                                      StatisticsColumnData data)

Convert statistics column data message to column statistics object.

Parameters:
  `ctx` - Kernal context.
  `data` - Statistics column data message to convert.
Returns:
  ColumnStatistics object.

#### toObjectData

    public static StatisticsObjectData toObjectData​(StatisticsKeyMessage keyMsg,
                                                    StatisticsType type,
                                                    ObjectStatisticsImpl stat)
                                             throws IgniteCheckedException

Build statistics object data from values.

Parameters:
  `keyMsg` - Statistics key.
  `type` - Statistics type.
  `stat` - Object statistics to convert.
Returns:
  Converted StatsObjectData message.
Throws:
  `IgniteCheckedException` - In case of errors.

#### toMessage

    public static StatisticsKeyMessage toMessage​(String schema,
                                                 String obj,
                                                 String... colNames)

Build stats key message.

Parameters:
  `schema` - Schema name.
  `obj` - Object name.
  `colNames` - Column names or `null`.
Returns:
  Statistics key message.

#### toObjectPartitionStatistics

    public static ObjectPartitionStatisticsImpl toObjectPartitionStatistics​(GridKernalContext ctx,
                                                                            StatisticsObjectData objData)
                                                                     throws IgniteCheckedException

Convert StatsObjectData message to ObjectPartitionStatistics.

Parameters:
  `ctx` - Kernal context to use during conversion.
  `objData` - StatsObjectData to convert.
Returns:
  Converted ObjectPartitionStatistics.
Throws:
  `IgniteCheckedException` - In case of errors.

#### toObjectStatistics

    public static ObjectStatisticsImpl toObjectStatistics​(GridKernalContext ctx,
                                                          StatisticsObjectData data)

Convert statistics object data message to object statistics impl.

Parameters:
  `ctx` - Kernal context to use during conversion.
  `data` - Statistics object data message to convert.
Returns:
  Converted object statistics.

#### statisticsTarget

    public static StatisticsTarget statisticsTarget​(StatisticsKeyMessage msg)

Create statistics target from statistics key message.

Parameters:
  `msg` - Source statistics key message;
Returns:
  StatisticsTarget.

#### compareVersions

    public static int compareVersions​(ObjectStatisticsImpl stat,
                                      Map<String,​Long> versions)

Test if specified statistics are fit to all required versions. It means that specified statistics contains all columns with at least versions from specified map.

Parameters:
  `stat` - Statistics to check. Can be `null`.
  `versions` - Map of column name to required version.
Returns:
  positive value if statistics versions bigger than specified in versions map, negative value if statistics version smaller than specified in version map, zero it they are equals.

#### compareVersions

    public static int compareVersions​(StatisticsObjectConfiguration cfg,
                                      Map<String,​Long> versions)

Test if secified statistics configuration is fit to all required versions. It means that specified statistics configuraion contains all columns with at least versions from specified map.

Parameters:
  `cfg` - Statistics configuraion to check. Can be `null`.
  `versions` - Map of column name to required version.
Returns:
  `true` if it is, `talse` otherwise.

#### toDecimal

    public static BigDecimal toDecimal​(Object obj)