Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::ProgressUpdater Class Reference

#include <progress-updater.h>

Collaboration diagram for impala::ProgressUpdater:

Public Member Functions

 ProgressUpdater (const std::string &label, int64_t max, int update_period=1)
 
 ProgressUpdater ()
 
void set_logging_level (int level)
 
void Update (int64_t delta)
 
bool done () const
 Returns if all tasks are done. More...
 
int64_t total () const
 
int64_t num_complete () const
 
int64_t remaining () const
 
std::string ToString () const
 Returns a string representation of the current progress. More...
 

Private Attributes

std::string label_
 
int logging_level_
 
int64_t total_
 
int update_period_
 
AtomicInt< int64_t > num_complete_
 
int last_output_percentage_
 

Detailed Description

Utility class to update progress. This is split out so a different logging level can be set for these updates (GLOG_module) This class is thread safe. Example usage: ProgressUpdater updater("Task", 100, 10); // 100 items, print every 10% updater.Update(15); // 15 done, prints 15% updater.Update(3); // 18 done, doesn't print update.Update(5); // 23 done, prints 23%

Definition at line 34 of file progress-updater.h.

Constructor & Destructor Documentation

impala::ProgressUpdater::ProgressUpdater ( const std::string &  label,
int64_t  max,
int  update_period = 1 
)

label - label that is printed with each update. max - maximum number of work items update_period - how often the progress is spewed expressed as a percentage

ProgressUpdater::ProgressUpdater ( )

Definition at line 29 of file progress-updater.cc.

Member Function Documentation

bool impala::ProgressUpdater::done ( ) const
inline

Returns if all tasks are done.

Definition at line 52 of file progress-updater.h.

References num_complete_, and total_.

Referenced by impala::HdfsScanNode::GetNext(), and impala::HdfsScanNode::ScannerThread().

int64_t impala::ProgressUpdater::num_complete ( ) const
inline

Definition at line 55 of file progress-updater.h.

References num_complete_.

Referenced by remaining(), ToString(), and Update().

int64_t impala::ProgressUpdater::remaining ( ) const
inline

Definition at line 56 of file progress-updater.h.

References num_complete(), and total().

Referenced by impala::HdfsScanNode::ThreadTokenAvailableCb().

void impala::ProgressUpdater::set_logging_level ( int  level)
inline

Sets the GLOG level for this progress updater. By default, this will use 2 but objects can override it.

Definition at line 45 of file progress-updater.h.

References logging_level_.

string ProgressUpdater::ToString ( ) const

Returns a string representation of the current progress.

Definition at line 62 of file progress-updater.cc.

References label_, num_complete(), num_complete_, and total_.

int64_t impala::ProgressUpdater::total ( ) const
inline

Definition at line 54 of file progress-updater.h.

References total_.

Referenced by remaining().

void ProgressUpdater::Update ( int64_t  delta)

'delta' more of the work has been complete. Will potentially output to VLOG_PROGRESS

Definition at line 34 of file progress-updater.cc.

References label_, last_output_percentage_, logging_level_, num_complete(), num_complete_, total_, and update_period_.

Member Data Documentation

std::string impala::ProgressUpdater::label_
private

Definition at line 62 of file progress-updater.h.

Referenced by ToString(), and Update().

int impala::ProgressUpdater::last_output_percentage_
private

Definition at line 68 of file progress-updater.h.

Referenced by Update().

int impala::ProgressUpdater::logging_level_
private

Definition at line 63 of file progress-updater.h.

Referenced by set_logging_level(), and Update().

AtomicInt<int64_t> impala::ProgressUpdater::num_complete_
private

Definition at line 67 of file progress-updater.h.

Referenced by done(), num_complete(), ToString(), and Update().

int64_t impala::ProgressUpdater::total_
private

Definition at line 64 of file progress-updater.h.

Referenced by done(), ToString(), total(), and Update().

int impala::ProgressUpdater::update_period_
private

Definition at line 65 of file progress-updater.h.

Referenced by Update().


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