OmniSciDB  72c90bc290
 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 421 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().

425  : buf_(buf)
426  , centroids_(centroids)
427  , total_weight_(centroids->totalWeight() + buf->totalWeight())
428  , forward_(forward) {
429  buf_->resetIndices(forward_);
430  centroids_->resetIndices(forward_);
431  mergeMinMax();
432  setCurrCentroid();
433 }
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 437 of file quantile.h.

437  {
438  if (buf_->hasNext()) {
439  if (centroids_->hasNext()) {
440  return (*buf_ < *centroids_) == forward_ ? buf_ : centroids_;
441  }
442  return buf_;
443  } else if (centroids_->hasNext()) {
444  return centroids_;
445  }
446  return nullptr;
447 }
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 548 of file quantile.h.

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

548  {
549  Skipped<RealType, IndexType> skipped;
550  while (auto* next_centroid = getNextCentroid()) {
551  if (skipped) {
552  if (skipped.isDifferentMean(next_centroid)) {
553  break;
554  } else if (curr_centroid_->mergeIfFits(*next_centroid, max_count)) {
555  skipped.merged(next_centroid);
556  } else {
557  skipped.skipSubsequent(next_centroid);
558  }
559  } else if (!curr_centroid_->mergeIfFits(*next_centroid, max_count)) {
560  skipped.skipFirst(next_centroid);
561  }
562  }
563  if (skipped) {
564  skipped.shiftCentroidsAndSetNext();
565  }
566 }
DEVICE Centroids< RealType, IndexType > * getNextCentroid() const
Definition: quantile.h:437
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 577 of file quantile.h.

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

577  {
578  if (centroids_->max_ < buf_->max_) {
579  centroids_->max_ = buf_->max_;
580  }
581  if (buf_->min_ < centroids_->min_) {
582  centroids_->min_ = buf_->min_;
583  }
584 }
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 588 of file quantile.h.

588  {
589  prefix_sum_ += curr_centroid_->currCount();
590  setCurrCentroid();
591 }
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 594 of file quantile.h.

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

594  {
595  if ((curr_centroid_ = getNextCentroid())) {
596  curr_centroid_->moveNextToCurrent();
597  }
598 }
DEVICE Centroids< RealType, IndexType > * getNextCentroid() const
Definition: quantile.h:437
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: