Interface ParallelMetricsRollup

  • All Known Implementing Classes:
    FacetStream, StatsStream

    public interface ParallelMetricsRollup
    Indicates the underlying stream source supports parallelizing metrics computation across collections using a rollup of metrics from each collection.
    • Method Detail

      • parallelize

        TupleStream[] parallelize​(List<String> partitions)
                           throws IOException
        Given a list of collections, return an array of TupleStream for each partition.
        Parameters:
        partitions - A list of collections to parallelize metrics computation across.
        Returns:
        An array of TupleStream for each partition requested.
        Throws:
        IOException - if an error occurs while constructing the underlying TupleStream for a partition.
      • getSortedRollupStream

        TupleStream getSortedRollupStream​(ParallelListStream plistStream,
                                          Metric[] rollupMetrics)
                                   throws IOException
        Get the rollup for the parallelized streams that is sorted based on the original (non-parallel) sort order.
        Parameters:
        plistStream - A parallel list stream to fetch metrics from each partition concurrently
        rollupMetrics - An array of metrics to rollup
        Returns:
        A rollup over parallelized streams that provide metrics; this is typically a SortStream.
        Throws:
        IOException - if an error occurs while reading from the sorted stream
      • openParallelStream

        default Optional<TupleStream> openParallelStream​(StreamContext context,
                                                         List<String> partitions,
                                                         Metric[] metrics)
                                                  throws IOException
        Given a list of partitions (collections), open a select stream that projects the dimensions and metrics produced by rolling up over a parallelized group of streams. If it's not possible to rollup the metrics produced by the underlying metrics stream, this method returns Optional.empty.
        Parameters:
        context - The current streaming expression context
        partitions - A list of collections to parallelize metrics computation across.
        metrics - A list of metrics to rollup.
        Returns:
        Either a TupleStream that performs a rollup over parallelized streams or empty if parallelization is not possible.
        Throws:
        IOException - if an error occurs reading tuples from the parallelized streams
      • getRollupMetrics

        default Optional<Metric[]> getRollupMetrics​(Metric[] metrics)
        Either an array of metrics that can be parallelized and rolled up or empty.
        Parameters:
        metrics - The list of metrics that we want to parallelize.
        Returns:
        Either an array of metrics that can be parallelized and rolled up or empty.