Lens AI Profiler Cpp
Classes | Public Types | Public Member Functions | List of all members
datasketches::quantiles_sorted_view< T, Comparator, Allocator > Class Template Reference

#include <quantiles_sorted_view.hpp>

Classes

class  const_iterator
 

Public Types

using Entry = typename std::conditional< std::is_arithmetic< T >::value, std::pair< T, uint64_t >, std::pair< const T *, uint64_t > >::type
 Entry type.
 
using AllocEntry = typename std::allocator_traits< Allocator >::template rebind_alloc< Entry >
 
using Container = std::vector< Entry, AllocEntry >
 
using quantile_return_type = typename std::conditional< std::is_arithmetic< T >::value, T, const T & >::type
 
using vector_double = std::vector< double, typename std::allocator_traits< Allocator >::template rebind_alloc< double > >
 

Public Member Functions

const_iterator begin () const
 
const_iterator end () const
 
size_t size () const
 
double get_rank (const T &item, bool inclusive=true) const
 
quantile_return_type get_quantile (double rank, bool inclusive=true) const
 
vector_double get_CDF (const T *split_points, uint32_t size, bool inclusive=true) const
 
vector_double get_PMF (const T *split_points, uint32_t size, bool inclusive=true) const
 

Detailed Description

template<typename T, typename Comparator, typename Allocator>
class datasketches::quantiles_sorted_view< T, Comparator, Allocator >

Sorted view for quantiles sketches (REQ, KLL and Quantiles)

Member Typedef Documentation

◆ quantile_return_type

template<typename T , typename Comparator , typename Allocator >
using datasketches::quantiles_sorted_view< T, Comparator, Allocator >::quantile_return_type = typename std::conditional<std::is_arithmetic<T>::value, T, const T&>::type

Quantile return type. This is to return quantiles either by value (for arithmetic types) or by const reference (for all other types)

Member Function Documentation

◆ begin()

template<typename T , typename C , typename A >
auto datasketches::quantiles_sorted_view< T, C, A >::begin

Iterator pointing to the first entry in the view. If the view is empty, the returned iterator must not be dereferenced or incremented.

Returns
iterator pointing to the first entry

◆ end()

template<typename T , typename C , typename A >
auto datasketches::quantiles_sorted_view< T, C, A >::end

Iterator pointing to the past-the-end entry in the view. The past-the-end entry is the hypothetical entry that would follow the last entry. It does not point to any entry, and must not be dereferenced or incremented.

Returns
iterator pointing to the past-the-end entry

◆ get_CDF()

template<typename T , typename C , typename A >
auto datasketches::quantiles_sorted_view< T, C, A >::get_CDF ( const T *  split_points,
uint32_t  size,
bool  inclusive = true 
) const

Returns an approximation to the Cumulative Distribution Function (CDF), which is the cumulative analog of the PMF, of the input stream given a set of split points (items).

If the view is empty this throws std::runtime_error.

Parameters
split_pointsan array of m unique, monotonically increasing items that divide the input domain into m+1 consecutive disjoint intervals.
sizethe number of split points in the array
inclusiveif true the rank of an item includes its own weight, and therefore if the sketch contains items equal to a slit point, then in CDF such items are included into the interval to the left of split point. Otherwise they are included into the interval to the right of split point.
Returns
an array of m+1 doubles, which are a consecutive approximation to the CDF of the input stream given the split_points. The value at array position j of the returned CDF array is the sum of the returned values in positions 0 through j of the returned PMF array. This can be viewed as array of ranks of the given split points plus one more value that is always 1.

◆ get_PMF()

template<typename T , typename C , typename A >
auto datasketches::quantiles_sorted_view< T, C, A >::get_PMF ( const T *  split_points,
uint32_t  size,
bool  inclusive = true 
) const

Returns an approximation to the Probability Mass Function (PMF) of the input stream given a set of split points (items).

If the view is empty this throws std::runtime_error.

Parameters
split_pointsan array of m unique, monotonically increasing items that divide the input domain into m+1 consecutive disjoint intervals (bins).
sizethe number of split points in the array
inclusiveif true the rank of an item includes its own weight, and therefore if the sketch contains items equal to a slit point, then in PMF such items are included into the interval to the left of split point. Otherwise they are included into the interval to the right of split point.
Returns
an array of m+1 doubles each of which is an approximation to the fraction of the input stream items (the mass) that fall into one of those intervals.

◆ get_quantile()

template<typename T , typename C , typename A >
auto datasketches::quantiles_sorted_view< T, C, A >::get_quantile ( double  rank,
bool  inclusive = true 
) const

Returns an item from the sketch that is the best approximation to an item from the original stream with the given normalized rank.

If the view is empty this throws std::runtime_error.

Parameters
rankof an item in the hypothetical sorted stream.
inclusiveif true, the given rank is considered inclusive (includes weight of an item)
Returns
approximate quantile associated with the given normalized rank

◆ get_rank()

template<typename T , typename C , typename A >
double datasketches::quantiles_sorted_view< T, C, A >::get_rank ( const T &  item,
bool  inclusive = true 
) const

Returns an approximation to the normalized rank of the given item.

If the view is empty this throws std::runtime_error.

Parameters
itemto be ranked
inclusiveif true the weight of the given item is included into the rank. Otherwise the rank equals the sum of the weights of all items that are less than the given item according to the Comparator.
Returns
an approximate normalized rank of the given item (0 to 1 inclusive)

◆ size()

template<typename T , typename C , typename A >
size_t datasketches::quantiles_sorted_view< T, C, A >::size
Returns
size of the view

The documentation for this class was generated from the following files: