OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 132 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 389 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().

393  : buf_(buf)
394  , centroids_(centroids)
395  , total_weight_(centroids->totalWeight() + buf->totalWeight())
396  , forward_(forward) {
397  buf_->resetIndices(forward_);
398  centroids_->resetIndices(forward_);
399  mergeMinMax();
400  setCurrCentroid();
401 }
Centroids< RealType, IndexType > * buf_
Definition: quantile.h:133
Centroids< RealType, IndexType > * centroids_
Definition: quantile.h:134

+ 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 405 of file quantile.h.

405  {
406  if (buf_->hasNext()) {
407  if (centroids_->hasNext()) {
408  return (*buf_ < *centroids_) == forward_ ? buf_ : centroids_;
409  }
410  return buf_;
411  } else if (centroids_->hasNext()) {
412  return centroids_;
413  }
414  return nullptr;
415 }
Centroids< RealType, IndexType > * buf_
Definition: quantile.h:133
Centroids< RealType, IndexType > * centroids_
Definition: quantile.h:134
template<typename RealType , typename IndexType >
DEVICE bool quantile::detail::CentroidsMerger< RealType, IndexType >::hasNext ( ) const
inline

Definition at line 151 of file quantile.h.

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

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

Definition at line 514 of file quantile.h.

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

514  {
515  Skipped<RealType, IndexType> skipped;
516  while (auto* next_centroid = getNextCentroid()) {
517  if (skipped) {
518  if (skipped.isDifferentMean(next_centroid)) {
519  break;
520  } else if (curr_centroid_->mergeIfFits(*next_centroid, max_count)) {
521  skipped.merged(next_centroid);
522  } else {
523  skipped.skipSubsequent(next_centroid);
524  }
525  } else if (!curr_centroid_->mergeIfFits(*next_centroid, max_count)) {
526  skipped.skipFirst(next_centroid);
527  }
528  }
529  if (skipped) {
530  skipped.shiftCentroidsAndSetNext();
531  }
532 }
DEVICE Centroids< RealType, IndexType > * getNextCentroid() const
Definition: quantile.h:405
Centroids< RealType, IndexType > * curr_centroid_
Definition: quantile.h:135

+ 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 543 of file quantile.h.

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

543  {
544  if (centroids_->max_ < buf_->max_) {
545  centroids_->max_ = buf_->max_;
546  }
547  if (buf_->min_ < centroids_->min_) {
548  centroids_->min_ = buf_->min_;
549  }
550 }
Centroids< RealType, IndexType > * buf_
Definition: quantile.h:133
Centroids< RealType, IndexType > * centroids_
Definition: quantile.h:134

+ Here is the caller graph for this function:

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

Definition at line 554 of file quantile.h.

554  {
555  prefix_sum_ += curr_centroid_->currCount();
556  setCurrCentroid();
557 }
Centroids< RealType, IndexType > * curr_centroid_
Definition: quantile.h:135
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 560 of file quantile.h.

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

560  {
561  if ((curr_centroid_ = getNextCentroid())) {
562  curr_centroid_->moveNextToCurrent();
563  }
564 }
DEVICE Centroids< RealType, IndexType > * getNextCentroid() const
Definition: quantile.h:405
Centroids< RealType, IndexType > * curr_centroid_
Definition: quantile.h:135

+ 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 135 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: