OmniSciDB  cde582ebc3
 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 411 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().

415  : buf_(buf)
416  , centroids_(centroids)
417  , total_weight_(centroids->totalWeight() + buf->totalWeight())
418  , forward_(forward) {
419  buf_->resetIndices(forward_);
420  centroids_->resetIndices(forward_);
421  mergeMinMax();
422  setCurrCentroid();
423 }
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 427 of file quantile.h.

427  {
428  if (buf_->hasNext()) {
429  if (centroids_->hasNext()) {
430  return (*buf_ < *centroids_) == forward_ ? buf_ : centroids_;
431  }
432  return buf_;
433  } else if (centroids_->hasNext()) {
434  return centroids_;
435  }
436  return nullptr;
437 }
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 536 of file quantile.h.

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

536  {
537  Skipped<RealType, IndexType> skipped;
538  while (auto* next_centroid = getNextCentroid()) {
539  if (skipped) {
540  if (skipped.isDifferentMean(next_centroid)) {
541  break;
542  } else if (curr_centroid_->mergeIfFits(*next_centroid, max_count)) {
543  skipped.merged(next_centroid);
544  } else {
545  skipped.skipSubsequent(next_centroid);
546  }
547  } else if (!curr_centroid_->mergeIfFits(*next_centroid, max_count)) {
548  skipped.skipFirst(next_centroid);
549  }
550  }
551  if (skipped) {
552  skipped.shiftCentroidsAndSetNext();
553  }
554 }
DEVICE Centroids< RealType, IndexType > * getNextCentroid() const
Definition: quantile.h:427
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 565 of file quantile.h.

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

565  {
566  if (centroids_->max_ < buf_->max_) {
567  centroids_->max_ = buf_->max_;
568  }
569  if (buf_->min_ < centroids_->min_) {
570  centroids_->min_ = buf_->min_;
571  }
572 }
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 576 of file quantile.h.

576  {
577  prefix_sum_ += curr_centroid_->currCount();
578  setCurrCentroid();
579 }
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 582 of file quantile.h.

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

582  {
583  if ((curr_centroid_ = getNextCentroid())) {
584  curr_centroid_->moveNextToCurrent();
585  }
586 }
DEVICE Centroids< RealType, IndexType > * getNextCentroid() const
Definition: quantile.h:427
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: