Class StatisticsUtils


  • public class StatisticsUtils
    extends Object
    Utilities to convert statistics from/to messages, validate configurations with statistics and so on.
    • Constructor Detail

      • StatisticsUtils

        public StatisticsUtils()
    • Method Detail

      • 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.
      • 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.
      • 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.