You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2016/05/12 22:09:59 UTC

[24/50] [abbrv] incubator-impala git commit: IMPALA-3443: Replace BOOST_FOREACH with ranged for()

IMPALA-3443: Replace BOOST_FOREACH with ranged for()

This patch doesn't use 'auto' for the loop index type, as it's not clear
yet where the savings in typing outweigh the cost of eliding the type.

Change-Id: Iae1ca36313e3562311b6418478bf54b6d9b0bf7d
Reviewed-on: http://gerrit.cloudera.org:8080/2890
Tested-by: Internal Jenkins
Reviewed-by: Henry Robinson <he...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/5454086c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/5454086c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/5454086c

Branch: refs/heads/master
Commit: 5454086c748d2b77a3fcfb1e2a71866c6260ca54
Parents: b5d77f4
Author: Henry Robinson <he...@cloudera.com>
Authored: Wed Apr 27 21:10:40 2016 -0700
Committer: Tim Armstrong <ta...@cloudera.com>
Committed: Thu May 12 14:17:56 2016 -0700

----------------------------------------------------------------------
 be/src/benchmarks/thread-create-benchmark.cc |  3 +-
 be/src/catalog/catalog-server.cc             | 10 +++---
 be/src/codegen/instruction-counter.cc        | 10 ++----
 be/src/common/status.cc                      |  9 ++---
 be/src/exec/catalog-op-executor.cc           |  4 +--
 be/src/exec/data-sink.cc                     |  2 +-
 be/src/exec/data-source-scan-node.cc         |  3 +-
 be/src/exec/hash-join-node.cc                |  2 +-
 be/src/exec/hbase-scan-node.cc               |  3 +-
 be/src/exec/hbase-table-writer.cc            |  5 ++-
 be/src/exec/hdfs-avro-scanner.cc             |  5 ++-
 be/src/exec/hdfs-parquet-scanner.cc          | 16 ++++-----
 be/src/exec/hdfs-scan-node.cc                | 19 +++++-----
 be/src/exec/hdfs-table-sink.cc               | 20 +++++------
 be/src/exec/incr-stats-util.cc               |  7 ++--
 be/src/exec/kudu-scan-node-test.cc           |  2 +-
 be/src/exec/kudu-scan-node.cc                | 11 +++---
 be/src/exec/kudu-scanner.cc                  |  3 +-
 be/src/exec/kudu-table-sink-test.cc          |  2 +-
 be/src/exec/kudu-table-sink.cc               |  2 +-
 be/src/exec/partitioned-hash-join-node.cc    | 14 ++++----
 be/src/exprs/aggregate-functions-test.cc     |  3 +-
 be/src/exprs/expr-codegen-test.cc            |  2 +-
 be/src/exprs/expr-test.cc                    |  8 ++---
 be/src/exprs/in-predicate-benchmark.cc       |  6 ++--
 be/src/resourcebroker/resource-broker.cc     | 25 +++++++------
 be/src/rpc/rpc-trace.cc                      |  9 +++--
 be/src/runtime/buffered-block-mgr-test.cc    |  8 ++---
 be/src/runtime/buffered-block-mgr.cc         |  6 ++--
 be/src/runtime/buffered-tuple-stream.cc      |  2 +-
 be/src/runtime/client-cache.cc               | 10 +++---
 be/src/runtime/coordinator.cc                | 43 +++++++++++------------
 be/src/runtime/data-stream-recvr.cc          |  2 +-
 be/src/runtime/descriptors.cc                |  2 +-
 be/src/runtime/disk-io-mgr-reader-context.cc |  2 +-
 be/src/runtime/disk-io-mgr.cc                |  2 +-
 be/src/runtime/lib-cache.cc                  |  3 +-
 be/src/runtime/mem-tracker.cc                |  2 +-
 be/src/runtime/plan-fragment-executor.cc     |  8 ++---
 be/src/runtime/sorted-run-merger.cc          |  2 +-
 be/src/runtime/sorter.cc                     | 20 +++++------
 be/src/runtime/timestamp-parse-util.cc       |  5 ++-
 be/src/runtime/tmp-file-mgr.cc               |  1 -
 be/src/runtime/types.cc                      |  5 ++-
 be/src/scheduling/admission-controller.cc    | 25 +++++++------
 be/src/scheduling/query-resource-mgr.cc      |  3 +-
 be/src/scheduling/query-schedule.cc          |  9 +++--
 be/src/scheduling/simple-scheduler.cc        | 29 ++++++++-------
 be/src/service/impala-beeswax-server.cc      |  7 ++--
 be/src/service/impala-hs2-server.cc          |  9 +++--
 be/src/service/impala-server-callbacks.cc    | 29 ++++++++-------
 be/src/service/impala-server.cc              | 33 +++++++++--------
 be/src/service/query-exec-state.cc           |  7 ++--
 be/src/service/query-options.cc              |  3 +-
 be/src/statestore/statestore-subscriber.cc   |  9 +++--
 be/src/statestore/statestore.cc              | 28 +++++++--------
 be/src/testutil/mini-impala-cluster.cc       |  5 +--
 be/src/util/codec.cc                         |  5 ++-
 be/src/util/collection-metrics.h             |  5 ++-
 be/src/util/debug-util.cc                    |  3 +-
 be/src/util/dict-encoding.h                  |  5 ++-
 be/src/util/dict-test.cc                     |  7 ++--
 be/src/util/error-util.cc                    |  8 ++---
 be/src/util/error-util.h                     |  1 -
 be/src/util/hdfs-bulk-ops.cc                 |  5 +--
 be/src/util/logging-support.cc               |  3 +-
 be/src/util/memory-metrics.cc                |  3 +-
 be/src/util/metrics.cc                       | 10 +++---
 be/src/util/metrics.h                        |  3 +-
 be/src/util/network-util.cc                  |  3 +-
 be/src/util/runtime-profile-test.cc          |  5 ++-
 be/src/util/runtime-profile.cc               | 27 +++++++-------
 be/src/util/thread.cc                        | 19 ++++------
 be/src/util/url-coding.cc                    |  3 +-
 be/src/util/webserver.cc                     | 15 ++++----
 75 files changed, 286 insertions(+), 368 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/benchmarks/thread-create-benchmark.cc
----------------------------------------------------------------------
diff --git a/be/src/benchmarks/thread-create-benchmark.cc b/be/src/benchmarks/thread-create-benchmark.cc
index 4f4e138..4b117bc 100644
--- a/be/src/benchmarks/thread-create-benchmark.cc
+++ b/be/src/benchmarks/thread-create-benchmark.cc
@@ -22,7 +22,6 @@
 #include "util/stopwatch.h"
 
 #include <boost/thread/thread.hpp>
-#include <boost/foreach.hpp>
 #include <boost/bind.hpp>
 
 #include "common/names.h"
@@ -90,7 +89,7 @@ void ImpalaThreadStarter(int num_threads, const function<void ()>& f) {
   for (int i=0; i < num_threads; ++i) {
     threads.push_back(new Thread("mythreadgroup", "thread", f));
   }
-  BOOST_FOREACH(Thread* thread, threads) {
+  for (Thread* thread: threads) {
     thread->Join();
     delete thread;
   }

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/catalog/catalog-server.cc
----------------------------------------------------------------------
diff --git a/be/src/catalog/catalog-server.cc b/be/src/catalog/catalog-server.cc
index bbe82b9..a1a20a8 100644
--- a/be/src/catalog/catalog-server.cc
+++ b/be/src/catalog/catalog-server.cc
@@ -229,7 +229,7 @@ void CatalogServer::UpdateCatalogTopicCallback(
     LOG_EVERY_N(INFO, 300) << "Catalog Version: " << catalog_objects_max_version_
                            << " Last Catalog Version: " << last_sent_catalog_version_;
 
-    BOOST_FOREACH(const TTopicItem& catalog_object, pending_topic_updates_) {
+    for (const TTopicItem& catalog_object: pending_topic_updates_) {
       if (subscriber_topic_updates->size() == 0) {
         subscriber_topic_updates->push_back(TTopicDelta());
         subscriber_topic_updates->back().topic_name = IMPALA_CATALOG_TOPIC;
@@ -294,7 +294,7 @@ void CatalogServer::BuildTopicUpdates(const vector<TCatalogObject>& catalog_obje
   unordered_set<string> current_entry_keys;
 
   // Add any new/updated catalog objects to the topic.
-  BOOST_FOREACH(const TCatalogObject& catalog_object, catalog_objects) {
+  for (const TCatalogObject& catalog_object: catalog_objects) {
     const string& entry_key = TCatalogObjectToEntryKey(catalog_object);
     if (entry_key.empty()) {
       LOG_EVERY_N(WARNING, 60) << "Unable to build topic entry key for TCatalogObject: "
@@ -325,7 +325,7 @@ void CatalogServer::BuildTopicUpdates(const vector<TCatalogObject>& catalog_obje
 
   // Any remaining items in catalog_topic_entry_keys_ indicate the object was removed
   // since the last update.
-  BOOST_FOREACH(const string& key, catalog_topic_entry_keys_) {
+  for (const string& key: catalog_topic_entry_keys_) {
     pending_topic_updates_.push_back(TTopicItem());
     TTopicItem& item = pending_topic_updates_.back();
     item.key = key;
@@ -345,7 +345,7 @@ void CatalogServer::CatalogUrlCallback(const Webserver::ArgumentMap& args,
     return;
   }
   Value databases(kArrayType);
-  BOOST_FOREACH(const TDatabase& db, get_dbs_result.dbs) {
+  for (const TDatabase& db: get_dbs_result.dbs) {
     Value database(kObjectType);
     Value str(db.db_name.c_str(), document->GetAllocator());
     database.AddMember("name", str, document->GetAllocator());
@@ -359,7 +359,7 @@ void CatalogServer::CatalogUrlCallback(const Webserver::ArgumentMap& args,
     }
 
     Value table_array(kArrayType);
-    BOOST_FOREACH(const string& table, get_table_results.tables) {
+    for (const string& table: get_table_results.tables) {
       Value table_obj(kObjectType);
       Value fq_name(Substitute("$0.$1", db.db_name, table).c_str(),
           document->GetAllocator());

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/codegen/instruction-counter.cc
----------------------------------------------------------------------
diff --git a/be/src/codegen/instruction-counter.cc b/be/src/codegen/instruction-counter.cc
index 56a5c04..9c7be41 100644
--- a/be/src/codegen/instruction-counter.cc
+++ b/be/src/codegen/instruction-counter.cc
@@ -14,8 +14,6 @@
 
 #include "codegen/instruction-counter.h"
 
-#include <boost/foreach.hpp>
-
 #include "common/logging.h"
 
 #include "common/names.h"
@@ -147,9 +145,7 @@ void InstructionCounter::visit(const Instruction& I) {
 }
 
 void InstructionCounter::ResetCount() {
-  BOOST_FOREACH(CounterMap::value_type& counter, counters_) {
-    counter.second = 0;
-  }
+  for (CounterMap::value_type& counter: counters_) counter.second = 0;
 }
 
 void InstructionCounter::PrintCounter(const char* name, int count, int max_count_len,
@@ -165,7 +161,7 @@ string InstructionCounter::PrintCounters() const {
   // Find the longest length of all the InstructionCount count_ strings.
   int max_count_len = 0;
   stringstream count_stream;
-  BOOST_FOREACH(const CounterMap::value_type& counter, counters_) {
+  for (const CounterMap::value_type& counter: counters_) {
     count_stream << counter.second;
     max_count_len =
         max(max_count_len, static_cast<int>(strlen(count_stream.str().c_str())));
@@ -177,7 +173,7 @@ string InstructionCounter::PrintCounters() const {
          << "                          ... Instruction Counts ...\n\n"
          << "===" << string(73, '-') << "===\n\n";
 
-  BOOST_FOREACH(const CounterMap::value_type& counter, counters_) {
+  for (const CounterMap::value_type& counter: counters_) {
     // Conditional is only used in order to print the top level counters
     // separate from the other counters.
     if (strcmp(counter.first.c_str(), TOTAL_BLOCKS) == 0) {

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/common/status.cc
----------------------------------------------------------------------
diff --git a/be/src/common/status.cc b/be/src/common/status.cc
index 0e8bc10..ede4144 100644
--- a/be/src/common/status.cc
+++ b/be/src/common/status.cc
@@ -12,7 +12,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include <boost/foreach.hpp>
 #include <boost/algorithm/string/join.hpp>
 
 #include "common/status.h"
@@ -185,9 +184,7 @@ void Status::MergeStatus(const Status& status) {
     msg_ = new ErrorMsg(*status.msg_);
   } else {
     msg_->AddDetail(status.msg().msg());
-    BOOST_FOREACH(const string& s, status.msg_->details()) {
-      msg_->AddDetail(s);
-    }
+    for (const string& s: status.msg_->details()) msg_->AddDetail(s);
   }
 }
 
@@ -202,9 +199,7 @@ void Status::ToThrift(TStatus* status) const {
   } else {
     status->status_code = msg_->error();
     status->error_msgs.push_back(msg_->msg());
-    BOOST_FOREACH(const string& s, msg_->details()) {
-      status->error_msgs.push_back(s);
-    }
+    for (const string& s: msg_->details()) status->error_msgs.push_back(s);
     status->__isset.error_msgs = true;
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/catalog-op-executor.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/catalog-op-executor.cc b/be/src/exec/catalog-op-executor.cc
index 3b6365d..77a2e82 100644
--- a/be/src/exec/catalog-op-executor.cc
+++ b/be/src/exec/catalog-op-executor.cc
@@ -193,7 +193,7 @@ void CatalogOpExecutor::SetTableStats(const TTableSchema& tbl_stats_schema,
   // Accumulate total number of rows in the table.
   long total_num_rows = 0;
   // Set per-partition stats.
-  BOOST_FOREACH(const TRow& row, tbl_stats_data.rows) {
+  for (const TRow& row: tbl_stats_data.rows) {
     DCHECK_GT(row.colVals.size(), 0);
     // The first column is the COUNT(*) expr of the original query.
     DCHECK(row.colVals[0].__isset.i64Val);
@@ -210,7 +210,7 @@ void CatalogOpExecutor::SetTableStats(const TTableSchema& tbl_stats_schema,
     total_num_rows += num_rows;
   }
 
-  BOOST_FOREACH(const TPartitionStats& existing_stats, existing_part_stats) {
+  for (const TPartitionStats& existing_stats: existing_part_stats) {
     total_num_rows += existing_stats.stats.num_rows;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/data-sink.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/data-sink.cc b/be/src/exec/data-sink.cc
index d4ad073..0ed6ab0 100644
--- a/be/src/exec/data-sink.cc
+++ b/be/src/exec/data-sink.cc
@@ -113,7 +113,7 @@ string DataSink::OutputInsertStats(const PartitionStatusMap& stats,
   stringstream ss;
   ss << prefix;
   bool first = true;
-  BOOST_FOREACH(const PartitionStatusMap::value_type& val, stats) {
+  for (const PartitionStatusMap::value_type& val: stats) {
     if (!first) ss << endl;
     first = false;
     ss << "Partition: ";

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/data-source-scan-node.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/data-source-scan-node.cc b/be/src/exec/data-source-scan-node.cc
index 829168f..1c1aae5 100644
--- a/be/src/exec/data-source-scan-node.cc
+++ b/be/src/exec/data-source-scan-node.cc
@@ -14,7 +14,6 @@
 
 #include "exec/data-source-scan-node.h"
 
-#include <boost/foreach.hpp>
 #include <vector>
 #include <gutil/strings/substitute.h>
 
@@ -94,7 +93,7 @@ Status DataSourceScanNode::Open(RuntimeState* state) {
 
   // Prepare the schema for TOpenParams.row_schema
   vector<extdatasource::TColumnDesc> cols;
-  BOOST_FOREACH(const SlotDescriptor* slot, tuple_desc_->slots()) {
+  for (const SlotDescriptor* slot: tuple_desc_->slots()) {
     extdatasource::TColumnDesc col;
     int col_idx = slot->col_pos();
     col.__set_name(tuple_desc_->table_desc()->col_descs()[col_idx].name());

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/hash-join-node.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/hash-join-node.cc b/be/src/exec/hash-join-node.cc
index 0e61689..9823df6 100644
--- a/be/src/exec/hash-join-node.cc
+++ b/be/src/exec/hash-join-node.cc
@@ -79,7 +79,7 @@ Status HashJoinNode::Init(const TPlanNode& tnode, RuntimeState* state) {
       Expr::CreateExprTrees(pool_, tnode.hash_join_node.other_join_conjuncts,
                             &other_join_conjunct_ctxs_));
 
-  BOOST_FOREACH(const TRuntimeFilterDesc& tfilter, tnode.runtime_filters) {
+  for (const TRuntimeFilterDesc& tfilter: tnode.runtime_filters) {
     // If filter propagation not enabled, only consider building broadcast joins (that may
     // be consumed by this fragment).
     if (state->query_options().runtime_filter_mode != TRuntimeFilterMode::GLOBAL &&

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/hbase-scan-node.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/hbase-scan-node.cc b/be/src/exec/hbase-scan-node.cc
index 2efc95a..f628c0d 100644
--- a/be/src/exec/hbase-scan-node.cc
+++ b/be/src/exec/hbase-scan-node.cc
@@ -15,7 +15,6 @@
 #include "hbase-scan-node.h"
 
 #include <algorithm>
-#include <boost/foreach.hpp>
 
 #include "runtime/runtime-state.h"
 #include "runtime/row-batch.h"
@@ -96,7 +95,7 @@ Status HBaseScanNode::Prepare(RuntimeState* state) {
   // Convert TScanRangeParams to ScanRanges
   DCHECK(scan_range_params_ != NULL)
       << "Must call SetScanRanges() before calling Prepare()";
-  BOOST_FOREACH(const TScanRangeParams& params, *scan_range_params_) {
+  for (const TScanRangeParams& params: *scan_range_params_) {
     DCHECK(params.scan_range.__isset.hbase_key_range);
     const THBaseKeyRange& key_range = params.scan_range.hbase_key_range;
     scan_range_vector_.push_back(HBaseTableScanner::ScanRange());

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/hbase-table-writer.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/hbase-table-writer.cc b/be/src/exec/hbase-table-writer.cc
index bbd17a6..eeb3fef 100644
--- a/be/src/exec/hbase-table-writer.cc
+++ b/be/src/exec/hbase-table-writer.cc
@@ -14,7 +14,6 @@
 
 #include "exec/hbase-table-writer.h"
 
-#include <boost/foreach.hpp>
 #include <boost/scoped_array.hpp>
 #include <sstream>
 
@@ -203,10 +202,10 @@ Status HBaseTableWriter::CleanUpJni() {
     put_list_ = NULL;
   }
 
-  BOOST_FOREACH(jbyteArray ref, cf_arrays_) {
+  for (jbyteArray ref: cf_arrays_) {
     RETURN_IF_ERROR(JniUtil::FreeGlobalRef(env, ref));
   }
-  BOOST_FOREACH(jbyteArray ref, qual_arrays_) {
+  for (jbyteArray ref: qual_arrays_) {
     RETURN_IF_ERROR(JniUtil::FreeGlobalRef(env, ref));
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/hdfs-avro-scanner.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/hdfs-avro-scanner.cc b/be/src/exec/hdfs-avro-scanner.cc
index 1064411..e7559ac 100644
--- a/be/src/exec/hdfs-avro-scanner.cc
+++ b/be/src/exec/hdfs-avro-scanner.cc
@@ -16,7 +16,6 @@
 
 #include <avro/errors.h>
 #include <avro/legacy.h>
-#include <boost/foreach.hpp>
 #include <gutil/strings/substitute.h>
 
 #include "codegen/llvm-codegen.h"
@@ -191,7 +190,7 @@ Status HdfsAvroScanner::ResolveSchemas(const AvroSchemaElement& table_root,
 
   // Associate each slot descriptor with a field in the file schema, or fill in the
   // template tuple with a default value from the table schema.
-  BOOST_FOREACH(SlotDescriptor* slot_desc, scan_node_->materialized_slots()) {
+  for (SlotDescriptor* slot_desc: scan_node_->materialized_slots()) {
     // Traverse the column path, simultaneously traversing the table schema by ordinal and
     // the file schema by field name from the table schema.
     const SchemaPath& path = slot_desc->col_path();
@@ -519,7 +518,7 @@ Status HdfsAvroScanner::ProcessRange() {
 bool HdfsAvroScanner::MaterializeTuple(const AvroSchemaElement& record_schema,
     MemPool* pool, uint8_t** data, Tuple* tuple) {
   DCHECK_EQ(record_schema.schema->type, AVRO_RECORD);
-  BOOST_FOREACH(const AvroSchemaElement& element, record_schema.children) {
+  for (const AvroSchemaElement& element: record_schema.children) {
     const SlotDescriptor* slot_desc = element.slot_desc;
     bool write_slot = false;
     void* slot = NULL;

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/hdfs-parquet-scanner.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/hdfs-parquet-scanner.cc b/be/src/exec/hdfs-parquet-scanner.cc
index a7677ad..b32270c 100644
--- a/be/src/exec/hdfs-parquet-scanner.cc
+++ b/be/src/exec/hdfs-parquet-scanner.cc
@@ -1000,7 +1000,7 @@ void HdfsParquetScanner::Close() {
 
   // Visit each column reader, including collection reader children.
   stack<ColumnReader*> readers;
-  BOOST_FOREACH(ColumnReader* r, column_readers_) readers.push(r);
+  for (ColumnReader* r: column_readers_) readers.push(r);
   while (!readers.empty()) {
     ColumnReader* col_reader = readers.top();
     readers.pop();
@@ -1008,7 +1008,7 @@ void HdfsParquetScanner::Close() {
     if (col_reader->IsCollectionReader()) {
       CollectionColumnReader* collection_reader =
           static_cast<CollectionColumnReader*>(col_reader);
-      BOOST_FOREACH(ColumnReader* r, *collection_reader->children()) readers.push(r);
+      for (ColumnReader* r: *collection_reader->children()) readers.push(r);
       continue;
     }
 
@@ -1616,14 +1616,14 @@ int HdfsParquetScanner::CountScalarColumns(const vector<ColumnReader*>& column_r
   DCHECK(!column_readers.empty());
   int num_columns = 0;
   stack<ColumnReader*> readers;
-  BOOST_FOREACH(ColumnReader* r, column_readers_) readers.push(r);
+  for (ColumnReader* r: column_readers_) readers.push(r);
   while (!readers.empty()) {
     ColumnReader* col_reader = readers.top();
     readers.pop();
     if (col_reader->IsCollectionReader()) {
       CollectionColumnReader* collection_reader =
           static_cast<CollectionColumnReader*>(col_reader);
-      BOOST_FOREACH(ColumnReader* r, *collection_reader->children()) readers.push(r);
+      for (ColumnReader* r: *collection_reader->children()) readers.push(r);
       continue;
     }
     ++num_columns;
@@ -1680,7 +1680,7 @@ Status HdfsParquetScanner::ProcessSplit() {
 
     // Prepare column readers for first read
     bool continue_execution = true;
-    BOOST_FOREACH(ColumnReader* col_reader, column_readers_) {
+    for (ColumnReader* col_reader: column_readers_) {
       continue_execution = col_reader->NextLevels();
       if (!continue_execution) break;
       DCHECK(parse_status_.ok()) << "Invalid parse_status_" << parse_status_.GetDetail();
@@ -2453,7 +2453,7 @@ Status HdfsParquetScanner::CreateColumnReaders(const TupleDescriptor& tuple_desc
   // Each tuple can have at most one position slot. We'll process this slot desc last.
   SlotDescriptor* pos_slot_desc = NULL;
 
-  BOOST_FOREACH(SlotDescriptor* slot_desc, tuple_desc.slots()) {
+  for (SlotDescriptor* slot_desc: tuple_desc.slots()) {
     // Skip partition columns
     if (&tuple_desc == scan_node_->tuple_desc() &&
         slot_desc->col_pos() < scan_node_->num_partition_keys()) continue;
@@ -2553,7 +2553,7 @@ Status HdfsParquetScanner::CreateCountingReader(
         node = nodes.front();
         nodes.pop();
         if (node->children.size() > 0) {
-          BOOST_FOREACH(const SchemaNode& child, node->children) nodes.push(&child);
+          for (const SchemaNode& child: node->children) nodes.push(&child);
         } else {
           // node is the least-nested scalar descendent of 'target_node'
           break;
@@ -2586,7 +2586,7 @@ Status HdfsParquetScanner::InitColumns(
   // Used to validate we issued the right number of scan ranges
   int num_scalar_readers = 0;
 
-  BOOST_FOREACH(ColumnReader* col_reader, column_readers) {
+  for (ColumnReader* col_reader: column_readers) {
     if (col_reader->IsCollectionReader()) {
       CollectionColumnReader* collection_reader =
           static_cast<CollectionColumnReader*>(col_reader);

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/hdfs-scan-node.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/hdfs-scan-node.cc b/be/src/exec/hdfs-scan-node.cc
index 16efdf8..4435aec 100644
--- a/be/src/exec/hdfs-scan-node.cc
+++ b/be/src/exec/hdfs-scan-node.cc
@@ -25,7 +25,6 @@
 #include <avro/errors.h>
 #include <avro/schema.h>
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 #include <boost/filesystem.hpp>
 #include <gutil/strings/substitute.h>
 
@@ -145,7 +144,7 @@ Status HdfsScanNode::Init(const TPlanNode& tnode, RuntimeState* state) {
   }
 
   const TQueryOptions& query_options = state->query_options();
-  BOOST_FOREACH(const TRuntimeFilterDesc& filter, tnode.runtime_filters) {
+  for (const TRuntimeFilterDesc& filter: tnode.runtime_filters) {
     if (query_options.disable_row_runtime_filtering &&
         !filter.is_bound_by_partition_columns) {
       continue;
@@ -232,9 +231,9 @@ Status HdfsScanNode::GetNext(RuntimeState* state, RowBatch* row_batch, bool* eos
     if (filter_ctxs_.size() > 0) WaitForRuntimeFilters(wait_time_ms);
     // Apply dynamic partition-pruning per-file.
     FileFormatsMap matching_per_type_files;
-    BOOST_FOREACH(const FileFormatsMap::value_type& v, per_type_files_) {
+    for (const FileFormatsMap::value_type& v: per_type_files_) {
       vector<HdfsFileDesc*>* matching_files = &matching_per_type_files[v.first];
-      BOOST_FOREACH(HdfsFileDesc* file, v.second) {
+      for (HdfsFileDesc* file: v.second) {
         if (FilePassesFilterPredicates(filter_ctxs_, v.first, file)) {
           matching_files->push_back(file);
         }
@@ -602,7 +601,7 @@ Status HdfsScanNode::Prepare(RuntimeState* state) {
   // will need to be decompressed at once). For all other formats, we use a constant.
   // TODO: can we do something better?
   int64_t scanner_thread_mem_usage = SCANNER_THREAD_MEM_USAGE;
-  BOOST_FOREACH(HdfsFileDesc* file, per_type_files_[THdfsFileFormat::TEXT]) {
+  for (HdfsFileDesc* file: per_type_files_[THdfsFileFormat::TEXT]) {
     if (file->file_compression != THdfsCompression::NONE) {
       int64_t bytes_required = file->file_length * COMPRESSED_TEXT_COMPRESSION_RATIO;
       scanner_thread_mem_usage = ::max(bytes_required, scanner_thread_mem_usage);
@@ -611,7 +610,7 @@ Status HdfsScanNode::Prepare(RuntimeState* state) {
   scanner_thread_bytes_required_ += scanner_thread_mem_usage;
 
   // Prepare all the partitions scanned by the scan node
-  BOOST_FOREACH(const int64_t& partition_id, partition_ids_) {
+  for (int64_t partition_id: partition_ids_) {
     HdfsPartitionDescriptor* partition_desc = hdfs_table_->GetPartition(partition_id);
     // This is IMPALA-1702, but will have been caught earlier in this method.
     DCHECK(partition_desc != NULL) << "table_id=" << hdfs_table_->id()
@@ -716,7 +715,7 @@ Status HdfsScanNode::Open(RuntimeState* state) {
   }
 
   // Open all the partition exprs used by the scan node
-  BOOST_FOREACH(const int64_t& partition_id, partition_ids_) {
+  for (int64_t partition_id: partition_ids_) {
     HdfsPartitionDescriptor* partition_desc = hdfs_table_->GetPartition(partition_id);
     DCHECK(partition_desc != NULL) << "table_id=" << hdfs_table_->id()
                                    << " partition_id=" << partition_id
@@ -834,7 +833,7 @@ void HdfsScanNode::Close(RuntimeState* state) {
   if (scan_node_pool_.get() != NULL) scan_node_pool_->FreeAll();
 
   // Close all the partitions scanned by the scan node
-  BOOST_FOREACH(const int64_t& partition_id, partition_ids_) {
+  for (int64_t partition_id: partition_ids_) {
     HdfsPartitionDescriptor* partition_desc = hdfs_table_->GetPartition(partition_id);
     if (partition_desc == NULL) {
       // TODO: Revert when IMPALA-1702 is fixed.
@@ -875,7 +874,7 @@ void HdfsScanNode::AddMaterializedRowBatch(RowBatch* row_batch) {
 
 void HdfsScanNode::InitNullCollectionValues(const TupleDescriptor* tuple_desc,
     Tuple* tuple) const {
-  BOOST_FOREACH(const SlotDescriptor* slot_desc, tuple_desc->collection_slots()) {
+  for (const SlotDescriptor* slot_desc: tuple_desc->collection_slots()) {
     CollectionValue* slot = reinterpret_cast<CollectionValue*>(
         tuple->GetSlot(slot_desc->tuple_offset()));
     if (tuple->IsNull(slot_desc->null_indicator_offset())) {
@@ -1348,7 +1347,7 @@ void HdfsScanNode::UpdateHdfsSplitStats(
     const vector<TScanRangeParams>& scan_range_params_list,
     PerVolumnStats* per_volume_stats) {
   pair<int, int64_t> init_value(0, 0);
-  BOOST_FOREACH(const TScanRangeParams& scan_range_params, scan_range_params_list) {
+  for (const TScanRangeParams& scan_range_params: scan_range_params_list) {
     const TScanRange& scan_range = scan_range_params.scan_range;
     if (!scan_range.__isset.hdfs_file_split) continue;
     const THdfsFileSplit& split = scan_range.hdfs_file_split;

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/hdfs-table-sink.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/hdfs-table-sink.cc b/be/src/exec/hdfs-table-sink.cc
index d145d9a..f345b73 100644
--- a/be/src/exec/hdfs-table-sink.cc
+++ b/be/src/exec/hdfs-table-sink.cc
@@ -96,9 +96,8 @@ Status HdfsTableSink::PrepareExprs(RuntimeState* state) {
       table_desc_->num_cols() - table_desc_->num_clustering_cols()) << DebugString();
 
   // Prepare literal partition key exprs
-  BOOST_FOREACH(
-      const HdfsTableDescriptor::PartitionIdToDescriptorMap::value_type& id_to_desc,
-      table_desc_->partition_descriptors()) {
+  for (const HdfsTableDescriptor::PartitionIdToDescriptorMap::value_type& id_to_desc:
+       table_desc_->partition_descriptors()) {
     HdfsPartitionDescriptor* partition = id_to_desc.second;
     RETURN_IF_ERROR(partition->PrepareExprs(state));
   }
@@ -163,9 +162,8 @@ Status HdfsTableSink::Open(RuntimeState* state) {
   RETURN_IF_ERROR(Expr::Open(output_expr_ctxs_, state));
   RETURN_IF_ERROR(Expr::Open(partition_key_expr_ctxs_, state));
   // Open literal partition key exprs
-  BOOST_FOREACH(
-      const HdfsTableDescriptor::PartitionIdToDescriptorMap::value_type& id_to_desc,
-      table_desc_->partition_descriptors()) {
+  for (const HdfsTableDescriptor::PartitionIdToDescriptorMap::value_type& id_to_desc:
+       table_desc_->partition_descriptors()) {
     HdfsPartitionDescriptor* partition = id_to_desc.second;
     RETURN_IF_ERROR(partition->OpenExprs(state));
   }
@@ -174,9 +172,8 @@ Status HdfsTableSink::Open(RuntimeState* state) {
   // partition key values to partition descriptor for multiple output format support. The
   // map is keyed on the concatenation of the non-constant keys of the PARTITION clause of
   // the INSERT statement.
-  BOOST_FOREACH(
-      const HdfsTableDescriptor::PartitionIdToDescriptorMap::value_type& id_to_desc,
-      table_desc_->partition_descriptors()) {
+  for (const HdfsTableDescriptor::PartitionIdToDescriptorMap::value_type& id_to_desc:
+       table_desc_->partition_descriptors()) {
     if (id_to_desc.first == g_ImpalaInternalService_constants.DEFAULT_PARTITION_ID) {
       default_partition_ = id_to_desc.second;
     } else {
@@ -648,9 +645,8 @@ void HdfsTableSink::Close(RuntimeState* state) {
   partition_keys_to_output_partitions_.clear();
 
   // Close literal partition key exprs
-  BOOST_FOREACH(
-      const HdfsTableDescriptor::PartitionIdToDescriptorMap::value_type& id_to_desc,
-      table_desc_->partition_descriptors()) {
+  for (const HdfsTableDescriptor::PartitionIdToDescriptorMap::value_type& id_to_desc:
+       table_desc_->partition_descriptors()) {
     HdfsPartitionDescriptor* partition = id_to_desc.second;
     partition->CloseExprs(state);
   }

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/incr-stats-util.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/incr-stats-util.cc b/be/src/exec/incr-stats-util.cc
index ac9c252..d83144f 100644
--- a/be/src/exec/incr-stats-util.cc
+++ b/be/src/exec/incr-stats-util.cc
@@ -14,7 +14,6 @@
 
 #include "incr-stats-util.h"
 
-#include <boost/foreach.hpp>
 #include <boost/unordered_set.hpp>
 #include <gutil/strings/substitute.h>
 #include <cmath>
@@ -204,7 +203,7 @@ void FinalizePartitionedColumnStats(const TTableSchema& col_stats_schema,
   if (rowset.rows.size() > 0) {
     DCHECK_GE(rowset.rows[0].colVals.size(), COLUMNS_PER_STAT);
     params->__isset.partition_stats = true;
-    BOOST_FOREACH(const TRow& col_stats_row, rowset.rows) {
+    for (const TRow& col_stats_row: rowset.rows) {
       // The last few columns are partition columns that the results are grouped by, and
       // so uniquely identify the partition that these stats belong to.
       vector<string> partition_key_vals;
@@ -265,7 +264,7 @@ void FinalizePartitionedColumnStats(const TTableSchema& col_stats_schema,
   TTableStats empty_table_stats;
   empty_table_stats.__set_num_rows(0);
   empty_part_stats.stats = empty_table_stats;
-  BOOST_FOREACH(const vector<string>& part_key_vals, expected_partitions) {
+  for (const vector<string>& part_key_vals: expected_partitions) {
     DCHECK_EQ(part_key_vals.size(), num_partition_cols);
     if (seen_partitions.find(part_key_vals) != seen_partitions.end()) continue;
     params->partition_stats[part_key_vals] = empty_part_stats;
@@ -274,7 +273,7 @@ void FinalizePartitionedColumnStats(const TTableSchema& col_stats_schema,
   // Now aggregate the existing statistics. The FE will ensure that the set of
   // partitions accessed by the query and this list are disjoint and cover the entire
   // set of partitions.
-  BOOST_FOREACH(const TPartitionStats& existing_stats, existing_part_stats) {
+  for (const TPartitionStats& existing_stats: existing_part_stats) {
     DCHECK_LE(existing_stats.intermediate_col_stats.size(),
         col_stats_schema.columns.size());
     for (int i = 0; i < num_cols; ++i) {

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/kudu-scan-node-test.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/kudu-scan-node-test.cc b/be/src/exec/kudu-scan-node-test.cc
index 9e1cf4c..11a04d8 100644
--- a/be/src/exec/kudu-scan-node-test.cc
+++ b/be/src/exec/kudu-scan-node-test.cc
@@ -204,7 +204,7 @@ class KuduScanNodeTest : public testing::Test {
           GetSlotDescriptor(KEY_SLOT_ID)->tuple_offset();
 
       std::sort(row_batches.begin(), row_batches.end(), comp);
-      BOOST_FOREACH(RowBatch* batch, row_batches) {
+      for (RowBatch* batch: row_batches) {
         VerifyBatch(batch, first_row, first_row + batch->num_rows(),
             num_cols_to_materialize, num_notnull_cols);
         first_row += batch->num_rows();

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/kudu-scan-node.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/kudu-scan-node.cc b/be/src/exec/kudu-scan-node.cc
index e835b09..3d12f4f 100644
--- a/be/src/exec/kudu-scan-node.cc
+++ b/be/src/exec/kudu-scan-node.cc
@@ -15,7 +15,6 @@
 #include "exec/kudu-scan-node.h"
 
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 #include <kudu/client/row_result.h>
 #include <kudu/client/schema.h>
 #include <kudu/client/value.h>
@@ -99,7 +98,7 @@ Status KuduScanNode::Prepare(RuntimeState* state) {
   // Convert TScanRangeParams to ScanRanges.
   CHECK(scan_range_params_ != NULL)
       << "Must call SetScanRanges() before calling Prepare()";
-  BOOST_FOREACH(const TScanRangeParams& params, *scan_range_params_) {
+  for (const TScanRangeParams& params: *scan_range_params_) {
     const TKuduKeyRange& key_range = params.scan_range.kudu_key_range;
     key_ranges_.push_back(key_range);
   }
@@ -127,7 +126,7 @@ Status KuduScanNode::Open(RuntimeState* state) {
       static_cast<const KuduTableDescriptor*>(tuple_desc_->table_desc());
 
   kudu::client::KuduClientBuilder b;
-  BOOST_FOREACH(const string& address, table_desc->kudu_master_addresses()) {
+  for (const string& address: table_desc->kudu_master_addresses()) {
     b.add_master_server_addr(address);
   }
 
@@ -200,7 +199,7 @@ Status KuduScanNode::GetNext(RuntimeState* state, RowBatch* row_batch, bool* eos
 Status KuduScanNode::TransformPushableConjunctsToRangePredicates() {
   // The only supported pushable predicates are binary operators with a SlotRef and a
   // literal as the left and right operands respectively.
-  BOOST_FOREACH(const TExpr& predicate, pushable_conjuncts_) {
+  for (const TExpr& predicate: pushable_conjuncts_) {
     DCHECK_EQ(predicate.nodes.size(), 3);
     const TExprNode& function_call = predicate.nodes[0];
 
@@ -247,7 +246,7 @@ void KuduScanNode::GetSlotRefColumnName(const TExprNode& node, string* col_name)
   const KuduTableDescriptor* table_desc =
       static_cast<const KuduTableDescriptor*>(tuple_desc_->table_desc());
   TSlotId slot_id = node.slot_ref.slot_id;
-  BOOST_FOREACH(SlotDescriptor* slot, tuple_desc_->slots()) {
+  for (SlotDescriptor* slot: tuple_desc_->slots()) {
     if (slot->id() == slot_id) {
       int col_idx = slot->col_pos();
       *col_name = table_desc->col_descs()[col_idx].name();
@@ -375,7 +374,7 @@ Status KuduScanNode::GetConjunctCtxs(vector<ExprContext*>* ctxs) {
 
 void KuduScanNode::ClonePredicates(vector<KuduPredicate*>* predicates) {
   unique_lock<mutex> l(lock_);
-  BOOST_FOREACH(KuduPredicate* predicate, kudu_predicates_) {
+  for (KuduPredicate* predicate: kudu_predicates_) {
     predicates->push_back(predicate->Clone());
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/kudu-scanner.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/kudu-scanner.cc b/be/src/exec/kudu-scanner.cc
index 48d82e8..18098aa 100644
--- a/be/src/exec/kudu-scanner.cc
+++ b/be/src/exec/kudu-scanner.cc
@@ -14,7 +14,6 @@
 
 #include "exec/kudu-scanner.h"
 
-#include <boost/foreach.hpp>
 #include <kudu/client/row_result.h>
 #include <thrift/protocol/TDebugProtocol.h>
 #include <vector>
@@ -168,7 +167,7 @@ Status KuduScanner::OpenNextRange(const TKuduKeyRange& key_range)  {
 
   vector<KuduPredicate*> predicates;
   scan_node_->ClonePredicates(&predicates);
-  BOOST_FOREACH(KuduPredicate* predicate, predicates) {
+  for (KuduPredicate* predicate: predicates) {
     KUDU_RETURN_IF_ERROR(scanner_->AddConjunctPredicate(predicate),
                          "Unable to add conjunct predicate.");
   }

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/kudu-table-sink-test.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/kudu-table-sink-test.cc b/be/src/exec/kudu-table-sink-test.cc
index 9e49d6d..11dfa5e 100644
--- a/be/src/exec/kudu-table-sink-test.cc
+++ b/be/src/exec/kudu-table-sink-test.cc
@@ -185,7 +185,7 @@ class KuduTableSinkTest : public testing::Test {
     while (scanner.HasMoreRows()) {
       vector<kudu::client::KuduRowResult> rows;
       KUDU_ASSERT_OK(scanner.NextBatch(&rows));
-      BOOST_FOREACH(const kudu::client::KuduRowResult& row, rows) {
+      for (const kudu::client::KuduRowResult& row: rows) {
         switch(num_columns) {
           case 1:
             ASSERT_EQ(row.ToString(), strings::Substitute(

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/kudu-table-sink.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/kudu-table-sink.cc b/be/src/exec/kudu-table-sink.cc
index b24c6ea..c3b91b7 100644
--- a/be/src/exec/kudu-table-sink.cc
+++ b/be/src/exec/kudu-table-sink.cc
@@ -114,7 +114,7 @@ Status KuduTableSink::Open(RuntimeState* state) {
   RETURN_IF_ERROR(Expr::Open(output_expr_ctxs_, state));
 
   kudu::client::KuduClientBuilder b;
-  BOOST_FOREACH(const string& address, table_desc_->kudu_master_addresses()) {
+  for (const string& address: table_desc_->kudu_master_addresses()) {
     b.add_master_server_addr(address);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exec/partitioned-hash-join-node.cc
----------------------------------------------------------------------
diff --git a/be/src/exec/partitioned-hash-join-node.cc b/be/src/exec/partitioned-hash-join-node.cc
index 1a21ecc..0ecec1e 100644
--- a/be/src/exec/partitioned-hash-join-node.cc
+++ b/be/src/exec/partitioned-hash-join-node.cc
@@ -93,7 +93,7 @@ Status PartitionedHashJoinNode::Init(const TPlanNode& tnode, RuntimeState* state
       Expr::CreateExprTrees(pool_, tnode.hash_join_node.other_join_conjuncts,
                             &other_join_conjunct_ctxs_));
 
-  BOOST_FOREACH(const TRuntimeFilterDesc& filter, tnode.runtime_filters) {
+  for (const TRuntimeFilterDesc& filter: tnode.runtime_filters) {
     // If filter propagation not enabled, only consider building broadcast joins (that may
     // be consumed by this fragment).
     if (state->query_options().runtime_filter_mode != TRuntimeFilterMode::GLOBAL &&
@@ -135,7 +135,7 @@ Status PartitionedHashJoinNode::Prepare(RuntimeState* state) {
       Expr::Prepare(build_expr_ctxs_, state, child(1)->row_desc(), expr_mem_tracker()));
   RETURN_IF_ERROR(
       Expr::Prepare(probe_expr_ctxs_, state, child(0)->row_desc(), expr_mem_tracker()));
-  BOOST_FOREACH(const FilterContext& ctx, filters_) {
+  for (const FilterContext& ctx: filters_) {
     RETURN_IF_ERROR(ctx.expr->Prepare(state, child(1)->row_desc(), expr_mem_tracker()));
     AddExprCtxToFree(ctx.expr);
   }
@@ -313,7 +313,7 @@ void PartitionedHashJoinNode::Close(RuntimeState* state) {
   Expr::Close(build_expr_ctxs_, state);
   Expr::Close(probe_expr_ctxs_, state);
   Expr::Close(other_join_conjunct_ctxs_, state);
-  BOOST_FOREACH(const FilterContext& ctx, filters_) {
+  for (const FilterContext& ctx: filters_) {
     ctx.expr->Close(state);
   }
   BlockingJoinNode::Close(state);
@@ -611,7 +611,7 @@ Status PartitionedHashJoinNode::ConstructBuildSide(RuntimeState* state) {
   RETURN_IF_ERROR(Expr::Open(build_expr_ctxs_, state));
   RETURN_IF_ERROR(Expr::Open(probe_expr_ctxs_, state));
   RETURN_IF_ERROR(Expr::Open(other_join_conjunct_ctxs_, state));
-  BOOST_FOREACH(const FilterContext& filter, filters_) {
+  for (const FilterContext& filter: filters_) {
     RETURN_IF_ERROR(filter.expr->Open(state));
   }
   AllocateRuntimeFilters(state);
@@ -1238,7 +1238,7 @@ Status PartitionedHashJoinNode::BuildHashTables(RuntimeState* state) {
 
   // First loop over the partitions and build hash tables for the partitions that did
   // not already spill.
-  BOOST_FOREACH(Partition* partition, hash_partitions_) {
+  for (Partition* partition: hash_partitions_) {
     if (partition->build_rows()->num_rows() == 0) {
       // This partition is empty, no need to do anything else.
       partition->Close(NULL);
@@ -1259,7 +1259,7 @@ Status PartitionedHashJoinNode::BuildHashTables(RuntimeState* state) {
   // an IO buffer for those partitions. Reserving an IO buffer can cause more partitions
   // to spill so this process is recursive.
   list<Partition*> spilled_partitions;
-  BOOST_FOREACH(Partition* partition, hash_partitions_) {
+  for (Partition* partition: hash_partitions_) {
     if (partition->is_closed()) continue;
     if (partition->is_spilled() && partition->probe_rows()->using_small_buffers()) {
       spilled_partitions.push_back(partition);
@@ -1290,7 +1290,7 @@ Status PartitionedHashJoinNode::BuildHashTables(RuntimeState* state) {
   // 2. in_mem. The build side is pinned and has a hash table built.
   // 3. spilled. The build side is fully unpinned and the probe side has an io
   //    sized buffer.
-  BOOST_FOREACH(Partition* partition, hash_partitions_) {
+  for (Partition* partition: hash_partitions_) {
     if (partition->hash_tbl() != NULL) partition->probe_rows()->Close();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exprs/aggregate-functions-test.cc
----------------------------------------------------------------------
diff --git a/be/src/exprs/aggregate-functions-test.cc b/be/src/exprs/aggregate-functions-test.cc
index 0550508..4c1bed3 100644
--- a/be/src/exprs/aggregate-functions-test.cc
+++ b/be/src/exprs/aggregate-functions-test.cc
@@ -16,7 +16,6 @@
 #include <gtest/gtest.h>
 #include <boost/algorithm/string.hpp>
 #include <boost/lexical_cast.hpp>
-#include <boost/foreach.hpp>
 #include <boost/accumulators/accumulators.hpp>
 #include <boost/accumulators/statistics/stats.hpp>
 #include <boost/accumulators/statistics/variance.hpp>
@@ -53,7 +52,7 @@ bool CheckHistogramDistribution(const StringVal& actual,
 
   accumulator_set<int, stats<tag::variance> > acc;
   int prev_val = -1;
-  BOOST_FOREACH(string& s, str_vals) {
+  for (string& s: str_vals) {
     trim(s);
     int val = lexical_cast<int>(s);
     if (prev_val != -1) acc(val - prev_val);

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exprs/expr-codegen-test.cc
----------------------------------------------------------------------
diff --git a/be/src/exprs/expr-codegen-test.cc b/be/src/exprs/expr-codegen-test.cc
index 7be6824..ec81b30 100644
--- a/be/src/exprs/expr-codegen-test.cc
+++ b/be/src/exprs/expr-codegen-test.cc
@@ -194,7 +194,7 @@ TExprNode CreateFunctionCall(vector<TExprNode> children) {
   TFunction fn;
   fn.name = fn_name;
   fn.binary_type = TFunctionBinaryType::IR;
-  BOOST_FOREACH(const TExprNode& child, children) {
+  for (const TExprNode& child: children) {
     fn.arg_types.push_back(child.type);
   }
   fn.ret_type = col_type;

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exprs/expr-test.cc
----------------------------------------------------------------------
diff --git a/be/src/exprs/expr-test.cc b/be/src/exprs/expr-test.cc
index 0e29006..82b0487 100644
--- a/be/src/exprs/expr-test.cc
+++ b/be/src/exprs/expr-test.cc
@@ -1707,7 +1707,7 @@ TEST_F(ExprTest, InPredicate) {
   dec_strs.push_back("cast(-1.23 as decimal(18,2))");
   dec_strs.push_back("cast(-1.23 as decimal(19,2))");
   dec_strs.push_back("cast(-1.23 as decimal(32,2))");
-  BOOST_FOREACH(const string& dec_str, dec_strs) {
+  for (const string& dec_str: dec_strs) {
     TestValue(dec_str + "in (0)", TYPE_BOOLEAN, false);
     TestValue(dec_str + "in (-1.23)", TYPE_BOOLEAN, true);
     TestValue(dec_str + "in (-1.230)", TYPE_BOOLEAN, true);
@@ -3035,7 +3035,7 @@ TEST_F(ExprTest, MathFunctions) {
   // Test all int types.
   string val_list;
   val_list = "0";
-  BOOST_FOREACH(IntValMap::value_type& entry, min_int_values_) {
+  for (IntValMap::value_type& entry: min_int_values_) {
     string val_str = lexical_cast<string>(entry.second);
     val_list.append(", " + val_str);
     PrimitiveType t = static_cast<PrimitiveType>(entry.first);
@@ -3091,7 +3091,7 @@ TEST_F(ExprTest, MathFunctions) {
   // Test all int types. A list of values will be built, each iteration adds a bigger
   // value. This requires min_int_values_ to be an ordered map.
   val_list = "0";
-  BOOST_FOREACH(IntValMap::value_type& entry, min_int_values_) {
+  for (IntValMap::value_type& entry: min_int_values_) {
     string val_str = lexical_cast<string>(entry.second);
     val_list.append(", " + val_str);
     PrimitiveType t = static_cast<PrimitiveType>(entry.first);
@@ -4759,7 +4759,7 @@ TEST_F(ExprTest, ResultsLayoutTest) {
   types.push_back(ColumnType::CreateVarcharType(255));
 
   expected_offsets.clear();
-  BOOST_FOREACH(const ColumnType& t, types) {
+  for (const ColumnType& t: types) {
     exprs.clear();
     expected_offsets.clear();
     // With one expr, all offsets should be 0.

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/exprs/in-predicate-benchmark.cc
----------------------------------------------------------------------
diff --git a/be/src/exprs/in-predicate-benchmark.cc b/be/src/exprs/in-predicate-benchmark.cc
index 01a0da1..f337e1e 100644
--- a/be/src/exprs/in-predicate-benchmark.cc
+++ b/be/src/exprs/in-predicate-benchmark.cc
@@ -219,7 +219,7 @@ class InPredicateBenchmark {
 
     vector<AnyVal*> constant_args;
     constant_args.push_back(NULL);
-    BOOST_FOREACH(AnyVal* p, data.anyval_ptrs) constant_args.push_back(p);
+    for (AnyVal* p: data.anyval_ptrs) constant_args.push_back(p);
     UdfTestHarness::SetConstantArgs(ctx, constant_args);
 
     InPredicate::SetLookupPrepare<T, SetType>(ctx, FunctionContext::FRAGMENT_LOCAL);
@@ -234,7 +234,7 @@ class InPredicateBenchmark {
   static void TestSetLookup(int batch_size, void* d) {
     TestData<T, SetType>* data = reinterpret_cast<TestData<T, SetType>*>(d);
     for (int i = 0; i < batch_size; ++i) {
-      BOOST_FOREACH(const T& search_val, data->search_vals) {
+      for (const T& search_val: data->search_vals) {
         BooleanVal found = InPredicate::SetLookup(&data->state, search_val);
         if (found.val) ++data->total_found_set;
         ++data->total_set;
@@ -246,7 +246,7 @@ class InPredicateBenchmark {
   static void TestIterate(int batch_size, void* d) {
     TestData<T, SetType>* data = reinterpret_cast<TestData<T, SetType>*>(d);
     for (int i = 0; i < batch_size; ++i) {
-      BOOST_FOREACH(const T& search_val, data->search_vals) {
+      for (const T& search_val: data->search_vals) {
         BooleanVal found = InPredicate::Iterate(
             data->state.type, search_val, data->anyvals.size(), &data->anyvals[0]);
         if (found.val) ++data->total_found_iter;

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/resourcebroker/resource-broker.cc
----------------------------------------------------------------------
diff --git a/be/src/resourcebroker/resource-broker.cc b/be/src/resourcebroker/resource-broker.cc
index dfc755b..e4a933a 100644
--- a/be/src/resourcebroker/resource-broker.cc
+++ b/be/src/resourcebroker/resource-broker.cc
@@ -15,7 +15,6 @@
 #include "resourcebroker/resource-broker.h"
 
 #include <boost/algorithm/string/join.hpp>
-#include <boost/foreach.hpp>
 #include <boost/uuid/uuid.hpp>
 #include <boost/uuid/uuid_generators.hpp>
 #include <boost/uuid/uuid_io.hpp>
@@ -266,7 +265,7 @@ bool ResourceBroker::LlamaHasRestarted(const llama::TStatus& status) const {
 
 void ResourceBroker::Close() {
   // Close connections to all Llama addresses, not just the active one.
-  BOOST_FOREACH(const TNetworkAddress& llama_address, llama_addresses_) {
+  for (const TNetworkAddress& llama_address: llama_addresses_) {
     llama_client_cache_->CloseConnections(llama_address);
   }
   llama_callback_server_->Join();
@@ -353,7 +352,7 @@ Status ResourceBroker::ReRegisterWithLlama(const llama::TLlamaAMGetNodesRequest&
 
 void ResourceBroker::PendingRequest::GetResources(ResourceMap* resources) {
   resources->clear();
-  BOOST_FOREACH(const llama::TAllocatedResource& resource, allocated_resources_) {
+  for (const llama::TAllocatedResource& resource: allocated_resources_) {
     TNetworkAddress host = MakeNetworkAddress(resource.location);
     (*resources)[host] = resource;
     VLOG_QUERY << "Getting allocated resource for reservation id "
@@ -365,7 +364,7 @@ void ResourceBroker::PendingRequest::SetResources(
     const vector<llama::TAllocatedResource>& resources) {
   // TODO: Llama returns a dump of all resources that we need to manually group by
   // reservation id. Can Llama do the grouping for us?
-  BOOST_FOREACH(const llama::TAllocatedResource& resource, resources) {
+  for (const llama::TAllocatedResource& resource: resources) {
     // Ignore resources that don't belong to the given reservation id.
     if (resource.reservation_id == request_id()) {
       allocated_resources_.push_back(resource);
@@ -405,7 +404,7 @@ bool ResourceBroker::WaitForNotification(int64_t timeout, ResourceMap* resources
     pending_request->GetResources(resources);
     int64_t total_memory_mb = 0L;
     int32_t total_vcpus = 0;
-    BOOST_FOREACH(const ResourceMap::value_type& resource, *resources) {
+    for (const ResourceMap::value_type& resource: *resources) {
       total_memory_mb += resource.second.memory_mb;
       total_vcpus += resource.second.v_cpu_cores;
     }
@@ -601,7 +600,7 @@ void ResourceBroker::ClearRequests(const TUniqueId& reservation_id) {
     lock_guard<mutex> l(pending_requests_lock_);
     PendingExpansionIdsMap::iterator it = pending_expansion_ids_.find(llama_id);
     if (it != pending_expansion_ids_.end()) {
-      BOOST_FOREACH(const llama::TUniqueId& id, it->second) {
+      for (const llama::TUniqueId& id: it->second) {
         PendingRequestMap::iterator request_it = pending_requests_.find(id);
         DCHECK(request_it != pending_requests_.end());
         if (request_it == pending_requests_.end()) continue;
@@ -621,7 +620,7 @@ void ResourceBroker::ClearRequests(const TUniqueId& reservation_id) {
     lock_guard<mutex> l(allocated_requests_lock_);
     AllocatedRequestMap::iterator it = allocated_requests_.find(llama_id);
     if (it == allocated_requests_.end()) return;
-    BOOST_FOREACH(AllocatedRequest& allocated_req, it->second) {
+    for (AllocatedRequest& allocated_req: it->second) {
       DCHECK(allocated_req.reservation_id() == llama_id);
       total_memory_bytes += (allocated_req.memory_mb() * 1024L * 1024L);
       total_vcpus += allocated_req.vcpus();
@@ -681,7 +680,7 @@ void ResourceBroker::AMNotification(const llama::TLlamaAMNotificationRequest& re
   lock_guard<mutex> l(pending_requests_lock_);
 
   // Process granted allocations.
-  BOOST_FOREACH(const llama::TUniqueId& res_id, request.allocated_reservation_ids) {
+  for (const llama::TUniqueId& res_id: request.allocated_reservation_ids) {
     PendingRequestMap::iterator it = pending_requests_.find(res_id);
     if (it == pending_requests_.end()) {
       VLOG_RPC << "Allocation for " << res_id << " arrived after timeout or cleanup";
@@ -698,7 +697,7 @@ void ResourceBroker::AMNotification(const llama::TLlamaAMNotificationRequest& re
   }
 
   // Process rejected allocations.
-  BOOST_FOREACH(const llama::TUniqueId& res_id, request.rejected_reservation_ids) {
+  for (const llama::TUniqueId& res_id: request.rejected_reservation_ids) {
     PendingRequestMap::iterator it = pending_requests_.find(res_id);
     if (it == pending_requests_.end()) {
       VLOG_RPC << "Rejection for " << res_id << " arrived after timeout";
@@ -714,21 +713,21 @@ void ResourceBroker::AMNotification(const llama::TLlamaAMNotificationRequest& re
   // TODO: We maybe want a thread pool for handling preemptions to avoid
   // blocking this function on query cancellations.
   // Process preempted reservations.
-  BOOST_FOREACH(const llama::TUniqueId& res_id, request.preempted_reservation_ids) {
+  for (const llama::TUniqueId& res_id: request.preempted_reservation_ids) {
     TUniqueId impala_res_id;
     impala_res_id << res_id;
     scheduler_->HandlePreemptedReservation(impala_res_id);
   }
 
   // Process preempted client resources.
-  BOOST_FOREACH(const llama::TUniqueId& res_id, request.preempted_client_resource_ids) {
+  for (const llama::TUniqueId& res_id: request.preempted_client_resource_ids) {
     TUniqueId impala_res_id;
     impala_res_id << res_id;
     scheduler_->HandlePreemptedResource(impala_res_id);
   }
 
   // Process lost client resources.
-  BOOST_FOREACH(const llama::TUniqueId& res_id, request.lost_client_resource_ids) {
+  for (const llama::TUniqueId& res_id: request.lost_client_resource_ids) {
     TUniqueId impala_res_id;
     impala_res_id << res_id;
     scheduler_->HandlePreemptedResource(impala_res_id);
@@ -801,7 +800,7 @@ ostream& operator<<(ostream& os,
     const map<TNetworkAddress, llama::TAllocatedResource>& resources) {
   typedef map<TNetworkAddress, llama::TAllocatedResource> ResourceMap;
   int count = 0;
-  BOOST_FOREACH(const ResourceMap::value_type& resource, resources) {
+  for (const ResourceMap::value_type& resource: resources) {
     os << "(" << resource.first << "," << resource.second << ")";
     if (++count != resources.size()) os << ",";
   }

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/rpc/rpc-trace.cc
----------------------------------------------------------------------
diff --git a/be/src/rpc/rpc-trace.cc b/be/src/rpc/rpc-trace.cc
index 73111f7..a018584 100644
--- a/be/src/rpc/rpc-trace.cc
+++ b/be/src/rpc/rpc-trace.cc
@@ -16,7 +16,6 @@
 
 #include <boost/bind.hpp>
 #include <boost/scoped_ptr.hpp>
-#include <boost/foreach.hpp>
 #include <gutil/strings/substitute.h>
 
 #include "common/logging.h"
@@ -90,7 +89,7 @@ void RpcEventHandlerManager::JsonCallback(const Webserver::ArgumentMap& args,
     Document* document) {
   lock_guard<mutex> l(lock_);
   Value servers(kArrayType);
-  BOOST_FOREACH(RpcEventHandler* handler, event_handlers_) {
+  for (RpcEventHandler* handler: event_handlers_) {
     Value server(kObjectType);
     handler->ToJson(&server, document);
     servers.PushBack(server, document->GetAllocator());
@@ -105,7 +104,7 @@ void RpcEventHandlerManager::ResetCallback(const Webserver::ArgumentMap& args,
   Webserver::ArgumentMap::const_iterator method_it = args.find("method");
   bool reset_all_in_server = (method_it == args.end());
   lock_guard<mutex> l(lock_);
-  BOOST_FOREACH(RpcEventHandler* handler, event_handlers_) {
+  for (RpcEventHandler* handler: event_handlers_) {
     if (reset_all_servers || handler->server_name() == server_it->second) {
       if (reset_all_in_server) {
         handler->ResetAll();
@@ -127,7 +126,7 @@ void RpcEventHandler::Reset(const string& method_name) {
 
 void RpcEventHandler::ResetAll() {
   lock_guard<mutex> l(method_map_lock_);
-  BOOST_FOREACH(const MethodMap::value_type& method, method_map_) {
+  for (const MethodMap::value_type& method: method_map_) {
     method.second->time_stats->Reset();
     method.second->num_in_flight.Store(0L);
   }
@@ -143,7 +142,7 @@ void RpcEventHandler::ToJson(Value* server, Document* document) {
   Value name(server_name_.c_str(), document->GetAllocator());
   server->AddMember("name", name, document->GetAllocator());
   Value methods(kArrayType);
-  BOOST_FOREACH(const MethodMap::value_type& rpc, method_map_) {
+  for (const MethodMap::value_type& rpc: method_map_) {
     Value method(kObjectType);
     Value method_name(rpc.first.c_str(), document->GetAllocator());
     method.AddMember("name", method_name, document->GetAllocator());

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/buffered-block-mgr-test.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/buffered-block-mgr-test.cc b/be/src/runtime/buffered-block-mgr-test.cc
index 3f7778f..04630fb 100644
--- a/be/src/runtime/buffered-block-mgr-test.cc
+++ b/be/src/runtime/buffered-block-mgr-test.cc
@@ -344,9 +344,7 @@ class BufferedBlockMgrTest : public ::testing::Test {
     AllocateBlocks(block_mgr, client, max_num_buffers, &blocks);
 
     EXPECT_EQ(block_mgr->bytes_allocated(), max_num_buffers * block_size);
-    BOOST_FOREACH(BufferedBlockMgr::Block* block, blocks) {
-      block->Unpin();
-    }
+    for (BufferedBlockMgr::Block* block: blocks) block->Unpin();
 
     // Re-pinning all blocks
     for (int i = 0; i < blocks.size(); ++i) {
@@ -359,9 +357,7 @@ class BufferedBlockMgrTest : public ::testing::Test {
     EXPECT_EQ(buffered_pin->value(), buffered_pins_expected);
 
     // Unpin all blocks
-    BOOST_FOREACH(BufferedBlockMgr::Block* block, blocks) {
-      block->Unpin();
-    }
+    for (BufferedBlockMgr::Block* block: blocks) block->Unpin();
     // Get two new blocks.
     AllocateBlocks(block_mgr, client, 2, &blocks);
     // At least two writes must be issued. The first (num_blocks - 2) must be in memory.

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/buffered-block-mgr.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/buffered-block-mgr.cc b/be/src/runtime/buffered-block-mgr.cc
index aecd8a2..b11054c 100644
--- a/be/src/runtime/buffered-block-mgr.cc
+++ b/be/src/runtime/buffered-block-mgr.cc
@@ -561,7 +561,7 @@ BufferedBlockMgr::~BufferedBlockMgr() {
   // See IMPALA-1890.
   DCHECK_EQ(non_local_outstanding_writes_, 0) << endl << DebugInternal();
   // Delete tmp files.
-  BOOST_FOREACH(TmpFileMgr::File& file, tmp_files_) {
+  for (TmpFileMgr::File& file: tmp_files_) {
     file.Remove();
   }
   tmp_files_.clear();
@@ -575,7 +575,7 @@ BufferedBlockMgr::~BufferedBlockMgr() {
   }
 
   // Free memory resources.
-  BOOST_FOREACH(BufferDescriptor* buffer, all_io_buffers_) {
+  for (BufferDescriptor* buffer: all_io_buffers_) {
     mem_tracker_->Release(buffer->len);
     delete[] buffer->buffer;
   }
@@ -1160,7 +1160,7 @@ bool BufferedBlockMgr::Validate() const {
     return false;
   }
 
-  BOOST_FOREACH(BufferDescriptor* buffer, all_io_buffers_) {
+  for (BufferDescriptor* buffer: all_io_buffers_) {
     bool is_free = free_io_buffers_.Contains(buffer);
     num_free_io_buffers += is_free;
 

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/buffered-tuple-stream.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/buffered-tuple-stream.cc b/be/src/runtime/buffered-tuple-stream.cc
index 86eedc4..eb35a69 100644
--- a/be/src/runtime/buffered-tuple-stream.cc
+++ b/be/src/runtime/buffered-tuple-stream.cc
@@ -467,7 +467,7 @@ Status BufferedTupleStream::UnpinStream(bool all) {
   DCHECK(!closed_);
   SCOPED_TIMER(unpin_timer_);
 
-  BOOST_FOREACH(BufferedBlockMgr::Block* block, blocks_) {
+  for (BufferedBlockMgr::Block* block: blocks_) {
     if (!block->is_pinned()) continue;
     if (!all && (block == write_block_ || (read_write_ && block == *read_block_))) {
       continue;

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/client-cache.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/client-cache.cc b/be/src/runtime/client-cache.cc
index e728c07..73ecc44 100644
--- a/be/src/runtime/client-cache.cc
+++ b/be/src/runtime/client-cache.cc
@@ -21,8 +21,6 @@
 #include <thrift/transport/TTransportUtils.h>
 #include <memory>
 
-#include <boost/foreach.hpp>
-
 #include "common/logging.h"
 #include "util/container-util.h"
 #include "util/network-util.h"
@@ -159,7 +157,7 @@ void ClientCacheHelper::CloseConnections(const TNetworkAddress& address) {
             << address;
     lock_guard<mutex> entry_lock(cache->lock);
     lock_guard<mutex> map_lock(client_map_lock_);
-    BOOST_FOREACH(ClientKey client_key, cache->clients) {
+    for (ClientKey client_key: cache->clients) {
       ClientMap::iterator client_map_entry = client_map_.find(client_key);
       DCHECK(client_map_entry != client_map_.end());
       client_map_entry->second->Close();
@@ -173,7 +171,7 @@ string ClientCacheHelper::DebugString() {
   out << "ClientCacheHelper(#hosts=" << per_host_caches_.size()
       << " [";
   bool first = true;
-  BOOST_FOREACH(const PerHostCacheMap::value_type& cache, per_host_caches_) {
+  for (const PerHostCacheMap::value_type& cache: per_host_caches_) {
     lock_guard<mutex> host_cache_lock(cache.second->lock);
     if (!first) out << " ";
     out << cache.first << ":" << cache.second->clients.size();
@@ -187,11 +185,11 @@ void ClientCacheHelper::TestShutdown() {
   vector<TNetworkAddress> addresses;
   {
     lock_guard<mutex> lock(cache_lock_);
-    BOOST_FOREACH(const PerHostCacheMap::value_type& cache_entry, per_host_caches_) {
+    for (const PerHostCacheMap::value_type& cache_entry: per_host_caches_) {
       addresses.push_back(cache_entry.first);
     }
   }
-  BOOST_FOREACH(const TNetworkAddress& address, addresses) {
+  for (const TNetworkAddress& address: addresses) {
     CloseConnections(address);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/coordinator.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/coordinator.cc b/be/src/runtime/coordinator.cc
index 451c5e9..6753c2b 100644
--- a/be/src/runtime/coordinator.cc
+++ b/be/src/runtime/coordinator.cc
@@ -28,7 +28,6 @@
 #include <boost/accumulators/statistics/variance.hpp>
 #include <boost/bind.hpp>
 #include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/unordered_set.hpp>
 #include <boost/algorithm/string/split.hpp>
@@ -259,8 +258,8 @@ void Coordinator::FragmentInstanceState::ComputeTotalSplitSize(
     const PerNodeScanRanges& per_node_scan_ranges) {
   total_split_size_ = 0;
 
-  BOOST_FOREACH(const PerNodeScanRanges::value_type& entry, per_node_scan_ranges) {
-    BOOST_FOREACH(const TScanRangeParams& scan_range_params, entry.second) {
+  for (const PerNodeScanRanges::value_type& entry: per_node_scan_ranges) {
+    for (const TScanRangeParams& scan_range_params: entry.second) {
       if (!scan_range_params.scan_range.__isset.hdfs_file_split) continue;
       total_split_size_ += scan_range_params.scan_range.hdfs_file_split.length;
     }
@@ -485,7 +484,7 @@ void Coordinator::UpdateFilterRoutingTable(const vector<TPlanNode>& plan_nodes,
       << "UpdateFilterRoutingTable() called after setting filter_routing_table_complete_";
   for (const TPlanNode& plan_node: plan_nodes) {
     if (!plan_node.__isset.runtime_filters) continue;
-    BOOST_FOREACH(const TRuntimeFilterDesc& filter, plan_node.runtime_filters) {
+    for (const TRuntimeFilterDesc& filter: plan_node.runtime_filters) {
       if (filter_mode_ == TRuntimeFilterMode::LOCAL && !filter.has_local_target) {
         continue;
       }
@@ -585,7 +584,7 @@ Status Coordinator::StartRemoteFragments(QuerySchedule* schedule) {
   const TMetricDef& def =
       MakeTMetricDef("fragment-latencies", TMetricKind::HISTOGRAM, TUnit::TIME_MS);
   HistogramMetric latencies(def, 20000, 3);
-  BOOST_FOREACH(FragmentInstanceState* exec_state, fragment_instance_states_) {
+  for (FragmentInstanceState* exec_state: fragment_instance_states_) {
     lock_guard<mutex> l(*exec_state->lock());
     // Preserve the first non-OK status, if there is one
     if (status.ok()) status = *exec_state->status();
@@ -618,7 +617,7 @@ string Coordinator::FilterDebugString() {
     table_printer.AddColumn("Completed", false);
   }
   lock_guard<SpinLock> l(filter_lock_);
-  BOOST_FOREACH(const FilterRoutingTable::value_type& v, filter_routing_table_) {
+  for (const FilterRoutingTable::value_type& v: filter_routing_table_) {
     vector<string> row;
     const FilterState& state = v.second;
     row.push_back(lexical_cast<string>(v.first));
@@ -719,7 +718,7 @@ void Coordinator::PopulatePathPermissionCache(hdfsFS fs, const string& path_str,
   vector<string> prefixes;
   // Stores the current prefix
   stringstream accumulator;
-  BOOST_FOREACH(const string& component, components) {
+  for (const string& component: components) {
     if (component.empty()) continue;
     accumulator << "/" << component;
     prefixes.push_back(accumulator.str());
@@ -737,7 +736,7 @@ void Coordinator::PopulatePathPermissionCache(hdfsFS fs, const string& path_str,
   // Set to the permission of the immediate parent (i.e. the permissions to inherit if the
   // current dir doesn't exist).
   short permissions = 0;
-  BOOST_FOREACH(const string& path, prefixes) {
+  for (const string& path: prefixes) {
     PermissionCache::const_iterator it = permissions_cache->find(path);
     if (it == permissions_cache->end()) {
       hdfsFileInfo* info = hdfsGetPathInfo(fs, path.c_str());
@@ -775,7 +774,7 @@ Status Coordinator::FinalizeSuccessfulInsert() {
 
   // Loop over all partitions that were updated by this insert, and create the set of
   // filesystem operations required to create the correct partition structure on disk.
-  BOOST_FOREACH(const PartitionStatusMap::value_type& partition, per_partition_status_) {
+  for (const PartitionStatusMap::value_type& partition: per_partition_status_) {
     SCOPED_TIMER(ADD_CHILD_TIMER(query_profile_, "Overwrite/PartitionCreationTimer",
           "FinalizationTimer"));
     // INSERT allows writes to tables that have partitions on multiple filesystems.
@@ -877,7 +876,7 @@ Status Coordinator::FinalizeSuccessfulInsert() {
     SCOPED_TIMER(ADD_CHILD_TIMER(query_profile_, "Overwrite/PartitionCreationTimer",
           "FinalizationTimer"));
     if (!partition_create_ops.Execute(exec_env_->hdfs_op_thread_pool(), false)) {
-      BOOST_FOREACH(const HdfsOperationSet::Error& err, partition_create_ops.errors()) {
+      for (const HdfsOperationSet::Error& err: partition_create_ops.errors()) {
         // It's ok to ignore errors creating the directories, since they may already
         // exist. If there are permission errors, we'll run into them later.
         if (err.first->op() != CREATE_DIR) {
@@ -893,7 +892,7 @@ Status Coordinator::FinalizeSuccessfulInsert() {
   HdfsOperationSet move_ops(&filesystem_connection_cache);
   HdfsOperationSet dir_deletion_ops(&filesystem_connection_cache);
 
-  BOOST_FOREACH(FileMoveMap::value_type& move, files_to_move_) {
+  for (FileMoveMap::value_type& move: files_to_move_) {
     // Empty destination means delete, so this is a directory. These get deleted in a
     // separate pass to ensure that we have moved all the contents of the directory first.
     if (move.second.empty()) {
@@ -936,7 +935,7 @@ Status Coordinator::FinalizeSuccessfulInsert() {
   // Do this last so that we don't make a dir unwritable before we write to it.
   if (FLAGS_insert_inherit_permissions) {
     HdfsOperationSet chmod_ops(&filesystem_connection_cache);
-    BOOST_FOREACH(const PermissionCache::value_type& perm, permissions_cache) {
+    for (const PermissionCache::value_type& perm: permissions_cache) {
       bool new_dir = perm.second.first;
       if (new_dir) {
         short permissions = perm.second.second;
@@ -1274,10 +1273,10 @@ void Coordinator::CollectScanNodeCounters(RuntimeProfile* profile,
 
 void Coordinator::CreateAggregateCounters(
     const vector<TPlanFragment>& fragments) {
-  BOOST_FOREACH(const TPlanFragment& fragment, fragments) {
+  for (const TPlanFragment& fragment: fragments) {
     if (!fragment.__isset.plan) continue;
     const vector<TPlanNode>& nodes = fragment.plan.nodes;
-    BOOST_FOREACH(const TPlanNode& node, nodes) {
+    for (const TPlanNode& node: nodes) {
       if (node.node_type != TPlanNodeType::HDFS_SCAN_NODE
           && node.node_type != TPlanNodeType::HBASE_SCAN_NODE) {
         continue;
@@ -1539,8 +1538,8 @@ Status Coordinator::UpdateFragmentExecStatus(const TReportExecStatusParams& para
     lock_guard<mutex> l(lock_);
     // Merge in table update data (partitions written to, files to be moved as part of
     // finalization)
-    BOOST_FOREACH(const PartitionStatusMap::value_type& partition,
-        params.insert_exec_status.per_partition_status) {
+    for (const PartitionStatusMap::value_type& partition:
+         params.insert_exec_status.per_partition_status) {
       TInsertPartitionStatus* status = &(per_partition_status_[partition.first]);
       status->num_appended_rows += partition.second.num_appended_rows;
       status->id = partition.second.id;
@@ -1626,7 +1625,7 @@ bool Coordinator::PrepareCatalogUpdate(TUpdateCatalogRequest* catalog_update) {
   // Assume we are called only after all fragments have completed
   DCHECK(has_called_wait_);
 
-  BOOST_FOREACH(const PartitionStatusMap::value_type& partition, per_partition_status_) {
+  for (const PartitionStatusMap::value_type& partition: per_partition_status_) {
     catalog_update->created_partitions.insert(partition.first);
   }
 
@@ -1799,7 +1798,7 @@ void Coordinator::ReportQuerySummary() {
       }
     }
     stringstream info;
-    BOOST_FOREACH(PerNodePeakMemoryUsage::value_type entry, per_node_peak_mem_usage) {
+    for (PerNodePeakMemoryUsage::value_type entry: per_node_peak_mem_usage) {
       info << entry.first << "("
            << PrettyPrinter::Print(entry.second, TUnit::BYTES) << ") ";
     }
@@ -1906,7 +1905,7 @@ void Coordinator::SetExecPlanDescriptorTable(const TPlanFragment& fragment,
 
   // Collect the TTupleId(s) for ScanNode(s).
   unordered_set<TTupleId> tuple_ids;
-  BOOST_FOREACH(const TPlanNode& plan_node, fragment.plan.nodes) {
+  for (const TPlanNode& plan_node: fragment.plan.nodes) {
     switch (plan_node.node_type) {
       case TPlanNodeType::HDFS_SCAN_NODE:
         tuple_ids.insert(plan_node.hdfs_scan_node.tuple_id);
@@ -1941,8 +1940,8 @@ void Coordinator::SetExecPlanDescriptorTable(const TPlanFragment& fragment,
 
   // Collect TTableId(s) matching the TTupleId(s).
   unordered_set<TTableId> table_ids;
-  BOOST_FOREACH(const TTupleId& tuple_id, tuple_ids) {
-    BOOST_FOREACH(const TTupleDescriptor& tuple_desc, desc_tbl_.tupleDescriptors) {
+  for (const TTupleId& tuple_id: tuple_ids) {
+    for (const TTupleDescriptor& tuple_desc: desc_tbl_.tupleDescriptors) {
       if (tuple_desc.__isset.tableId &&  tuple_id == tuple_desc.id) {
         table_ids.insert(tuple_desc.tableId);
       }
@@ -1956,7 +1955,7 @@ void Coordinator::SetExecPlanDescriptorTable(const TPlanFragment& fragment,
   }
 
   // Iterate over all TTableDescriptor(s) and add the ones that are needed.
-  BOOST_FOREACH(const TTableDescriptor& table_desc, desc_tbl_.tableDescriptors) {
+  for (const TTableDescriptor& table_desc: desc_tbl_.tableDescriptors) {
     if (table_ids.find(table_desc.id) == table_ids.end()) continue;
     thrift_desc_tbl.tableDescriptors.push_back(table_desc);
     thrift_desc_tbl.__isset.tableDescriptors = true;

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/data-stream-recvr.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/data-stream-recvr.cc b/be/src/runtime/data-stream-recvr.cc
index 34fd156..516aef6 100644
--- a/be/src/runtime/data-stream-recvr.cc
+++ b/be/src/runtime/data-stream-recvr.cc
@@ -272,7 +272,7 @@ Status DataStreamRecvr::CreateMerger(const TupleRowComparator& less_than) {
 }
 
 void DataStreamRecvr::TransferAllResources(RowBatch* transfer_batch) {
-  BOOST_FOREACH(SenderQueue* sender_queue, sender_queues_) {
+  for (SenderQueue* sender_queue: sender_queues_) {
     if (sender_queue->current_batch() != NULL) {
       sender_queue->current_batch()->TransferResourceOwnership(transfer_batch);
     }

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/descriptors.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/descriptors.cc b/be/src/runtime/descriptors.cc
index be6f83e..dd45a3e 100644
--- a/be/src/runtime/descriptors.cc
+++ b/be/src/runtime/descriptors.cc
@@ -152,7 +152,7 @@ string TableDescriptor::fully_qualified_name() const {
 
 string TableDescriptor::DebugString() const {
   vector<string> cols;
-  BOOST_FOREACH(const ColumnDescriptor& col_desc, col_descs_) {
+  for (const ColumnDescriptor& col_desc: col_descs_) {
     cols.push_back(col_desc.DebugString());
   }
   stringstream out;

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/disk-io-mgr-reader-context.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/disk-io-mgr-reader-context.cc b/be/src/runtime/disk-io-mgr-reader-context.cc
index a9c929f..f1e71b2 100644
--- a/be/src/runtime/disk-io-mgr-reader-context.cc
+++ b/be/src/runtime/disk-io-mgr-reader-context.cc
@@ -79,7 +79,7 @@ void DiskIoMgr::RequestContext::Cancel(const Status& status) {
     }
   }
 
-  BOOST_FOREACH(const WriteRange::WriteDoneCallback& write_callback, write_callbacks) {
+  for (const WriteRange::WriteDoneCallback& write_callback: write_callbacks) {
     write_callback(status_);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/disk-io-mgr.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/disk-io-mgr.cc b/be/src/runtime/disk-io-mgr.cc
index 68745d9..66f0498 100644
--- a/be/src/runtime/disk-io-mgr.cc
+++ b/be/src/runtime/disk-io-mgr.cc
@@ -193,7 +193,7 @@ string DiskIoMgr::DebugString() {
     ss << "  " << (void*) disk_queues_[i] << ":" ;
     if (!disk_queues_[i]->request_contexts.empty()) {
       ss << " Readers: ";
-      BOOST_FOREACH(RequestContext* req_context, disk_queues_[i]->request_contexts) {
+      for (RequestContext* req_context: disk_queues_[i]->request_contexts) {
         ss << (void*)req_context;
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/lib-cache.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/lib-cache.cc b/be/src/runtime/lib-cache.cc
index 862d376..5c1e423 100644
--- a/be/src/runtime/lib-cache.cc
+++ b/be/src/runtime/lib-cache.cc
@@ -15,7 +15,6 @@
 #include "runtime/lib-cache.h"
 
 #include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
 #include <boost/thread/locks.hpp>
 
 #include "codegen/llvm-codegen.h"
@@ -261,7 +260,7 @@ void LibCache::RemoveEntryInternal(const string& hdfs_lib_file,
 
 void LibCache::DropCache() {
   unique_lock<mutex> lib_cache_lock(lock_);
-  BOOST_FOREACH(LibMap::value_type& v, lib_cache_) {
+  for (LibMap::value_type& v: lib_cache_) {
     bool can_delete = false;
     {
       // Lock to wait for any threads currently processing the entry.

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/mem-tracker.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/mem-tracker.cc b/be/src/runtime/mem-tracker.cc
index d9408ca..66b0a8d 100644
--- a/be/src/runtime/mem-tracker.cc
+++ b/be/src/runtime/mem-tracker.cc
@@ -356,7 +356,7 @@ bool MemTracker::ExpandRmReservation(int64_t bytes) {
     return false;
   }
 
-  BOOST_FOREACH(const MemTracker* tracker, limit_trackers_) {
+  for (const MemTracker* tracker: limit_trackers_) {
     if (tracker == this) continue;
     if (tracker->consumption_->current_value() + bytes_allocated > tracker->limit_) {
       // TODO: Allocation may be larger than needed and might exceed some parent

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/plan-fragment-executor.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/plan-fragment-executor.cc b/be/src/runtime/plan-fragment-executor.cc
index 00fcb11..820369e 100644
--- a/be/src/runtime/plan-fragment-executor.cc
+++ b/be/src/runtime/plan-fragment-executor.cc
@@ -17,7 +17,6 @@
 #include <thrift/protocol/TDebugProtocol.h>
 #include <boost/date_time/posix_time/posix_time_types.hpp>
 #include <boost/unordered_map.hpp>
-#include <boost/foreach.hpp>
 #include <gutil/strings/substitute.h>
 
 #include "codegen/llvm-codegen.h"
@@ -219,7 +218,7 @@ Status PlanFragmentExecutor::Prepare(const TExecPlanFragmentParams& request) {
   // set #senders of exchange nodes before calling Prepare()
   vector<ExecNode*> exch_nodes;
   plan_->CollectNodes(TPlanNodeType::EXCHANGE_NODE, &exch_nodes);
-  BOOST_FOREACH(ExecNode* exch_node, exch_nodes)
+  for (ExecNode* exch_node: exch_nodes)
   {
     DCHECK_EQ(exch_node->type(), TPlanNodeType::EXCHANGE_NODE);
     int num_senders = FindWithDefault(params.per_exch_num_senders,
@@ -294,7 +293,7 @@ void PlanFragmentExecutor::PrintVolumeIds(
   if (per_node_scan_ranges.empty()) return;
 
   HdfsScanNode::PerVolumnStats per_volume_stats;
-  BOOST_FOREACH(const PerNodeScanRanges::value_type& entry, per_node_scan_ranges) {
+  for (const PerNodeScanRanges::value_type& entry: per_node_scan_ranges) {
     HdfsScanNode::UpdateHdfsSplitStats(entry.second, &per_volume_stats);
   }
 
@@ -588,8 +587,7 @@ void PlanFragmentExecutor::Close() {
           runtime_state_->fragment_instance_id(), runtime_state_->cgroup());
     }
     if (plan_ != NULL) plan_->Close(runtime_state_.get());
-    BOOST_FOREACH(DiskIoMgr::RequestContext* context,
-        *runtime_state_->reader_contexts()) {
+    for (DiskIoMgr::RequestContext* context: *runtime_state_->reader_contexts()) {
       runtime_state_->io_mgr()->UnregisterContext(context);
     }
     exec_env_->thread_mgr()->UnregisterPool(runtime_state_->resource_pool());

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/sorted-run-merger.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/sorted-run-merger.cc b/be/src/runtime/sorted-run-merger.cc
index 2f12724..d773937 100644
--- a/be/src/runtime/sorted-run-merger.cc
+++ b/be/src/runtime/sorted-run-merger.cc
@@ -128,7 +128,7 @@ SortedRunMerger::SortedRunMerger(const TupleRowComparator& compare_less_than,
 Status SortedRunMerger::Prepare(const vector<RunBatchSupplier>& input_runs) {
   DCHECK_EQ(min_heap_.size(), 0);
   min_heap_.reserve(input_runs.size());
-  BOOST_FOREACH(const RunBatchSupplier& input_run, input_runs) {
+  for (const RunBatchSupplier& input_run: input_runs) {
     BatchedRowSupplier* new_elem = pool_.Add(new BatchedRowSupplier(this, input_run));
     DCHECK(new_elem != NULL);
     bool empty;

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/sorter.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/sorter.cc b/be/src/runtime/sorter.cc
index 257ff77..7de1b25 100644
--- a/be/src/runtime/sorter.cc
+++ b/be/src/runtime/sorter.cc
@@ -486,8 +486,8 @@ Status Sorter::Run::AddBatch(RowBatch* batch, int start_index, int* num_processe
 
         // Sorting of tuples containing array values is not implemented. The planner
         // combined with projection should guarantee that none are in each tuple.
-        BOOST_FOREACH(const SlotDescriptor* collection_slot,
-            sort_tuple_desc_->collection_slots()) {
+        for (const SlotDescriptor* collection_slot:
+             sort_tuple_desc_->collection_slots()) {
           DCHECK(new_tuple->IsNull(collection_slot->null_indicator_offset()));
         }
 
@@ -522,11 +522,11 @@ Status Sorter::Run::AddBatch(RowBatch* batch, int start_index, int* num_processe
 
 void Sorter::Run::TransferResources(RowBatch* row_batch) {
   DCHECK(row_batch != NULL);
-  BOOST_FOREACH(BufferedBlockMgr::Block* block, fixed_len_blocks_) {
+  for (BufferedBlockMgr::Block* block: fixed_len_blocks_) {
     if (block != NULL) row_batch->AddBlock(block);
   }
   fixed_len_blocks_.clear();
-  BOOST_FOREACH(BufferedBlockMgr::Block* block, var_len_blocks_) {
+  for (BufferedBlockMgr::Block* block: var_len_blocks_) {
     if (block != NULL) row_batch->AddBlock(block);
   }
   var_len_blocks_.clear();
@@ -537,11 +537,11 @@ void Sorter::Run::TransferResources(RowBatch* row_batch) {
 }
 
 void Sorter::Run::DeleteAllBlocks() {
-  BOOST_FOREACH(BufferedBlockMgr::Block* block, fixed_len_blocks_) {
+  for (BufferedBlockMgr::Block* block: fixed_len_blocks_) {
     if (block != NULL) block->Delete();
   }
   fixed_len_blocks_.clear();
-  BOOST_FOREACH(BufferedBlockMgr::Block* block, var_len_blocks_) {
+  for (BufferedBlockMgr::Block* block: var_len_blocks_) {
     if (block != NULL) block->Delete();
   }
   var_len_blocks_.clear();
@@ -597,7 +597,7 @@ Status Sorter::Run::UnpinAllBlocks() {
   }
 
   // Clear var_len_blocks_ and replace with it with the contents of sorted_var_len_blocks
-  BOOST_FOREACH(BufferedBlockMgr::Block* var_block, var_len_blocks_) {
+  for (BufferedBlockMgr::Block* var_block: var_len_blocks_) {
     var_block->Delete();
   }
   var_len_blocks_.clear();
@@ -797,7 +797,7 @@ void Sorter::Run::CollectNonNullVarSlots(Tuple* src,
     vector<StringValue*>* string_values, int* total_var_len) {
   string_values->clear();
   *total_var_len = 0;
-  BOOST_FOREACH(const SlotDescriptor* string_slot, sort_tuple_desc_->string_slots()) {
+  for (const SlotDescriptor* string_slot: sort_tuple_desc_->string_slots()) {
     if (!src->IsNull(string_slot->null_indicator_offset())) {
       StringValue* string_val =
           reinterpret_cast<StringValue*>(src->GetSlot(string_slot->tuple_offset()));
@@ -832,7 +832,7 @@ Status Sorter::Run::TryAddBlock(vector<BufferedBlockMgr::Block*>* block_sequence
 
 void Sorter::Run::CopyVarLenData(const vector<StringValue*>& string_values,
     uint8_t* dest) {
-  BOOST_FOREACH(StringValue* string_val, string_values) {
+  for (StringValue* string_val: string_values) {
     memcpy(dest, string_val->ptr, string_val->len);
     string_val->ptr = reinterpret_cast<char*>(dest);
     dest += string_val->len;
@@ -844,7 +844,7 @@ void Sorter::Run::CopyVarLenDataConvertOffset(const vector<StringValue*>& string
   DCHECK_GE(block_index, 0);
   DCHECK_GE(dest - block_start, 0);
 
-  BOOST_FOREACH(StringValue* string_val, string_values) {
+  for (StringValue* string_val: string_values) {
     memcpy(dest, string_val->ptr, string_val->len);
     DCHECK_LE(dest - block_start, sorter_->block_mgr_->max_block_size());
     DCHECK_LE(dest - block_start, INT_MAX);

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/timestamp-parse-util.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/timestamp-parse-util.cc b/be/src/runtime/timestamp-parse-util.cc
index 3220a42..2ab2580 100644
--- a/be/src/runtime/timestamp-parse-util.cc
+++ b/be/src/runtime/timestamp-parse-util.cc
@@ -17,7 +17,6 @@
 #include <boost/assign/list_of.hpp>
 #include <boost/date_time/gregorian/gregorian.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/foreach.hpp>
 #include <boost/unordered_map.hpp>
 
 #include "runtime/string-value.inline.h"
@@ -363,7 +362,7 @@ int TimestampParser::Format(const DateTimeFormatContext& dt_ctx,
   if (dt_ctx.has_date_toks && d.is_special()) return -1;
   if (dt_ctx.has_time_toks && t.is_special()) return -1;
   char* str = buff;
-  BOOST_FOREACH(const DateTimeFormatToken& tok, dt_ctx.toks) {
+  for (const DateTimeFormatToken& tok: dt_ctx.toks) {
     int32_t num_val = -1;
     const char* str_val = NULL;
     int str_val_len = 0;
@@ -420,7 +419,7 @@ bool TimestampParser::ParseDateTime(const char* str, int str_len,
   // Keep track of the number of characters we need to shift token positions by.
   // Variable-length tokens will result in values > 0;
   int shift_len = 0;
-  BOOST_FOREACH(const DateTimeFormatToken& tok, dt_ctx.toks) {
+  for (const DateTimeFormatToken& tok: dt_ctx.toks) {
     const char* tok_val = str + tok.pos + shift_len;
     if (tok.type == SEPARATOR) {
       if (UNLIKELY(*tok_val != *tok.val)) return false;

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/tmp-file-mgr.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/tmp-file-mgr.cc b/be/src/runtime/tmp-file-mgr.cc
index 8afbbfb..8e9ffc1 100644
--- a/be/src/runtime/tmp-file-mgr.cc
+++ b/be/src/runtime/tmp-file-mgr.cc
@@ -13,7 +13,6 @@
 // limitations under the License.
 
 #include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/thread/locks.hpp>
 #include <boost/uuid/uuid_io.hpp>

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/5454086c/be/src/runtime/types.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/types.cc b/be/src/runtime/types.cc
index 2164beb..6bd929f 100644
--- a/be/src/runtime/types.cc
+++ b/be/src/runtime/types.cc
@@ -16,7 +16,6 @@
 
 #include <ostream>
 #include <sstream>
-#include <boost/foreach.hpp>
 
 #include "gen-cpp/TCLIService_constants.h"
 #include "codegen/llvm-codegen.h"
@@ -195,12 +194,12 @@ void ColumnType::ToThrift(TColumnType* thrift_type) const {
       DCHECK_EQ(type, TYPE_STRUCT);
       node.type = TTypeNodeType::STRUCT;
       node.__set_struct_fields(vector<TStructField>());
-      BOOST_FOREACH(const string& field_name, field_names) {
+      for (const string& field_name: field_names) {
         node.struct_fields.push_back(TStructField());
         node.struct_fields.back().name = field_name;
       }
     }
-    BOOST_FOREACH(const ColumnType& child, children) {
+    for (const ColumnType& child: children) {
       child.ToThrift(thrift_type);
     }
   } else {