Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
progress-updater.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 
16 #ifndef IMPALA_UTIL_PROGRESS_UPDATER_H
17 #define IMPALA_UTIL_PROGRESS_UPDATER_H
18 
19 #include <string>
20 #include <boost/cstdint.hpp>
21 
22 #include "common/atomic.h"
23 
24 namespace impala {
25 
35  public:
39  ProgressUpdater(const std::string& label, int64_t max, int update_period = 1);
40 
42 
45  void set_logging_level(int level) { logging_level_ = level; }
46 
49  void Update(int64_t delta);
50 
52  bool done() const { return num_complete_ >= total_; }
53 
54  int64_t total() const { return total_; }
55  int64_t num_complete() const { return num_complete_; }
56  int64_t remaining() const { return total() - num_complete(); }
57 
59  std::string ToString() const;
60 
61  private:
62  std::string label_;
64  int64_t total_;
66 
69 };
70 
71 }
72 
73 #endif
int64_t num_complete() const
bool done() const
Returns if all tasks are done.
std::string ToString() const
Returns a string representation of the current progress.
void set_logging_level(int level)
AtomicInt< int64_t > num_complete_
int64_t remaining() const
int64_t total() const
void Update(int64_t delta)