Skip to content

Commit

Permalink
Change How Context Assignment Works
Browse files Browse the repository at this point in the history
Changed how the context assignment works to accept values, and support
chained invocations.
  • Loading branch information
pfifer committed May 15, 2017
1 parent 8df9010 commit 9d233c0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
9 changes: 4 additions & 5 deletions aws/kinesis/core/reducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ class Reducer : boost::noncopyable {
auto flush_predicate_result = flush_predicate_(input);

aws::utils::flush_statistics_context flush_reason;
flush_reason.record_count() = size >= count_limit_;
flush_reason.data_size() = estimated_size >= size_limit_;
flush_reason.predicate_match() = flush_predicate_result;
flush_reason.record_count(size >= count_limit_).data_size(estimated_size >= size_limit_)
.predicate_match(flush_predicate_result);

if (flush_reason.flush_required()) {
auto output = flush(lock, flush_reason);
Expand All @@ -102,7 +101,7 @@ class Reducer : boost::noncopyable {
// Manually trigger a flush, as though a deadline has been reached
void flush() {
aws::utils::flush_statistics_context flush_reason;
flush_reason.manual() = true;
flush_reason.manual(true);
trigger_flush(flush_reason);
}

Expand Down Expand Up @@ -180,7 +179,7 @@ class Reducer : boost::noncopyable {

void deadline_reached() {
aws::utils::flush_statistics_context flush_reason;
flush_reason.timed() = true;
flush_reason.timed(true);
trigger_flush(flush_reason);
}

Expand Down
25 changes: 25 additions & 0 deletions aws/utils/processing_statistics_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@

using namespace aws::utils;

flush_statistics_context& flush_statistics_context::manual(bool value) {
manual_ = value;
return *this;
}

flush_statistics_context& flush_statistics_context::record_count(bool value) {
record_count_ = value;
return *this;
}

flush_statistics_context& flush_statistics_context::data_size(bool value) {
data_size_ = value;
return *this;
}

flush_statistics_context& flush_statistics_context::predicate_match(bool value) {
predicate_match_ = value;
return *this;
}

flush_statistics_context& flush_statistics_context::timed(bool value) {
timed_ = value;
return *this;
}

flush_statistics_aggregator::flush_statistics_aggregator(const std::string &stream_name, const std::string &input_type,
const std::string &output_type) :
stream_name_(stream_name),
Expand Down
15 changes: 10 additions & 5 deletions aws/utils/processing_statistics_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@ namespace aws {
bool timed_ = false;

public:
bool &manual() { return manual_; }
bool manual() { return manual_; }
flush_statistics_context& manual(bool value);

bool &record_count() { return record_count_; }
bool record_count() { return record_count_; }
flush_statistics_context& record_count(bool value);

bool &data_size() { return data_size_; }
bool data_size() { return data_size_; }
flush_statistics_context& data_size(bool value);

bool &predicate_match() { return predicate_match_; }
bool predicate_match() { return predicate_match_; }
flush_statistics_context& predicate_match(bool value);

bool &timed() { return timed_; }
bool timed() { return timed_; }
flush_statistics_context& timed(bool value);

bool flush_required() {
return manual_ || record_count_ || data_size_ || predicate_match_ || timed_;
Expand Down

0 comments on commit 9d233c0

Please sign in to comment.