OmniSciDB  a5dc49c757
 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 441 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().

445  : buf_(buf)
446  , centroids_(centroids)
447  , total_weight_(centroids->totalWeight() + buf->totalWeight())
448  , forward_(forward) {
449  buf_->resetIndices(forward_);
450  centroids_->resetIndices(forward_);
451  mergeMinMax();
452  setCurrCentroid();
453 }
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 457 of file quantile.h.

457  {
458  if (buf_->hasNext()) {
459  if (centroids_->hasNext()) {
460  return (*buf_ < *centroids_) == forward_ ? buf_ : centroids_;
461  }
462  return buf_;
463  } else if (centroids_->hasNext()) {
464  return centroids_;
465  }
466  return nullptr;
467 }
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 568 of file quantile.h.

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

568  {
569  Skipped<RealType, IndexType> skipped;
570  while (auto* next_centroid = getNextCentroid()) {
571  if (skipped) {
572  if (skipped.isDifferentMean(next_centroid)) {
573  break;
574  } else if (curr_centroid_->mergeIfFits(*next_centroid, max_count)) {
575  skipped.merged(next_centroid);
576  } else {
577  skipped.skipSubsequent(next_centroid);
578  }
579  } else if (!curr_centroid_->mergeIfFits(*next_centroid, max_count)) {
580  skipped.skipFirst(next_centroid);
581  }
582  }
583  if (skipped) {
584  skipped.shiftCentroidsAndSetNext();
585  }
586 }
DEVICE Centroids< RealType, IndexType > * getNextCentroid() const
Definition: quantile.h:457
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 597 of file quantile.h.

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

597  {
598  if (centroids_->max_ < buf_->max_) {
599  centroids_->max_ = buf_->max_;
600  }
601  if (buf_->min_ < centroids_->min_) {
602  centroids_->min_ = buf_->min_;
603  }
604 }
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 608 of file quantile.h.

608  {
609  prefix_sum_ += curr_centroid_->currCount();
610  setCurrCentroid();
611 }
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 614 of file quantile.h.

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

614  {
615  if ((curr_centroid_ = getNextCentroid())) {
616  curr_centroid_->moveNextToCurrent();
617  }
618 }
DEVICE Centroids< RealType, IndexType > * getNextCentroid() const
Definition: quantile.h:457
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: