You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by da...@apache.org on 2016/01/15 21:00:10 UTC
[5/6] incubator-kudu git commit: Replace BOOST_FOREACH with c++11
range syntax
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/common/schema.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/schema.cc b/src/kudu/common/schema.cc
index 5364172..e722d20 100644
--- a/src/kudu/common/schema.cc
+++ b/src/kudu/common/schema.cc
@@ -103,7 +103,7 @@ void Schema::CopyFrom(const Schema& other) {
// reference the other Schema's ColumnSchema objects.
name_to_index_.clear();
int i = 0;
- BOOST_FOREACH(const ColumnSchema &col, cols_) {
+ for (const ColumnSchema &col : cols_) {
// The map uses the 'name' string from within the ColumnSchema object.
name_to_index_[col.name()] = i++;
}
@@ -156,7 +156,7 @@ Status Schema::Reset(const vector<ColumnSchema>& cols,
size_t off = 0;
size_t i = 0;
name_to_index_.clear();
- BOOST_FOREACH(const ColumnSchema &col, cols_) {
+ for (const ColumnSchema &col : cols_) {
// The map uses the 'name' string from within the ColumnSchema object.
if (!InsertIfNotPresent(&name_to_index_, col.name(), i++)) {
return Status::InvalidArgument("Duplicate column name", col.name());
@@ -183,7 +183,7 @@ Status Schema::Reset(const vector<ColumnSchema>& cols,
// Determine whether any column is nullable
has_nullables_ = false;
- BOOST_FOREACH(const ColumnSchema& col, cols_) {
+ for (const ColumnSchema& col : cols_) {
if (col.is_nullable()) {
has_nullables_ = true;
break;
@@ -197,7 +197,7 @@ Status Schema::CreateProjectionByNames(const std::vector<StringPiece>& col_names
Schema* out) const {
vector<ColumnId> ids;
vector<ColumnSchema> cols;
- BOOST_FOREACH(const StringPiece& name, col_names) {
+ for (const StringPiece& name : col_names) {
int idx = find_column(name);
if (idx == -1) {
return Status::NotFound("column not found", name);
@@ -214,7 +214,7 @@ Status Schema::CreateProjectionByIdsIgnoreMissing(const std::vector<ColumnId>& c
Schema* out) const {
vector<ColumnSchema> cols;
vector<ColumnId> filtered_col_ids;
- BOOST_FOREACH(ColumnId id, col_ids) {
+ for (ColumnId id : col_ids) {
int idx = find_column_by_id(id);
if (idx == -1) {
continue;
@@ -247,7 +247,7 @@ Status Schema::VerifyProjectionCompatibility(const Schema& projection) const {
}
vector<string> missing_columns;
- BOOST_FOREACH(const ColumnSchema& pcol, projection.columns()) {
+ for (const ColumnSchema& pcol : projection.columns()) {
int index = find_column(pcol.name());
if (index < 0) {
missing_columns.push_back(pcol.name());
@@ -283,7 +283,7 @@ Status Schema::GetMappedReadProjection(const Schema& projection,
mapped_cols.reserve(projection.num_columns());
mapped_ids.reserve(projection.num_columns());
- BOOST_FOREACH(const ColumnSchema& col, projection.columns()) {
+ for (const ColumnSchema& col : projection.columns()) {
int index = find_column(col.name());
DCHECK_GE(index, 0) << col.name();
mapped_cols.push_back(cols_[index]);
@@ -301,7 +301,7 @@ string Schema::ToString() const {
col_strs.push_back(strings::Substitute("$0:$1", col_ids_[i], cols_[i].ToString()));
}
} else {
- BOOST_FOREACH(const ColumnSchema &col, cols_) {
+ for (const ColumnSchema &col : cols_) {
col_strs.push_back(col.ToString());
}
}
@@ -350,7 +350,7 @@ string Schema::DebugEncodedRowKey(Slice encoded_key, StartOrEnd start_or_end) co
size_t Schema::memory_footprint_excluding_this() const {
size_t size = kudu_malloc_usable_size(cols_.data());
- BOOST_FOREACH(const ColumnSchema& col, cols_) {
+ for (const ColumnSchema& col : cols_) {
size += col.memory_footprint_excluding_this();
}
@@ -447,7 +447,7 @@ Status SchemaBuilder::RenameColumn(const string& old_name, const string& new_nam
col_names_.erase(it_names); // TODO: Should this one stay and marked as alias?
col_names_.insert(new_name);
- BOOST_FOREACH(ColumnSchema& col_schema, cols_) {
+ for (ColumnSchema& col_schema : cols_) {
if (old_name == col_schema.name()) {
col_schema.set_name(new_name);
return Status::OK();
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/common/schema.h
----------------------------------------------------------------------
diff --git a/src/kudu/common/schema.h b/src/kudu/common/schema.h
index ab45ef3..3788072 100644
--- a/src/kudu/common/schema.h
+++ b/src/kudu/common/schema.h
@@ -17,7 +17,6 @@
#ifndef KUDU_COMMON_SCHEMA_H
#define KUDU_COMMON_SCHEMA_H
-#include <boost/foreach.hpp>
#include <functional>
#include <glog/logging.h>
#include <memory>
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/common/wire_protocol.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/wire_protocol.cc b/src/kudu/common/wire_protocol.cc
index a10ac7d..774afb7 100644
--- a/src/kudu/common/wire_protocol.cc
+++ b/src/kudu/common/wire_protocol.cc
@@ -164,7 +164,7 @@ Status HostPortFromPB(const HostPortPB& host_port_pb, HostPort* host_port) {
Status AddHostPortPBs(const vector<Sockaddr>& addrs,
RepeatedPtrField<HostPortPB>* pbs) {
- BOOST_FOREACH(const Sockaddr& addr, addrs) {
+ for (const Sockaddr& addr : addrs) {
HostPortPB* pb = pbs->Add();
if (addr.IsWildcard()) {
RETURN_NOT_OK(GetFQDN(pb->mutable_host()));
@@ -266,7 +266,7 @@ Status ColumnPBsToSchema(const RepeatedPtrField<ColumnSchemaPB>& column_pbs,
columns.reserve(column_pbs.size());
int num_key_columns = 0;
bool is_handling_key = true;
- BOOST_FOREACH(const ColumnSchemaPB& pb, column_pbs) {
+ for (const ColumnSchemaPB& pb : column_pbs) {
columns.push_back(ColumnSchemaFromPB(pb));
if (pb.is_key()) {
if (!is_handling_key) {
@@ -295,7 +295,7 @@ Status SchemaToColumnPBs(const Schema& schema,
int flags) {
cols->Clear();
int idx = 0;
- BOOST_FOREACH(const ColumnSchema& col, schema.columns()) {
+ for (const ColumnSchema& col : schema.columns()) {
ColumnSchemaPB* col_pb = cols->Add();
ColumnSchemaToPB(col, col_pb);
col_pb->set_is_key(idx < schema.num_key_columns());
@@ -403,7 +403,7 @@ Status ExtractRowsFromRowBlockPB(const Schema& schema,
Status FindLeaderHostPort(const RepeatedPtrField<ServerEntryPB>& entries,
HostPort* leader_hostport) {
- BOOST_FOREACH(const ServerEntryPB& entry, entries) {
+ for (const ServerEntryPB& entry : entries) {
if (entry.has_error()) {
LOG(WARNING) << "Error encountered for server entry " << entry.ShortDebugString()
<< ": " << StatusFromPB(entry.error()).ToString();
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/consensus-test-util.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus-test-util.h b/src/kudu/consensus/consensus-test-util.h
index a2c5596..8398230 100644
--- a/src/kudu/consensus/consensus-test-util.h
+++ b/src/kudu/consensus/consensus-test-util.h
@@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/foreach.hpp>
#include <boost/thread/locks.hpp>
#include <gmock/gmock.h>
#include <map>
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/consensus.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus.cc b/src/kudu/consensus/consensus.cc
index 84dab04..b8b30ed 100644
--- a/src/kudu/consensus/consensus.cc
+++ b/src/kudu/consensus/consensus.cc
@@ -17,7 +17,6 @@
#include "kudu/consensus/consensus.h"
-#include <boost/foreach.hpp>
#include <set>
#include "kudu/consensus/log_util.h"
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/consensus_meta-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_meta-test.cc b/src/kudu/consensus/consensus_meta-test.cc
index be6d568..7eb9c2d 100644
--- a/src/kudu/consensus/consensus_meta-test.cc
+++ b/src/kudu/consensus/consensus_meta-test.cc
@@ -18,7 +18,6 @@
#include <vector>
-#include <boost/foreach.hpp>
#include <gtest/gtest.h>
#include "kudu/common/wire_protocol.h"
@@ -136,7 +135,7 @@ TEST_F(ConsensusMetadataTest, TestFlush) {
RaftConfigPB BuildConfig(const vector<string>& uuids) {
RaftConfigPB config;
config.set_local(false);
- BOOST_FOREACH(const string& uuid, uuids) {
+ for (const string& uuid : uuids) {
RaftPeerPB* peer = config.add_peers();
peer->set_permanent_uuid(uuid);
peer->set_member_type(RaftPeerPB::VOTER);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/consensus_queue.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_queue.cc b/src/kudu/consensus/consensus_queue.cc
index 019911f..a4e3b4b 100644
--- a/src/kudu/consensus/consensus_queue.cc
+++ b/src/kudu/consensus/consensus_queue.cc
@@ -17,7 +17,6 @@
#include "kudu/consensus/consensus_queue.h"
#include <algorithm>
-#include <boost/foreach.hpp>
#include <boost/thread/locks.hpp>
#include <gflags/gflags.h>
#include <iostream>
@@ -150,7 +149,7 @@ void PeerMessageQueue::SetLeaderMode(const OpId& committed_index,
// Reset last communication time with all peers to reset the clock on the
// failure timeout.
MonoTime now(MonoTime::Now(MonoTime::FINE));
- BOOST_FOREACH(const PeersMap::value_type& entry, peers_map_) {
+ for (const PeersMap::value_type& entry : peers_map_) {
entry.second->last_successful_communication_time = now;
}
}
@@ -203,10 +202,10 @@ void PeerMessageQueue::UntrackPeer(const string& uuid) {
void PeerMessageQueue::CheckPeersInActiveConfigIfLeaderUnlocked() const {
if (queue_state_.mode != LEADER) return;
unordered_set<string> config_peer_uuids;
- BOOST_FOREACH(const RaftPeerPB& peer_pb, queue_state_.active_config->peers()) {
+ for (const RaftPeerPB& peer_pb : queue_state_.active_config->peers()) {
InsertOrDie(&config_peer_uuids, peer_pb.permanent_uuid());
}
- BOOST_FOREACH(const PeersMap::value_type& entry, peers_map_) {
+ for (const PeersMap::value_type& entry : peers_map_) {
if (!ContainsKey(config_peer_uuids, entry.first)) {
LOG_WITH_PREFIX_UNLOCKED(FATAL) << Substitute("Peer $0 is not in the active config. "
"Queue state: $1",
@@ -362,7 +361,7 @@ Status PeerMessageQueue::RequestForPeer(const string& uuid,
// "all replicated" point. At some point we may want to allow partially loading
// (and not pinning) earlier messages. At that point we'll need to do something
// smarter here, like copy or ref-count.
- BOOST_FOREACH(const ReplicateRefPtr& msg, messages) {
+ for (const ReplicateRefPtr& msg : messages) {
request->mutable_ops()->AddAllocated(msg->get());
}
msg_refs->swap(messages);
@@ -435,7 +434,7 @@ void PeerMessageQueue::AdvanceQueueWatermark(const char* type,
// - Find the vector.size() - 'num_peers_required' position, this
// will be the new 'watermark'.
vector<const OpId*> watermarks;
- BOOST_FOREACH(const PeersMap::value_type& peer, peers_map_) {
+ for (const PeersMap::value_type& peer : peers_map_) {
if (peer.second->is_last_exchange_successful) {
watermarks.push_back(&peer.second->last_received);
}
@@ -456,11 +455,11 @@ void PeerMessageQueue::AdvanceQueueWatermark(const char* type,
<< "from " << old_watermark << " to " << new_watermark;
if (VLOG_IS_ON(3)) {
VLOG_WITH_PREFIX_UNLOCKED(3) << "Peers: ";
- BOOST_FOREACH(const PeersMap::value_type& peer, peers_map_) {
+ for (const PeersMap::value_type& peer : peers_map_) {
VLOG_WITH_PREFIX_UNLOCKED(3) << "Peer: " << peer.second->ToString();
}
VLOG_WITH_PREFIX_UNLOCKED(3) << "Sorted watermarks:";
- BOOST_FOREACH(const OpId* watermark, watermarks) {
+ for (const OpId* watermark : watermarks) {
VLOG_WITH_PREFIX_UNLOCKED(3) << "Watermark: " << watermark->ShortDebugString();
}
}
@@ -686,7 +685,7 @@ void PeerMessageQueue::DumpToStrings(vector<string>* lines) const {
void PeerMessageQueue::DumpToStringsUnlocked(vector<string>* lines) const {
lines->push_back("Watermarks:");
- BOOST_FOREACH(const PeersMap::value_type& entry, peers_map_) {
+ for (const PeersMap::value_type& entry : peers_map_) {
lines->push_back(
Substitute("Peer: $0 Watermark: $1", entry.first, entry.second->ToString()));
}
@@ -701,7 +700,7 @@ void PeerMessageQueue::DumpToHtml(std::ostream& out) const {
out << "<h3>Watermarks</h3>" << endl;
out << "<table>" << endl;;
out << " <tr><th>Peer</th><th>Watermark</th></tr>" << endl;
- BOOST_FOREACH(const PeersMap::value_type& entry, peers_map_) {
+ for (const PeersMap::value_type& entry : peers_map_) {
out << Substitute(" <tr><td>$0</td><td>$1</td></tr>",
EscapeForHtmlToString(entry.first),
EscapeForHtmlToString(entry.second->ToString())) << endl;
@@ -800,7 +799,7 @@ void PeerMessageQueue::NotifyObserversOfMajorityReplOpChangeTask(
// TODO move commit index advancement here so that the queue is not dependent on
// consensus at all, but that requires a bit more work.
OpId new_committed_index;
- BOOST_FOREACH(PeerMessageQueueObserver* observer, copy) {
+ for (PeerMessageQueueObserver* observer : copy) {
observer->UpdateMajorityReplicated(new_majority_replicated_op, &new_committed_index);
}
@@ -821,7 +820,7 @@ void PeerMessageQueue::NotifyObserversOfTermChangeTask(int64_t term) {
copy = observers_;
}
OpId new_committed_index;
- BOOST_FOREACH(PeerMessageQueueObserver* observer, copy) {
+ for (PeerMessageQueueObserver* observer : copy) {
observer->NotifyTermChange(term);
}
}
@@ -845,7 +844,7 @@ void PeerMessageQueue::NotifyObserversOfFailedFollowerTask(const string& uuid,
observers_copy = observers_;
}
OpId new_committed_index;
- BOOST_FOREACH(PeerMessageQueueObserver* observer, observers_copy) {
+ for (PeerMessageQueueObserver* observer : observers_copy) {
observer->NotifyFailedFollower(uuid, term, reason);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/leader_election-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/leader_election-test.cc b/src/kudu/consensus/leader_election-test.cc
index e1a1a18..58b7014 100644
--- a/src/kudu/consensus/leader_election-test.cc
+++ b/src/kudu/consensus/leader_election-test.cc
@@ -17,7 +17,6 @@
#include "kudu/consensus/leader_election.h"
-#include <boost/foreach.hpp>
#include <string>
#include <vector>
@@ -135,7 +134,7 @@ void LeaderElectionTest::InitUUIDs(int num_voters) {
void LeaderElectionTest::InitNoOpPeerProxies() {
config_.Clear();
- BOOST_FOREACH(const string& uuid, voter_uuids_) {
+ for (const string& uuid : voter_uuids_) {
RaftPeerPB* peer_pb = config_.add_peers();
peer_pb->set_permanent_uuid(uuid);
PeerProxy* proxy = new NoOpTestPeerProxy(pool_.get(), *peer_pb);
@@ -145,7 +144,7 @@ void LeaderElectionTest::InitNoOpPeerProxies() {
void LeaderElectionTest::InitDelayableMockedProxies(bool enable_delay) {
config_.Clear();
- BOOST_FOREACH(const string& uuid, voter_uuids_) {
+ for (const string& uuid : voter_uuids_) {
RaftPeerPB* peer_pb = config_.add_peers();
peer_pb->set_permanent_uuid(uuid);
DelayablePeerProxy<MockedPeerProxy>* proxy =
@@ -265,7 +264,7 @@ scoped_refptr<LeaderElection> LeaderElectionTest::SetUpElectionWithGrantDenyErro
TEST_F(LeaderElectionTest, TestPerfectElection) {
// Try configuration sizes of 1, 3, 5.
vector<int> config_sizes = { 1, 3, 5 };
- BOOST_FOREACH(int num_voters, config_sizes) {
+ for (int num_voters : config_sizes) {
LOG(INFO) << "Testing election with config size of " << num_voters;
int majority_size = (num_voters / 2) + 1;
ConsensusTerm election_term = 10 + num_voters; // Just to be able to differentiate.
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/leader_election.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/leader_election.cc b/src/kudu/consensus/leader_election.cc
index 6d7131e..20fea08 100644
--- a/src/kudu/consensus/leader_election.cc
+++ b/src/kudu/consensus/leader_election.cc
@@ -18,7 +18,6 @@
#include "kudu/consensus/leader_election.h"
#include <boost/bind.hpp>
-#include <boost/foreach.hpp>
#include "kudu/consensus/consensus_peers.h"
#include "kudu/consensus/metadata.pb.h"
@@ -163,7 +162,7 @@ LeaderElection::LeaderElection(const RaftConfigPB& config,
timeout_(timeout),
decision_callback_(decision_callback) {
- BOOST_FOREACH(const RaftPeerPB& peer, config.peers()) {
+ for (const RaftPeerPB& peer : config.peers()) {
if (request.candidate_uuid() == peer.permanent_uuid()) continue;
follower_uuids_.push_back(peer.permanent_uuid());
@@ -197,7 +196,7 @@ void LeaderElection::Run() {
CheckForDecision();
// The rest of the code below is for a typical multi-node configuration.
- BOOST_FOREACH(const std::string& voter_uuid, follower_uuids_) {
+ for (const std::string& voter_uuid : follower_uuids_) {
VoterState* state = NULL;
{
lock_guard<Lock> guard(&lock_);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/local_consensus.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/local_consensus.cc b/src/kudu/consensus/local_consensus.cc
index 892a507..b378bf3 100644
--- a/src/kudu/consensus/local_consensus.cc
+++ b/src/kudu/consensus/local_consensus.cc
@@ -83,7 +83,7 @@ Status LocalConsensus::Start(const ConsensusBootstrapInfo& info) {
}
Status LocalConsensus::ResubmitOrphanedReplicates(const std::vector<ReplicateMsg*> replicates) {
- BOOST_FOREACH(ReplicateMsg* msg, replicates) {
+ for (ReplicateMsg* msg : replicates) {
DCHECK_LT(msg->id().index(), next_op_id_index_)
<< "Orphaned replicate " << OpIdToString(msg->id())
<< " is newer than next op index " << next_op_id_index_;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/log-dump.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log-dump.cc b/src/kudu/consensus/log-dump.cc
index 05209c1..8448ba8 100644
--- a/src/kudu/consensus/log-dump.cc
+++ b/src/kudu/consensus/log-dump.cc
@@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/foreach.hpp>
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <iostream>
@@ -120,7 +119,7 @@ Status PrintDecodedWriteRequestPB(const string& indent,
}
int i = 0;
- BOOST_FOREACH(const DecodedRowOperation& op, ops) {
+ for (const DecodedRowOperation& op : ops) {
// TODO (KUDU-515): Handle the case when a tablet's schema changes
// mid-segment.
cout << indent << "op " << (i++) << ": " << op.ToString(tablet_schema) << endl;
@@ -163,7 +162,7 @@ Status PrintSegment(const scoped_refptr<ReadableLogSegment>& segment) {
Schema tablet_schema;
RETURN_NOT_OK(SchemaFromPB(segment->header().schema(), &tablet_schema));
- BOOST_FOREACH(LogEntryPB* entry, entries) {
+ for (LogEntryPB* entry : entries) {
if (print_type == PRINT_PB) {
if (FLAGS_truncate_data > 0) {
@@ -200,7 +199,7 @@ Status DumpLog(const string& tablet_id) {
SegmentSequence segments;
RETURN_NOT_OK(reader->GetSegmentsSnapshot(&segments));
- BOOST_FOREACH(const scoped_refptr<ReadableLogSegment>& segment, segments) {
+ for (const scoped_refptr<ReadableLogSegment>& segment : segments) {
RETURN_NOT_OK(PrintSegment(segment));
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/log-test-base.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log-test-base.h b/src/kudu/consensus/log-test-base.h
index 067e843..080811d 100644
--- a/src/kudu/consensus/log-test-base.h
+++ b/src/kudu/consensus/log-test-base.h
@@ -19,7 +19,6 @@
#include "kudu/consensus/log.h"
-#include <boost/foreach.hpp>
#include <glog/logging.h>
#include <gtest/gtest.h>
@@ -172,7 +171,7 @@ class LogTestBase : public KuduTest {
kTestTablet),
&files));
int count = 0;
- BOOST_FOREACH(const string& s, files) {
+ for (const string& s : files) {
if (HasPrefixString(s, FsManager::kWalFileNamePrefix)) {
count++;
}
@@ -181,7 +180,7 @@ class LogTestBase : public KuduTest {
}
void EntriesToIdList(vector<uint32_t>* ids) {
- BOOST_FOREACH(const LogEntryPB* entry, entries_) {
+ for (const LogEntryPB* entry : entries_) {
VLOG(2) << "Entry contents: " << entry->DebugString();
if (entry->type() == REPLICATE) {
ids->push_back(entry->replicate().id().index());
@@ -314,7 +313,7 @@ class LogTestBase : public KuduTest {
string DumpSegmentsToString(const SegmentSequence& segments) {
string dump;
- BOOST_FOREACH(const scoped_refptr<ReadableLogSegment>& segment, segments) {
+ for (const scoped_refptr<ReadableLogSegment>& segment : segments) {
dump.append("------------\n");
strings::SubstituteAndAppend(&dump, "Segment: $0, Path: $1\n",
segment->header().sequence_number(), segment->path());
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/log-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log-test.cc b/src/kudu/consensus/log-test.cc
index 703e5fa..157d70b 100644
--- a/src/kudu/consensus/log-test.cc
+++ b/src/kudu/consensus/log-test.cc
@@ -17,7 +17,6 @@
#include <algorithm>
#include <boost/bind.hpp>
-#include <boost/foreach.hpp>
#include <boost/function.hpp>
#include <glog/stl_logging.h>
#include <vector>
@@ -364,7 +363,7 @@ TEST_F(LogTest, TestSegmentRollover) {
ASSERT_OK(log_->GetLogReader()->GetSegmentsSnapshot(&segments));
ASSERT_TRUE(segments.back()->HasFooter());
- BOOST_FOREACH(const scoped_refptr<ReadableLogSegment>& entry, segments) {
+ for (const scoped_refptr<ReadableLogSegment>& entry : segments) {
Status s = entry->ReadEntries(&entries_);
if (!s.ok()) {
FAIL() << "Failed to read entries in segment: " << entry->path()
@@ -693,7 +692,7 @@ TEST_F(LogTest, TestWriteManyBatches) {
vector<scoped_refptr<ReadableLogSegment> > segments;
ASSERT_OK(log_->GetLogReader()->GetSegmentsSnapshot(&segments));
- BOOST_FOREACH(const scoped_refptr<ReadableLogSegment> entry, segments) {
+ for (const scoped_refptr<ReadableLogSegment> entry : segments) {
STLDeleteElements(&entries_);
ASSERT_OK(entry->ReadEntries(&entries_));
num_entries += entries_.size();
@@ -865,7 +864,7 @@ void LogTest::GenerateTestSequence(Random* rng, int seq_len,
}
void LogTest::AppendTestSequence(const vector<TestLogSequenceElem>& seq) {
- BOOST_FOREACH(const TestLogSequenceElem& e, seq) {
+ for (const TestLogSequenceElem& e : seq) {
VLOG(1) << "Appending: " << e;
switch (e.type) {
case TestLogSequenceElem::REPLICATE:
@@ -941,7 +940,7 @@ TEST_F(LogTest, TestReadLogWithReplacedReplicates) {
start_index, end_index, LogReader::kNoSizeLimit, &repls));
ASSERT_EQ(end_index - start_index + 1, repls.size());
int expected_index = start_index;
- BOOST_FOREACH(const ReplicateMsg* repl, repls) {
+ for (const ReplicateMsg* repl : repls) {
ASSERT_EQ(expected_index, repl->id().index());
ASSERT_EQ(terms_by_index[expected_index], repl->id().term());
expected_index++;
@@ -966,7 +965,7 @@ TEST_F(LogTest, TestReadLogWithReplacedReplicates) {
ASSERT_LE(repls.size(), end_index - start_index + 1);
int total_size = 0;
int expected_index = start_index;
- BOOST_FOREACH(const ReplicateMsg* repl, repls) {
+ for (const ReplicateMsg* repl : repls) {
ASSERT_EQ(expected_index, repl->id().index());
ASSERT_EQ(terms_by_index[expected_index], repl->id().term());
expected_index++;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/log.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log.cc b/src/kudu/consensus/log.cc
index fac45d9..89630d6 100644
--- a/src/kudu/consensus/log.cc
+++ b/src/kudu/consensus/log.cc
@@ -178,7 +178,7 @@ void Log::AppendThread::RunThread() {
SCOPED_LATENCY_METRIC(log_->metrics_, group_commit_latency);
bool is_all_commits = true;
- BOOST_FOREACH(LogEntryBatch* entry_batch, entry_batches) {
+ for (LogEntryBatch* entry_batch : entry_batches) {
entry_batch->WaitForReady();
TRACE_EVENT_FLOW_END0("log", "Batch", entry_batch);
Status s = log_->DoAppend(entry_batch);
@@ -206,7 +206,7 @@ void Log::AppendThread::RunThread() {
if (PREDICT_FALSE(!s.ok())) {
LOG(ERROR) << "Error syncing log" << s.ToString();
DLOG(FATAL) << "Aborting: " << s.ToString();
- BOOST_FOREACH(LogEntryBatch* entry_batch, entry_batches) {
+ for (LogEntryBatch* entry_batch : entry_batches) {
if (!entry_batch->callback().is_null()) {
entry_batch->callback().Run(s);
}
@@ -215,7 +215,7 @@ void Log::AppendThread::RunThread() {
TRACE_EVENT0("log", "Callbacks");
VLOG(2) << "Synchronized " << entry_batches.size() << " entry batches";
SCOPED_WATCH_STACK(100);
- BOOST_FOREACH(LogEntryBatch* entry_batch, entry_batches) {
+ for (LogEntryBatch* entry_batch : entry_batches) {
if (PREDICT_TRUE(!entry_batch->failed_to_append()
&& !entry_batch->callback().is_null())) {
entry_batch->callback().Run(Status::OK());
@@ -400,7 +400,7 @@ Status Log::Reserve(LogEntryTypePB type,
// In DEBUG builds, verify that all of the entries in the batch match the specified type.
// In non-debug builds the foreach loop gets optimized out.
#ifndef NDEBUG
- BOOST_FOREACH(const LogEntryPB& entry, entry_batch->entry()) {
+ for (const LogEntryPB& entry : entry_batch->entry()) {
DCHECK_EQ(entry.type(), type) << "Bad batch: " << entry_batch->DebugString();
}
#endif
@@ -553,7 +553,7 @@ Status Log::UpdateIndexForBatch(const LogEntryBatch& batch,
return Status::OK();
}
- BOOST_FOREACH(const LogEntryPB& entry_pb, batch.entry_batch_pb_->entry()) {
+ for (const LogEntryPB& entry_pb : batch.entry_batch_pb_->entry()) {
LogIndexEntry index_entry;
index_entry.op_id = entry_pb.replicate().id();
@@ -574,7 +574,7 @@ void Log::UpdateFooterForBatch(LogEntryBatch* batch) {
// immediately.
if (batch->type_ == REPLICATE) {
// Update the index bounds for the current segment.
- BOOST_FOREACH(const LogEntryPB& entry_pb, batch->entry_batch_pb_->entry()) {
+ for (const LogEntryPB& entry_pb : batch->entry_batch_pb_->entry()) {
int64_t index = entry_pb.replicate().id().index();
if (!footer_builder_.has_min_replicate_index() ||
index < footer_builder_.min_replicate_index()) {
@@ -735,7 +735,7 @@ Status Log::GC(int64_t min_op_idx, int32_t* num_gced) {
// Now that they are no longer referenced by the Log, delete the files.
*num_gced = 0;
- BOOST_FOREACH(const scoped_refptr<ReadableLogSegment>& segment, segments_to_delete) {
+ for (const scoped_refptr<ReadableLogSegment>& segment : segments_to_delete) {
LOG(INFO) << "Deleting log segment in path: " << segment->path()
<< " (GCed ops < " << min_op_idx << ")";
RETURN_NOT_OK(fs_manager_->env()->DeleteFile(segment->path()));
@@ -765,7 +765,7 @@ void Log::GetGCableDataSize(int64_t min_op_idx, int64_t* total_size) const {
return;
}
}
- BOOST_FOREACH(const scoped_refptr<ReadableLogSegment>& segment, segments_to_delete) {
+ for (const scoped_refptr<ReadableLogSegment>& segment : segments_to_delete) {
*total_size += segment->file_size();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/log_anchor_registry.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_anchor_registry.cc b/src/kudu/consensus/log_anchor_registry.cc
index 7d58f5d..6e6c399 100644
--- a/src/kudu/consensus/log_anchor_registry.cc
+++ b/src/kudu/consensus/log_anchor_registry.cc
@@ -18,7 +18,6 @@
#include "kudu/consensus/log_anchor_registry.h"
#include "kudu/consensus/opid_util.h"
-#include <boost/foreach.hpp>
#include <boost/thread/locks.hpp>
#include <string>
@@ -89,7 +88,7 @@ std::string LogAnchorRegistry::DumpAnchorInfo() const {
string buf;
boost::lock_guard<simple_spinlock> l(lock_);
MonoTime now = MonoTime::Now(MonoTime::FINE);
- BOOST_FOREACH(const AnchorMultiMap::value_type& entry, anchors_) {
+ for (const AnchorMultiMap::value_type& entry : anchors_) {
const LogAnchor* anchor = entry.second;
DCHECK(anchor->is_registered);
if (!buf.empty()) buf += ", ";
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/log_cache.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_cache.cc b/src/kudu/consensus/log_cache.cc
index 08177df..8f92ab4 100644
--- a/src/kudu/consensus/log_cache.cc
+++ b/src/kudu/consensus/log_cache.cc
@@ -18,7 +18,6 @@
#include "kudu/consensus/log_cache.h"
#include <algorithm>
-#include <boost/foreach.hpp>
#include <gflags/gflags.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/wire_format_lite_inl.h>
@@ -307,7 +306,7 @@ Status LogCache::ReadOps(int64_t after_op_index,
LOG_WITH_PREFIX_UNLOCKED(INFO) << "Successfully read " << raw_replicate_ptrs.size() << " ops "
<< "from disk.";
- BOOST_FOREACH(ReplicateMsg* msg, raw_replicate_ptrs) {
+ for (ReplicateMsg* msg : raw_replicate_ptrs) {
CHECK_EQ(next_index, msg->id().index());
remaining_space -= TotalByteSizeForMessage(*msg);
@@ -431,7 +430,7 @@ std::string LogCache::LogPrefixUnlocked() const {
void LogCache::DumpToLog() const {
vector<string> strings;
DumpToStrings(&strings);
- BOOST_FOREACH(const string& s, strings) {
+ for (const string& s : strings) {
LOG_WITH_PREFIX_UNLOCKED(INFO) << s;
}
}
@@ -441,7 +440,7 @@ void LogCache::DumpToStrings(vector<string>* lines) const {
int counter = 0;
lines->push_back(ToStringUnlocked());
lines->push_back("Messages:");
- BOOST_FOREACH(const MessageCache::value_type& entry, cache_) {
+ for (const MessageCache::value_type& entry : cache_) {
const ReplicateMsg* msg = entry.second->get();
lines->push_back(
Substitute("Message[$0] $1.$2 : REPLICATE. Type: $3, Size: $4",
@@ -460,7 +459,7 @@ void LogCache::DumpToHtml(std::ostream& out) const {
out << "<tr><th>Entry</th><th>OpId</th><th>Type</th><th>Size</th><th>Status</th></tr>" << endl;
int counter = 0;
- BOOST_FOREACH(const MessageCache::value_type& entry, cache_) {
+ for (const MessageCache::value_type& entry : cache_) {
const ReplicateMsg* msg = entry.second->get();
out << Substitute("<tr><th>$0</th><th>$1.$2</th><td>REPLICATE $3</td>"
"<td>$4</td><td>$5</td></tr>",
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/log_index.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_index.cc b/src/kudu/consensus/log_index.cc
index 6d25f3a..1b99b2b 100644
--- a/src/kudu/consensus/log_index.cc
+++ b/src/kudu/consensus/log_index.cc
@@ -28,7 +28,6 @@
#include "kudu/consensus/log_index.h"
-#include <boost/foreach.hpp>
#include <fcntl.h>
#include <string>
#include <sys/mman.h>
@@ -256,7 +255,7 @@ void LogIndex::GC(int64_t min_index_to_retain) {
}
// Outside of the lock, try to delete them (avoid holding the lock during IO).
- BOOST_FOREACH(int64_t chunk_idx, chunks_to_delete) {
+ for (int64_t chunk_idx : chunks_to_delete) {
string path = GetChunkPath(chunk_idx);
int rc = unlink(path.c_str());
if (rc != 0) {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/log_reader.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_reader.cc b/src/kudu/consensus/log_reader.cc
index c56cd6b..131d91a 100644
--- a/src/kudu/consensus/log_reader.cc
+++ b/src/kudu/consensus/log_reader.cc
@@ -17,7 +17,6 @@
#include "kudu/consensus/log_reader.h"
-#include <boost/foreach.hpp>
#include <boost/thread/locks.hpp>
#include <algorithm>
@@ -139,7 +138,7 @@ Status LogReader::Init(const string& tablet_wal_path) {
SegmentSequence read_segments;
// build a log segment from each file
- BOOST_FOREACH(const string &log_file, log_files) {
+ for (const string &log_file : log_files) {
if (HasPrefixString(log_file, FsManager::kWalFileNamePrefix)) {
string fqp = JoinPathSegments(tablet_wal_path, log_file);
scoped_refptr<ReadableLogSegment> segment;
@@ -167,7 +166,7 @@ Status LogReader::Init(const string& tablet_wal_path) {
string previous_seg_path;
int64_t previous_seg_seqno = -1;
- BOOST_FOREACH(const SegmentSequence::value_type& entry, read_segments) {
+ for (const SegmentSequence::value_type& entry : read_segments) {
VLOG(1) << " Log Reader Indexed: " << entry->footer().ShortDebugString();
// Check that the log segments are in sequence.
if (previous_seg_seqno != -1 && entry->header().sequence_number() != previous_seg_seqno + 1) {
@@ -203,7 +202,7 @@ Status LogReader::GetSegmentPrefixNotIncluding(int64_t index,
boost::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(state_, kLogReaderReading);
- BOOST_FOREACH(const scoped_refptr<ReadableLogSegment>& segment, segments_) {
+ for (const scoped_refptr<ReadableLogSegment>& segment : segments_) {
// The last segment doesn't have a footer. Never include that one.
if (!segment->HasFooter()) {
break;
@@ -222,7 +221,7 @@ int64_t LogReader::GetMinReplicateIndex() const {
boost::lock_guard<simple_spinlock> lock(lock_);
int64_t min_remaining_op_idx = -1;
- BOOST_FOREACH(const scoped_refptr<ReadableLogSegment>& segment, segments_) {
+ for (const scoped_refptr<ReadableLogSegment>& segment : segments_) {
if (!segment->HasFooter()) continue;
if (!segment->footer().has_min_replicate_index()) continue;
if (min_remaining_op_idx == -1 ||
@@ -239,7 +238,7 @@ void LogReader::GetMaxIndexesToSegmentSizeMap(int64_t min_op_idx, int32_t segmen
max_idx_to_segment_size) const {
boost::lock_guard<simple_spinlock> lock(lock_);
DCHECK_GE(segments_count, 0);
- BOOST_FOREACH(const scoped_refptr<ReadableLogSegment>& segment, segments_) {
+ for (const scoped_refptr<ReadableLogSegment>& segment : segments_) {
if (max_idx_to_segment_size->size() == segments_count) {
break;
}
@@ -486,7 +485,7 @@ const int LogReader::num_segments() const {
string LogReader::ToString() const {
boost::lock_guard<simple_spinlock> lock(lock_);
string ret = "Reader's SegmentSequence: \n";
- BOOST_FOREACH(const SegmentSequence::value_type& entry, segments_) {
+ for (const SegmentSequence::value_type& entry : segments_) {
ret.append(Substitute("Segment: $0 Footer: $1\n",
entry->header().sequence_number(),
!entry->HasFooter() ? "NONE" : entry->footer().ShortDebugString()));
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/log_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_util.cc b/src/kudu/consensus/log_util.cc
index 815a080..c29d628 100644
--- a/src/kudu/consensus/log_util.cc
+++ b/src/kudu/consensus/log_util.cc
@@ -22,7 +22,6 @@
#include <limits>
#include <utility>
-#include <boost/foreach.hpp>
#include <gflags/gflags.h>
#include <glog/logging.h>
@@ -198,7 +197,7 @@ Status ReadableLogSegment::RebuildFooterByScanning() {
footer_.set_num_entries(entries.size());
// Rebuild the min/max replicate index (by scanning)
- BOOST_FOREACH(const LogEntryPB* entry, entries) {
+ for (const LogEntryPB* entry : entries) {
if (entry->has_replicate()) {
int64_t index = entry->replicate().id().index();
// TODO: common code with Log::UpdateFooterForBatch
@@ -568,7 +567,7 @@ Status ReadableLogSegment::MakeCorruptionStatus(int batch_number, int64_t batch_
batch_number, batch_offset, path_);
err.append("Prior batch offsets:");
std::sort(recent_offsets->begin(), recent_offsets->end());
- BOOST_FOREACH(int64_t offset, *recent_offsets) {
+ for (int64_t offset : *recent_offsets) {
if (offset >= 0) {
SubstituteAndAppend(&err, " $0", offset);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/mt-log-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/mt-log-test.cc b/src/kudu/consensus/mt-log-test.cc
index bf8f6f1..18d57d5 100644
--- a/src/kudu/consensus/mt-log-test.cc
+++ b/src/kudu/consensus/mt-log-test.cc
@@ -125,7 +125,7 @@ class MultiThreadedLogTest : public LogTestBase {
thread_id, FLAGS_num_batches_per_thread)) {
latch.Wait();
}
- BOOST_FOREACH(const Status& status, errors) {
+ for (const Status& status : errors) {
WARN_NOT_OK(status, "Unexpected failure during AsyncAppend");
}
ASSERT_EQ(0, errors.size());
@@ -138,7 +138,7 @@ class MultiThreadedLogTest : public LogTestBase {
&MultiThreadedLogTest::LogWriterThread, this, i, &new_thread));
threads_.push_back(new_thread);
}
- BOOST_FOREACH(scoped_refptr<kudu::Thread>& thread, threads_) {
+ for (scoped_refptr<kudu::Thread>& thread : threads_) {
ASSERT_OK(ThreadJoiner(thread.get()).Join());
}
}
@@ -161,7 +161,7 @@ TEST_F(MultiThreadedLogTest, TestAppends) {
SegmentSequence segments;
ASSERT_OK(log_->GetLogReader()->GetSegmentsSnapshot(&segments));
- BOOST_FOREACH(const SegmentSequence::value_type& entry, segments) {
+ for (const SegmentSequence::value_type& entry : segments) {
ASSERT_OK(entry->ReadEntries(&entries_));
}
vector<uint32_t> ids;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/peer_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/peer_manager.cc b/src/kudu/consensus/peer_manager.cc
index d342ce0..b00a7ad 100644
--- a/src/kudu/consensus/peer_manager.cc
+++ b/src/kudu/consensus/peer_manager.cc
@@ -55,7 +55,7 @@ Status PeerManager::UpdateRaftConfig(const RaftConfigPB& config) {
boost::lock_guard<simple_spinlock> lock(lock_);
// Create new peers
- BOOST_FOREACH(const RaftPeerPB& peer_pb, config.peers()) {
+ for (const RaftPeerPB& peer_pb : config.peers()) {
new_peers.insert(peer_pb.permanent_uuid());
Peer* peer = FindPtrOrNull(peers_, peer_pb.permanent_uuid());
if (peer != NULL) {
@@ -100,7 +100,7 @@ void PeerManager::SignalRequest(bool force_if_queue_empty) {
void PeerManager::Close() {
{
boost::lock_guard<simple_spinlock> lock(lock_);
- BOOST_FOREACH(const PeersMap::value_type& entry, peers_) {
+ for (const PeersMap::value_type& entry : peers_) {
entry.second->Close();
}
STLDeleteValues(&peers_);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/quorum_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/quorum_util.cc b/src/kudu/consensus/quorum_util.cc
index efa9848..ef93934 100644
--- a/src/kudu/consensus/quorum_util.cc
+++ b/src/kudu/consensus/quorum_util.cc
@@ -16,7 +16,6 @@
// under the License.
#include "kudu/consensus/quorum_util.h"
-#include <boost/foreach.hpp>
#include <set>
#include <string>
@@ -32,7 +31,7 @@ using std::string;
using strings::Substitute;
bool IsRaftConfigMember(const std::string& uuid, const RaftConfigPB& config) {
- BOOST_FOREACH(const RaftPeerPB& peer, config.peers()) {
+ for (const RaftPeerPB& peer : config.peers()) {
if (peer.permanent_uuid() == uuid) {
return true;
}
@@ -41,7 +40,7 @@ bool IsRaftConfigMember(const std::string& uuid, const RaftConfigPB& config) {
}
bool IsRaftConfigVoter(const std::string& uuid, const RaftConfigPB& config) {
- BOOST_FOREACH(const RaftPeerPB& peer, config.peers()) {
+ for (const RaftPeerPB& peer : config.peers()) {
if (peer.permanent_uuid() == uuid) {
return peer.member_type() == RaftPeerPB::VOTER;
}
@@ -52,7 +51,7 @@ bool IsRaftConfigVoter(const std::string& uuid, const RaftConfigPB& config) {
Status GetRaftConfigMember(const RaftConfigPB& config,
const std::string& uuid,
RaftPeerPB* peer_pb) {
- BOOST_FOREACH(const RaftPeerPB& peer, config.peers()) {
+ for (const RaftPeerPB& peer : config.peers()) {
if (peer.permanent_uuid() == uuid) {
*peer_pb = peer;
return Status::OK();
@@ -71,7 +70,7 @@ Status GetRaftConfigLeader(const ConsensusStatePB& cstate, RaftPeerPB* peer_pb)
bool RemoveFromRaftConfig(RaftConfigPB* config, const string& uuid) {
RepeatedPtrField<RaftPeerPB> modified_peers;
bool removed = false;
- BOOST_FOREACH(const RaftPeerPB& peer, config->peers()) {
+ for (const RaftPeerPB& peer : config->peers()) {
if (peer.permanent_uuid() == uuid) {
removed = true;
continue;
@@ -85,7 +84,7 @@ bool RemoveFromRaftConfig(RaftConfigPB* config, const string& uuid) {
int CountVoters(const RaftConfigPB& config) {
int voters = 0;
- BOOST_FOREACH(const RaftPeerPB& peer, config.peers()) {
+ for (const RaftPeerPB& peer : config.peers()) {
if (peer.member_type() == RaftPeerPB::VOTER) {
voters++;
}
@@ -107,7 +106,7 @@ RaftPeerPB::Role GetConsensusRole(const std::string& permanent_uuid,
return RaftPeerPB::NON_PARTICIPANT;
}
- BOOST_FOREACH(const RaftPeerPB& peer, cstate.config().peers()) {
+ for (const RaftPeerPB& peer : cstate.config().peers()) {
if (peer.permanent_uuid() == permanent_uuid) {
switch (peer.member_type()) {
case RaftPeerPB::VOTER:
@@ -167,7 +166,7 @@ Status VerifyRaftConfig(const RaftConfigPB& config, RaftConfigState type) {
return Status::OK();
}
- BOOST_FOREACH(const RaftPeerPB& peer, config.peers()) {
+ for (const RaftPeerPB& peer : config.peers()) {
if (!peer.has_permanent_uuid() || peer.permanent_uuid() == "") {
return Status::IllegalState(Substitute("One peer didn't have an uuid or had the empty"
" string. RaftConfig: $0", config.ShortDebugString()));
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/raft_consensus-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus-test.cc b/src/kudu/consensus/raft_consensus-test.cc
index 0df4d50..1876bcf 100644
--- a/src/kudu/consensus/raft_consensus-test.cc
+++ b/src/kudu/consensus/raft_consensus-test.cc
@@ -285,7 +285,7 @@ class RaftConsensusTest : public KuduTest {
void DumpRounds() {
LOG(INFO) << "Dumping rounds...";
- BOOST_FOREACH(const scoped_refptr<ConsensusRound>& round, rounds_) {
+ for (const scoped_refptr<ConsensusRound>& round : rounds_) {
LOG(INFO) << "Round: OpId " << round->id() << ", ReplicateMsg: "
<< round->replicate_msg()->ShortDebugString();
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/raft_consensus.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus.cc b/src/kudu/consensus/raft_consensus.cc
index 06952d1..7607630 100644
--- a/src/kudu/consensus/raft_consensus.cc
+++ b/src/kudu/consensus/raft_consensus.cc
@@ -269,7 +269,7 @@ Status RaftConsensus::Start(const ConsensusBootstrapInfo& info) {
<< info.orphaned_replicates.size()
<< " pending transactions. Active config: "
<< state_->GetActiveConfigUnlocked().ShortDebugString();
- BOOST_FOREACH(ReplicateMsg* replicate, info.orphaned_replicates) {
+ for (ReplicateMsg* replicate : info.orphaned_replicates) {
ReplicateRefPtr replicate_ptr = make_scoped_refptr_replicate(new ReplicateMsg(*replicate));
RETURN_NOT_OK(StartReplicaTransactionUnlocked(replicate_ptr));
}
@@ -859,7 +859,7 @@ Status RaftConsensus::CheckLeaderRequestUnlocked(const ConsensusRequestPB* reque
// we initialize raft_consensus-state is preventing us from doing so.
Status s;
const OpId* prev = deduped_req->preceding_opid;
- BOOST_FOREACH(const ReplicateRefPtr& message, deduped_req->messages) {
+ for (const ReplicateRefPtr& message : deduped_req->messages) {
s = ReplicaState::CheckOpInSequence(*prev, message->get()->id());
if (PREDICT_FALSE(!s.ok())) {
LOG(ERROR) << "Leader request contained out-of-sequence messages. Status: "
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/raft_consensus_quorum-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus_quorum-test.cc b/src/kudu/consensus/raft_consensus_quorum-test.cc
index a835ee4..1b3ecba 100644
--- a/src/kudu/consensus/raft_consensus_quorum-test.cc
+++ b/src/kudu/consensus/raft_consensus_quorum-test.cc
@@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/foreach.hpp>
#include <gtest/gtest.h>
#include "kudu/common/schema.h"
@@ -196,7 +195,7 @@ class RaftConsensusQuorumTest : public KuduTest {
ConsensusBootstrapInfo boot_info;
TestPeerMap all_peers = peers_->GetPeerMapCopy();
- BOOST_FOREACH(const TestPeerMap::value_type& entry, all_peers) {
+ for (const TestPeerMap::value_type& entry : all_peers) {
RETURN_NOT_OK(entry.second->Start(boot_info));
}
return Status::OK();
@@ -226,7 +225,7 @@ class RaftConsensusQuorumTest : public KuduTest {
CHECK_OK(peers_->GetPeerByIdx(peer_idx, &follower));
scoped_refptr<RaftConsensus> leader;
CHECK_OK(peers_->GetPeerByIdx(leader_idx, &leader));
- BOOST_FOREACH(LocalTestPeerProxy* proxy, down_cast<LocalTestPeerProxyFactory*>(
+ for (LocalTestPeerProxy* proxy : down_cast<LocalTestPeerProxyFactory*>(
leader->peer_proxy_factory_.get())->GetProxies()) {
if (proxy->GetTarget() == follower->peer_uuid()) {
return proxy;
@@ -339,7 +338,7 @@ class RaftConsensusQuorumTest : public KuduTest {
vector<string> lines;
scoped_refptr<RaftConsensus> leader;
CHECK_OK(peers_->GetPeerByIdx(leader_idx, &leader));
- BOOST_FOREACH(const string& line, lines) {
+ for (const string& line : lines) {
LOG(ERROR) << line;
}
@@ -398,7 +397,7 @@ class RaftConsensusQuorumTest : public KuduTest {
TestPeerMap all_peers = peers_->GetPeerMapCopy();
int i = 0;
- BOOST_FOREACH(const TestPeerMap::value_type& entry, all_peers) {
+ for (const TestPeerMap::value_type& entry : all_peers) {
if (entry.second->peer_uuid() != leader->peer_uuid()) {
WaitForReplicateIfNotAlreadyPresent(*last_op_id, i);
}
@@ -421,7 +420,7 @@ class RaftConsensusQuorumTest : public KuduTest {
log::SegmentSequence segments;
ASSERT_OK(log_reader->GetSegmentsSnapshot(&segments));
- BOOST_FOREACH(const log::SegmentSequence::value_type& entry, segments) {
+ for (const log::SegmentSequence::value_type& entry : segments) {
ASSERT_OK(entry->ReadEntries(&ret));
}
@@ -434,13 +433,13 @@ class RaftConsensusQuorumTest : public KuduTest {
void VerifyLogs(int leader_idx, int first_replica_idx, int last_replica_idx) {
// Wait for in-flight transactions to be done. We're destroying the
// peers next and leader transactions won't be able to commit anymore.
- BOOST_FOREACH(TestTransactionFactory* factory, txn_factories_) {
+ for (TestTransactionFactory* factory : txn_factories_) {
factory->WaitDone();
}
// Shut down all the peers.
TestPeerMap all_peers = peers_->GetPeerMapCopy();
- BOOST_FOREACH(const TestPeerMap::value_type& entry, all_peers) {
+ for (const TestPeerMap::value_type& entry : all_peers) {
entry.second->Shutdown();
}
@@ -467,7 +466,7 @@ class RaftConsensusQuorumTest : public KuduTest {
void ExtractReplicateIds(const vector<LogEntryPB*>& entries,
vector<OpId>* ids) {
ids->reserve(entries.size() / 2);
- BOOST_FOREACH(const LogEntryPB* entry, entries) {
+ for (const LogEntryPB* entry : entries) {
if (entry->has_replicate()) {
ids->push_back(entry->replicate().id());
}
@@ -491,7 +490,7 @@ class RaftConsensusQuorumTest : public KuduTest {
OpIdHashFunctor,
OpIdEqualsFunctor> replication_ops;
- BOOST_FOREACH(const LogEntryPB* entry, entries) {
+ for (const LogEntryPB* entry : entries) {
if (entry->has_replicate()) {
ASSERT_TRUE(InsertIfNotPresent(&replication_ops, entry->replicate().id()))
<< "REPLICATE op id showed up twice: " << entry->ShortDebugString();
@@ -523,7 +522,7 @@ class RaftConsensusQuorumTest : public KuduTest {
string ret = "";
SubstituteAndAppend(&ret, "$1 log entries for replica $0:\n",
replica_id, replica_entries.size());
- BOOST_FOREACH(LogEntryPB* replica_entry, replica_entries) {
+ for (LogEntryPB* replica_entry : replica_entries) {
StrAppend(&ret, "Replica log entry: ", replica_entry->ShortDebugString(), "\n");
}
return ret;
@@ -642,7 +641,7 @@ TEST_F(RaftConsensusQuorumTest, TestFollowersReplicateAndCommitSequence) {
&commit_sync);
// Commit the operations, but wait for the replicates to finish first
- BOOST_FOREACH(const scoped_refptr<ConsensusRound>& round, rounds) {
+ for (const scoped_refptr<ConsensusRound>& round : rounds) {
ASSERT_OK(CommitDummyMessage(kLeaderIdx, round.get(), &commit_sync));
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/raft_consensus_state-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus_state-test.cc b/src/kudu/consensus/raft_consensus_state-test.cc
index a699861..31a3215 100644
--- a/src/kudu/consensus/raft_consensus_state-test.cc
+++ b/src/kudu/consensus/raft_consensus_state-test.cc
@@ -16,7 +16,6 @@
// under the License.
#include "kudu/consensus/raft_consensus_state.h"
-#include <boost/foreach.hpp>
#include <gtest/gtest.h>
#include <vector>
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/consensus/raft_consensus_state.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus_state.cc b/src/kudu/consensus/raft_consensus_state.cc
index 2a03187..e962da1 100644
--- a/src/kudu/consensus/raft_consensus_state.cc
+++ b/src/kudu/consensus/raft_consensus_state.cc
@@ -16,7 +16,6 @@
// under the License.
#include <algorithm>
-#include <boost/foreach.hpp>
#include "kudu/consensus/log_util.h"
#include "kudu/consensus/quorum_util.h"
@@ -388,7 +387,7 @@ Status ReplicaState::CancelPendingTransactions() {
void ReplicaState::GetUncommittedPendingOperationsUnlocked(
vector<scoped_refptr<ConsensusRound> >* ops) {
- BOOST_FOREACH(const IndexToRoundMap::value_type& entry, pending_txns_) {
+ for (const IndexToRoundMap::value_type& entry : pending_txns_) {
if (entry.first > last_committed_index_.index()) {
ops->push_back(entry.second);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/experiments/merge-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/experiments/merge-test.cc b/src/kudu/experiments/merge-test.cc
index b7cf93a..f8b1271 100644
--- a/src/kudu/experiments/merge-test.cc
+++ b/src/kudu/experiments/merge-test.cc
@@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <gflags/gflags.h>
#include <glog/logging.h>
@@ -54,7 +53,7 @@ void HeapMerge(
vector<MergeTypeIter> iters;
vector<size_t> indexes;
size_t i = 0;
- BOOST_FOREACH(const vector<MergeType> &list, in_lists) {
+ for (const vector<MergeType> &list : in_lists) {
iters.push_back(list.begin());
indexes.push_back(i++);
}
@@ -82,7 +81,7 @@ void SimpleMerge(const vector<vector<MergeType> > &in_lists,
vector<MergeType> *out) {
typedef vector<MergeType>::const_iterator MergeTypeIter;
vector<MergeTypeIter> iters;
- BOOST_FOREACH(const vector<MergeType> &list, in_lists) {
+ for (const vector<MergeType> &list : in_lists) {
iters.push_back(list.begin());
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/experiments/rwlock-perf.cc
----------------------------------------------------------------------
diff --git a/src/kudu/experiments/rwlock-perf.cc b/src/kudu/experiments/rwlock-perf.cc
index 456e23b..31118cc 100644
--- a/src/kudu/experiments/rwlock-perf.cc
+++ b/src/kudu/experiments/rwlock-perf.cc
@@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/foreach.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#include <boost/smart_ptr/detail/yield_k.hpp>
@@ -220,7 +219,7 @@ void test_shared_lock(int num_threads,
}
int64_t start = CycleClock::Now();
- BOOST_FOREACH(boost::thread &thr, threads) {
+ for (boost::thread &thr : threads) {
thr.join();
}
int64_t end = CycleClock::Now();
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/fs/block_id.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_id.cc b/src/kudu/fs/block_id.cc
index 2aa799a..8b82117 100644
--- a/src/kudu/fs/block_id.cc
+++ b/src/kudu/fs/block_id.cc
@@ -17,7 +17,6 @@
#include "kudu/fs/block_id.h"
-#include <boost/foreach.hpp>
#include <glog/logging.h>
#include <string>
#include <vector>
@@ -35,7 +34,7 @@ const uint64_t BlockId::kInvalidId = 0;
string BlockId::JoinStrings(const vector<BlockId>& blocks) {
vector<string> strings;
strings.reserve(blocks.size());
- BOOST_FOREACH(const BlockId& block, blocks) {
+ for (const BlockId& block : blocks) {
strings.push_back(block.ToString());
}
return ::JoinStrings(strings, ",");
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/fs/block_manager-stress-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager-stress-test.cc b/src/kudu/fs/block_manager-stress-test.cc
index 1fc4b17..e1bc9dd 100644
--- a/src/kudu/fs/block_manager-stress-test.cc
+++ b/src/kudu/fs/block_manager-stress-test.cc
@@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/foreach.hpp>
#include <cmath>
#include <memory>
#include <string>
@@ -99,7 +98,7 @@ class BlockManagerStressTest : public KuduTest {
if (!FLAGS_block_manager_paths.empty()) {
vector<string> paths = strings::Split(FLAGS_block_manager_paths, ",",
strings::SkipEmpty());
- BOOST_FOREACH(const string& path, paths) {
+ for (const string& path : paths) {
WARN_NOT_OK(env_->DeleteRecursively(path),
Substitute("Couldn't recursively delete $0", path));
}
@@ -155,7 +154,7 @@ class BlockManagerStressTest : public KuduTest {
}
void JoinThreads() {
- BOOST_FOREACH(const scoped_refptr<kudu::Thread>& thr, threads_) {
+ for (const scoped_refptr<kudu::Thread>& thr : threads_) {
CHECK_OK(ThreadJoiner(thr.get()).Join());
}
}
@@ -255,7 +254,7 @@ void BlockManagerStressTest<T>::WriterThread() {
// Publish the now sync'ed blocks to readers and deleters.
{
lock_guard<rw_spinlock> l(&lock_);
- BOOST_FOREACH(WritableBlock* block, dirty_blocks) {
+ for (WritableBlock* block : dirty_blocks) {
written_blocks_.push_back(block->id());
}
}
@@ -352,7 +351,7 @@ void BlockManagerStressTest<T>::DeleterThread() {
}
// And delete them.
- BOOST_FOREACH(const BlockId& block_id, to_delete) {
+ for (const BlockId& block_id : to_delete) {
LOG(INFO) << "Deleting block " << block_id.ToString();
CHECK_OK(bm_->DeleteBlock(block_id));
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/fs/block_manager-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager-test.cc b/src/kudu/fs/block_manager-test.cc
index c1a943c..8bdba82 100644
--- a/src/kudu/fs/block_manager-test.cc
+++ b/src/kudu/fs/block_manager-test.cc
@@ -17,7 +17,6 @@
#include <memory>
-#include <boost/foreach.hpp>
#include "kudu/fs/file_block_manager.h"
#include "kudu/fs/log_block_manager.h"
@@ -117,11 +116,11 @@ class BlockManagerTest : public KuduTest {
template <>
void BlockManagerTest<FileBlockManager>::RunMultipathTest(const vector<string>& paths) {
// Ensure that each path has an instance file and that it's well-formed.
- BOOST_FOREACH(const string& path, paths) {
+ for (const string& path : paths) {
vector<string> children;
ASSERT_OK(env_->GetChildren(path, &children));
ASSERT_EQ(3, children.size());
- BOOST_FOREACH(const string& child, children) {
+ for (const string& child : children) {
if (child == "." || child == "..") {
continue;
}
@@ -144,7 +143,7 @@ void BlockManagerTest<FileBlockManager>::RunMultipathTest(const vector<string>&
// Each path should now have some additional block subdirectories. We
// can't know for sure exactly how many (depends on the block IDs
// generated), but this ensures that at least some change were made.
- BOOST_FOREACH(const string& path, paths) {
+ for (const string& path : paths) {
vector<string> children;
ASSERT_OK(env_->GetChildren(path, &children));
ASSERT_GT(children.size(), 3);
@@ -169,7 +168,7 @@ void BlockManagerTest<LogBlockManager>::RunMultipathTest(const vector<string>& p
// Verify the results: 7 children = dot, dotdot, instance file, and two
// containers (two files per container).
- BOOST_FOREACH(const string& path, paths) {
+ for (const string& path : paths) {
vector<string> children;
ASSERT_OK(env_->GetChildren(path, &children));
ASSERT_EQ(children.size(), 7);
@@ -297,7 +296,7 @@ void BlockManagerTest<LogBlockManager>::RunLogContainerPreallocationTest() {
// Instead, we expect the size to either be 0 (preallocation isn't
// supported) or equal to the preallocation amount.
bool found = false;
- BOOST_FOREACH(const string& child, children) {
+ for (const string& child : children) {
if (HasSuffixString(child, ".data")) {
found = true;
uint64_t size;
@@ -604,7 +603,7 @@ TYPED_TEST(BlockManagerTest, ConcurrentCloseReadableBlockTest) {
&CloseHelper, reader.get(), &t));
threads.push_back(t);
}
- BOOST_FOREACH(const scoped_refptr<Thread>& t, threads) {
+ for (const scoped_refptr<Thread>& t : threads) {
t->Join();
}
}
@@ -725,7 +724,7 @@ TEST_F(LogBlockManagerTest, TestReuseBlockIds) {
ASSERT_EQ(4, bm_->available_containers_.size());
// Delete the original blocks.
- BOOST_FOREACH(const BlockId& b, block_ids) {
+ for (const BlockId& b : block_ids) {
ASSERT_OK(bm_->DeleteBlock(b));
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/fs/block_manager.h
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager.h b/src/kudu/fs/block_manager.h
index 598e8a6..cc5c5a1 100644
--- a/src/kudu/fs/block_manager.h
+++ b/src/kudu/fs/block_manager.h
@@ -18,7 +18,6 @@
#ifndef KUDU_FS_BLOCK_MANAGER_H
#define KUDU_FS_BLOCK_MANAGER_H
-#include <boost/foreach.hpp>
#include <cstddef>
#include <memory>
#include <stdint.h>
@@ -246,7 +245,7 @@ class ScopedWritableBlockCloser {
ScopedWritableBlockCloser() {}
~ScopedWritableBlockCloser() {
- BOOST_FOREACH(WritableBlock* block, blocks_) {
+ for (WritableBlock* block : blocks_) {
WARN_NOT_OK(block->Abort(), strings::Substitute(
"Failed to abort block with id $0", block->id().ToString()));
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/fs/block_manager_util-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager_util-test.cc b/src/kudu/fs/block_manager_util-test.cc
index a9be3ac..cc68380 100644
--- a/src/kudu/fs/block_manager_util-test.cc
+++ b/src/kudu/fs/block_manager_util-test.cc
@@ -19,7 +19,6 @@
#include <string>
#include <vector>
-#include <boost/foreach.hpp>
#include <google/protobuf/repeated_field.h>
#include <gtest/gtest.h>
@@ -107,7 +106,7 @@ static void RunCheckIntegrityTest(Env* env,
ElementDeleter deleter(&instances);
int i = 0;
- BOOST_FOREACH(const PathSetPB& ps, path_sets) {
+ for (const PathSetPB& ps : path_sets) {
gscoped_ptr<PathInstanceMetadataFile> instance(
new PathInstanceMetadataFile(env, "asdf", Substitute("$0", i)));
gscoped_ptr<PathInstanceMetadataPB> metadata(new PathInstanceMetadataPB());
@@ -150,7 +149,7 @@ TEST_F(KuduTest, CheckIntegrity) {
{
// Test where the path sets have duplicate UUIDs.
vector<PathSetPB> path_sets_copy(path_sets);
- BOOST_FOREACH(PathSetPB& ps, path_sets_copy) {
+ for (PathSetPB& ps : path_sets_copy) {
ps.add_all_uuids("fee");
}
EXPECT_NO_FATAL_FAILURE(RunCheckIntegrityTest(
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/fs/block_manager_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager_util.cc b/src/kudu/fs/block_manager_util.cc
index 760079d..2865e04 100644
--- a/src/kudu/fs/block_manager_util.cc
+++ b/src/kudu/fs/block_manager_util.cc
@@ -20,7 +20,6 @@
#include <unordered_map>
#include <utility>
-#include <boost/foreach.hpp>
#include <gflags/gflags.h>
#include "kudu/fs/fs.pb.h"
@@ -70,7 +69,7 @@ Status PathInstanceMetadataFile::Create(const string& uuid, const vector<string>
PathSetPB* new_path_set = new_instance.mutable_path_set();
new_path_set->set_uuid(uuid);
new_path_set->mutable_all_uuids()->Reserve(all_uuids.size());
- BOOST_FOREACH(const string& u, all_uuids) {
+ for (const string& u : all_uuids) {
new_path_set->add_all_uuids(u);
}
@@ -129,7 +128,7 @@ Status PathInstanceMetadataFile::CheckIntegrity(
unordered_map<string, PathInstanceMetadataFile*> uuids;
pair<string, PathInstanceMetadataFile*> first_all_uuids;
- BOOST_FOREACH(PathInstanceMetadataFile* instance, instances) {
+ for (PathInstanceMetadataFile* instance : instances) {
const PathSetPB& path_set = instance->metadata()->path_set();
// Check that this instance's UUID wasn't already claimed.
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/fs/file_block_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/file_block_manager.cc b/src/kudu/fs/file_block_manager.cc
index 150878b..8de5698 100644
--- a/src/kudu/fs/file_block_manager.cc
+++ b/src/kudu/fs/file_block_manager.cc
@@ -17,7 +17,6 @@
#include "kudu/fs/file_block_manager.h"
-#include <boost/foreach.hpp>
#include <deque>
#include <string>
#include <unordered_set>
@@ -484,7 +483,7 @@ Status FileBlockManager::SyncMetadata(const internal::FileBlockLocation& locatio
vector<string> to_sync;
{
lock_guard<simple_spinlock> l(&lock_);
- BOOST_FOREACH(const string& parent_dir, parent_dirs) {
+ for (const string& parent_dir : parent_dirs) {
if (dirty_dirs_.erase(parent_dir)) {
to_sync.push_back(parent_dir);
}
@@ -493,7 +492,7 @@ Status FileBlockManager::SyncMetadata(const internal::FileBlockLocation& locatio
// Sync them.
if (FLAGS_enable_data_block_fsync) {
- BOOST_FOREACH(const string& s, to_sync) {
+ for (const string& s : to_sync) {
RETURN_NOT_OK(env_->SyncDir(s));
}
}
@@ -544,14 +543,14 @@ Status FileBlockManager::Create() {
// The UUIDs and indices will be included in every instance file.
ObjectIdGenerator oid_generator;
vector<string> all_uuids(root_paths_.size());
- BOOST_FOREACH(string& u, all_uuids) {
+ for (string& u : all_uuids) {
u = oid_generator.Next();
}
int idx = 0;
// Ensure the data paths exist and create the instance files.
unordered_set<string> to_sync;
- BOOST_FOREACH(const string& root_path, root_paths_) {
+ for (const string& root_path : root_paths_) {
bool created;
RETURN_NOT_OK_PREPEND(env_util::CreateDirIfMissing(env_, root_path, &created),
Substitute("Could not create directory $0", root_path));
@@ -572,14 +571,14 @@ Status FileBlockManager::Create() {
// Ensure newly created directories are synchronized to disk.
if (FLAGS_enable_data_block_fsync) {
- BOOST_FOREACH(const string& dir, to_sync) {
+ for (const string& dir : to_sync) {
RETURN_NOT_OK_PREPEND(env_->SyncDir(dir),
Substitute("Unable to synchronize directory $0", dir));
}
}
// Success: don't delete any files.
- BOOST_FOREACH(ScopedFileDeleter* deleter, delete_on_failure) {
+ for (ScopedFileDeleter* deleter : delete_on_failure) {
deleter->Cancel();
}
return Status::OK();
@@ -590,7 +589,7 @@ Status FileBlockManager::Open() {
ElementDeleter deleter(&instances);
instances.reserve(root_paths_.size());
- BOOST_FOREACH(const string& root_path, root_paths_) {
+ for (const string& root_path : root_paths_) {
if (!env_->FileExists(root_path)) {
return Status::NotFound(Substitute(
"FileBlockManager at $0 not found", root_path));
@@ -625,7 +624,7 @@ Status FileBlockManager::Open() {
JoinStrings(root_paths_, ",")));
PathMap instances_by_idx;
- BOOST_FOREACH(PathInstanceMetadataFile* instance, instances) {
+ for (PathInstanceMetadataFile* instance : instances) {
const PathSetPB& path_set = instance->metadata()->path_set();
uint32_t idx = -1;
for (int i = 0; i < path_set.all_uuids_size(); i++) {
@@ -696,7 +695,7 @@ Status FileBlockManager::CreateBlock(const CreateBlockOptions& opts,
// directory, which may not have been created but is definitely dirty
// (because we added a file to it).
lock_guard<simple_spinlock> l(&lock_);
- BOOST_FOREACH(const string& created, created_dirs) {
+ for (const string& created : created_dirs) {
dirty_dirs_.insert(created);
}
dirty_dirs_.insert(DirName(path));
@@ -754,13 +753,13 @@ Status FileBlockManager::CloseBlocks(const vector<WritableBlock*>& blocks) {
// Ask the kernel to begin writing out each block's dirty data. This is
// done up-front to give the kernel opportunities to coalesce contiguous
// dirty pages.
- BOOST_FOREACH(WritableBlock* block, blocks) {
+ for (WritableBlock* block : blocks) {
RETURN_NOT_OK(block->FlushDataAsync());
}
}
// Now close each block, waiting for each to become durable.
- BOOST_FOREACH(WritableBlock* block, blocks) {
+ for (WritableBlock* block : blocks) {
RETURN_NOT_OK(block->Close());
}
return Status::OK();
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/fs/fs_manager-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/fs_manager-test.cc b/src/kudu/fs/fs_manager-test.cc
index b79282e..922e617 100644
--- a/src/kudu/fs/fs_manager-test.cc
+++ b/src/kudu/fs/fs_manager-test.cc
@@ -91,7 +91,7 @@ TEST_F(FsManagerTestBase, TestBaseOperations) {
TEST_F(FsManagerTestBase, TestIllegalPaths) {
vector<string> illegal = { "", "asdf", "/foo\n\t" };
- BOOST_FOREACH(const string& path, illegal) {
+ for (const string& path : illegal) {
ReinitFsManager(path, { path });
ASSERT_TRUE(fs_manager()->CreateInitialFileSystemLayout().IsIOError());
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/fs/fs_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/fs_manager.cc b/src/kudu/fs/fs_manager.cc
index d303261..b03b003 100644
--- a/src/kudu/fs/fs_manager.cc
+++ b/src/kudu/fs/fs_manager.cc
@@ -22,7 +22,6 @@
#include <map>
#include <unordered_set>
-#include <boost/foreach.hpp>
#include <glog/logging.h>
#include <glog/stl_logging.h>
#include <google/protobuf/message.h>
@@ -145,7 +144,7 @@ Status FsManager::Init() {
// Deduplicate all of the roots.
set<string> all_roots;
all_roots.insert(wal_fs_root_);
- BOOST_FOREACH(const string& data_fs_root, data_fs_roots_) {
+ for (const string& data_fs_root : data_fs_roots_) {
all_roots.insert(data_fs_root);
}
@@ -153,7 +152,7 @@ Status FsManager::Init() {
// root a bit as we go.
typedef map<string, string> RootMap;
RootMap canonicalized_roots;
- BOOST_FOREACH(const string& root, all_roots) {
+ for (const string& root : all_roots) {
if (root.empty()) {
return Status::IOError("Empty string provided for filesystem root");
}
@@ -182,7 +181,7 @@ Status FsManager::Init() {
canonicalized_wal_fs_root_ = FindOrDie(canonicalized_roots, wal_fs_root_);
if (!data_fs_roots_.empty()) {
canonicalized_metadata_fs_root_ = FindOrDie(canonicalized_roots, data_fs_roots_[0]);
- BOOST_FOREACH(const string& data_fs_root, data_fs_roots_) {
+ for (const string& data_fs_root : data_fs_roots_) {
canonicalized_data_fs_roots_.insert(FindOrDie(canonicalized_roots, data_fs_root));
}
} else {
@@ -191,7 +190,7 @@ Status FsManager::Init() {
canonicalized_metadata_fs_root_ = canonicalized_wal_fs_root_;
canonicalized_data_fs_roots_.insert(canonicalized_wal_fs_root_);
}
- BOOST_FOREACH(const RootMap::value_type& e, canonicalized_roots) {
+ for (const RootMap::value_type& e : canonicalized_roots) {
canonicalized_all_fs_roots_.insert(e.second);
}
@@ -226,7 +225,7 @@ void FsManager::InitBlockManager() {
Status FsManager::Open() {
RETURN_NOT_OK(Init());
- BOOST_FOREACH(const string& root, canonicalized_all_fs_roots_) {
+ for (const string& root : canonicalized_all_fs_roots_) {
gscoped_ptr<InstanceMetadataPB> pb(new InstanceMetadataPB);
RETURN_NOT_OK(pb_util::ReadPBContainerFromPath(env_, GetInstanceMetadataPath(root),
pb.get()));
@@ -251,7 +250,7 @@ Status FsManager::CreateInitialFileSystemLayout() {
RETURN_NOT_OK(Init());
// It's OK if a root already exists as long as there's nothing in it.
- BOOST_FOREACH(const string& root, canonicalized_all_fs_roots_) {
+ for (const string& root : canonicalized_all_fs_roots_) {
if (!env_->FileExists(root)) {
// We'll create the directory below.
continue;
@@ -274,7 +273,7 @@ Status FsManager::CreateInitialFileSystemLayout() {
InstanceMetadataPB metadata;
CreateInstanceMetadata(&metadata);
unordered_set<string> to_sync;
- BOOST_FOREACH(const string& root, canonicalized_all_fs_roots_) {
+ for (const string& root : canonicalized_all_fs_roots_) {
bool created;
RETURN_NOT_OK_PREPEND(CreateDirIfMissing(root, &created),
"Unable to create FSManager root");
@@ -292,7 +291,7 @@ Status FsManager::CreateInitialFileSystemLayout() {
vector<string> ancillary_dirs = { GetWalsRootDir(),
GetTabletMetadataDir(),
GetConsensusMetadataDir() };
- BOOST_FOREACH(const string& dir, ancillary_dirs) {
+ for (const string& dir : ancillary_dirs) {
bool created;
RETURN_NOT_OK_PREPEND(CreateDirIfMissing(dir, &created),
Substitute("Unable to create directory $0", dir));
@@ -304,7 +303,7 @@ Status FsManager::CreateInitialFileSystemLayout() {
// Ensure newly created directories are synchronized to disk.
if (FLAGS_enable_data_block_fsync) {
- BOOST_FOREACH(const string& dir, to_sync) {
+ for (const string& dir : to_sync) {
RETURN_NOT_OK_PREPEND(env_->SyncDir(dir),
Substitute("Unable to synchronize directory $0", dir));
}
@@ -314,7 +313,7 @@ Status FsManager::CreateInitialFileSystemLayout() {
RETURN_NOT_OK_PREPEND(block_manager_->Create(), "Unable to create block manager");
// Success: don't delete any files.
- BOOST_FOREACH(ScopedFileDeleter* deleter, delete_on_failure) {
+ for (ScopedFileDeleter* deleter : delete_on_failure) {
deleter->Cancel();
}
return Status::OK();
@@ -351,7 +350,7 @@ Status FsManager::WriteInstanceMetadata(const InstanceMetadataPB& metadata,
Status FsManager::IsDirectoryEmpty(const string& path, bool* is_empty) {
vector<string> children;
RETURN_NOT_OK(env_->GetChildren(path, &children));
- BOOST_FOREACH(const string& child, children) {
+ for (const string& child : children) {
if (child == "." || child == "..") {
continue;
} else {
@@ -374,7 +373,7 @@ const string& FsManager::uuid() const {
vector<string> FsManager::GetDataRootDirs() const {
// Add the data subdirectory to each data root.
std::vector<std::string> data_paths;
- BOOST_FOREACH(const string& data_fs_root, canonicalized_data_fs_roots_) {
+ for (const string& data_fs_root : canonicalized_data_fs_roots_) {
data_paths.push_back(JoinPathSegments(data_fs_root, kDataDirName));
}
return data_paths;
@@ -414,7 +413,7 @@ Status FsManager::ListTabletIds(vector<string>* tablet_ids) {
Substitute("Couldn't list tablets in metadata directory $0", dir));
vector<string> tablets;
- BOOST_FOREACH(const string& child, children) {
+ for (const string& child : children) {
if (!IsValidTabletId(child)) {
continue;
}
@@ -449,7 +448,7 @@ string FsManager::GetWalSegmentFileName(const string& tablet_id,
void FsManager::DumpFileSystemTree(ostream& out) {
DCHECK(initted_);
- BOOST_FOREACH(const string& root, canonicalized_all_fs_roots_) {
+ for (const string& root : canonicalized_all_fs_roots_) {
out << "File-System Root: " << root << std::endl;
std::vector<string> objects;
@@ -465,7 +464,7 @@ void FsManager::DumpFileSystemTree(ostream& out) {
void FsManager::DumpFileSystemTree(ostream& out, const string& prefix,
const string& path, const vector<string>& objects) {
- BOOST_FOREACH(const string& name, objects) {
+ for (const string& name : objects) {
if (name == "." || name == "..") continue;
std::vector<string> sub_objects;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/fs/log_block_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/log_block_manager.cc b/src/kudu/fs/log_block_manager.cc
index 8aec59e..c5c4d97 100644
--- a/src/kudu/fs/log_block_manager.cc
+++ b/src/kudu/fs/log_block_manager.cc
@@ -17,7 +17,6 @@
#include "kudu/fs/log_block_manager.h"
-#include <boost/foreach.hpp>
#include "kudu/fs/block_manager_metrics.h"
#include "kudu/fs/block_manager_util.h"
@@ -1040,7 +1039,7 @@ LogBlockManager::~LogBlockManager() {
LOG_SLOW_EXECUTION(INFO, 1000,
Substitute("waiting on $0 log block manager thread pools",
thread_pools_by_root_path_.size())) {
- BOOST_FOREACH(const ThreadPoolMap::value_type& e,
+ for (const ThreadPoolMap::value_type& e :
thread_pools_by_root_path_) {
ThreadPool* p = e.second;
p->Wait();
@@ -1072,14 +1071,14 @@ Status LogBlockManager::Create() {
// The UUIDs and indices will be included in every instance file.
vector<string> all_uuids(root_paths_.size());
- BOOST_FOREACH(string& u, all_uuids) {
+ for (string& u : all_uuids) {
u = oid_generator()->Next();
}
int idx = 0;
// Ensure the data paths exist and create the instance files.
unordered_set<string> to_sync;
- BOOST_FOREACH(const string& root_path, root_paths_) {
+ for (const string& root_path : root_paths_) {
bool created;
RETURN_NOT_OK_PREPEND(env_util::CreateDirIfMissing(env_, root_path, &created),
Substitute("Could not create directory $0", root_path));
@@ -1103,14 +1102,14 @@ Status LogBlockManager::Create() {
// Ensure newly created directories are synchronized to disk.
if (FLAGS_enable_data_block_fsync) {
- BOOST_FOREACH(const string& dir, to_sync) {
+ for (const string& dir : to_sync) {
RETURN_NOT_OK_PREPEND(env_->SyncDir(dir),
Substitute("Unable to synchronize directory $0", dir));
}
}
// Success: don't delete any files.
- BOOST_FOREACH(ScopedFileDeleter* deleter, delete_on_failure) {
+ for (ScopedFileDeleter* deleter : delete_on_failure) {
deleter->Cancel();
}
return Status::OK();
@@ -1122,13 +1121,13 @@ Status LogBlockManager::Open() {
vector<Status> statuses(root_paths_.size());
unordered_map<string, PathInstanceMetadataFile*> metadata_files;
ValueDeleter deleter(&metadata_files);
- BOOST_FOREACH(const string& root_path, root_paths_) {
+ for (const string& root_path : root_paths_) {
InsertOrDie(&metadata_files, root_path, NULL);
}
// Submit each open to its own thread pool and wait for them to complete.
int i = 0;
- BOOST_FOREACH(const string& root_path, root_paths_) {
+ for (const string& root_path : root_paths_) {
ThreadPool* pool = FindOrDie(thread_pools_by_root_path_, root_path);
RETURN_NOT_OK_PREPEND(pool->SubmitClosure(
Bind(&LogBlockManager::OpenRootPath,
@@ -1139,13 +1138,13 @@ Status LogBlockManager::Open() {
Substitute("Could not open root path $0", root_path));
i++;
}
- BOOST_FOREACH(const ThreadPoolMap::value_type& e,
+ for (const ThreadPoolMap::value_type& e :
thread_pools_by_root_path_) {
e.second->Wait();
}
// Ensure that no tasks failed.
- BOOST_FOREACH(const Status& s, statuses) {
+ for (const Status& s : statuses) {
if (!s.ok()) {
return s;
}
@@ -1268,13 +1267,13 @@ Status LogBlockManager::CloseBlocks(const std::vector<WritableBlock*>& blocks) {
// Ask the kernel to begin writing out each block's dirty data. This is
// done up-front to give the kernel opportunities to coalesce contiguous
// dirty pages.
- BOOST_FOREACH(WritableBlock* block, blocks) {
+ for (WritableBlock* block : blocks) {
RETURN_NOT_OK(block->FlushDataAsync());
}
}
// Now close each block, waiting for each to become durable.
- BOOST_FOREACH(WritableBlock* block, blocks) {
+ for (WritableBlock* block : blocks) {
RETURN_NOT_OK(block->Close());
}
return Status::OK();
@@ -1445,7 +1444,7 @@ void LogBlockManager::OpenRootPath(const string& root_path,
"Could not list children of $0", root_path));
return;
}
- BOOST_FOREACH(const string& child, children) {
+ for (const string& child : children) {
string id;
if (!TryStripSuffixString(child, LogBlockContainer::kMetadataFileSuffix, &id)) {
continue;
@@ -1478,7 +1477,7 @@ void LogBlockManager::OpenRootPath(const string& root_path,
// the container-local map first ensures that we discount deleted blocks
// before checking for duplicate IDs.
UntrackedBlockMap blocks_in_container;
- BOOST_FOREACH(const BlockRecordPB& r, records) {
+ for (const BlockRecordPB& r : records) {
ProcessBlockRecord(r, container.get(), &blocks_in_container);
}
@@ -1486,7 +1485,7 @@ void LogBlockManager::OpenRootPath(const string& root_path,
// the container.
{
lock_guard<simple_spinlock> l(&lock_);
- BOOST_FOREACH(const UntrackedBlockMap::value_type& e, blocks_in_container) {
+ for (const UntrackedBlockMap::value_type& e : blocks_in_container) {
if (!AddLogBlockUnlocked(e.second)) {
LOG(FATAL) << "Found duplicate CREATE record for block " << e.first
<< " which already is alive from another container when "
@@ -1590,7 +1589,7 @@ Status LogBlockManager::Init() {
ThreadPoolMap pools;
ValueDeleter d(&pools);
int i = 0;
- BOOST_FOREACH(const string& root, root_paths_) {
+ for (const string& root : root_paths_) {
gscoped_ptr<ThreadPool> p;
RETURN_NOT_OK_PREPEND(ThreadPoolBuilder(Substitute("lbm root $0", i++))
.set_max_threads(1)
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/integration-tests/all_types-itest.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/all_types-itest.cc b/src/kudu/integration-tests/all_types-itest.cc
index 66333c2..9dae94f 100644
--- a/src/kudu/integration-tests/all_types-itest.cc
+++ b/src/kudu/integration-tests/all_types-itest.cc
@@ -62,7 +62,7 @@ struct SliceKeysTestSetup {
splits.push_back(StringPrintf("%08x", split));
}
vector<const KuduPartialRow*> rows;
- BOOST_FOREACH(string val, splits) {
+ for (string val : splits) {
Slice slice(val);
KuduPartialRow* row = schema.NewRow();
CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::type> >(0, slice));
@@ -139,7 +139,7 @@ struct IntKeysTestSetup {
splits.push_back(i * increment_);
}
vector<const KuduPartialRow*> rows;
- BOOST_FOREACH(CppType val, splits) {
+ for (CppType val : splits) {
KuduPartialRow* row = schema.NewRow();
CHECK_OK(row->Set<TypeTraits<KeyTypeWrapper::type> >(0, val));
rows.push_back(row);
@@ -221,7 +221,7 @@ class AllTypesItest : public KuduTest {
ExternalMiniClusterOptions opts;
opts.num_tablet_servers = kNumTabletServers;
- BOOST_FOREACH(const std::string& flag, ts_flags) {
+ for (const std::string& flag : ts_flags) {
opts.extra_tserver_flags.push_back(flag);
}
@@ -236,7 +236,7 @@ class AllTypesItest : public KuduTest {
vector<const KuduPartialRow*> split_rows = setup_.GenerateSplitRows(schema_);
gscoped_ptr<client::KuduTableCreator> table_creator(client_->NewTableCreator());
- BOOST_FOREACH(const KuduPartialRow* row, split_rows) {
+ for (const KuduPartialRow* row : split_rows) {
split_rows_.push_back(*row);
}
@@ -292,7 +292,7 @@ class AllTypesItest : public KuduTest {
void SetupProjection(vector<string>* projection) {
vector<string> keys = setup_.GetKeyColumns();
- BOOST_FOREACH(const string& key, keys) {
+ for (const string& key : keys) {
projection->push_back(key);
}
projection->push_back("int8_val");
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/integration-tests/alter_table-randomized-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/alter_table-randomized-test.cc b/src/kudu/integration-tests/alter_table-randomized-test.cc
index 3880c79..b272b8d 100644
--- a/src/kudu/integration-tests/alter_table-randomized-test.cc
+++ b/src/kudu/integration-tests/alter_table-randomized-test.cc
@@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/foreach.hpp>
#include <algorithm>
#include <map>
@@ -106,7 +105,7 @@ struct RowState {
string ret = "(";
typedef pair<string, int32_t> entry;
bool first = true;
- BOOST_FOREACH(const entry& e, cols) {
+ for (const entry& e : cols) {
if (!first) {
ret.append(", ");
}
@@ -180,7 +179,7 @@ struct TableState {
void AddColumnWithDefault(const string& name, int32_t def, bool nullable) {
col_names_.push_back(name);
col_nullable_.push_back(nullable);
- BOOST_FOREACH(entry& e, rows_) {
+ for (entry& e : rows_) {
e.second->cols.push_back(make_pair(name, def));
}
}
@@ -190,7 +189,7 @@ struct TableState {
int index = col_it - col_names_.begin();
col_names_.erase(col_it);
col_nullable_.erase(col_nullable_.begin() + index);
- BOOST_FOREACH(entry& e, rows_) {
+ for (entry& e : rows_) {
e.second->cols.erase(e.second->cols.begin() + index);
}
}
@@ -207,7 +206,7 @@ struct TableState {
void ToStrings(vector<string>* strs) {
strs->clear();
- BOOST_FOREACH(const entry& e, rows_) {
+ for (const entry& e : rows_) {
strs->push_back(e.second->ToString());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/integration-tests/alter_table-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/alter_table-test.cc b/src/kudu/integration-tests/alter_table-test.cc
index e0b0025..1dfeee2 100644
--- a/src/kudu/integration-tests/alter_table-test.cc
+++ b/src/kudu/integration-tests/alter_table-test.cc
@@ -16,7 +16,6 @@
// under the License.
#include <boost/assign.hpp>
-#include <boost/foreach.hpp>
#include <gflags/gflags.h>
#include <gtest/gtest.h>
#include <map>
@@ -447,7 +446,7 @@ void AlterTableTest::UpdateRow(int32_t row_key,
int32_t key = bswap_32(row_key); // endian swap to match 'InsertRows'
CHECK_OK(update->mutable_row()->SetInt32(0, key));
typedef map<string, int32_t>::value_type entry;
- BOOST_FOREACH(const entry& e, updates) {
+ for (const entry& e : updates) {
CHECK_OK(update->mutable_row()->SetInt32(e.first, e.second));
}
CHECK_OK(session->Apply(update.release()));
@@ -476,7 +475,7 @@ void AlterTableTest::VerifyRows(int start_row, int num_rows, VerifyPattern patte
while (scanner.HasMoreRows()) {
CHECK_OK(scanner.NextBatch(&results));
- BOOST_FOREACH(const KuduRowResult& row, results) {
+ for (const KuduRowResult& row : results) {
int32_t key = 0;
CHECK_OK(row.GetInt32(0, &key));
int32_t row_idx = bswap_32(key);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/9daafa5e/src/kudu/integration-tests/client-stress-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/client-stress-test.cc b/src/kudu/integration-tests/client-stress-test.cc
index fb1c52c..6401bfc 100644
--- a/src/kudu/integration-tests/client-stress-test.cc
+++ b/src/kudu/integration-tests/client-stress-test.cc
@@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/foreach.hpp>
#include <memory>
#include <vector>
@@ -148,7 +147,7 @@ TEST_F(ClientStressTest, TestStartScans) {
go_latch.CountDown();
- BOOST_FOREACH(const scoped_refptr<kudu::Thread>& thr, threads) {
+ for (const scoped_refptr<kudu::Thread>& thr : threads) {
CHECK_OK(ThreadJoiner(thr.get()).Join());
}
}