OmniSciDB  16c4e035a1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
quantile::detail::CentroidsMerger< RealType, IndexType > Class Template Reference

#include <quantile.h>

Public Member Functions

DEVICE CentroidsMerger (Centroids< RealType, IndexType > *buf, Centroids< RealType, IndexType > *centroids, bool const forward)
 
DEVICE Centroids< RealType,
IndexType > * 
getNextCentroid () const
 
DEVICE bool hasNext () const
 
DEVICE void merge (IndexType const max_count)
 
DEVICE void next ()
 
DEVICE IndexType prefixSum () const
 
DEVICE IndexType totalWeight () const
 

Private Member Functions

DEVICE void mergeMinMax ()
 
DEVICE void setCurrCentroid ()
 

Private Attributes

Centroids< RealType, IndexType > * buf_
 
Centroids< RealType, IndexType > * centroids_
 
Centroids< RealType, IndexType > * curr_centroid_
 
IndexType prefix_sum_ {0}
 
IndexType const total_weight_
 
bool const forward_
 

Detailed Description

template<typename RealType, typename IndexType>
class quantile::detail::CentroidsMerger< RealType, IndexType >

Definition at line 134 of file quantile.h.

Constructor & Destructor Documentation

template<typename RealType , typename IndexType >
DEVICE quantile::detail::CentroidsMerger< RealType, IndexType >::CentroidsMerger ( Centroids< RealType, IndexType > *  buf,
Centroids< RealType, IndexType > *  centroids,
bool const  forward 
)

Definition at line 400 of file quantile.h.

References quantile::detail::CentroidsMerger< RealType, IndexType >::buf_, quantile::detail::CentroidsMerger< RealType, IndexType >::centroids_, quantile::detail::CentroidsMerger< RealType, IndexType >::forward_, quantile::detail::CentroidsMerger< RealType, IndexType >::mergeMinMax(), and quantile::detail::CentroidsMerger< RealType, IndexType >::setCurrCentroid().

404  : buf_(buf)
405  , centroids_(centroids)
406  , total_weight_(centroids->totalWeight() + buf->totalWeight())
407  , forward_(forward) {
408  buf_->resetIndices(forward_);
409  centroids_->resetIndices(forward_);
410  mergeMinMax();
411  setCurrCentroid();
412 }
Centroids< RealType, IndexType > * buf_
Definition: quantile.h:135
Centroids< RealType, IndexType > * centroids_
Definition: quantile.h:136

+ Here is the call graph for this function:

Member Function Documentation

template<typename RealType , typename IndexType >
DEVICE Centroids< RealType, IndexType > * quantile::detail::CentroidsMerger< RealType, IndexType >::getNextCentroid ( ) const

Definition at line 416 of file quantile.h.

416  {
417  if (buf_->hasNext()) {
418  if (centroids_->hasNext()) {
419  return (*buf_ < *centroids_) == forward_ ? buf_ : centroids_;
420  }
421  return buf_;
422  } else if (centroids_->hasNext()) {
423  return centroids_;
424  }
425  return nullptr;
426 }
Centroids< RealType, IndexType > * buf_
Definition: quantile.h:135
Centroids< RealType, IndexType > * centroids_
Definition: quantile.h:136
template<typename RealType , typename IndexType >
DEVICE bool quantile::detail::CentroidsMerger< RealType, IndexType >::hasNext ( ) const
inline

Definition at line 153 of file quantile.h.

References quantile::detail::CentroidsMerger< RealType, IndexType >::buf_, and quantile::detail::CentroidsMerger< RealType, IndexType >::centroids_.

153 { return buf_->hasNext() || centroids_->hasNext(); }
Centroids< RealType, IndexType > * buf_
Definition: quantile.h:135
Centroids< RealType, IndexType > * centroids_
Definition: quantile.h:136
template<typename RealType , typename IndexType >
DEVICE void quantile::detail::CentroidsMerger< RealType, IndexType >::merge ( IndexType const  max_count)

Definition at line 525 of file quantile.h.

Referenced by quantile::detail::TDigest< RealType, IndexType >::mergeCentroids().

525  {
526  Skipped<RealType, IndexType> skipped;
527  while (auto* next_centroid = getNextCentroid()) {
528  if (skipped) {
529  if (skipped.isDifferentMean(next_centroid)) {
530  break;
531  } else if (curr_centroid_->mergeIfFits(*next_centroid, max_count)) {
532  skipped.merged(next_centroid);
533  } else {
534  skipped.skipSubsequent(next_centroid);
535  }
536  } else if (!curr_centroid_->mergeIfFits(*next_centroid, max_count)) {
537  skipped.skipFirst(next_centroid);
538  }
539  }
540  if (skipped) {
541  skipped.shiftCentroidsAndSetNext();
542  }
543 }
DEVICE Centroids< RealType, IndexType > * getNextCentroid() const
Definition: quantile.h:416
Centroids< RealType, IndexType > * curr_centroid_
Definition: quantile.h:137

+ Here is the caller graph for this function:

template<typename RealType , typename IndexType >
DEVICE void quantile::detail::CentroidsMerger< RealType, IndexType >::mergeMinMax ( )
private

Definition at line 554 of file quantile.h.

Referenced by quantile::detail::CentroidsMerger< RealType, IndexType >::CentroidsMerger().

554  {
555  if (centroids_->max_ < buf_->max_) {
556  centroids_->max_ = buf_->max_;
557  }
558  if (buf_->min_ < centroids_->min_) {
559  centroids_->min_ = buf_->min_;
560  }
561 }
Centroids< RealType, IndexType > * buf_
Definition: quantile.h:135
Centroids< RealType, IndexType > * centroids_
Definition: quantile.h:136

+ Here is the caller graph for this function:

template<typename RealType , typename IndexType >
DEVICE void quantile::detail::CentroidsMerger< RealType, IndexType >::next ( )

Definition at line 565 of file quantile.h.

565  {
566  prefix_sum_ += curr_centroid_->currCount();
567  setCurrCentroid();
568 }
Centroids< RealType, IndexType > * curr_centroid_
Definition: quantile.h:137
template<typename RealType , typename IndexType >
DEVICE IndexType quantile::detail::CentroidsMerger< RealType, IndexType >::prefixSum ( ) const
inline
template<typename RealType , typename IndexType >
DEVICE void quantile::detail::CentroidsMerger< RealType, IndexType >::setCurrCentroid ( )
private

Definition at line 571 of file quantile.h.

Referenced by quantile::detail::CentroidsMerger< RealType, IndexType >::CentroidsMerger().

571  {
572  if ((curr_centroid_ = getNextCentroid())) {
573  curr_centroid_->moveNextToCurrent();
574  }
575 }
DEVICE Centroids< RealType, IndexType > * getNextCentroid() const
Definition: quantile.h:416
Centroids< RealType, IndexType > * curr_centroid_
Definition: quantile.h:137

+ Here is the caller graph for this function:

template<typename RealType , typename IndexType >
DEVICE IndexType quantile::detail::CentroidsMerger< RealType, IndexType >::totalWeight ( ) const
inline

Member Data Documentation

template<typename RealType , typename IndexType >
Centroids<RealType, IndexType>* quantile::detail::CentroidsMerger< RealType, IndexType >::buf_
private
template<typename RealType , typename IndexType >
Centroids<RealType, IndexType>* quantile::detail::CentroidsMerger< RealType, IndexType >::centroids_
private
template<typename RealType , typename IndexType >
Centroids<RealType, IndexType>* quantile::detail::CentroidsMerger< RealType, IndexType >::curr_centroid_
private

Definition at line 137 of file quantile.h.

template<typename RealType , typename IndexType >
bool const quantile::detail::CentroidsMerger< RealType, IndexType >::forward_
private
template<typename RealType , typename IndexType >
IndexType quantile::detail::CentroidsMerger< RealType, IndexType >::prefix_sum_ {0}
private
template<typename RealType , typename IndexType >
IndexType const quantile::detail::CentroidsMerger< RealType, IndexType >::total_weight_
private

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