类 QuantileSummary

  • 所有已实现的接口:
    Serializable

    @TypeInfo(QuantileSummaryTypeInfoFactory.class)
    public class QuantileSummary
    extends Object
    implements Serializable
    Helper class to compute an approximate quantile summary. This implementation is based on the algorithm proposed in the paper: "Space-efficient Online Computation of Quantile Summaries" by Greenwald, Michael and Khanna, Sanjeev. (https://doi.org/10.1145/375663.375670)
    另请参阅:
    序列化表格
    • 构造器详细资料

      • QuantileSummary

        public QuantileSummary()
        Empty QuantileSummary Constructor.
      • QuantileSummary

        public QuantileSummary​(double relativeError)
        QuantileSummary Constructor.
        参数:
        relativeError - The target relative error.
      • QuantileSummary

        public QuantileSummary​(double relativeError,
                               int compressThreshold)
        QuantileSummary Constructor.
        参数:
        relativeError - The target relative error.
        compressThreshold - the compression threshold. After the internal buffer of statistics crosses this size, it attempts to compress the statistics together.
      • QuantileSummary

        public QuantileSummary​(double relativeError,
                               int compressThreshold,
                               List<QuantileSummary.StatsTuple> sampled,
                               long count,
                               boolean compressed)
        QuantileSummary Constructor.
        参数:
        relativeError - The target relative error.
        compressThreshold - the compression threshold.
        sampled - A buffer of quantile statistics. See the G-K article for more details.
        count - The count of all the elements inserted in the sampled buffer.
        compressed - Whether the statistics have been compressed.
    • 方法详细资料

      • insert

        public QuantileSummary insert​(double item)
        Insert a new observation into the summary.
        参数:
        item - The new observation to insert into the summary.
        返回:
        A summary with the given observation inserted into the summary.
      • compress

        public QuantileSummary compress()
        Returns a new summary that compresses the summary statistics and the head buffer.

        This implements the COMPRESS function of the GK algorithm.

        返回:
        The compressed summary.
      • merge

        public QuantileSummary merge​(QuantileSummary other)
        Merges two summaries together.
        参数:
        other - The summary to be merged.
        返回:
        The merged summary.
      • query

        public double query​(double percentile)
        Runs a query for a given percentile. The query can only be run on a compressed summary, you need to call compress() before using it.
        参数:
        percentile - The target percentile.
        返回:
        The corresponding approximate quantile.
      • query

        public double[] query​(double[] percentiles)
        Runs a query for a given sequence of percentiles. The query can only be run on a compressed summary, you need to call compress() before using it.
        参数:
        percentiles - A list of the target percentiles.
        返回:
        A list of the corresponding approximate quantiles, in the same order as the input.
      • isEmpty

        public boolean isEmpty()
        Checks whether the QuantileSummary has inserted rows. Running query on an empty QuantileSummary would cause IllegalStateException.
        返回:
        True if the QuantileSummary is empty, otherwise false.
      • getRelativeError

        public double getRelativeError()
      • getCompressThreshold

        public int getCompressThreshold()
      • getCount

        public long getCount()
      • getHeadBuffer

        public List<Double> getHeadBuffer()
      • isCompressed

        public boolean isCompressed()