You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by ji...@apache.org on 2018/02/26 19:15:42 UTC

[01/46] incubator-quickstep git commit: Prune columns after partition rule. [Forced Update!]

Repository: incubator-quickstep
Updated Branches:
  refs/heads/fix-iwyu 165bd1fe5 -> c2ed5c69b (forced update)


Prune columns after partition rule.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/71aa8d26
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/71aa8d26
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/71aa8d26

Branch: refs/heads/fix-iwyu
Commit: 71aa8d265cc2240da0ebf8275a70884002a1ea45
Parents: 475704e
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Tue Sep 19 19:17:29 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Tue Sep 19 19:17:29 2017 -0500

----------------------------------------------------------------------
 query_optimizer/PhysicalGenerator.cpp | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/71aa8d26/query_optimizer/PhysicalGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/PhysicalGenerator.cpp b/query_optimizer/PhysicalGenerator.cpp
index 6932b30..865cd11 100644
--- a/query_optimizer/PhysicalGenerator.cpp
+++ b/query_optimizer/PhysicalGenerator.cpp
@@ -173,6 +173,7 @@ P::PhysicalPtr PhysicalGenerator::optimizePlan() {
   // set output PartitionSchemeHeader in a Physical Plan node, when needed.
   if (FLAGS_use_partition_rule) {
     rules.push_back(std::make_unique<Partition>(optimizer_context_));
+    rules.push_back(std::make_unique<PruneColumns>());
   }
 
   // NOTE(jianqiao): Adding rules after InjectJoinFilters (or AttachLIPFilters)


[40/46] incubator-quickstep git commit: Fixed the bug when partition w/ pruned columns.

Posted by ji...@apache.org.
Fixed the bug when partition w/ pruned columns.


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

Branch: refs/heads/fix-iwyu
Commit: d63477247648a45b577be27db57954f9e85454c3
Parents: d886ddb
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Tue Oct 24 16:17:50 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Thu Dec 21 15:28:38 2017 -0600

----------------------------------------------------------------------
 query_optimizer/ExecutionGenerator.cpp          | 39 ++++++++++----------
 .../tests/execution_generator/Partition.test    | 25 +------------
 2 files changed, 20 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d6347724/query_optimizer/ExecutionGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp
index 5ef58a9..555118a 100644
--- a/query_optimizer/ExecutionGenerator.cpp
+++ b/query_optimizer/ExecutionGenerator.cpp
@@ -486,26 +486,8 @@ void ExecutionGenerator::createTemporaryCatalogRelation(
     const P::PhysicalPtr &physical,
     const CatalogRelation **catalog_relation_output,
     S::InsertDestination *insert_destination_proto) {
-  std::unique_ptr<CatalogRelation> catalog_relation(
-      new CatalogRelation(catalog_database_,
-                          getNewRelationName(),
-                          -1 /* id */,
-                          true /* is_temporary*/));
-  attribute_id aid = 0;
-  for (const E::NamedExpressionPtr &project_expression :
-       physical->getOutputAttributes()) {
-    // The attribute name is simply set to the attribute id to make it distinct.
-    std::unique_ptr<CatalogAttribute> catalog_attribute(
-        new CatalogAttribute(catalog_relation.get(),
-                             std::to_string(aid),
-                             project_expression->getValueType(),
-                             aid,
-                             project_expression->attribute_alias()));
-    attribute_substitution_map_[project_expression->id()] =
-        catalog_attribute.get();
-    catalog_relation->addAttribute(catalog_attribute.release());
-    ++aid;
-  }
+  auto catalog_relation =
+      make_unique<CatalogRelation>(catalog_database_, getNewRelationName(), -1 /* id */, true /* is_temporary*/);
 
   const P::PartitionSchemeHeader *partition_scheme_header = physical->getOutputPartitionSchemeHeader();
   if (partition_scheme_header) {
@@ -514,6 +496,9 @@ void ExecutionGenerator::createTemporaryCatalogRelation(
       DCHECK(!partition_equivalent_expr_ids.empty());
       const E::ExprId partition_expr_id = *partition_equivalent_expr_ids.begin();
       DCHECK(attribute_substitution_map_.find(partition_expr_id) != attribute_substitution_map_.end());
+      // Use the attribute id from the input relation.
+      // NOTE(zuyu): The following line should be before changing
+      // 'attribute_substitution_map_' with the output attributes.
       output_partition_attr_ids.push_back(attribute_substitution_map_[partition_expr_id]->getID());
     }
 
@@ -544,6 +529,20 @@ void ExecutionGenerator::createTemporaryCatalogRelation(
     insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::BLOCK_POOL);
   }
 
+  attribute_id aid = 0;
+  for (const E::NamedExpressionPtr &project_expression :
+       physical->getOutputAttributes()) {
+    // The attribute name is simply set to the attribute id to make it distinct.
+    auto catalog_attribute =
+        make_unique<CatalogAttribute>(catalog_relation.get(), std::to_string(aid),
+                                      project_expression->getValueType(), aid,
+                                      project_expression->attribute_alias());
+    attribute_substitution_map_[project_expression->id()] =
+        catalog_attribute.get();
+    catalog_relation->addAttribute(catalog_attribute.release());
+    ++aid;
+  }
+
   *catalog_relation_output = catalog_relation.get();
   const relation_id output_rel_id = catalog_database_->addRelation(
       catalog_relation.release());

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d6347724/query_optimizer/tests/execution_generator/Partition.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/execution_generator/Partition.test b/query_optimizer/tests/execution_generator/Partition.test
index da9b6b8..747b969 100644
--- a/query_optimizer/tests/execution_generator/Partition.test
+++ b/query_optimizer/tests/execution_generator/Partition.test
@@ -297,30 +297,7 @@ SELECT dim_2_hash_partitions.id as dim_id, fact.id as fact_id
 FROM dim_2_hash_partitions, fact
 WHERE dim_2_hash_partitions.id > 20 AND fact.id > 0;
 --
-+-----------+-----------+
-|dim_id     |fact_id    |
-+-----------+-----------+
-|         24|          4|
-|         24|          8|
-|         24|         12|
-|         24|         16|
-|         24|         24|
-|         22|          4|
-|         22|          8|
-|         22|         12|
-|         22|         16|
-|         22|         24|
-|         24|          2|
-|         24|          6|
-|         24|         14|
-|         24|         18|
-|         24|         22|
-|         22|          2|
-|         22|          6|
-|         22|         14|
-|         22|         18|
-|         22|         22|
-+-----------+-----------+
+[same as above]
 ==
 
 SELECT id, int_col


[21/46] incubator-quickstep git commit: Support Multiple Tuple Inserts

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fe838df/parser/preprocessed/SqlParser_gen.cpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlParser_gen.cpp b/parser/preprocessed/SqlParser_gen.cpp
index 72c61dd..9b77875 100644
--- a/parser/preprocessed/SqlParser_gen.cpp
+++ b/parser/preprocessed/SqlParser_gen.cpp
@@ -341,6 +341,7 @@ union YYSTYPE
   quickstep::NumericParseLiteralValue *numeric_literal_value_;
   quickstep::ParseLiteralValue *literal_value_;
   quickstep::PtrList<quickstep::ParseScalarLiteral> *literal_value_list_;
+  quickstep::PtrList<quickstep::PtrList<quickstep::ParseScalarLiteral>> *literal_value_list_multiple_;
 
   quickstep::ParseExpression *expression_;
 
@@ -431,7 +432,7 @@ union YYSTYPE
 
   quickstep::ParsePriority *opt_priority_clause_;
 
-#line 435 "SqlParser_gen.cpp" /* yacc.c:355  */
+#line 436 "SqlParser_gen.cpp" /* yacc.c:355  */
 };
 
 typedef union YYSTYPE YYSTYPE;
@@ -460,13 +461,13 @@ int quickstep_yyparse (yyscan_t yyscanner, quickstep::ParseStatement **parsedSta
 #endif /* !YY_QUICKSTEP_YY_SQLPARSER_GEN_HPP_INCLUDED  */
 
 /* Copy the second part of user declarations.  */
-#line 222 "../SqlParser.ypp" /* yacc.c:358  */
+#line 223 "../SqlParser.ypp" /* yacc.c:358  */
 
 /* This header needs YYSTYPE, which is defined by the %union directive above */
 #include "SqlLexer_gen.hpp"
 void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string &feature);
 
-#line 470 "SqlParser_gen.cpp" /* yacc.c:358  */
+#line 471 "SqlParser_gen.cpp" /* yacc.c:358  */
 
 #ifdef short
 # undef short
@@ -710,16 +711,16 @@ union yyalloc
 /* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  50
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   1391
+#define YYLAST   1327
 
 /* YYNTOKENS -- Number of terminals.  */
 #define YYNTOKENS  148
 /* YYNNTS -- Number of nonterminals.  */
-#define YYNNTS  110
+#define YYNNTS  111
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  298
+#define YYNRULES  300
 /* YYNSTATES -- Number of states.  */
-#define YYNSTATES  550
+#define YYNSTATES  555
 
 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
    by yylex, with out-of-bounds checking.  */
@@ -779,36 +780,37 @@ static const yytype_uint8 yytranslate[] =
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   640,   640,   644,   648,   652,   656,   659,   666,   669,
-     672,   675,   678,   681,   684,   687,   690,   693,   699,   705,
-     712,   718,   725,   734,   739,   748,   753,   758,   762,   768,
-     773,   776,   779,   784,   787,   790,   793,   796,   799,   802,
-     805,   808,   811,   823,   826,   829,   847,   867,   870,   873,
-     878,   883,   889,   895,   904,   908,   914,   917,   922,   927,
-     932,   939,   946,   950,   956,   959,   964,   967,   972,   975,
-     980,   983,  1002,  1005,  1010,  1014,  1020,  1023,  1026,  1029,
-    1034,  1037,  1040,  1047,  1052,  1063,  1068,  1073,  1077,  1081,
-    1087,  1090,  1096,  1104,  1107,  1110,  1116,  1121,  1126,  1130,
-    1136,  1140,  1143,  1148,  1151,  1156,  1161,  1166,  1170,  1176,
-    1185,  1188,  1193,  1196,  1215,  1220,  1224,  1230,  1236,  1245,
-    1250,  1258,  1264,  1270,  1273,  1276,  1281,  1284,  1289,  1293,
-    1299,  1302,  1305,  1310,  1315,  1320,  1323,  1326,  1331,  1334,
-    1337,  1340,  1343,  1346,  1349,  1352,  1357,  1360,  1365,  1369,
-    1373,  1376,  1380,  1383,  1388,  1391,  1396,  1399,  1404,  1408,
-    1414,  1417,  1422,  1425,  1430,  1433,  1438,  1441,  1460,  1463,
-    1468,  1472,  1478,  1484,  1489,  1492,  1497,  1500,  1505,  1508,
-    1513,  1516,  1521,  1522,  1525,  1530,  1531,  1534,  1539,  1543,
-    1549,  1556,  1559,  1562,  1567,  1570,  1573,  1579,  1582,  1587,
-    1592,  1601,  1606,  1615,  1620,  1623,  1628,  1631,  1636,  1642,
-    1648,  1651,  1654,  1657,  1660,  1663,  1669,  1678,  1681,  1686,
-    1689,  1694,  1697,  1702,  1705,  1708,  1711,  1715,  1719,  1722,
-    1725,  1728,  1731,  1736,  1740,  1744,  1747,  1752,  1757,  1761,
-    1767,  1770,  1775,  1779,  1785,  1790,  1794,  1800,  1805,  1808,
-    1813,  1817,  1823,  1826,  1829,  1832,  1844,  1848,  1867,  1880,
-    1895,  1898,  1901,  1904,  1907,  1910,  1915,  1919,  1925,  1928,
-    1933,  1937,  1944,  1947,  1950,  1953,  1956,  1959,  1962,  1965,
-    1968,  1971,  1976,  1987,  1990,  1995,  1998,  2001,  2007,  2011,
-    2017,  2020,  2028,  2031,  2034,  2037,  2043,  2048,  2053
+       0,   644,   644,   648,   652,   656,   660,   663,   670,   673,
+     676,   679,   682,   685,   688,   691,   694,   697,   703,   709,
+     716,   722,   729,   738,   743,   752,   757,   762,   766,   772,
+     777,   780,   783,   788,   791,   794,   797,   800,   803,   806,
+     809,   812,   815,   827,   830,   833,   851,   871,   874,   877,
+     882,   887,   893,   899,   908,   912,   918,   921,   926,   931,
+     936,   943,   950,   954,   960,   963,   968,   971,   976,   979,
+     984,   987,  1006,  1009,  1014,  1018,  1024,  1027,  1030,  1033,
+    1038,  1041,  1044,  1051,  1056,  1067,  1072,  1077,  1081,  1085,
+    1091,  1094,  1100,  1108,  1111,  1114,  1120,  1125,  1130,  1134,
+    1140,  1144,  1147,  1152,  1155,  1160,  1165,  1170,  1174,  1180,
+    1189,  1192,  1197,  1200,  1219,  1224,  1228,  1234,  1240,  1249,
+    1254,  1262,  1268,  1274,  1277,  1280,  1285,  1288,  1293,  1297,
+    1303,  1306,  1309,  1314,  1319,  1324,  1327,  1330,  1335,  1338,
+    1341,  1344,  1347,  1350,  1353,  1356,  1361,  1364,  1369,  1373,
+    1377,  1380,  1384,  1387,  1392,  1395,  1400,  1403,  1408,  1412,
+    1418,  1421,  1426,  1429,  1434,  1437,  1442,  1445,  1464,  1467,
+    1472,  1476,  1482,  1488,  1493,  1496,  1501,  1504,  1509,  1512,
+    1517,  1520,  1525,  1526,  1529,  1534,  1535,  1538,  1543,  1547,
+    1553,  1560,  1563,  1566,  1571,  1574,  1577,  1583,  1586,  1591,
+    1596,  1605,  1610,  1619,  1624,  1627,  1632,  1635,  1640,  1646,
+    1652,  1655,  1658,  1661,  1664,  1667,  1673,  1682,  1685,  1690,
+    1693,  1698,  1701,  1706,  1709,  1712,  1715,  1719,  1723,  1726,
+    1729,  1732,  1735,  1740,  1744,  1748,  1751,  1756,  1761,  1765,
+    1771,  1774,  1779,  1783,  1789,  1794,  1798,  1804,  1809,  1812,
+    1817,  1821,  1827,  1830,  1833,  1836,  1848,  1852,  1871,  1884,
+    1899,  1902,  1905,  1908,  1911,  1914,  1919,  1923,  1929,  1933,
+    1939,  1942,  1947,  1951,  1958,  1961,  1964,  1967,  1970,  1973,
+    1976,  1979,  1982,  1985,  1990,  2001,  2004,  2009,  2012,  2015,
+    2021,  2025,  2031,  2034,  2042,  2045,  2048,  2051,  2057,  2062,
+    2067
 };
 #endif
 
@@ -883,10 +885,11 @@ static const char *const yytname[] =
   "simple_when_clause_list", "simple_when_clause",
   "searched_when_clause_list", "searched_when_clause", "opt_else_clause",
   "expression_list", "literal_value", "datetime_unit",
-  "literal_value_commalist", "attribute_ref", "attribute_ref_list",
-  "comparison_operation", "unary_operation", "add_operation",
-  "multiply_operation", "name_commalist", "any_name", "boolean_value",
-  "command", "command_argument_list", YY_NULLPTR
+  "literal_value_commalist", "literal_value_commalist_multiple",
+  "attribute_ref", "attribute_ref_list", "comparison_operation",
+  "unary_operation", "add_operation", "multiply_operation",
+  "name_commalist", "any_name", "boolean_value", "command",
+  "command_argument_list", YY_NULLPTR
 };
 #endif
 
@@ -913,10 +916,10 @@ static const yytype_uint16 yytoknum[] =
 };
 # endif
 
-#define YYPACT_NINF -395
+#define YYPACT_NINF -410
 
 #define yypact_value_is_default(Yystate) \
-  (!!((Yystate) == (-395)))
+  (!!((Yystate) == (-410)))
 
 #define YYTABLE_NINF -139
 
@@ -927,61 +930,62 @@ static const yytype_uint16 yytoknum[] =
      STATE-NUM.  */
 static const yytype_int16 yypact[] =
 {
-     174,  -395,  -395,   -64,    85,   -26,    14,   -31,   -16,  -395,
-      40,   196,   196,  -395,   109,   102,  -395,  -395,  -395,  -395,
-    -395,  -395,  -395,  -395,  -395,  -395,   148,    -3,    87,  -395,
-     -40,   121,   196,  -395,  -395,     1,    -5,   196,   196,   196,
-     196,   196,  -395,  -395,   716,    82,     2,  -395,   153,    63,
-    -395,  -395,  -395,    98,   152,    -3,    40,   141,  -395,    98,
-    -395,  -395,  -395,    12,    97,   116,   261,   116,   169,   126,
-     138,  -395,   176,  -395,  -395,   270,   274,  -395,  -395,  -395,
-     807,   139,  -395,   210,  -395,  -395,   154,  -395,  -395,   297,
-    -395,  -395,  -395,  -395,   172,  -395,  -395,   177,   231,   901,
-     313,   265,   192,  -395,  -395,   338,    23,  -395,  -395,   243,
-    -395,  -395,  -395,  -395,  -395,  1083,    -7,   196,   196,   214,
-     196,     1,   196,  -395,    98,   363,  -395,   205,   263,  -395,
-    -395,  -395,   255,  -395,   116,  -395,   196,   196,   625,  -395,
-    -395,   262,   196,  -395,  -395,  -395,   625,    33,   -29,  -395,
-     409,  -395,   165,   165,  1174,   411,  -395,   -14,    28,  -395,
-      13,   138,  1174,  -395,  -395,   196,  1174,  -395,  -395,  -395,
-    -395,  1174,    18,   274,  -395,   196,   398,    59,  -395,   417,
-    -395,    98,  -395,   202,  -395,   116,    98,    87,  -395,   196,
-      80,   196,   196,   196,  -395,   285,  -395,   211,  1241,   992,
-     214,   534,   422,   423,  -395,  -395,   312,   415,  1252,   219,
-      43,  1174,    61,  -395,  1174,  -395,   369,   292,  -395,  -395,
-    -395,  -395,  -395,  -395,   367,  -395,   216,   294,  -395,  -395,
-       7,   186,   267,  -395,   298,   186,     3,   372,  -395,  -395,
-      23,  -395,   347,  -395,  -395,   295,  1174,  -395,   351,   229,
-     196,  -395,  1174,  -395,   196,  -395,  -395,  -395,   303,   366,
-     368,   304,  -395,  -395,  -395,   232,  -395,  -395,  -395,  -395,
-    -395,    34,   196,   323,    80,   196,  -395,   188,  -395,  -395,
-       4,    65,   625,   625,   276,  -395,  -395,  -395,  -395,  -395,
-    -395,  -395,  -395,  1174,   311,  1174,    51,  -395,   234,   326,
-    1174,    71,  -395,   399,   351,  -395,  -395,  1174,   453,  -395,
-     160,   196,  -395,  -395,   370,  -395,   373,   374,   379,    13,
-    -395,   457,   462,   186,   430,   400,   431,   329,   380,  -395,
-     236,  -395,  1174,  -395,   351,  -395,   625,   333,   334,   196,
-    -395,   196,  -395,  -395,  -395,  -395,  -395,  -395,  -395,   196,
-    -395,  -395,  -395,   238,   454,   184,  -395,   336,   348,  -395,
-     391,   342,  1252,  -395,   403,   196,  -395,  -395,   188,  -395,
-    -395,   423,  -395,  -395,  -395,  1174,   345,   341,   901,  -395,
-     351,   401,  -395,  -395,  1252,   350,   351,  1174,  -395,    37,
-      35,  -395,  -395,  -395,  -395,  -395,    13,   267,   390,   395,
-    -395,  1174,   625,   396,  1174,  -395,   455,   108,  -395,   351,
-       8,   196,   196,   240,  -395,   242,  -395,   196,  -395,  -395,
-    -395,  -395,   354,    80,   461,   402,  -395,   625,  -395,  -395,
-     356,  -395,   346,   901,  -395,  1174,   245,  -395,  -395,  1252,
-     351,  -395,   495,  -395,   408,  -395,  -395,   358,   422,   464,
-     420,   358,  1174,  -395,  -395,  -395,   490,  -395,   249,   251,
-    -395,  -395,  -395,   196,  -395,  -395,   375,   468,  -395,    19,
-     196,  1174,   264,   351,  -395,   266,   371,   625,  1174,   504,
-     376,   377,  -395,   227,    46,   405,  -395,   269,   196,    -9,
-    -395,   381,   351,  -395,  -395,  -395,   422,   377,  -395,   196,
-    -395,   376,  -395,  1174,  -395,  -395,   421,   418,   407,   425,
-     515,   196,  -395,   277,  -395,  -395,   384,  -395,   496,  -395,
-    -395,    49,  -395,  -395,  -395,  -395,    56,   386,  -395,   196,
-     388,  -395,  -395,   466,   426,   467,  -395,   196,   279,   347,
-    -395,  -395,  -395,   281,   445,   404,  -395,   539,  -395,  -395
+     405,  -410,  -410,   -52,    43,   -13,    34,   -38,   116,  -410,
+      48,   231,   231,  -410,   115,   119,  -410,  -410,  -410,  -410,
+    -410,  -410,  -410,  -410,  -410,  -410,   166,    46,    49,  -410,
+     -36,   205,   231,  -410,  -410,    38,   132,   231,   231,   231,
+     231,   231,  -410,  -410,   652,    97,    72,  -410,   203,    95,
+    -410,  -410,  -410,   130,   175,    46,    48,   158,  -410,   130,
+    -410,  -410,  -410,    25,    61,   128,   270,   128,   184,   142,
+     149,  -410,   106,  -410,  -410,   309,   313,  -410,  -410,  -410,
+     743,   153,  -410,   218,  -410,  -410,   189,  -410,  -410,   331,
+    -410,  -410,  -410,  -410,   199,  -410,  -410,   207,   272,   837,
+     347,   305,   211,  -410,  -410,   328,    19,  -410,  -410,   262,
+    -410,  -410,  -410,  -410,  -410,  1019,     5,   231,   231,   220,
+     231,    38,   231,  -410,   130,   373,  -410,   148,   243,  -410,
+    -410,  -410,   244,  -410,   128,  -410,   231,   231,   561,  -410,
+    -410,   245,   231,  -410,  -410,  -410,   561,    52,    17,  -410,
+     400,  -410,   140,   140,  1110,   402,  -410,     1,    29,  -410,
+      20,   149,  1110,  -410,  -410,   231,  1110,  -410,  -410,  -410,
+    -410,  1110,    21,   313,  -410,   231,   323,   -64,  -410,   416,
+    -410,   130,  -410,   167,  -410,   128,   130,    49,  -410,   231,
+     152,   231,   231,   231,  -410,   269,  -410,   169,  1177,   928,
+     220,   470,   426,   433,  -410,  -410,   407,   428,  1188,   303,
+     173,    23,  1110,    64,  -410,  1110,  -410,   388,   306,  -410,
+    -410,  -410,  -410,  -410,  -410,   381,  -410,    66,   310,  -410,
+    -410,     8,   209,   215,  -410,   311,   209,     9,   385,  -410,
+    -410,    19,  -410,   360,  -410,  -410,   315,  1110,  -410,   301,
+     180,   231,  -410,  1110,  -410,   231,  -410,  -410,  -410,   320,
+     384,   386,   329,  -410,  -410,  -410,   196,  -410,  -410,  -410,
+    -410,  -410,    16,   231,   341,   152,   231,  -410,   174,  -410,
+    -410,     2,    81,   561,   561,   206,  -410,  -410,  -410,  -410,
+    -410,  -410,  -410,  -410,  1110,   334,  1110,    58,  -410,   210,
+     335,   349,  1110,    68,  -410,   420,   301,  -410,  -410,  1110,
+     476,  -410,   162,   231,  -410,  -410,   389,  -410,   390,   391,
+     406,    20,  -410,   486,   487,   209,   453,   421,   455,   353,
+     403,  -410,   223,  -410,  1110,  -410,   301,  -410,   561,   357,
+     358,   231,  -410,   231,  -410,  -410,  -410,  -410,  -410,  -410,
+    -410,   231,  -410,  -410,  -410,   225,   477,    86,  -410,   361,
+     366,  -410,   417,   364,  1188,  -410,   430,   231,  -410,  -410,
+     174,  -410,  -410,   433,  -410,  -410,  -410,  1110,   367,   284,
+     837,  -410,   301,   424,  -410,  -410,  1188,  1188,   374,   301,
+    1110,  -410,    33,   -16,  -410,  -410,  -410,  -410,  -410,    20,
+     215,   419,   422,  -410,  1110,   561,   429,  1110,  -410,   475,
+      18,  -410,   301,    31,   231,   231,   227,  -410,   233,  -410,
+     231,  -410,  -410,  -410,  -410,   382,   152,   489,   432,  -410,
+     561,  -410,  -410,   392,  -410,   289,   837,  -410,  1110,   238,
+    -410,  -410,   240,  1188,   301,  -410,   521,  -410,   437,  -410,
+    -410,   393,   426,   498,   456,   393,  1110,  -410,  -410,  -410,
+     522,  -410,   246,   252,  -410,  -410,  -410,   231,  -410,  -410,
+     399,   504,  -410,    32,   231,  1110,   254,   301,  -410,  -410,
+     257,   404,   561,  1110,   540,   412,   408,  -410,   274,    11,
+     442,  -410,   286,   231,   127,  -410,   410,   301,  -410,  -410,
+    -410,   426,   408,  -410,   231,  -410,   412,  -410,  1110,  -410,
+    -410,   460,   454,   447,   458,   549,   231,  -410,   290,  -410,
+    -410,   425,  -410,   528,  -410,  -410,    -6,  -410,  -410,  -410,
+    -410,    12,   431,  -410,   231,   434,  -410,  -410,   495,   462,
+     496,  -410,   231,   293,   360,  -410,  -410,  -410,   299,   473,
+     435,  -410,   563,  -410,  -410
 };
 
   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -989,93 +993,96 @@ static const yytype_int16 yypact[] =
      means the default is an error.  */
 static const yytype_uint16 yydefact[] =
 {
-       0,     6,   298,     0,     0,     0,     0,     0,     0,    18,
+       0,     6,   300,     0,     0,     0,     0,     0,     0,    18,
      123,     0,     0,     7,     0,     0,    15,     8,    10,    11,
       13,    14,     9,    17,    12,    16,     0,   112,   119,   121,
-       0,   296,     0,   290,   291,     0,     0,     0,     0,     0,
+       0,   298,     0,   292,   293,     0,     0,     0,     0,     0,
        0,     0,   124,   125,     0,     0,   114,   115,     0,   156,
        1,     3,     2,     0,     0,   112,   123,     0,   110,     0,
-       5,     4,   297,     0,     0,   103,     0,   103,     0,     0,
-     197,    25,     0,   256,   253,     0,   282,   126,    40,    29,
+       5,     4,   299,     0,     0,   103,     0,   103,     0,     0,
+     197,    25,     0,   256,   253,     0,   284,   126,    40,    29,
        0,     0,    30,    31,    34,    36,     0,    37,    39,     0,
       41,   252,    35,    38,     0,    32,    33,     0,     0,     0,
        0,     0,   127,   128,   232,   132,   218,   220,   222,   225,
-     228,   229,   230,   224,   223,     0,   268,     0,     0,     0,
+     228,   229,   230,   224,   223,     0,   270,     0,     0,     0,
        0,     0,     0,   111,     0,     0,   120,     0,     0,   100,
      102,   101,     0,    98,   103,    97,     0,     0,     0,   106,
      198,     0,     0,    94,   254,   255,     0,     0,   248,   245,
        0,    43,     0,   257,     0,     0,    44,     0,     0,   259,
-       0,   197,     0,   283,   284,     0,     0,   131,   286,   287,
-     285,     0,     0,     0,   221,     0,     0,   197,   108,     0,
-     116,     0,   117,     0,   288,   103,     0,   118,   113,     0,
+       0,   197,     0,   285,   286,     0,     0,   131,   288,   289,
+     287,     0,     0,     0,   221,     0,     0,   197,   108,     0,
+     116,     0,   117,     0,   290,   103,     0,   118,   113,     0,
        0,     0,     0,     0,    96,    66,    27,     0,     0,     0,
-       0,     0,   199,   201,   203,   205,     0,   223,     0,     0,
-       0,     0,   248,   242,     0,   246,     0,     0,   262,   263,
-     264,   261,   265,   260,     0,   258,     0,     0,   134,   231,
-       0,     0,   158,   147,   133,   152,   135,   160,   129,   130,
-     217,   219,   174,   226,   269,     0,     0,   233,   250,     0,
-       0,   105,     0,   157,     0,    99,    95,    19,     0,     0,
-       0,     0,    20,    21,    22,     0,    74,    76,    77,    78,
-      79,     0,     0,     0,    64,     0,    42,    56,   204,   212,
-       0,     0,     0,     0,     0,   272,   274,   275,   276,   277,
-     273,   278,   280,     0,     0,     0,     0,   266,     0,     0,
-       0,     0,   243,     0,   249,   241,    45,     0,     0,    46,
-     138,     0,   148,   154,   144,   139,   140,   142,     0,     0,
-     151,     0,     0,   150,     0,   162,     0,     0,   176,   234,
-       0,   235,     0,   107,   109,   289,     0,     0,     0,     0,
-     104,     0,    81,    84,    82,   294,   295,   293,   292,     0,
-      80,    85,   270,     0,   268,     0,    63,    65,    68,    28,
-       0,     0,     0,    47,     0,     0,    49,    55,    57,    26,
-     211,   200,   202,   279,   281,     0,     0,     0,     0,   213,
-     210,     0,   209,    93,     0,     0,   247,     0,   240,     0,
-       0,   153,   155,   145,   141,   143,     0,   159,     0,     0,
-     149,     0,     0,   164,     0,   227,     0,   178,   236,   251,
-       0,     0,     0,     0,    75,     0,    67,     0,    86,    87,
-      88,    89,    90,     0,     0,    70,    48,     0,    51,    50,
-       0,    54,     0,     0,   215,     0,     0,   208,   267,     0,
-     244,   237,     0,   238,     0,   136,   137,   161,   163,     0,
-     166,   175,     0,   181,   180,   173,     0,    61,     0,     0,
-      58,    83,   271,     0,    24,    62,     0,     0,    23,     0,
-       0,     0,     0,   206,   214,     0,     0,     0,     0,     0,
-     168,   177,   188,   191,     0,     0,    59,     0,     0,     0,
-      52,     0,   207,   216,    92,   239,   146,   165,   167,     0,
-     122,   169,   170,     0,   192,   193,   194,     0,     0,     0,
-       0,     0,    91,     0,    72,    73,     0,    53,     0,   171,
-     189,     0,   190,   182,   184,   183,     0,     0,    69,     0,
-       0,   195,   196,     0,     0,     0,   179,     0,     0,   174,
-     185,   187,   186,     0,     0,     0,    60,     0,   172,    71
+       0,     0,   199,   201,   203,   205,     0,   223,     0,    93,
+       0,     0,     0,   248,   242,     0,   246,     0,     0,   262,
+     263,   264,   261,   265,   260,     0,   258,     0,     0,   134,
+     231,     0,     0,   158,   147,   133,   152,   135,   160,   129,
+     130,   217,   219,   174,   226,   271,     0,     0,   233,   250,
+       0,     0,   105,     0,   157,     0,    99,    95,    19,     0,
+       0,     0,     0,    20,    21,    22,     0,    74,    76,    77,
+      78,    79,     0,     0,     0,    64,     0,    42,    56,   204,
+     212,     0,     0,     0,     0,     0,   274,   276,   277,   278,
+     279,   275,   280,   282,     0,     0,     0,     0,   266,     0,
+       0,     0,     0,     0,   243,     0,   249,   241,    45,     0,
+       0,    46,   138,     0,   148,   154,   144,   139,   140,   142,
+       0,     0,   151,     0,     0,   150,     0,   162,     0,     0,
+     176,   234,     0,   235,     0,   107,   109,   291,     0,     0,
+       0,     0,   104,     0,    81,    84,    82,   296,   297,   295,
+     294,     0,    80,    85,   272,     0,   270,     0,    63,    65,
+      68,    28,     0,     0,     0,    47,     0,     0,    49,    55,
+      57,    26,   211,   200,   202,   281,   283,     0,     0,     0,
+       0,   213,   210,     0,   209,   268,     0,     0,     0,   247,
+       0,   240,     0,     0,   153,   155,   145,   141,   143,     0,
+     159,     0,     0,   149,     0,     0,   164,     0,   227,     0,
+     178,   236,   251,     0,     0,     0,     0,    75,     0,    67,
+       0,    86,    87,    88,    89,    90,     0,     0,    70,    48,
+       0,    51,    50,     0,    54,     0,     0,   215,     0,     0,
+     208,   267,     0,     0,   244,   237,     0,   238,     0,   136,
+     137,   161,   163,     0,   166,   175,     0,   181,   180,   173,
+       0,    61,     0,     0,    58,    83,   273,     0,    24,    62,
+       0,     0,    23,     0,     0,     0,     0,   206,   214,   269,
+       0,     0,     0,     0,     0,   168,   177,   188,   191,     0,
+       0,    59,     0,     0,     0,    52,     0,   207,   216,    92,
+     239,   146,   165,   167,     0,   122,   169,   170,     0,   192,
+     193,   194,     0,     0,     0,     0,     0,    91,     0,    72,
+      73,     0,    53,     0,   171,   189,     0,   190,   182,   184,
+     183,     0,     0,    69,     0,     0,   195,   196,     0,     0,
+       0,   179,     0,     0,   174,   185,   187,   186,     0,     0,
+       0,    60,     0,   172,    71
 };
 
   /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-    -395,  -395,  -395,  -395,  -395,  -395,  -395,  -395,  -164,  -395,
-     349,   180,  -395,  -395,  -271,  -395,  -395,  -395,  -395,  -395,
-    -395,  -394,   209,  -395,  -395,  -395,  -395,  -395,  -395,  -395,
-    -395,    24,   -46,  -395,  -395,  -395,   301,  -395,   497,  -395,
-    -395,   435,   259,   433,   -28,   498,  -395,  -395,   397,  -395,
-     -90,  -395,  -395,  -207,   162,  -187,   -10,  -395,  -395,  -395,
-    -395,  -395,  -395,  -395,    60,    21,  -395,  -395,  -395,  -395,
-    -395,  -395,    84,    62,  -395,  -395,   -54,  -395,  -145,   282,
-     280,   382,   -35,   406,   412,   451,  -156,  -395,  -395,  -395,
-    -395,   355,  -395,   427,   359,  -232,  -203,   429,   129,  -128,
-    -395,  -395,  -395,  -395,  -395,  -136,    -4,  -395,  -395,  -395
+    -410,  -410,  -410,  -410,  -410,  -410,  -410,  -410,  -148,  -410,
+     376,   216,  -410,  -410,  -264,  -410,  -410,  -410,  -410,  -410,
+    -410,  -409,   236,  -410,  -410,  -410,  -410,  -410,  -410,  -410,
+    -410,    85,    -3,  -410,  -410,  -410,   325,  -410,   526,  -410,
+    -410,   467,   217,   464,   -43,   533,  -410,  -410,   436,  -410,
+    -114,  -410,  -410,  -186,   192,  -184,    -9,  -410,  -410,  -410,
+    -410,  -410,  -410,  -410,    89,    55,  -410,  -410,  -410,  -410,
+    -410,  -410,   109,    92,  -410,  -410,    79,  -410,  -142,   318,
+     322,   409,   -42,   441,   439,   501,  -154,  -410,  -410,  -410,
+    -410,   398,  -410,   469,   413,  -232,  -195,   449,  -324,  -410,
+    -129,  -410,  -410,  -410,  -410,  -410,  -141,    -4,  -410,  -410,
+    -410
 };
 
   /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int16 yydefgoto[] =
 {
       -1,    14,    15,    16,    17,    18,    19,    20,   196,   197,
-     100,   367,   368,   369,   262,   357,   358,   273,   425,   468,
-     516,   265,   266,   267,   268,   269,   270,   422,   464,    21,
+     100,   369,   370,   371,   263,   359,   360,   274,   428,   472,
+     521,   266,   267,   268,   269,   270,   271,   425,   468,    21,
       22,    65,   133,    23,    24,   177,   178,    25,    58,    26,
       46,    47,   157,    28,    29,    44,   101,   102,   103,   161,
-     104,   323,   318,   232,   233,   312,   313,   234,   325,   403,
-     450,   480,   500,   501,   502,   327,   328,   407,   455,   456,
-     510,   536,   481,   482,   506,   522,   139,   140,   202,   203,
+     104,   325,   320,   233,   234,   314,   315,   235,   327,   406,
+     454,   485,   505,   506,   507,   329,   330,   410,   459,   460,
+     515,   541,   486,   487,   511,   527,   139,   140,   202,   203,
      204,   205,   206,   106,   107,   108,   109,   110,   111,   112,
-     212,   213,   148,   149,   216,   249,   113,   224,   298,   114,
-     353,   295,   115,   166,   171,   183,   116,   351,    30,    31
+     213,   214,   148,   149,   217,   250,   113,   225,   299,   209,
+     114,   355,   296,   115,   166,   171,   183,   116,   353,    30,
+      31
 };
 
   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
@@ -1083,256 +1090,215 @@ static const yytype_int16 yydefgoto[] =
      number is the opposite.  If YYTABLE_NINF, syntax error.  */
 static const yytype_int16 yytable[] =
 {
-      36,   210,    48,   356,   235,   297,   209,    45,    49,   105,
-     207,    33,   282,    34,   330,    56,   282,    33,   207,    34,
-     175,   135,    33,   310,    34,   257,    56,   282,    63,   182,
-      56,   126,   214,    68,    69,    70,    71,    72,    33,   342,
-      34,   343,   321,   127,   143,   147,   168,   169,   320,   163,
-     164,   282,    37,   507,   163,   164,   280,    32,   163,   164,
-      67,   381,   344,   533,   158,   514,    66,    41,    42,   487,
-     231,   207,   128,   207,   235,   284,   285,   286,   287,   288,
-     289,   290,   291,   292,   293,    39,   163,   164,   194,    33,
-      40,    34,   163,   164,   513,    38,   508,   515,    43,   345,
-      60,   167,   129,    61,   442,   146,   534,   237,    48,    50,
-     279,   359,   397,   179,    49,   531,   184,    59,   186,   226,
-      64,    10,   214,   251,    62,   258,    64,   105,   346,   347,
-     322,   228,   195,   198,    57,   532,   400,   176,   184,   255,
-     231,   248,   294,   382,   352,   185,   436,   176,   118,   370,
-     259,   230,   465,   457,   207,   207,   236,   230,   256,   428,
-     348,   239,   242,   235,   490,   300,   281,   211,   243,   447,
-     170,   244,   451,   229,   509,     1,   301,     2,   349,   304,
-     443,   438,   441,   260,   535,   198,   119,   263,   264,   271,
-      33,   410,    34,   387,   138,   211,    53,   117,   360,    10,
-      33,   472,    34,   413,   379,   250,     3,   120,   207,   261,
-     229,   248,    10,   415,   453,   130,   131,   334,   218,   311,
-     454,   418,     4,     5,   419,   420,   236,    49,    54,   231,
-       6,    49,   314,   361,     7,   122,   297,   163,   164,   315,
-     235,   219,    51,   362,    52,   125,   179,   316,   163,   164,
-     335,   189,   190,   132,     8,   220,   221,   448,   377,    27,
-     380,   504,    10,    35,   136,   386,   134,   350,   354,   317,
-     137,   198,   389,   138,   207,   458,   459,   144,   222,     9,
-     363,   145,   469,   150,   505,    55,   434,   308,    10,   462,
-      10,   364,   151,   373,   374,   375,   365,   409,   152,   207,
-     421,   392,   153,   223,    11,   391,   231,    49,   141,   191,
-     192,    12,   121,   156,    13,   236,   154,   366,   159,    49,
-     142,   155,   284,   285,   286,   287,   288,   289,   290,   291,
-     292,   293,   496,   163,   164,   184,   160,   271,   162,   314,
-     432,   172,    33,   248,    34,   184,   315,   253,   254,   207,
-     435,  -138,   440,   376,   316,   471,   274,   275,   181,   163,
-     164,   430,   163,   164,   299,   254,   248,   163,   164,   248,
-     188,   165,   163,   164,   331,   332,   317,   340,   341,   383,
-     384,   408,   332,   416,   417,   460,   254,   461,   254,   294,
-     474,   332,   236,   538,   485,   254,   486,   254,   248,   193,
-     473,   543,    33,    73,    34,    74,   208,   184,   184,   493,
-     332,   494,   384,   354,   512,   341,   217,   483,   227,    75,
-      76,   245,   528,   341,   544,   254,   546,   254,   252,   272,
-     282,   305,   283,    78,    79,   296,   492,   306,   307,   309,
-     329,    80,    81,   483,   319,   324,   326,   336,   339,    82,
-      83,   337,    84,   338,   355,   378,   246,    85,   385,   271,
-     390,   388,    86,   396,   398,    87,   491,   393,   483,   399,
-     394,   395,   401,   404,   405,   402,   406,   411,   412,    88,
-      89,   175,   423,   426,   271,   424,   427,    90,   429,   433,
-      91,   445,   449,   437,   439,   518,   446,   452,   463,   466,
-     470,   467,   476,   477,   332,    92,   478,   527,   479,   484,
-     489,   498,   499,   511,   521,    93,   495,   524,    94,   488,
-     523,    95,    96,   503,   526,   184,   517,   525,   529,   530,
-     537,    97,   539,   184,   540,   542,   541,    98,    33,    73,
-      34,    74,    99,   247,   199,   547,   549,   277,   431,   548,
-     414,   333,   123,   180,   124,    75,    76,   187,   444,   238,
-     545,   519,   497,   372,   371,   520,   174,   302,   475,    78,
-      79,   303,   240,     0,     0,   215,     0,    80,    81,     0,
-       0,   278,   225,   241,     0,    82,    83,     0,    84,     0,
-       0,     0,     0,    85,     0,     0,     0,   200,    86,     0,
-       0,    87,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,    88,    89,     0,     0,     0,
-       0,     0,     0,    90,     0,     0,    91,     0,     0,    33,
-      73,    34,    74,     0,     0,   199,     0,     0,     0,     0,
-       0,    92,     0,     0,     0,     0,    75,    76,    10,     0,
-       0,    93,     0,     0,    94,     0,     0,    95,    96,     0,
-      78,    79,     0,     0,     0,     0,     0,    97,    80,    81,
-       0,     0,     0,    98,     0,     0,    82,    83,   201,    84,
-       0,     0,     0,     0,    85,     0,     0,     0,   200,    86,
-       0,     0,    87,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,    88,    89,     0,     0,
-       0,     0,     0,     0,    90,     0,     0,    91,     0,     0,
-      33,    73,    34,    74,     0,     0,     0,     0,     0,     0,
-       0,     0,    92,     0,     0,     0,     0,    75,    76,    77,
-       0,     0,    93,     0,     0,    94,     0,     0,    95,    96,
-       0,    78,    79,     0,     0,     0,     0,     0,    97,    80,
-      81,     0,     0,     0,    98,     0,     0,    82,    83,   201,
-      84,     0,     0,     0,     0,    85,     0,     0,     0,     0,
-      86,     0,     0,    87,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,    88,    89,     0,
-       0,     0,     0,     0,     0,    90,     0,     0,    91,     0,
-       0,    33,    73,    34,    74,     0,     0,     0,     0,     0,
-       0,     0,     0,    92,     0,     0,     0,     0,    75,    76,
-       0,     0,     0,    93,     0,     0,    94,     0,     0,    95,
-      96,     0,    78,    79,     0,     0,     0,     0,     0,    97,
-      80,    81,     0,     0,     0,    98,     0,     0,    82,    83,
-      99,    84,     0,     0,     0,     0,    85,     0,     0,     0,
-       0,    86,     0,     0,    87,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,    88,    89,
-       0,     0,     0,     0,     0,     0,    90,     0,     0,    91,
-       0,     0,     0,     0,     0,    33,    73,    34,    74,     0,
-       0,     0,     0,     0,    92,     0,     0,     0,     0,     0,
-       0,     0,    75,    76,    93,     0,     0,    94,     0,     0,
-      95,    96,     0,     0,     0,     0,    78,    79,     0,     0,
-      97,   146,     0,     0,    80,    81,    98,     0,     0,     0,
-       0,    99,    82,    83,     0,    84,     0,     0,     0,     0,
-      85,     0,     0,     0,     0,    86,     0,     0,    87,     0,
+      36,   210,   105,    48,   211,   182,   236,    45,    49,   207,
+     283,   358,    33,   298,    34,   332,   126,   207,   512,   538,
+      33,   344,    34,   345,    33,    33,    34,    34,    63,   143,
+      56,   283,   175,    68,    69,    70,    71,    72,   147,   283,
+     283,   258,   168,   169,   346,   312,   232,    33,   323,    34,
+     163,   164,   322,   446,   163,   164,   127,   158,   492,   281,
+     536,   513,   539,   442,   135,    37,   129,    56,   383,    32,
+     207,   138,   207,   163,   164,    56,    42,   236,   215,    59,
+     537,   347,   251,    40,   518,   128,   280,   163,   164,   163,
+     164,   285,   286,   287,   288,   289,   290,   291,   292,   293,
+     294,   167,   163,   164,    60,    39,    43,    61,    38,    48,
+     348,   349,   227,   179,    49,    50,   184,   232,   186,   480,
+     105,    67,    10,   421,   457,   215,   422,   423,   361,   447,
+     458,   194,   195,   198,   249,   400,   324,   310,   184,   514,
+     540,   403,   350,   257,   354,   302,   229,   372,   439,   176,
+     384,   146,   231,   176,   207,   207,   237,    10,   295,   282,
+     351,   240,   469,    64,   231,   243,   170,   236,   244,   431,
+     303,   245,   451,   306,   230,   455,   461,   495,   445,   130,
+     131,   381,   256,    57,   362,   198,   212,   264,   265,   272,
+     390,   441,   298,   219,   189,   190,   413,   259,   212,    41,
+     416,   519,   424,    66,   476,   249,   185,   232,    62,   207,
+     418,   336,   117,    33,    53,    34,   220,    27,   118,   363,
+      10,    35,   260,   375,   376,   377,   230,   237,    49,   364,
+     221,   222,    49,   520,   316,    33,   119,    34,   141,   120,
+     238,   317,   313,    55,    10,   236,    54,   179,   298,   318,
+     142,   337,   379,   223,   382,   261,   252,    64,   122,    51,
+     389,    52,   125,   452,   437,   132,   365,   392,   352,   356,
+     121,   319,   198,   462,   463,   134,   207,   366,   224,   136,
+      10,   262,   367,   378,   138,   232,   137,   316,   473,   191,
+     192,   466,   412,   438,   317,   163,   164,   150,   475,  -138,
+     151,   207,   318,   368,   395,   163,   164,   394,   509,    49,
+     163,   164,   254,   255,   275,   276,   144,   237,   301,   255,
+     145,    49,   163,   164,   319,   333,   334,    33,    73,    34,
+      74,   510,    33,   152,    34,   435,   153,   184,   249,   272,
+     501,   342,   343,   154,    75,    76,   246,   184,   444,   163,
+     164,   155,   159,   207,   156,   385,   386,   162,    78,    79,
+     172,   165,   249,   433,   181,   249,    80,    81,   411,   334,
+     419,   420,   464,   255,    82,    83,   160,    84,   465,   255,
+     188,   247,    85,   478,   334,   479,   386,    86,   193,   208,
+      87,   490,   255,   543,   249,   237,   477,   491,   255,   498,
+     334,   548,   499,   386,    88,    89,     1,   218,     2,   228,
+     184,   184,    90,   273,   488,    91,   356,   285,   286,   287,
+     288,   289,   290,   291,   292,   293,   294,   253,   163,   164,
+      92,   517,   343,   497,   283,   533,   343,     3,   549,   255,
+      93,   488,   284,    94,   551,   255,    95,    96,   297,   300,
+     307,   308,   309,     4,     5,   311,    97,   321,   326,   328,
+     331,     6,    98,   272,   338,     7,   488,    99,   248,   339,
+     496,   340,   357,   341,    33,    73,    34,    74,   380,   387,
+     199,   388,   391,   393,   295,     8,   396,   397,   398,   272,
+     399,    75,    76,   401,   402,   404,   405,   407,   408,   409,
+     523,   414,   415,   427,   175,    78,    79,   426,   430,   429,
+       9,   436,   532,    80,    81,   432,   440,   456,   443,    10,
+     449,    82,    83,   450,    84,   453,   467,   470,   481,    85,
+     184,   471,   482,   200,    86,    11,   474,    87,   184,   334,
+     483,   489,    12,   493,   484,    13,   494,   503,   504,   500,
+     516,    88,    89,   526,   508,   522,   528,   529,   531,    90,
+     530,   535,    91,   545,   547,    33,    73,    34,    74,   534,
+     554,   199,   546,   552,   278,   542,   335,    92,   544,   417,
+     553,   123,    75,    76,    10,   180,   434,    93,   187,   124,
+      94,   448,   502,    95,    96,   524,    78,    79,   239,   550,
+     525,   373,   226,    97,    80,    81,   374,   241,   279,    98,
+     242,   304,    82,    83,   201,    84,   174,   216,     0,     0,
+      85,     0,     0,     0,   200,    86,   305,     0,    87,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
        0,     0,    88,    89,     0,     0,     0,     0,     0,     0,
       90,     0,     0,    91,     0,     0,    33,    73,    34,    74,
        0,     0,     0,     0,     0,     0,     0,     0,    92,     0,
-       0,     0,     0,    75,    76,    10,     0,     0,    93,     0,
+       0,     0,     0,    75,    76,    77,     0,     0,    93,     0,
        0,    94,     0,     0,    95,    96,     0,    78,    79,     0,
        0,     0,     0,     0,    97,    80,    81,     0,     0,     0,
-      98,     0,     0,    82,    83,    99,    84,     0,     0,     0,
-       0,    85,     0,     0,     0,   200,    86,     0,     0,    87,
+      98,     0,     0,    82,    83,   201,    84,     0,     0,     0,
+       0,    85,     0,     0,     0,     0,    86,     0,     0,    87,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,    88,    89,     0,     0,     0,     0,     0,
        0,    90,     0,     0,    91,     0,     0,    33,    73,    34,
       74,     0,     0,     0,     0,     0,     0,     0,     0,    92,
-       0,     0,     0,     0,    75,   173,     0,     0,     0,    93,
+       0,     0,     0,     0,    75,    76,     0,     0,     0,    93,
        0,     0,    94,     0,     0,    95,    96,     0,    78,    79,
        0,     0,     0,     0,     0,    97,    80,    81,     0,     0,
-       0,    98,     0,     0,    82,    83,   201,    84,     0,     0,
+       0,    98,     0,     0,    82,    83,    99,    84,     0,     0,
        0,     0,    85,     0,     0,     0,     0,    86,     0,     0,
       87,     0,     0,     0,     0,     0,     0,     0,     0,     0,
        0,     0,     0,     0,    88,    89,     0,     0,     0,     0,
-       0,     0,    90,     0,     0,    91,     0,     0,    33,    73,
-      34,    74,     0,     0,     0,     0,     0,     0,     0,     0,
-      92,     0,     0,     0,     0,    75,    76,     0,     0,     0,
-      93,     0,     0,    94,     0,     0,    95,    96,     0,    78,
-      79,     0,     0,     0,     0,     0,    97,    80,    81,     0,
-       0,     0,    98,     0,     0,    82,    83,    99,    84,     0,
-       0,     0,     0,    85,     0,     0,     0,     0,    86,     0,
-       0,    87,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,    88,    89,    73,     0,    74,
-       0,     0,     0,    90,     0,     0,    91,     0,     0,     0,
-       0,     0,     0,    75,   173,     0,    78,    79,     0,     0,
-       0,    92,     0,     0,     0,    81,     0,    78,    79,     0,
-       0,    93,    82,    83,    94,    84,    81,    95,    96,     0,
-      85,     0,     0,    82,    83,     0,    84,    97,    87,     0,
-       0,    85,     0,    98,     0,     0,     0,     0,    99,    87,
-       0,     0,    88,   276,     0,     0,     0,     0,     0,     0,
-      90,     0,     0,    88,    89,     0,     0,     0,     0,     0,
-       0,    90,     0,     0,    91,     0,     0,     0,    92,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,    93,    92,
-       0,     0,     0,     0,    95,    96,     0,     0,     0,    93,
-       0,     0,     0,     0,    97,    95,    96,     0,     0,     0,
-      98,     0,     0,     0,     0,    97,     0,     0,     0,     0,
-       0,    98
+       0,     0,    90,     0,     0,    91,     0,     0,     0,     0,
+       0,    33,    73,    34,    74,     0,     0,     0,     0,     0,
+      92,     0,     0,     0,     0,     0,     0,     0,    75,    76,
+      93,     0,     0,    94,     0,     0,    95,    96,     0,     0,
+       0,     0,    78,    79,     0,     0,    97,   146,     0,     0,
+      80,    81,    98,     0,     0,     0,     0,    99,    82,    83,
+       0,    84,     0,     0,     0,     0,    85,     0,     0,     0,
+       0,    86,     0,     0,    87,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,    88,    89,
+       0,     0,     0,     0,     0,     0,    90,     0,     0,    91,
+       0,     0,    33,    73,    34,    74,     0,     0,     0,     0,
+       0,     0,     0,     0,    92,     0,     0,     0,     0,    75,
+      76,    10,     0,     0,    93,     0,     0,    94,     0,     0,
+      95,    96,     0,    78,    79,     0,     0,     0,     0,     0,
+      97,    80,    81,     0,     0,     0,    98,     0,     0,    82,
+      83,    99,    84,     0,     0,     0,     0,    85,     0,     0,
+       0,   200,    86,     0,     0,    87,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,    88,
+      89,     0,     0,     0,     0,     0,     0,    90,     0,     0,
+      91,     0,     0,    33,    73,    34,    74,     0,     0,     0,
+       0,     0,     0,     0,     0,    92,     0,     0,     0,     0,
+      75,   173,     0,     0,     0,    93,     0,     0,    94,     0,
+       0,    95,    96,     0,    78,    79,     0,     0,     0,     0,
+       0,    97,    80,    81,     0,     0,     0,    98,     0,     0,
+      82,    83,   201,    84,     0,     0,     0,     0,    85,     0,
+       0,     0,     0,    86,     0,     0,    87,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+      88,    89,     0,     0,     0,     0,     0,     0,    90,     0,
+       0,    91,     0,     0,    33,    73,    34,    74,     0,     0,
+       0,     0,     0,     0,     0,     0,    92,     0,     0,     0,
+       0,    75,    76,     0,     0,     0,    93,     0,     0,    94,
+       0,     0,    95,    96,     0,    78,    79,     0,     0,     0,
+       0,     0,    97,    80,    81,     0,     0,     0,    98,     0,
+       0,    82,    83,    99,    84,     0,     0,     0,     0,    85,
+       0,     0,     0,     0,    86,     0,     0,    87,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,    88,    89,    73,     0,    74,     0,     0,     0,    90,
+       0,     0,    91,     0,     0,     0,     0,     0,     0,    75,
+     173,     0,    78,    79,     0,     0,     0,    92,     0,     0,
+       0,    81,     0,    78,    79,     0,     0,    93,    82,    83,
+      94,    84,    81,    95,    96,     0,    85,     0,     0,    82,
+      83,     0,    84,    97,    87,     0,     0,    85,     0,    98,
+       0,     0,     0,     0,    99,    87,     0,     0,    88,   277,
+       0,     0,     0,     0,     0,     0,    90,     0,     0,    88,
+      89,     0,     0,     0,     0,     0,     0,    90,     0,     0,
+      91,     0,     0,     0,    92,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,    93,    92,     0,     0,     0,     0,
+      95,    96,     0,     0,     0,    93,     0,     0,     0,     0,
+      97,    95,    96,     0,     0,     0,    98,     0,     0,     0,
+       0,    97,     0,     0,     0,     0,     0,    98
 };
 
 static const yytype_int16 yycheck[] =
 {
-       4,   146,    12,   274,   160,   208,   142,    11,    12,    44,
-     138,     4,     8,     6,   246,    29,     8,     4,   146,     6,
-      27,    67,     4,   230,     6,   189,    29,     8,    32,   119,
-      29,    59,    61,    37,    38,    39,    40,    41,     4,     5,
-       6,     7,    39,    31,    72,    80,    23,    24,   235,    21,
-      22,     8,    78,     7,    21,    22,   201,   121,    21,    22,
-      36,    10,    28,     7,    99,    74,    71,    83,    28,   463,
-     160,   199,    60,   201,   230,    10,    11,    12,    13,    14,
-      15,    16,    17,    18,    19,    71,    21,    22,   134,     4,
-     121,     6,    21,    22,   488,   121,    50,   106,    58,    65,
-     140,   105,     5,   143,    69,   134,    50,   161,   118,     0,
-     200,   275,   319,   117,   118,    66,   120,    30,   122,   154,
-     125,   114,    61,   177,     3,    45,   125,   162,    94,    95,
-     127,   145,   136,   137,   137,    86,   323,   144,   142,   185,
-     230,   176,    77,    92,   272,   121,   378,   144,   146,   145,
-      70,   144,   423,   145,   282,   283,   160,   144,   186,   362,
-     126,   165,   144,   319,   145,   122,   201,   134,   172,   401,
-     147,   175,   404,   145,   128,     1,   211,     3,   144,   214,
-     145,   384,   145,   103,   128,   189,    33,   191,   192,   193,
-       4,   336,     6,   122,   135,   134,    48,   115,    10,   114,
-       4,   433,     6,   339,   294,   146,    32,   144,   336,   129,
-     145,   246,   114,   349,   106,   118,   119,   252,    53,    33,
-     112,    37,    48,    49,    40,    41,   230,   231,    80,   319,
-      56,   235,    72,    45,    60,    83,   439,    21,    22,    79,
-     396,    76,   140,    55,   142,   104,   250,    87,    21,    22,
-     254,    46,    47,   137,    80,    90,    91,   402,   293,     0,
-     295,    34,   114,     4,    95,   300,     5,   271,   272,   109,
-     144,   275,   307,   135,   402,   411,   412,     7,   113,   105,
-      92,     7,   427,   144,    57,    26,   376,    71,   114,   417,
-     114,   103,    82,    17,    18,    19,   108,   332,   144,   427,
-     116,   311,     5,   138,   130,   145,   396,   311,   132,    46,
-      47,   137,    53,    82,   140,   319,   144,   129,     5,   323,
-     144,   144,    10,    11,    12,    13,    14,    15,    16,    17,
-      18,    19,   477,    21,    22,   339,    71,   341,   146,    72,
-     375,    98,     4,   378,     6,   349,    79,   145,   146,   477,
-       9,    84,   387,    77,    87,     9,   145,   146,   144,    21,
-      22,   365,    21,    22,   145,   146,   401,    21,    22,   404,
-       7,    33,    21,    22,   145,   146,   109,   145,   146,   145,
-     146,   145,   146,   145,   146,   145,   146,   145,   146,    77,
-     145,   146,   396,   529,   145,   146,   145,   146,   433,   144,
-     435,   537,     4,     5,     6,     7,   144,   411,   412,   145,
-     146,   145,   146,   417,   145,   146,     7,   452,     7,    21,
-      22,    23,   145,   146,   145,   146,   145,   146,    11,   144,
-       8,    62,     9,    35,    36,    20,   471,   145,    71,   145,
-     145,    43,    44,   478,   146,    73,    99,   144,   144,    51,
-      52,    85,    54,    85,   131,   144,    58,    59,   132,   463,
-       7,    62,    64,    84,     7,    67,   470,    97,   503,     7,
-      97,    97,    42,    42,   145,    75,    96,   144,   144,    81,
-      82,    27,   146,    92,   488,   137,   144,    89,    85,   144,
-      92,   101,    96,    92,   144,   499,   101,    42,   144,    38,
-     144,    99,     7,    95,   146,   107,    42,   511,    88,    19,
-      42,     7,   136,   108,    93,   117,   145,   110,   120,   144,
-     102,   123,   124,   146,     9,   529,   145,   102,   144,    33,
-     144,   133,   144,   537,    68,    68,   110,   139,     4,     5,
-       6,     7,   144,   145,    10,   100,     7,   198,   368,   145,
-     341,   250,    55,   118,    56,    21,    22,   124,   396,   162,
-     539,   501,   478,   283,   282,   503,   115,   212,   439,    35,
-      36,   212,   166,    -1,    -1,   148,    -1,    43,    44,    -1,
-      -1,   199,   153,   171,    -1,    51,    52,    -1,    54,    -1,
-      -1,    -1,    -1,    59,    -1,    -1,    -1,    63,    64,    -1,
-      -1,    67,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    81,    82,    -1,    -1,    -1,
-      -1,    -1,    -1,    89,    -1,    -1,    92,    -1,    -1,     4,
-       5,     6,     7,    -1,    -1,    10,    -1,    -1,    -1,    -1,
-      -1,   107,    -1,    -1,    -1,    -1,    21,    22,   114,    -1,
-      -1,   117,    -1,    -1,   120,    -1,    -1,   123,   124,    -1,
-      35,    36,    -1,    -1,    -1,    -1,    -1,   133,    43,    44,
-      -1,    -1,    -1,   139,    -1,    -1,    51,    52,   144,    54,
-      -1,    -1,    -1,    -1,    59,    -1,    -1,    -1,    63,    64,
-      -1,    -1,    67,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    81,    82,    -1,    -1,
-      -1,    -1,    -1,    -1,    89,    -1,    -1,    92,    -1,    -1,
-       4,     5,     6,     7,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,   107,    -1,    -1,    -1,    -1,    21,    22,    23,
-      -1,    -1,   117,    -1,    -1,   120,    -1,    -1,   123,   124,
-      -1,    35,    36,    -1,    -1,    -1,    -1,    -1,   133,    43,
-      44,    -1,    -1,    -1,   139,    -1,    -1,    51,    52,   144,
-      54,    -1,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
-      64,    -1,    -1,    67,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    81,    82,    -1,
-      -1,    -1,    -1,    -1,    -1,    89,    -1,    -1,    92,    -1,
-      -1,     4,     5,     6,     7,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,   107,    -1,    -1,    -1,    -1,    21,    22,
-      -1,    -1,    -1,   117,    -1,    -1,   120,    -1,    -1,   123,
-     124,    -1,    35,    36,    -1,    -1,    -1,    -1,    -1,   133,
-      43,    44,    -1,    -1,    -1,   139,    -1,    -1,    51,    52,
-     144,    54,    -1,    -1,    -1,    -1,    59,    -1,    -1,    -1,
-      -1,    64,    -1,    -1,    67,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    81,    82,
-      -1,    -1,    -1,    -1,    -1,    -1,    89,    -1,    -1,    92,
-      -1,    -1,    -1,    -1,    -1,     4,     5,     6,     7,    -1,
-      -1,    -1,    -1,    -1,   107,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    21,    22,   117,    -1,    -1,   120,    -1,    -1,
-     123,   124,    -1,    -1,    -1,    -1,    35,    36,    -1,    -1,
-     133,   134,    -1,    -1,    43,    44,   139,    -1,    -1,    -1,
-      -1,   144,    51,    52,    -1,    54,    -1,    -1,    -1,    -1,
-      59,    -1,    -1,    -1,    -1,    64,    -1,    -1,    67,    -1,
+       4,   142,    44,    12,   146,   119,   160,    11,    12,   138,
+       8,   275,     4,   208,     6,   247,    59,   146,     7,     7,
+       4,     5,     6,     7,     4,     4,     6,     6,    32,    72,
+      29,     8,    27,    37,    38,    39,    40,    41,    80,     8,
+       8,   189,    23,    24,    28,   231,   160,     4,    39,     6,
+      21,    22,   236,    69,    21,    22,    31,    99,   467,   201,
+      66,    50,    50,   387,    67,    78,     5,    29,    10,   121,
+     199,   135,   201,    21,    22,    29,    28,   231,    61,    30,
+      86,    65,   146,   121,   493,    60,   200,    21,    22,    21,
+      22,    10,    11,    12,    13,    14,    15,    16,    17,    18,
+      19,   105,    21,    22,   140,    71,    58,   143,   121,   118,
+      94,    95,   154,   117,   118,     0,   120,   231,   122,   443,
+     162,    36,   114,    37,   106,    61,    40,    41,   276,   145,
+     112,   134,   136,   137,   176,   321,   127,    71,   142,   128,
+     128,   325,   126,   186,   273,   122,   145,   145,   380,   144,
+      92,   134,   144,   144,   283,   284,   160,   114,    77,   201,
+     144,   165,   426,   125,   144,   144,   147,   321,   172,   364,
+     212,   175,   404,   215,   145,   407,   145,   145,   145,   118,
+     119,   295,   185,   137,    10,   189,   134,   191,   192,   193,
+     122,   386,   387,    53,    46,    47,   338,    45,   134,    83,
+     341,    74,   116,    71,   436,   247,   121,   321,     3,   338,
+     351,   253,   115,     4,    48,     6,    76,     0,   146,    45,
+     114,     4,    70,    17,    18,    19,   145,   231,   232,    55,
+      90,    91,   236,   106,    72,     4,    33,     6,   132,   144,
+     161,    79,    33,    26,   114,   399,    80,   251,   443,    87,
+     144,   255,   294,   113,   296,   103,   177,   125,    83,   140,
+     302,   142,   104,   405,   378,   137,    92,   309,   272,   273,
+      53,   109,   276,   414,   415,     5,   405,   103,   138,    95,
+     114,   129,   108,    77,   135,   399,   144,    72,   430,    46,
+      47,   420,   334,     9,    79,    21,    22,   144,     9,    84,
+      82,   430,    87,   129,   313,    21,    22,   145,    34,   313,
+      21,    22,   145,   146,   145,   146,     7,   321,   145,   146,
+       7,   325,    21,    22,   109,   145,   146,     4,     5,     6,
+       7,    57,     4,   144,     6,   377,     5,   341,   380,   343,
+     482,   145,   146,   144,    21,    22,    23,   351,   390,    21,
+      22,   144,     5,   482,    82,   145,   146,   146,    35,    36,
+      98,    33,   404,   367,   144,   407,    43,    44,   145,   146,
+     145,   146,   145,   146,    51,    52,    71,    54,   145,   146,
+       7,    58,    59,   145,   146,   145,   146,    64,   144,   144,
+      67,   145,   146,   534,   436,   399,   438,   145,   146,   145,
+     146,   542,   145,   146,    81,    82,     1,     7,     3,     7,
+     414,   415,    89,   144,   456,    92,   420,    10,    11,    12,
+      13,    14,    15,    16,    17,    18,    19,    11,    21,    22,
+     107,   145,   146,   475,     8,   145,   146,    32,   145,   146,
+     117,   483,     9,   120,   145,   146,   123,   124,    20,   146,
+      62,   145,    71,    48,    49,   145,   133,   146,    73,    99,
+     145,    56,   139,   467,   144,    60,   508,   144,   145,    85,
+     474,    85,   131,   144,     4,     5,     6,     7,   144,   144,
+      10,   132,    62,     7,    77,    80,    97,    97,    97,   493,
+      84,    21,    22,     7,     7,    42,    75,    42,   145,    96,
+     504,   144,   144,   137,    27,    35,    36,   146,   144,    92,
+     105,   144,   516,    43,    44,    85,    92,    42,   144,   114,
+     101,    51,    52,   101,    54,    96,   144,    38,     7,    59,
+     534,    99,    95,    63,    64,   130,   144,    67,   542,   146,
+      42,    19,   137,   144,    88,   140,    42,     7,   136,   145,
+     108,    81,    82,    93,   146,   145,   102,   110,     9,    89,
+     102,    33,    92,    68,    68,     4,     5,     6,     7,   144,
+       7,    10,   110,   100,   198,   144,   251,   107,   144,   343,
+     145,    55,    21,    22,   114,   118,   370,   117,   124,    56,
+     120,   399,   483,   123,   124,   506,    35,    36,   162,   544,
+     508,   283,   153,   133,    43,    44,   284,   166,   199,   139,
+     171,   213,    51,    52,   144,    54,   115,   148,    -1,    -1,
+      59,    -1,    -1,    -1,    63,    64,   213,    -1,    67,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
       -1,    -1,    81,    82,    -1,    -1,    -1,    -1,    -1,    -1,
       89,    -1,    -1,    92,    -1,    -1,     4,     5,     6,     7,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   107,    -1,
-      -1,    -1,    -1,    21,    22,   114,    -1,    -1,   117,    -1,
+      -1,    -1,    -1,    21,    22,    23,    -1,    -1,   117,    -1,
       -1,   120,    -1,    -1,   123,   124,    -1,    35,    36,    -1,
       -1,    -1,    -1,    -1,   133,    43,    44,    -1,    -1,    -1,
      139,    -1,    -1,    51,    52,   144,    54,    -1,    -1,    -1,
-      -1,    59,    -1,    -1,    -1,    63,    64,    -1,    -1,    67,
+      -1,    59,    -1,    -1,    -1,    -1,    64,    -1,    -1,    67,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
       -1,    -1,    -1,    81,    82,    -1,    -1,    -1,    -1,    -1,
       -1,    89,    -1,    -1,    92,    -1,    -1,     4,     5,     6,
@@ -1344,29 +1310,56 @@ static const yytype_int16 yycheck[] =
       -1,    -1,    59,    -1,    -1,    -1,    -1,    64,    -1,    -1,
       67,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
       -1,    -1,    -1,    -1,    81,    82,    -1,    -1,    -1,    -1,
-      -1,    -1,    89,    -1,    -1,    92,    -1,    -1,     4,     5,
-       6,     7,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-     107,    -1,    -1,    -1,    -1,    21,    22,    -1,    -1,    -1,
-     117,    -1,    -1,   120,    -1,    -1,   123,   124,    -1,    35,
-      36,    -1,    -1,    -1,    -1,    -1,   133,    43,    44,    -1,
-      -1,    -1,   139,    -1,    -1,    51,    52,   144,    54,    -1,
-      -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    64,    -1,
-      -1,    67,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    81,    82,     5,    -1,     7,
-      -1,    -1,    -1,    89,    -1,    -1,    92,    -1,    -1,    -1,
-      -1,    -1,    -1,    21,    22,    -1,    35,    36,    -1,    -1,
-      -1,   107,    -1,    -1,    -1,    44,    -1,    35,    36,    -1,
-      -1,   117,    51,    52,   120,    54,    44,   123,   124,    -1,
-      59,    -1,    -1,    51,    52,    -1,    54,   133,    67,    -1,
-      -1,    59,    -1,   139,    -1,    -1,    -1,    -1,   144,    67,
-      -1,    -1,    81,    82,    -1,    -1,    -1,    -1,    -1,    -1,
-      89,    -1,    -1,    81,    82,    -1,    -1,    -1,    -1,    -1,
-      -1,    89,    -1,    -1,    92,    -1,    -1,    -1,   107,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   117,   107,
-      -1,    -1,    -1,    -1,   123,   124,    -1,    -1,    -1,   117,
-      -1,    -1,    -1,    -1,   133,   123,   124,    -1,    -1,    -1,
-     139,    -1,    -1,    -1,    -1,   133,    -1,    -1,    -1,    -1,
-      -1,   139
+      -1,    -1,    89,    -1,    -1,    92,    -1,    -1,    -1,    -1,
+      -1,     4,     5,     6,     7,    -1,    -1,    -1,    -1,    -1,
+     107,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    21,    22,
+     117,    -1,    -1,   120,    -1,    -1,   123,   124,    -1,    -1,
+      -1,    -1,    35,    36,    -1,    -1,   133,   134,    -1,    -1,
+      43,    44,   139,    -1,    -1,    -1,    -1,   144,    51,    52,
+      -1,    54,    -1,    -1,    -1,    -1,    59,    -1,    -1,    -1,
+      -1,    64,    -1,    -1,    67,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    81,    82,
+      -1,    -1,    -1,    -1,    -1,    -1,    89,    -1,    -1,    92,
+      -1,    -1,     4,     5,     6,     7,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,   107,    -1,    -1,    -1,    -1,    21,
+      22,   114,    -1,    -1,   117,    -1,    -1,   120,    -1,    -1,
+     123,   124,    -1,    35,    36,    -1,    -1,    -1,    -1,    -1,
+     133,    43,    44,    -1,    -1,    -1,   139,    -1,    -1,    51,
+      52,   144,    54,    -1,    -1,    -1,    -1,    59,    -1,    -1,
+      -1,    63,    64,    -1,    -1,    67,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    81,
+      82,    -1,    -1,    -1,    -1,    -1,    -1,    89,    -1,    -1,
+      92,    -1,    -1,     4,     5,     6,     7,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,   107,    -1,    -1,    -1,    -1,
+      21,    22,    -1,    -1,    -1,   117,    -1,    -1,   120,    -1,
+      -1,   123,   124,    -1,    35,    36,    -1,    -1,    -1,    -1,
+      -1,   133,    43,    44,    -1,    -1,    -1,   139,    -1,    -1,
+      51,    52,   144,    54,    -1,    -1,    -1,    -1,    59,    -1,
+      -1,    -1,    -1,    64,    -1,    -1,    67,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      81,    82,    -1,    -1,    -1,    -1,    -1,    -1,    89,    -1,
+      -1,    92,    -1,    -1,     4,     5,     6,     7,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,   107,    -1,    -1,    -1,
+      -1,    21,    22,    -1,    -1,    -1,   117,    -1,    -1,   120,
+      -1,    -1,   123,   124,    -1,    35,    36,    -1,    -1,    -1,
+      -1,    -1,   133,    43,    44,    -1,    -1,    -1,   139,    -1,
+      -1,    51,    52,   144,    54,    -1,    -1,    -1,    -1,    59,
+      -1,    -1,    -1,    -1,    64,    -1,    -1,    67,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    81,    82,     5,    -1,     7,    -1,    -1,    -1,    89,
+      -1,    -1,    92,    -1,    -1,    -1,    -1,    -1,    -1,    21,
+      22,    -1,    35,    36,    -1,    -1,    -1,   107,    -1,    -1,
+      -1,    44,    -1,    35,    36,    -1,    -1,   117,    51,    52,
+     120,    54,    44,   123,   124,    -1,    59,    -1,    -1,    51,
+      52,    -1,    54,   133,    67,    -1,    -1,    59,    -1,   139,
+      -1,    -1,    -1,    -1,   144,    67,    -1,    -1,    81,    82,
+      -1,    -1,    -1,    -1,    -1,    -1,    89,    -1,    -1,    81,
+      82,    -1,    -1,    -1,    -1,    -1,    -1,    89,    -1,    -1,
+      92,    -1,    -1,    -1,   107,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,   117,   107,    -1,    -1,    -1,    -1,
+     123,   124,    -1,    -1,    -1,   117,    -1,    -1,    -1,    -1,
+     133,   123,   124,    -1,    -1,    -1,   139,    -1,    -1,    -1,
+      -1,   133,    -1,    -1,    -1,    -1,    -1,   139
 };
 
   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -1376,58 +1369,59 @@ static const yytype_uint16 yystos[] =
        0,     1,     3,    32,    48,    49,    56,    60,    80,   105,
      114,   130,   137,   140,   149,   150,   151,   152,   153,   154,
      155,   177,   178,   181,   182,   185,   187,   190,   191,   192,
-     256,   257,   121,     4,     6,   190,   254,    78,   121,    71,
-     121,    83,    28,    58,   193,   254,   188,   189,   204,   254,
+     257,   258,   121,     4,     6,   190,   255,    78,   121,    71,
+     121,    83,    28,    58,   193,   255,   188,   189,   204,   255,
        0,   140,   142,    48,    80,   190,    29,   137,   186,    30,
-     140,   143,     3,   254,   125,   179,    71,   179,   254,   254,
-     254,   254,   254,     5,     7,    21,    22,    23,    35,    36,
+     140,   143,     3,   255,   125,   179,    71,   179,   255,   255,
+     255,   255,   255,     5,     7,    21,    22,    23,    35,    36,
       43,    44,    51,    52,    54,    59,    64,    67,    81,    82,
       89,    92,   107,   117,   120,   123,   124,   133,   139,   144,
      158,   194,   195,   196,   198,   230,   231,   232,   233,   234,
-     235,   236,   237,   244,   247,   250,   254,   115,   146,    33,
+     235,   236,   237,   244,   248,   251,   255,   115,   146,    33,
      144,   190,    83,   186,   193,   104,   192,    31,    60,     5,
      118,   119,   137,   180,     5,   180,    95,   144,   135,   224,
      225,   132,   144,   192,     7,     7,   134,   230,   240,   241,
      144,    82,   144,     5,   144,   144,    82,   190,   230,     5,
-      71,   197,   146,    21,    22,    33,   251,   254,    23,    24,
-     147,   252,    98,    22,   233,    27,   144,   183,   184,   254,
-     189,   144,   198,   253,   254,   179,   254,   191,     7,    46,
-      47,    46,    47,   144,   180,   254,   156,   157,   254,    10,
-      63,   144,   226,   227,   228,   229,   230,   247,   144,   253,
-     226,   134,   238,   239,    61,   241,   242,     7,    53,    76,
-      90,    91,   113,   138,   245,   245,   230,     7,   145,   145,
-     144,   198,   201,   202,   205,   234,   254,   224,   196,   254,
-     231,   232,   144,   254,   254,    23,    58,   145,   230,   243,
-     146,   224,    11,   145,   146,   180,   192,   156,    45,    70,
-     103,   129,   162,   254,   254,   169,   170,   171,   172,   173,
-     174,   254,   144,   165,   145,   146,    82,   158,   229,   198,
-     226,   230,     8,     9,    10,    11,    12,    13,    14,    15,
-      16,    17,    18,    19,    77,   249,    20,   244,   246,   145,
-     122,   230,   239,   242,   230,    62,   145,    71,    71,   145,
-     201,    33,   203,   204,    72,    79,    87,   109,   200,   146,
-     203,    39,   127,   199,    73,   206,    99,   213,   214,   145,
-     243,   145,   146,   184,   230,   254,   144,    85,    85,   144,
-     145,   146,     5,     7,    28,    65,    94,    95,   126,   144,
-     254,   255,   247,   248,   254,   131,   162,   163,   164,   156,
-      10,    45,    55,    92,   103,   108,   129,   159,   160,   161,
-     145,   227,   228,    17,    18,    19,    77,   230,   144,   198,
-     230,    10,    92,   145,   146,   132,   230,   122,    62,   230,
-       7,   145,   204,    97,    97,    97,    84,   201,     7,     7,
-     203,    42,    75,   207,    42,   145,    96,   215,   145,   230,
-     226,   144,   144,   253,   170,   253,   145,   146,    37,    40,
-      41,   116,   175,   146,   137,   166,    92,   144,   244,    85,
-     254,   159,   230,   144,   198,     9,   243,    92,   244,   144,
-     230,   145,    69,   145,   202,   101,   101,   243,   226,    96,
-     208,   243,    42,   106,   112,   216,   217,   145,   253,   253,
-     145,   145,   247,   144,   176,   162,    38,    99,   167,   226,
-     144,     9,   243,   230,   145,   246,     7,    95,    42,    88,
-     209,   220,   221,   230,    19,   145,   145,   169,   144,    42,
-     145,   254,   230,   145,   145,   145,   226,   220,     7,   136,
-     210,   211,   212,   146,    34,    57,   222,     7,    50,   128,
-     218,   108,   145,   169,    74,   106,   168,   145,   254,   212,
-     221,    93,   223,   102,   110,   102,     9,   254,   145,   144,
-      33,    66,    86,     7,    50,   128,   219,   144,   253,   144,
-      68,   110,    68,   253,   145,   213,   145,   100,   145,     7
+      71,   197,   146,    21,    22,    33,   252,   255,    23,    24,
+     147,   253,    98,    22,   233,    27,   144,   183,   184,   255,
+     189,   144,   198,   254,   255,   179,   255,   191,     7,    46,
+      47,    46,    47,   144,   180,   255,   156,   157,   255,    10,
+      63,   144,   226,   227,   228,   229,   230,   248,   144,   247,
+     254,   226,   134,   238,   239,    61,   241,   242,     7,    53,
+      76,    90,    91,   113,   138,   245,   245,   230,     7,   145,
+     145,   144,   198,   201,   202,   205,   234,   255,   224,   196,
+     255,   231,   232,   144,   255,   255,    23,    58,   145,   230,
+     243,   146,   224,    11,   145,   146,   180,   192,   156,    45,
+      70,   103,   129,   162,   255,   255,   169,   170,   171,   172,
+     173,   174,   255,   144,   165,   145,   146,    82,   158,   229,
+     198,   226,   230,     8,     9,    10,    11,    12,    13,    14,
+      15,    16,    17,    18,    19,    77,   250,    20,   244,   246,
+     146,   145,   122,   230,   239,   242,   230,    62,   145,    71,
+      71,   145,   201,    33,   203,   204,    72,    79,    87,   109,
+     200,   146,   203,    39,   127,   199,    73,   206,    99,   213,
+     214,   145,   243,   145,   146,   184,   230,   255,   144,    85,
+      85,   144,   145,   146,     5,     7,    28,    65,    94,    95,
+     126,   144,   255,   256,   248,   249,   255,   131,   162,   163,
+     164,   156,    10,    45,    55,    92,   103,   108,   129,   159,
+     160,   161,   145,   227,   228,    17,    18,    19,    77,   230,
+     144,   198,   230,    10,    92,   145,   146,   144,   132,   230,
+     122,    62,   230,     7,   145,   204,    97,    97,    97,    84,
+     201,     7,     7,   203,    42,    75,   207,    42,   145,    96,
+     215,   145,   230,   226,   144,   144,   254,   170,   254,   145,
+     146,    37,    40,    41,   116,   175,   146,   137,   166,    92,
+     144,   244,    85,   255,   159,   230,   144,   198,     9,   243,
+      92,   244,   246,   144,   230,   145,    69,   145,   202,   101,
+     101,   243,   226,    96,   208,   243,    42,   106,   112,   216,
+     217,   145,   254,   254,   145,   145,   248,   144,   176,   162,
+      38,    99,   167,   226,   144,     9,   243,   230,   145,   145,
+     246,     7,    95,    42,    88,   209,   220,   221,   230,    19,
+     145,   145,   169,   144,    42,   145,   255,   230,   145,   145,
+     145,   226,   220,     7,   136,   210,   211,   212,   146,    34,
+      57,   222,     7,    50,   128,   218,   108,   145,   169,    74,
+     106,   168,   145,   255,   212,   221,    93,   223,   102,   110,
+     102,     9,   255,   145,   144,    33,    66,    86,     7,    50,
+     128,   219,   144,   254,   144,    68,   110,    68,   254,   145,
+     213,   145,   100,   145,     7
 };
 
   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
@@ -1460,9 +1454,10 @@ static const yytype_uint16 yyr1[] =
      237,   237,   238,   238,   239,   240,   240,   241,   242,   242,
      243,   243,   244,   244,   244,   244,   244,   244,   244,   244,
      245,   245,   245,   245,   245,   245,   246,   246,   247,   247,
-     248,   248,   249,   249,   249,   249,   249,   249,   249,   249,
-     249,   249,   250,   251,   251,   252,   252,   252,   253,   253,
-     254,   254,   255,   255,   255,   255,   256,   257,   257
+     248,   248,   249,   249,   250,   250,   250,   250,   250,   250,
+     250,   250,   250,   250,   251,   252,   252,   253,   253,   253,
+     254,   254,   255,   255,   256,   256,   256,   256,   257,   258,
+     258
 };
 
   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
@@ -1477,7 +1472,7 @@ static const yytype_uint8 yyr2[] =
       10,     4,     3,     1,     0,     1,     0,     3,     0,     5,
        0,     8,     1,     1,     1,     3,     1,     1,     1,     1,
        2,     2,     2,     4,     2,     2,     1,     1,     1,     1,
-       0,     3,    10,     7,     4,     5,     5,     4,     4,     5,
+       0,     3,    10,     5,     4,     5,     5,     4,     4,     5,
        2,     2,     2,     0,     4,     5,     4,     3,     1,     3,
        2,     3,     0,     3,     2,     1,     3,     3,     4,     1,
        3,     1,    10,     0,     1,     1,     1,     1,     1,     3,
@@ -1494,10 +1489,11 @@ static const yytype_uint8 yyr2[] =
        1,     3,     1,     3,     4,     4,     5,     6,     6,     8,
        5,     4,     1,     2,     4,     1,     2,     4,     0,     2,
        1,     3,     1,     1,     2,     2,     1,     2,     3,     2,
-       1,     1,     1,     1,     1,     1,     1,     3,     1,     3,
-       1,     3,     1,     1,     1,     1,     1,     1,     1,     2,
-       1,     2,     1,     1,     1,     1,     1,     1,     1,     3,
-       1,     1,     1,     1,     1,     1,     2,     2,     0
+       1,     1,     1,     1,     1,     1,     1,     3,     3,     5,
+       1,     3,     1,     3,     1,     1,     1,     1,     1,     1,
+       1,     2,     1,     2,     1,     1,     1,     1,     1,     1,
+       1,     3,     1,     1,     1,     1,     1,     1,     2,     2,
+       0
 };
 
 
@@ -1994,1071 +1990,1081 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio
   switch (yytype)
     {
           case 3: /* TOKEN_COMMAND  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2004 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2000 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 4: /* TOKEN_NAME  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2014 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2010 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 5: /* TOKEN_STRING_SINGLE_QUOTED  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2024 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2020 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 6: /* TOKEN_STRING_DOUBLE_QUOTED  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2034 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2030 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 7: /* TOKEN_UNSIGNED_NUMVAL  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).numeric_literal_value_) != nullptr) {
     delete ((*yyvaluep).numeric_literal_value_);
   }
 }
-#line 2044 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2040 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 150: /* sql_statement  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 2054 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2050 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 151: /* quit_statement  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).quit_statement_) != nullptr) {
     delete ((*yyvaluep).quit_statement_);
   }
 }
-#line 2064 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2060 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 152: /* alter_table_statement  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 2074 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2070 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 153: /* create_table_statement  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).create_table_statement_) != nullptr) {
     delete ((*yyvaluep).create_table_statement_);
   }
 }
-#line 2084 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2080 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 154: /* create_index_statement  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 2094 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2090 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 155: /* drop_table_statement  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).drop_table_statement_) != nullptr) {
     delete ((*yyvaluep).drop_table_statement_);
   }
 }
-#line 2104 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2100 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 156: /* column_def  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_definition_) != nullptr) {
     delete ((*yyvaluep).attribute_definition_);
   }
 }
-#line 2114 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2110 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 157: /* column_def_commalist  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_definition_list_) != nullptr) {
     delete ((*yyvaluep).attribute_definition_list_);
   }
 }
-#line 2124 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2120 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 158: /* data_type  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).data_type_) != nullptr) {
     delete ((*yyvaluep).data_type_);
   }
 }
-#line 2134 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2130 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 159: /* column_constraint_def  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_) != nullptr) {
     delete ((*yyvaluep).column_constraint_);
   }
 }
-#line 2144 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2140 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 160: /* column_constraint_def_list  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_list_) != nullptr) {
     delete ((*yyvaluep).column_constraint_list_);
   }
 }
-#line 2154 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2150 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 161: /* opt_column_constraint_def_list  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_list_) != nullptr) {
     delete ((*yyvaluep).column_constraint_list_);
   }
 }
-#line 2164 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2160 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 165: /* opt_column_list  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_list_) != nullptr) {
     delete ((*yyvaluep).attribute_list_);
   }
 }
-#line 2174 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2170 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 166: /* opt_block_properties  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).block_properties_) != nullptr) {
     delete ((*yyvaluep).block_properties_);
   }
 }
-#line 2184 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2180 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 167: /* opt_partition_clause  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).partition_clause_) != nullptr) {
     delete ((*yyvaluep).partition_clause_);
   }
 }
-#line 2194 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2190 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 168: /* partition_type  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2204 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2200 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 169: /* key_value_list  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_list_) != nullptr) {
     delete ((*yyvaluep).key_value_list_);
   }
 }
-#line 2214 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2210 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 170: /* key_value  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_) != nullptr) {
     delete ((*yyvaluep).key_value_);
   }
 }
-#line 2224 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2220 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 171: /* key_string_value  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_string_value_) != nullptr) {
     delete ((*yyvaluep).key_string_value_);
   }
 }
-#line 2234 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2230 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 172: /* key_string_list  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_string_list_) != nullptr) {
     delete ((*yyvaluep).key_string_list_);
   }
 }
-#line 2244 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2240 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 173: /* key_integer_value  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_integer_value_) != nullptr) {
     delete ((*yyvaluep).key_integer_value_);
   }
 }
-#line 2254 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2250 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 174: /* key_bool_value  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_bool_value_) != nullptr) {
     delete ((*yyvaluep).key_bool_value_);
   }
 }
-#line 2264 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2260 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 175: /* index_type  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2274 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2270 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 176: /* opt_index_properties  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_list_) != nullptr) {
     delete ((*yyvaluep).key_value_list_);
   }
 }
-#line 2284 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2280 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 177: /* insert_statement  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).insert_statement_) != nullptr) {
     delete ((*yyvaluep).insert_statement_);
   }
 }
-#line 2294 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2290 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 178: /* copy_statement  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).copy_statement_) != nullptr) {
     delete ((*yyvaluep).copy_statement_);
   }
 }
-#line 2304 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2300 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 179: /* copy_to_target  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2314 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2310 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 180: /* opt_copy_params  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_list_) != nullptr) {
     delete ((*yyvaluep).key_value_list_);
   }
 }
-#line 2324 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2320 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 181: /* update_statement  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).update_statement_) != nullptr) {
     delete ((*yyvaluep).update_statement_);
   }
 }
-#line 2334 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2330 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 182: /* delete_statement  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).delete_statement_) != nullptr) {
     delete ((*yyvaluep).delete_statement_);
   }
 }
-#line 2344 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2340 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 183: /* assignment_list  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).assignment_list_) != nullptr) {
     delete ((*yyvaluep).assignment_list_);
   }
 }
-#line 2354 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2350 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 184: /* assignment_item  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).assignment_) != nullptr) {
     delete ((*yyvaluep).assignment_);
   }
 }
-#line 2364 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2360 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 185: /* set_operation_statement  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).set_operation_statement_) != nullptr) {
     delete ((*yyvaluep).set_operation_statement_);
   }
 }
-#line 2374 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2370 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 186: /* opt_priority_clause  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).opt_priority_clause_) != nullptr) {
     delete ((*yyvaluep).opt_priority_clause_);
   }
 }
-#line 2384 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2380 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 187: /* with_clause  */
-#line 631 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 635 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).with_list_) != nullptr) {
     delete ((*yyvalu

<TRUNCATED>


[36/46] incubator-quickstep git commit: Remove glog source code from third party

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/base/mutex.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/base/mutex.h b/third_party/src/glog/src/base/mutex.h
deleted file mode 100644
index 37527d5..0000000
--- a/third_party/src/glog/src/base/mutex.h
+++ /dev/null
@@ -1,331 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-// 
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// 
-// ---
-// Author: Craig Silverstein.
-//
-// A simple mutex wrapper, supporting locks and read-write locks.
-// You should assume the locks are *not* re-entrant.
-//
-// To use: you should define the following macros in your configure.ac:
-//   ACX_PTHREAD
-//   AC_RWLOCK
-// The latter is defined in ../autoconf.
-//
-// This class is meant to be internal-only and should be wrapped by an
-// internal namespace.  Before you use this module, please give the
-// name of your internal namespace for this module.  Or, if you want
-// to expose it, you'll want to move it to the Google namespace.  We
-// cannot put this class in global namespace because there can be some
-// problems when we have multiple versions of Mutex in each shared object.
-//
-// NOTE: by default, we have #ifdef'ed out the TryLock() method.
-//       This is for two reasons:
-// 1) TryLock() under Windows is a bit annoying (it requires a
-//    #define to be defined very early).
-// 2) TryLock() is broken for NO_THREADS mode, at least in NDEBUG
-//    mode.
-// If you need TryLock(), and either these two caveats are not a
-// problem for you, or you're willing to work around them, then
-// feel free to #define GMUTEX_TRYLOCK, or to remove the #ifdefs
-// in the code below.
-//
-// CYGWIN NOTE: Cygwin support for rwlock seems to be buggy:
-//    http://www.cygwin.com/ml/cygwin/2008-12/msg00017.html
-// Because of that, we might as well use windows locks for
-// cygwin.  They seem to be more reliable than the cygwin pthreads layer.
-//
-// TRICKY IMPLEMENTATION NOTE:
-// This class is designed to be safe to use during
-// dynamic-initialization -- that is, by global constructors that are
-// run before main() starts.  The issue in this case is that
-// dynamic-initialization happens in an unpredictable order, and it
-// could be that someone else's dynamic initializer could call a
-// function that tries to acquire this mutex -- but that all happens
-// before this mutex's constructor has run.  (This can happen even if
-// the mutex and the function that uses the mutex are in the same .cc
-// file.)  Basically, because Mutex does non-trivial work in its
-// constructor, it's not, in the naive implementation, safe to use
-// before dynamic initialization has run on it.
-//
-// The solution used here is to pair the actual mutex primitive with a
-// bool that is set to true when the mutex is dynamically initialized.
-// (Before that it's false.)  Then we modify all mutex routines to
-// look at the bool, and not try to lock/unlock until the bool makes
-// it to true (which happens after the Mutex constructor has run.)
-//
-// This works because before main() starts -- particularly, during
-// dynamic initialization -- there are no threads, so a) it's ok that
-// the mutex operations are a no-op, since we don't need locking then
-// anyway; and b) we can be quite confident our bool won't change
-// state between a call to Lock() and a call to Unlock() (that would
-// require a global constructor in one translation unit to call Lock()
-// and another global constructor in another translation unit to call
-// Unlock() later, which is pretty perverse).
-//
-// That said, it's tricky, and can conceivably fail; it's safest to
-// avoid trying to acquire a mutex in a global constructor, if you
-// can.  One way it can fail is that a really smart compiler might
-// initialize the bool to true at static-initialization time (too
-// early) rather than at dynamic-initialization time.  To discourage
-// that, we set is_safe_ to true in code (not the constructor
-// colon-initializer) and set it to true via a function that always
-// evaluates to true, but that the compiler can't know always
-// evaluates to true.  This should be good enough.
-
-#ifndef GOOGLE_MUTEX_H_
-#define GOOGLE_MUTEX_H_
-
-#include "config.h"           // to figure out pthreads support
-
-#if defined(NO_THREADS)
-  typedef int MutexType;      // to keep a lock-count
-#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
-# ifndef WIN32_LEAN_AND_MEAN
-#  define WIN32_LEAN_AND_MEAN  // We only need minimal includes
-# endif
-# ifdef GMUTEX_TRYLOCK
-  // We need Windows NT or later for TryEnterCriticalSection().  If you
-  // don't need that functionality, you can remove these _WIN32_WINNT
-  // lines, and change TryLock() to assert(0) or something.
-#   ifndef _WIN32_WINNT
-#     define _WIN32_WINNT 0x0400
-#   endif
-# endif
-// To avoid macro definition of ERROR.
-# ifndef NOGDI
-#  define NOGDI
-# endif
-// To avoid macro definition of min/max.
-# ifndef NOMINMAX
-#  define NOMINMAX
-# endif
-# include <windows.h>
-  typedef CRITICAL_SECTION MutexType;
-#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
-  // Needed for pthread_rwlock_*.  If it causes problems, you could take it
-  // out, but then you'd have to unset HAVE_RWLOCK (at least on linux -- it
-  // *does* cause problems for FreeBSD, or MacOSX, but isn't needed
-  // for locking there.)
-# ifdef __linux__
-#   define _XOPEN_SOURCE 500  // may be needed to get the rwlock calls
-# endif
-# include <pthread.h>
-  typedef pthread_rwlock_t MutexType;
-#elif defined(HAVE_PTHREAD)
-# include <pthread.h>
-  typedef pthread_mutex_t MutexType;
-#else
-# error Need to implement mutex.h for your architecture, or #define NO_THREADS
-#endif
-
-// We need to include these header files after defining _XOPEN_SOURCE
-// as they may define the _XOPEN_SOURCE macro.
-#include <assert.h>
-#include <stdlib.h>      // for abort()
-
-#define MUTEX_NAMESPACE glog_internal_namespace_
-
-namespace MUTEX_NAMESPACE {
-
-class Mutex {
- public:
-  // Create a Mutex that is not held by anybody.  This constructor is
-  // typically used for Mutexes allocated on the heap or the stack.
-  // See below for a recommendation for constructing global Mutex
-  // objects.
-  inline Mutex();
-
-  // Destructor
-  inline ~Mutex();
-
-  inline void Lock();    // Block if needed until free then acquire exclusively
-  inline void Unlock();  // Release a lock acquired via Lock()
-#ifdef GMUTEX_TRYLOCK
-  inline bool TryLock(); // If free, Lock() and return true, else return false
-#endif
-  // Note that on systems that don't support read-write locks, these may
-  // be implemented as synonyms to Lock() and Unlock().  So you can use
-  // these for efficiency, but don't use them anyplace where being able
-  // to do shared reads is necessary to avoid deadlock.
-  inline void ReaderLock();   // Block until free or shared then acquire a share
-  inline void ReaderUnlock(); // Release a read share of this Mutex
-  inline void WriterLock() { Lock(); }     // Acquire an exclusive lock
-  inline void WriterUnlock() { Unlock(); } // Release a lock from WriterLock()
-
-  // TODO(hamaji): Do nothing, implement correctly.
-  inline void AssertHeld() {}
-
- private:
-  MutexType mutex_;
-  // We want to make sure that the compiler sets is_safe_ to true only
-  // when we tell it to, and never makes assumptions is_safe_ is
-  // always true.  volatile is the most reliable way to do that.
-  volatile bool is_safe_;
-
-  inline void SetIsSafe() { is_safe_ = true; }
-
-  // Catch the error of writing Mutex when intending MutexLock.
-  Mutex(Mutex* /*ignored*/) {}
-  // Disallow "evil" constructors
-  Mutex(const Mutex&);
-  void operator=(const Mutex&);
-};
-
-// Now the implementation of Mutex for various systems
-#if defined(NO_THREADS)
-
-// When we don't have threads, we can be either reading or writing,
-// but not both.  We can have lots of readers at once (in no-threads
-// mode, that's most likely to happen in recursive function calls),
-// but only one writer.  We represent this by having mutex_ be -1 when
-// writing and a number > 0 when reading (and 0 when no lock is held).
-//
-// In debug mode, we assert these invariants, while in non-debug mode
-// we do nothing, for efficiency.  That's why everything is in an
-// assert.
-
-Mutex::Mutex() : mutex_(0) { }
-Mutex::~Mutex()            { assert(mutex_ == 0); }
-void Mutex::Lock()         { assert(--mutex_ == -1); }
-void Mutex::Unlock()       { assert(mutex_++ == -1); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { if (mutex_) return false; Lock(); return true; }
-#endif
-void Mutex::ReaderLock()   { assert(++mutex_ > 0); }
-void Mutex::ReaderUnlock() { assert(mutex_-- > 0); }
-
-#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
-
-Mutex::Mutex()             { InitializeCriticalSection(&mutex_); SetIsSafe(); }
-Mutex::~Mutex()            { DeleteCriticalSection(&mutex_); }
-void Mutex::Lock()         { if (is_safe_) EnterCriticalSection(&mutex_); }
-void Mutex::Unlock()       { if (is_safe_) LeaveCriticalSection(&mutex_); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { return is_safe_ ?
-                                 TryEnterCriticalSection(&mutex_) != 0 : true; }
-#endif
-void Mutex::ReaderLock()   { Lock(); }      // we don't have read-write locks
-void Mutex::ReaderUnlock() { Unlock(); }
-
-#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
-
-#define SAFE_PTHREAD(fncall)  do {   /* run fncall if is_safe_ is true */  \
-  if (is_safe_ && fncall(&mutex_) != 0) abort();                           \
-} while (0)
-
-Mutex::Mutex() {
-  SetIsSafe();
-  if (is_safe_ && pthread_rwlock_init(&mutex_, NULL) != 0) abort();
-}
-Mutex::~Mutex()            { SAFE_PTHREAD(pthread_rwlock_destroy); }
-void Mutex::Lock()         { SAFE_PTHREAD(pthread_rwlock_wrlock); }
-void Mutex::Unlock()       { SAFE_PTHREAD(pthread_rwlock_unlock); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { return is_safe_ ?
-                                    pthread_rwlock_trywrlock(&mutex_) == 0 :
-                                    true; }
-#endif
-void Mutex::ReaderLock()   { SAFE_PTHREAD(pthread_rwlock_rdlock); }
-void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock); }
-#undef SAFE_PTHREAD
-
-#elif defined(HAVE_PTHREAD)
-
-#define SAFE_PTHREAD(fncall)  do {   /* run fncall if is_safe_ is true */  \
-  if (is_safe_ && fncall(&mutex_) != 0) abort();                           \
-} while (0)
-
-Mutex::Mutex()             {
-  SetIsSafe();
-  if (is_safe_ && pthread_mutex_init(&mutex_, NULL) != 0) abort();
-}
-Mutex::~Mutex()            { SAFE_PTHREAD(pthread_mutex_destroy); }
-void Mutex::Lock()         { SAFE_PTHREAD(pthread_mutex_lock); }
-void Mutex::Unlock()       { SAFE_PTHREAD(pthread_mutex_unlock); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { return is_safe_ ?
-                                 pthread_mutex_trylock(&mutex_) == 0 : true; }
-#endif
-void Mutex::ReaderLock()   { Lock(); }
-void Mutex::ReaderUnlock() { Unlock(); }
-#undef SAFE_PTHREAD
-
-#endif
-
-// --------------------------------------------------------------------------
-// Some helper classes
-
-// MutexLock(mu) acquires mu when constructed and releases it when destroyed.
-class MutexLock {
- public:
-  explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); }
-  ~MutexLock() { mu_->Unlock(); }
- private:
-  Mutex * const mu_;
-  // Disallow "evil" constructors
-  MutexLock(const MutexLock&);
-  void operator=(const MutexLock&);
-};
-
-// ReaderMutexLock and WriterMutexLock do the same, for rwlocks
-class ReaderMutexLock {
- public:
-  explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); }
-  ~ReaderMutexLock() { mu_->ReaderUnlock(); }
- private:
-  Mutex * const mu_;
-  // Disallow "evil" constructors
-  ReaderMutexLock(const ReaderMutexLock&);
-  void operator=(const ReaderMutexLock&);
-};
-
-class WriterMutexLock {
- public:
-  explicit WriterMutexLock(Mutex *mu) : mu_(mu) { mu_->WriterLock(); }
-  ~WriterMutexLock() { mu_->WriterUnlock(); }
- private:
-  Mutex * const mu_;
-  // Disallow "evil" constructors
-  WriterMutexLock(const WriterMutexLock&);
-  void operator=(const WriterMutexLock&);
-};
-
-// Catch bug where variable name is omitted, e.g. MutexLock (&mu);
-#define MutexLock(x) COMPILE_ASSERT(0, mutex_lock_decl_missing_var_name)
-#define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name)
-#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name)
-
-}  // namespace MUTEX_NAMESPACE
-
-using namespace MUTEX_NAMESPACE;
-
-#undef MUTEX_NAMESPACE
-
-#endif  /* #define GOOGLE_MUTEX_H__ */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/config.h.in
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/config.h.in b/third_party/src/glog/src/config.h.in
deleted file mode 100644
index 0c5e8b0..0000000
--- a/third_party/src/glog/src/config.h.in
+++ /dev/null
@@ -1,171 +0,0 @@
-/* src/config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* define if glog doesn't use RTTI */
-#undef DISABLE_RTTI
-
-/* Namespace for Google classes */
-#undef GOOGLE_NAMESPACE
-
-/* Define if you have the `dladdr' function */
-#undef HAVE_DLADDR
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <execinfo.h> header file. */
-#undef HAVE_EXECINFO_H
-
-/* Define if you have the `fcntl' function */
-#undef HAVE_FCNTL
-
-/* Define to 1 if you have the <glob.h> header file. */
-#undef HAVE_GLOB_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `pthread' library (-lpthread). */
-#undef HAVE_LIBPTHREAD
-
-/* Define to 1 if you have the <libunwind.h> header file. */
-#undef HAVE_LIBUNWIND_H
-
-/* define if you have google gflags library */
-#undef HAVE_LIB_GFLAGS
-
-/* define if you have google gmock library */
-#undef HAVE_LIB_GMOCK
-
-/* define if you have google gtest library */
-#undef HAVE_LIB_GTEST
-
-/* define if you have libunwind */
-#undef HAVE_LIB_UNWIND
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* define if the compiler implements namespaces */
-#undef HAVE_NAMESPACES
-
-/* Define if you have POSIX threads libraries and header files. */
-#undef HAVE_PTHREAD
-
-/* Define to 1 if you have the <pwd.h> header file. */
-#undef HAVE_PWD_H
-
-/* define if the compiler implements pthread_rwlock_* */
-#undef HAVE_RWLOCK
-
-/* Define if you have the `sigaltstack' function */
-#undef HAVE_SIGALTSTACK
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <syscall.h> header file. */
-#undef HAVE_SYSCALL_H
-
-/* Define to 1 if you have the <syslog.h> header file. */
-#undef HAVE_SYSLOG_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/syscall.h> header file. */
-#undef HAVE_SYS_SYSCALL_H
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-#undef HAVE_SYS_TIME_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <sys/ucontext.h> header file. */
-#undef HAVE_SYS_UCONTEXT_H
-
-/* Define to 1 if you have the <sys/utsname.h> header file. */
-#undef HAVE_SYS_UTSNAME_H
-
-/* Define to 1 if you have the <ucontext.h> header file. */
-#undef HAVE_UCONTEXT_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if you have the <unwind.h> header file. */
-#undef HAVE_UNWIND_H
-
-/* define if the compiler supports using expression for operator */
-#undef HAVE_USING_OPERATOR
-
-/* define if your compiler has __attribute__ */
-#undef HAVE___ATTRIBUTE__
-
-/* define if your compiler has __builtin_expect */
-#undef HAVE___BUILTIN_EXPECT
-
-/* define if your compiler has __sync_val_compare_and_swap */
-#undef HAVE___SYNC_VAL_COMPARE_AND_SWAP
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
-#undef LT_OBJDIR
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* How to access the PC from a struct ucontext */
-#undef PC_FROM_UCONTEXT
-
-/* Define to necessary symbol if this constant uses a non-standard name on
-   your system. */
-#undef PTHREAD_CREATE_JOINABLE
-
-/* The size of `void *', as computed by sizeof. */
-#undef SIZEOF_VOID_P
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* the namespace where STL code like vector<> is defined */
-#undef STL_NAMESPACE
-
-/* location of source code */
-#undef TEST_SRC_DIR
-
-/* Version number of package */
-#undef VERSION
-
-/* Stops putting the code inside the Google namespace */
-#undef _END_GOOGLE_NAMESPACE_
-
-/* Puts following code inside the Google namespace */
-#undef _START_GOOGLE_NAMESPACE_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/config_cmake.h.in
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/config_cmake.h.in b/third_party/src/glog/src/config_cmake.h.in
deleted file mode 100644
index 3a3ecb0..0000000
--- a/third_party/src/glog/src/config_cmake.h.in
+++ /dev/null
@@ -1,169 +0,0 @@
-/* define if glog doesn't use RTTI */
-/* #undef DISABLE_RTTI */
-
-/* Namespace for Google classes */
-#define GOOGLE_NAMESPACE google
-
-/* Define if you have the `dladdr' function */
-/* #undef HAVE_DLADDR */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#cmakedefine HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the <execinfo.h> header file. */
-#cmakedefine HAVE_EXECINFO_H 1
-
-/* Define if you have the `fcntl' function */
-#cmakedefine HAVE_FCNTL 1
-
-/* Define to 1 if you have the <glob.h> header file. */
-#cmakedefine HAVE_GLOB_H 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#cmakedefine HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `pthread' library (-lpthread). */
-#cmakedefine HAVE_LIBPTHREAD 1
-
-/* Define to 1 if you have the <libunwind.h> header file. */
-#cmakedefine HAVE_LIBUNWIND_H 1
-
-/* define if you have google gflags library */
-/* #undef HAVE_LIB_GFLAGS */
-
-/* define if you have google gmock library */
-/* #undef HAVE_LIB_GMOCK */
-
-/* define if you have google gtest library */
-/* #undef HAVE_LIB_GTEST */
-
-/* define if you have libunwind */
-/* #undef HAVE_LIB_UNWIND */
-
-/* Define to 1 if you have the <memory.h> header file. */
-#cmakedefine HAVE_MEMORY_H 1
-
-/* define if the compiler implements namespaces */
-#define HAVE_NAMESPACES 1
-
-/* Define if you have POSIX threads libraries and header files. */
-#cmakedefine HAVE_PTHREAD 1
-
-/* Define to 1 if you have the <pwd.h> header file. */
-#cmakedefine HAVE_PWD_H 1
-
-/* define if the compiler implements pthread_rwlock_* */
-#cmakedefine HAVE_RWLOCK 1
-
-/* Define if you have the `sigaltstack' function */
-#cmakedefine HAVE_SIGALTSTACK 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#cmakedefine HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#cmakedefine HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#cmakedefine HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#cmakedefine HAVE_STRING_H 1
-
-/* Define to 1 if you have the <syscall.h> header file. */
-#cmakedefine HAVE_SYSCALL_H 1
-
-/* Define to 1 if you have the <syslog.h> header file. */
-#cmakedefine HAVE_SYSLOG_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#cmakedefine HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/syscall.h> header file. */
-#cmakedefine HAVE_SYS_SYSCALL_H 1
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-#cmakedefine HAVE_SYS_TIME_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#cmakedefine HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <sys/ucontext.h> header file. */
-#cmakedefine HAVE_SYS_UCONTEXT_H 1
-
-/* Define to 1 if you have the <sys/utsname.h> header file. */
-#cmakedefine HAVE_SYS_UTSNAME_H 1
-
-/* Define to 1 if you have the <ucontext.h> header file. */
-#cmakedefine HAVE_UCONTEXT_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#cmakedefine HAVE_UNISTD_H 1
-
-/* Define to 1 if you have the <unwind.h> header file. */
-#cmakedefine HAVE_UNWIND_H 1
-
-/* define if the compiler supports using expression for operator */
-#define HAVE_USING_OPERATOR 1
-
-/* define if your compiler has __attribute__ */
-#cmakedefine HAVE___ATTRIBUTE__ 1
-
-/* define if your compiler has __builtin_expect */
-#cmakedefine HAVE___BUILTIN_EXPECT 1
-
-/* define if your compiler has __sync_val_compare_and_swap */
-#cmakedefine HAVE___SYNC_VAL_COMPARE_AND_SWAP 1
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
-#define LT_OBJDIR ".libs/"
-
-/* Name of package */
-#define PACKAGE "glog"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "opensource@google.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "glog"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "glog 0.3.3"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "glog"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.3.3"
-
-/* How to access the PC from a struct ucontext */
-#cmakedefine PC_FROM_UCONTEXT ${PC_FROM_UCONTEXT}
-
-/* Define to necessary symbol if this constant uses a non-standard name on
-   your system. */
-/* #undef PTHREAD_CREATE_JOINABLE */
-
-/* The size of `void *', as computed by sizeof. */
-#define SIZEOF_VOID_P ${SIZEOF_VOID_P}
-
-/* Define to 1 if you have the ANSI C header files. */
-/* #undef STDC_HEADERS */
-
-/* the namespace where STL code like vector<> is defined */
-#define STL_NAMESPACE std
-
-/* location of source code */
-#define TEST_SRC_DIR "../glog"
-
-/* Version number of package */
-#define VERSION "0.3.3"
-
-/* Stops putting the code inside the Google namespace */
-#define _END_GOOGLE_NAMESPACE_ }
-
-/* Puts following code inside the Google namespace */
-#define _START_GOOGLE_NAMESPACE_ namespace google {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/config_for_unittests.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/config_for_unittests.h b/third_party/src/glog/src/config_for_unittests.h
deleted file mode 100644
index 13ea8ea..0000000
--- a/third_party/src/glog/src/config_for_unittests.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// All Rights Reserved.
-//
-// Author: Craig Silverstein
-// Copied from google-perftools and modified by Shinichiro Hamaji
-//
-// This file is needed for windows -- unittests are not part of the
-// glog dll, but still want to include config.h just like the
-// dll does, so they can use internal tools and APIs for testing.
-//
-// The problem is that config.h declares GOOGLE_GLOG_DLL_DECL to be
-// for exporting symbols, but the unittest needs to *import* symbols
-// (since it's not the dll).
-//
-// The solution is to have this file, which is just like config.h but
-// sets GOOGLE_GLOG_DLL_DECL to do a dllimport instead of a dllexport.
-//
-// The reason we need this extra GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS
-// variable is in case people want to set GOOGLE_GLOG_DLL_DECL explicitly
-// to something other than __declspec(dllexport).  In that case, they
-// may want to use something other than __declspec(dllimport) for the
-// unittest case.  For that, we allow folks to define both
-// GOOGLE_GLOG_DLL_DECL and GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS explicitly.
-//
-// NOTE: This file is equivalent to config.h on non-windows systems,
-// which never defined GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS and always
-// define GOOGLE_GLOG_DLL_DECL to the empty string.
-
-#include "config.h"
-
-#undef GOOGLE_GLOG_DLL_DECL
-#ifdef GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS
-# define GOOGLE_GLOG_DLL_DECL  GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS
-#else
-// if DLL_DECL_FOR_UNITTESTS isn't defined, use ""
-# define GOOGLE_GLOG_DLL_DECL
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/demangle.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/demangle.cc b/third_party/src/glog/src/demangle.cc
deleted file mode 100644
index e858181..0000000
--- a/third_party/src/glog/src/demangle.cc
+++ /dev/null
@@ -1,1304 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-//
-// For reference check out:
-// http://www.codesourcery.com/public/cxx-abi/abi.html#mangling
-//
-// Note that we only have partial C++0x support yet.
-
-#include <stdio.h>  // for NULL
-#include "demangle.h"
-
-_START_GOOGLE_NAMESPACE_
-
-typedef struct {
-  const char *abbrev;
-  const char *real_name;
-} AbbrevPair;
-
-// List of operators from Itanium C++ ABI.
-static const AbbrevPair kOperatorList[] = {
-  { "nw", "new" },
-  { "na", "new[]" },
-  { "dl", "delete" },
-  { "da", "delete[]" },
-  { "ps", "+" },
-  { "ng", "-" },
-  { "ad", "&" },
-  { "de", "*" },
-  { "co", "~" },
-  { "pl", "+" },
-  { "mi", "-" },
-  { "ml", "*" },
-  { "dv", "/" },
-  { "rm", "%" },
-  { "an", "&" },
-  { "or", "|" },
-  { "eo", "^" },
-  { "aS", "=" },
-  { "pL", "+=" },
-  { "mI", "-=" },
-  { "mL", "*=" },
-  { "dV", "/=" },
-  { "rM", "%=" },
-  { "aN", "&=" },
-  { "oR", "|=" },
-  { "eO", "^=" },
-  { "ls", "<<" },
-  { "rs", ">>" },
-  { "lS", "<<=" },
-  { "rS", ">>=" },
-  { "eq", "==" },
-  { "ne", "!=" },
-  { "lt", "<" },
-  { "gt", ">" },
-  { "le", "<=" },
-  { "ge", ">=" },
-  { "nt", "!" },
-  { "aa", "&&" },
-  { "oo", "||" },
-  { "pp", "++" },
-  { "mm", "--" },
-  { "cm", "," },
-  { "pm", "->*" },
-  { "pt", "->" },
-  { "cl", "()" },
-  { "ix", "[]" },
-  { "qu", "?" },
-  { "st", "sizeof" },
-  { "sz", "sizeof" },
-  { NULL, NULL },
-};
-
-// List of builtin types from Itanium C++ ABI.
-static const AbbrevPair kBuiltinTypeList[] = {
-  { "v", "void" },
-  { "w", "wchar_t" },
-  { "b", "bool" },
-  { "c", "char" },
-  { "a", "signed char" },
-  { "h", "unsigned char" },
-  { "s", "short" },
-  { "t", "unsigned short" },
-  { "i", "int" },
-  { "j", "unsigned int" },
-  { "l", "long" },
-  { "m", "unsigned long" },
-  { "x", "long long" },
-  { "y", "unsigned long long" },
-  { "n", "__int128" },
-  { "o", "unsigned __int128" },
-  { "f", "float" },
-  { "d", "double" },
-  { "e", "long double" },
-  { "g", "__float128" },
-  { "z", "ellipsis" },
-  { NULL, NULL }
-};
-
-// List of substitutions Itanium C++ ABI.
-static const AbbrevPair kSubstitutionList[] = {
-  { "St", "" },
-  { "Sa", "allocator" },
-  { "Sb", "basic_string" },
-  // std::basic_string<char, std::char_traits<char>,std::allocator<char> >
-  { "Ss", "string"},
-  // std::basic_istream<char, std::char_traits<char> >
-  { "Si", "istream" },
-  // std::basic_ostream<char, std::char_traits<char> >
-  { "So", "ostream" },
-  // std::basic_iostream<char, std::char_traits<char> >
-  { "Sd", "iostream" },
-  { NULL, NULL }
-};
-
-// State needed for demangling.
-typedef struct {
-  const char *mangled_cur;  // Cursor of mangled name.
-  char *out_cur;            // Cursor of output string.
-  const char *out_begin;    // Beginning of output string.
-  const char *out_end;      // End of output string.
-  const char *prev_name;    // For constructors/destructors.
-  int prev_name_length;     // For constructors/destructors.
-  short nest_level;         // For nested names.
-  bool append;              // Append flag.
-  bool overflowed;          // True if output gets overflowed.
-} State;
-
-// We don't use strlen() in libc since it's not guaranteed to be async
-// signal safe.
-static size_t StrLen(const char *str) {
-  size_t len = 0;
-  while (*str != '\0') {
-    ++str;
-    ++len;
-  }
-  return len;
-}
-
-// Returns true if "str" has at least "n" characters remaining.
-static bool AtLeastNumCharsRemaining(const char *str, int n) {
-  for (int i = 0; i < n; ++i) {
-    if (str[i] == '\0') {
-      return false;
-    }
-  }
-  return true;
-}
-
-// Returns true if "str" has "prefix" as a prefix.
-static bool StrPrefix(const char *str, const char *prefix) {
-  size_t i = 0;
-  while (str[i] != '\0' && prefix[i] != '\0' &&
-         str[i] == prefix[i]) {
-    ++i;
-  }
-  return prefix[i] == '\0';  // Consumed everything in "prefix".
-}
-
-static void InitState(State *state, const char *mangled,
-                      char *out, int out_size) {
-  state->mangled_cur = mangled;
-  state->out_cur = out;
-  state->out_begin = out;
-  state->out_end = out + out_size;
-  state->prev_name  = NULL;
-  state->prev_name_length = -1;
-  state->nest_level = -1;
-  state->append = true;
-  state->overflowed = false;
-}
-
-// Returns true and advances "mangled_cur" if we find "one_char_token"
-// at "mangled_cur" position.  It is assumed that "one_char_token" does
-// not contain '\0'.
-static bool ParseOneCharToken(State *state, const char one_char_token) {
-  if (state->mangled_cur[0] == one_char_token) {
-    ++state->mangled_cur;
-    return true;
-  }
-  return false;
-}
-
-// Returns true and advances "mangled_cur" if we find "two_char_token"
-// at "mangled_cur" position.  It is assumed that "two_char_token" does
-// not contain '\0'.
-static bool ParseTwoCharToken(State *state, const char *two_char_token) {
-  if (state->mangled_cur[0] == two_char_token[0] &&
-      state->mangled_cur[1] == two_char_token[1]) {
-    state->mangled_cur += 2;
-    return true;
-  }
-  return false;
-}
-
-// Returns true and advances "mangled_cur" if we find any character in
-// "char_class" at "mangled_cur" position.
-static bool ParseCharClass(State *state, const char *char_class) {
-  const char *p = char_class;
-  for (; *p != '\0'; ++p) {
-    if (state->mangled_cur[0] == *p) {
-      ++state->mangled_cur;
-      return true;
-    }
-  }
-  return false;
-}
-
-// This function is used for handling an optional non-terminal.
-static bool Optional(bool) {
-  return true;
-}
-
-// This function is used for handling <non-terminal>+ syntax.
-typedef bool (*ParseFunc)(State *);
-static bool OneOrMore(ParseFunc parse_func, State *state) {
-  if (parse_func(state)) {
-    while (parse_func(state)) {
-    }
-    return true;
-  }
-  return false;
-}
-
-// This function is used for handling <non-terminal>* syntax. The function
-// always returns true and must be followed by a termination token or a
-// terminating sequence not handled by parse_func (e.g.
-// ParseOneCharToken(state, 'E')).
-static bool ZeroOrMore(ParseFunc parse_func, State *state) {
-  while (parse_func(state)) {
-  }
-  return true;
-}
-
-// Append "str" at "out_cur".  If there is an overflow, "overflowed"
-// is set to true for later use.  The output string is ensured to
-// always terminate with '\0' as long as there is no overflow.
-static void Append(State *state, const char * const str, const int length) {
-  int i;
-  for (i = 0; i < length; ++i) {
-    if (state->out_cur + 1 < state->out_end) {  // +1 for '\0'
-      *state->out_cur = str[i];
-      ++state->out_cur;
-    } else {
-      state->overflowed = true;
-      break;
-    }
-  }
-  if (!state->overflowed) {
-    *state->out_cur = '\0';  // Terminate it with '\0'
-  }
-}
-
-// We don't use equivalents in libc to avoid locale issues.
-static bool IsLower(char c) {
-  return c >= 'a' && c <= 'z';
-}
-
-static bool IsAlpha(char c) {
-  return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
-}
-
-static bool IsDigit(char c) {
-  return c >= '0' && c <= '9';
-}
-
-// Returns true if "str" is a function clone suffix.  These suffixes are used
-// by GCC 4.5.x and later versions to indicate functions which have been
-// cloned during optimization.  We treat any sequence (.<alpha>+.<digit>+)+ as
-// a function clone suffix.
-static bool IsFunctionCloneSuffix(const char *str) {
-  size_t i = 0;
-  while (str[i] != '\0') {
-    // Consume a single .<alpha>+.<digit>+ sequence.
-    if (str[i] != '.' || !IsAlpha(str[i + 1])) {
-      return false;
-    }
-    i += 2;
-    while (IsAlpha(str[i])) {
-      ++i;
-    }
-    if (str[i] != '.' || !IsDigit(str[i + 1])) {
-      return false;
-    }
-    i += 2;
-    while (IsDigit(str[i])) {
-      ++i;
-    }
-  }
-  return true;  // Consumed everything in "str".
-}
-
-// Append "str" with some tweaks, iff "append" state is true.
-// Returns true so that it can be placed in "if" conditions.
-static void MaybeAppendWithLength(State *state, const char * const str,
-                                  const int length) {
-  if (state->append && length > 0) {
-    // Append a space if the output buffer ends with '<' and "str"
-    // starts with '<' to avoid <<<.
-    if (str[0] == '<' && state->out_begin < state->out_cur  &&
-        state->out_cur[-1] == '<') {
-      Append(state, " ", 1);
-    }
-    // Remember the last identifier name for ctors/dtors.
-    if (IsAlpha(str[0]) || str[0] == '_') {
-      state->prev_name = state->out_cur;
-      state->prev_name_length = length;
-    }
-    Append(state, str, length);
-  }
-}
-
-// A convenient wrapper arount MaybeAppendWithLength().
-static bool MaybeAppend(State *state, const char * const str) {
-  if (state->append) {
-    int length = StrLen(str);
-    MaybeAppendWithLength(state, str, length);
-  }
-  return true;
-}
-
-// This function is used for handling nested names.
-static bool EnterNestedName(State *state) {
-  state->nest_level = 0;
-  return true;
-}
-
-// This function is used for handling nested names.
-static bool LeaveNestedName(State *state, short prev_value) {
-  state->nest_level = prev_value;
-  return true;
-}
-
-// Disable the append mode not to print function parameters, etc.
-static bool DisableAppend(State *state) {
-  state->append = false;
-  return true;
-}
-
-// Restore the append mode to the previous state.
-static bool RestoreAppend(State *state, bool prev_value) {
-  state->append = prev_value;
-  return true;
-}
-
-// Increase the nest level for nested names.
-static void MaybeIncreaseNestLevel(State *state) {
-  if (state->nest_level > -1) {
-    ++state->nest_level;
-  }
-}
-
-// Appends :: for nested names if necessary.
-static void MaybeAppendSeparator(State *state) {
-  if (state->nest_level >= 1) {
-    MaybeAppend(state, "::");
-  }
-}
-
-// Cancel the last separator if necessary.
-static void MaybeCancelLastSeparator(State *state) {
-  if (state->nest_level >= 1 && state->append &&
-      state->out_begin <= state->out_cur - 2) {
-    state->out_cur -= 2;
-    *state->out_cur = '\0';
-  }
-}
-
-// Returns true if the identifier of the given length pointed to by
-// "mangled_cur" is anonymous namespace.
-static bool IdentifierIsAnonymousNamespace(State *state, int length) {
-  static const char anon_prefix[] = "_GLOBAL__N_";
-  return (length > (int)sizeof(anon_prefix) - 1 &&  // Should be longer.
-          StrPrefix(state->mangled_cur, anon_prefix));
-}
-
-// Forward declarations of our parsing functions.
-static bool ParseMangledName(State *state);
-static bool ParseEncoding(State *state);
-static bool ParseName(State *state);
-static bool ParseUnscopedName(State *state);
-static bool ParseUnscopedTemplateName(State *state);
-static bool ParseNestedName(State *state);
-static bool ParsePrefix(State *state);
-static bool ParseUnqualifiedName(State *state);
-static bool ParseSourceName(State *state);
-static bool ParseLocalSourceName(State *state);
-static bool ParseNumber(State *state, int *number_out);
-static bool ParseFloatNumber(State *state);
-static bool ParseSeqId(State *state);
-static bool ParseIdentifier(State *state, int length);
-static bool ParseOperatorName(State *state);
-static bool ParseSpecialName(State *state);
-static bool ParseCallOffset(State *state);
-static bool ParseNVOffset(State *state);
-static bool ParseVOffset(State *state);
-static bool ParseCtorDtorName(State *state);
-static bool ParseType(State *state);
-static bool ParseCVQualifiers(State *state);
-static bool ParseBuiltinType(State *state);
-static bool ParseFunctionType(State *state);
-static bool ParseBareFunctionType(State *state);
-static bool ParseClassEnumType(State *state);
-static bool ParseArrayType(State *state);
-static bool ParsePointerToMemberType(State *state);
-static bool ParseTemplateParam(State *state);
-static bool ParseTemplateTemplateParam(State *state);
-static bool ParseTemplateArgs(State *state);
-static bool ParseTemplateArg(State *state);
-static bool ParseExpression(State *state);
-static bool ParseExprPrimary(State *state);
-static bool ParseLocalName(State *state);
-static bool ParseDiscriminator(State *state);
-static bool ParseSubstitution(State *state);
-
-// Implementation note: the following code is a straightforward
-// translation of the Itanium C++ ABI defined in BNF with a couple of
-// exceptions.
-//
-// - Support GNU extensions not defined in the Itanium C++ ABI
-// - <prefix> and <template-prefix> are combined to avoid infinite loop
-// - Reorder patterns to shorten the code
-// - Reorder patterns to give greedier functions precedence
-//   We'll mark "Less greedy than" for these cases in the code
-//
-// Each parsing function changes the state and returns true on
-// success.  Otherwise, don't change the state and returns false.  To
-// ensure that the state isn't changed in the latter case, we save the
-// original state before we call more than one parsing functions
-// consecutively with &&, and restore the state if unsuccessful.  See
-// ParseEncoding() as an example of this convention.  We follow the
-// convention throughout the code.
-//
-// Originally we tried to do demangling without following the full ABI
-// syntax but it turned out we needed to follow the full syntax to
-// parse complicated cases like nested template arguments.  Note that
-// implementing a full-fledged demangler isn't trivial (libiberty's
-// cp-demangle.c has +4300 lines).
-//
-// Note that (foo) in <(foo) ...> is a modifier to be ignored.
-//
-// Reference:
-// - Itanium C++ ABI
-//   <http://www.codesourcery.com/cxx-abi/abi.html#mangling>
-
-// <mangled-name> ::= _Z <encoding>
-static bool ParseMangledName(State *state) {
-  return ParseTwoCharToken(state, "_Z") && ParseEncoding(state);
-}
-
-// <encoding> ::= <(function) name> <bare-function-type>
-//            ::= <(data) name>
-//            ::= <special-name>
-static bool ParseEncoding(State *state) {
-  State copy = *state;
-  if (ParseName(state) && ParseBareFunctionType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseName(state) || ParseSpecialName(state)) {
-    return true;
-  }
-  return false;
-}
-
-// <name> ::= <nested-name>
-//        ::= <unscoped-template-name> <template-args>
-//        ::= <unscoped-name>
-//        ::= <local-name>
-static bool ParseName(State *state) {
-  if (ParseNestedName(state) || ParseLocalName(state)) {
-    return true;
-  }
-
-  State copy = *state;
-  if (ParseUnscopedTemplateName(state) &&
-      ParseTemplateArgs(state)) {
-    return true;
-  }
-  *state = copy;
-
-  // Less greedy than <unscoped-template-name> <template-args>.
-  if (ParseUnscopedName(state)) {
-    return true;
-  }
-  return false;
-}
-
-// <unscoped-name> ::= <unqualified-name>
-//                 ::= St <unqualified-name>
-static bool ParseUnscopedName(State *state) {
-  if (ParseUnqualifiedName(state)) {
-    return true;
-  }
-
-  State copy = *state;
-  if (ParseTwoCharToken(state, "St") &&
-      MaybeAppend(state, "std::") &&
-      ParseUnqualifiedName(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <unscoped-template-name> ::= <unscoped-name>
-//                          ::= <substitution>
-static bool ParseUnscopedTemplateName(State *state) {
-  return ParseUnscopedName(state) || ParseSubstitution(state);
-}
-
-// <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E
-//               ::= N [<CV-qualifiers>] <template-prefix> <template-args> E
-static bool ParseNestedName(State *state) {
-  State copy = *state;
-  if (ParseOneCharToken(state, 'N') &&
-      EnterNestedName(state) &&
-      Optional(ParseCVQualifiers(state)) &&
-      ParsePrefix(state) &&
-      LeaveNestedName(state, copy.nest_level) &&
-      ParseOneCharToken(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// This part is tricky.  If we literally translate them to code, we'll
-// end up infinite loop.  Hence we merge them to avoid the case.
-//
-// <prefix> ::= <prefix> <unqualified-name>
-//          ::= <template-prefix> <template-args>
-//          ::= <template-param>
-//          ::= <substitution>
-//          ::= # empty
-// <template-prefix> ::= <prefix> <(template) unqualified-name>
-//                   ::= <template-param>
-//                   ::= <substitution>
-static bool ParsePrefix(State *state) {
-  bool has_something = false;
-  while (true) {
-    MaybeAppendSeparator(state);
-    if (ParseTemplateParam(state) ||
-        ParseSubstitution(state) ||
-        ParseUnscopedName(state)) {
-      has_something = true;
-      MaybeIncreaseNestLevel(state);
-      continue;
-    }
-    MaybeCancelLastSeparator(state);
-    if (has_something && ParseTemplateArgs(state)) {
-      return ParsePrefix(state);
-    } else {
-      break;
-    }
-  }
-  return true;
-}
-
-// <unqualified-name> ::= <operator-name>
-//                    ::= <ctor-dtor-name>
-//                    ::= <source-name>
-//                    ::= <local-source-name>
-static bool ParseUnqualifiedName(State *state) {
-  return (ParseOperatorName(state) ||
-          ParseCtorDtorName(state) ||
-          ParseSourceName(state) ||
-          ParseLocalSourceName(state));
-}
-
-// <source-name> ::= <positive length number> <identifier>
-static bool ParseSourceName(State *state) {
-  State copy = *state;
-  int length = -1;
-  if (ParseNumber(state, &length) && ParseIdentifier(state, length)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <local-source-name> ::= L <source-name> [<discriminator>]
-//
-// References:
-//   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31775
-//   http://gcc.gnu.org/viewcvs?view=rev&revision=124467
-static bool ParseLocalSourceName(State *state) {
-  State copy = *state;
-  if (ParseOneCharToken(state, 'L') && ParseSourceName(state) &&
-      Optional(ParseDiscriminator(state))) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <number> ::= [n] <non-negative decimal integer>
-// If "number_out" is non-null, then *number_out is set to the value of the
-// parsed number on success.
-static bool ParseNumber(State *state, int *number_out) {
-  int sign = 1;
-  if (ParseOneCharToken(state, 'n')) {
-    sign = -1;
-  }
-  const char *p = state->mangled_cur;
-  int number = 0;
-  for (;*p != '\0'; ++p) {
-    if (IsDigit(*p)) {
-      number = number * 10 + (*p - '0');
-    } else {
-      break;
-    }
-  }
-  if (p != state->mangled_cur) {  // Conversion succeeded.
-    state->mangled_cur = p;
-    if (number_out != NULL) {
-      *number_out = number * sign;
-    }
-    return true;
-  }
-  return false;
-}
-
-// Floating-point literals are encoded using a fixed-length lowercase
-// hexadecimal string.
-static bool ParseFloatNumber(State *state) {
-  const char *p = state->mangled_cur;
-  for (;*p != '\0'; ++p) {
-    if (!IsDigit(*p) && !(*p >= 'a' && *p <= 'f')) {
-      break;
-    }
-  }
-  if (p != state->mangled_cur) {  // Conversion succeeded.
-    state->mangled_cur = p;
-    return true;
-  }
-  return false;
-}
-
-// The <seq-id> is a sequence number in base 36,
-// using digits and upper case letters
-static bool ParseSeqId(State *state) {
-  const char *p = state->mangled_cur;
-  for (;*p != '\0'; ++p) {
-    if (!IsDigit(*p) && !(*p >= 'A' && *p <= 'Z')) {
-      break;
-    }
-  }
-  if (p != state->mangled_cur) {  // Conversion succeeded.
-    state->mangled_cur = p;
-    return true;
-  }
-  return false;
-}
-
-// <identifier> ::= <unqualified source code identifier> (of given length)
-static bool ParseIdentifier(State *state, int length) {
-  if (length == -1 ||
-      !AtLeastNumCharsRemaining(state->mangled_cur, length)) {
-    return false;
-  }
-  if (IdentifierIsAnonymousNamespace(state, length)) {
-    MaybeAppend(state, "(anonymous namespace)");
-  } else {
-    MaybeAppendWithLength(state, state->mangled_cur, length);
-  }
-  state->mangled_cur += length;
-  return true;
-}
-
-// <operator-name> ::= nw, and other two letters cases
-//                 ::= cv <type>  # (cast)
-//                 ::= v  <digit> <source-name> # vendor extended operator
-static bool ParseOperatorName(State *state) {
-  if (!AtLeastNumCharsRemaining(state->mangled_cur, 2)) {
-    return false;
-  }
-  // First check with "cv" (cast) case.
-  State copy = *state;
-  if (ParseTwoCharToken(state, "cv") &&
-      MaybeAppend(state, "operator ") &&
-      EnterNestedName(state) &&
-      ParseType(state) &&
-      LeaveNestedName(state, copy.nest_level)) {
-    return true;
-  }
-  *state = copy;
-
-  // Then vendor extended operators.
-  if (ParseOneCharToken(state, 'v') && ParseCharClass(state, "0123456789") &&
-      ParseSourceName(state)) {
-    return true;
-  }
-  *state = copy;
-
-  // Other operator names should start with a lower alphabet followed
-  // by a lower/upper alphabet.
-  if (!(IsLower(state->mangled_cur[0]) &&
-        IsAlpha(state->mangled_cur[1]))) {
-    return false;
-  }
-  // We may want to perform a binary search if we really need speed.
-  const AbbrevPair *p;
-  for (p = kOperatorList; p->abbrev != NULL; ++p) {
-    if (state->mangled_cur[0] == p->abbrev[0] &&
-        state->mangled_cur[1] == p->abbrev[1]) {
-      MaybeAppend(state, "operator");
-      if (IsLower(*p->real_name)) {  // new, delete, etc.
-        MaybeAppend(state, " ");
-      }
-      MaybeAppend(state, p->real_name);
-      state->mangled_cur += 2;
-      return true;
-    }
-  }
-  return false;
-}
-
-// <special-name> ::= TV <type>
-//                ::= TT <type>
-//                ::= TI <type>
-//                ::= TS <type>
-//                ::= Tc <call-offset> <call-offset> <(base) encoding>
-//                ::= GV <(object) name>
-//                ::= T <call-offset> <(base) encoding>
-// G++ extensions:
-//                ::= TC <type> <(offset) number> _ <(base) type>
-//                ::= TF <type>
-//                ::= TJ <type>
-//                ::= GR <name>
-//                ::= GA <encoding>
-//                ::= Th <call-offset> <(base) encoding>
-//                ::= Tv <call-offset> <(base) encoding>
-//
-// Note: we don't care much about them since they don't appear in
-// stack traces.  The are special data.
-static bool ParseSpecialName(State *state) {
-  State copy = *state;
-  if (ParseOneCharToken(state, 'T') &&
-      ParseCharClass(state, "VTIS") &&
-      ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoCharToken(state, "Tc") && ParseCallOffset(state) &&
-      ParseCallOffset(state) && ParseEncoding(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoCharToken(state, "GV") &&
-      ParseName(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOneCharToken(state, 'T') && ParseCallOffset(state) &&
-      ParseEncoding(state)) {
-    return true;
-  }
-  *state = copy;
-
-  // G++ extensions
-  if (ParseTwoCharToken(state, "TC") && ParseType(state) &&
-      ParseNumber(state, NULL) && ParseOneCharToken(state, '_') &&
-      DisableAppend(state) &&
-      ParseType(state)) {
-    RestoreAppend(state, copy.append);
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOneCharToken(state, 'T') && ParseCharClass(state, "FJ") &&
-      ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoCharToken(state, "GR") && ParseName(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoCharToken(state, "GA") && ParseEncoding(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOneCharToken(state, 'T') && ParseCharClass(state, "hv") &&
-      ParseCallOffset(state) && ParseEncoding(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <call-offset> ::= h <nv-offset> _
-//               ::= v <v-offset> _
-static bool ParseCallOffset(State *state) {
-  State copy = *state;
-  if (ParseOneCharToken(state, 'h') &&
-      ParseNVOffset(state) && ParseOneCharToken(state, '_')) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOneCharToken(state, 'v') &&
-      ParseVOffset(state) && ParseOneCharToken(state, '_')) {
-    return true;
-  }
-  *state = copy;
-
-  return false;
-}
-
-// <nv-offset> ::= <(offset) number>
-static bool ParseNVOffset(State *state) {
-  return ParseNumber(state, NULL);
-}
-
-// <v-offset>  ::= <(offset) number> _ <(virtual offset) number>
-static bool ParseVOffset(State *state) {
-  State copy = *state;
-  if (ParseNumber(state, NULL) && ParseOneCharToken(state, '_') &&
-      ParseNumber(state, NULL)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <ctor-dtor-name> ::= C1 | C2 | C3
-//                  ::= D0 | D1 | D2
-static bool ParseCtorDtorName(State *state) {
-  State copy = *state;
-  if (ParseOneCharToken(state, 'C') &&
-      ParseCharClass(state, "123")) {
-    const char * const prev_name = state->prev_name;
-    const int prev_name_length = state->prev_name_length;
-    MaybeAppendWithLength(state, prev_name, prev_name_length);
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOneCharToken(state, 'D') &&
-      ParseCharClass(state, "012")) {
-    const char * const prev_name = state->prev_name;
-    const int prev_name_length = state->prev_name_length;
-    MaybeAppend(state, "~");
-    MaybeAppendWithLength(state, prev_name, prev_name_length);
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <type> ::= <CV-qualifiers> <type>
-//        ::= P <type>   # pointer-to
-//        ::= R <type>   # reference-to
-//        ::= O <type>   # rvalue reference-to (C++0x)
-//        ::= C <type>   # complex pair (C 2000)
-//        ::= G <type>   # imaginary (C 2000)
-//        ::= U <source-name> <type>  # vendor extended type qualifier
-//        ::= <builtin-type>
-//        ::= <function-type>
-//        ::= <class-enum-type>
-//        ::= <array-type>
-//        ::= <pointer-to-member-type>
-//        ::= <template-template-param> <template-args>
-//        ::= <template-param>
-//        ::= <substitution>
-//        ::= Dp <type>          # pack expansion of (C++0x)
-//        ::= Dt <expression> E  # decltype of an id-expression or class
-//                               # member access (C++0x)
-//        ::= DT <expression> E  # decltype of an expression (C++0x)
-//
-static bool ParseType(State *state) {
-  // We should check CV-qualifers, and PRGC things first.
-  State copy = *state;
-  if (ParseCVQualifiers(state) && ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseCharClass(state, "OPRCG") && ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoCharToken(state, "Dp") && ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOneCharToken(state, 'D') && ParseCharClass(state, "tT") &&
-      ParseExpression(state) && ParseOneCharToken(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOneCharToken(state, 'U') && ParseSourceName(state) &&
-      ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseBuiltinType(state) ||
-      ParseFunctionType(state) ||
-      ParseClassEnumType(state) ||
-      ParseArrayType(state) ||
-      ParsePointerToMemberType(state) ||
-      ParseSubstitution(state)) {
-    return true;
-  }
-
-  if (ParseTemplateTemplateParam(state) &&
-      ParseTemplateArgs(state)) {
-    return true;
-  }
-  *state = copy;
-
-  // Less greedy than <template-template-param> <template-args>.
-  if (ParseTemplateParam(state)) {
-    return true;
-  }
-
-  return false;
-}
-
-// <CV-qualifiers> ::= [r] [V] [K]
-// We don't allow empty <CV-qualifiers> to avoid infinite loop in
-// ParseType().
-static bool ParseCVQualifiers(State *state) {
-  int num_cv_qualifiers = 0;
-  num_cv_qualifiers += ParseOneCharToken(state, 'r');
-  num_cv_qualifiers += ParseOneCharToken(state, 'V');
-  num_cv_qualifiers += ParseOneCharToken(state, 'K');
-  return num_cv_qualifiers > 0;
-}
-
-// <builtin-type> ::= v, etc.
-//                ::= u <source-name>
-static bool ParseBuiltinType(State *state) {
-  const AbbrevPair *p;
-  for (p = kBuiltinTypeList; p->abbrev != NULL; ++p) {
-    if (state->mangled_cur[0] == p->abbrev[0]) {
-      MaybeAppend(state, p->real_name);
-      ++state->mangled_cur;
-      return true;
-    }
-  }
-
-  State copy = *state;
-  if (ParseOneCharToken(state, 'u') && ParseSourceName(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <function-type> ::= F [Y] <bare-function-type> E
-static bool ParseFunctionType(State *state) {
-  State copy = *state;
-  if (ParseOneCharToken(state, 'F') &&
-      Optional(ParseOneCharToken(state, 'Y')) &&
-      ParseBareFunctionType(state) && ParseOneCharToken(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <bare-function-type> ::= <(signature) type>+
-static bool ParseBareFunctionType(State *state) {
-  State copy = *state;
-  DisableAppend(state);
-  if (OneOrMore(ParseType, state)) {
-    RestoreAppend(state, copy.append);
-    MaybeAppend(state, "()");
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <class-enum-type> ::= <name>
-static bool ParseClassEnumType(State *state) {
-  return ParseName(state);
-}
-
-// <array-type> ::= A <(positive dimension) number> _ <(element) type>
-//              ::= A [<(dimension) expression>] _ <(element) type>
-static bool ParseArrayType(State *state) {
-  State copy = *state;
-  if (ParseOneCharToken(state, 'A') && ParseNumber(state, NULL) &&
-      ParseOneCharToken(state, '_') && ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOneCharToken(state, 'A') && Optional(ParseExpression(state)) &&
-      ParseOneCharToken(state, '_') && ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <pointer-to-member-type> ::= M <(class) type> <(member) type>
-static bool ParsePointerToMemberType(State *state) {
-  State copy = *state;
-  if (ParseOneCharToken(state, 'M') && ParseType(state) &&
-      ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <template-param> ::= T_
-//                  ::= T <parameter-2 non-negative number> _
-static bool ParseTemplateParam(State *state) {
-  if (ParseTwoCharToken(state, "T_")) {
-    MaybeAppend(state, "?");  // We don't support template substitutions.
-    return true;
-  }
-
-  State copy = *state;
-  if (ParseOneCharToken(state, 'T') && ParseNumber(state, NULL) &&
-      ParseOneCharToken(state, '_')) {
-    MaybeAppend(state, "?");  // We don't support template substitutions.
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-
-// <template-template-param> ::= <template-param>
-//                           ::= <substitution>
-static bool ParseTemplateTemplateParam(State *state) {
-  return (ParseTemplateParam(state) ||
-          ParseSubstitution(state));
-}
-
-// <template-args> ::= I <template-arg>+ E
-static bool ParseTemplateArgs(State *state) {
-  State copy = *state;
-  DisableAppend(state);
-  if (ParseOneCharToken(state, 'I') &&
-      OneOrMore(ParseTemplateArg, state) &&
-      ParseOneCharToken(state, 'E')) {
-    RestoreAppend(state, copy.append);
-    MaybeAppend(state, "<>");
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <template-arg>  ::= <type>
-//                 ::= <expr-primary>
-//                 ::= I <template-arg>* E        # argument pack
-//                 ::= X <expression> E
-static bool ParseTemplateArg(State *state) {
-  State copy = *state;
-  if (ParseOneCharToken(state, 'I') &&
-      ZeroOrMore(ParseTemplateArg, state) &&
-      ParseOneCharToken(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseType(state) ||
-      ParseExprPrimary(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOneCharToken(state, 'X') && ParseExpression(state) &&
-      ParseOneCharToken(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <expression> ::= <template-param>
-//              ::= <expr-primary>
-//              ::= <unary operator-name> <expression>
-//              ::= <binary operator-name> <expression> <expression>
-//              ::= <trinary operator-name> <expression> <expression>
-//                  <expression>
-//              ::= st <type>
-//              ::= sr <type> <unqualified-name> <template-args>
-//              ::= sr <type> <unqualified-name>
-static bool ParseExpression(State *state) {
-  if (ParseTemplateParam(state) || ParseExprPrimary(state)) {
-    return true;
-  }
-
-  State copy = *state;
-  if (ParseOperatorName(state) &&
-      ParseExpression(state) &&
-      ParseExpression(state) &&
-      ParseExpression(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOperatorName(state) &&
-      ParseExpression(state) &&
-      ParseExpression(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOperatorName(state) &&
-      ParseExpression(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoCharToken(state, "st") && ParseType(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoCharToken(state, "sr") && ParseType(state) &&
-      ParseUnqualifiedName(state) &&
-      ParseTemplateArgs(state)) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoCharToken(state, "sr") && ParseType(state) &&
-      ParseUnqualifiedName(state)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <expr-primary> ::= L <type> <(value) number> E
-//                ::= L <type> <(value) float> E
-//                ::= L <mangled-name> E
-//                // A bug in g++'s C++ ABI version 2 (-fabi-version=2).
-//                ::= LZ <encoding> E
-static bool ParseExprPrimary(State *state) {
-  State copy = *state;
-  if (ParseOneCharToken(state, 'L') && ParseType(state) &&
-      ParseNumber(state, NULL) &&
-      ParseOneCharToken(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOneCharToken(state, 'L') && ParseType(state) &&
-      ParseFloatNumber(state) &&
-      ParseOneCharToken(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOneCharToken(state, 'L') && ParseMangledName(state) &&
-      ParseOneCharToken(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseTwoCharToken(state, "LZ") && ParseEncoding(state) &&
-      ParseOneCharToken(state, 'E')) {
-    return true;
-  }
-  *state = copy;
-
-  return false;
-}
-
-// <local-name> := Z <(function) encoding> E <(entity) name>
-//                 [<discriminator>]
-//              := Z <(function) encoding> E s [<discriminator>]
-static bool ParseLocalName(State *state) {
-  State copy = *state;
-  if (ParseOneCharToken(state, 'Z') && ParseEncoding(state) &&
-      ParseOneCharToken(state, 'E') && MaybeAppend(state, "::") &&
-      ParseName(state) && Optional(ParseDiscriminator(state))) {
-    return true;
-  }
-  *state = copy;
-
-  if (ParseOneCharToken(state, 'Z') && ParseEncoding(state) &&
-      ParseTwoCharToken(state, "Es") && Optional(ParseDiscriminator(state))) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <discriminator> := _ <(non-negative) number>
-static bool ParseDiscriminator(State *state) {
-  State copy = *state;
-  if (ParseOneCharToken(state, '_') && ParseNumber(state, NULL)) {
-    return true;
-  }
-  *state = copy;
-  return false;
-}
-
-// <substitution> ::= S_
-//                ::= S <seq-id> _
-//                ::= St, etc.
-static bool ParseSubstitution(State *state) {
-  if (ParseTwoCharToken(state, "S_")) {
-    MaybeAppend(state, "?");  // We don't support substitutions.
-    return true;
-  }
-
-  State copy = *state;
-  if (ParseOneCharToken(state, 'S') && ParseSeqId(state) &&
-      ParseOneCharToken(state, '_')) {
-    MaybeAppend(state, "?");  // We don't support substitutions.
-    return true;
-  }
-  *state = copy;
-
-  // Expand abbreviations like "St" => "std".
-  if (ParseOneCharToken(state, 'S')) {
-    const AbbrevPair *p;
-    for (p = kSubstitutionList; p->abbrev != NULL; ++p) {
-      if (state->mangled_cur[0] == p->abbrev[1]) {
-        MaybeAppend(state, "std");
-        if (p->real_name[0] != '\0') {
-          MaybeAppend(state, "::");
-          MaybeAppend(state, p->real_name);
-        }
-        ++state->mangled_cur;
-        return true;
-      }
-    }
-  }
-  *state = copy;
-  return false;
-}
-
-// Parse <mangled-name>, optionally followed by either a function-clone suffix
-// or version suffix.  Returns true only if all of "mangled_cur" was consumed.
-static bool ParseTopLevelMangledName(State *state) {
-  if (ParseMangledName(state)) {
-    if (state->mangled_cur[0] != '\0') {
-      // Drop trailing function clone suffix, if any.
-      if (IsFunctionCloneSuffix(state->mangled_cur)) {
-        return true;
-      }
-      // Append trailing version suffix if any.
-      // ex. _Z3foo@@GLIBCXX_3.4
-      if (state->mangled_cur[0] == '@') {
-        MaybeAppend(state, state->mangled_cur);
-        return true;
-      }
-      return false;  // Unconsumed suffix.
-    }
-    return true;
-  }
-  return false;
-}
-
-// The demangler entry point.
-bool Demangle(const char *mangled, char *out, int out_size) {
-  State state;
-  InitState(&state, mangled, out, out_size);
-  return ParseTopLevelMangledName(&state) && !state.overflowed;
-}
-
-_END_GOOGLE_NAMESPACE_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/demangle.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/demangle.h b/third_party/src/glog/src/demangle.h
deleted file mode 100644
index 9c75915..0000000
--- a/third_party/src/glog/src/demangle.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-//
-// An async-signal-safe and thread-safe demangler for Itanium C++ ABI
-// (aka G++ V3 ABI).
-
-// The demangler is implemented to be used in async signal handlers to
-// symbolize stack traces.  We cannot use libstdc++'s
-// abi::__cxa_demangle() in such signal handlers since it's not async
-// signal safe (it uses malloc() internally).
-//
-// Note that this demangler doesn't support full demangling.  More
-// specifically, it doesn't print types of function parameters and
-// types of template arguments.  It just skips them.  However, it's
-// still very useful to extract basic information such as class,
-// function, constructor, destructor, and operator names.
-//
-// See the implementation note in demangle.cc if you are interested.
-//
-// Example:
-//
-// | Mangled Name  | The Demangler | abi::__cxa_demangle()
-// |---------------|---------------|-----------------------
-// | _Z1fv         | f()           | f()
-// | _Z1fi         | f()           | f(int)
-// | _Z3foo3bar    | foo()         | foo(bar)
-// | _Z1fIiEvi     | f<>()         | void f<int>(int)
-// | _ZN1N1fE      | N::f          | N::f
-// | _ZN3Foo3BarEv | Foo::Bar()    | Foo::Bar()
-// | _Zrm1XS_"     | operator%()   | operator%(X, X)
-// | _ZN3FooC1Ev   | Foo::Foo()    | Foo::Foo()
-// | _Z1fSs        | f()           | f(std::basic_string<char,
-// |               |               |   std::char_traits<char>,
-// |               |               |   std::allocator<char> >)
-//
-// See the unit test for more examples.
-//
-// Note: we might want to write demanglers for ABIs other than Itanium
-// C++ ABI in the future.
-//
-
-#ifndef BASE_DEMANGLE_H_
-#define BASE_DEMANGLE_H_
-
-#include "config.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// Demangle "mangled".  On success, return true and write the
-// demangled symbol name to "out".  Otherwise, return false.
-// "out" is modified even if demangling is unsuccessful.
-bool Demangle(const char *mangled, char *out, int out_size);
-
-_END_GOOGLE_NAMESPACE_
-
-#endif  // BASE_DEMANGLE_H_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/demangle_unittest.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/demangle_unittest.cc b/third_party/src/glog/src/demangle_unittest.cc
deleted file mode 100644
index 9d219e6..0000000
--- a/third_party/src/glog/src/demangle_unittest.cc
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-//
-// Unit tests for functions in demangle.c.
-
-#include "utilities.h"
-
-#include <iostream>
-#include <fstream>
-#include <string>
-#include "glog/logging.h"
-#include "demangle.h"
-#include "googletest.h"
-#include "config.h"
-
-GLOG_DEFINE_bool(demangle_filter, false,
-                 "Run demangle_unittest in filter mode");
-
-using namespace std;
-using namespace GOOGLE_NAMESPACE;
-
-// A wrapper function for Demangle() to make the unit test simple.
-static const char *DemangleIt(const char * const mangled) {
-  static char demangled[4096];
-  if (Demangle(mangled, demangled, sizeof(demangled))) {
-    return demangled;
-  } else {
-    return mangled;
-  }
-}
-
-// Test corner cases of bounary conditions.
-TEST(Demangle, CornerCases) {
-  char tmp[10];
-  EXPECT_TRUE(Demangle("_Z6foobarv", tmp, sizeof(tmp)));
-  // sizeof("foobar()") == 9
-  EXPECT_STREQ("foobar()", tmp);
-  EXPECT_TRUE(Demangle("_Z6foobarv", tmp, 9));
-  EXPECT_STREQ("foobar()", tmp);
-  EXPECT_FALSE(Demangle("_Z6foobarv", tmp, 8));  // Not enough.
-  EXPECT_FALSE(Demangle("_Z6foobarv", tmp, 1));
-  EXPECT_FALSE(Demangle("_Z6foobarv", tmp, 0));
-  EXPECT_FALSE(Demangle("_Z6foobarv", NULL, 0));  // Should not cause SEGV.
-}
-
-// Test handling of functions suffixed with .clone.N, which is used by GCC
-// 4.5.x, and .constprop.N and .isra.N, which are used by GCC 4.6.x.  These
-// suffixes are used to indicate functions which have been cloned during
-// optimization.  We ignore these suffixes.
-TEST(Demangle, Clones) {
-  char tmp[20];
-  EXPECT_TRUE(Demangle("_ZL3Foov", tmp, sizeof(tmp)));
-  EXPECT_STREQ("Foo()", tmp);
-  EXPECT_TRUE(Demangle("_ZL3Foov.clone.3", tmp, sizeof(tmp)));
-  EXPECT_STREQ("Foo()", tmp);
-  EXPECT_TRUE(Demangle("_ZL3Foov.constprop.80", tmp, sizeof(tmp)));
-  EXPECT_STREQ("Foo()", tmp);
-  EXPECT_TRUE(Demangle("_ZL3Foov.isra.18", tmp, sizeof(tmp)));
-  EXPECT_STREQ("Foo()", tmp);
-  EXPECT_TRUE(Demangle("_ZL3Foov.isra.2.constprop.18", tmp, sizeof(tmp)));
-  EXPECT_STREQ("Foo()", tmp);
-  // Invalid (truncated), should not demangle.
-  EXPECT_FALSE(Demangle("_ZL3Foov.clo", tmp, sizeof(tmp)));
-  // Invalid (.clone. not followed by number), should not demangle.
-  EXPECT_FALSE(Demangle("_ZL3Foov.clone.", tmp, sizeof(tmp)));
-  // Invalid (.clone. followed by non-number), should not demangle.
-  EXPECT_FALSE(Demangle("_ZL3Foov.clone.foo", tmp, sizeof(tmp)));
-  // Invalid (.constprop. not followed by number), should not demangle.
-  EXPECT_FALSE(Demangle("_ZL3Foov.isra.2.constprop.", tmp, sizeof(tmp)));
-}
-
-TEST(Demangle, FromFile) {
-  string test_file = FLAGS_test_srcdir + "/src/demangle_unittest.txt";
-  ifstream f(test_file.c_str());  // The file should exist.
-  EXPECT_FALSE(f.fail());
-
-  string line;
-  while (getline(f, line)) {
-    // Lines start with '#' are considered as comments.
-    if (line.empty() || line[0] == '#') {
-      continue;
-    }
-    // Each line should contain a mangled name and a demangled name
-    // separated by '\t'.  Example: "_Z3foo\tfoo"
-    string::size_type tab_pos = line.find('\t');
-    EXPECT_NE(string::npos, tab_pos);
-    string mangled = line.substr(0, tab_pos);
-    string demangled = line.substr(tab_pos + 1);
-    EXPECT_EQ(demangled, DemangleIt(mangled.c_str()));
-  }
-}
-
-int main(int argc, char **argv) {
-#ifdef HAVE_LIB_GFLAGS
-  ParseCommandLineFlags(&argc, &argv, true);
-#endif
-  InitGoogleTest(&argc, argv);
-
-  FLAGS_logtostderr = true;
-  InitGoogleLogging(argv[0]);
-  if (FLAGS_demangle_filter) {
-    // Read from cin and write to cout.
-    string line;
-    while (getline(cin, line, '\n')) {
-      cout << DemangleIt(line.c_str()) << endl;
-    }
-    return 0;
-  } else if (argc > 1) {
-    cout << DemangleIt(argv[1]) << endl;
-    return 0;
-  } else {
-    return RUN_ALL_TESTS();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/demangle_unittest.sh
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/demangle_unittest.sh b/third_party/src/glog/src/demangle_unittest.sh
deleted file mode 100644
index 91deee2..0000000
--- a/third_party/src/glog/src/demangle_unittest.sh
+++ /dev/null
@@ -1,95 +0,0 @@
-#! /bin/sh
-#
-# Copyright (c) 2006, Google Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# Author: Satoru Takabayashi
-#
-# Unit tests for demangle.c with a real binary.
-
-set -e
-
-die () {
-    echo $1
-    exit 1
-}
-
-BINDIR=".libs"
-LIBGLOG="$BINDIR/libglog.so"
-
-DEMANGLER="$BINDIR/demangle_unittest"
-
-if test -e "$DEMANGLER"; then
-  # We need shared object.
-  export LD_LIBRARY_PATH=$BINDIR
-  export DYLD_LIBRARY_PATH=$BINDIR
-else
-  # For windows
-  DEMANGLER="./demangle_unittest.exe"
-  if ! test -e "$DEMANGLER"; then
-    echo "We coundn't find demangle_unittest binary."
-    exit 1
-  fi
-fi
-
-# Extract C++ mangled symbols from libbase.so.
-NM_OUTPUT="demangle.nm"
-nm "$LIBGLOG" | perl -nle 'print $1 if /\s(_Z\S+$)/' > "$NM_OUTPUT"
-
-# Check if mangled symbols exist. If there are none, we quit.
-# The binary is more likely compiled with GCC 2.95 or something old.
-if ! grep --quiet '^_Z' "$NM_OUTPUT"; then
-    echo "PASS"
-    exit 0
-fi
-
-# Demangle the symbols using our demangler.
-DM_OUTPUT="demangle.dm"
-GLOG_demangle_filter=1 "$DEMANGLER" --demangle_filter < "$NM_OUTPUT" > "$DM_OUTPUT"
-
-# Calculate the numbers of lines.
-NM_LINES=`wc -l "$NM_OUTPUT" | awk '{ print $1 }'`
-DM_LINES=`wc -l "$DM_OUTPUT" | awk '{ print $1 }'`
-
-# Compare the numbers of lines.  They must be the same.
-if test "$NM_LINES" != "$DM_LINES"; then
-    die "$NM_OUTPUT and $DM_OUTPUT don't have the same numbers of lines"
-fi
-
-# Check if mangled symbols exist.  They must not exist.
-if grep --quiet '^_Z' "$DM_OUTPUT"; then
-    MANGLED=`grep '^_Z' "$DM_OUTPUT" | wc -l | awk '{ print \$1 }'`
-    echo "Mangled symbols ($MANGLED out of $NM_LINES) found in $DM_OUTPUT:"
-    grep '^_Z' "$DM_OUTPUT"
-    die "Mangled symbols ($MANGLED out of $NM_LINES) found in $DM_OUTPUT"
-fi
-
-# All C++ symbols are demangled successfully.
-echo "PASS"
-exit 0

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/demangle_unittest.txt
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/demangle_unittest.txt b/third_party/src/glog/src/demangle_unittest.txt
deleted file mode 100644
index 4e23c65..0000000
--- a/third_party/src/glog/src/demangle_unittest.txt
+++ /dev/null
@@ -1,137 +0,0 @@
-# Test caces for demangle_unittest.  Each line consists of a
-# tab-separated pair of mangled and demangled symbol names.
-
-# Constructors and destructors.
-_ZN3FooC1Ev	Foo::Foo()
-_ZN3FooD1Ev	Foo::~Foo()
-_ZNSoD0Ev	std::ostream::~ostream()
-
-# G++ extensions.
-_ZTCN10LogMessage9LogStreamE0_So	LogMessage::LogStream
-_ZTv0_n12_N10LogMessage9LogStreamD0Ev	LogMessage::LogStream::~LogStream()
-_ZThn4_N7icu_3_410UnicodeSetD0Ev	icu_3_4::UnicodeSet::~UnicodeSet()
-
-# A bug in g++'s C++ ABI version 2 (-fabi-version=2).
-_ZN7NSSInfoI5groupjjXadL_Z10getgrgid_rEELZ19nss_getgrgid_r_nameEEC1Ei	NSSInfo<>::NSSInfo()
-
-# C linkage symbol names.  Should keep them untouched.
-main	main
-Demangle	Demangle
-_ZERO	_ZERO
-
-# Cast operator.
-_Zcviv	operator int()
-_ZN3foocviEv	foo::operator int()
-
-# Versioned symbols.
-_Z3Foo@GLIBCXX_3.4	Foo@GLIBCXX_3.4
-_Z3Foo@@GLIBCXX_3.4	Foo@@GLIBCXX_3.4
-
-# Abbreviations.
-_ZNSaE	std::allocator
-_ZNSbE	std::basic_string
-_ZNSdE	std::iostream
-_ZNSiE	std::istream
-_ZNSoE	std::ostream
-_ZNSsE	std::string
-
-# Substitutions.  We just replace them with ?.
-_ZN3fooS_E	foo::?
-_ZN3foo3barS0_E	foo::bar::?
-_ZNcvT_IiEEv	operator ?<>()
-
-# "<< <" case.
-_ZlsI3fooE	operator<< <>
-
-# Random things we found interesting.
-_ZN3FooISt6vectorISsSaISsEEEclEv	Foo<>::operator()()
-_ZTI9Callback1IiE	Callback1<>
-_ZN7icu_3_47UMemorynwEj	icu_3_4::UMemory::operator new()
-_ZNSt6vectorIbE9push_backE	std::vector<>::push_back
-_ZNSt6vectorIbSaIbEE9push_backEb	std::vector<>::push_back()
-_ZlsRSoRK15PRIVATE_Counter	operator<<()
-_ZSt6fill_nIPPN9__gnu_cxx15_Hashtable_nodeISt4pairIKPKcjEEEjS8_ET_SA_T0_RKT1_	std::fill_n<>()
-_ZZ3FoovE3Bar	Foo()::Bar
-_ZGVZ7UpTimervE8up_timer	UpTimer()::up_timer
-
-# Test cases from gcc-4.1.0/libstdc++-v3/testsuite/demangle.
-# Collected by:
-# % grep verify_demangle **/*.cc | perl -nle 'print $1 if /"(_Z.*?)"/' |
-#   sort | uniq
-#
-# Note that the following symbols are invalid.
-# That's why they are not demangled.
-# - _ZNZN1N1fEiE1X1gE
-# - _ZNZN1N1fEiE1X1gEv
-# - _Z1xINiEE
-_Z1fA37_iPS_	f()
-_Z1fAszL_ZZNK1N1A1fEvE3foo_0E_i	f()
-_Z1fI1APS0_PKS0_EvT_T0_T1_PA4_S3_M1CS8_	f<>()
-_Z1fI1XENT_1tES2_	f<>()
-_Z1fI1XEvPVN1AIT_E1TE	f<>()
-_Z1fILi1ELc120EEv1AIXplT_cviLd4028ae147ae147aeEEE	f<>()
-_Z1fILi1ELc120EEv1AIXplT_cviLf3f800000EEE	f<>()
-_Z1fILi5E1AEvN1CIXqugtT_Li0ELi1ELi2EEE1qE	f<>()
-_Z1fILi5E1AEvN1CIXstN1T1tEEXszsrS2_1tEE1qE	f<>()
-_Z1fILi5EEvN1AIXcvimlT_Li22EEE1qE	f<>()
-_Z1fIiEvi	f<>()
-_Z1fKPFiiE	f()
-_Z1fM1AFivEPS0_	f()
-_Z1fM1AKFivE	f()
-_Z1fM1AKFvvE	f()
-_Z1fPFPA1_ivE	f()
-_Z1fPFYPFiiEiE	f()
-_Z1fPFvvEM1SFvvE	f()
-_Z1fPKM1AFivE	f()
-_Z1fi	f()
-_Z1fv	f()
-_Z1jM1AFivEPS1_	j()
-_Z1rM1GFivEMS_KFivES_M1HFivES1_4whatIKS_E5what2IS8_ES3_	r()
-_Z1sPA37_iPS0_	s()
-_Z1xINiEE	_Z1xINiEE
-_Z3absILi11EEvv	abs<>()
-_Z3foo3bar	foo()
-_Z3foo5Hello5WorldS0_S_	foo()
-_Z3fooA30_A_i	foo()
-_Z3fooIA6_KiEvA9_KT_rVPrS4_	foo<>()
-_Z3fooILi2EEvRAplT_Li1E_i	foo<>()
-_Z3fooIiFvdEiEvv	foo<>()
-_Z3fooPM2ABi	foo()
-_Z3fooc	foo()
-_Z3fooiPiPS_PS0_PS1_PS2_PS3_PS4_PS5_PS6_PS7_PS8_PS9_PSA_PSB_PSC_	foo()
-_Z3kooPA28_A30_i	koo()
-_Z4makeI7FactoryiET_IT0_Ev	make<>()
-_Z5firstI3DuoEvS0_	first<>()
-_Z5firstI3DuoEvT_	first<>()
-_Z9hairyfuncM1YKFPVPFrPA2_PM1XKFKPA3_ilEPcEiE	hairyfunc()
-_ZGVN5libcw24_GLOBAL__N_cbll.cc0ZhUKa23compiler_bug_workaroundISt6vectorINS_13omanip_id_tctINS_5debug32memblk_types_manipulator_data_ctEEESaIS6_EEE3idsE	libcw::(anonymous namespace)::compiler_bug_workaround<>::ids
-_ZN12libcw_app_ct10add_optionIS_EEvMT_FvPKcES3_cS3_S3_	libcw_app_ct::add_option<>()
-_ZN1AIfEcvT_IiEEv	A<>::operator ?<>()
-_ZN1N1TIiiE2mfES0_IddE	N::T<>::mf()
-_ZN1N1fE	N::f
-_ZN1f1fE	f::f
-_ZN3FooIA4_iE3barE	Foo<>::bar
-_ZN5Arena5levelE	Arena::level
-_ZN5StackIiiE5levelE	Stack<>::level
-_ZN5libcw5debug13cwprint_usingINS_9_private_12GlobalObjectEEENS0_17cwprint_using_tctIT_EERKS5_MS5_KFvRSt7ostreamE	libcw::debug::cwprint_using<>()
-_ZN6System5Sound4beepEv	System::Sound::beep()
-_ZNKSt14priority_queueIP27timer_event_request_base_ctSt5dequeIS1_SaIS1_EE13timer_greaterE3topEv	std::priority_queue<>::top()
-_ZNKSt15_Deque_iteratorIP15memory_block_stRKS1_PS2_EeqERKS5_	std::_Deque_iterator<>::operator==()
-_ZNKSt17__normal_iteratorIPK6optionSt6vectorIS0_SaIS0_EEEmiERKS6_	std::__normal_iterator<>::operator-()
-_ZNSbIcSt11char_traitsIcEN5libcw5debug27no_alloc_checking_allocatorEE12_S_constructIPcEES6_T_S7_RKS3_	std::basic_string<>::_S_construct<>()
-_ZNSt13_Alloc_traitsISbIcSt18string_char_traitsIcEN5libcw5debug9_private_17allocator_adaptorIcSt24__default_alloc_templateILb0ELi327664EELb1EEEENS5_IS9_S7_Lb1EEEE15_S_instancelessE	std::_Alloc_traits<>::_S_instanceless
-_ZNSt3_In4wardE	std::_In::ward
-_ZNZN1N1fEiE1X1gE	_ZNZN1N1fEiE1X1gE
-_ZNZN1N1fEiE1X1gEv	_ZNZN1N1fEiE1X1gEv
-_ZSt1BISt1DIP1ARKS2_PS3_ES0_IS2_RS2_PS2_ES2_ET0_T_SB_SA_PT1_	std::B<>()
-_ZSt5state	std::state
-_ZTI7a_class	a_class
-_ZZN1N1fEiE1p	N::f()::p
-_ZZN1N1fEiEs	N::f()
-_ZlsRK1XS1_	operator<<()
-_ZlsRKU3fooU4bart1XS0_	operator<<()
-_ZlsRKU3fooU4bart1XS2_	operator<<()
-_ZlsRSoRKSs	operator<<()
-_ZngILi42EEvN1AIXplT_Li2EEE1TE	operator-<>()
-_ZplR1XS0_	operator+()
-_Zrm1XS_	operator%()


[16/46] incubator-quickstep git commit: Added ProbabilityStore class

Posted by ji...@apache.org.
Added ProbabilityStore class

- Used to store probabilities of objects.
- Probabilities are of two kinds: Individual and cumulative.
- All the individual probabilities within the store add up to one.
- Support for finding the object with given cumulative probability.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/8f094a1c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/8f094a1c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/8f094a1c

Branch: refs/heads/fix-iwyu
Commit: 8f094a1c086445b79d6dba36f81326ac06050209
Parents: f820c45
Author: Harshad Deshmukh <hb...@apache.org>
Authored: Fri Sep 29 15:38:42 2017 -0500
Committer: Harshad Deshmukh <hb...@apache.org>
Committed: Wed Oct 11 10:38:36 2017 -0500

----------------------------------------------------------------------
 query_execution/CMakeLists.txt                  |  13 +
 query_execution/ProbabilityStore.hpp            | 263 +++++++++++++++++++
 .../tests/ProbabilityStore_unittest.cpp         | 106 ++++++++
 3 files changed, 382 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8f094a1c/query_execution/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_execution/CMakeLists.txt b/query_execution/CMakeLists.txt
index 8f797f7..791434a 100644
--- a/query_execution/CMakeLists.txt
+++ b/query_execution/CMakeLists.txt
@@ -40,6 +40,7 @@ if (ENABLE_DISTRIBUTED)
   add_library(quickstep_queryexecution_PolicyEnforcerDistributed PolicyEnforcerDistributed.cpp PolicyEnforcerDistributed.hpp)
 endif(ENABLE_DISTRIBUTED)
 add_library(quickstep_queryexecution_PolicyEnforcerSingleNode PolicyEnforcerSingleNode.cpp PolicyEnforcerSingleNode.hpp)
+add_library(quickstep_queryexecution_ProbabilityStore ../empty_src.cpp ProbabilityStore.hpp)
 add_library(quickstep_queryexecution_QueryContext QueryContext.cpp QueryContext.hpp)
 add_library(quickstep_queryexecution_QueryContext_proto
             ${queryexecution_QueryContext_proto_srcs}
@@ -201,6 +202,9 @@ target_link_libraries(quickstep_queryexecution_PolicyEnforcerSingleNode
                       quickstep_utility_Macros
                       tmb
                       ${GFLAGS_LIB_NAME})
+target_link_libraries(quickstep_queryexecution_ProbabilityStore
+                      glog
+                      quickstep_utility_Macros)
 target_link_libraries(quickstep_queryexecution_QueryContext
                       glog
                       quickstep_catalog_CatalogDatabaseLite
@@ -372,6 +376,7 @@ target_link_libraries(quickstep_queryexecution
                       quickstep_queryexecution_ForemanSingleNode
                       quickstep_queryexecution_PolicyEnforcerBase
                       quickstep_queryexecution_PolicyEnforcerSingleNode
+                      quickstep_queryexecution_ProbabilityStore
                       quickstep_queryexecution_QueryContext
                       quickstep_queryexecution_QueryContext_proto
                       quickstep_queryexecution_QueryExecutionMessages_proto
@@ -425,6 +430,14 @@ if (ENABLE_DISTRIBUTED)
   add_test(BlockLocator_unittest BlockLocator_unittest)
 endif(ENABLE_DISTRIBUTED)
 
+add_executable(ProbabilityStore_unittest
+        "${CMAKE_CURRENT_SOURCE_DIR}/tests/ProbabilityStore_unittest.cpp")
+target_link_libraries(ProbabilityStore_unittest
+                      gtest
+                      gtest_main
+                      quickstep_queryexecution_ProbabilityStore)
+add_test(ProbabilityStore_unittest ProbabilityStore_unittest)
+
 add_executable(QueryManagerSingleNode_unittest
   "${CMAKE_CURRENT_SOURCE_DIR}/tests/QueryManagerSingleNode_unittest.cpp")
 target_link_libraries(QueryManagerSingleNode_unittest

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8f094a1c/query_execution/ProbabilityStore.hpp
----------------------------------------------------------------------
diff --git a/query_execution/ProbabilityStore.hpp b/query_execution/ProbabilityStore.hpp
new file mode 100644
index 0000000..079f60b
--- /dev/null
+++ b/query_execution/ProbabilityStore.hpp
@@ -0,0 +1,263 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ **/
+
+#ifndef QUICKSTEP_QUERY_EXECUTION_PROBABILITY_STORE_HPP_
+#define QUICKSTEP_QUERY_EXECUTION_PROBABILITY_STORE_HPP_
+
+#include <algorithm>
+#include <cstddef>
+#include <random>
+#include <unordered_map>
+#include <vector>
+
+#include "utility/Macros.hpp"
+
+#include "glog/logging.h"
+
+namespace quickstep {
+
+/**
+ * @brief A class that stores the probabilities of objects. We use an integer field
+ *        called "key" to identify each object.
+ *        A probability is expressed as a fraction. All the objects share a common denominator.
+ **/
+class ProbabilityStore {
+ public:
+  /**
+   * @brief Constructor.
+   **/
+  ProbabilityStore()
+      : common_denominator_(1.0), dist_(0.0, 1.0), engine_(std::random_device()()) {}
+
+  /**
+   * @brief Get the number of objects in the store.
+   **/
+  inline std::size_t getNumObjects() const {
+    DCHECK_EQ(individual_probabilities_.size(), cumulative_probabilities_.size());
+    return individual_probabilities_.size();
+  }
+
+  /**
+   * @brief Get the common denominator.
+   */
+  inline std::size_t getDenominator() const {
+    return common_denominator_;
+  }
+
+  /**
+   * @brief Check if an object with a given key is present.
+   * @param key The key of the given object.
+   * @return True if the object is present, false otherwise.
+   */
+  inline bool hasObject(const std::size_t key) const {
+    return (individual_probabilities_.find(key) != individual_probabilities_.end());
+  }
+
+  /**
+   * @brief Add individual (not cumulative) probability for a given object with
+   *        updated denominator.
+   *
+   * @note This function leaves the cumulative probabilities in a consistent
+   *       state. An alternative lazy implementation should be written if cost
+   *       of calculating cumulative probabilities is high.
+   *
+   * @param key The key of the given object.
+   * @param numerator The numerator for the given object.
+   * @param new_denominator The updated denominator for the store.
+   **/
+  void addOrUpdateObjectNewDenominator(const std::size_t key,
+                                       const float numerator,
+                                       const float new_denominator) {
+    CHECK_GT(new_denominator, 0u);
+    DCHECK_LE(numerator, new_denominator);
+    common_denominator_ = new_denominator;
+    addOrUpdateObjectHelper(key, numerator);
+  }
+
+  /**
+   * @brief Add or update multiple objects with a new denominator.
+   * @param keys The keys to be added/updated.
+   * @param numerators The numerators to be added/updated.
+   * @param new_denominator The new denominator.
+   */
+  void addOrUpdateObjectsNewDenominator(
+      const std::vector<std::size_t> &keys,
+      const std::vector<float> &numerators,
+      const float new_denominator) {
+    CHECK_GT(new_denominator, 0u);
+    common_denominator_ = new_denominator;
+    addOrUpdateObjectsHelper(keys, numerators);
+  }
+
+  /**
+   * @brief Remove an object from the store.
+   *
+   * @note This function decrements the denominator with the value of the numerator being removed.
+   *
+   * @param key The key of the object to be removed.
+   **/
+  void removeObject(const std::size_t key) {
+    auto individual_it = individual_probabilities_.find(key);
+    DCHECK(individual_it != individual_probabilities_.end());
+    const float new_denominator = common_denominator_ - individual_it->second;
+    individual_probabilities_.erase(individual_it);
+    common_denominator_ = new_denominator;
+    updateCumulativeProbabilities();
+  }
+
+  /**
+   * @brief Get the individual probability (not cumulative) for an object.
+   *
+   * @param key The key of the object.
+   **/
+  const float getIndividualProbability(const std::size_t key) const {
+    const auto it = individual_probabilities_.find(key);
+    DCHECK(it != individual_probabilities_.end());
+    DCHECK_NE(0.0, common_denominator_);
+    return it->second / common_denominator_;
+  }
+
+  /**
+   * @brief Update the cumulative probabilities.
+   *
+   * @note This function should be called upon if there are any updates,
+   *       additions or deletions to the individual probabilities.
+   * @note An efficient implementation should be written if there are large
+   *       number of objects.
+   **/
+  void updateCumulativeProbabilities() {
+    cumulative_probabilities_.clear();
+    float cumulative_probability = 0;
+    for (const auto p : individual_probabilities_) {
+      cumulative_probability += p.second / common_denominator_;
+      cumulative_probabilities_.emplace_back(p.first,
+                                             cumulative_probability);
+    }
+    if (!cumulative_probabilities_.empty()) {
+      // Adjust the last cumulative probability manually to 1, so that
+      // floating addition related rounding issues are ignored.
+      cumulative_probabilities_.back().updateProbability(1);
+    }
+  }
+
+  /**
+   * @brief Return a uniformly chosen random key.
+   **/
+  inline const std::size_t pickRandomKey() const {
+    return getKeyForProbability(dist_(engine_));
+  }
+
+ private:
+  struct ProbabilityInfo {
+   public:
+    ProbabilityInfo(const std::size_t key, const float probability)
+        : key_(key), probability_(probability) {
+      DCHECK(probability_ <= 1.0);
+    }
+
+    void updateProbability(const float new_probability) {
+      probability_ = new_probability;
+    }
+
+    const std::size_t key_;
+    float probability_;
+  };
+
+  /**
+   * @brief Get a key for a given cumulative probability.
+   *
+   * @param key_cumulative_probability The input cumulative probability.
+   *
+   * @return The object that has a cumulative probability that is greater than
+   *         or equal to the input cumulative probability.
+   **/
+  inline std::size_t getKeyForProbability(
+      const float key_cumulative_probability) const {
+    DCHECK(!cumulative_probabilities_.empty());
+    // It doesn't matter in which order the objects are arranged in the
+    // cumulative_probabilities_ vector.
+    ProbabilityInfo search_key(0, key_cumulative_probability);
+    const auto it = std::upper_bound(
+        cumulative_probabilities_.begin(),
+        cumulative_probabilities_.end(),
+        search_key,
+        [](const ProbabilityInfo &a, const ProbabilityInfo &b) {
+          return a.probability_ < b.probability_;
+        });
+    DCHECK(it != std::end(cumulative_probabilities_));
+    return it->key_;
+  }
+
+  /**
+   * @brief Add individual (not cumulative) probability for a given object.
+   *
+   * @note This function leaves the cumulative probabilities in a consistent
+   *       state. An alternative lazy implementation should be written if cost
+   *       of calculating cumulative probabilities is high.
+   * @note This function may override previously written probability values.
+   *
+   * @param key The key of the given object.
+   * @param numerator The numerator for the given object.
+   **/
+  void addOrUpdateObjectHelper(const std::size_t key,
+                               const float numerator) {
+    DCHECK_LE(numerator, common_denominator_);
+    individual_probabilities_[key] = numerator;
+    updateCumulativeProbabilities();
+  }
+
+  /**
+   * @brief Add individual (not cumulative) probabilities for given objects.
+   *
+   * @note This function leaves the cumulative probabilities in a consistent
+   *       state. An alternative lazy implementation should be written if cost
+   *       of calculating cumulative probabilities is high.
+   * @note This function may override previously written probability values.
+   *
+   * @param keys A vector of keys to be added.
+   * @param numerators The numerators of the given objects.
+   **/
+  void addOrUpdateObjectsHelper(const std::vector<std::size_t> &keys,
+                                const std::vector<float> &numerators) {
+    DCHECK_EQ(keys.size(), numerators.size());
+    for (std::size_t i = 0; i < keys.size(); ++i) {
+      DCHECK_LE(numerators[i], common_denominator_);
+      individual_probabilities_[keys[i]] = numerators[i];
+    }
+    updateCumulativeProbabilities();
+  }
+
+  // Key = key of the object.
+  // Value = Numerator of the object.
+  std::unordered_map<std::size_t, float> individual_probabilities_;
+  std::vector<ProbabilityInfo> cumulative_probabilities_;
+
+  float common_denominator_;
+
+  mutable std::uniform_real_distribution<float> dist_;
+  mutable std::default_random_engine engine_;
+
+  DISALLOW_COPY_AND_ASSIGN(ProbabilityStore);
+};
+
+/** @} */
+
+}  // namespace quickstep
+
+#endif  // QUICKSTEP_QUERY_EXECUTION_PROBABILITY_STORE_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8f094a1c/query_execution/tests/ProbabilityStore_unittest.cpp
----------------------------------------------------------------------
diff --git a/query_execution/tests/ProbabilityStore_unittest.cpp b/query_execution/tests/ProbabilityStore_unittest.cpp
new file mode 100644
index 0000000..e333f60
--- /dev/null
+++ b/query_execution/tests/ProbabilityStore_unittest.cpp
@@ -0,0 +1,106 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ **/
+
+#include "query_execution/ProbabilityStore.hpp"
+
+#include <cstddef>
+#include <vector>
+
+#include "gtest/gtest.h"
+
+namespace quickstep {
+
+TEST(ProbabilityStoreTest, CountTest) {
+  ProbabilityStore store;
+  EXPECT_EQ(0u, store.getNumObjects());
+  const std::size_t kKey = 0;
+  store.addOrUpdateObjectNewDenominator(kKey, 1, 1);
+  EXPECT_EQ(1u, store.getNumObjects());
+  store.removeObject(kKey);
+  EXPECT_EQ(0u, store.getNumObjects());
+
+  std::vector<std::size_t> objects {3, 5, 7, 9};
+  std::vector<float> numerators {1, 2, 2, 5};
+  const std::size_t kNewDenominator = std::accumulate(numerators.begin(), numerators.end(), 0);
+  store.addOrUpdateObjectsNewDenominator(objects, numerators, kNewDenominator);
+
+  EXPECT_EQ(objects.size(), store.getNumObjects());
+}
+
+TEST(ProbabilityStoreTest, IndividualProbabilityTest) {
+  ProbabilityStore store;
+  std::vector<std::size_t> objects {3, 5, 7, 9};
+  std::vector<float> numerators {1, 2, 2, 5};
+  const std::size_t kNewDenominator = std::accumulate(numerators.begin(), numerators.end(), 0);
+  store.addOrUpdateObjectsNewDenominator(objects, numerators, kNewDenominator);
+
+  for (std::size_t object_num = 0; object_num < objects.size(); ++object_num) {
+    EXPECT_EQ(numerators[object_num] / static_cast<float>(kNewDenominator),
+              store.getIndividualProbability(objects[object_num]));
+  }
+}
+
+TEST(ProbabilityStoreTest, PickRandomKeyTest) {
+  ProbabilityStore store;
+  std::vector<std::size_t> objects {3, 5, 7, 9};
+  std::vector<float> numerators {1, 2, 2, 5};
+  const std::size_t kNewDenominator = std::accumulate(numerators.begin(), numerators.end(), 0);
+  store.addOrUpdateObjectsNewDenominator(objects, numerators, kNewDenominator);
+
+  const std::size_t kNumTrials = 10;
+  while (!objects.empty()) {
+    for (std::size_t trial_num = 0; trial_num < kNumTrials; ++trial_num) {
+      const std::size_t picked_key = store.pickRandomKey();
+      const auto it = std::find(objects.begin(), objects.end(), picked_key);
+      EXPECT_TRUE(it != objects.end());
+    }
+    const std::size_t key_to_be_removed = objects.back();
+    store.removeObject(key_to_be_removed);
+    objects.pop_back();
+    EXPECT_EQ(objects.size(), store.getNumObjects());
+  }
+}
+
+TEST(ProbabilityStoreTest, RemoveObjectTest) {
+  ProbabilityStore store;
+  std::vector<std::size_t> objects {3, 5, 7, 9};
+  std::vector<float> numerators {1, 2, 2, 5};
+  const std::size_t kNewDenominator = std::accumulate(numerators.begin(), numerators.end(), 0);
+  store.addOrUpdateObjectsNewDenominator(objects, numerators, kNewDenominator);
+
+  for (std::size_t object_num = 0; object_num < objects.size(); ++object_num) {
+    EXPECT_EQ(numerators[object_num] / static_cast<float>(kNewDenominator),
+              store.getIndividualProbability(objects[object_num]));
+  }
+
+  // Remove last object "9", with numerator 5.
+  store.removeObject(objects.back());
+  objects.pop_back();
+  numerators.pop_back();
+  const float expected_new_denominator =
+      std::accumulate(numerators.begin(), numerators.end(), 0);
+
+  EXPECT_EQ(expected_new_denominator, store.getDenominator());
+  for (std::size_t object_num = 0; object_num < objects.size(); ++object_num) {
+    EXPECT_EQ(numerators[object_num] / static_cast<float>(expected_new_denominator),
+              store.getIndividualProbability(objects[object_num]));
+  }
+}
+
+}  // namespace quickstep


[12/46] incubator-quickstep git commit: Moved InsertDestination::getTouchedBlocks as a private method.

Posted by ji...@apache.org.
Moved InsertDestination::getTouchedBlocks as a private method.


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

Branch: refs/heads/fix-iwyu
Commit: a61b03dcc2446a5bd276a0117f493ba56d8a3ffe
Parents: 79710ca
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Thu Oct 5 16:41:38 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Mon Oct 9 12:00:08 2017 -0500

----------------------------------------------------------------------
 .../tests/HashJoinOperator_unittest.cpp         | 24 +++----
 storage/InsertDestination.cpp                   | 27 +++-----
 storage/InsertDestination.hpp                   | 70 ++++++++++++--------
 3 files changed, 65 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a61b03dc/relational_operators/tests/HashJoinOperator_unittest.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/tests/HashJoinOperator_unittest.cpp b/relational_operators/tests/HashJoinOperator_unittest.cpp
index 1fc84fc..cfd4314 100644
--- a/relational_operators/tests/HashJoinOperator_unittest.cpp
+++ b/relational_operators/tests/HashJoinOperator_unittest.cpp
@@ -485,7 +485,7 @@ TEST_P(HashJoinOperatorTest, LongKeyHashJoinTest) {
   InsertDestination *insert_destination = query_context_->getInsertDestination(prober->getInsertDestinationID());
   DCHECK(insert_destination);
 
-  const std::vector<block_id> &result_blocks = insert_destination->getTouchedBlocks();
+  const std::vector<block_id> result_blocks = insert_destination->getTouchedBlocks();
   for (std::size_t bid = 0; bid < result_blocks.size(); ++bid) {
     BlockReference result_block = storage_manager_->getBlock(result_blocks[bid],
                                                              insert_destination->getRelation());
@@ -640,7 +640,7 @@ TEST_P(HashJoinOperatorTest, IntDuplicateKeyHashJoinTest) {
   InsertDestination *insert_destination = query_context_->getInsertDestination(prober->getInsertDestinationID());
   DCHECK(insert_destination);
 
-  const std::vector<block_id> &result_blocks = insert_destination->getTouchedBlocks();
+  const std::vector<block_id> result_blocks = insert_destination->getTouchedBlocks();
   for (std::size_t bid = 0; bid < result_blocks.size(); ++bid) {
     BlockReference result_block = storage_manager_->getBlock(result_blocks[bid],
                                                              insert_destination->getRelation());
@@ -795,7 +795,7 @@ TEST_P(HashJoinOperatorTest, CharKeyCartesianProductHashJoinTest) {
   InsertDestination *insert_destination = query_context_->getInsertDestination(prober->getInsertDestinationID());
   DCHECK(insert_destination);
 
-  const std::vector<block_id> &result_blocks = insert_destination->getTouchedBlocks();
+  const std::vector<block_id> result_blocks = insert_destination->getTouchedBlocks();
   for (std::size_t bid = 0; bid < result_blocks.size(); ++bid) {
     BlockReference result_block = storage_manager_->getBlock(result_blocks[bid],
                                                              insert_destination->getRelation());
@@ -944,7 +944,7 @@ TEST_P(HashJoinOperatorTest, VarCharDuplicateKeyHashJoinTest) {
   InsertDestination *insert_destination = query_context_->getInsertDestination(prober->getInsertDestinationID());
   DCHECK(insert_destination);
 
-  const std::vector<block_id> &result_blocks = insert_destination->getTouchedBlocks();
+  const std::vector<block_id> result_blocks = insert_destination->getTouchedBlocks();
   for (std::size_t bid = 0; bid < result_blocks.size(); ++bid) {
     BlockReference result_block = storage_manager_->getBlock(result_blocks[bid],
                                                              insert_destination->getRelation());
@@ -1123,7 +1123,7 @@ TEST_P(HashJoinOperatorTest, CompositeKeyHashJoinTest) {
   InsertDestination *insert_destination = query_context_->getInsertDestination(prober->getInsertDestinationID());
   DCHECK(insert_destination);
 
-  const std::vector<block_id> &result_blocks = insert_destination->getTouchedBlocks();
+  const std::vector<block_id> result_blocks = insert_destination->getTouchedBlocks();
   for (std::size_t bid = 0; bid < result_blocks.size(); ++bid) {
     BlockReference result_block = storage_manager_->getBlock(result_blocks[bid],
                                                              insert_destination->getRelation());
@@ -1313,7 +1313,7 @@ TEST_P(HashJoinOperatorTest, CompositeKeyHashJoinWithResidualPredicateTest) {
   InsertDestination *insert_destination = query_context_->getInsertDestination(prober->getInsertDestinationID());
   DCHECK(insert_destination);
 
-  const std::vector<block_id> &result_blocks = insert_destination->getTouchedBlocks();
+  const std::vector<block_id> result_blocks = insert_destination->getTouchedBlocks();
   for (std::size_t bid = 0; bid < result_blocks.size(); ++bid) {
     BlockReference result_block = storage_manager_->getBlock(result_blocks[bid],
                                                              insert_destination->getRelation());
@@ -1370,7 +1370,7 @@ TEST_P(HashJoinOperatorTest, CompositeKeyHashJoinWithResidualPredicateTest) {
 }
 
 // Hash join tests with single attribute partitions.
-TEST_P(HashJoinOperatorTest, SinlgeAttributePartitionedLongKeyHashJoinTest) {
+TEST_P(HashJoinOperatorTest, SingleAttributePartitionedLongKeyHashJoinTest) {
   insertTuplesWithSingleAttributePartitions();
 
   // Setup the hash table proto in the query context proto.
@@ -1480,7 +1480,7 @@ TEST_P(HashJoinOperatorTest, SinlgeAttributePartitionedLongKeyHashJoinTest) {
   InsertDestination *insert_destination = query_context_->getInsertDestination(prober->getInsertDestinationID());
   DCHECK(insert_destination);
 
-  const std::vector<block_id> &result_blocks = insert_destination->getTouchedBlocks();
+  const std::vector<block_id> result_blocks = insert_destination->getTouchedBlocks();
   for (std::size_t bid = 0; bid < result_blocks.size(); ++bid) {
     BlockReference result_block = storage_manager_->getBlock(result_blocks[bid],
                                                              insert_destination->getRelation());
@@ -1514,7 +1514,7 @@ TEST_P(HashJoinOperatorTest, SinlgeAttributePartitionedLongKeyHashJoinTest) {
   db_->dropRelationById(output_relation_id);
 }
 
-TEST_P(HashJoinOperatorTest, SinlgeAttributePartitionedCompositeKeyHashJoinTest) {
+TEST_P(HashJoinOperatorTest, SingleAttributePartitionedCompositeKeyHashJoinTest) {
   insertTuplesWithSingleAttributePartitions();
 
   // Setup the hash table proto in the query context proto.
@@ -1629,7 +1629,7 @@ TEST_P(HashJoinOperatorTest, SinlgeAttributePartitionedCompositeKeyHashJoinTest)
   InsertDestination *insert_destination = query_context_->getInsertDestination(prober->getInsertDestinationID());
   DCHECK(insert_destination);
 
-  const std::vector<block_id> &result_blocks = insert_destination->getTouchedBlocks();
+  const std::vector<block_id> result_blocks = insert_destination->getTouchedBlocks();
   for (std::size_t bid = 0; bid < result_blocks.size(); ++bid) {
     BlockReference result_block = storage_manager_->getBlock(result_blocks[bid],
                                                              insert_destination->getRelation());
@@ -1685,7 +1685,7 @@ TEST_P(HashJoinOperatorTest, SinlgeAttributePartitionedCompositeKeyHashJoinTest)
   db_->dropRelationById(output_relation_id);
 }
 
-TEST_P(HashJoinOperatorTest, SinlgeAttributePartitionedCompositeKeyHashJoinWithResidualPredicateTest) {
+TEST_P(HashJoinOperatorTest, SingleAttributePartitionedCompositeKeyHashJoinWithResidualPredicateTest) {
   insertTuplesWithSingleAttributePartitions();
 
   // Setup the hash table proto in the query context proto.
@@ -1810,7 +1810,7 @@ TEST_P(HashJoinOperatorTest, SinlgeAttributePartitionedCompositeKeyHashJoinWithR
   InsertDestination *insert_destination = query_context_->getInsertDestination(prober->getInsertDestinationID());
   DCHECK(insert_destination);
 
-  const std::vector<block_id> &result_blocks = insert_destination->getTouchedBlocks();
+  const std::vector<block_id> result_blocks = insert_destination->getTouchedBlocks();
   for (std::size_t bid = 0; bid < result_blocks.size(); ++bid) {
     BlockReference result_block = storage_manager_->getBlock(result_blocks[bid],
                                                              insert_destination->getRelation());

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a61b03dc/storage/InsertDestination.cpp
----------------------------------------------------------------------
diff --git a/storage/InsertDestination.cpp b/storage/InsertDestination.cpp
index ff39c55..8821019 100644
--- a/storage/InsertDestination.cpp
+++ b/storage/InsertDestination.cpp
@@ -475,7 +475,7 @@ void BlockPoolInsertDestination::returnBlock(MutableBlockReference &&block, cons
   sendBlockFilledMessage(block->getID());
 }
 
-const std::vector<block_id>& BlockPoolInsertDestination::getTouchedBlocksInternal() {
+std::vector<block_id> BlockPoolInsertDestination::getTouchedBlocksInternal() {
   for (std::vector<MutableBlockReference>::size_type i = 0; i < available_block_refs_.size(); ++i) {
     done_block_ids_.push_back(available_block_refs_[i]->getID());
   }
@@ -546,27 +546,22 @@ MutableBlockReference PartitionAwareInsertDestination::createNewBlockInPartition
   return storage_manager_->getBlockMutable(new_id, relation_);
 }
 
-const std::vector<block_id>& PartitionAwareInsertDestination::getTouchedBlocksInternal() {
+std::vector<block_id> PartitionAwareInsertDestination::getTouchedBlocksInternal() {
+  std::vector<block_id> all_partitions_done_block_ids;
   // Iterate through each partition and get all the touched blocks.
   for (std::size_t part_id = 0;
        part_id < partition_scheme_header_->getNumPartitions();
        ++part_id) {
-    done_block_ids_[part_id] = getTouchedBlocksInternalInPartition(part_id);
-    all_partitions_done_block_ids_.insert(
-        all_partitions_done_block_ids_.end(), done_block_ids_[part_id].begin(), done_block_ids_[part_id].end());
-    done_block_ids_[part_id].clear();
-  }
-  return all_partitions_done_block_ids_;
-}
+    for (std::size_t i = 0; i < available_block_refs_[part_id].size(); ++i) {
+      done_block_ids_[part_id].push_back(available_block_refs_[part_id][i]->getID());
+    }
+    available_block_refs_[part_id].clear();
 
-const std::vector<block_id>& PartitionAwareInsertDestination::getTouchedBlocksInternalInPartition(
-    partition_id part_id) {
-  for (std::vector<MutableBlockReference>::size_type i = 0; i < available_block_refs_[part_id].size(); ++i) {
-    done_block_ids_[part_id].push_back(available_block_refs_[part_id][i]->getID());
+    all_partitions_done_block_ids.insert(
+        all_partitions_done_block_ids.end(), done_block_ids_[part_id].begin(), done_block_ids_[part_id].end());
+    done_block_ids_[part_id].clear();
   }
-  available_block_refs_[part_id].clear();
-
-  return done_block_ids_[part_id];
+  return all_partitions_done_block_ids;
 }
 
 PartitionSchemeHeader::PartitionAttributeIds PartitionAwareInsertDestination::getPartitioningAttributes() const {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a61b03dc/storage/InsertDestination.hpp
----------------------------------------------------------------------
diff --git a/storage/InsertDestination.hpp b/storage/InsertDestination.hpp
index c3d5641..a0a7bc2 100644
--- a/storage/InsertDestination.hpp
+++ b/storage/InsertDestination.hpp
@@ -58,6 +58,8 @@ class StorageManager;
 
 namespace merge_run_operator {
 class RunCreator;
+class RunMergerTest;
+class RunTest;
 }  // namespace merge_run_operator
 
 namespace serialization { class InsertDestination; }
@@ -173,21 +175,6 @@ class InsertDestination : public InsertDestinationInterface {
   }
 
   /**
-   * @brief Get the set of blocks that were used by clients of this
-   *        InsertDestination for insertion.
-   * @warning Should only be called AFTER this InsertDestination will no longer
-   *          be used, and all blocks have been returned to it via
-   *          returnBlock().
-   *
-   * @return A reference to a vector of block_ids of blocks that were used for
-   *         insertion.
-   **/
-  const std::vector<block_id>& getTouchedBlocks() {
-    SpinMutexLock lock(mutex_);
-    return getTouchedBlocksInternal();
-  }
-
-  /**
    * @brief Get the set of blocks that were partially filled by clients of this
    *        InsertDestination for insertion.
    * @warning Should only be called AFTER this InsertDestination will no longer
@@ -233,8 +220,6 @@ class InsertDestination : public InsertDestinationInterface {
   // this without holding the mutex.
   virtual MutableBlockReference createNewBlock() = 0;
 
-  virtual const std::vector<block_id>& getTouchedBlocksInternal() = 0;
-
   /**
    * @brief When a StorageBlock becomes full, pipeline the block id to the
    *        scheduler.
@@ -311,12 +296,44 @@ class InsertDestination : public InsertDestinationInterface {
   SpinMutex mutex_;
 
  private:
+  /**
+   * @brief Get the set of blocks that were used by clients of this
+   *        InsertDestination for insertion.
+   * @warning Should only be called AFTER this InsertDestination will no longer
+   *          be used, and all blocks have been returned to it via
+   *          returnBlock().
+   *
+   * @return A vector of block_ids of blocks that were used for insertion.
+   **/
+  std::vector<block_id> getTouchedBlocks() {
+    SpinMutexLock lock(mutex_);
+    return getTouchedBlocksInternal();
+  }
+
+  virtual std::vector<block_id> getTouchedBlocksInternal() = 0;
+
   // TODO(shoban): Workaround to support sort. Sort needs finegrained control of
   // blocks being used to insert, since inserting in an arbitrary block could
   // lead to unsorted results. InsertDestination API changed while sort was
   // being implemented.
   friend class merge_run_operator::RunCreator;
 
+  // NOTE(zuyu): Access getTouchedBlocks.
+  friend class AggregationOperatorTest;
+  friend class merge_run_operator::RunTest;
+  friend class merge_run_operator::RunMergerTest;
+
+  FRIEND_TEST(HashJoinOperatorTest, LongKeyHashJoinTest);
+  FRIEND_TEST(HashJoinOperatorTest, IntDuplicateKeyHashJoinTest);
+  FRIEND_TEST(HashJoinOperatorTest, CharKeyCartesianProductHashJoinTest);
+  FRIEND_TEST(HashJoinOperatorTest, VarCharDuplicateKeyHashJoinTest);
+  FRIEND_TEST(HashJoinOperatorTest, CompositeKeyHashJoinTest);
+  FRIEND_TEST(HashJoinOperatorTest, CompositeKeyHashJoinWithResidualPredicateTest);
+  FRIEND_TEST(HashJoinOperatorTest, SingleAttributePartitionedLongKeyHashJoinTest);
+  FRIEND_TEST(HashJoinOperatorTest, SingleAttributePartitionedCompositeKeyHashJoinTest);
+  FRIEND_TEST(HashJoinOperatorTest,
+              SingleAttributePartitionedCompositeKeyHashJoinWithResidualPredicateTest);
+
   DISALLOW_COPY_AND_ASSIGN(InsertDestination);
 };
 
@@ -358,15 +375,15 @@ class AlwaysCreateBlockInsertDestination : public InsertDestination {
 
   MutableBlockReference createNewBlock() override;
 
-  const std::vector<block_id>& getTouchedBlocksInternal() override {
-    return returned_block_ids_;
-  }
-
   void getPartiallyFilledBlocks(std::vector<MutableBlockReference> *partial_blocks,
                                 std::vector<partition_id> *part_ids) override {
   }
 
  private:
+  std::vector<block_id> getTouchedBlocksInternal() override {
+    return returned_block_ids_;
+  }
+
   std::vector<block_id> returned_block_ids_;
 
   DISALLOW_COPY_AND_ASSIGN(AlwaysCreateBlockInsertDestination);
@@ -454,11 +471,11 @@ class BlockPoolInsertDestination : public InsertDestination {
   void getPartiallyFilledBlocks(std::vector<MutableBlockReference> *partial_blocks,
                                 std::vector<partition_id> *part_ids) override;
 
-  const std::vector<block_id>& getTouchedBlocksInternal() override;
-
   MutableBlockReference createNewBlock() override;
 
  private:
+  std::vector<block_id> getTouchedBlocksInternal() override;
+
   FRIEND_TEST(QueryManagerTest, TwoNodesDAGPartiallyFilledBlocksTest);
 
   // A vector of references to blocks which are loaded in memory.
@@ -585,10 +602,9 @@ class PartitionAwareInsertDestination : public InsertDestination {
   MutableBlockReference createNewBlock() override;
   MutableBlockReference createNewBlockInPartition(const partition_id part_id);
 
-  const std::vector<block_id>& getTouchedBlocksInternal() override;
-  const std::vector<block_id>& getTouchedBlocksInternalInPartition(partition_id part_id);
-
  private:
+  std::vector<block_id> getTouchedBlocksInternal() override;
+
   /**
    * @brief Get the set of blocks that were partially filled by clients of this
    *        InsertDestination for insertion.
@@ -652,8 +668,6 @@ class PartitionAwareInsertDestination : public InsertDestination {
   std::vector< std::vector<block_id> > available_block_ids_;
   // A vector of done block ids for each partition.
   std::vector< std::vector<block_id> > done_block_ids_;
-  // Done block ids across all partitions.
-  std::vector<block_id> all_partitions_done_block_ids_;
   // Mutex for locking each partition separately.
   SpinMutex *mutexes_for_partition_;
 


[44/46] incubator-quickstep git commit: Fix the hanging problem of SeparateChainingHashTable::resize()

Posted by ji...@apache.org.
Fix the hanging problem of SeparateChainingHashTable::resize()


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

Branch: refs/heads/fix-iwyu
Commit: d1dbb0d9bc2d1f001deee4039157b0be464870f4
Parents: 539e1eb
Author: Jianqiao Zhu <ji...@cs.wisc.edu>
Authored: Sun Feb 18 01:16:07 2018 -0600
Committer: Jianqiao Zhu <ji...@cs.wisc.edu>
Committed: Sun Feb 18 01:16:07 2018 -0600

----------------------------------------------------------------------
 storage/SeparateChainingHashTable.hpp | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d1dbb0d9/storage/SeparateChainingHashTable.hpp
----------------------------------------------------------------------
diff --git a/storage/SeparateChainingHashTable.hpp b/storage/SeparateChainingHashTable.hpp
index 2403623..2594f61 100644
--- a/storage/SeparateChainingHashTable.hpp
+++ b/storage/SeparateChainingHashTable.hpp
@@ -243,9 +243,10 @@ class SeparateChainingHashTable : public HashTable<ValueT,
                                         HashTablePreallocationState *prealloc_state);
 
   // Determine whether it is actually necessary to resize this hash table.
-  // Checks that there is at least one unallocated bucket, and that there is
+  // Checks that there are sufficient unallocated buckets, and that there are
   // at least 'extra_variable_storage' bytes of variable-length storage free.
-  bool isFull(const std::size_t extra_variable_storage) const;
+  bool isFull(const std::size_t extra_buckets,
+              const std::size_t extra_variable_storage) const;
 
   // Helper object to manage key storage.
   HashTableKeyManager<serializable, force_key_copy> key_manager_;
@@ -1131,7 +1132,7 @@ void SeparateChainingHashTable<ValueT, resizable, serializable, force_key_copy,
   // Recheck whether the hash table is still full. Note that multiple threads
   // might wait to rebuild this hash table simultaneously. Only the first one
   // should do the rebuild.
-  if (!isFull(extra_variable_storage)) {
+  if (!isFull(extra_buckets, extra_variable_storage)) {
     return;
   }
 
@@ -1505,9 +1506,11 @@ template <typename ValueT,
           bool force_key_copy,
           bool allow_duplicate_keys>
 bool SeparateChainingHashTable<ValueT, resizable, serializable, force_key_copy, allow_duplicate_keys>
-    ::isFull(const std::size_t extra_variable_storage) const {
-  if (header_->buckets_allocated.load(std::memory_order_relaxed) >= header_->num_buckets) {
-    // All buckets are allocated.
+    ::isFull(const std::size_t extra_buckets,
+             const std::size_t extra_variable_storage) const {
+  if (header_->buckets_allocated.load(std::memory_order_relaxed)
+          + extra_buckets >= header_->num_buckets) {
+    // Not enough buckets.
     return true;
   }
 


[35/46] incubator-quickstep git commit: Remove glog source code from third party

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/glog/log_severity.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/glog/log_severity.h b/third_party/src/glog/src/glog/log_severity.h
deleted file mode 100644
index 99945a4..0000000
--- a/third_party/src/glog/src/glog/log_severity.h
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef BASE_LOG_SEVERITY_H__
-#define BASE_LOG_SEVERITY_H__
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-// Variables of type LogSeverity are widely taken to lie in the range
-// [0, NUM_SEVERITIES-1].  Be careful to preserve this assumption if
-// you ever need to change their values or add a new severity.
-typedef int LogSeverity;
-
-const int GLOG_INFO = 0, GLOG_WARNING = 1, GLOG_ERROR = 2, GLOG_FATAL = 3,
-  NUM_SEVERITIES = 4;
-#ifndef GLOG_NO_ABBREVIATED_SEVERITIES
-# ifdef ERROR
-#  error ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail.
-# endif
-const int INFO = GLOG_INFO, WARNING = GLOG_WARNING,
-  ERROR = GLOG_ERROR, FATAL = GLOG_FATAL;
-#endif
-
-// DFATAL is FATAL in debug mode, ERROR in normal mode
-#ifdef NDEBUG
-#define DFATAL_LEVEL ERROR
-#else
-#define DFATAL_LEVEL FATAL
-#endif
-
-extern GOOGLE_GLOG_DLL_DECL const char* const LogSeverityNames[NUM_SEVERITIES];
-
-// NDEBUG usage helpers related to (RAW_)DCHECK:
-//
-// DEBUG_MODE is for small !NDEBUG uses like
-//   if (DEBUG_MODE) foo.CheckThatFoo();
-// instead of substantially more verbose
-//   #ifndef NDEBUG
-//     foo.CheckThatFoo();
-//   #endif
-//
-// IF_DEBUG_MODE is for small !NDEBUG uses like
-//   IF_DEBUG_MODE( string error; )
-//   DCHECK(Foo(&error)) << error;
-// instead of substantially more verbose
-//   #ifndef NDEBUG
-//     string error;
-//     DCHECK(Foo(&error)) << error;
-//   #endif
-//
-#ifdef NDEBUG
-enum { DEBUG_MODE = 0 };
-#define IF_DEBUG_MODE(x)
-#else
-enum { DEBUG_MODE = 1 };
-#define IF_DEBUG_MODE(x) x
-#endif
-
-#endif  // BASE_LOG_SEVERITY_H__

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/glog/logging.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/glog/logging.h b/third_party/src/glog/src/glog/logging.h
deleted file mode 100644
index 8a6dca0..0000000
--- a/third_party/src/glog/src/glog/logging.h
+++ /dev/null
@@ -1,1619 +0,0 @@
-// Copyright (c) 1999, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney
-//
-// This file contains #include information about logging-related stuff.
-// Pretty much everybody needs to #include this file so that they can
-// log various happenings.
-//
-#ifndef _LOGGING_H_
-#define _LOGGING_H_
-
-#include "glog/config.h"
-
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <iosfwd>
-#include <ostream>
-#include <sstream>
-#include <string>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#include <vector>
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-#if defined(_MSC_VER)
-#define GLOG_MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
-                                     __pragma(warning(disable:n))
-#define GLOG_MSVC_POP_WARNING() __pragma(warning(pop))
-#else
-#define GLOG_MSVC_PUSH_DISABLE_WARNING(n)
-#define GLOG_MSVC_POP_WARNING()
-#endif
-
-// We care a lot about number of bits things take up.  Unfortunately,
-// systems define their bit-specific ints in a lot of different ways.
-// We use our own way, and have a typedef to get there.
-// Note: these commands below may look like "#if 1" or "#if 0", but
-// that's because they were constructed that way at ./configure time.
-// Look at logging.h.in to see how they're calculated (based on your config).
-#ifdef HAVE_STDINT_H
-#include <stdint.h>             // the normal place uint16_t is defined
-#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>          // the normal place u_int16_t is defined
-#endif
-#ifdef HAVE_INTTYPES_H
-#include <inttypes.h>           // a third place for uint16_t or u_int16_t
-#endif
-
-#if 0
-#include <gflags/gflags.h>
-#endif
-
-namespace google {
-
-#if 1    // the C99 format
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#elif 0  // the BSD format
-typedef int32_t int32;
-typedef u_int32_t uint32;
-typedef int64_t int64;
-typedef u_int64_t uint64;
-#elif 0  // the windows (vc7) format
-typedef __int32 int32;
-typedef unsigned __int32 uint32;
-typedef __int64 int64;
-typedef unsigned __int64 uint64;
-#else
-#error Do not know how to define a 32-bit integer quantity on your system
-#endif
-
-}
-
-// The global value of GOOGLE_STRIP_LOG. All the messages logged to
-// LOG(XXX) with severity less than GOOGLE_STRIP_LOG will not be displayed.
-// If it can be determined at compile time that the message will not be
-// printed, the statement will be compiled out.
-//
-// Example: to strip out all INFO and WARNING messages, use the value
-// of 2 below. To make an exception for WARNING messages from a single
-// file, add "#define GOOGLE_STRIP_LOG 1" to that file _before_ including
-// base/logging.h
-#ifndef GOOGLE_STRIP_LOG
-#define GOOGLE_STRIP_LOG 0
-#endif
-
-// GCC can be told that a certain branch is not likely to be taken (for
-// instance, a CHECK failure), and use that information in static analysis.
-// Giving it this information can help it optimize for the common case in
-// the absence of better information (ie. -fprofile-arcs).
-//
-#ifndef GOOGLE_PREDICT_BRANCH_NOT_TAKEN
-#ifdef HAVE___BUILTIN_EXPECT
-#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) (__builtin_expect(x, 0))
-#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0))
-#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
-#else
-#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) x
-#define GOOGLE_PREDICT_FALSE(x) x
-#define GOOGLE_PREDICT_TRUE(x) x
-#endif
-#endif
-
-// Make a bunch of macros for logging.  The way to log things is to stream
-// things to LOG(<a particular severity level>).  E.g.,
-//
-//   LOG(INFO) << "Found " << num_cookies << " cookies";
-//
-// You can capture log messages in a string, rather than reporting them
-// immediately:
-//
-//   vector<string> errors;
-//   LOG_STRING(ERROR, &errors) << "Couldn't parse cookie #" << cookie_num;
-//
-// This pushes back the new error onto 'errors'; if given a NULL pointer,
-// it reports the error via LOG(ERROR).
-//
-// You can also do conditional logging:
-//
-//   LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
-//
-// You can also do occasional logging (log every n'th occurrence of an
-// event):
-//
-//   LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
-//
-// The above will cause log messages to be output on the 1st, 11th, 21st, ...
-// times it is executed.  Note that the special google::COUNTER value is used
-// to identify which repetition is happening.
-//
-// You can also do occasional conditional logging (log every n'th
-// occurrence of an event, when condition is satisfied):
-//
-//   LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << google::COUNTER
-//                                           << "th big cookie";
-//
-// You can log messages the first N times your code executes a line. E.g.
-//
-//   LOG_FIRST_N(INFO, 20) << "Got the " << google::COUNTER << "th cookie";
-//
-// Outputs log messages for the first 20 times it is executed.
-//
-// Analogous SYSLOG, SYSLOG_IF, and SYSLOG_EVERY_N macros are available.
-// These log to syslog as well as to the normal logs.  If you use these at
-// all, you need to be aware that syslog can drastically reduce performance,
-// especially if it is configured for remote logging!  Don't use these
-// unless you fully understand this and have a concrete need to use them.
-// Even then, try to minimize your use of them.
-//
-// There are also "debug mode" logging macros like the ones above:
-//
-//   DLOG(INFO) << "Found cookies";
-//
-//   DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
-//
-//   DLOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
-//
-// All "debug mode" logging is compiled away to nothing for non-debug mode
-// compiles.
-//
-// We also have
-//
-//   LOG_ASSERT(assertion);
-//   DLOG_ASSERT(assertion);
-//
-// which is syntactic sugar for {,D}LOG_IF(FATAL, assert fails) << assertion;
-//
-// There are "verbose level" logging macros.  They look like
-//
-//   VLOG(1) << "I'm printed when you run the program with --v=1 or more";
-//   VLOG(2) << "I'm printed when you run the program with --v=2 or more";
-//
-// These always log at the INFO log level (when they log at all).
-// The verbose logging can also be turned on module-by-module.  For instance,
-//    --vmodule=mapreduce=2,file=1,gfs*=3 --v=0
-// will cause:
-//   a. VLOG(2) and lower messages to be printed from mapreduce.{h,cc}
-//   b. VLOG(1) and lower messages to be printed from file.{h,cc}
-//   c. VLOG(3) and lower messages to be printed from files prefixed with "gfs"
-//   d. VLOG(0) and lower messages to be printed from elsewhere
-//
-// The wildcarding functionality shown by (c) supports both '*' (match
-// 0 or more characters) and '?' (match any single character) wildcards.
-//
-// There's also VLOG_IS_ON(n) "verbose level" condition macro. To be used as
-//
-//   if (VLOG_IS_ON(2)) {
-//     // do some logging preparation and logging
-//     // that can't be accomplished with just VLOG(2) << ...;
-//   }
-//
-// There are also VLOG_IF, VLOG_EVERY_N and VLOG_IF_EVERY_N "verbose level"
-// condition macros for sample cases, when some extra computation and
-// preparation for logs is not needed.
-//   VLOG_IF(1, (size > 1024))
-//      << "I'm printed when size is more than 1024 and when you run the "
-//         "program with --v=1 or more";
-//   VLOG_EVERY_N(1, 10)
-//      << "I'm printed every 10th occurrence, and when you run the program "
-//         "with --v=1 or more. Present occurence is " << google::COUNTER;
-//   VLOG_IF_EVERY_N(1, (size > 1024), 10)
-//      << "I'm printed on every 10th occurence of case when size is more "
-//         " than 1024, when you run the program with --v=1 or more. ";
-//         "Present occurence is " << google::COUNTER;
-//
-// The supported severity levels for macros that allow you to specify one
-// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
-// Note that messages of a given severity are logged not only in the
-// logfile for that severity, but also in all logfiles of lower severity.
-// E.g., a message of severity FATAL will be logged to the logfiles of
-// severity FATAL, ERROR, WARNING, and INFO.
-//
-// There is also the special severity of DFATAL, which logs FATAL in
-// debug mode, ERROR in normal mode.
-//
-// Very important: logging a message at the FATAL severity level causes
-// the program to terminate (after the message is logged).
-//
-// Unless otherwise specified, logs will be written to the filename
-// "<program name>.<hostname>.<user name>.log.<severity level>.", followed
-// by the date, time, and pid (you can't prevent the date, time, and pid
-// from being in the filename).
-//
-// The logging code takes two flags:
-//     --v=#           set the verbose level
-//     --logtostderr   log all the messages to stderr instead of to logfiles
-
-// LOG LINE PREFIX FORMAT
-//
-// Log lines have this form:
-//
-//     Lmmdd hh:mm:ss.uuuuuu threadid file:line] msg...
-//
-// where the fields are defined as follows:
-//
-//   L                A single character, representing the log level
-//                    (eg 'I' for INFO)
-//   mm               The month (zero padded; ie May is '05')
-//   dd               The day (zero padded)
-//   hh:mm:ss.uuuuuu  Time in hours, minutes and fractional seconds
-//   threadid         The space-padded thread ID as returned by GetTID()
-//                    (this matches the PID on Linux)
-//   file             The file name
-//   line             The line number
-//   msg              The user-supplied message
-//
-// Example:
-//
-//   I1103 11:57:31.739339 24395 google.cc:2341] Command line: ./some_prog
-//   I1103 11:57:31.739403 24395 google.cc:2342] Process id 24395
-//
-// NOTE: although the microseconds are useful for comparing events on
-// a single machine, clocks on different machines may not be well
-// synchronized.  Hence, use caution when comparing the low bits of
-// timestamps from different machines.
-
-#ifndef DECLARE_VARIABLE
-#define MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#define DECLARE_VARIABLE(type, shorttype, name, tn)                     \
-  namespace fL##shorttype {                                             \
-    extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name;                      \
-  }                                                                     \
-  using fL##shorttype::FLAGS_##name
-
-// bool specialization
-#define DECLARE_bool(name) \
-  DECLARE_VARIABLE(bool, B, name, bool)
-
-// int32 specialization
-#define DECLARE_int32(name) \
-  DECLARE_VARIABLE(google::int32, I, name, int32)
-
-// Special case for string, because we have to specify the namespace
-// std::string, which doesn't play nicely with our FLAG__namespace hackery.
-#define DECLARE_string(name)                                            \
-  namespace fLS {                                                       \
-    extern GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name;              \
-  }                                                                     \
-  using fLS::FLAGS_##name
-#endif
-
-// Set whether log messages go to stderr instead of logfiles
-DECLARE_bool(logtostderr);
-
-// Set whether log messages go to stderr in addition to logfiles.
-DECLARE_bool(alsologtostderr);
-
-// Set color messages logged to stderr (if supported by terminal).
-DECLARE_bool(colorlogtostderr);
-
-// Log messages at a level >= this flag are automatically sent to
-// stderr in addition to log files.
-DECLARE_int32(stderrthreshold);
-
-// Set whether the log prefix should be prepended to each line of output.
-DECLARE_bool(log_prefix);
-
-// Log messages at a level <= this flag are buffered.
-// Log messages at a higher level are flushed immediately.
-DECLARE_int32(logbuflevel);
-
-// Sets the maximum number of seconds which logs may be buffered for.
-DECLARE_int32(logbufsecs);
-
-// Log suppression level: messages logged at a lower level than this
-// are suppressed.
-DECLARE_int32(minloglevel);
-
-// If specified, logfiles are written into this directory instead of the
-// default logging directory.
-DECLARE_string(log_dir);
-
-// Sets the path of the directory into which to put additional links
-// to the log files.
-DECLARE_string(log_link);
-
-DECLARE_int32(v);  // in vlog_is_on.cc
-
-// Sets the maximum log file size (in MB).
-DECLARE_int32(max_log_size);
-
-// Sets whether to avoid logging to the disk if the disk is full.
-DECLARE_bool(stop_logging_if_full_disk);
-
-#ifdef MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#undef MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#undef DECLARE_VARIABLE
-#undef DECLARE_bool
-#undef DECLARE_int32
-#undef DECLARE_string
-#endif
-
-// Log messages below the GOOGLE_STRIP_LOG level will be compiled away for
-// security reasons. See LOG(severtiy) below.
-
-// A few definitions of macros that don't generate much code.  Since
-// LOG(INFO) and its ilk are used all over our code, it's
-// better to have compact code for these operations.
-
-#if GOOGLE_STRIP_LOG == 0
-#define COMPACT_GOOGLE_LOG_INFO google::LogMessage( \
-      __FILE__, __LINE__)
-#define LOG_TO_STRING_INFO(message) google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_INFO, message)
-#else
-#define COMPACT_GOOGLE_LOG_INFO google::NullStream()
-#define LOG_TO_STRING_INFO(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 1
-#define COMPACT_GOOGLE_LOG_WARNING google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_WARNING)
-#define LOG_TO_STRING_WARNING(message) google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_WARNING, message)
-#else
-#define COMPACT_GOOGLE_LOG_WARNING google::NullStream()
-#define LOG_TO_STRING_WARNING(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 2
-#define COMPACT_GOOGLE_LOG_ERROR google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_ERROR)
-#define LOG_TO_STRING_ERROR(message) google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_ERROR, message)
-#else
-#define COMPACT_GOOGLE_LOG_ERROR google::NullStream()
-#define LOG_TO_STRING_ERROR(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 3
-#define COMPACT_GOOGLE_LOG_FATAL google::LogMessageFatal( \
-      __FILE__, __LINE__)
-#define LOG_TO_STRING_FATAL(message) google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_FATAL, message)
-#else
-#define COMPACT_GOOGLE_LOG_FATAL google::NullStreamFatal()
-#define LOG_TO_STRING_FATAL(message) google::NullStreamFatal()
-#endif
-
-// For DFATAL, we want to use LogMessage (as opposed to
-// LogMessageFatal), to be consistent with the original behavior.
-#ifdef NDEBUG
-#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
-#elif GOOGLE_STRIP_LOG <= 3
-#define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_FATAL)
-#else
-#define COMPACT_GOOGLE_LOG_DFATAL google::NullStreamFatal()
-#endif
-
-#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, &google::LogMessage::SendToLog)
-#define SYSLOG_INFO(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_WARNING(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_WARNING(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_ERROR(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_ERROR(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_FATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_FATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_DFATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_DFATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-
-#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) || defined(__CYGWIN32__)
-// A very useful logging macro to log windows errors:
-#define LOG_SYSRESULT(result) \
-  if (FAILED(HRESULT_FROM_WIN32(result))) { \
-    LPSTR message = NULL; \
-    LPSTR msg = reinterpret_cast<LPSTR>(&message); \
-    DWORD message_length = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | \
-                         FORMAT_MESSAGE_FROM_SYSTEM, \
-                         0, result, 0, msg, 100, NULL); \
-    if (message_length > 0) { \
-      google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, 0, \
-          &google::LogMessage::SendToLog).stream() \
-          << reinterpret_cast<const char*>(message); \
-      LocalFree(message); \
-    } \
-  }
-#endif
-
-// We use the preprocessor's merging operator, "##", so that, e.g.,
-// LOG(INFO) becomes the token GOOGLE_LOG_INFO.  There's some funny
-// subtle difference between ostream member streaming functions (e.g.,
-// ostream::operator<<(int) and ostream non-member streaming functions
-// (e.g., ::operator<<(ostream&, string&): it turns out that it's
-// impossible to stream something like a string directly to an unnamed
-// ostream. We employ a neat hack by calling the stream() member
-// function of LogMessage which seems to avoid the problem.
-#define LOG(severity) COMPACT_GOOGLE_LOG_ ## severity.stream()
-#define SYSLOG(severity) SYSLOG_ ## severity(0).stream()
-
-namespace google {
-
-// They need the definitions of integer types.
-#include "glog/log_severity.h"
-#include "glog/vlog_is_on.h"
-
-// Initialize google's logging library. You will see the program name
-// specified by argv0 in log outputs.
-GOOGLE_GLOG_DLL_DECL void InitGoogleLogging(const char* argv0);
-
-// Shutdown google's logging library.
-GOOGLE_GLOG_DLL_DECL void ShutdownGoogleLogging();
-
-// Install a function which will be called after LOG(FATAL).
-GOOGLE_GLOG_DLL_DECL void InstallFailureFunction(void (*fail_func)());
-
-class LogSink;  // defined below
-
-// If a non-NULL sink pointer is given, we push this message to that sink.
-// For LOG_TO_SINK we then do normal LOG(severity) logging as well.
-// This is useful for capturing messages and passing/storing them
-// somewhere more specific than the global log of the process.
-// Argument types:
-//   LogSink* sink;
-//   LogSeverity severity;
-// The cast is to disambiguate NULL arguments.
-#define LOG_TO_SINK(sink, severity) \
-  google::LogMessage(                                    \
-      __FILE__, __LINE__,                                               \
-      google::GLOG_ ## severity,                         \
-      static_cast<google::LogSink*>(sink), true).stream()
-#define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity)                  \
-  google::LogMessage(                                    \
-      __FILE__, __LINE__,                                               \
-      google::GLOG_ ## severity,                         \
-      static_cast<google::LogSink*>(sink), false).stream()
-
-// If a non-NULL string pointer is given, we write this message to that string.
-// We then do normal LOG(severity) logging as well.
-// This is useful for capturing messages and storing them somewhere more
-// specific than the global log of the process.
-// Argument types:
-//   string* message;
-//   LogSeverity severity;
-// The cast is to disambiguate NULL arguments.
-// NOTE: LOG(severity) expands to LogMessage().stream() for the specified
-// severity.
-#define LOG_TO_STRING(severity, message) \
-  LOG_TO_STRING_##severity(static_cast<string*>(message)).stream()
-
-// If a non-NULL pointer is given, we push the message onto the end
-// of a vector of strings; otherwise, we report it with LOG(severity).
-// This is handy for capturing messages and perhaps passing them back
-// to the caller, rather than reporting them immediately.
-// Argument types:
-//   LogSeverity severity;
-//   vector<string> *outvec;
-// The cast is to disambiguate NULL arguments.
-#define LOG_STRING(severity, outvec) \
-  LOG_TO_STRING_##severity(static_cast<vector<string>*>(outvec)).stream()
-
-#define LOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-#define SYSLOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & SYSLOG(severity)
-
-#define LOG_ASSERT(condition)  \
-  LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
-#define SYSLOG_ASSERT(condition) \
-  SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
-
-// CHECK dies with a fatal error if condition is not true.  It is *not*
-// controlled by NDEBUG, so the check will be executed regardless of
-// compilation mode.  Therefore, it is safe to do things like:
-//    CHECK(fp->Write(x) == 4)
-#define CHECK(condition)  \
-      LOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN(!(condition))) \
-             << "Check failed: " #condition " "
-
-// A container for a string pointer which can be evaluated to a bool -
-// true iff the pointer is NULL.
-struct CheckOpString {
-  CheckOpString(std::string* str) : str_(str) { }
-  // No destructor: if str_ is non-NULL, we're about to LOG(FATAL),
-  // so there's no point in cleaning up str_.
-  operator bool() const {
-    return GOOGLE_PREDICT_BRANCH_NOT_TAKEN(str_ != NULL);
-  }
-  std::string* str_;
-};
-
-// Function is overloaded for integral types to allow static const
-// integrals declared in classes and not defined to be used as arguments to
-// CHECK* macros. It's not encouraged though.
-template <class T>
-inline const T&       GetReferenceableValue(const T&           t) { return t; }
-inline char           GetReferenceableValue(char               t) { return t; }
-inline unsigned char  GetReferenceableValue(unsigned char      t) { return t; }
-inline signed char    GetReferenceableValue(signed char        t) { return t; }
-inline short          GetReferenceableValue(short              t) { return t; }
-inline unsigned short GetReferenceableValue(unsigned short     t) { return t; }
-inline int            GetReferenceableValue(int                t) { return t; }
-inline unsigned int   GetReferenceableValue(unsigned int       t) { return t; }
-inline long           GetReferenceableValue(long               t) { return t; }
-inline unsigned long  GetReferenceableValue(unsigned long      t) { return t; }
-inline long long      GetReferenceableValue(long long          t) { return t; }
-inline unsigned long long GetReferenceableValue(unsigned long long t) {
-  return t;
-}
-
-// This is a dummy class to define the following operator.
-struct DummyClassToDefineOperator {};
-
-}
-
-// Define global operator<< to declare using ::operator<<.
-// This declaration will allow use to use CHECK macros for user
-// defined classes which have operator<< (e.g., stl_logging.h).
-inline std::ostream& operator<<(
-    std::ostream& out, const google::DummyClassToDefineOperator&) {
-  return out;
-}
-
-namespace google {
-
-// This formats a value for a failing CHECK_XX statement.  Ordinarily,
-// it uses the definition for operator<<, with a few special cases below.
-template <typename T>
-inline void MakeCheckOpValueString(std::ostream* os, const T& v) {
-  (*os) << v;
-}
-
-// Overrides for char types provide readable values for unprintable
-// characters.
-template <> GOOGLE_GLOG_DLL_DECL
-void MakeCheckOpValueString(std::ostream* os, const char& v);
-template <> GOOGLE_GLOG_DLL_DECL
-void MakeCheckOpValueString(std::ostream* os, const signed char& v);
-template <> GOOGLE_GLOG_DLL_DECL
-void MakeCheckOpValueString(std::ostream* os, const unsigned char& v);
-
-// Build the error message string. Specify no inlining for code size.
-template <typename T1, typename T2>
-std::string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext)
-#ifdef HAVE___ATTRIBUTE__
-    __attribute__((noinline));
-#else
-    ;
-#endif
-
-namespace base {
-namespace internal {
-
-// If "s" is less than base_logging::INFO, returns base_logging::INFO.
-// If "s" is greater than base_logging::FATAL, returns
-// base_logging::ERROR.  Otherwise, returns "s".
-LogSeverity NormalizeSeverity(LogSeverity s);
-
-}  // namespace internal
-
-// A helper class for formatting "expr (V1 vs. V2)" in a CHECK_XX
-// statement.  See MakeCheckOpString for sample usage.  Other
-// approaches were considered: use of a template method (e.g.,
-// base::BuildCheckOpString(exprtext, base::Print<T1>, &v1,
-// base::Print<T2>, &v2), however this approach has complications
-// related to volatile arguments and function-pointer arguments).
-class GOOGLE_GLOG_DLL_DECL CheckOpMessageBuilder {
- public:
-  // Inserts "exprtext" and " (" to the stream.
-  explicit CheckOpMessageBuilder(const char *exprtext);
-  // Deletes "stream_".
-  ~CheckOpMessageBuilder();
-  // For inserting the first variable.
-  std::ostream* ForVar1() { return stream_; }
-  // For inserting the second variable (adds an intermediate " vs. ").
-  std::ostream* ForVar2();
-  // Get the result (inserts the closing ")").
-  std::string* NewString();
-
- private:
-  std::ostringstream *stream_;
-};
-
-}  // namespace base
-
-template <typename T1, typename T2>
-std::string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext) {
-  base::CheckOpMessageBuilder comb(exprtext);
-  MakeCheckOpValueString(comb.ForVar1(), v1);
-  MakeCheckOpValueString(comb.ForVar2(), v2);
-  return comb.NewString();
-}
-
-// Helper functions for CHECK_OP macro.
-// The (int, int) specialization works around the issue that the compiler
-// will not instantiate the template version of the function on values of
-// unnamed enum type - see comment below.
-#define DEFINE_CHECK_OP_IMPL(name, op) \
-  template <typename T1, typename T2> \
-  inline std::string* name##Impl(const T1& v1, const T2& v2,    \
-                            const char* exprtext) { \
-    if (GOOGLE_PREDICT_TRUE(v1 op v2)) return NULL; \
-    else return MakeCheckOpString(v1, v2, exprtext); \
-  } \
-  inline std::string* name##Impl(int v1, int v2, const char* exprtext) { \
-    return name##Impl<int, int>(v1, v2, exprtext); \
-  }
-
-// We use the full name Check_EQ, Check_NE, etc. in case the file including
-// base/logging.h provides its own #defines for the simpler names EQ, NE, etc.
-// This happens if, for example, those are used as token names in a
-// yacc grammar.
-DEFINE_CHECK_OP_IMPL(Check_EQ, ==)  // Compilation error with CHECK_EQ(NULL, x)?
-DEFINE_CHECK_OP_IMPL(Check_NE, !=)  // Use CHECK(x == NULL) instead.
-DEFINE_CHECK_OP_IMPL(Check_LE, <=)
-DEFINE_CHECK_OP_IMPL(Check_LT, < )
-DEFINE_CHECK_OP_IMPL(Check_GE, >=)
-DEFINE_CHECK_OP_IMPL(Check_GT, > )
-#undef DEFINE_CHECK_OP_IMPL
-
-// Helper macro for binary operators.
-// Don't use this macro directly in your code, use CHECK_EQ et al below.
-
-#if defined(STATIC_ANALYSIS)
-// Only for static analysis tool to know that it is equivalent to assert
-#define CHECK_OP_LOG(name, op, val1, val2, log) CHECK((val1) op (val2))
-#elif !defined(NDEBUG)
-// In debug mode, avoid constructing CheckOpStrings if possible,
-// to reduce the overhead of CHECK statments by 2x.
-// Real DCHECK-heavy tests have seen 1.5x speedups.
-
-// The meaning of "string" might be different between now and 
-// when this macro gets invoked (e.g., if someone is experimenting
-// with other string implementations that get defined after this
-// file is included).  Save the current meaning now and use it 
-// in the macro.
-typedef std::string _Check_string;
-#define CHECK_OP_LOG(name, op, val1, val2, log)                         \
-  while (google::_Check_string* _result =                \
-         google::Check##name##Impl(                      \
-             google::GetReferenceableValue(val1),        \
-             google::GetReferenceableValue(val2),        \
-             #val1 " " #op " " #val2))                                  \
-    log(__FILE__, __LINE__,                                             \
-        google::CheckOpString(_result)).stream()
-#else
-// In optimized mode, use CheckOpString to hint to compiler that
-// the while condition is unlikely.
-#define CHECK_OP_LOG(name, op, val1, val2, log)                         \
-  while (google::CheckOpString _result =                 \
-         google::Check##name##Impl(                      \
-             google::GetReferenceableValue(val1),        \
-             google::GetReferenceableValue(val2),        \
-             #val1 " " #op " " #val2))                                  \
-    log(__FILE__, __LINE__, _result).stream()
-#endif  // STATIC_ANALYSIS, !NDEBUG
-
-#if GOOGLE_STRIP_LOG <= 3
-#define CHECK_OP(name, op, val1, val2) \
-  CHECK_OP_LOG(name, op, val1, val2, google::LogMessageFatal)
-#else
-#define CHECK_OP(name, op, val1, val2) \
-  CHECK_OP_LOG(name, op, val1, val2, google::NullStreamFatal)
-#endif // STRIP_LOG <= 3
-
-// Equality/Inequality checks - compare two values, and log a FATAL message
-// including the two values when the result is not as expected.  The values
-// must have operator<<(ostream, ...) defined.
-//
-// You may append to the error message like so:
-//   CHECK_NE(1, 2) << ": The world must be ending!";
-//
-// We are very careful to ensure that each argument is evaluated exactly
-// once, and that anything which is legal to pass as a function argument is
-// legal here.  In particular, the arguments may be temporary expressions
-// which will end up being destroyed at the end of the apparent statement,
-// for example:
-//   CHECK_EQ(string("abc")[1], 'b');
-//
-// WARNING: These don't compile correctly if one of the arguments is a pointer
-// and the other is NULL. To work around this, simply static_cast NULL to the
-// type of the desired pointer.
-
-#define CHECK_EQ(val1, val2) CHECK_OP(_EQ, ==, val1, val2)
-#define CHECK_NE(val1, val2) CHECK_OP(_NE, !=, val1, val2)
-#define CHECK_LE(val1, val2) CHECK_OP(_LE, <=, val1, val2)
-#define CHECK_LT(val1, val2) CHECK_OP(_LT, < , val1, val2)
-#define CHECK_GE(val1, val2) CHECK_OP(_GE, >=, val1, val2)
-#define CHECK_GT(val1, val2) CHECK_OP(_GT, > , val1, val2)
-
-// Check that the input is non NULL.  This very useful in constructor
-// initializer lists.
-
-#define CHECK_NOTNULL(val) \
-  google::CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val))
-
-// Helper functions for string comparisons.
-// To avoid bloat, the definitions are in logging.cc.
-#define DECLARE_CHECK_STROP_IMPL(func, expected) \
-  GOOGLE_GLOG_DLL_DECL std::string* Check##func##expected##Impl( \
-      const char* s1, const char* s2, const char* names);
-DECLARE_CHECK_STROP_IMPL(strcmp, true)
-DECLARE_CHECK_STROP_IMPL(strcmp, false)
-DECLARE_CHECK_STROP_IMPL(strcasecmp, true)
-DECLARE_CHECK_STROP_IMPL(strcasecmp, false)
-#undef DECLARE_CHECK_STROP_IMPL
-
-// Helper macro for string comparisons.
-// Don't use this macro directly in your code, use CHECK_STREQ et al below.
-#define CHECK_STROP(func, op, expected, s1, s2) \
-  while (google::CheckOpString _result = \
-         google::Check##func##expected##Impl((s1), (s2), \
-                                     #s1 " " #op " " #s2)) \
-    LOG(FATAL) << *_result.str_
-
-
-// String (char*) equality/inequality checks.
-// CASE versions are case-insensitive.
-//
-// Note that "s1" and "s2" may be temporary strings which are destroyed
-// by the compiler at the end of the current "full expression"
-// (e.g. CHECK_STREQ(Foo().c_str(), Bar().c_str())).
-
-#define CHECK_STREQ(s1, s2) CHECK_STROP(strcmp, ==, true, s1, s2)
-#define CHECK_STRNE(s1, s2) CHECK_STROP(strcmp, !=, false, s1, s2)
-#define CHECK_STRCASEEQ(s1, s2) CHECK_STROP(strcasecmp, ==, true, s1, s2)
-#define CHECK_STRCASENE(s1, s2) CHECK_STROP(strcasecmp, !=, false, s1, s2)
-
-#define CHECK_INDEX(I,A) CHECK(I < (sizeof(A)/sizeof(A[0])))
-#define CHECK_BOUND(B,A) CHECK(B <= (sizeof(A)/sizeof(A[0])))
-
-#define CHECK_DOUBLE_EQ(val1, val2)              \
-  do {                                           \
-    CHECK_LE((val1), (val2)+0.000000000000001L); \
-    CHECK_GE((val1), (val2)-0.000000000000001L); \
-  } while (0)
-
-#define CHECK_NEAR(val1, val2, margin)           \
-  do {                                           \
-    CHECK_LE((val1), (val2)+(margin));           \
-    CHECK_GE((val1), (val2)-(margin));           \
-  } while (0)
-
-// perror()..googly style!
-//
-// PLOG() and PLOG_IF() and PCHECK() behave exactly like their LOG* and
-// CHECK equivalents with the addition that they postpend a description
-// of the current state of errno to their output lines.
-
-#define PLOG(severity) GOOGLE_PLOG(severity, 0).stream()
-
-#define GOOGLE_PLOG(severity, counter)  \
-  google::ErrnoLogMessage( \
-      __FILE__, __LINE__, google::GLOG_ ## severity, counter, \
-      &google::LogMessage::SendToLog)
-
-#define PLOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & PLOG(severity)
-
-// A CHECK() macro that postpends errno if the condition is false. E.g.
-//
-// if (poll(fds, nfds, timeout) == -1) { PCHECK(errno == EINTR); ... }
-#define PCHECK(condition)  \
-      PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN(!(condition))) \
-              << "Check failed: " #condition " "
-
-// A CHECK() macro that lets you assert the success of a function that
-// returns -1 and sets errno in case of an error. E.g.
-//
-// CHECK_ERR(mkdir(path, 0700));
-//
-// or
-//
-// int fd = open(filename, flags); CHECK_ERR(fd) << ": open " << filename;
-#define CHECK_ERR(invocation)                                          \
-PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1))    \
-        << #invocation
-
-// Use macro expansion to create, for each use of LOG_EVERY_N(), static
-// variables with the __LINE__ expansion as part of the variable name.
-#define LOG_EVERY_N_VARNAME(base, line) LOG_EVERY_N_VARNAME_CONCAT(base, line)
-#define LOG_EVERY_N_VARNAME_CONCAT(base, line) base ## line
-
-#define LOG_OCCURRENCES LOG_EVERY_N_VARNAME(occurrences_, __LINE__)
-#define LOG_OCCURRENCES_MOD_N LOG_EVERY_N_VARNAME(occurrences_mod_n_, __LINE__)
-
-#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
-  if (LOG_OCCURRENCES_MOD_N == 1) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (condition && \
-      ((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
-                 &what_to_do).stream()
-
-#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
-  if (LOG_OCCURRENCES_MOD_N == 1) \
-    google::ErrnoLogMessage( \
-        __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0; \
-  if (LOG_OCCURRENCES <= n) \
-    ++LOG_OCCURRENCES; \
-  if (LOG_OCCURRENCES <= n) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-namespace glog_internal_namespace_ {
-template <bool>
-struct CompileAssert {
-};
-struct CrashReason;
-}  // namespace glog_internal_namespace_
-
-#define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \
-  typedef google::glog_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
-
-#define LOG_EVERY_N(severity, n)                                        \
-  GOOGLE_GLOG_COMPILE_ASSERT(google::GLOG_ ## severity < \
-                             google::NUM_SEVERITIES,     \
-                             INVALID_REQUESTED_LOG_SEVERITY);           \
-  SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
-
-#define SYSLOG_EVERY_N(severity, n) \
-  SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToSyslogAndLog)
-
-#define PLOG_EVERY_N(severity, n) \
-  SOME_KIND_OF_PLOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
-
-#define LOG_FIRST_N(severity, n) \
-  SOME_KIND_OF_LOG_FIRST_N(severity, (n), google::LogMessage::SendToLog)
-
-#define LOG_IF_EVERY_N(severity, condition, n) \
-  SOME_KIND_OF_LOG_IF_EVERY_N(severity, (condition), (n), google::LogMessage::SendToLog)
-
-// We want the special COUNTER value available for LOG_EVERY_X()'ed messages
-enum PRIVATE_Counter {COUNTER};
-
-#ifdef GLOG_NO_ABBREVIATED_SEVERITIES
-// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets
-// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us
-// to keep using this syntax, we define this macro to do the same thing
-// as COMPACT_GOOGLE_LOG_ERROR.
-#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR
-#define SYSLOG_0 SYSLOG_ERROR
-#define LOG_TO_STRING_0 LOG_TO_STRING_ERROR
-// Needed for LOG_IS_ON(ERROR).
-const LogSeverity GLOG_0 = GLOG_ERROR;
-#else
-// Users may include windows.h after logging.h without
-// GLOG_NO_ABBREVIATED_SEVERITIES nor WIN32_LEAN_AND_MEAN.
-// For this case, we cannot detect if ERROR is defined before users
-// actually use ERROR. Let's make an undefined symbol to warn users.
-# define GLOG_ERROR_MSG ERROR_macro_is_defined_Define_GLOG_NO_ABBREVIATED_SEVERITIES_before_including_logging_h_See_the_document_for_detail
-# define COMPACT_GOOGLE_LOG_0 GLOG_ERROR_MSG
-# define SYSLOG_0 GLOG_ERROR_MSG
-# define LOG_TO_STRING_0 GLOG_ERROR_MSG
-# define GLOG_0 GLOG_ERROR_MSG
-#endif
-
-// Plus some debug-logging macros that get compiled to nothing for production
-
-#ifndef NDEBUG
-
-#define DLOG(severity) LOG(severity)
-#define DVLOG(verboselevel) VLOG(verboselevel)
-#define DLOG_IF(severity, condition) LOG_IF(severity, condition)
-#define DLOG_EVERY_N(severity, n) LOG_EVERY_N(severity, n)
-#define DLOG_IF_EVERY_N(severity, condition, n) \
-  LOG_IF_EVERY_N(severity, condition, n)
-#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
-
-// debug-only checking.  not executed in NDEBUG mode.
-#define DCHECK(condition) CHECK(condition)
-#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2)
-#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2)
-#define DCHECK_LE(val1, val2) CHECK_LE(val1, val2)
-#define DCHECK_LT(val1, val2) CHECK_LT(val1, val2)
-#define DCHECK_GE(val1, val2) CHECK_GE(val1, val2)
-#define DCHECK_GT(val1, val2) CHECK_GT(val1, val2)
-#define DCHECK_NOTNULL(val) CHECK_NOTNULL(val)
-#define DCHECK_STREQ(str1, str2) CHECK_STREQ(str1, str2)
-#define DCHECK_STRCASEEQ(str1, str2) CHECK_STRCASEEQ(str1, str2)
-#define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2)
-#define DCHECK_STRCASENE(str1, str2) CHECK_STRCASENE(str1, str2)
-
-#else  // NDEBUG
-
-#define DLOG(severity) \
-  true ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DVLOG(verboselevel) \
-  (true || !VLOG_IS_ON(verboselevel)) ?\
-    (void) 0 : google::LogMessageVoidify() & LOG(INFO)
-
-#define DLOG_IF(severity, condition) \
-  (true || !(condition)) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_EVERY_N(severity, n) \
-  true ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_IF_EVERY_N(severity, condition, n) \
-  (true || !(condition))? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_ASSERT(condition) \
-  true ? (void) 0 : LOG_ASSERT(condition)
-
-// MSVC warning C4127: conditional expression is constant
-#define DCHECK(condition) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK(condition)
-
-#define DCHECK_EQ(val1, val2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_EQ(val1, val2)
-
-#define DCHECK_NE(val1, val2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_NE(val1, val2)
-
-#define DCHECK_LE(val1, val2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_LE(val1, val2)
-
-#define DCHECK_LT(val1, val2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_LT(val1, val2)
-
-#define DCHECK_GE(val1, val2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_GE(val1, val2)
-
-#define DCHECK_GT(val1, val2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_GT(val1, val2)
-
-// You may see warnings in release mode if you don't use the return
-// value of DCHECK_NOTNULL. Please just use DCHECK for such cases.
-#define DCHECK_NOTNULL(val) (val)
-
-#define DCHECK_STREQ(str1, str2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_STREQ(str1, str2)
-
-#define DCHECK_STRCASEEQ(str1, str2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_STRCASEEQ(str1, str2)
-
-#define DCHECK_STRNE(str1, str2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_STRNE(str1, str2)
-
-#define DCHECK_STRCASENE(str1, str2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_STRCASENE(str1, str2)
-
-#endif  // NDEBUG
-
-// Log only in verbose mode.
-
-#define VLOG(verboselevel) LOG_IF(INFO, VLOG_IS_ON(verboselevel))
-
-#define VLOG_IF(verboselevel, condition) \
-  LOG_IF(INFO, (condition) && VLOG_IS_ON(verboselevel))
-
-#define VLOG_EVERY_N(verboselevel, n) \
-  LOG_IF_EVERY_N(INFO, VLOG_IS_ON(verboselevel), n)
-
-#define VLOG_IF_EVERY_N(verboselevel, condition, n) \
-  LOG_IF_EVERY_N(INFO, (condition) && VLOG_IS_ON(verboselevel), n)
-
-namespace base_logging {
-
-// LogMessage::LogStream is a std::ostream backed by this streambuf.
-// This class ignores overflow and leaves two bytes at the end of the
-// buffer to allow for a '\n' and '\0'.
-class LogStreamBuf : public std::streambuf {
- public:
-  // REQUIREMENTS: "len" must be >= 2 to account for the '\n' and '\n'.
-  LogStreamBuf(char *buf, int len) {
-    setp(buf, buf + len - 2);
-  }
-  // This effectively ignores overflow.
-  virtual int_type overflow(int_type ch) {
-    return ch;
-  }
-
-  // Legacy public ostrstream method.
-  size_t pcount() const { return pptr() - pbase(); }
-  char* pbase() const { return std::streambuf::pbase(); }
-};
-
-}  // namespace base_logging
-
-//
-// This class more or less represents a particular log message.  You
-// create an instance of LogMessage and then stream stuff to it.
-// When you finish streaming to it, ~LogMessage is called and the
-// full message gets streamed to the appropriate destination.
-//
-// You shouldn't actually use LogMessage's constructor to log things,
-// though.  You should use the LOG() macro (and variants thereof)
-// above.
-class GOOGLE_GLOG_DLL_DECL LogMessage {
-public:
-  enum {
-    // Passing kNoLogPrefix for the line number disables the
-    // log-message prefix. Useful for using the LogMessage
-    // infrastructure as a printing utility. See also the --log_prefix
-    // flag for controlling the log-message prefix on an
-    // application-wide basis.
-    kNoLogPrefix = -1
-  };
-
-  // LogStream inherit from non-DLL-exported class (std::ostrstream)
-  // and VC++ produces a warning for this situation.
-  // However, MSDN says "C4275 can be ignored in Microsoft Visual C++
-  // 2005 if you are deriving from a type in the Standard C++ Library"
-  // http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx
-  // Let's just ignore the warning.
-#ifdef _MSC_VER
-# pragma warning(disable: 4275)
-#endif
-  class GOOGLE_GLOG_DLL_DECL LogStream : public std::ostream {
-#ifdef _MSC_VER
-# pragma warning(default: 4275)
-#endif
-  public:
-    LogStream(char *buf, int len, int ctr)
-        : std::ostream(NULL),
-          streambuf_(buf, len),
-          ctr_(ctr),
-          self_(this) {
-      rdbuf(&streambuf_);
-    }
-
-    int ctr() const { return ctr_; }
-    void set_ctr(int ctr) { ctr_ = ctr; }
-    LogStream* self() const { return self_; }
-
-    // Legacy std::streambuf methods.
-    size_t pcount() const { return streambuf_.pcount(); }
-    char* pbase() const { return streambuf_.pbase(); }
-    char* str() const { return pbase(); }
-
-  private:
-    base_logging::LogStreamBuf streambuf_;
-    int ctr_;  // Counter hack (for the LOG_EVERY_X() macro)
-    LogStream *self_;  // Consistency check hack
-  };
-
-public:
-  // icc 8 requires this typedef to avoid an internal compiler error.
-  typedef void (LogMessage::*SendMethod)();
-
-  LogMessage(const char* file, int line, LogSeverity severity, int ctr,
-             SendMethod send_method);
-
-  // Two special constructors that generate reduced amounts of code at
-  // LOG call sites for common cases.
-
-  // Used for LOG(INFO): Implied are:
-  // severity = INFO, ctr = 0, send_method = &LogMessage::SendToLog.
-  //
-  // Using this constructor instead of the more complex constructor above
-  // saves 19 bytes per call site.
-  LogMessage(const char* file, int line);
-
-  // Used for LOG(severity) where severity != INFO.  Implied
-  // are: ctr = 0, send_method = &LogMessage::SendToLog
-  //
-  // Using this constructor instead of the more complex constructor above
-  // saves 17 bytes per call site.
-  LogMessage(const char* file, int line, LogSeverity severity);
-
-  // Constructor to log this message to a specified sink (if not NULL).
-  // Implied are: ctr = 0, send_method = &LogMessage::SendToSinkAndLog if
-  // also_send_to_log is true, send_method = &LogMessage::SendToSink otherwise.
-  LogMessage(const char* file, int line, LogSeverity severity, LogSink* sink,
-             bool also_send_to_log);
-
-  // Constructor where we also give a vector<string> pointer
-  // for storing the messages (if the pointer is not NULL).
-  // Implied are: ctr = 0, send_method = &LogMessage::SaveOrSendToLog.
-  LogMessage(const char* file, int line, LogSeverity severity,
-             std::vector<std::string>* outvec);
-
-  // Constructor where we also give a string pointer for storing the
-  // message (if the pointer is not NULL).  Implied are: ctr = 0,
-  // send_method = &LogMessage::WriteToStringAndLog.
-  LogMessage(const char* file, int line, LogSeverity severity,
-             std::string* message);
-
-  // A special constructor used for check failures
-  LogMessage(const char* file, int line, const CheckOpString& result);
-
-  ~LogMessage();
-
-  // Flush a buffered message to the sink set in the constructor.  Always
-  // called by the destructor, it may also be called from elsewhere if
-  // needed.  Only the first call is actioned; any later ones are ignored.
-  void Flush();
-
-  // An arbitrary limit on the length of a single log message.  This
-  // is so that streaming can be done more efficiently.
-  static const size_t kMaxLogMessageLen;
-
-  // Theses should not be called directly outside of logging.*,
-  // only passed as SendMethod arguments to other LogMessage methods:
-  void SendToLog();  // Actually dispatch to the logs
-  void SendToSyslogAndLog();  // Actually dispatch to syslog and the logs
-
-  // Call abort() or similar to perform LOG(FATAL) crash.
-  static void Fail()
-#ifdef HAVE___ATTRIBUTE__
-      __attribute__((noreturn));
-#else
-      ;
-#endif
-
-  std::ostream& stream();
-
-  int preserved_errno() const;
-
-  // Must be called without the log_mutex held.  (L < log_mutex)
-  static int64 num_messages(int severity);
-
-  struct LogMessageData;
-
-private:
-  // Fully internal SendMethod cases:
-  void SendToSinkAndLog();  // Send to sink if provided and dispatch to the logs
-  void SendToSink();  // Send to sink if provided, do nothing otherwise.
-
-  // Write to string if provided and dispatch to the logs.
-  void WriteToStringAndLog();
-
-  void SaveOrSendToLog();  // Save to stringvec if provided, else to logs
-
-  void Init(const char* file, int line, LogSeverity severity,
-            void (LogMessage::*send_method)());
-
-  // Used to fill in crash information during LOG(FATAL) failures.
-  void RecordCrashReason(glog_internal_namespace_::CrashReason* reason);
-
-  // Counts of messages sent at each priority:
-  static int64 num_messages_[NUM_SEVERITIES];  // under log_mutex
-
-  // We keep the data in a separate struct so that each instance of
-  // LogMessage uses less stack space.
-  LogMessageData* allocated_;
-  LogMessageData* data_;
-
-  friend class LogDestination;
-
-  LogMessage(const LogMessage&);
-  void operator=(const LogMessage&);
-};
-
-// This class happens to be thread-hostile because all instances share
-// a single data buffer, but since it can only be created just before
-// the process dies, we don't worry so much.
-class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage {
- public:
-  LogMessageFatal(const char* file, int line);
-  LogMessageFatal(const char* file, int line, const CheckOpString& result);
-  ~LogMessageFatal()
-#ifdef HAVE___ATTRIBUTE__
-      __attribute__((noreturn));
-#else
-      ;
-#endif
-};
-
-// A non-macro interface to the log facility; (useful
-// when the logging level is not a compile-time constant).
-inline void LogAtLevel(int const severity, std::string const &msg) {
-  LogMessage(__FILE__, __LINE__, severity).stream() << msg;
-}
-
-// A macro alternative of LogAtLevel. New code may want to use this
-// version since there are two advantages: 1. this version outputs the
-// file name and the line number where this macro is put like other
-// LOG macros, 2. this macro can be used as C++ stream.
-#define LOG_AT_LEVEL(severity) google::LogMessage(__FILE__, __LINE__, severity).stream()
-
-// A small helper for CHECK_NOTNULL().
-template <typename T>
-T* CheckNotNull(const char *file, int line, const char *names, T* t) {
-  if (t == NULL) {
-    LogMessageFatal(file, line, new std::string(names));
-  }
-  return t;
-}
-
-// Allow folks to put a counter in the LOG_EVERY_X()'ed messages. This
-// only works if ostream is a LogStream. If the ostream is not a
-// LogStream you'll get an assert saying as much at runtime.
-GOOGLE_GLOG_DLL_DECL std::ostream& operator<<(std::ostream &os,
-                                              const PRIVATE_Counter&);
-
-
-// Derived class for PLOG*() above.
-class GOOGLE_GLOG_DLL_DECL ErrnoLogMessage : public LogMessage {
- public:
-
-  ErrnoLogMessage(const char* file, int line, LogSeverity severity, int ctr,
-                  void (LogMessage::*send_method)());
-
-  // Postpends ": strerror(errno) [errno]".
-  ~ErrnoLogMessage();
-
- private:
-  ErrnoLogMessage(const ErrnoLogMessage&);
-  void operator=(const ErrnoLogMessage&);
-};
-
-
-// This class is used to explicitly ignore values in the conditional
-// logging macros.  This avoids compiler warnings like "value computed
-// is not used" and "statement has no effect".
-
-class GOOGLE_GLOG_DLL_DECL LogMessageVoidify {
- public:
-  LogMessageVoidify() { }
-  // This has to be an operator with a precedence lower than << but
-  // higher than ?:
-  void operator&(std::ostream&) { }
-};
-
-
-// Flushes all log files that contains messages that are at least of
-// the specified severity level.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL void FlushLogFiles(LogSeverity min_severity);
-
-// Flushes all log files that contains messages that are at least of
-// the specified severity level. Thread-hostile because it ignores
-// locking -- used for catastrophic failures.
-GOOGLE_GLOG_DLL_DECL void FlushLogFilesUnsafe(LogSeverity min_severity);
-
-//
-// Set the destination to which a particular severity level of log
-// messages is sent.  If base_filename is "", it means "don't log this
-// severity".  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogDestination(LogSeverity severity,
-                                            const char* base_filename);
-
-//
-// Set the basename of the symlink to the latest log file at a given
-// severity.  If symlink_basename is empty, do not make a symlink.  If
-// you don't call this function, the symlink basename is the
-// invocation name of the program.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogSymlink(LogSeverity severity,
-                                        const char* symlink_basename);
-
-//
-// Used to send logs to some other kind of destination
-// Users should subclass LogSink and override send to do whatever they want.
-// Implementations must be thread-safe because a shared instance will
-// be called from whichever thread ran the LOG(XXX) line.
-class GOOGLE_GLOG_DLL_DECL LogSink {
- public:
-  virtual ~LogSink();
-
-  // Sink's logging logic (message_len is such as to exclude '\n' at the end).
-  // This method can't use LOG() or CHECK() as logging system mutex(s) are held
-  // during this call.
-  virtual void send(LogSeverity severity, const char* full_filename,
-                    const char* base_filename, int line,
-                    const struct ::tm* tm_time,
-                    const char* message, size_t message_len) = 0;
-
-  // Redefine this to implement waiting for
-  // the sink's logging logic to complete.
-  // It will be called after each send() returns,
-  // but before that LogMessage exits or crashes.
-  // By default this function does nothing.
-  // Using this function one can implement complex logic for send()
-  // that itself involves logging; and do all this w/o causing deadlocks and
-  // inconsistent rearrangement of log messages.
-  // E.g. if a LogSink has thread-specific actions, the send() method
-  // can simply add the message to a queue and wake up another thread that
-  // handles real logging while itself making some LOG() calls;
-  // WaitTillSent() can be implemented to wait for that logic to complete.
-  // See our unittest for an example.
-  virtual void WaitTillSent();
-
-  // Returns the normal text output of the log message.
-  // Can be useful to implement send().
-  static std::string ToString(LogSeverity severity, const char* file, int line,
-                              const struct ::tm* tm_time,
-                              const char* message, size_t message_len);
-};
-
-// Add or remove a LogSink as a consumer of logging data.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL void AddLogSink(LogSink *destination);
-GOOGLE_GLOG_DLL_DECL void RemoveLogSink(LogSink *destination);
-
-//
-// Specify an "extension" added to the filename specified via
-// SetLogDestination.  This applies to all severity levels.  It's
-// often used to append the port we're listening on to the logfile
-// name.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogFilenameExtension(
-    const char* filename_extension);
-
-//
-// Make it so that all log messages of at least a particular severity
-// are logged to stderr (in addition to logging to the usual log
-// file(s)).  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetStderrLogging(LogSeverity min_severity);
-
-//
-// Make it so that all log messages go only to stderr.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void LogToStderr();
-
-//
-// Make it so that all log messages of at least a particular severity are
-// logged via email to a list of addresses (in addition to logging to the
-// usual log file(s)).  The list of addresses is just a string containing
-// the email addresses to send to (separated by spaces, say).  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetEmailLogging(LogSeverity min_severity,
-                                          const char* addresses);
-
-// A simple function that sends email. dest is a commma-separated
-// list of addressess.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL bool SendEmail(const char *dest,
-                                    const char *subject, const char *body);
-
-GOOGLE_GLOG_DLL_DECL const std::vector<std::string>& GetLoggingDirectories();
-
-// For tests only:  Clear the internal [cached] list of logging directories to
-// force a refresh the next time GetLoggingDirectories is called.
-// Thread-hostile.
-void TestOnly_ClearLoggingDirectoriesList();
-
-// Returns a set of existing temporary directories, which will be a
-// subset of the directories returned by GetLogginDirectories().
-// Thread-safe.
-GOOGLE_GLOG_DLL_DECL void GetExistingTempDirectories(
-    std::vector<std::string>* list);
-
-// Print any fatal message again -- useful to call from signal handler
-// so that the last thing in the output is the fatal message.
-// Thread-hostile, but a race is unlikely.
-GOOGLE_GLOG_DLL_DECL void ReprintFatalMessage();
-
-// Truncate a log file that may be the append-only output of multiple
-// processes and hence can't simply be renamed/reopened (typically a
-// stdout/stderr).  If the file "path" is > "limit" bytes, copy the
-// last "keep" bytes to offset 0 and truncate the rest. Since we could
-// be racing with other writers, this approach has the potential to
-// lose very small amounts of data. For security, only follow symlinks
-// if the path is /proc/self/fd/*
-GOOGLE_GLOG_DLL_DECL void TruncateLogFile(const char *path,
-                                          int64 limit, int64 keep);
-
-// Truncate stdout and stderr if they are over the value specified by
-// --max_log_size; keep the final 1MB.  This function has the same
-// race condition as TruncateLogFile.
-GOOGLE_GLOG_DLL_DECL void TruncateStdoutStderr();
-
-// Return the string representation of the provided LogSeverity level.
-// Thread-safe.
-GOOGLE_GLOG_DLL_DECL const char* GetLogSeverityName(LogSeverity severity);
-
-// ---------------------------------------------------------------------
-// Implementation details that are not useful to most clients
-// ---------------------------------------------------------------------
-
-// A Logger is the interface used by logging modules to emit entries
-// to a log.  A typical implementation will dump formatted data to a
-// sequence of files.  We also provide interfaces that will forward
-// the data to another thread so that the invoker never blocks.
-// Implementations should be thread-safe since the logging system
-// will write to them from multiple threads.
-
-namespace base {
-
-class GOOGLE_GLOG_DLL_DECL Logger {
- public:
-  virtual ~Logger();
-
-  // Writes "message[0,message_len-1]" corresponding to an event that
-  // occurred at "timestamp".  If "force_flush" is true, the log file
-  // is flushed immediately.
-  //
-  // The input message has already been formatted as deemed
-  // appropriate by the higher level logging facility.  For example,
-  // textual log messages already contain timestamps, and the
-  // file:linenumber header.
-  virtual void Write(bool force_flush,
-                     time_t timestamp,
-                     const char* message,
-                     int message_len) = 0;
-
-  // Flush any buffered messages
-  virtual void Flush() = 0;
-
-  // Get the current LOG file size.
-  // The returned value is approximate since some
-  // logged data may not have been flushed to disk yet.
-  virtual uint32 LogSize() = 0;
-};
-
-// Get the logger for the specified severity level.  The logger
-// remains the property of the logging module and should not be
-// deleted by the caller.  Thread-safe.
-extern GOOGLE_GLOG_DLL_DECL Logger* GetLogger(LogSeverity level);
-
-// Set the logger for the specified severity level.  The logger
-// becomes the property of the logging module and should not
-// be deleted by the caller.  Thread-safe.
-extern GOOGLE_GLOG_DLL_DECL void SetLogger(LogSeverity level, Logger* logger);
-
-}
-
-// glibc has traditionally implemented two incompatible versions of
-// strerror_r(). There is a poorly defined convention for picking the
-// version that we want, but it is not clear whether it even works with
-// all versions of glibc.
-// So, instead, we provide this wrapper that automatically detects the
-// version that is in use, and then implements POSIX semantics.
-// N.B. In addition to what POSIX says, we also guarantee that "buf" will
-// be set to an empty string, if this function failed. This means, in most
-// cases, you do not need to check the error code and you can directly
-// use the value of "buf". It will never have an undefined value.
-GOOGLE_GLOG_DLL_DECL int posix_strerror_r(int err, char *buf, size_t len);
-
-
-// A class for which we define operator<<, which does nothing.
-class GOOGLE_GLOG_DLL_DECL NullStream : public LogMessage::LogStream {
- public:
-  // Initialize the LogStream so the messages can be written somewhere
-  // (they'll never be actually displayed). This will be needed if a
-  // NullStream& is implicitly converted to LogStream&, in which case
-  // the overloaded NullStream::operator<< will not be invoked.
-  NullStream() : LogMessage::LogStream(message_buffer_, 1, 0) { }
-  NullStream(const char* /*file*/, int /*line*/,
-             const CheckOpString& /*result*/) :
-      LogMessage::LogStream(message_buffer_, 1, 0) { }
-  NullStream &stream() { return *this; }
- private:
-  // A very short buffer for messages (which we discard anyway). This
-  // will be needed if NullStream& converted to LogStream& (e.g. as a
-  // result of a conditional expression).
-  char message_buffer_[2];
-};
-
-// Do nothing. This operator is inline, allowing the message to be
-// compiled away. The message will not be compiled away if we do
-// something like (flag ? LOG(INFO) : LOG(ERROR)) << message; when
-// SKIP_LOG=WARNING. In those cases, NullStream will be implicitly
-// converted to LogStream and the message will be computed and then
-// quietly discarded.
-template<class T>
-inline NullStream& operator<<(NullStream &str, const T &) { return str; }
-
-// Similar to NullStream, but aborts the program (without stack
-// trace), like LogMessageFatal.
-class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream {
- public:
-  NullStreamFatal() { }
-  NullStreamFatal(const char* file, int line, const CheckOpString& result) :
-      NullStream(file, line, result) { }
-#ifdef HAVE___ATTRIBUTE__
-  __attribute__((noreturn)) ~NullStreamFatal() { _exit(1); }
-#else
-  ~NullStreamFatal() { _exit(1); }
-#endif
-};
-
-// Install a signal handler that will dump signal information and a stack
-// trace when the program crashes on certain signals.  We'll install the
-// signal handler for the following signals.
-//
-// SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, and SIGTERM.
-//
-// By default, the signal handler will write the failure dump to the
-// standard error.  You can customize the destination by installing your
-// own writer function by InstallFailureWriter() below.
-//
-// Note on threading:
-//
-// The function should be called before threads are created, if you want
-// to use the failure signal handler for all threads.  The stack trace
-// will be shown only for the thread that receives the signal.  In other
-// words, stack traces of other threads won't be shown.
-GOOGLE_GLOG_DLL_DECL void InstallFailureSignalHandler();
-
-// Installs a function that is used for writing the failure dump.  "data"
-// is the pointer to the beginning of a message to be written, and "size"
-// is the size of the message.  You should not expect the data is
-// terminated with '\0'.
-GOOGLE_GLOG_DLL_DECL void InstallFailureWriter(
-    void (*writer)(const char* data, int size));
-
-}
-
-#endif // _LOGGING_H_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/glog/raw_logging.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/glog/raw_logging.h b/third_party/src/glog/src/glog/raw_logging.h
deleted file mode 100644
index bbda44f..0000000
--- a/third_party/src/glog/src/glog/raw_logging.h
+++ /dev/null
@@ -1,191 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Maxim Lifantsev
-//
-// Thread-safe logging routines that do not allocate any memory or
-// acquire any locks, and can therefore be used by low-level memory
-// allocation and synchronization code.
-
-#ifndef BASE_RAW_LOGGING_H_
-#define BASE_RAW_LOGGING_H_
-
-#include "glog/config.h"
-
-#include <time.h>
-
-namespace google {
-
-#include "glog/log_severity.h"
-#include "glog/vlog_is_on.h"
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-// This is similar to LOG(severity) << format... and VLOG(level) << format..,
-// but
-// * it is to be used ONLY by low-level modules that can't use normal LOG()
-// * it is desiged to be a low-level logger that does not allocate any
-//   memory and does not need any locks, hence:
-// * it logs straight and ONLY to STDERR w/o buffering
-// * it uses an explicit format and arguments list
-// * it will silently chop off really long message strings
-// Usage example:
-//   RAW_LOG(ERROR, "Failed foo with %i: %s", status, error);
-//   RAW_VLOG(3, "status is %i", status);
-// These will print an almost standard log lines like this to stderr only:
-//   E0821 211317 file.cc:123] RAW: Failed foo with 22: bad_file
-//   I0821 211317 file.cc:142] RAW: status is 20
-#define RAW_LOG(severity, ...) \
-  do { \
-    switch (google::GLOG_ ## severity) {  \
-      case 0: \
-        RAW_LOG_INFO(__VA_ARGS__); \
-        break; \
-      case 1: \
-        RAW_LOG_WARNING(__VA_ARGS__); \
-        break; \
-      case 2: \
-        RAW_LOG_ERROR(__VA_ARGS__); \
-        break; \
-      case 3: \
-        RAW_LOG_FATAL(__VA_ARGS__); \
-        break; \
-      default: \
-        break; \
-    } \
-  } while (0)
-
-// The following STRIP_LOG testing is performed in the header file so that it's
-// possible to completely compile out the logging code and the log messages.
-#if STRIP_LOG == 0
-#define RAW_VLOG(verboselevel, ...) \
-  do { \
-    if (VLOG_IS_ON(verboselevel)) { \
-      RAW_LOG_INFO(__VA_ARGS__); \
-    } \
-  } while (0)
-#else
-#define RAW_VLOG(verboselevel, ...) RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG == 0
-
-#if STRIP_LOG == 0
-#define RAW_LOG_INFO(...) google::RawLog__(google::GLOG_INFO, \
-                                   __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG == 0
-
-#if STRIP_LOG <= 1
-#define RAW_LOG_WARNING(...) google::RawLog__(google::GLOG_WARNING,   \
-                                      __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG <= 1
-
-#if STRIP_LOG <= 2
-#define RAW_LOG_ERROR(...) google::RawLog__(google::GLOG_ERROR,       \
-                                    __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG <= 2
-
-#if STRIP_LOG <= 3
-#define RAW_LOG_FATAL(...) google::RawLog__(google::GLOG_FATAL,       \
-                                    __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_FATAL(...) \
-  do { \
-    google::RawLogStub__(0, __VA_ARGS__);        \
-    exit(1); \
-  } while (0)
-#endif // STRIP_LOG <= 3
-
-// Similar to CHECK(condition) << message,
-// but for low-level modules: we use only RAW_LOG that does not allocate memory.
-// We do not want to provide args list here to encourage this usage:
-//   if (!cond)  RAW_LOG(FATAL, "foo ...", hard_to_compute_args);
-// so that the args are not computed when not needed.
-#define RAW_CHECK(condition, message)                                   \
-  do {                                                                  \
-    if (!(condition)) {                                                 \
-      RAW_LOG(FATAL, "Check %s failed: %s", #condition, message);       \
-    }                                                                   \
-  } while (0)
-
-// Debug versions of RAW_LOG and RAW_CHECK
-#ifndef NDEBUG
-
-#define RAW_DLOG(severity, ...) RAW_LOG(severity, __VA_ARGS__)
-#define RAW_DCHECK(condition, message) RAW_CHECK(condition, message)
-
-#else  // NDEBUG
-
-#define RAW_DLOG(severity, ...)                                 \
-  while (false)                                                 \
-    RAW_LOG(severity, __VA_ARGS__)
-#define RAW_DCHECK(condition, message) \
-  while (false) \
-    RAW_CHECK(condition, message)
-
-#endif  // NDEBUG
-
-// Stub log function used to work around for unused variable warnings when
-// building with STRIP_LOG > 0.
-static inline void RawLogStub__(int /* ignored */, ...) {
-}
-
-// Helper function to implement RAW_LOG and RAW_VLOG
-// Logs format... at "severity" level, reporting it
-// as called from file:line.
-// This does not allocate memory or acquire locks.
-GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity,
-                                   const char* file,
-                                   int line,
-                                   const char* format, ...)
-#ifdef HAVE___ATTRIBUTE__
-    __attribute__((__format__ (__printf__, 4, 5)));
-#else
-    ;
-#endif
-
-// Hack to propagate time information into this module so that
-// this module does not have to directly call localtime_r(),
-// which could allocate memory.
-GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct tm& t, int usecs);
-
-}
-
-#endif  // BASE_RAW_LOGGING_H_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/glog/stl_logging.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/glog/stl_logging.h b/third_party/src/glog/src/glog/stl_logging.h
deleted file mode 100644
index 14d68ca..0000000
--- a/third_party/src/glog/src/glog/stl_logging.h
+++ /dev/null
@@ -1,183 +0,0 @@
-// Copyright (c) 2003, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Stream output operators for STL containers; to be used for logging *only*.
-// Inclusion of this file lets you do:
-//
-// list<string> x;
-// LOG(INFO) << "data: " << x;
-// vector<int> v1, v2;
-// CHECK_EQ(v1, v2);
-
-#ifndef UTIL_GTL_STL_LOGGING_INL_H_
-#define UTIL_GTL_STL_LOGGING_INL_H_
-
-#if !1
-# error We do not support stl_logging for this compiler
-#endif
-
-#include <deque>
-#include <list>
-#include <map>
-#include <ostream>
-#include <set>
-#include <utility>
-#include <vector>
-
-#ifdef __GNUC__
-# include <ext/hash_set>
-# include <ext/hash_map>
-# include <ext/slist>
-#endif
-
-// Forward declare these two, and define them after all the container streams
-// operators so that we can recurse from pair -> container -> container -> pair
-// properly.
-template<class First, class Second>
-std::ostream& operator<<(std::ostream& out, const std::pair<First, Second>& p);
-
-namespace google {
-
-template<class Iter>
-void PrintSequence(std::ostream& out, Iter begin, Iter end);
-
-}
-
-#define OUTPUT_TWO_ARG_CONTAINER(Sequence) \
-template<class T1, class T2> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_TWO_ARG_CONTAINER(std::vector)
-OUTPUT_TWO_ARG_CONTAINER(std::deque)
-OUTPUT_TWO_ARG_CONTAINER(std::list)
-#ifdef __GNUC__
-OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist)
-#endif
-
-#undef OUTPUT_TWO_ARG_CONTAINER
-
-#define OUTPUT_THREE_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_THREE_ARG_CONTAINER(std::set)
-OUTPUT_THREE_ARG_CONTAINER(std::multiset)
-
-#undef OUTPUT_THREE_ARG_CONTAINER
-
-#define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3, class T4> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3, T4>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_FOUR_ARG_CONTAINER(std::map)
-OUTPUT_FOUR_ARG_CONTAINER(std::multimap)
-#ifdef __GNUC__
-OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set)
-OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset)
-#endif
-
-#undef OUTPUT_FOUR_ARG_CONTAINER
-
-#define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3, class T4, class T5> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3, T4, T5>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-#ifdef __GNUC__
-OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map)
-OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap)
-#endif
-
-#undef OUTPUT_FIVE_ARG_CONTAINER
-
-template<class First, class Second>
-inline std::ostream& operator<<(std::ostream& out,
-                                const std::pair<First, Second>& p) {
-  out << '(' << p.first << ", " << p.second << ')';
-  return out;
-}
-
-namespace google {
-
-template<class Iter>
-inline void PrintSequence(std::ostream& out, Iter begin, Iter end) {
-  // Output at most 100 elements -- appropriate if used for logging.
-  for (int i = 0; begin != end && i < 100; ++i, ++begin) {
-    if (i > 0) out << ' ';
-    out << *begin;
-  }
-  if (begin != end) {
-    out << " ...";
-  }
-}
-
-}
-
-// Note that this is technically undefined behavior! We are adding things into
-// the std namespace for a reason though -- we are providing new operations on
-// types which are themselves defined with this namespace. Without this, these
-// operator overloads cannot be found via ADL. If these definitions are not
-// found via ADL, they must be #included before they're used, which requires
-// this header to be included before apparently independent other headers.
-//
-// For example, base/logging.h defines various template functions to implement
-// CHECK_EQ(x, y) and stream x and y into the log in the event the check fails.
-// It does so via the function template MakeCheckOpValueString:
-//   template<class T>
-//   void MakeCheckOpValueString(strstream* ss, const T& v) {
-//     (*ss) << v;
-//   }
-// Because 'glog/logging.h' is included before 'glog/stl_logging.h',
-// subsequent CHECK_EQ(v1, v2) for vector<...> typed variable v1 and v2 can only
-// find these operator definitions via ADL.
-//
-// Even this solution has problems -- it may pull unintended operators into the
-// namespace as well, allowing them to also be found via ADL, and creating code
-// that only works with a particular order of includes. Long term, we need to
-// move all of the *definitions* into namespace std, bet we need to ensure no
-// one references them first. This lets us take that step. We cannot define them
-// in both because that would create ambiguous overloads when both are found.
-namespace std { using ::operator<<; }
-
-#endif  // UTIL_GTL_STL_LOGGING_INL_H_


[04/46] incubator-quickstep git commit: Fixed the root path check in the validate_cmakelists script.

Posted by ji...@apache.org.
Fixed the root path check in the validate_cmakelists script.


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

Branch: refs/heads/fix-iwyu
Commit: bf455e26eb89902731f01928f5eff369a875e5f4
Parents: 8d7284d
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Thu Sep 28 19:36:06 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Thu Sep 28 19:36:06 2017 -0500

----------------------------------------------------------------------
 validate_cmakelists.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/bf455e26/validate_cmakelists.py
----------------------------------------------------------------------
diff --git a/validate_cmakelists.py b/validate_cmakelists.py
index 0b2e79d..f5f2f89 100755
--- a/validate_cmakelists.py
+++ b/validate_cmakelists.py
@@ -469,7 +469,7 @@ def main(cmakelists_to_process):
         int: The total number of targets that failed validation because of
             missing or superfluous dependencies.
     """
-    if not os.getcwd().endswith("quickstep"):
+    if not os.path.isfile("validate_cmakelists.py"):
         print("WARNING: you don't appear to be running in the root quickstep "
               "source directory. Don't blame me if something goes wrong.")
     qs_module_dirs = []


[39/46] incubator-quickstep git commit: Upgrade cpplint

Posted by ji...@apache.org.
Upgrade cpplint

- Added several missing headers.
- Modified the lint_everything file to add the command line flags.


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

Branch: refs/heads/fix-iwyu
Commit: d886ddb095d3eaafde00bdfb5f85f97aabe5e7e2
Parents: c43107d
Author: Harshad Deshmukh <hb...@apache.org>
Authored: Tue Dec 19 12:56:36 2017 -0600
Committer: Harshad Deshmukh <hb...@apache.org>
Committed: Thu Dec 21 14:30:47 2017 -0600

----------------------------------------------------------------------
 .travis.yml                                     |    2 +-
 catalog/CatalogRelation.hpp                     |    1 +
 catalog/IndexScheme.hpp                         |    1 +
 catalog/tests/Catalog_unittest.cpp              |    1 +
 cli/tests/NetworkIO_unittest.cpp                |    6 +-
 .../aggregation/AggregationHandleSum.cpp        |    1 +
 expressions/scalar/ScalarAttribute.cpp          |    1 +
 .../WindowAggregateFunctionAvg.cpp              |    1 +
 .../WindowAggregateFunctionAvg.hpp              |    1 +
 .../WindowAggregateFunctionCount.cpp            |    1 +
 .../WindowAggregateFunctionCount.hpp            |    1 +
 .../WindowAggregateFunctionMax.cpp              |    1 +
 .../WindowAggregateFunctionMax.hpp              |    1 +
 .../WindowAggregateFunctionMin.cpp              |    1 +
 .../WindowAggregateFunctionMin.hpp              |    1 +
 .../WindowAggregateFunctionSum.cpp              |    1 +
 .../WindowAggregateFunctionSum.hpp              |    1 +
 lint_everything.py                              |   47 +
 parser/ParseBlockProperties.cpp                 |    8 +-
 parser/ParseBlockProperties.hpp                 |    8 +-
 parser/ParseString.hpp                          |    2 +-
 query_optimizer/LIPFilterGenerator.cpp          |    1 +
 .../expressions/BinaryExpression.cpp            |    1 +
 query_optimizer/expressions/Exists.cpp          |    4 +-
 query_optimizer/expressions/InTableQuery.cpp    |    1 +
 query_optimizer/expressions/InValueList.cpp     |    2 +
 query_optimizer/expressions/LogicalAnd.cpp      |    1 +
 query_optimizer/expressions/LogicalOr.cpp       |    1 +
 query_optimizer/expressions/SearchedCase.cpp    |    1 +
 query_optimizer/expressions/SimpleCase.cpp      |    2 +
 .../expressions/SubqueryExpression.cpp          |    1 +
 query_optimizer/logical/SetOperation.hpp        |    1 +
 query_optimizer/logical/Sort.hpp                |    1 +
 .../physical/SharedSubplanReference.hpp         |    1 +
 query_optimizer/physical/Sort.hpp               |    1 +
 query_optimizer/physical/TableReference.hpp     |    1 +
 query_optimizer/resolver/NameResolver.cpp       |    1 +
 query_optimizer/resolver/NameResolver.hpp       |    1 +
 query_optimizer/rules/AttachLIPFilters.cpp      |    5 +-
 .../StarSchemaHashJoinOrderOptimization.cpp     |    2 +
 query_optimizer/rules/UnnestSubqueries.cpp      |    1 +
 .../rules/tests/PushDownFilter_unittest.cpp     |    2 +
 .../rules/tests/UpdateExpression_unittest.cpp   |    2 +
 .../strategy/tests/Aggregate_unittest.cpp       |    1 +
 .../strategy/tests/Join_unittest.cpp            |    1 +
 .../strategy/tests/OneToOne_unittest.cpp        |    2 +
 .../strategy/tests/Selection_unittest.cpp       |    2 +
 query_optimizer/strategy/tests/StrategyTest.hpp |    2 +
 .../tests/ExecutionGeneratorTestRunner.cpp      |    2 +-
 .../tests/ExecutionGeneratorTestRunner.hpp      |    2 +-
 relational_operators/AggregationOperator.hpp    |    1 +
 relational_operators/InsertOperator.cpp         |    1 +
 relational_operators/InsertOperator.hpp         |    1 +
 .../WindowAggregationOperator.cpp               |    1 +
 .../WindowAggregationOperator.hpp               |    1 +
 .../BasicColumnStoreTupleStorageSubBlock.hpp    |    4 +-
 storage/BasicColumnStoreValueAccessor.hpp       |   13 +-
 storage/CollisionFreeVectorTable.hpp            |    1 +
 storage/CompressedTupleStorageSubBlock.hpp      |    4 +-
 storage/LinearOpenAddressingHashTable.hpp       |    1 +
 storage/PackedPayloadHashTable.cpp              |    1 +
 storage/SplitRowStoreTupleStorageSubBlock.cpp   |    1 +
 storage/SplitRowStoreTupleStorageSubBlock.hpp   |    1 +
 storage/StorageManager.cpp                      |    1 +
 storage/SubBlockTypeRegistry.cpp                |    1 +
 storage/ThreadPrivateCompactKeyHashTable.cpp    |    2 +
 .../tests/BloomFilterIndexSubBlock_unittest.cpp |    1 +
 storage/tests/FileManager_unittest_common.hpp   |    4 -
 storage/tests/StorageBlockSort_unittest.cpp     |    1 +
 third_party/src/cpplint/cpplint.py              | 1205 +++++++++---------
 third_party/src/cpplint/lint_everything.py      |   40 -
 transaction/LockManager.cpp                     |    1 +
 .../comparisons/AsciiStringComparators-inl.hpp  |    1 +
 types/operations/comparisons/Comparison-inl.hpp |    1 +
 .../comparisons/LiteralComparators-inl.hpp      |    1 +
 .../PatternMatchingComparators-inl.hpp          |    1 +
 utility/tests/DAG_unittest.cpp                  |    2 +
 utility/tests/ScopedReassignment_unittest.cpp   |    2 +
 utility/textbased_test/TextBasedTestDriver.cpp  |    1 +
 79 files changed, 729 insertions(+), 701 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 9820599..4e7833f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -79,7 +79,7 @@ before_script:
            -D VECTOR_COPY_ELISION_LEVEL=$VECTOR_COPY_ELISION_LEVEL ..)
 
 script:
-  - ./third_party/src/cpplint/lint_everything.py
+  - ./lint_everything.py
   - ./validate_cmakelists.py
   - ./cyclic_dependency.py
   - (cd build && make)

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/catalog/CatalogRelation.hpp
----------------------------------------------------------------------
diff --git a/catalog/CatalogRelation.hpp b/catalog/CatalogRelation.hpp
index 6439a1b..2b5a250 100644
--- a/catalog/CatalogRelation.hpp
+++ b/catalog/CatalogRelation.hpp
@@ -24,6 +24,7 @@
 #include <cstddef>
 #include <memory>
 #include <string>
+#include <utility>
 #include <vector>
 
 #include "catalog/Catalog.pb.h"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/catalog/IndexScheme.hpp
----------------------------------------------------------------------
diff --git a/catalog/IndexScheme.hpp b/catalog/IndexScheme.hpp
index 3bf3f17..bc7f480 100644
--- a/catalog/IndexScheme.hpp
+++ b/catalog/IndexScheme.hpp
@@ -24,6 +24,7 @@
 #include <cstddef>
 #include <string>
 #include <unordered_map>
+#include <utility>
 #include <vector>
 
 #include "catalog/Catalog.pb.h"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/catalog/tests/Catalog_unittest.cpp
----------------------------------------------------------------------
diff --git a/catalog/tests/Catalog_unittest.cpp b/catalog/tests/Catalog_unittest.cpp
index 7b121fa..d3c101d 100644
--- a/catalog/tests/Catalog_unittest.cpp
+++ b/catalog/tests/Catalog_unittest.cpp
@@ -23,6 +23,7 @@
 #include <memory>
 #include <sstream>
 #include <string>
+#include <utility>
 #include <vector>
 
 #include "catalog/Catalog.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/cli/tests/NetworkIO_unittest.cpp
----------------------------------------------------------------------
diff --git a/cli/tests/NetworkIO_unittest.cpp b/cli/tests/NetworkIO_unittest.cpp
index 9dbd63e..48574c8 100644
--- a/cli/tests/NetworkIO_unittest.cpp
+++ b/cli/tests/NetworkIO_unittest.cpp
@@ -38,8 +38,8 @@ namespace quickstep {
 
 using networkio_internal::RequestState;
 
-static std::string const kQueryRequest = "O Captain! My Captain!";
-static std::string const kQueryResponse = "Our fearful trip is done,";
+static char const kQueryRequest[] = "O Captain! My Captain!";
+static char const kQueryResponse[] = "Our fearful trip is done,";
 
 /**
  * Contains a server instance for testing.
@@ -123,7 +123,7 @@ TEST(NetworkIOTest, TestNetworkIOCommandInteraction) {
     EXPECT_EQ(command->getCommand(), kQueryRequest);
 
     // Set some output for the main test thread, destruction of the handle will return the request.
-    fprintf(command->out(), "%s", kQueryResponse.c_str());
+    fprintf(command->out(), "%s", kQueryResponse);
   });
   server_handler.start();
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/expressions/aggregation/AggregationHandleSum.cpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregationHandleSum.cpp b/expressions/aggregation/AggregationHandleSum.cpp
index 9f5f220..b3e0059 100644
--- a/expressions/aggregation/AggregationHandleSum.cpp
+++ b/expressions/aggregation/AggregationHandleSum.cpp
@@ -22,6 +22,7 @@
 #include <cstddef>
 #include <cstdint>
 #include <memory>
+#include <utility>
 #include <vector>
 
 #include "catalog/CatalogTypedefs.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/expressions/scalar/ScalarAttribute.cpp
----------------------------------------------------------------------
diff --git a/expressions/scalar/ScalarAttribute.cpp b/expressions/scalar/ScalarAttribute.cpp
index 036eeba..944dc35 100644
--- a/expressions/scalar/ScalarAttribute.cpp
+++ b/expressions/scalar/ScalarAttribute.cpp
@@ -19,6 +19,7 @@
 
 #include "expressions/scalar/ScalarAttribute.hpp"
 
+#include <memory>
 #include <string>
 #include <utility>
 #include <vector>

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp b/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp
index 20c296b..9776ba1 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionAvg.cpp
@@ -19,6 +19,7 @@
 
 #include "expressions/window_aggregation/WindowAggregateFunctionAvg.hpp"
 
+#include <memory>
 #include <vector>
 
 #include "expressions/window_aggregation/WindowAggregationHandleAvg.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/expressions/window_aggregation/WindowAggregateFunctionAvg.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionAvg.hpp b/expressions/window_aggregation/WindowAggregateFunctionAvg.hpp
index 1706ce8..af3d688 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionAvg.hpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionAvg.hpp
@@ -20,6 +20,7 @@
 #ifndef QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_AVG_HPP_
 #define QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_AVG_HPP_
 
+#include <memory>
 #include <string>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/expressions/window_aggregation/WindowAggregateFunctionCount.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionCount.cpp b/expressions/window_aggregation/WindowAggregateFunctionCount.cpp
index 9290ac0..55f42cc 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionCount.cpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionCount.cpp
@@ -19,6 +19,7 @@
 
 #include "expressions/window_aggregation/WindowAggregateFunctionCount.hpp"
 
+#include <memory>
 #include <vector>
 
 #include "expressions/window_aggregation/WindowAggregationHandle.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/expressions/window_aggregation/WindowAggregateFunctionCount.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionCount.hpp b/expressions/window_aggregation/WindowAggregateFunctionCount.hpp
index f508105..972de33 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionCount.hpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionCount.hpp
@@ -20,6 +20,7 @@
 #ifndef QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_COUNT_HPP_
 #define QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_COUNT_HPP_
 
+#include <memory>
 #include <string>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/expressions/window_aggregation/WindowAggregateFunctionMax.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionMax.cpp b/expressions/window_aggregation/WindowAggregateFunctionMax.cpp
index 594301a..082ccbd 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionMax.cpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionMax.cpp
@@ -19,6 +19,7 @@
 
 #include "expressions/window_aggregation/WindowAggregateFunctionMax.hpp"
 
+#include <memory>
 #include <vector>
 
 #include "expressions/window_aggregation/WindowAggregationHandle.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/expressions/window_aggregation/WindowAggregateFunctionMax.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionMax.hpp b/expressions/window_aggregation/WindowAggregateFunctionMax.hpp
index 15563df..315aeca 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionMax.hpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionMax.hpp
@@ -20,6 +20,7 @@
 #ifndef QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_MAX_HPP_
 #define QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_MAX_HPP_
 
+#include <memory>
 #include <string>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/expressions/window_aggregation/WindowAggregateFunctionMin.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionMin.cpp b/expressions/window_aggregation/WindowAggregateFunctionMin.cpp
index 650241f..66909ff 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionMin.cpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionMin.cpp
@@ -19,6 +19,7 @@
 
 #include "expressions/window_aggregation/WindowAggregateFunctionMin.hpp"
 
+#include <memory>
 #include <vector>
 
 #include "expressions/window_aggregation/WindowAggregationHandle.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/expressions/window_aggregation/WindowAggregateFunctionMin.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionMin.hpp b/expressions/window_aggregation/WindowAggregateFunctionMin.hpp
index 8bb4386..231f60b 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionMin.hpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionMin.hpp
@@ -20,6 +20,7 @@
 #ifndef QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_MIN_HPP_
 #define QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_MIN_HPP_
 
+#include <memory>
 #include <string>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/expressions/window_aggregation/WindowAggregateFunctionSum.cpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionSum.cpp b/expressions/window_aggregation/WindowAggregateFunctionSum.cpp
index 14c51d8..d774b8a 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionSum.cpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionSum.cpp
@@ -19,6 +19,7 @@
 
 #include "expressions/window_aggregation/WindowAggregateFunctionSum.hpp"
 
+#include <memory>
 #include <vector>
 
 #include "expressions/window_aggregation/WindowAggregationHandle.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/expressions/window_aggregation/WindowAggregateFunctionSum.hpp
----------------------------------------------------------------------
diff --git a/expressions/window_aggregation/WindowAggregateFunctionSum.hpp b/expressions/window_aggregation/WindowAggregateFunctionSum.hpp
index 89582dd..a2f926a 100644
--- a/expressions/window_aggregation/WindowAggregateFunctionSum.hpp
+++ b/expressions/window_aggregation/WindowAggregateFunctionSum.hpp
@@ -20,6 +20,7 @@
 #ifndef QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_SUM_HPP_
 #define QUICKSTEP_EXPRESSIONS_WINDOW_AGGREGATION_WINDOW_AGGREGATE_FUNCTION_SUM_HPP_
 
+#include <memory>
 #include <string>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/lint_everything.py
----------------------------------------------------------------------
diff --git a/lint_everything.py b/lint_everything.py
new file mode 100755
index 0000000..ddc812c
--- /dev/null
+++ b/lint_everything.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python2
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+import subprocess
+import sys
+
+EXCLUDED_PREFIXES = ['./.', './third_party', './build', './parser/preprocessed']
+
+print "Running cpplint on entire source tree. This may take several minutes ..."
+
+call_args = ['/usr/bin/env',
+             'python2',
+             './third_party/src/cpplint/cpplint.py',
+             '--extensions=cpp,hpp',
+             '--linelength=120',
+             '--headers=hpp',
+             '--filter=-build/header_guard',
+             '--quiet']
+
+for (dirpath, dirnames, filenames) in os.walk('.'):
+    filtered = False
+    for prefix in EXCLUDED_PREFIXES:
+        if dirpath.startswith(prefix):
+            filtered = True
+    if not filtered:
+        for filename in filenames:
+            if filename.endswith('.hpp') or filename.endswith('.cpp'):
+                call_args.append(dirpath + '/' + filename)
+
+sys.exit(subprocess.call(call_args))

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/parser/ParseBlockProperties.cpp
----------------------------------------------------------------------
diff --git a/parser/ParseBlockProperties.cpp b/parser/ParseBlockProperties.cpp
index 31c30a0..053bd79 100644
--- a/parser/ParseBlockProperties.cpp
+++ b/parser/ParseBlockProperties.cpp
@@ -23,9 +23,9 @@
 
 namespace quickstep {
 
-const std::string ParseBlockProperties::kKeyBlockSizeMB = "blocksizemb";
-const std::string ParseBlockProperties::kKeyCompress = "compress";
-const std::string ParseBlockProperties::kKeySort = "sort";
-const std::string ParseBlockProperties::kKeyType = "type";
+const char ParseBlockProperties::kKeyBlockSizeMB[] = "blocksizemb";
+const char ParseBlockProperties::kKeyCompress[] = "compress";
+const char ParseBlockProperties::kKeySort[] = "sort";
+const char ParseBlockProperties::kKeyType[] = "type";
 
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/parser/ParseBlockProperties.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseBlockProperties.hpp b/parser/ParseBlockProperties.hpp
index fa176b1..f93107a 100644
--- a/parser/ParseBlockProperties.hpp
+++ b/parser/ParseBlockProperties.hpp
@@ -48,10 +48,10 @@ namespace quickstep {
  */
 class ParseBlockProperties : public ParseTreeNode {
   // Valid key names for the BlockProperties.
-  static const std::string kKeyBlockSizeMB;
-  static const std::string kKeyCompress;
-  static const std::string kKeySort;
-  static const std::string kKeyType;
+  static const char kKeyBlockSizeMB[];
+  static const char kKeyCompress[];
+  static const char kKeySort[];
+  static const char kKeyType[];
 
  public:
   /**

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/parser/ParseString.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseString.hpp b/parser/ParseString.hpp
index 1997822..13dbf44 100644
--- a/parser/ParseString.hpp
+++ b/parser/ParseString.hpp
@@ -115,4 +115,4 @@ class ParseString : public ParseTreeNode {
 
 }  // namespace quickstep
 
-#endif /* QUICKSTEP_PARSER_PARSE_STRING_HPP_ */
+#endif  // QUICKSTEP_PARSER_PARSE_STRING_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/LIPFilterGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/LIPFilterGenerator.cpp b/query_optimizer/LIPFilterGenerator.cpp
index 3562974..f87831c 100644
--- a/query_optimizer/LIPFilterGenerator.cpp
+++ b/query_optimizer/LIPFilterGenerator.cpp
@@ -21,6 +21,7 @@
 
 #include <map>
 #include <memory>
+#include <unordered_map>
 #include <unordered_set>
 #include <utility>
 #include <vector>

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/expressions/BinaryExpression.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/BinaryExpression.cpp b/query_optimizer/expressions/BinaryExpression.cpp
index f49c6a2..07eb5ff 100644
--- a/query_optimizer/expressions/BinaryExpression.cpp
+++ b/query_optimizer/expressions/BinaryExpression.cpp
@@ -23,6 +23,7 @@
 #include <cstddef>
 #include <string>
 #include <unordered_map>
+#include <utility>
 #include <vector>
 
 #include "expressions/scalar/ScalarBinaryExpression.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/expressions/Exists.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/Exists.cpp b/query_optimizer/expressions/Exists.cpp
index a7b0201..bf4cb72 100644
--- a/query_optimizer/expressions/Exists.cpp
+++ b/query_optimizer/expressions/Exists.cpp
@@ -19,8 +19,10 @@
 
 #include "query_optimizer/expressions/Exists.hpp"
 
-#include <vector>
 #include <string>
+#include <unordered_map>
+#include <utility>
+#include <vector>
 
 #include "query_optimizer/OptimizerTree.hpp"
 #include "query_optimizer/expressions/ExprId.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/expressions/InTableQuery.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/InTableQuery.cpp b/query_optimizer/expressions/InTableQuery.cpp
index 7122664..79018e5 100644
--- a/query_optimizer/expressions/InTableQuery.cpp
+++ b/query_optimizer/expressions/InTableQuery.cpp
@@ -20,6 +20,7 @@
 #include "query_optimizer/expressions/InTableQuery.hpp"
 
 #include <string>
+#include <unordered_map>
 #include <vector>
 
 #include "query_optimizer/OptimizerTree.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/expressions/InValueList.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/InValueList.cpp b/query_optimizer/expressions/InValueList.cpp
index 0451db7..d968d48 100644
--- a/query_optimizer/expressions/InValueList.cpp
+++ b/query_optimizer/expressions/InValueList.cpp
@@ -19,7 +19,9 @@
 
 #include "query_optimizer/expressions/InValueList.hpp"
 
+#include <memory>
 #include <string>
+#include <unordered_map>
 #include <vector>
 
 #include "expressions/predicate/DisjunctionPredicate.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/expressions/LogicalAnd.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/LogicalAnd.cpp b/query_optimizer/expressions/LogicalAnd.cpp
index 80ee0eb..1497874 100644
--- a/query_optimizer/expressions/LogicalAnd.cpp
+++ b/query_optimizer/expressions/LogicalAnd.cpp
@@ -19,6 +19,7 @@
 
 #include "query_optimizer/expressions/LogicalAnd.hpp"
 
+#include <memory>
 #include <string>
 #include <unordered_map>
 #include <vector>

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/expressions/LogicalOr.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/LogicalOr.cpp b/query_optimizer/expressions/LogicalOr.cpp
index 02028e1..3ae3e5d 100644
--- a/query_optimizer/expressions/LogicalOr.cpp
+++ b/query_optimizer/expressions/LogicalOr.cpp
@@ -19,6 +19,7 @@
 
 #include "query_optimizer/expressions/LogicalOr.hpp"
 
+#include <memory>
 #include <string>
 #include <unordered_map>
 #include <vector>

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/expressions/SearchedCase.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/SearchedCase.cpp b/query_optimizer/expressions/SearchedCase.cpp
index 2de52c9..c53e030 100644
--- a/query_optimizer/expressions/SearchedCase.cpp
+++ b/query_optimizer/expressions/SearchedCase.cpp
@@ -22,6 +22,7 @@
 #include <cstddef>
 #include <memory>
 #include <string>
+#include <unordered_map>
 #include <utility>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/expressions/SimpleCase.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/SimpleCase.cpp b/query_optimizer/expressions/SimpleCase.cpp
index b127d51..f11c8c8 100644
--- a/query_optimizer/expressions/SimpleCase.cpp
+++ b/query_optimizer/expressions/SimpleCase.cpp
@@ -20,7 +20,9 @@
 #include "query_optimizer/expressions/SimpleCase.hpp"
 
 #include <cstddef>
+#include <memory>
 #include <string>
+#include <unordered_map>
 #include <utility>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/expressions/SubqueryExpression.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/SubqueryExpression.cpp b/query_optimizer/expressions/SubqueryExpression.cpp
index dbcb6d6..bc5a6d3 100644
--- a/query_optimizer/expressions/SubqueryExpression.cpp
+++ b/query_optimizer/expressions/SubqueryExpression.cpp
@@ -20,6 +20,7 @@
 #include "query_optimizer/expressions/SubqueryExpression.hpp"
 
 #include <string>
+#include <unordered_map>
 #include <vector>
 
 #include "query_optimizer/OptimizerTree.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/logical/SetOperation.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/logical/SetOperation.hpp b/query_optimizer/logical/SetOperation.hpp
index 7e45231..2e706af 100644
--- a/query_optimizer/logical/SetOperation.hpp
+++ b/query_optimizer/logical/SetOperation.hpp
@@ -20,6 +20,7 @@
 #ifndef QUICKSTEP_QUERY_OPTIMIZER_LOGICAL_SET_OPERATION_HPP_
 #define QUICKSTEP_QUERY_OPTIMIZER_LOGICAL_SET_OPERATION_HPP_
 
+#include <memory>
 #include <string>
 #include <type_traits>
 #include <vector>

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/logical/Sort.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/logical/Sort.hpp b/query_optimizer/logical/Sort.hpp
index 894970b..129c6d4 100644
--- a/query_optimizer/logical/Sort.hpp
+++ b/query_optimizer/logical/Sort.hpp
@@ -22,6 +22,7 @@
 
 #include <memory>
 #include <string>
+#include <utility>
 #include <vector>
 
 #include "query_optimizer/OptimizerTree.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/physical/SharedSubplanReference.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/SharedSubplanReference.hpp b/query_optimizer/physical/SharedSubplanReference.hpp
index 60a2866..849bd3a 100644
--- a/query_optimizer/physical/SharedSubplanReference.hpp
+++ b/query_optimizer/physical/SharedSubplanReference.hpp
@@ -20,6 +20,7 @@
 #ifndef QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_SHARED_SUBPLAN_REFERENCE_HPP_
 #define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_SHARED_SUBPLAN_REFERENCE_HPP_
 
+#include <memory>
 #include <string>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/physical/Sort.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/Sort.hpp b/query_optimizer/physical/Sort.hpp
index d0c6fe8..4a49aa3 100644
--- a/query_optimizer/physical/Sort.hpp
+++ b/query_optimizer/physical/Sort.hpp
@@ -20,6 +20,7 @@
 #ifndef QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_SORT_HPP_
 #define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_SORT_HPP_
 
+#include <memory>
 #include <string>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/physical/TableReference.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/TableReference.hpp b/query_optimizer/physical/TableReference.hpp
index 85cb76b..d5b9896 100644
--- a/query_optimizer/physical/TableReference.hpp
+++ b/query_optimizer/physical/TableReference.hpp
@@ -20,6 +20,7 @@
 #ifndef QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_TABLE_REFERENCE_HPP_
 #define QUICKSTEP_QUERY_OPTIMIZER_PHYSICAL_TABLE_REFERENCE_HPP_
 
+#include <memory>
 #include <string>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/resolver/NameResolver.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/NameResolver.cpp b/query_optimizer/resolver/NameResolver.cpp
index 1c6bf6a..65f492f 100644
--- a/query_optimizer/resolver/NameResolver.cpp
+++ b/query_optimizer/resolver/NameResolver.cpp
@@ -20,6 +20,7 @@
 #include "query_optimizer/resolver/NameResolver.hpp"
 
 #include <map>
+#include <memory>
 #include <string>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/resolver/NameResolver.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/NameResolver.hpp b/query_optimizer/resolver/NameResolver.hpp
index 88154c7..4771e3e 100644
--- a/query_optimizer/resolver/NameResolver.hpp
+++ b/query_optimizer/resolver/NameResolver.hpp
@@ -21,6 +21,7 @@
 #define QUICKSTEP_QUERY_OPTIMIZER_RESOLVER_NAME_RESOLVER_HPP_
 
 #include <map>
+#include <memory>
 #include <string>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/rules/AttachLIPFilters.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/AttachLIPFilters.cpp b/query_optimizer/rules/AttachLIPFilters.cpp
index 9a13b48..7914bab 100644
--- a/query_optimizer/rules/AttachLIPFilters.cpp
+++ b/query_optimizer/rules/AttachLIPFilters.cpp
@@ -22,11 +22,12 @@
 #include <algorithm>
 #include <cstdint>
 #include <map>
+#include <memory>
 #include <set>
-#include <unordered_set>
 #include <unordered_map>
-#include <vector>
+#include <unordered_set>
 #include <utility>
+#include <vector>
 
 #include "query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp"
 #include "query_optimizer/expressions/AttributeReference.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp b/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp
index 340875d..1007dd5 100644
--- a/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp
+++ b/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp
@@ -24,6 +24,8 @@
 #include <memory>
 #include <set>
 #include <unordered_map>
+#include <unordered_set>
+#include <utility>
 #include <vector>
 
 #include "query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/rules/UnnestSubqueries.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/UnnestSubqueries.cpp b/query_optimizer/rules/UnnestSubqueries.cpp
index b376b0b..8fba933 100644
--- a/query_optimizer/rules/UnnestSubqueries.cpp
+++ b/query_optimizer/rules/UnnestSubqueries.cpp
@@ -23,6 +23,7 @@
 #include <functional>
 #include <memory>
 #include <set>
+#include <unordered_map>
 #include <utility>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/rules/tests/PushDownFilter_unittest.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/tests/PushDownFilter_unittest.cpp b/query_optimizer/rules/tests/PushDownFilter_unittest.cpp
index 9f26180..6956ac6 100644
--- a/query_optimizer/rules/tests/PushDownFilter_unittest.cpp
+++ b/query_optimizer/rules/tests/PushDownFilter_unittest.cpp
@@ -19,6 +19,8 @@
 
 #include "query_optimizer/rules/PushDownFilter.hpp"
 
+#include <memory>
+
 #include "query_optimizer/expressions/Alias.hpp"
 #include "query_optimizer/expressions/AttributeReference.hpp"
 #include "query_optimizer/expressions/ComparisonExpression.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/rules/tests/UpdateExpression_unittest.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/tests/UpdateExpression_unittest.cpp b/query_optimizer/rules/tests/UpdateExpression_unittest.cpp
index f13b685..37012d4 100644
--- a/query_optimizer/rules/tests/UpdateExpression_unittest.cpp
+++ b/query_optimizer/rules/tests/UpdateExpression_unittest.cpp
@@ -20,6 +20,8 @@
 #include "query_optimizer/rules/UpdateExpression.hpp"
 
 #include <map>
+#include <memory>
+#include <unordered_map>
 
 #include "query_optimizer/expressions/Alias.hpp"
 #include "query_optimizer/expressions/AttributeReference.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/strategy/tests/Aggregate_unittest.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/strategy/tests/Aggregate_unittest.cpp b/query_optimizer/strategy/tests/Aggregate_unittest.cpp
index 8eb5e93..ecf94b2 100644
--- a/query_optimizer/strategy/tests/Aggregate_unittest.cpp
+++ b/query_optimizer/strategy/tests/Aggregate_unittest.cpp
@@ -19,6 +19,7 @@
 
 #include "query_optimizer/strategy/Aggregate.hpp"
 
+#include <memory>
 #include <vector>
 
 #include "expressions/aggregation/AggregateFunctionFactory.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/strategy/tests/Join_unittest.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/strategy/tests/Join_unittest.cpp b/query_optimizer/strategy/tests/Join_unittest.cpp
index ad34bec..14025c3 100644
--- a/query_optimizer/strategy/tests/Join_unittest.cpp
+++ b/query_optimizer/strategy/tests/Join_unittest.cpp
@@ -19,6 +19,7 @@
 
 #include "query_optimizer/strategy/Join.hpp"
 
+#include <memory>
 #include <vector>
 
 #include "query_optimizer/OptimizerContext.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/strategy/tests/OneToOne_unittest.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/strategy/tests/OneToOne_unittest.cpp b/query_optimizer/strategy/tests/OneToOne_unittest.cpp
index 9dda602..a07c110 100644
--- a/query_optimizer/strategy/tests/OneToOne_unittest.cpp
+++ b/query_optimizer/strategy/tests/OneToOne_unittest.cpp
@@ -19,6 +19,8 @@
 
 #include "query_optimizer/strategy/OneToOne.hpp"
 
+#include <memory>
+
 #include "query_optimizer/logical/Logical.hpp"
 #include "query_optimizer/logical/TableReference.hpp"
 #include "query_optimizer/logical/TopLevelPlan.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/strategy/tests/Selection_unittest.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/strategy/tests/Selection_unittest.cpp b/query_optimizer/strategy/tests/Selection_unittest.cpp
index 35b0bd2..58fe379 100644
--- a/query_optimizer/strategy/tests/Selection_unittest.cpp
+++ b/query_optimizer/strategy/tests/Selection_unittest.cpp
@@ -19,6 +19,8 @@
 
 #include "query_optimizer/strategy/Selection.hpp"
 
+#include <memory>
+
 #include "query_optimizer/OptimizerContext.hpp"
 #include "query_optimizer/expressions/Alias.hpp"
 #include "query_optimizer/expressions/AttributeReference.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/strategy/tests/StrategyTest.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/strategy/tests/StrategyTest.hpp b/query_optimizer/strategy/tests/StrategyTest.hpp
index dcad010..2fcf205 100644
--- a/query_optimizer/strategy/tests/StrategyTest.hpp
+++ b/query_optimizer/strategy/tests/StrategyTest.hpp
@@ -20,6 +20,8 @@
 #ifndef QUICKSTEP_QUERY_OPTIMIZER_STRATEGY_TESTS_STRATEGY_TEST_HPP_
 #define QUICKSTEP_QUERY_OPTIMIZER_STRATEGY_TESTS_STRATEGY_TEST_HPP_
 
+#include <memory>
+
 #include "query_optimizer/logical/Logical.hpp"
 #include "query_optimizer/physical/Physical.hpp"
 #include "query_optimizer/strategy/Strategy.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/tests/ExecutionGeneratorTestRunner.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/ExecutionGeneratorTestRunner.cpp b/query_optimizer/tests/ExecutionGeneratorTestRunner.cpp
index a854589..39c0c78 100644
--- a/query_optimizer/tests/ExecutionGeneratorTestRunner.cpp
+++ b/query_optimizer/tests/ExecutionGeneratorTestRunner.cpp
@@ -43,7 +43,7 @@ class CatalogRelation;
 
 namespace optimizer {
 
-const std::string ExecutionGeneratorTestRunner::kResetOption =
+const char ExecutionGeneratorTestRunner::kResetOption[] =
     "reset_before_execution";
 
 void ExecutionGeneratorTestRunner::runTestCase(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/query_optimizer/tests/ExecutionGeneratorTestRunner.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/ExecutionGeneratorTestRunner.hpp b/query_optimizer/tests/ExecutionGeneratorTestRunner.hpp
index f4e11ea..ff4f9c8 100644
--- a/query_optimizer/tests/ExecutionGeneratorTestRunner.hpp
+++ b/query_optimizer/tests/ExecutionGeneratorTestRunner.hpp
@@ -53,7 +53,7 @@ class ExecutionGeneratorTestRunner : public TextBasedTestRunner {
    * @brief If this option is enabled, recreate the entire database and
    * repopulate the data before every test.
    */
-  static const std::string kResetOption;
+  static const char kResetOption[];
 
   /**
    * @brief Constructor.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/relational_operators/AggregationOperator.hpp
----------------------------------------------------------------------
diff --git a/relational_operators/AggregationOperator.hpp b/relational_operators/AggregationOperator.hpp
index c673ff5..91065b5 100644
--- a/relational_operators/AggregationOperator.hpp
+++ b/relational_operators/AggregationOperator.hpp
@@ -21,6 +21,7 @@
 #define QUICKSTEP_RELATIONAL_OPERATORS_AGGREGATION_OPERATOR_HPP_
 
 #include <cstddef>
+#include <memory>
 #include <string>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/relational_operators/InsertOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/InsertOperator.cpp b/relational_operators/InsertOperator.cpp
index b8c9f07..e675615 100644
--- a/relational_operators/InsertOperator.cpp
+++ b/relational_operators/InsertOperator.cpp
@@ -20,6 +20,7 @@
 #include "relational_operators/InsertOperator.hpp"
 
 #include <memory>
+#include <utility>
 #include <vector>
 
 #include "query_execution/QueryContext.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/relational_operators/InsertOperator.hpp
----------------------------------------------------------------------
diff --git a/relational_operators/InsertOperator.hpp b/relational_operators/InsertOperator.hpp
index 3865a7f..b019803 100644
--- a/relational_operators/InsertOperator.hpp
+++ b/relational_operators/InsertOperator.hpp
@@ -23,6 +23,7 @@
 #include <cstddef>
 #include <string>
 #include <memory>
+#include <utility>
 #include <vector>
 
 #include "catalog/CatalogRelation.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/relational_operators/WindowAggregationOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/WindowAggregationOperator.cpp b/relational_operators/WindowAggregationOperator.cpp
index 2fd9e32..faa63ea 100644
--- a/relational_operators/WindowAggregationOperator.cpp
+++ b/relational_operators/WindowAggregationOperator.cpp
@@ -19,6 +19,7 @@
 
 #include "relational_operators/WindowAggregationOperator.hpp"
 
+#include <utility>
 #include <vector>
 
 #include "catalog/CatalogRelation.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/relational_operators/WindowAggregationOperator.hpp
----------------------------------------------------------------------
diff --git a/relational_operators/WindowAggregationOperator.hpp b/relational_operators/WindowAggregationOperator.hpp
index beaf1a3..739bae2 100644
--- a/relational_operators/WindowAggregationOperator.hpp
+++ b/relational_operators/WindowAggregationOperator.hpp
@@ -21,6 +21,7 @@
 #define QUICKSTEP_RELATIONAL_OPERATORS_WINDOW_AGGREGATION_OPERATOR_HPP_
 
 #include <string>
+#include <utility>
 #include <vector>
 
 #include "catalog/CatalogRelation.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/BasicColumnStoreTupleStorageSubBlock.hpp
----------------------------------------------------------------------
diff --git a/storage/BasicColumnStoreTupleStorageSubBlock.hpp b/storage/BasicColumnStoreTupleStorageSubBlock.hpp
index e896a7a..0affc83 100644
--- a/storage/BasicColumnStoreTupleStorageSubBlock.hpp
+++ b/storage/BasicColumnStoreTupleStorageSubBlock.hpp
@@ -131,8 +131,8 @@ class BasicColumnStoreTupleStorageSubBlock : public TupleStorageSubBlock {
     return header_->num_tuples - 1;
   }
 
-  bool hasTupleWithID(const tuple_id tuple) const override {
-    return ((tuple >=0) && (tuple < header_->num_tuples));
+  bool hasTupleWithID(const tuple_id tid) const override {
+    return ((tid >=0) && (tid < header_->num_tuples));
   }
 
   InsertResult insertTuple(const Tuple &tuple) override;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/BasicColumnStoreValueAccessor.hpp
----------------------------------------------------------------------
diff --git a/storage/BasicColumnStoreValueAccessor.hpp b/storage/BasicColumnStoreValueAccessor.hpp
index 7516dc9..8c8ee6a 100644
--- a/storage/BasicColumnStoreValueAccessor.hpp
+++ b/storage/BasicColumnStoreValueAccessor.hpp
@@ -20,6 +20,7 @@
 #ifndef QUICKSTEP_STORAGE_BASIC_COLUMN_STORE_VALUE_ACCESSOR_HPP_
 #define QUICKSTEP_STORAGE_BASIC_COLUMN_STORE_VALUE_ACCESSOR_HPP_
 
+#include <memory>
 #include <vector>
 
 #include "catalog/CatalogRelationSchema.hpp"
@@ -108,25 +109,25 @@ class BasicColumnStoreValueAccessorHelper {
   }
 
   template <bool check_null>
-  inline const void* getAttributeValue(const tuple_id tuple,
+  inline const void* getAttributeValue(const tuple_id tid,
                                        const attribute_id attr) const {
-    DEBUG_ASSERT(tuple < num_tuples_);
+    DEBUG_ASSERT(tid < num_tuples_);
     DEBUG_ASSERT(relation_.hasAttributeWithId(attr));
     if (check_null
         && (!column_null_bitmaps_.elementIsNull(attr))
-        && column_null_bitmaps_[attr].getBit(tuple)) {
+        && column_null_bitmaps_[attr].getBit(tid)) {
       return nullptr;
     }
 
     // TODO(chasseur): Consider cacheing the byte lengths of attributes.
     return static_cast<const char*>(column_stripes_[attr])
-           + (tuple * relation_.getAttributeById(attr)->getType().maximumByteLength());
+           + (tid * relation_.getAttributeById(attr)->getType().maximumByteLength());
   }
 
-  inline TypedValue getAttributeValueTyped(const tuple_id tuple,
+  inline TypedValue getAttributeValueTyped(const tuple_id tid,
                                            const attribute_id attr) const {
     const Type &attr_type = relation_.getAttributeById(attr)->getType();
-    const void *untyped_value = getAttributeValue<true>(tuple, attr);
+    const void *untyped_value = getAttributeValue<true>(tid, attr);
     return (untyped_value == nullptr)
         ? attr_type.makeNullValue()
         : attr_type.makeValue(untyped_value, attr_type.maximumByteLength());

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/CollisionFreeVectorTable.hpp
----------------------------------------------------------------------
diff --git a/storage/CollisionFreeVectorTable.hpp b/storage/CollisionFreeVectorTable.hpp
index 8e1342b..2660cc4 100644
--- a/storage/CollisionFreeVectorTable.hpp
+++ b/storage/CollisionFreeVectorTable.hpp
@@ -26,6 +26,7 @@
 #include <cstdint>
 #include <cstring>
 #include <memory>
+#include <utility>
 #include <vector>
 
 #include "catalog/CatalogTypedefs.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/CompressedTupleStorageSubBlock.hpp
----------------------------------------------------------------------
diff --git a/storage/CompressedTupleStorageSubBlock.hpp b/storage/CompressedTupleStorageSubBlock.hpp
index 926ef4f..d89a529 100644
--- a/storage/CompressedTupleStorageSubBlock.hpp
+++ b/storage/CompressedTupleStorageSubBlock.hpp
@@ -119,8 +119,8 @@ class CompressedTupleStorageSubBlock : public TupleStorageSubBlock {
     return *static_cast<const tuple_id*>(sub_block_memory_) - 1;
   }
 
-  bool hasTupleWithID(const tuple_id tuple) const override {
-    return tuple < *static_cast<const tuple_id*>(sub_block_memory_);
+  bool hasTupleWithID(const tuple_id tid) const override {
+    return tid < *static_cast<const tuple_id*>(sub_block_memory_);
   }
 
   InsertResult insertTuple(const Tuple &tuple) override {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/LinearOpenAddressingHashTable.hpp
----------------------------------------------------------------------
diff --git a/storage/LinearOpenAddressingHashTable.hpp b/storage/LinearOpenAddressingHashTable.hpp
index 044ec6f..a654b3f 100644
--- a/storage/LinearOpenAddressingHashTable.hpp
+++ b/storage/LinearOpenAddressingHashTable.hpp
@@ -27,6 +27,7 @@
 #include <limits>
 #include <memory>
 #include <type_traits>
+#include <utility>
 #include <vector>
 
 #include "storage/HashTable.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/PackedPayloadHashTable.cpp
----------------------------------------------------------------------
diff --git a/storage/PackedPayloadHashTable.cpp b/storage/PackedPayloadHashTable.cpp
index 1df20d0..28935b2 100644
--- a/storage/PackedPayloadHashTable.cpp
+++ b/storage/PackedPayloadHashTable.cpp
@@ -23,6 +23,7 @@
 #include <cstddef>
 #include <cstdint>
 #include <cstdlib>
+#include <utility>
 #include <vector>
 
 #include "expressions/aggregation/AggregationHandle.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/SplitRowStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/SplitRowStoreTupleStorageSubBlock.cpp b/storage/SplitRowStoreTupleStorageSubBlock.cpp
index 9f5a839..c40ce01 100644
--- a/storage/SplitRowStoreTupleStorageSubBlock.cpp
+++ b/storage/SplitRowStoreTupleStorageSubBlock.cpp
@@ -22,6 +22,7 @@
 #include <cstddef>
 #include <cstdint>
 #include <cstring>
+#include <unordered_map>
 #include <utility>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/SplitRowStoreTupleStorageSubBlock.hpp
----------------------------------------------------------------------
diff --git a/storage/SplitRowStoreTupleStorageSubBlock.hpp b/storage/SplitRowStoreTupleStorageSubBlock.hpp
index c5a9528..a00195b 100644
--- a/storage/SplitRowStoreTupleStorageSubBlock.hpp
+++ b/storage/SplitRowStoreTupleStorageSubBlock.hpp
@@ -24,6 +24,7 @@
 #include <cstdint>
 #include <memory>
 #include <unordered_map>
+#include <utility>
 #include <vector>
 
 #include "expressions/predicate/PredicateCost.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/StorageManager.cpp
----------------------------------------------------------------------
diff --git a/storage/StorageManager.cpp b/storage/StorageManager.cpp
index 5924607..12a96d1 100644
--- a/storage/StorageManager.cpp
+++ b/storage/StorageManager.cpp
@@ -57,6 +57,7 @@
 #include <memory>
 #include <string>
 #include <unordered_map>
+#include <utility>
 #include <vector>
 
 #include "catalog/CatalogTypedefs.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/SubBlockTypeRegistry.cpp
----------------------------------------------------------------------
diff --git a/storage/SubBlockTypeRegistry.cpp b/storage/SubBlockTypeRegistry.cpp
index d35e422..07e8f48 100644
--- a/storage/SubBlockTypeRegistry.cpp
+++ b/storage/SubBlockTypeRegistry.cpp
@@ -20,6 +20,7 @@
 #include "storage/SubBlockTypeRegistry.hpp"
 
 #include <cstddef>
+#include <unordered_map>
 
 #include "storage/StorageBlockLayout.pb.h"
 #include "utility/Macros.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/ThreadPrivateCompactKeyHashTable.cpp
----------------------------------------------------------------------
diff --git a/storage/ThreadPrivateCompactKeyHashTable.cpp b/storage/ThreadPrivateCompactKeyHashTable.cpp
index fb68940..2b18f3a 100644
--- a/storage/ThreadPrivateCompactKeyHashTable.cpp
+++ b/storage/ThreadPrivateCompactKeyHashTable.cpp
@@ -22,7 +22,9 @@
 #include <algorithm>
 #include <cstddef>
 #include <cstdint>
+#include <memory>
 #include <type_traits>
+#include <utility>
 #include <vector>
 
 #include "expressions/aggregation/AggregationHandle.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/tests/BloomFilterIndexSubBlock_unittest.cpp
----------------------------------------------------------------------
diff --git a/storage/tests/BloomFilterIndexSubBlock_unittest.cpp b/storage/tests/BloomFilterIndexSubBlock_unittest.cpp
index 4f77c11..0287240 100644
--- a/storage/tests/BloomFilterIndexSubBlock_unittest.cpp
+++ b/storage/tests/BloomFilterIndexSubBlock_unittest.cpp
@@ -24,6 +24,7 @@
 #include <memory>
 #include <sstream>
 #include <string>
+#include <utility>
 #include <vector>
 
 #include "catalog/CatalogAttribute.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/tests/FileManager_unittest_common.hpp
----------------------------------------------------------------------
diff --git a/storage/tests/FileManager_unittest_common.hpp b/storage/tests/FileManager_unittest_common.hpp
index 06d64ec..f1172db 100644
--- a/storage/tests/FileManager_unittest_common.hpp
+++ b/storage/tests/FileManager_unittest_common.hpp
@@ -32,13 +32,9 @@
 
 namespace quickstep {
 
-namespace {
-
 static const char kSampleString[kSlotSizeBytes] =
   "All animals are equal, but some animals are more equal than others.";
 
-}  // namespace
-
 template <typename FileManagerImpl>
 class FileManagerTest : public ::testing::Test {
  protected:

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/storage/tests/StorageBlockSort_unittest.cpp
----------------------------------------------------------------------
diff --git a/storage/tests/StorageBlockSort_unittest.cpp b/storage/tests/StorageBlockSort_unittest.cpp
index 559f6c3..4fded73 100644
--- a/storage/tests/StorageBlockSort_unittest.cpp
+++ b/storage/tests/StorageBlockSort_unittest.cpp
@@ -22,6 +22,7 @@
 #include <limits>
 #include <memory>
 #include <string>
+#include <utility>
 #include <vector>
 
 #include "gtest/gtest.h"


[08/46] incubator-quickstep git commit: Fixed the root path check in the cyclic_dependency.py.

Posted by ji...@apache.org.
Fixed the root path check in the cyclic_dependency.py.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/0898a77b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/0898a77b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/0898a77b

Branch: refs/heads/fix-iwyu
Commit: 0898a77beac5ccb9c97675148bcf853a5490e279
Parents: 7fb7a77
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Mon Oct 2 20:47:44 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Tue Oct 3 10:48:45 2017 -0500

----------------------------------------------------------------------
 cyclic_dependency.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0898a77b/cyclic_dependency.py
----------------------------------------------------------------------
diff --git a/cyclic_dependency.py b/cyclic_dependency.py
index adb5fc7..4914e0b 100755
--- a/cyclic_dependency.py
+++ b/cyclic_dependency.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 
 # Script to do analyze the dependencies in Quickstep particularly cycles in the
 # dependency graph. This script can be used to find:
@@ -169,7 +169,7 @@ def find_path(G, nodes_list, nodes_map, source, target):
         print('No path.')
 
 def main():
-    if not os.getcwd().endswith("quickstep"):
+    if not os.path.isfile("cyclic_dependency.py"):
         print("WARNING: you don't appear to be running in the root quickstep "
               "source directory. Don't blame me if something goes wrong.")
     qs_module_dirs = []


[05/46] incubator-quickstep git commit: Bug fix in LockManager loop

Posted by ji...@apache.org.
Bug fix in LockManager loop

- Added a false condition for acquire lock
- Added clarifying comment.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/9cbb930b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/9cbb930b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/9cbb930b

Branch: refs/heads/fix-iwyu
Commit: 9cbb930b5adb589f7a2ba8140d8d59227c9a570e
Parents: bf455e2
Author: Harshad Deshmukh <hb...@apache.org>
Authored: Wed Sep 27 10:02:10 2017 -0500
Committer: Harshad Deshmukh <hb...@apache.org>
Committed: Fri Sep 29 10:42:41 2017 -0500

----------------------------------------------------------------------
 transaction/LockManager.cpp | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9cbb930b/transaction/LockManager.cpp
----------------------------------------------------------------------
diff --git a/transaction/LockManager.cpp b/transaction/LockManager.cpp
index 2a3760f..c917b4b 100644
--- a/transaction/LockManager.cpp
+++ b/transaction/LockManager.cpp
@@ -80,21 +80,22 @@ void LockManager::run() {
         if (request.getRequestType() == RequestType::kReleaseLocks) {
           CHECK(releaseAllLocks(request.getTransactionId()))
               << "Unexpected condition occured.";
-
         } else if (acquireLock(request.getTransactionId(),
                                request.getResourceId(),
                                request.getAccessMode())) {
+          // Lock has been acquired.
           LOG(INFO) << "Transaction "
                     << std::to_string(request.getTransactionId())
-                    << " is waiting " + request.getResourceId().toString();
+                    << " acquired " + request.getResourceId().toString();
 
-            inner_pending_requests_.push(request);
+          permitted_requests_.push(request);
         } else {
-            LOG(INFO) << "Transaction "
-                      << std::to_string(request.getTransactionId())
-                      << " acquired " + request.getResourceId().toString();
+          // We are unable to acquire lock at this point.
+          LOG(INFO) << "Transaction "
+                    << std::to_string(request.getTransactionId())
+                    << " is waiting " + request.getResourceId().toString();
 
-            permitted_requests_.push(request);
+          inner_pending_requests_.push(request);
         }
       }
     }


[34/46] incubator-quickstep git commit: Remove glog source code from third party

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/glog/vlog_is_on.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/glog/vlog_is_on.h b/third_party/src/glog/src/glog/vlog_is_on.h
deleted file mode 100644
index 02b0b86..0000000
--- a/third_party/src/glog/src/glog/vlog_is_on.h
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright (c) 1999, 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney and many others
-//
-// Defines the VLOG_IS_ON macro that controls the variable-verbosity
-// conditional logging.
-//
-// It's used by VLOG and VLOG_IF in logging.h
-// and by RAW_VLOG in raw_logging.h to trigger the logging.
-//
-// It can also be used directly e.g. like this:
-//   if (VLOG_IS_ON(2)) {
-//     // do some logging preparation and logging
-//     // that can't be accomplished e.g. via just VLOG(2) << ...;
-//   }
-//
-// The truth value that VLOG_IS_ON(level) returns is determined by 
-// the three verbosity level flags:
-//   --v=<n>  Gives the default maximal active V-logging level;
-//            0 is the default.
-//            Normally positive values are used for V-logging levels.
-//   --vmodule=<str>  Gives the per-module maximal V-logging levels to override
-//                    the value given by --v.
-//                    E.g. "my_module=2,foo*=3" would change the logging level
-//                    for all code in source files "my_module.*" and "foo*.*"
-//                    ("-inl" suffixes are also disregarded for this matching).
-//
-// SetVLOGLevel helper function is provided to do limited dynamic control over
-// V-logging by overriding the per-module settings given via --vmodule flag.
-//
-// CAVEAT: --vmodule functionality is not available in non gcc compilers.
-//
-
-#ifndef BASE_VLOG_IS_ON_H_
-#define BASE_VLOG_IS_ON_H_
-
-#include "glog/log_severity.h"
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-#if defined(__GNUC__)
-// We emit an anonymous static int* variable at every VLOG_IS_ON(n) site.
-// (Normally) the first time every VLOG_IS_ON(n) site is hit,
-// we determine what variable will dynamically control logging at this site:
-// it's either FLAGS_v or an appropriate internal variable
-// matching the current source file that represents results of
-// parsing of --vmodule flag and/or SetVLOGLevel calls.
-#define VLOG_IS_ON(verboselevel)                                \
-  __extension__  \
-  ({ static google::int32* vlocal__ = &google::kLogSiteUninitialized;           \
-     google::int32 verbose_level__ = (verboselevel);                    \
-     (*vlocal__ >= verbose_level__) &&                          \
-     ((vlocal__ != &google::kLogSiteUninitialized) ||                   \
-      (google::InitVLOG3__(&vlocal__, &FLAGS_v,                         \
-                   __FILE__, verbose_level__))); })
-#else
-// GNU extensions not available, so we do not support --vmodule.
-// Dynamic value of FLAGS_v always controls the logging level.
-#define VLOG_IS_ON(verboselevel) (FLAGS_v >= (verboselevel))
-#endif
-
-// Set VLOG(_IS_ON) level for module_pattern to log_level.
-// This lets us dynamically control what is normally set by the --vmodule flag.
-// Returns the level that previously applied to module_pattern.
-// NOTE: To change the log level for VLOG(_IS_ON) sites
-//	 that have already executed after/during InitGoogleLogging,
-//	 one needs to supply the exact --vmodule pattern that applied to them.
-//       (If no --vmodule pattern applied to them
-//       the value of FLAGS_v will continue to control them.)
-extern GOOGLE_GLOG_DLL_DECL int SetVLOGLevel(const char* module_pattern,
-                                             int log_level);
-
-// Various declarations needed for VLOG_IS_ON above: =========================
-
-// Special value used to indicate that a VLOG_IS_ON site has not been
-// initialized.  We make this a large value, so the common-case check
-// of "*vlocal__ >= verbose_level__" in VLOG_IS_ON definition
-// passes in such cases and InitVLOG3__ is then triggered.
-extern google::int32 kLogSiteUninitialized;
-
-// Helper routine which determines the logging info for a particalur VLOG site.
-//   site_flag     is the address of the site-local pointer to the controlling
-//                 verbosity level
-//   site_default  is the default to use for *site_flag
-//   fname         is the current source file name
-//   verbose_level is the argument to VLOG_IS_ON
-// We will return the return value for VLOG_IS_ON
-// and if possible set *site_flag appropriately.
-extern GOOGLE_GLOG_DLL_DECL bool InitVLOG3__(
-    google::int32** site_flag,
-    google::int32* site_default,
-    const char* fname,
-    google::int32 verbose_level);
-
-#endif  // BASE_VLOG_IS_ON_H_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/googletest.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/googletest.h b/third_party/src/glog/src/googletest.h
deleted file mode 100644
index b3e26c4..0000000
--- a/third_party/src/glog/src/googletest.h
+++ /dev/null
@@ -1,604 +0,0 @@
-// Copyright (c) 2009, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Shinichiro Hamaji
-//   (based on googletest: http://code.google.com/p/googletest/)
-
-#ifdef GOOGLETEST_H__
-#error You must not include this file twice.
-#endif
-#define GOOGLETEST_H__
-
-#include "utilities.h"
-
-#include <ctype.h>
-#include <setjmp.h>
-#include <time.h>
-
-#include <map>
-#include <sstream>
-#include <string>
-#include <vector>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#include "base/commandlineflags.h"
-
-using std::map;
-using std::string;
-using std::vector;
-
-_START_GOOGLE_NAMESPACE_
-
-extern GOOGLE_GLOG_DLL_DECL void (*g_logging_fail_func)();
-
-_END_GOOGLE_NAMESPACE_
-
-#undef GOOGLE_GLOG_DLL_DECL
-#define GOOGLE_GLOG_DLL_DECL
-
-static inline string GetTempDir() {
-#ifndef OS_WINDOWS
-  return "/tmp";
-#else
-  char tmp[MAX_PATH];
-  GetTempPathA(MAX_PATH, tmp);
-  return tmp;
-#endif
-}
-
-#ifdef OS_WINDOWS
-// The test will run in glog/vsproject/<project name>
-// (e.g., glog/vsproject/logging_unittest).
-static const char TEST_SRC_DIR[] = "../..";
-#elif !defined(TEST_SRC_DIR)
-# warning TEST_SRC_DIR should be defined in config.h
-static const char TEST_SRC_DIR[] = ".";
-#endif
-
-DEFINE_string(test_tmpdir, GetTempDir(), "Dir we use for temp files");
-DEFINE_string(test_srcdir, TEST_SRC_DIR,
-              "Source-dir root, needed to find glog_unittest_flagfile");
-DEFINE_bool(run_benchmark, false, "If true, run benchmarks");
-#ifdef NDEBUG
-DEFINE_int32(benchmark_iters, 100000000, "Number of iterations per benchmark");
-#else
-DEFINE_int32(benchmark_iters, 100000, "Number of iterations per benchmark");
-#endif
-
-#ifdef HAVE_LIB_GTEST
-# include <gtest/gtest.h>
-// Use our ASSERT_DEATH implementation.
-# undef ASSERT_DEATH
-# undef ASSERT_DEBUG_DEATH
-using testing::InitGoogleTest;
-#else
-
-_START_GOOGLE_NAMESPACE_
-
-void InitGoogleTest(int*, char**) {}
-
-// The following is some bare-bones testing infrastructure
-
-#define EXPECT_TRUE(cond)                               \
-  do {                                                  \
-    if (!(cond)) {                                      \
-      fprintf(stderr, "Check failed: %s\n", #cond);     \
-      exit(1);                                          \
-    }                                                   \
-  } while (0)
-
-#define EXPECT_FALSE(cond)  EXPECT_TRUE(!(cond))
-
-#define EXPECT_OP(op, val1, val2)                                       \
-  do {                                                                  \
-    if (!((val1) op (val2))) {                                          \
-      fprintf(stderr, "Check failed: %s %s %s\n", #val1, #op, #val2);   \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-#define EXPECT_EQ(val1, val2)  EXPECT_OP(==, val1, val2)
-#define EXPECT_NE(val1, val2)  EXPECT_OP(!=, val1, val2)
-#define EXPECT_GT(val1, val2)  EXPECT_OP(>, val1, val2)
-#define EXPECT_LT(val1, val2)  EXPECT_OP(<, val1, val2)
-
-#define EXPECT_NAN(arg)                                         \
-  do {                                                          \
-    if (!isnan(arg)) {                                          \
-      fprintf(stderr, "Check failed: isnan(%s)\n", #arg);       \
-      exit(1);                                                  \
-    }                                                           \
-  } while (0)
-
-#define EXPECT_INF(arg)                                         \
-  do {                                                          \
-    if (!isinf(arg)) {                                          \
-      fprintf(stderr, "Check failed: isinf(%s)\n", #arg);       \
-      exit(1);                                                  \
-    }                                                           \
-  } while (0)
-
-#define EXPECT_DOUBLE_EQ(val1, val2)                                    \
-  do {                                                                  \
-    if (((val1) < (val2) - 0.001 || (val1) > (val2) + 0.001)) {         \
-      fprintf(stderr, "Check failed: %s == %s\n", #val1, #val2);        \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-#define EXPECT_STREQ(val1, val2)                                        \
-  do {                                                                  \
-    if (strcmp((val1), (val2)) != 0) {                                  \
-      fprintf(stderr, "Check failed: streq(%s, %s)\n", #val1, #val2);   \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-
-vector<void (*)()> g_testlist;  // the tests to run
-
-#define TEST(a, b)                                      \
-  struct Test_##a##_##b {                               \
-    Test_##a##_##b() { g_testlist.push_back(&Run); }    \
-    static void Run() { FlagSaver fs; RunTest(); }      \
-    static void RunTest();                              \
-  };                                                    \
-  static Test_##a##_##b g_test_##a##_##b;               \
-  void Test_##a##_##b::RunTest()
-
-
-static inline int RUN_ALL_TESTS() {
-  vector<void (*)()>::const_iterator it;
-  for (it = g_testlist.begin(); it != g_testlist.end(); ++it) {
-    (*it)();
-  }
-  fprintf(stderr, "Passed %d tests\n\nPASS\n", (int)g_testlist.size());
-  return 0;
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#endif  // ! HAVE_LIB_GTEST
-
-_START_GOOGLE_NAMESPACE_
-
-static bool g_called_abort;
-static jmp_buf g_jmp_buf;
-static inline void CalledAbort() {
-  g_called_abort = true;
-  longjmp(g_jmp_buf, 1);
-}
-
-#ifdef OS_WINDOWS
-// TODO(hamaji): Death test somehow doesn't work in Windows.
-#define ASSERT_DEATH(fn, msg)
-#else
-#define ASSERT_DEATH(fn, msg)                                           \
-  do {                                                                  \
-    g_called_abort = false;                                             \
-    /* in logging.cc */                                                 \
-    void (*original_logging_fail_func)() = g_logging_fail_func;         \
-    g_logging_fail_func = &CalledAbort;                                 \
-    if (!setjmp(g_jmp_buf)) fn;                                         \
-    /* set back to their default */                                     \
-    g_logging_fail_func = original_logging_fail_func;                   \
-    if (!g_called_abort) {                                              \
-      fprintf(stderr, "Function didn't die (%s): %s\n", msg, #fn);      \
-      exit(1);                                                          \
-    }                                                                   \
-  } while (0)
-#endif
-
-#ifdef NDEBUG
-#define ASSERT_DEBUG_DEATH(fn, msg)
-#else
-#define ASSERT_DEBUG_DEATH(fn, msg) ASSERT_DEATH(fn, msg)
-#endif  // NDEBUG
-
-// Benchmark tools.
-
-#define BENCHMARK(n) static BenchmarkRegisterer __benchmark_ ## n (#n, &n);
-
-map<string, void (*)(int)> g_benchlist;  // the benchmarks to run
-
-class BenchmarkRegisterer {
- public:
-  BenchmarkRegisterer(const char* name, void (*function)(int iters)) {
-    EXPECT_TRUE(g_benchlist.insert(std::make_pair(name, function)).second);
-  }
-};
-
-static inline void RunSpecifiedBenchmarks() {
-  if (!FLAGS_run_benchmark) {
-    return;
-  }
-
-  int iter_cnt = FLAGS_benchmark_iters;
-  puts("Benchmark\tTime(ns)\tIterations");
-  for (map<string, void (*)(int)>::const_iterator iter = g_benchlist.begin();
-       iter != g_benchlist.end();
-       ++iter) {
-    clock_t start = clock();
-    iter->second(iter_cnt);
-    double elapsed_ns =
-        ((double)clock() - start) / CLOCKS_PER_SEC * 1000*1000*1000;
-    printf("%s\t%8.2lf\t%10d\n",
-           iter->first.c_str(), elapsed_ns / iter_cnt, iter_cnt);
-  }
-  puts("");
-}
-
-// ----------------------------------------------------------------------
-// Golden file functions
-// ----------------------------------------------------------------------
-
-class CapturedStream {
- public:
-  CapturedStream(int fd, const string & filename) :
-    fd_(fd),
-    uncaptured_fd_(-1),
-    filename_(filename) {
-    Capture();
-  }
-
-  ~CapturedStream() {
-    if (uncaptured_fd_ != -1) {
-      CHECK(close(uncaptured_fd_) != -1);
-    }
-  }
-
-  // Start redirecting output to a file
-  void Capture() {
-    // Keep original stream for later
-    CHECK(uncaptured_fd_ == -1) << ", Stream " << fd_ << " already captured!";
-    uncaptured_fd_ = dup(fd_);
-    CHECK(uncaptured_fd_ != -1);
-
-    // Open file to save stream to
-    int cap_fd = open(filename_.c_str(),
-                      O_CREAT | O_TRUNC | O_WRONLY,
-                      S_IRUSR | S_IWUSR);
-    CHECK(cap_fd != -1);
-
-    // Send stdout/stderr to this file
-    fflush(NULL);
-    CHECK(dup2(cap_fd, fd_) != -1);
-    CHECK(close(cap_fd) != -1);
-  }
-
-  // Remove output redirection
-  void StopCapture() {
-    // Restore original stream
-    if (uncaptured_fd_ != -1) {
-      fflush(NULL);
-      CHECK(dup2(uncaptured_fd_, fd_) != -1);
-    }
-  }
-
-  const string & filename() const { return filename_; }
-
- private:
-  int fd_;             // file descriptor being captured
-  int uncaptured_fd_;  // where the stream was originally being sent to
-  string filename_;    // file where stream is being saved
-};
-static CapturedStream * s_captured_streams[STDERR_FILENO+1];
-// Redirect a file descriptor to a file.
-//   fd       - Should be STDOUT_FILENO or STDERR_FILENO
-//   filename - File where output should be stored
-static inline void CaptureTestOutput(int fd, const string & filename) {
-  CHECK((fd == STDOUT_FILENO) || (fd == STDERR_FILENO));
-  CHECK(s_captured_streams[fd] == NULL);
-  s_captured_streams[fd] = new CapturedStream(fd, filename);
-}
-static inline void CaptureTestStderr() {
-  CaptureTestOutput(STDERR_FILENO, FLAGS_test_tmpdir + "/captured.err");
-}
-// Return the size (in bytes) of a file
-static inline size_t GetFileSize(FILE * file) {
-  fseek(file, 0, SEEK_END);
-  return static_cast<size_t>(ftell(file));
-}
-// Read the entire content of a file as a string
-static inline string ReadEntireFile(FILE * file) {
-  const size_t file_size = GetFileSize(file);
-  char * const buffer = new char[file_size];
-
-  size_t bytes_last_read = 0;  // # of bytes read in the last fread()
-  size_t bytes_read = 0;       // # of bytes read so far
-
-  fseek(file, 0, SEEK_SET);
-
-  // Keep reading the file until we cannot read further or the
-  // pre-determined file size is reached.
-  do {
-    bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file);
-    bytes_read += bytes_last_read;
-  } while (bytes_last_read > 0 && bytes_read < file_size);
-
-  const string content = string(buffer, buffer+bytes_read);
-  delete[] buffer;
-
-  return content;
-}
-// Get the captured stdout (when fd is STDOUT_FILENO) or stderr (when
-// fd is STDERR_FILENO) as a string
-static inline string GetCapturedTestOutput(int fd) {
-  CHECK(fd == STDOUT_FILENO || fd == STDERR_FILENO);
-  CapturedStream * const cap = s_captured_streams[fd];
-  CHECK(cap)
-    << ": did you forget CaptureTestStdout() or CaptureTestStderr()?";
-
-  // Make sure everything is flushed.
-  cap->StopCapture();
-
-  // Read the captured file.
-  FILE * const file = fopen(cap->filename().c_str(), "r");
-  const string content = ReadEntireFile(file);
-  fclose(file);
-
-  delete cap;
-  s_captured_streams[fd] = NULL;
-
-  return content;
-}
-// Get the captured stderr of a test as a string.
-static inline string GetCapturedTestStderr() {
-  return GetCapturedTestOutput(STDERR_FILENO);
-}
-
-// Check if the string is [IWEF](\d{4}|DATE)
-static inline bool IsLoggingPrefix(const string& s) {
-  if (s.size() != 5) return false;
-  if (!strchr("IWEF", s[0])) return false;
-  for (int i = 1; i <= 4; ++i) {
-    if (!isdigit(s[i]) && s[i] != "DATE"[i-1]) return false;
-  }
-  return true;
-}
-
-// Convert log output into normalized form.
-//
-// Example:
-//     I0102 030405 logging_unittest.cc:345] RAW: vlog -1
-//  => IDATE TIME__ logging_unittest.cc:LINE] RAW: vlog -1
-static inline string MungeLine(const string& line) {
-  std::istringstream iss(line);
-  string before, logcode_date, time, thread_lineinfo;
-  iss >> logcode_date;
-  while (!IsLoggingPrefix(logcode_date)) {
-    before += " " + logcode_date;
-    if (!(iss >> logcode_date)) {
-      // We cannot find the header of log output.
-      return before;
-    }
-  }
-  if (!before.empty()) before += " ";
-  iss >> time;
-  iss >> thread_lineinfo;
-  CHECK(!thread_lineinfo.empty());
-  if (thread_lineinfo[thread_lineinfo.size() - 1] != ']') {
-    // We found thread ID.
-    string tmp;
-    iss >> tmp;
-    CHECK(!tmp.empty());
-    CHECK_EQ(']', tmp[tmp.size() - 1]);
-    thread_lineinfo = "THREADID " + tmp;
-  }
-  size_t index = thread_lineinfo.find(':');
-  CHECK_NE(string::npos, index);
-  thread_lineinfo = thread_lineinfo.substr(0, index+1) + "LINE]";
-  string rest;
-  std::getline(iss, rest);
-  return (before + logcode_date[0] + "DATE TIME__ " + thread_lineinfo +
-          MungeLine(rest));
-}
-
-static inline void StringReplace(string* str,
-                          const string& oldsub,
-                          const string& newsub) {
-  size_t pos = str->find(oldsub);
-  if (pos != string::npos) {
-    str->replace(pos, oldsub.size(), newsub.c_str());
-  }
-}
-
-static inline string Munge(const string& filename) {
-  FILE* fp = fopen(filename.c_str(), "rb");
-  CHECK(fp != NULL) << filename << ": couldn't open";
-  char buf[4096];
-  string result;
-  while (fgets(buf, 4095, fp)) {
-    string line = MungeLine(buf);
-    char null_str[256];
-    sprintf(null_str, "%p", static_cast<void*>(NULL));
-    StringReplace(&line, "__NULLP__", null_str);
-    // Remove 0x prefix produced by %p. VC++ doesn't put the prefix.
-    StringReplace(&line, " 0x", " ");
-
-    char errmsg_buf[100];
-    posix_strerror_r(0, errmsg_buf, sizeof(errmsg_buf));
-    if (*errmsg_buf == '\0') {
-      // MacOSX 10.4 and FreeBSD return empty string for errno=0.
-      // In such case, the we need to remove an extra space.
-      StringReplace(&line, "__SUCCESS__ ", "");
-    } else {
-      StringReplace(&line, "__SUCCESS__", errmsg_buf);
-    }
-    StringReplace(&line, "__ENOENT__", strerror(ENOENT));
-    StringReplace(&line, "__EINTR__", strerror(EINTR));
-    StringReplace(&line, "__ENXIO__", strerror(ENXIO));
-    StringReplace(&line, "__ENOEXEC__", strerror(ENOEXEC));
-    result += line + "\n";
-  }
-  fclose(fp);
-  return result;
-}
-
-static inline void WriteToFile(const string& body, const string& file) {
-  FILE* fp = fopen(file.c_str(), "wb");
-  fwrite(body.data(), 1, body.size(), fp);
-  fclose(fp);
-}
-
-static inline bool MungeAndDiffTestStderr(const string& golden_filename) {
-  CapturedStream* cap = s_captured_streams[STDERR_FILENO];
-  CHECK(cap) << ": did you forget CaptureTestStderr()?";
-
-  cap->StopCapture();
-
-  // Run munge
-  const string captured = Munge(cap->filename());
-  const string golden = Munge(golden_filename);
-  if (captured != golden) {
-    fprintf(stderr,
-            "Test with golden file failed. We'll try to show the diff:\n");
-    string munged_golden = golden_filename + ".munged";
-    WriteToFile(golden, munged_golden);
-    string munged_captured = cap->filename() + ".munged";
-    WriteToFile(captured, munged_captured);
-    string diffcmd("diff -u " + munged_golden + " " + munged_captured);
-    if (system(diffcmd.c_str()) != 0) {
-      fprintf(stderr, "diff command was failed.\n");
-    }
-    unlink(munged_golden.c_str());
-    unlink(munged_captured.c_str());
-    return false;
-  }
-  LOG(INFO) << "Diff was successful";
-  return true;
-}
-
-// Save flags used from logging_unittest.cc.
-#ifndef HAVE_LIB_GFLAGS
-struct FlagSaver {
-  FlagSaver()
-      : v_(FLAGS_v),
-        stderrthreshold_(FLAGS_stderrthreshold),
-        logtostderr_(FLAGS_logtostderr),
-        alsologtostderr_(FLAGS_alsologtostderr) {}
-  ~FlagSaver() {
-    FLAGS_v = v_;
-    FLAGS_stderrthreshold = stderrthreshold_;
-    FLAGS_logtostderr = logtostderr_;
-    FLAGS_alsologtostderr = alsologtostderr_;
-  }
-  int v_;
-  int stderrthreshold_;
-  bool logtostderr_;
-  bool alsologtostderr_;
-};
-#endif
-
-class Thread {
- public:
-  virtual ~Thread() {}
-
-  void SetJoinable(bool) {}
-#if defined(OS_WINDOWS) || defined(OS_CYGWIN)
-  void Start() {
-    handle_ = CreateThread(NULL,
-                           0,
-                           (LPTHREAD_START_ROUTINE)&Thread::InvokeThread,
-                           (LPVOID)this,
-                           0,
-                           &th_);
-    CHECK(handle_) << "CreateThread";
-  }
-  void Join() {
-    WaitForSingleObject(handle_, INFINITE);
-  }
-#elif defined(HAVE_PTHREAD)
-  void Start() {
-    pthread_create(&th_, NULL, &Thread::InvokeThread, this);
-  }
-  void Join() {
-    pthread_join(th_, NULL);
-  }
-#else
-# error No thread implementation.
-#endif
-
- protected:
-  virtual void Run() = 0;
-
- private:
-  static void* InvokeThread(void* self) {
-    ((Thread*)self)->Run();
-    return NULL;
-  }
-
-#if defined(OS_WINDOWS) || defined(OS_CYGWIN)
-  HANDLE handle_;
-  DWORD th_;
-#else
-  pthread_t th_;
-#endif
-};
-
-static inline void SleepForMilliseconds(int t) {
-#ifndef OS_WINDOWS
-  usleep(t * 1000);
-#else
-  Sleep(t);
-#endif
-}
-
-// Add hook for operator new to ensure there are no memory allocation.
-
-void (*g_new_hook)() = NULL;
-
-_END_GOOGLE_NAMESPACE_
-
-void* operator new(size_t size) throw(std::bad_alloc) {
-  if (GOOGLE_NAMESPACE::g_new_hook) {
-    GOOGLE_NAMESPACE::g_new_hook();
-  }
-  return malloc(size);
-}
-
-void* operator new[](size_t size) throw(std::bad_alloc) {
-  return ::operator new(size);
-}
-
-void operator delete(void* p) throw() {
-  free(p);
-}
-
-void operator delete[](void* p) throw() {
-  ::operator delete(p);
-}


[14/46] incubator-quickstep git commit: Relax the sort requirement in columnstore.

Posted by ji...@apache.org.
Relax the sort requirement in columnstore.


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

Branch: refs/heads/fix-iwyu
Commit: ffb8e055a890a9002235a8516e5f2dece2d6228a
Parents: 69fd94b
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Mon Oct 9 11:23:08 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Tue Oct 10 14:10:03 2017 -0500

----------------------------------------------------------------------
 parser/CMakeLists.txt                      |  1 +
 parser/ParseBlockProperties.hpp            | 10 ++++--
 parser/tests/Create.test                   | 45 +++++++++++++++++++++++++
 query_optimizer/OptimizerTree.hpp          |  9 +++--
 query_optimizer/resolver/Resolver.cpp      | 15 +++++----
 query_optimizer/tests/resolver/Create.test | 38 +++++++++++++++++----
 6 files changed, 99 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/ffb8e055/parser/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt
index b3ddf30..d4aaab4 100644
--- a/parser/CMakeLists.txt
+++ b/parser/CMakeLists.txt
@@ -150,6 +150,7 @@ target_link_libraries(quickstep_parser_ParseBlockProperties
                       quickstep_parser_ParseTreeNode
                       quickstep_utility_Macros
                       quickstep_utility_PtrList
+                      quickstep_utility_SqlError
                       quickstep_utility_StringUtil)
 target_link_libraries(quickstep_parser_ParseCaseExpressions
                       quickstep_parser_ParseExpression

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/ffb8e055/parser/ParseBlockProperties.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseBlockProperties.hpp b/parser/ParseBlockProperties.hpp
index ce0cd92..fa176b1 100644
--- a/parser/ParseBlockProperties.hpp
+++ b/parser/ParseBlockProperties.hpp
@@ -31,6 +31,7 @@
 #include "parser/ParseTreeNode.hpp"
 #include "utility/Macros.hpp"
 #include "utility/PtrList.hpp"
+#include "utility/SqlError.hpp"
 #include "utility/StringUtil.hpp"
 
 #include "glog/logging.h"
@@ -143,10 +144,13 @@ class ParseBlockProperties : public ParseTreeNode {
     if (sort_key_value == nullptr) {
       return nullptr;
     }
-    if (sort_key_value->getKeyValueType() !=
-        ParseKeyValue::KeyValueType::kStringString) {
-      return nullptr;
+    if (sort_key_value->getKeyValueType() ==
+        ParseKeyValue::KeyValueType::kStringStringList) {
+      THROW_SQL_ERROR_AT(sort_key_value)
+          << "The SORT property must be a string, not a string list.";
     }
+
+    DCHECK(sort_key_value->getKeyValueType() == ParseKeyValue::KeyValueType::kStringString);
     return static_cast<const ParseKeyStringValue*>(sort_key_value)->value();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/ffb8e055/parser/tests/Create.test
----------------------------------------------------------------------
diff --git a/parser/tests/Create.test b/parser/tests/Create.test
index 8c11054..3923c13 100644
--- a/parser/tests/Create.test
+++ b/parser/tests/Create.test
@@ -259,6 +259,51 @@ CreateTableStatement[relation_name=test]
       +-value=String[value=rowstore]
 ==
 
+CREATE TABLE test (attr INT, attr2 INT) WITH BLOCKPROPERTIES
+(TYPE columnstore)
+--
+CreateTableStatement[relation_name=test]
++-attribute_list=
+| +-AttributeDefinition[name=attr,type=Int]
+| +-AttributeDefinition[name=attr2,type=Int]
++-block_properties=
+  +-BlockProperties
+    +-block_property=KeyStringValue[key=TYPE]
+      +-value=String[value=columnstore]
+==
+
+CREATE TABLE test (attr INT, attr2 INT) WITH BLOCKPROPERTIES
+(TYPE columnstore, SORT attr)
+--
+CreateTableStatement[relation_name=test]
++-attribute_list=
+| +-AttributeDefinition[name=attr,type=Int]
+| +-AttributeDefinition[name=attr2,type=Int]
++-block_properties=
+  +-BlockProperties
+    +-block_property=KeyStringValue[key=TYPE]
+    | +-value=String[value=columnstore]
+    +-block_property=KeyStringValue[key=SORT]
+      +-value=String[value=attr]
+==
+
+CREATE TABLE test (attr INT, attr2 INT) WITH BLOCKPROPERTIES
+(TYPE columnstore, SORT (attr, attr2))
+--
+CreateTableStatement[relation_name=test]
++-attribute_list=
+| +-AttributeDefinition[name=attr,type=Int]
+| +-AttributeDefinition[name=attr2,type=Int]
++-block_properties=
+  +-BlockProperties
+    +-block_property=KeyStringValue[key=TYPE]
+    | +-value=String[value=columnstore]
+    +-block_property=KeyStringList[key=SORT]
+      +-value_list=
+        +-String[value=attr]
+        +-String[value=attr2]
+==
+
 CREATE TABLE test (attr INT) WITH BLOCKPROPERTIES
 (TYPE compressed_columnstore, SORT attr, COMPRESS ALL)
 --

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/ffb8e055/query_optimizer/OptimizerTree.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/OptimizerTree.hpp b/query_optimizer/OptimizerTree.hpp
index c54ce20..0f4713e 100644
--- a/query_optimizer/OptimizerTree.hpp
+++ b/query_optimizer/OptimizerTree.hpp
@@ -240,9 +240,12 @@ OptimizerProtoRepresentation<TreeNodeType>* getOptimizerRepresentationForProto(
     }
     case TupleStorageSubBlockDescription::BASIC_COLUMN_STORE: {
       node->addProperty("blocktype", "columnstore");
-      node->addProperty("sort",
-          storage_block_description.GetExtension(
-              quickstep::BasicColumnStoreTupleStorageSubBlockDescription::sort_attribute_id));
+      if (storage_block_description.HasExtension(
+              quickstep::BasicColumnStoreTupleStorageSubBlockDescription::sort_attribute_id)) {
+        node->addProperty("sort",
+            storage_block_description.GetExtension(
+                quickstep::BasicColumnStoreTupleStorageSubBlockDescription::sort_attribute_id));
+      }
       break;
     }
     case TupleStorageSubBlockDescription::COMPRESSED_COLUMN_STORE: {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/ffb8e055/query_optimizer/resolver/Resolver.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp
index 935e235..2991568 100644
--- a/query_optimizer/resolver/Resolver.cpp
+++ b/query_optimizer/resolver/Resolver.cpp
@@ -687,7 +687,7 @@ StorageBlockLayoutDescription* Resolver::resolveBlockProperties(
 
   // Resolve TYPE property.
   // The type of the block will determine these:
-  bool block_requires_sort = false;
+  bool block_allows_sort = false;
   bool block_requires_compress = false;
 
   const ParseString *type_parse_string = block_properties->getType();
@@ -702,7 +702,8 @@ StorageBlockLayoutDescription* Resolver::resolveBlockProperties(
   } else if (type_string.compare("columnstore") == 0) {
     description->set_sub_block_type(
         quickstep::TupleStorageSubBlockDescription::BASIC_COLUMN_STORE);
-    block_requires_sort = true;
+    // NOTE(zuyu): sort is optional.
+    block_allows_sort = true;
   } else if (type_string.compare("compressed_rowstore") == 0) {
     description->set_sub_block_type(
         quickstep::TupleStorageSubBlockDescription::COMPRESSED_PACKED_ROW_STORE);
@@ -710,7 +711,7 @@ StorageBlockLayoutDescription* Resolver::resolveBlockProperties(
   } else if (type_string.compare("compressed_columnstore") == 0) {
     description->set_sub_block_type(
         quickstep::TupleStorageSubBlockDescription::COMPRESSED_COLUMN_STORE);
-    block_requires_sort = true;
+    block_allows_sort = true;
     block_requires_compress = true;
   } else {
     THROW_SQL_ERROR_AT(type_parse_string) << "Unrecognized storage type.";
@@ -718,10 +719,12 @@ StorageBlockLayoutDescription* Resolver::resolveBlockProperties(
 
   // Resolve the SORT property.
   const ParseString *sort_parse_string = block_properties->getSort();
-  if (block_requires_sort) {
+  if (block_allows_sort) {
     if (sort_parse_string == nullptr) {
-      THROW_SQL_ERROR_AT(type_parse_string)
-          << "The SORT property must be specified as an attribute name.";
+      if (description->sub_block_type() != TupleStorageSubBlockDescription::BASIC_COLUMN_STORE) {
+        THROW_SQL_ERROR_AT(type_parse_string)
+            << "The SORT property must be specified as an attribute name.";
+      }
     } else {
       // Lookup the name and map to a column id.
       const attribute_id sort_id = GetAttributeIdFromName(create_table_statement.attribute_definition_list(),

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/ffb8e055/query_optimizer/tests/resolver/Create.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/resolver/Create.test b/query_optimizer/tests/resolver/Create.test
index c216c85..ed9158a 100644
--- a/query_optimizer/tests/resolver/Create.test
+++ b/query_optimizer/tests/resolver/Create.test
@@ -133,13 +133,37 @@ ERROR: The SORT property does not apply to this block type. (2 : 28)
                            ^
 ==
 
-# Columnstores require a sort attribute.
+# Columnstores do not require a sort attribute.
 CREATE TABLE foo (attr INT) WITH BLOCKPROPERTIES
 (TYPE columnstore);
 --
-ERROR: The SORT property must be specified as an attribute name. (2 : 7)
-(TYPE columnstore);
-      ^
+TopLevelPlan
++-plan=CreateTable[relation=foo]
+| +-block_properties=ProtoDescription
+| | +-Property=ProtoProperty[Property=blocktype,Value=columnstore]
+| | +-Property=ProtoProperty[Property=slots,Value=1]
+| +-attributes=
+|   +-AttributeReference[id=0,name=attr,relation=foo,type=Int]
++-output_attributes=
+  +-AttributeReference[id=0,name=attr,relation=foo,type=Int]
+==
+
+# Columnstores have a optional sort attribute.
+CREATE TABLE foo (attr INT, attr2 INT) WITH BLOCKPROPERTIES
+(TYPE columnstore, SORT attr2);
+--
+TopLevelPlan
++-plan=CreateTable[relation=foo]
+| +-block_properties=ProtoDescription
+| | +-Property=ProtoProperty[Property=blocktype,Value=columnstore]
+| | +-Property=ProtoProperty[Property=sort,Value=1]
+| | +-Property=ProtoProperty[Property=slots,Value=1]
+| +-attributes=
+|   +-AttributeReference[id=0,name=attr,relation=foo,type=Int]
+|   +-AttributeReference[id=1,name=attr2,relation=foo,type=Int]
++-output_attributes=
+  +-AttributeReference[id=0,name=attr,relation=foo,type=Int]
+  +-AttributeReference[id=1,name=attr2,relation=foo,type=Int]
 ==
 
 # Non-existant columns should be caught.
@@ -155,9 +179,9 @@ ERROR: The SORT property did not match any attribute name. (2 : 25)
 CREATE TABLE foo (attr INT, attr2 INT) WITH BLOCKPROPERTIES
 (TYPE columnstore, SORT (attr, attr2));
 --
-ERROR: The SORT property must be specified as an attribute name. (2 : 7)
-(TYPE columnstore, SORT (attr, attr2...
-      ^
+ERROR: The SORT property must be a string, not a string list. (2 : 20)
+(TYPE columnstore, SORT (attr, attr2));
+                   ^
 ==
 # Compress should only be specified on compressed blocks.
 CREATE TABLE foo (attr INT) WITH BLOCKPROPERTIES


[30/46] incubator-quickstep git commit: Remove glog source code from third party

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/symbolize.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/symbolize.h b/third_party/src/glog/src/symbolize.h
deleted file mode 100644
index 1ebe4dd..0000000
--- a/third_party/src/glog/src/symbolize.h
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-//
-// This library provides Symbolize() function that symbolizes program
-// counters to their corresponding symbol names on linux platforms.
-// This library has a minimal implementation of an ELF symbol table
-// reader (i.e. it doesn't depend on libelf, etc.).
-//
-// The algorithm used in Symbolize() is as follows.
-//
-//   1. Go through a list of maps in /proc/self/maps and find the map
-//   containing the program counter.
-//
-//   2. Open the mapped file and find a regular symbol table inside.
-//   Iterate over symbols in the symbol table and look for the symbol
-//   containing the program counter.  If such a symbol is found,
-//   obtain the symbol name, and demangle the symbol if possible.
-//   If the symbol isn't found in the regular symbol table (binary is
-//   stripped), try the same thing with a dynamic symbol table.
-//
-// Note that Symbolize() is originally implemented to be used in
-// FailureSignalHandler() in base/google.cc.  Hence it doesn't use
-// malloc() and other unsafe operations.  It should be both
-// thread-safe and async-signal-safe.
-
-#ifndef BASE_SYMBOLIZE_H_
-#define BASE_SYMBOLIZE_H_
-
-#include "utilities.h"
-#include "config.h"
-#include "glog/logging.h"
-
-#ifdef HAVE_SYMBOLIZE
-
-#if defined(__ELF__)  // defined by gcc on Linux
-#include <elf.h>
-#include <link.h>  // For ElfW() macro.
-
-// If there is no ElfW macro, let's define it by ourself.
-#ifndef ElfW
-# if SIZEOF_VOID_P == 4
-#  define ElfW(type) Elf32_##type
-# elif SIZEOF_VOID_P == 8
-#  define ElfW(type) Elf64_##type
-# else
-#  error "Unknown sizeof(void *)"
-# endif
-#endif
-
-_START_GOOGLE_NAMESPACE_
-
-// Gets the section header for the given name, if it exists. Returns true on
-// success. Otherwise, returns false.
-bool GetSectionHeaderByName(int fd, const char *name, size_t name_len,
-                            ElfW(Shdr) *out);
-
-_END_GOOGLE_NAMESPACE_
-
-#endif  /* __ELF__ */
-
-_START_GOOGLE_NAMESPACE_
-
-// Installs a callback function, which will be called right before a symbol name
-// is printed. The callback is intended to be used for showing a file name and a
-// line number preceding a symbol name.
-// "fd" is a file descriptor of the object file containing the program
-// counter "pc". The callback function should write output to "out"
-// and return the size of the output written. On error, the callback
-// function should return -1.
-typedef int (*SymbolizeCallback)(int fd, void *pc, char *out, size_t out_size,
-                                 uint64 relocation);
-void InstallSymbolizeCallback(SymbolizeCallback callback);
-
-_END_GOOGLE_NAMESPACE_
-
-#endif
-
-_START_GOOGLE_NAMESPACE_
-
-// Symbolizes a program counter.  On success, returns true and write the
-// symbol name to "out".  The symbol name is demangled if possible
-// (supports symbols generated by GCC 3.x or newer).  Otherwise,
-// returns false.
-bool Symbolize(void *pc, char *out, int out_size);
-
-_END_GOOGLE_NAMESPACE_
-
-#endif  // BASE_SYMBOLIZE_H_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/symbolize_unittest.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/symbolize_unittest.cc b/third_party/src/glog/src/symbolize_unittest.cc
deleted file mode 100644
index f25909d..0000000
--- a/third_party/src/glog/src/symbolize_unittest.cc
+++ /dev/null
@@ -1,365 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-//
-// Unit tests for functions in symbolize.cc.
-
-#include "utilities.h"
-
-#include <signal.h>
-#include <iostream>
-
-#include "glog/logging.h"
-#include "symbolize.h"
-#include "googletest.h"
-#include "config.h"
-
-using namespace std;
-using namespace GOOGLE_NAMESPACE;
-
-#if defined(HAVE_STACKTRACE) && defined(__ELF__)
-
-#define always_inline
-
-// This unit tests make sense only with GCC.
-// Uses lots of GCC specific features.
-#if defined(__GNUC__) && !defined(__OPENCC__)
-#  if __GNUC__ >= 4
-#    define TEST_WITH_MODERN_GCC
-#    if __i386__  // always_inline isn't supported for x86_64 with GCC 4.1.0.
-#      undef always_inline
-#      define always_inline __attribute__((always_inline))
-#      define HAVE_ALWAYS_INLINE
-#    endif  // __i386__
-#  else
-#  endif  // __GNUC__ >= 4
-#  if defined(__i386__) || defined(__x86_64__)
-#    define TEST_X86_32_AND_64 1
-#  endif  // defined(__i386__) || defined(__x86_64__)
-#endif
-
-// A wrapper function for Symbolize() to make the unit test simple.
-static const char *TrySymbolize(void *pc) {
-  static char symbol[4096];
-  if (Symbolize(pc, symbol, sizeof(symbol))) {
-    return symbol;
-  } else {
-    return NULL;
-  }
-}
-
-// Make them C linkage to avoid mangled names.
-extern "C" {
-void nonstatic_func() {
-  volatile int a = 0;
-  ++a;
-}
-
-static void static_func() {
-  volatile int a = 0;
-  ++a;
-}
-}
-
-TEST(Symbolize, Symbolize) {
-  // We do C-style cast since GCC 2.95.3 doesn't allow
-  // reinterpret_cast<void *>(&func).
-
-  // Compilers should give us pointers to them.
-  EXPECT_STREQ("nonstatic_func", TrySymbolize((void *)(&nonstatic_func)));
-  EXPECT_STREQ("static_func", TrySymbolize((void *)(&static_func)));
-
-  EXPECT_TRUE(NULL == TrySymbolize(NULL));
-}
-
-struct Foo {
-  static void func(int x);
-};
-
-void ATTRIBUTE_NOINLINE Foo::func(int x) {
-  volatile int a = x;
-  ++a;
-}
-
-// With a modern GCC, Symbolize() should return demangled symbol
-// names.  Function parameters should be omitted.
-#ifdef TEST_WITH_MODERN_GCC
-TEST(Symbolize, SymbolizeWithDemangling) {
-  Foo::func(100);
-  EXPECT_STREQ("Foo::func()", TrySymbolize((void *)(&Foo::func)));
-}
-#endif
-
-// Tests that verify that Symbolize footprint is within some limit.
-
-// To measure the stack footprint of the Symbolize function, we create
-// a signal handler (for SIGUSR1 say) that calls the Symbolize function
-// on an alternate stack. This alternate stack is initialized to some
-// known pattern (0x55, 0x55, 0x55, ...). We then self-send this signal,
-// and after the signal handler returns, look at the alternate stack
-// buffer to see what portion has been touched.
-//
-// This trick gives us the the stack footprint of the signal handler.
-// But the signal handler, even before the call to Symbolize, consumes
-// some stack already. We however only want the stack usage of the
-// Symbolize function. To measure this accurately, we install two signal
-// handlers: one that does nothing and just returns, and another that
-// calls Symbolize. The difference between the stack consumption of these
-// two signals handlers should give us the Symbolize stack foorprint.
-
-static void *g_pc_to_symbolize;
-static char g_symbolize_buffer[4096];
-static char *g_symbolize_result;
-
-static void EmptySignalHandler(int signo) {}
-
-static void SymbolizeSignalHandler(int signo) {
-  if (Symbolize(g_pc_to_symbolize, g_symbolize_buffer,
-                sizeof(g_symbolize_buffer))) {
-    g_symbolize_result = g_symbolize_buffer;
-  } else {
-    g_symbolize_result = NULL;
-  }
-}
-
-const int kAlternateStackSize = 8096;
-const char kAlternateStackFillValue = 0x55;
-
-// These helper functions look at the alternate stack buffer, and figure
-// out what portion of this buffer has been touched - this is the stack
-// consumption of the signal handler running on this alternate stack.
-static ATTRIBUTE_NOINLINE bool StackGrowsDown(int *x) {
-  int y;
-  return &y < x;
-}
-static int GetStackConsumption(const char* alt_stack) {
-  int x;
-  if (StackGrowsDown(&x)) {
-    for (int i = 0; i < kAlternateStackSize; i++) {
-      if (alt_stack[i] != kAlternateStackFillValue) {
-        return (kAlternateStackSize - i);
-      }
-    }
-  } else {
-    for (int i = (kAlternateStackSize - 1); i >= 0; i--) {
-      if (alt_stack[i] != kAlternateStackFillValue) {
-        return i;
-      }
-    }
-  }
-  return -1;
-}
-
-#ifdef HAVE_SIGALTSTACK
-
-// Call Symbolize and figure out the stack footprint of this call.
-static const char *SymbolizeStackConsumption(void *pc, int *stack_consumed) {
-
-  g_pc_to_symbolize = pc;
-
-  // The alt-signal-stack cannot be heap allocated because there is a
-  // bug in glibc-2.2 where some signal handler setup code looks at the
-  // current stack pointer to figure out what thread is currently running.
-  // Therefore, the alternate stack must be allocated from the main stack
-  // itself.
-  char altstack[kAlternateStackSize];
-  memset(altstack, kAlternateStackFillValue, kAlternateStackSize);
-
-  // Set up the alt-signal-stack (and save the older one).
-  stack_t sigstk;
-  memset(&sigstk, 0, sizeof(stack_t));
-  stack_t old_sigstk;
-  sigstk.ss_sp = altstack;
-  sigstk.ss_size = kAlternateStackSize;
-  sigstk.ss_flags = 0;
-  CHECK_ERR(sigaltstack(&sigstk, &old_sigstk));
-
-  // Set up SIGUSR1 and SIGUSR2 signal handlers (and save the older ones).
-  struct sigaction sa;
-  memset(&sa, 0, sizeof(struct sigaction));
-  struct sigaction old_sa1, old_sa2;
-  sigemptyset(&sa.sa_mask);
-  sa.sa_flags = SA_ONSTACK;
-
-  // SIGUSR1 maps to EmptySignalHandler.
-  sa.sa_handler = EmptySignalHandler;
-  CHECK_ERR(sigaction(SIGUSR1, &sa, &old_sa1));
-
-  // SIGUSR2 maps to SymbolizeSignalHanlder.
-  sa.sa_handler = SymbolizeSignalHandler;
-  CHECK_ERR(sigaction(SIGUSR2, &sa, &old_sa2));
-
-  // Send SIGUSR1 signal and measure the stack consumption of the empty
-  // signal handler.
-  CHECK_ERR(kill(getpid(), SIGUSR1));
-  int stack_consumption1 = GetStackConsumption(altstack);
-
-  // Send SIGUSR2 signal and measure the stack consumption of the symbolize
-  // signal handler.
-  CHECK_ERR(kill(getpid(), SIGUSR2));
-  int stack_consumption2 = GetStackConsumption(altstack);
-
-  // The difference between the two stack consumption values is the
-  // stack footprint of the Symbolize function.
-  if (stack_consumption1 != -1 && stack_consumption2 != -1) {
-    *stack_consumed = stack_consumption2 - stack_consumption1;
-  } else {
-    *stack_consumed = -1;
-  }
-
-  // Log the stack consumption values.
-  LOG(INFO) << "Stack consumption of empty signal handler: "
-            << stack_consumption1;
-  LOG(INFO) << "Stack consumption of symbolize signal handler: "
-            << stack_consumption2;
-  LOG(INFO) << "Stack consumption of Symbolize: " << *stack_consumed;
-
-  // Now restore the old alt-signal-stack and signal handlers.
-  CHECK_ERR(sigaltstack(&old_sigstk, NULL));
-  CHECK_ERR(sigaction(SIGUSR1, &old_sa1, NULL));
-  CHECK_ERR(sigaction(SIGUSR2, &old_sa2, NULL));
-
-  return g_symbolize_result;
-}
-
-// Symbolize stack consumption should be within 2kB.
-const int kStackConsumptionUpperLimit = 2048;
-
-TEST(Symbolize, SymbolizeStackConsumption) {
-  int stack_consumed;
-  const char* symbol;
-
-  symbol = SymbolizeStackConsumption((void *)(&nonstatic_func),
-                                     &stack_consumed);
-  EXPECT_STREQ("nonstatic_func", symbol);
-  EXPECT_GT(stack_consumed, 0);
-  EXPECT_LT(stack_consumed, kStackConsumptionUpperLimit);
-
-  symbol = SymbolizeStackConsumption((void *)(&static_func),
-                                     &stack_consumed);
-  EXPECT_STREQ("static_func", symbol);
-  EXPECT_GT(stack_consumed, 0);
-  EXPECT_LT(stack_consumed, kStackConsumptionUpperLimit);
-}
-
-#ifdef TEST_WITH_MODERN_GCC
-TEST(Symbolize, SymbolizeWithDemanglingStackConsumption) {
-  Foo::func(100);
-  int stack_consumed;
-  const char* symbol;
-
-  symbol = SymbolizeStackConsumption((void *)(&Foo::func), &stack_consumed);
-
-  EXPECT_STREQ("Foo::func()", symbol);
-  EXPECT_GT(stack_consumed, 0);
-  EXPECT_LT(stack_consumed, kStackConsumptionUpperLimit);
-}
-#endif
-
-#endif  // HAVE_SIGALTSTACK
-
-// x86 specific tests.  Uses some inline assembler.
-extern "C" {
-inline void* always_inline inline_func() {
-  register void *pc = NULL;
-#ifdef TEST_X86_32_AND_64
-  __asm__ __volatile__("call 1f; 1: pop %0" : "=r"(pc));
-#endif
-  return pc;
-}
-
-void* ATTRIBUTE_NOINLINE non_inline_func() {
-  register void *pc = NULL;
-#ifdef TEST_X86_32_AND_64
-  __asm__ __volatile__("call 1f; 1: pop %0" : "=r"(pc));
-#endif
-  return pc;
-}
-
-void ATTRIBUTE_NOINLINE TestWithPCInsideNonInlineFunction() {
-#if defined(TEST_X86_32_AND_64) && defined(HAVE_ATTRIBUTE_NOINLINE)
-  void *pc = non_inline_func();
-  const char *symbol = TrySymbolize(pc);
-  CHECK(symbol != NULL);
-  CHECK_STREQ(symbol, "non_inline_func");
-  cout << "Test case TestWithPCInsideNonInlineFunction passed." << endl;
-#endif
-}
-
-void ATTRIBUTE_NOINLINE TestWithPCInsideInlineFunction() {
-#if defined(TEST_X86_32_AND_64) && defined(HAVE_ALWAYS_INLINE)
-  void *pc = inline_func();  // Must be inlined.
-  const char *symbol = TrySymbolize(pc);
-  CHECK(symbol != NULL);
-  CHECK_STREQ(symbol, __FUNCTION__);
-  cout << "Test case TestWithPCInsideInlineFunction passed." << endl;
-#endif
-}
-}
-
-// Test with a return address.
-void ATTRIBUTE_NOINLINE TestWithReturnAddress() {
-#if defined(HAVE_ATTRIBUTE_NOINLINE)
-  void *return_address = __builtin_return_address(0);
-  const char *symbol = TrySymbolize(return_address);
-  CHECK(symbol != NULL);
-  CHECK_STREQ(symbol, "main");
-  cout << "Test case TestWithReturnAddress passed." << endl;
-#endif
-}
-
-int main(int argc, char **argv) {
-  FLAGS_logtostderr = true;
-  InitGoogleLogging(argv[0]);
-  InitGoogleTest(&argc, argv);
-#ifdef HAVE_SYMBOLIZE
-  // We don't want to get affected by the callback interface, that may be
-  // used to install some callback function at InitGoogle() time.
-  InstallSymbolizeCallback(NULL);
-
-  TestWithPCInsideInlineFunction();
-  TestWithPCInsideNonInlineFunction();
-  TestWithReturnAddress();
-  return RUN_ALL_TESTS();
-#else
-  return 0;
-#endif
-}
-
-#else
-int main() {
-#ifdef HAVE_SYMBOLIZE
-  printf("PASS (no symbolize_unittest support)\n");
-#else
-  printf("PASS (no symbolize support)\n");
-#endif
-  return 0;
-}
-#endif  // HAVE_STACKTRACE

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/utilities.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/utilities.cc b/third_party/src/glog/src/utilities.cc
deleted file mode 100644
index 8ec69d3..0000000
--- a/third_party/src/glog/src/utilities.cc
+++ /dev/null
@@ -1,347 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Shinichiro Hamaji
-
-#include "utilities.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <signal.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#include <time.h>
-#if defined(HAVE_SYSCALL_H)
-#include <syscall.h>                 // for syscall()
-#elif defined(HAVE_SYS_SYSCALL_H)
-#include <sys/syscall.h>                 // for syscall()
-#endif
-#ifdef HAVE_SYSLOG_H
-# include <syslog.h>
-#endif
-
-#include "base/googleinit.h"
-
-using std::string;
-
-_START_GOOGLE_NAMESPACE_
-
-static const char* g_program_invocation_short_name = NULL;
-static pthread_t g_main_thread_id;
-
-_END_GOOGLE_NAMESPACE_
-
-// The following APIs are all internal.
-#ifdef HAVE_STACKTRACE
-
-#include "stacktrace.h"
-#include "symbolize.h"
-#include "base/commandlineflags.h"
-
-GLOG_DEFINE_bool(symbolize_stacktrace, true,
-                 "Symbolize the stack trace in the tombstone");
-
-_START_GOOGLE_NAMESPACE_
-
-typedef void DebugWriter(const char*, void*);
-
-// The %p field width for printf() functions is two characters per byte.
-// For some environments, add two extra bytes for the leading "0x".
-static const int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*);
-
-static void DebugWriteToStderr(const char* data, void *) {
-  // This one is signal-safe.
-  if (write(STDERR_FILENO, data, strlen(data)) < 0) {
-    // Ignore errors.
-  }
-}
-
-void DebugWriteToString(const char* data, void *arg) {
-  reinterpret_cast<string*>(arg)->append(data);
-}
-
-#ifdef HAVE_SYMBOLIZE
-// Print a program counter and its symbol name.
-static void DumpPCAndSymbol(DebugWriter *writerfn, void *arg, void *pc,
-                            const char * const prefix) {
-  char tmp[1024];
-  const char *symbol = "(unknown)";
-  // Symbolizes the previous address of pc because pc may be in the
-  // next function.  The overrun happens when the function ends with
-  // a call to a function annotated noreturn (e.g. CHECK).
-  if (Symbolize(reinterpret_cast<char *>(pc) - 1, tmp, sizeof(tmp))) {
-      symbol = tmp;
-  }
-  char buf[1024];
-  snprintf(buf, sizeof(buf), "%s@ %*p  %s\n",
-           prefix, kPrintfPointerFieldWidth, pc, symbol);
-  writerfn(buf, arg);
-}
-#endif
-
-static void DumpPC(DebugWriter *writerfn, void *arg, void *pc,
-                   const char * const prefix) {
-  char buf[100];
-  snprintf(buf, sizeof(buf), "%s@ %*p\n",
-           prefix, kPrintfPointerFieldWidth, pc);
-  writerfn(buf, arg);
-}
-
-// Dump current stack trace as directed by writerfn
-static void DumpStackTrace(int skip_count, DebugWriter *writerfn, void *arg) {
-  // Print stack trace
-  void* stack[32];
-  int depth = GetStackTrace(stack, ARRAYSIZE(stack), skip_count+1);
-  for (int i = 0; i < depth; i++) {
-#if defined(HAVE_SYMBOLIZE)
-    if (FLAGS_symbolize_stacktrace) {
-      DumpPCAndSymbol(writerfn, arg, stack[i], "    ");
-    } else {
-      DumpPC(writerfn, arg, stack[i], "    ");
-    }
-#else
-    DumpPC(writerfn, arg, stack[i], "    ");
-#endif
-  }
-}
-
-static void DumpStackTraceAndExit() {
-  DumpStackTrace(1, DebugWriteToStderr, NULL);
-
-  // Set the default signal handler for SIGABRT, to avoid invoking our
-  // own signal handler installed by InstallFailedSignalHandler().
-  struct sigaction sig_action;
-  memset(&sig_action, 0, sizeof(sig_action));
-  sigemptyset(&sig_action.sa_mask);
-  sig_action.sa_handler = SIG_DFL;
-  sigaction(SIGABRT, &sig_action, NULL);
-
-  abort();
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#endif  // HAVE_STACKTRACE
-
-_START_GOOGLE_NAMESPACE_
-
-namespace glog_internal_namespace_ {
-
-const char* ProgramInvocationShortName() {
-  if (g_program_invocation_short_name != NULL) {
-    return g_program_invocation_short_name;
-  } else {
-    // TODO(hamaji): Use /proc/self/cmdline and so?
-    return "UNKNOWN";
-  }
-}
-
-bool IsGoogleLoggingInitialized() {
-  return g_program_invocation_short_name != NULL;
-}
-
-bool is_default_thread() {
-  if (g_program_invocation_short_name == NULL) {
-    // InitGoogleLogging() not yet called, so unlikely to be in a different
-    // thread
-    return true;
-  } else {
-    return pthread_equal(pthread_self(), g_main_thread_id);
-  }
-}
-
-#ifdef OS_WINDOWS
-struct timeval {
-  long tv_sec, tv_usec;
-};
-
-// Based on: http://www.google.com/codesearch/p?hl=en#dR3YEbitojA/os_win32.c&q=GetSystemTimeAsFileTime%20license:bsd
-// See COPYING for copyright information.
-static int gettimeofday(struct timeval *tv, void* tz) {
-#define EPOCHFILETIME (116444736000000000ULL)
-  FILETIME ft;
-  LARGE_INTEGER li;
-  uint64 tt;
-
-  GetSystemTimeAsFileTime(&ft);
-  li.LowPart = ft.dwLowDateTime;
-  li.HighPart = ft.dwHighDateTime;
-  tt = (li.QuadPart - EPOCHFILETIME) / 10;
-  tv->tv_sec = tt / 1000000;
-  tv->tv_usec = tt % 1000000;
-
-  return 0;
-}
-#endif
-
-int64 CycleClock_Now() {
-  // TODO(hamaji): temporary impementation - it might be too slow.
-  struct timeval tv;
-  gettimeofday(&tv, NULL);
-  return static_cast<int64>(tv.tv_sec) * 1000000 + tv.tv_usec;
-}
-
-int64 UsecToCycles(int64 usec) {
-  return usec;
-}
-
-WallTime WallTime_Now() {
-  // Now, cycle clock is retuning microseconds since the epoch.
-  return CycleClock_Now() * 0.000001;
-}
-
-static int32 g_main_thread_pid = getpid();
-int32 GetMainThreadPid() {
-  return g_main_thread_pid;
-}
-
-bool PidHasChanged() {
-  int32 pid = getpid();
-  if (g_main_thread_pid == pid) {
-    return false;
-  }
-  g_main_thread_pid = pid;
-  return true;
-}
-
-pid_t GetTID() {
-  // On Linux and MacOSX, we try to use gettid().
-#if defined OS_LINUX || defined OS_MACOSX
-#ifndef __NR_gettid
-#ifdef OS_MACOSX
-#define __NR_gettid SYS_gettid
-#elif ! defined __i386__
-#error "Must define __NR_gettid for non-x86 platforms"
-#else
-#define __NR_gettid 224
-#endif
-#endif
-  static bool lacks_gettid = false;
-  if (!lacks_gettid) {
-    pid_t tid = syscall(__NR_gettid);
-    if (tid != -1) {
-      return tid;
-    }
-    // Technically, this variable has to be volatile, but there is a small
-    // performance penalty in accessing volatile variables and there should
-    // not be any serious adverse effect if a thread does not immediately see
-    // the value change to "true".
-    lacks_gettid = true;
-  }
-#endif  // OS_LINUX || OS_MACOSX
-
-  // If gettid() could not be used, we use one of the following.
-#if defined OS_LINUX
-  return getpid();  // Linux:  getpid returns thread ID when gettid is absent
-#elif defined OS_WINDOWS || defined OS_CYGWIN
-  return GetCurrentThreadId();
-#else
-  // If none of the techniques above worked, we use pthread_self().
-  return (pid_t)(uintptr_t)pthread_self();
-#endif
-}
-
-const char* const_basename(const char* filepath) {
-  const char* base = strrchr(filepath, '/');
-#ifdef OS_WINDOWS  // Look for either path separator in Windows
-  if (!base)
-    base = strrchr(filepath, '\\');
-#endif
-  return base ? (base+1) : filepath;
-}
-
-static string g_my_user_name;
-const string& MyUserName() {
-  return g_my_user_name;
-}
-static void MyUserNameInitializer() {
-  // TODO(hamaji): Probably this is not portable.
-#if defined(OS_WINDOWS)
-  const char* user = getenv("USERNAME");
-#else
-  const char* user = getenv("USER");
-#endif
-  if (user != NULL) {
-    g_my_user_name = user;
-  } else {
-    g_my_user_name = "invalid-user";
-  }
-}
-REGISTER_MODULE_INITIALIZER(utilities, MyUserNameInitializer())
-
-#ifdef HAVE_STACKTRACE
-void DumpStackTraceToString(string* stacktrace) {
-  DumpStackTrace(1, DebugWriteToString, stacktrace);
-}
-#endif
-
-// We use an atomic operation to prevent problems with calling CrashReason
-// from inside the Mutex implementation (potentially through RAW_CHECK).
-static const CrashReason* g_reason = 0;
-
-void SetCrashReason(const CrashReason* r) {
-  sync_val_compare_and_swap(&g_reason,
-                            reinterpret_cast<const CrashReason*>(0),
-                            r);
-}
-
-void InitGoogleLoggingUtilities(const char* argv0) {
-  CHECK(!IsGoogleLoggingInitialized())
-      << "You called InitGoogleLogging() twice!";
-  const char* slash = strrchr(argv0, '/');
-#ifdef OS_WINDOWS
-  if (!slash)  slash = strrchr(argv0, '\\');
-#endif
-  g_program_invocation_short_name = slash ? slash + 1 : argv0;
-  g_main_thread_id = pthread_self();
-
-#ifdef HAVE_STACKTRACE
-  InstallFailureFunction(&DumpStackTraceAndExit);
-#endif
-}
-
-void ShutdownGoogleLoggingUtilities() {
-  CHECK(IsGoogleLoggingInitialized())
-      << "You called ShutdownGoogleLogging() without calling InitGoogleLogging() first!";
-  g_program_invocation_short_name = NULL;
-#ifdef HAVE_SYSLOG_H
-  closelog();
-#endif
-}
-
-}  // namespace glog_internal_namespace_
-
-_END_GOOGLE_NAMESPACE_
-
-// Make an implementation of stacktrace compiled.
-#ifdef STACKTRACE_H
-# include STACKTRACE_H
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/utilities.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/utilities.h b/third_party/src/glog/src/utilities.h
deleted file mode 100644
index 5f79968..0000000
--- a/third_party/src/glog/src/utilities.h
+++ /dev/null
@@ -1,226 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Shinichiro Hamaji
-//
-// Define utilties for glog internal usage.
-
-#ifndef UTILITIES_H__
-#define UTILITIES_H__
-
-#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
-# define OS_WINDOWS
-#elif defined(__CYGWIN__) || defined(__CYGWIN32__)
-# define OS_CYGWIN
-#elif defined(linux) || defined(__linux) || defined(__linux__)
-# define OS_LINUX
-#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
-# define OS_MACOSX
-#elif defined(__FreeBSD__)
-# define OS_FREEBSD
-#elif defined(__NetBSD__)
-# define OS_NETBSD
-#elif defined(__OpenBSD__)
-# define OS_OPENBSD
-#else
-// TODO(hamaji): Add other platforms.
-#endif
-
-// printf macros for size_t, in the style of inttypes.h
-#ifdef _LP64
-#define __PRIS_PREFIX "z"
-#else
-#define __PRIS_PREFIX
-#endif
-
-// Use these macros after a % in a printf format string
-// to get correct 32/64 bit behavior, like this:
-// size_t size = records.size();
-// printf("%"PRIuS"\n", size);
-
-#define PRIdS __PRIS_PREFIX "d"
-#define PRIxS __PRIS_PREFIX "x"
-#define PRIuS __PRIS_PREFIX "u"
-#define PRIXS __PRIS_PREFIX "X"
-#define PRIoS __PRIS_PREFIX "o"
-
-#include "base/mutex.h"  // This must go first so we get _XOPEN_SOURCE
-
-#include <string>
-
-#if defined(OS_WINDOWS)
-# include "port.h"
-#endif
-
-#include "config.h"
-#include "glog/logging.h"
-
-// There are three different ways we can try to get the stack trace:
-//
-// 1) The libunwind library.  This is still in development, and as a
-//    separate library adds a new dependency, but doesn't need a frame
-//    pointer.  It also doesn't call malloc.
-//
-// 2) Our hand-coded stack-unwinder.  This depends on a certain stack
-//    layout, which is used by gcc (and those systems using a
-//    gcc-compatible ABI) on x86 systems, at least since gcc 2.95.
-//    It uses the frame pointer to do its work.
-//
-// 3) The gdb unwinder -- also the one used by the c++ exception code.
-//    It's obviously well-tested, but has a fatal flaw: it can call
-//    malloc() from the unwinder.  This is a problem because we're
-//    trying to use the unwinder to instrument malloc().
-//
-// Note: if you add a new implementation here, make sure it works
-// correctly when GetStackTrace() is called with max_depth == 0.
-// Some code may do that.
-
-#if defined(HAVE_LIB_UNWIND)
-# define STACKTRACE_H "stacktrace_libunwind-inl.h"
-#elif !defined(NO_FRAME_POINTER)
-# if defined(__i386__) && __GNUC__ >= 2
-#  define STACKTRACE_H "stacktrace_x86-inl.h"
-# elif defined(__x86_64__) && __GNUC__ >= 2 && HAVE_UNWIND_H
-#  define STACKTRACE_H "stacktrace_x86_64-inl.h"
-# elif (defined(__ppc__) || defined(__PPC__)) && __GNUC__ >= 2
-#  define STACKTRACE_H "stacktrace_powerpc-inl.h"
-# endif
-#endif
-
-#if !defined(STACKTRACE_H) && defined(HAVE_EXECINFO_H)
-# define STACKTRACE_H "stacktrace_generic-inl.h"
-#endif
-
-#if defined(STACKTRACE_H)
-# define HAVE_STACKTRACE
-#endif
-
-// defined by gcc
-#if defined(__ELF__) && defined(OS_LINUX)
-# define HAVE_SYMBOLIZE
-#elif defined(OS_MACOSX) && defined(HAVE_DLADDR)
-// Use dladdr to symbolize.
-# define HAVE_SYMBOLIZE
-#endif
-
-#ifndef ARRAYSIZE
-// There is a better way, but this is good enough for our purpose.
-# define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a)))
-#endif
-
-_START_GOOGLE_NAMESPACE_
-
-namespace glog_internal_namespace_ {
-
-#ifdef HAVE___ATTRIBUTE__
-# define ATTRIBUTE_NOINLINE __attribute__ ((noinline))
-# define HAVE_ATTRIBUTE_NOINLINE
-#else
-# define ATTRIBUTE_NOINLINE
-#endif
-
-const char* ProgramInvocationShortName();
-
-bool IsGoogleLoggingInitialized();
-
-bool is_default_thread();
-
-int64 CycleClock_Now();
-
-int64 UsecToCycles(int64 usec);
-
-typedef double WallTime;
-WallTime WallTime_Now();
-
-int32 GetMainThreadPid();
-bool PidHasChanged();
-
-pid_t GetTID();
-
-const std::string& MyUserName();
-
-// Get the part of filepath after the last path separator.
-// (Doesn't modify filepath, contrary to basename() in libgen.h.)
-const char* const_basename(const char* filepath);
-
-// Wrapper of __sync_val_compare_and_swap. If the GCC extension isn't
-// defined, we try the CPU specific logics (we only support x86 and
-// x86_64 for now) first, then use a naive implementation, which has a
-// race condition.
-template<typename T>
-inline T sync_val_compare_and_swap(T* ptr, T oldval, T newval) {
-#if defined(HAVE___SYNC_VAL_COMPARE_AND_SWAP)
-  return __sync_val_compare_and_swap(ptr, oldval, newval);
-#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
-  T ret;
-  __asm__ __volatile__("lock; cmpxchg %1, (%2);"
-                       :"=a"(ret)
-                        // GCC may produces %sil or %dil for
-                        // constraint "r", but some of apple's gas
-                        // dosn't know the 8 bit registers.
-                        // We use "q" to avoid these registers.
-                       :"q"(newval), "q"(ptr), "a"(oldval)
-                       :"memory", "cc");
-  return ret;
-#else
-  T ret = *ptr;
-  if (ret == oldval) {
-    *ptr = newval;
-  }
-  return ret;
-#endif
-}
-
-void DumpStackTraceToString(std::string* stacktrace);
-
-struct CrashReason {
-  CrashReason() : filename(0), line_number(0), message(0), depth(0) {}
-
-  const char* filename;
-  int line_number;
-  const char* message;
-
-  // We'll also store a bit of stack trace context at the time of crash as
-  // it may not be available later on.
-  void* stack[32];
-  int depth;
-};
-
-void SetCrashReason(const CrashReason* r);
-
-void InitGoogleLoggingUtilities(const char* argv0);
-void ShutdownGoogleLoggingUtilities();
-
-}  // namespace glog_internal_namespace_
-
-_END_GOOGLE_NAMESPACE_
-
-using namespace GOOGLE_NAMESPACE::glog_internal_namespace_;
-
-#endif  // UTILITIES_H__

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/utilities_unittest.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/utilities_unittest.cc b/third_party/src/glog/src/utilities_unittest.cc
deleted file mode 100644
index 7b79619..0000000
--- a/third_party/src/glog/src/utilities_unittest.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Shinichiro Hamaji
-
-#include "utilities.h"
-#include "googletest.h"
-#include "glog/logging.h"
-
-using namespace GOOGLE_NAMESPACE;
-
-TEST(utilities, sync_val_compare_and_swap) {
-  bool now_entering = false;
-  EXPECT_FALSE(sync_val_compare_and_swap(&now_entering, false, true));
-  EXPECT_TRUE(sync_val_compare_and_swap(&now_entering, false, true));
-  EXPECT_TRUE(sync_val_compare_and_swap(&now_entering, false, true));
-}
-
-TEST(utilities, InitGoogleLoggingDeathTest) {
-  ASSERT_DEATH(InitGoogleLogging("foobar"), "");
-}
-
-int main(int argc, char **argv) {
-  InitGoogleLogging(argv[0]);
-  InitGoogleTest(&argc, argv);
-
-  CHECK_EQ(RUN_ALL_TESTS(), 0);
-}

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/vlog_is_on.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/vlog_is_on.cc b/third_party/src/glog/src/vlog_is_on.cc
deleted file mode 100644
index 8a79df5..0000000
--- a/third_party/src/glog/src/vlog_is_on.cc
+++ /dev/null
@@ -1,249 +0,0 @@
-// Copyright (c) 1999, 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney and many others
-//
-// Broken out from logging.cc by Soren Lassen
-// logging_unittest.cc covers the functionality herein
-
-#include "utilities.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <cstdio>
-#include <string>
-#include "base/commandlineflags.h"
-#include "glog/logging.h"
-#include "glog/raw_logging.h"
-#include "base/googleinit.h"
-
-// glog doesn't have annotation
-#define ANNOTATE_BENIGN_RACE(address, description)
-
-using std::string;
-
-GLOG_DEFINE_int32(v, 0, "Show all VLOG(m) messages for m <= this."
-" Overridable by --vmodule.");
-
-GLOG_DEFINE_string(vmodule, "", "per-module verbose level."
-" Argument is a comma-separated list of <module name>=<log level>."
-" <module name> is a glob pattern, matched against the filename base"
-" (that is, name ignoring .cc/.h./-inl.h)."
-" <log level> overrides any value given by --v.");
-
-_START_GOOGLE_NAMESPACE_
-
-namespace glog_internal_namespace_ {
-
-// Implementation of fnmatch that does not need 0-termination
-// of arguments and does not allocate any memory,
-// but we only support "*" and "?" wildcards, not the "[...]" patterns.
-// It's not a static function for the unittest.
-GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern,
-                                       size_t patt_len,
-                                       const char* str,
-                                       size_t str_len) {
-  size_t p = 0;
-  size_t s = 0;
-  while (1) {
-    if (p == patt_len  &&  s == str_len) return true;
-    if (p == patt_len) return false;
-    if (s == str_len) return p+1 == patt_len  &&  pattern[p] == '*';
-    if (pattern[p] == str[s]  ||  pattern[p] == '?') {
-      p += 1;
-      s += 1;
-      continue;
-    }
-    if (pattern[p] == '*') {
-      if (p+1 == patt_len) return true;
-      do {
-        if (SafeFNMatch_(pattern+(p+1), patt_len-(p+1), str+s, str_len-s)) {
-          return true;
-        }
-        s += 1;
-      } while (s != str_len);
-      return false;
-    }
-    return false;
-  }
-}
-
-}  // namespace glog_internal_namespace_
-
-using glog_internal_namespace_::SafeFNMatch_;
-
-int32 kLogSiteUninitialized = 1000;
-
-// List of per-module log levels from FLAGS_vmodule.
-// Once created each element is never deleted/modified
-// except for the vlog_level: other threads will read VModuleInfo blobs
-// w/o locks and we'll store pointers to vlog_level at VLOG locations
-// that will never go away.
-// We can't use an STL struct here as we wouldn't know
-// when it's safe to delete/update it: other threads need to use it w/o locks.
-struct VModuleInfo {
-  string module_pattern;
-  mutable int32 vlog_level;  // Conceptually this is an AtomicWord, but it's
-                             // too much work to use AtomicWord type here
-                             // w/o much actual benefit.
-  const VModuleInfo* next;
-};
-
-// This protects the following global variables.
-static Mutex vmodule_lock;
-// Pointer to head of the VModuleInfo list.
-// It's a map from module pattern to logging level for those module(s).
-static VModuleInfo* vmodule_list = 0;
-// Boolean initialization flag.
-static bool inited_vmodule = false;
-
-// L >= vmodule_lock.
-static void VLOG2Initializer() {
-  vmodule_lock.AssertHeld();
-  // Can now parse --vmodule flag and initialize mapping of module-specific
-  // logging levels.
-  inited_vmodule = false;
-  const char* vmodule = FLAGS_vmodule.c_str();
-  const char* sep;
-  VModuleInfo* head = NULL;
-  VModuleInfo* tail = NULL;
-  while ((sep = strchr(vmodule, '=')) != NULL) {
-    string pattern(vmodule, sep - vmodule);
-    int module_level;
-    if (sscanf(sep, "=%d", &module_level) == 1) {
-      VModuleInfo* info = new VModuleInfo;
-      info->module_pattern = pattern;
-      info->vlog_level = module_level;
-      if (head)  tail->next = info;
-      else  head = info;
-      tail = info;
-    }
-    // Skip past this entry
-    vmodule = strchr(sep, ',');
-    if (vmodule == NULL) break;
-    vmodule++;  // Skip past ","
-  }
-  if (head) {  // Put them into the list at the head:
-    tail->next = vmodule_list;
-    vmodule_list = head;
-  }
-  inited_vmodule = true;
-}
-
-// This can be called very early, so we use SpinLock and RAW_VLOG here.
-int SetVLOGLevel(const char* module_pattern, int log_level) {
-  int result = FLAGS_v;
-  int const pattern_len = strlen(module_pattern);
-  bool found = false;
-  MutexLock l(&vmodule_lock);  // protect whole read-modify-write
-  for (const VModuleInfo* info = vmodule_list;
-       info != NULL; info = info->next) {
-    if (info->module_pattern == module_pattern) {
-      if (!found) {
-        result = info->vlog_level;
-        found = true;
-      }
-      info->vlog_level = log_level;
-    } else if (!found  &&
-               SafeFNMatch_(info->module_pattern.c_str(),
-                            info->module_pattern.size(),
-                            module_pattern, pattern_len)) {
-      result = info->vlog_level;
-      found = true;
-    }
-  }
-  if (!found) {
-    VModuleInfo* info = new VModuleInfo;
-    info->module_pattern = module_pattern;
-    info->vlog_level = log_level;
-    info->next = vmodule_list;
-    vmodule_list = info;
-  }
-  RAW_VLOG(1, "Set VLOG level for \"%s\" to %d", module_pattern, log_level);
-  return result;
-}
-
-// NOTE: Individual VLOG statements cache the integer log level pointers.
-// NOTE: This function must not allocate memory or require any locks.
-bool InitVLOG3__(int32** site_flag, int32* site_default,
-                 const char* fname, int32 verbose_level) {
-  MutexLock l(&vmodule_lock);
-  bool read_vmodule_flag = inited_vmodule;
-  if (!read_vmodule_flag) {
-    VLOG2Initializer();
-  }
-
-  // protect the errno global in case someone writes:
-  // VLOG(..) << "The last error was " << strerror(errno)
-  int old_errno = errno;
-
-  // site_default normally points to FLAGS_v
-  int32* site_flag_value = site_default;
-
-  // Get basename for file
-  const char* base = strrchr(fname, '/');
-  base = base ? (base+1) : fname;
-  const char* base_end = strchr(base, '.');
-  size_t base_length = base_end ? size_t(base_end - base) : strlen(base);
-
-  // Trim out trailing "-inl" if any
-  if (base_length >= 4 && (memcmp(base+base_length-4, "-inl", 4) == 0)) {
-    base_length -= 4;
-  }
-
-  // TODO: Trim out _unittest suffix?  Perhaps it is better to have
-  // the extra control and just leave it there.
-
-  // find target in vector of modules, replace site_flag_value with
-  // a module-specific verbose level, if any.
-  for (const VModuleInfo* info = vmodule_list;
-       info != NULL; info = info->next) {
-    if (SafeFNMatch_(info->module_pattern.c_str(), info->module_pattern.size(),
-                     base, base_length)) {
-      site_flag_value = &info->vlog_level;
-        // value at info->vlog_level is now what controls
-        // the VLOG at the caller site forever
-      break;
-    }
-  }
-
-  // Cache the vlog value pointer if --vmodule flag has been parsed.
-  ANNOTATE_BENIGN_RACE(site_flag,
-                       "*site_flag may be written by several threads,"
-                       " but the value will be the same");
-  if (read_vmodule_flag) *site_flag = site_flag_value;
-
-  // restore the errno in case something recoverable went wrong during
-  // the initialization of the VLOG mechanism (see above note "protect the..")
-  errno = old_errno;
-  return *site_flag_value >= verbose_level;
-}
-
-_END_GOOGLE_NAMESPACE_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/base/commandlineflags.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/base/commandlineflags.h b/third_party/src/glog/src/windows/base/commandlineflags.h
deleted file mode 100644
index c8d5089..0000000
--- a/third_party/src/glog/src/windows/base/commandlineflags.h
+++ /dev/null
@@ -1,133 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-// 
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// This file is a compatibility layer that defines Google's version of
-// command line flags that are used for configuration.
-//
-// We put flags into their own namespace.  It is purposefully
-// named in an opaque way that people should have trouble typing
-// directly.  The idea is that DEFINE puts the flag in the weird
-// namespace, and DECLARE imports the flag from there into the
-// current namespace.  The net result is to force people to use
-// DECLARE to get access to a flag, rather than saying
-//   extern bool FLAGS_logtostderr;
-// or some such instead.  We want this so we can put extra
-// functionality (like sanity-checking) in DECLARE if we want,
-// and make sure it is picked up everywhere.
-//
-// We also put the type of the variable in the namespace, so that
-// people can't DECLARE_int32 something that they DEFINE_bool'd
-// elsewhere.
-#ifndef BASE_COMMANDLINEFLAGS_H__
-#define BASE_COMMANDLINEFLAGS_H__
-
-#include "config.h"
-#include <string>
-#include <string.h>               // for memchr
-#include <stdlib.h>               // for getenv
-
-#ifdef HAVE_LIB_GFLAGS
-
-#include <gflags/gflags.h>
-
-#else
-
-#include "glog/logging.h"
-
-#define DECLARE_VARIABLE(type, shorttype, name, tn)                     \
-  namespace fL##shorttype {                                             \
-    extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name;                      \
-  }                                                                     \
-  using fL##shorttype::FLAGS_##name
-#define DEFINE_VARIABLE(type, shorttype, name, value, meaning, tn)      \
-  namespace fL##shorttype {                                             \
-    GOOGLE_GLOG_DLL_DECL type FLAGS_##name(value);                      \
-    char FLAGS_no##name;                                                \
-  }                                                                     \
-  using fL##shorttype::FLAGS_##name
-
-// bool specialization
-#define DECLARE_bool(name) \
-  DECLARE_VARIABLE(bool, B, name, bool)
-#define DEFINE_bool(name, value, meaning) \
-  DEFINE_VARIABLE(bool, B, name, value, meaning, bool)
-
-// int32 specialization
-#define DECLARE_int32(name) \
-  DECLARE_VARIABLE(GOOGLE_NAMESPACE::int32, I, name, int32)
-#define DEFINE_int32(name, value, meaning) \
-  DEFINE_VARIABLE(GOOGLE_NAMESPACE::int32, I, name, value, meaning, int32)
-
-// Special case for string, because we have to specify the namespace
-// std::string, which doesn't play nicely with our FLAG__namespace hackery.
-#define DECLARE_string(name)                                            \
-  namespace fLS {                                                       \
-    extern GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name;              \
-  }                                                                     \
-  using fLS::FLAGS_##name
-#define DEFINE_string(name, value, meaning)                             \
-  namespace fLS {                                                       \
-    std::string FLAGS_##name##_buf(value);                              \
-    GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name = FLAGS_##name##_buf; \
-    char FLAGS_no##name;                                                \
-  }                                                                     \
-  using fLS::FLAGS_##name
-
-#endif  // HAVE_LIB_GFLAGS
-
-// Define GLOG_DEFINE_* using DEFINE_* . By using these macros, we
-// have GLOG_* environ variables even if we have gflags installed.
-//
-// If both an environment variable and a flag are specified, the value
-// specified by a flag wins. E.g., if GLOG_v=0 and --v=1, the
-// verbosity will be 1, not 0.
-
-#define GLOG_DEFINE_bool(name, value, meaning) \
-  DEFINE_bool(name, EnvToBool("GLOG_" #name, value), meaning)
-
-#define GLOG_DEFINE_int32(name, value, meaning) \
-  DEFINE_int32(name, EnvToInt("GLOG_" #name, value), meaning)
-
-#define GLOG_DEFINE_string(name, value, meaning) \
-  DEFINE_string(name, EnvToString("GLOG_" #name, value), meaning)
-
-// These macros (could be functions, but I don't want to bother with a .cc
-// file), make it easier to initialize flags from the environment.
-
-#define EnvToString(envname, dflt)   \
-  (!getenv(envname) ? (dflt) : getenv(envname))
-
-#define EnvToBool(envname, dflt)   \
-  (!getenv(envname) ? (dflt) : memchr("tTyY1\0", getenv(envname)[0], 6) != NULL)
-
-#define EnvToInt(envname, dflt)  \
-  (!getenv(envname) ? (dflt) : strtol(getenv(envname), NULL, 10))
-
-#endif  // BASE_COMMANDLINEFLAGS_H__

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/base/googleinit.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/base/googleinit.h b/third_party/src/glog/src/windows/base/googleinit.h
deleted file mode 100644
index 5a8b515..0000000
--- a/third_party/src/glog/src/windows/base/googleinit.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-// 
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Jacob Hoffman-Andrews
-
-#ifndef _GOOGLEINIT_H
-#define _GOOGLEINIT_H
-
-class GoogleInitializer {
- public:
-  typedef void (*void_function)(void);
-  GoogleInitializer(const char*, void_function f) {
-    f();
-  }
-};
-
-#define REGISTER_MODULE_INITIALIZER(name, body)                 \
-  namespace {                                                   \
-    static void google_init_module_##name () { body; }          \
-    GoogleInitializer google_initializer_module_##name(#name,   \
-            google_init_module_##name);                         \
-  }
-
-#endif /* _GOOGLEINIT_H */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/base/mutex.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/base/mutex.h b/third_party/src/glog/src/windows/base/mutex.h
deleted file mode 100644
index 37527d5..0000000
--- a/third_party/src/glog/src/windows/base/mutex.h
+++ /dev/null
@@ -1,331 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-// 
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// 
-// ---
-// Author: Craig Silverstein.
-//
-// A simple mutex wrapper, supporting locks and read-write locks.
-// You should assume the locks are *not* re-entrant.
-//
-// To use: you should define the following macros in your configure.ac:
-//   ACX_PTHREAD
-//   AC_RWLOCK
-// The latter is defined in ../autoconf.
-//
-// This class is meant to be internal-only and should be wrapped by an
-// internal namespace.  Before you use this module, please give the
-// name of your internal namespace for this module.  Or, if you want
-// to expose it, you'll want to move it to the Google namespace.  We
-// cannot put this class in global namespace because there can be some
-// problems when we have multiple versions of Mutex in each shared object.
-//
-// NOTE: by default, we have #ifdef'ed out the TryLock() method.
-//       This is for two reasons:
-// 1) TryLock() under Windows is a bit annoying (it requires a
-//    #define to be defined very early).
-// 2) TryLock() is broken for NO_THREADS mode, at least in NDEBUG
-//    mode.
-// If you need TryLock(), and either these two caveats are not a
-// problem for you, or you're willing to work around them, then
-// feel free to #define GMUTEX_TRYLOCK, or to remove the #ifdefs
-// in the code below.
-//
-// CYGWIN NOTE: Cygwin support for rwlock seems to be buggy:
-//    http://www.cygwin.com/ml/cygwin/2008-12/msg00017.html
-// Because of that, we might as well use windows locks for
-// cygwin.  They seem to be more reliable than the cygwin pthreads layer.
-//
-// TRICKY IMPLEMENTATION NOTE:
-// This class is designed to be safe to use during
-// dynamic-initialization -- that is, by global constructors that are
-// run before main() starts.  The issue in this case is that
-// dynamic-initialization happens in an unpredictable order, and it
-// could be that someone else's dynamic initializer could call a
-// function that tries to acquire this mutex -- but that all happens
-// before this mutex's constructor has run.  (This can happen even if
-// the mutex and the function that uses the mutex are in the same .cc
-// file.)  Basically, because Mutex does non-trivial work in its
-// constructor, it's not, in the naive implementation, safe to use
-// before dynamic initialization has run on it.
-//
-// The solution used here is to pair the actual mutex primitive with a
-// bool that is set to true when the mutex is dynamically initialized.
-// (Before that it's false.)  Then we modify all mutex routines to
-// look at the bool, and not try to lock/unlock until the bool makes
-// it to true (which happens after the Mutex constructor has run.)
-//
-// This works because before main() starts -- particularly, during
-// dynamic initialization -- there are no threads, so a) it's ok that
-// the mutex operations are a no-op, since we don't need locking then
-// anyway; and b) we can be quite confident our bool won't change
-// state between a call to Lock() and a call to Unlock() (that would
-// require a global constructor in one translation unit to call Lock()
-// and another global constructor in another translation unit to call
-// Unlock() later, which is pretty perverse).
-//
-// That said, it's tricky, and can conceivably fail; it's safest to
-// avoid trying to acquire a mutex in a global constructor, if you
-// can.  One way it can fail is that a really smart compiler might
-// initialize the bool to true at static-initialization time (too
-// early) rather than at dynamic-initialization time.  To discourage
-// that, we set is_safe_ to true in code (not the constructor
-// colon-initializer) and set it to true via a function that always
-// evaluates to true, but that the compiler can't know always
-// evaluates to true.  This should be good enough.
-
-#ifndef GOOGLE_MUTEX_H_
-#define GOOGLE_MUTEX_H_
-
-#include "config.h"           // to figure out pthreads support
-
-#if defined(NO_THREADS)
-  typedef int MutexType;      // to keep a lock-count
-#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
-# ifndef WIN32_LEAN_AND_MEAN
-#  define WIN32_LEAN_AND_MEAN  // We only need minimal includes
-# endif
-# ifdef GMUTEX_TRYLOCK
-  // We need Windows NT or later for TryEnterCriticalSection().  If you
-  // don't need that functionality, you can remove these _WIN32_WINNT
-  // lines, and change TryLock() to assert(0) or something.
-#   ifndef _WIN32_WINNT
-#     define _WIN32_WINNT 0x0400
-#   endif
-# endif
-// To avoid macro definition of ERROR.
-# ifndef NOGDI
-#  define NOGDI
-# endif
-// To avoid macro definition of min/max.
-# ifndef NOMINMAX
-#  define NOMINMAX
-# endif
-# include <windows.h>
-  typedef CRITICAL_SECTION MutexType;
-#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
-  // Needed for pthread_rwlock_*.  If it causes problems, you could take it
-  // out, but then you'd have to unset HAVE_RWLOCK (at least on linux -- it
-  // *does* cause problems for FreeBSD, or MacOSX, but isn't needed
-  // for locking there.)
-# ifdef __linux__
-#   define _XOPEN_SOURCE 500  // may be needed to get the rwlock calls
-# endif
-# include <pthread.h>
-  typedef pthread_rwlock_t MutexType;
-#elif defined(HAVE_PTHREAD)
-# include <pthread.h>
-  typedef pthread_mutex_t MutexType;
-#else
-# error Need to implement mutex.h for your architecture, or #define NO_THREADS
-#endif
-
-// We need to include these header files after defining _XOPEN_SOURCE
-// as they may define the _XOPEN_SOURCE macro.
-#include <assert.h>
-#include <stdlib.h>      // for abort()
-
-#define MUTEX_NAMESPACE glog_internal_namespace_
-
-namespace MUTEX_NAMESPACE {
-
-class Mutex {
- public:
-  // Create a Mutex that is not held by anybody.  This constructor is
-  // typically used for Mutexes allocated on the heap or the stack.
-  // See below for a recommendation for constructing global Mutex
-  // objects.
-  inline Mutex();
-
-  // Destructor
-  inline ~Mutex();
-
-  inline void Lock();    // Block if needed until free then acquire exclusively
-  inline void Unlock();  // Release a lock acquired via Lock()
-#ifdef GMUTEX_TRYLOCK
-  inline bool TryLock(); // If free, Lock() and return true, else return false
-#endif
-  // Note that on systems that don't support read-write locks, these may
-  // be implemented as synonyms to Lock() and Unlock().  So you can use
-  // these for efficiency, but don't use them anyplace where being able
-  // to do shared reads is necessary to avoid deadlock.
-  inline void ReaderLock();   // Block until free or shared then acquire a share
-  inline void ReaderUnlock(); // Release a read share of this Mutex
-  inline void WriterLock() { Lock(); }     // Acquire an exclusive lock
-  inline void WriterUnlock() { Unlock(); } // Release a lock from WriterLock()
-
-  // TODO(hamaji): Do nothing, implement correctly.
-  inline void AssertHeld() {}
-
- private:
-  MutexType mutex_;
-  // We want to make sure that the compiler sets is_safe_ to true only
-  // when we tell it to, and never makes assumptions is_safe_ is
-  // always true.  volatile is the most reliable way to do that.
-  volatile bool is_safe_;
-
-  inline void SetIsSafe() { is_safe_ = true; }
-
-  // Catch the error of writing Mutex when intending MutexLock.
-  Mutex(Mutex* /*ignored*/) {}
-  // Disallow "evil" constructors
-  Mutex(const Mutex&);
-  void operator=(const Mutex&);
-};
-
-// Now the implementation of Mutex for various systems
-#if defined(NO_THREADS)
-
-// When we don't have threads, we can be either reading or writing,
-// but not both.  We can have lots of readers at once (in no-threads
-// mode, that's most likely to happen in recursive function calls),
-// but only one writer.  We represent this by having mutex_ be -1 when
-// writing and a number > 0 when reading (and 0 when no lock is held).
-//
-// In debug mode, we assert these invariants, while in non-debug mode
-// we do nothing, for efficiency.  That's why everything is in an
-// assert.
-
-Mutex::Mutex() : mutex_(0) { }
-Mutex::~Mutex()            { assert(mutex_ == 0); }
-void Mutex::Lock()         { assert(--mutex_ == -1); }
-void Mutex::Unlock()       { assert(mutex_++ == -1); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { if (mutex_) return false; Lock(); return true; }
-#endif
-void Mutex::ReaderLock()   { assert(++mutex_ > 0); }
-void Mutex::ReaderUnlock() { assert(mutex_-- > 0); }
-
-#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
-
-Mutex::Mutex()             { InitializeCriticalSection(&mutex_); SetIsSafe(); }
-Mutex::~Mutex()            { DeleteCriticalSection(&mutex_); }
-void Mutex::Lock()         { if (is_safe_) EnterCriticalSection(&mutex_); }
-void Mutex::Unlock()       { if (is_safe_) LeaveCriticalSection(&mutex_); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { return is_safe_ ?
-                                 TryEnterCriticalSection(&mutex_) != 0 : true; }
-#endif
-void Mutex::ReaderLock()   { Lock(); }      // we don't have read-write locks
-void Mutex::ReaderUnlock() { Unlock(); }
-
-#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
-
-#define SAFE_PTHREAD(fncall)  do {   /* run fncall if is_safe_ is true */  \
-  if (is_safe_ && fncall(&mutex_) != 0) abort();                           \
-} while (0)
-
-Mutex::Mutex() {
-  SetIsSafe();
-  if (is_safe_ && pthread_rwlock_init(&mutex_, NULL) != 0) abort();
-}
-Mutex::~Mutex()            { SAFE_PTHREAD(pthread_rwlock_destroy); }
-void Mutex::Lock()         { SAFE_PTHREAD(pthread_rwlock_wrlock); }
-void Mutex::Unlock()       { SAFE_PTHREAD(pthread_rwlock_unlock); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { return is_safe_ ?
-                                    pthread_rwlock_trywrlock(&mutex_) == 0 :
-                                    true; }
-#endif
-void Mutex::ReaderLock()   { SAFE_PTHREAD(pthread_rwlock_rdlock); }
-void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock); }
-#undef SAFE_PTHREAD
-
-#elif defined(HAVE_PTHREAD)
-
-#define SAFE_PTHREAD(fncall)  do {   /* run fncall if is_safe_ is true */  \
-  if (is_safe_ && fncall(&mutex_) != 0) abort();                           \
-} while (0)
-
-Mutex::Mutex()             {
-  SetIsSafe();
-  if (is_safe_ && pthread_mutex_init(&mutex_, NULL) != 0) abort();
-}
-Mutex::~Mutex()            { SAFE_PTHREAD(pthread_mutex_destroy); }
-void Mutex::Lock()         { SAFE_PTHREAD(pthread_mutex_lock); }
-void Mutex::Unlock()       { SAFE_PTHREAD(pthread_mutex_unlock); }
-#ifdef GMUTEX_TRYLOCK
-bool Mutex::TryLock()      { return is_safe_ ?
-                                 pthread_mutex_trylock(&mutex_) == 0 : true; }
-#endif
-void Mutex::ReaderLock()   { Lock(); }
-void Mutex::ReaderUnlock() { Unlock(); }
-#undef SAFE_PTHREAD
-
-#endif
-
-// --------------------------------------------------------------------------
-// Some helper classes
-
-// MutexLock(mu) acquires mu when constructed and releases it when destroyed.
-class MutexLock {
- public:
-  explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); }
-  ~MutexLock() { mu_->Unlock(); }
- private:
-  Mutex * const mu_;
-  // Disallow "evil" constructors
-  MutexLock(const MutexLock&);
-  void operator=(const MutexLock&);
-};
-
-// ReaderMutexLock and WriterMutexLock do the same, for rwlocks
-class ReaderMutexLock {
- public:
-  explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); }
-  ~ReaderMutexLock() { mu_->ReaderUnlock(); }
- private:
-  Mutex * const mu_;
-  // Disallow "evil" constructors
-  ReaderMutexLock(const ReaderMutexLock&);
-  void operator=(const ReaderMutexLock&);
-};
-
-class WriterMutexLock {
- public:
-  explicit WriterMutexLock(Mutex *mu) : mu_(mu) { mu_->WriterLock(); }
-  ~WriterMutexLock() { mu_->WriterUnlock(); }
- private:
-  Mutex * const mu_;
-  // Disallow "evil" constructors
-  WriterMutexLock(const WriterMutexLock&);
-  void operator=(const WriterMutexLock&);
-};
-
-// Catch bug where variable name is omitted, e.g. MutexLock (&mu);
-#define MutexLock(x) COMPILE_ASSERT(0, mutex_lock_decl_missing_var_name)
-#define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name)
-#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name)
-
-}  // namespace MUTEX_NAMESPACE
-
-using namespace MUTEX_NAMESPACE;
-
-#undef MUTEX_NAMESPACE
-
-#endif  /* #define GOOGLE_MUTEX_H__ */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/config_cmake.h.in
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/config_cmake.h.in b/third_party/src/glog/src/windows/config_cmake.h.in
deleted file mode 100644
index e5468d8..0000000
--- a/third_party/src/glog/src/windows/config_cmake.h.in
+++ /dev/null
@@ -1,142 +0,0 @@
-/* src/config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Namespace for Google classes */
-#define GOOGLE_NAMESPACE google
-
-/* Define if you have the `dladdr' function */
-#undef HAVE_DLADDR
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <execinfo.h> header file. */
-#undef HAVE_EXECINFO_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <libunwind.h> header file. */
-#undef HAVE_LIBUNWIND_H
-
-/* define if you have google gflags library */
-#undef HAVE_LIB_GFLAGS
-
-/* define if you have libunwind */
-#undef HAVE_LIB_UNWIND
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* define if the compiler implements namespaces */
-#undef HAVE_NAMESPACES
-
-/* Define if you have POSIX threads libraries and header files. */
-#undef HAVE_PTHREAD
-
-/* define if the compiler implements pthread_rwlock_* */
-#undef HAVE_RWLOCK
-
-/* Define if you have the `sigaltstack' function */
-#undef HAVE_SIGALTSTACK
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <syscall.h> header file. */
-#undef HAVE_SYSCALL_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/syscall.h> header file. */
-#undef HAVE_SYS_SYSCALL_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <ucontext.h> header file. */
-#undef HAVE_UCONTEXT_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* define if the compiler supports using expression for operator */
-#undef HAVE_USING_OPERATOR
-
-/* define if your compiler has __attribute__ */
-#undef HAVE___ATTRIBUTE__
-
-/* define if your compiler has __builtin_expect */
-#undef HAVE___BUILTIN_EXPECT
-
-/* define if your compiler has __sync_val_compare_and_swap */
-#undef HAVE___SYNC_VAL_COMPARE_AND_SWAP
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* How to access the PC from a struct ucontext */
-#undef PC_FROM_UCONTEXT
-
-/* Define to necessary symbol if this constant uses a non-standard name on
-   your system. */
-#undef PTHREAD_CREATE_JOINABLE
-
-/* The size of `void *', as computed by sizeof. */
-#undef SIZEOF_VOID_P
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* the namespace where STL code like vector<> is defined */
-#undef STL_NAMESPACE
-
-/* Version number of package */
-#undef VERSION
-
-/* Stops putting the code inside the Google namespace */
-#define _END_GOOGLE_NAMESPACE_ }
-
-/* Puts following code inside the Google namespace */
-#define _START_GOOGLE_NAMESPACE_ namespace google {
-
-/* Always the empty-string on non-windows systems. On windows, should be
-   "__declspec(dllexport)". This way, when we compile the dll, we export our
-   functions/classes. It's safe to define this here because config.h is only
-   used internally, to compile the DLL, and every DLL source file #includes
-   "config.h" before anything else. */
-#ifndef GOOGLE_GLOG_DLL_DECL
-# define GOOGLE_GLOG_IS_A_DLL  1   /* not set if you're statically linking */
-# define GOOGLE_GLOG_DLL_DECL  __declspec(dllexport)
-# define GOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS  __declspec(dllimport)
-#endif
-
-/* Whether snprintf exists in stdio.h */
-#cmakedefine HAVE_SNPRINTF 1
-
-/* Whether pid_t exists in process.h */
-#cmakedefine HAVE_PID_T 1

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/glog/log_severity.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/glog/log_severity.h b/third_party/src/glog/src/windows/glog/log_severity.h
deleted file mode 100644
index 22a4191..0000000
--- a/third_party/src/glog/src/windows/glog/log_severity.h
+++ /dev/null
@@ -1,96 +0,0 @@
-// This file is automatically generated from src/glog/log_severity.h
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef BASE_LOG_SEVERITY_H__
-#define BASE_LOG_SEVERITY_H__
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-// Variables of type LogSeverity are widely taken to lie in the range
-// [0, NUM_SEVERITIES-1].  Be careful to preserve this assumption if
-// you ever need to change their values or add a new severity.
-typedef int LogSeverity;
-
-const int GLOG_INFO = 0, GLOG_WARNING = 1, GLOG_ERROR = 2, GLOG_FATAL = 3,
-  NUM_SEVERITIES = 4;
-#ifndef GLOG_NO_ABBREVIATED_SEVERITIES
-# ifdef ERROR
-#  error ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail.
-# endif
-const int INFO = GLOG_INFO, WARNING = GLOG_WARNING,
-  ERROR = GLOG_ERROR, FATAL = GLOG_FATAL;
-#endif
-
-// DFATAL is FATAL in debug mode, ERROR in normal mode
-#ifdef NDEBUG
-#define DFATAL_LEVEL ERROR
-#else
-#define DFATAL_LEVEL FATAL
-#endif
-
-extern GOOGLE_GLOG_DLL_DECL const char* const LogSeverityNames[NUM_SEVERITIES];
-
-// NDEBUG usage helpers related to (RAW_)DCHECK:
-//
-// DEBUG_MODE is for small !NDEBUG uses like
-//   if (DEBUG_MODE) foo.CheckThatFoo();
-// instead of substantially more verbose
-//   #ifndef NDEBUG
-//     foo.CheckThatFoo();
-//   #endif
-//
-// IF_DEBUG_MODE is for small !NDEBUG uses like
-//   IF_DEBUG_MODE( string error; )
-//   DCHECK(Foo(&error)) << error;
-// instead of substantially more verbose
-//   #ifndef NDEBUG
-//     string error;
-//     DCHECK(Foo(&error)) << error;
-//   #endif
-//
-#ifdef NDEBUG
-enum { DEBUG_MODE = 0 };
-#define IF_DEBUG_MODE(x)
-#else
-enum { DEBUG_MODE = 1 };
-#define IF_DEBUG_MODE(x) x
-#endif
-
-#endif  // BASE_LOG_SEVERITY_H__


[43/46] incubator-quickstep git commit: Add a flag to allow disabling of Comparison inline expansion to enable acceleration of Quickstep build.

Posted by ji...@apache.org.
Add a flag to allow disabling of Comparison inline expansion to enable acceleration of Quickstep build.

(for development productivity as well as solving the Travis CI timeout problem)


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/539e1ebe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/539e1ebe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/539e1ebe

Branch: refs/heads/fix-iwyu
Commit: 539e1ebe09b5d1a2d86069ed1fdc6e9fb38c5ce7
Parents: 4a945a6
Author: Jianqiao Zhu <ji...@cs.wisc.edu>
Authored: Fri Feb 2 17:27:59 2018 -0600
Committer: Jianqiao Zhu <ji...@cs.wisc.edu>
Committed: Fri Feb 2 17:31:24 2018 -0600

----------------------------------------------------------------------
 .travis.yml                                     |  3 ++-
 CMakeLists.txt                                  | 14 ++++++++++++++
 .../comparisons/AsciiStringComparators-inl.hpp  |  2 ++
 .../comparisons/AsciiStringComparators.hpp      |  4 ++++
 types/operations/comparisons/Comparison.cpp     | 20 --------------------
 .../comparisons/LiteralComparators-inl.hpp      |  2 ++
 .../comparisons/LiteralComparators.hpp          |  4 ++++
 7 files changed, 28 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/539e1ebe/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 4e7833f..6517ae8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -76,7 +76,8 @@ before_script:
            -D CMAKE_CXX_COMPILER=$CXX
            -D CMAKE_LINKER=$CLINKER
            -D USE_TCMALLOC=0
-           -D VECTOR_COPY_ELISION_LEVEL=$VECTOR_COPY_ELISION_LEVEL ..)
+           -D VECTOR_COPY_ELISION_LEVEL=$VECTOR_COPY_ELISION_LEVEL
+           -D ENABLE_COMPARISON_INLINE_EXPANSION=OFF ..)
 
 script:
   - ./lint_everything.py

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/539e1ebe/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 88835ac..c777a6a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -145,6 +145,20 @@ if (ENABLE_VECTOR_PREDICATE_SHORT_CIRCUIT)
   )
 endif()
 
+set(COMPARISON_INLINE_EXPANSION_MSG_LIST
+    "This option controls whether to enable inlined template expansion "
+    "of comparison predicates. WARNING: This option should only be "
+    "turned off for development use. Turning off this option will greatly "
+    "reduce Quickstep compile time but incur drastic performance degradation.")
+string(REPLACE ";" "" COMPARISON_INLINE_EXPANSION_MSG ${COMPARISON_INLINE_EXPANSION_MSG_LIST})
+option(ENABLE_COMPARISON_INLINE_EXPANSION ${COMPARISON_INLINE_EXPANSION_MSG} ON)
+if (ENABLE_COMPARISON_INLINE_EXPANSION)
+  set_property(
+    DIRECTORY
+    APPEND PROPERTY COMPILE_DEFINITIONS QUICKSTEP_ENABLE_COMPARISON_INLINE_EXPANSION
+  )
+endif()
+
 option(ENABLE_NETWORK_CLI "Allows use of the network cli" OFF)
 option(ENABLE_DISTRIBUTED "Use the distributed version of Quickstep" OFF)
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/539e1ebe/types/operations/comparisons/AsciiStringComparators-inl.hpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/AsciiStringComparators-inl.hpp b/types/operations/comparisons/AsciiStringComparators-inl.hpp
index fd0d17d..8b2c1bf 100644
--- a/types/operations/comparisons/AsciiStringComparators-inl.hpp
+++ b/types/operations/comparisons/AsciiStringComparators-inl.hpp
@@ -46,6 +46,7 @@
 
 namespace quickstep {
 
+#ifdef QUICKSTEP_ENABLE_COMPARISON_INLINE_EXPANSION
 template <template <typename T> class ComparisonFunctor,
           bool left_nullable, bool left_null_terminated, bool left_longer,
           bool right_nullable, bool right_null_terminated, bool right_longer>
@@ -586,6 +587,7 @@ TypedValue AsciiStringUncheckedComparator<ComparisonFunctor,
 
   return new_value;
 }
+#endif  // QUICKSTEP_ENABLE_COMPARISON_INLINE_EXPANSION
 
 }  // namespace quickstep
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/539e1ebe/types/operations/comparisons/AsciiStringComparators.hpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/AsciiStringComparators.hpp b/types/operations/comparisons/AsciiStringComparators.hpp
index 936fd1f..2aec8c4 100644
--- a/types/operations/comparisons/AsciiStringComparators.hpp
+++ b/types/operations/comparisons/AsciiStringComparators.hpp
@@ -122,6 +122,7 @@ class AsciiStringUncheckedComparator : public UncheckedComparator {
                                0);
   }
 
+#ifdef QUICKSTEP_ENABLE_COMPARISON_INLINE_EXPANSION
   TupleIdSequence* compareColumnVectors(
       const ColumnVector &left,
       const ColumnVector &right,
@@ -202,6 +203,7 @@ class AsciiStringUncheckedComparator : public UncheckedComparator {
   TypedValue accumulateColumnVector(
       const TypedValue &current,
       const ColumnVector &column_vector) const override;
+#endif  // QUICKSTEP_ENABLE_COMPARISON_INLINE_EXPANSION
 
  private:
   /**
@@ -248,6 +250,7 @@ class AsciiStringUncheckedComparator : public UncheckedComparator {
     }
   }
 
+#ifdef QUICKSTEP_ENABLE_COMPARISON_INLINE_EXPANSION
   template <bool column_vector_on_left>
   TupleIdSequence* compareColumnVectorAndStaticValueHelper(
       const ColumnVector &column_vector,
@@ -271,6 +274,7 @@ class AsciiStringUncheckedComparator : public UncheckedComparator {
       const TupleIdSequence *filter,
       const TupleIdSequence *existence_bitmap) const;
 #endif  // QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
+#endif  // QUICKSTEP_ENABLE_COMPARISON_INLINE_EXPANSION
 
   template <bool arguments_in_order>
   inline bool compareDataPtrsHelper(const void *left, const void *right) const {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/539e1ebe/types/operations/comparisons/Comparison.cpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/Comparison.cpp b/types/operations/comparisons/Comparison.cpp
index ef04ccf..023c76a 100644
--- a/types/operations/comparisons/Comparison.cpp
+++ b/types/operations/comparisons/Comparison.cpp
@@ -33,8 +33,6 @@ TupleIdSequence* UncheckedComparator::compareColumnVectors(
     const ColumnVector &right,
     const TupleIdSequence *filter,
     const TupleIdSequence *existence_bitmap) const {
-  DEV_WARNING("Using fallback non-specialized implementation of "
-              "UncheckedComparator::compareColumnVectors()");
   return compareColumnVectorsDefaultImpl<true, true>(
       left, right, filter, existence_bitmap);
 }
@@ -44,8 +42,6 @@ TupleIdSequence* UncheckedComparator::compareColumnVectorAndStaticValue(
     const TypedValue &right,
     const TupleIdSequence *filter,
     const TupleIdSequence *existence_bitmap) const {
-  DEV_WARNING("Using fallback non-specialized implementation of "
-              "UncheckedComparator::compareColumnVectorAndStaticValue()");
   return compareColumnVectorAndStaticValueDefaultImpl<true, true>(
       left, right, filter, existence_bitmap);
 }
@@ -55,8 +51,6 @@ TupleIdSequence* UncheckedComparator::compareStaticValueAndColumnVector(
     const ColumnVector &right,
     const TupleIdSequence *filter,
     const TupleIdSequence *existence_bitmap) const {
-  DEV_WARNING("Using fallback non-specialized implementation of "
-              "UncheckedComparator::compareStaticValueAndColumnVector()");
   return compareStaticValueAndColumnVectorDefaultImpl<true, true>(
       left, right, filter, existence_bitmap);
 }
@@ -67,8 +61,6 @@ TupleIdSequence* UncheckedComparator::compareSingleValueAccessor(
     const attribute_id left_id,
     const attribute_id right_id,
     const TupleIdSequence *filter) const {
-  DEV_WARNING("Using fallback non-specialized implementation of "
-              "UncheckedComparator::compareSingleValueAccessor()");
   return compareSingleValueAccessorDefaultImpl<true, true>(
       accessor, left_id, right_id, filter);
 }
@@ -78,8 +70,6 @@ TupleIdSequence* UncheckedComparator::compareValueAccessorAndStaticValue(
     const attribute_id left_id,
     const TypedValue &right,
     const TupleIdSequence *filter) const {
-  DEV_WARNING("Using fallback non-specialized implementation of "
-              "UncheckedComparator::compareValueAccessorAndStaticValue()");
   return compareValueAccessorAndStaticValueDefaultImpl<true, true>(
       left_accessor, left_id, right, filter);
 }
@@ -89,8 +79,6 @@ TupleIdSequence* UncheckedComparator::compareStaticValueAndValueAccessor(
     ValueAccessor *right_accessor,
     const attribute_id right_id,
     const TupleIdSequence *filter) const {
-  DEV_WARNING("Using fallback non-specialized implementation of "
-              "UncheckedComparator::compareStaticValueAndValueAccessor()");
   return compareStaticValueAndValueAccessorDefaultImpl<true, true>(
       left, right_accessor, right_id, filter);
 }
@@ -101,8 +89,6 @@ TupleIdSequence* UncheckedComparator::compareColumnVectorAndValueAccessor(
     const attribute_id right_id,
     const TupleIdSequence *filter,
     const TupleIdSequence *existence_bitmap) const {
-  DEV_WARNING("Using fallback non-specialized implementation of "
-              "UncheckedComparator::compareColumnVectorAndValueAccessor()");
   return compareColumnVectorAndValueAccessorDefaultImpl<true, true>(
       left, right_accessor, right_id, filter, existence_bitmap);
 }
@@ -113,8 +99,6 @@ TupleIdSequence* UncheckedComparator::compareValueAccessorAndColumnVector(
     const ColumnVector &right,
     const TupleIdSequence *filter,
     const TupleIdSequence *existence_bitmap) const {
-  DEV_WARNING("Using fallback non-specialized implementation of "
-              "UncheckedComparator::compareValueAccessorAndColumnVector()");
   return compareValueAccessorAndColumnVectorDefaultImpl<true, true>(
       left_accessor, left_id, right, filter, existence_bitmap);
 }
@@ -123,8 +107,6 @@ TypedValue UncheckedComparator::accumulateValueAccessor(
     const TypedValue &current,
     ValueAccessor *accessor,
     const attribute_id value_accessor_id) const {
-  DEV_WARNING("Using fallback non-specialized implementation of "
-              "UncheckedComparator::accumulateValueAccessor()");
   return accumulateValueAccessorDefaultImpl<true>(
       current, accessor, value_accessor_id);
 }
@@ -133,8 +115,6 @@ TypedValue UncheckedComparator::accumulateValueAccessor(
 TypedValue UncheckedComparator::accumulateColumnVector(
     const TypedValue &current,
     const ColumnVector &column_vector) const {
-  DEV_WARNING("Using fallback non-specialized implementation of "
-              "UncheckedComparator::accumulateColumnVector()");
   return accumulateColumnVectorDefaultImpl<true>(current, column_vector);
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/539e1ebe/types/operations/comparisons/LiteralComparators-inl.hpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/LiteralComparators-inl.hpp b/types/operations/comparisons/LiteralComparators-inl.hpp
index 5fc9bfe..8612885 100644
--- a/types/operations/comparisons/LiteralComparators-inl.hpp
+++ b/types/operations/comparisons/LiteralComparators-inl.hpp
@@ -46,6 +46,7 @@
 
 namespace quickstep {
 
+#ifdef QUICKSTEP_ENABLE_COMPARISON_INLINE_EXPANSION
 template <template <typename LeftArgument, typename RightArgument> class ComparisonFunctor,
           typename LeftCppType, bool left_nullable,
           typename RightCppType, bool right_nullable>
@@ -662,6 +663,7 @@ TypedValue LiteralUncheckedComparator<ComparisonFunctor,
     return TypedValue(current.getTypeID());
   }
 }
+#endif  // QUICKSTEP_ENABLE_COMPARISON_INLINE_EXPANSION
 
 }  // namespace quickstep
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/539e1ebe/types/operations/comparisons/LiteralComparators.hpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/LiteralComparators.hpp b/types/operations/comparisons/LiteralComparators.hpp
index c7b9b34..bc4b1dd 100644
--- a/types/operations/comparisons/LiteralComparators.hpp
+++ b/types/operations/comparisons/LiteralComparators.hpp
@@ -143,6 +143,7 @@ class LiteralUncheckedComparator : public UncheckedComparator {
                                right.getLiteral<RightCppType>());
   }
 
+#ifdef QUICKSTEP_ENABLE_COMPARISON_INLINE_EXPANSION
   TupleIdSequence* compareColumnVectors(
       const ColumnVector &left,
       const ColumnVector &right,
@@ -223,8 +224,10 @@ class LiteralUncheckedComparator : public UncheckedComparator {
   TypedValue accumulateColumnVector(
       const TypedValue &current,
       const ColumnVector &column_vector) const override;
+#endif  // QUICKSTEP_ENABLE_COMPARISON_INLINE_EXPANSION
 
  private:
+#ifdef QUICKSTEP_ENABLE_COMPARISON_INLINE_EXPANSION
   template <bool column_vector_on_left>
   TupleIdSequence* compareColumnVectorAndStaticValueHelper(
       const ColumnVector &column_vector,
@@ -248,6 +251,7 @@ class LiteralUncheckedComparator : public UncheckedComparator {
       const TupleIdSequence *filter,
       const TupleIdSequence *existence_bitmap) const;
 #endif  // QUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION
+#endif  // QUICKSTEP_ENABLE_COMPARISON_INLINE_EXPANSION
 
   template <bool arguments_in_order>
   inline bool compareDataPtrsHelper(const void *left, const void *right) const {


[15/46] incubator-quickstep git commit: Removed unused argument always_mark_full.

Posted by ji...@apache.org.
Removed unused argument always_mark_full.


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

Branch: refs/heads/fix-iwyu
Commit: f820c45ee56a9e74671fb1c22c5e6b7e13471b5d
Parents: ffb8e05
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Thu Oct 5 17:18:05 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Tue Oct 10 14:14:29 2017 -0500

----------------------------------------------------------------------
 storage/InsertDestination.cpp          | 73 ++++++++++-------------------
 storage/InsertDestination.hpp          | 21 ++++-----
 storage/InsertDestinationInterface.hpp | 12 ++---
 3 files changed, 36 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/f820c45e/storage/InsertDestination.cpp
----------------------------------------------------------------------
diff --git a/storage/InsertDestination.cpp b/storage/InsertDestination.cpp
index 8821019..c2b44d8 100644
--- a/storage/InsertDestination.cpp
+++ b/storage/InsertDestination.cpp
@@ -199,7 +199,7 @@ void InsertDestination::insertTupleInBatch(const Tuple &tuple) {
   returnBlock(std::move(output_block), false);
 }
 
-void InsertDestination::bulkInsertTuples(ValueAccessor *accessor, bool always_mark_full) {
+void InsertDestination::bulkInsertTuples(ValueAccessor *accessor, const bool always_mark_full) {
   InvokeOnAnyValueAccessor(
       accessor,
       [&](auto *accessor) -> void {  // NOLINT(build/c++11)
@@ -207,23 +207,17 @@ void InsertDestination::bulkInsertTuples(ValueAccessor *accessor, bool always_ma
     while (!accessor->iterationFinished()) {
       MutableBlockReference output_block = this->getBlockForInsertion();
       // FIXME(chasseur): Deal with TupleTooLargeForBlock exception.
-      if (output_block->bulkInsertTuples(accessor) == 0) {
-        // output_block is full.
-        this->returnBlock(std::move(output_block), true);
-      } else {
-        // Bulk insert into output_block was successful. output_block
-        // will be rebuilt when there won't be any more insertions to it.
-        this->returnBlock(std::move(output_block),
-                          always_mark_full || !accessor->iterationFinished());
-      }
+      const auto num_tuples_inserted = output_block->bulkInsertTuples(accessor);
+      this->returnBlock(std::move(output_block),
+                        num_tuples_inserted == 0 || !accessor->iterationFinished() ||
+                            always_mark_full);
     }
   });
 }
 
 void InsertDestination::bulkInsertTuplesWithRemappedAttributes(
     const std::vector<attribute_id> &attribute_map,
-    ValueAccessor *accessor,
-    bool always_mark_full) {
+    ValueAccessor *accessor) {
   InvokeOnAnyValueAccessor(
       accessor,
       [&](auto *accessor) -> void {  // NOLINT(build/c++11)
@@ -231,17 +225,10 @@ void InsertDestination::bulkInsertTuplesWithRemappedAttributes(
     while (!accessor->iterationFinished()) {
       MutableBlockReference output_block = this->getBlockForInsertion();
       // FIXME(chasseur): Deal with TupleTooLargeForBlock exception.
-      if (output_block->bulkInsertTuplesWithRemappedAttributes(
-              attribute_map,
-              accessor) == 0) {
-        // output_block is full.
-        this->returnBlock(std::move(output_block), true);
-      } else {
-        // Bulk insert into output_block was successful. output_block
-        // will be rebuilt when there won't be any more insertions to it.
-        this->returnBlock(std::move(output_block),
-                          always_mark_full || !accessor->iterationFinished());
-      }
+      const auto num_tuples_inserted =
+          output_block->bulkInsertTuplesWithRemappedAttributes(attribute_map, accessor);
+      this->returnBlock(std::move(output_block),
+                        num_tuples_inserted == 0 || !accessor->iterationFinished());
     }
   });
 }
@@ -267,8 +254,7 @@ void removeGapOnlyAccessors(
 }
 
 void InsertDestination::bulkInsertTuplesFromValueAccessors(
-    const std::vector<std::pair<ValueAccessor *, std::vector<attribute_id>>> &accessor_attribute_map,
-    bool always_mark_full) {
+    const std::vector<std::pair<ValueAccessor *, std::vector<attribute_id>>> &accessor_attribute_map) {
   // Handle pathological corner case where there are no accessors
   if (accessor_attribute_map.size() == 0)
     return;
@@ -323,9 +309,7 @@ void InsertDestination::bulkInsertTuplesFromValueAccessors(
 
     // Update the header for output_block and then return it.
     output_block->bulkInsertPartialTuplesFinalize(num_tuples_inserted);
-    const bool mark_full = always_mark_full
-                           || !first_accessor->iterationFinishedVirtual();
-    this->returnBlock(std::move(output_block), mark_full);
+    this->returnBlock(std::move(output_block), !first_accessor->iterationFinishedVirtual());
   }
 }
 
@@ -606,7 +590,7 @@ void PartitionAwareInsertDestination::insertTupleInBatch(const Tuple &tuple) {
   returnBlockInPartition(std::move(output_block), false, part_id);
 }
 
-void PartitionAwareInsertDestination::bulkInsertTuples(ValueAccessor *accessor, bool always_mark_full) {
+void PartitionAwareInsertDestination::bulkInsertTuples(ValueAccessor *accessor, const bool always_mark_full) {
   const std::size_t num_partitions = partition_scheme_header_->getNumPartitions();
 
   InvokeOnAnyValueAccessor(
@@ -639,29 +623,24 @@ void PartitionAwareInsertDestination::bulkInsertTuples(ValueAccessor *accessor,
       adapter[partition]->beginIteration();
       while (!adapter[partition]->iterationFinished()) {
         MutableBlockReference output_block = this->getBlockForInsertionInPartition(partition);
-        if (output_block->bulkInsertTuples(adapter[partition].get()) == 0) {
-          this->returnBlockInPartition(std::move(output_block), true, partition);
-        } else {
-          // Bulk insert into output_block was successful. output_block
-          // will be rebuilt when there won't be any more insertions to it.
-          this->returnBlockInPartition(std::move(output_block),
-                                       always_mark_full || !adapter[partition]->iterationFinished(),
-                                       partition);
-        }
+        const auto num_tuples_inserted = output_block->bulkInsertTuples(adapter[partition].get());
+        this->returnBlockInPartition(std::move(output_block),
+                                     num_tuples_inserted == 0 || !adapter[partition]->iterationFinished() ||
+                                         always_mark_full,
+                                     partition);
       }
     }
   });
 }
 
 void PartitionAwareInsertDestination::bulkInsertTuplesWithRemappedAttributes(
-    const std::vector<attribute_id> &attribute_map, ValueAccessor *accessor, bool always_mark_full) {
+    const std::vector<attribute_id> &attribute_map, ValueAccessor *accessor) {
   const std::size_t num_partitions = partition_scheme_header_->getNumPartitions();
 
   InvokeOnAnyValueAccessor(
       accessor,
       [this,
        &attribute_map,
-       &always_mark_full,
        &num_partitions](auto *accessor) -> void {  // NOLINT(build/c++11)
     std::vector<std::unique_ptr<TupleIdSequence>> partition_membership(num_partitions);
 
@@ -688,15 +667,11 @@ void PartitionAwareInsertDestination::bulkInsertTuplesWithRemappedAttributes(
       adapter[partition]->beginIteration();
       while (!adapter[partition]->iterationFinished()) {
         MutableBlockReference output_block = this->getBlockForInsertionInPartition(partition);
-        if (output_block->bulkInsertTuplesWithRemappedAttributes(attribute_map, adapter[partition].get()) == 0) {
-          this->returnBlockInPartition(std::move(output_block), true, partition);
-        } else {
-          // Bulk insert into output_block was successful. output_block
-          // will be rebuilt when there won't be any more insertions to it.
-          this->returnBlockInPartition(std::move(output_block),
-                                       always_mark_full || !adapter[partition]->iterationFinished(),
-                                       partition);
-        }
+        const auto num_tuple_inserted =
+            output_block->bulkInsertTuplesWithRemappedAttributes(attribute_map, adapter[partition].get());
+        this->returnBlockInPartition(std::move(output_block),
+                                     num_tuple_inserted == 0 || !adapter[partition]->iterationFinished(),
+                                     partition);
       }
     }
   });

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/f820c45e/storage/InsertDestination.hpp
----------------------------------------------------------------------
diff --git a/storage/InsertDestination.hpp b/storage/InsertDestination.hpp
index ab791b1..3b39aeb 100644
--- a/storage/InsertDestination.hpp
+++ b/storage/InsertDestination.hpp
@@ -156,16 +156,15 @@ class InsertDestination : public InsertDestinationInterface {
 
   void insertTupleInBatch(const Tuple &tuple) override;
 
-  void bulkInsertTuples(ValueAccessor *accessor, bool always_mark_full = false) override;
+  void bulkInsertTuples(ValueAccessor *accessor,
+                        const bool always_mark_full = false) override;
 
   void bulkInsertTuplesWithRemappedAttributes(
       const std::vector<attribute_id> &attribute_map,
-      ValueAccessor *accessor,
-      bool always_mark_full = false) override;
+      ValueAccessor *accessor) override;
 
   void bulkInsertTuplesFromValueAccessors(
-      const std::vector<std::pair<ValueAccessor *, std::vector<attribute_id>>> &accessor_attribute_map,
-      bool always_mark_full = false) override;
+      const std::vector<std::pair<ValueAccessor *, std::vector<attribute_id>>> &accessor_attribute_map) override;
 
   void insertTuplesFromVector(std::vector<Tuple>::const_iterator begin,
                               std::vector<Tuple>::const_iterator end) override;
@@ -363,8 +362,7 @@ class AlwaysCreateBlockInsertDestination : public InsertDestination {
   }
 
   void bulkInsertTuplesFromValueAccessors(
-      const std::vector<std::pair<ValueAccessor *, std::vector<attribute_id>>> &accessor_attribute_map,
-      bool always_mark_full = false) override {
+      const std::vector<std::pair<ValueAccessor *, std::vector<attribute_id>>> &accessor_attribute_map) override {
     LOG(FATAL) << "bulkInsertTuplesFromValueAccessors is not implemented for AlwaysCreateBlockInsertDestination";
   }
 
@@ -551,16 +549,15 @@ class PartitionAwareInsertDestination : public InsertDestination {
 
   void insertTupleInBatch(const Tuple &tuple) override;
 
-  void bulkInsertTuples(ValueAccessor *accessor, bool always_mark_full = false) override;
+  void bulkInsertTuples(ValueAccessor *accessor,
+                        const bool always_mark_full = false) override;
 
   void bulkInsertTuplesWithRemappedAttributes(
       const std::vector<attribute_id> &attribute_map,
-      ValueAccessor *accessor,
-      bool always_mark_full = false) override;
+      ValueAccessor *accessor) override;
 
   void bulkInsertTuplesFromValueAccessors(
-      const std::vector<std::pair<ValueAccessor *, std::vector<attribute_id>>> &accessor_attribute_map,
-      bool always_mark_full = false) override {
+      const std::vector<std::pair<ValueAccessor *, std::vector<attribute_id>>> &accessor_attribute_map) override {
     LOG(FATAL) << "bulkInsertTuplesFromValueAccessors is not implemented for PartitionAwareInsertDestination";
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/f820c45e/storage/InsertDestinationInterface.hpp
----------------------------------------------------------------------
diff --git a/storage/InsertDestinationInterface.hpp b/storage/InsertDestinationInterface.hpp
index b8c584b..7b87a98 100644
--- a/storage/InsertDestinationInterface.hpp
+++ b/storage/InsertDestinationInterface.hpp
@@ -104,7 +104,7 @@ class InsertDestinationInterface {
    *        insertion from ValueAccessor even when partially full.
    **/
   virtual void bulkInsertTuples(ValueAccessor *accessor,
-                                bool always_mark_full = false) = 0;
+                                const bool always_mark_full = false) = 0;
 
   /**
    * @brief Bulk-insert tuples from a ValueAccessor with differently-ordered
@@ -115,13 +115,10 @@ class InsertDestinationInterface {
    *        corresponding attributes which should be read from accessor.
    * @param accessor A ValueAccessor whose tuples will by inserted into blocks
    *        from this InsertDestination.
-   * @param always_mark_full If \c true, always mark the blocks full after
-   *        insertion from ValueAccessor even when partially full.
    **/
   virtual void bulkInsertTuplesWithRemappedAttributes(
       const std::vector<attribute_id> &attribute_map,
-      ValueAccessor *accessor,
-      bool always_mark_full = false) = 0;
+      ValueAccessor *accessor) = 0;
 
   /**
    * @brief Bulk-insert tuples from one or more ValueAccessors
@@ -137,12 +134,9 @@ class InsertDestinationInterface {
    *        is the attribute_id "n" in corresponding input value accessor.
    *        Set the i-th element to kInvalidCatalogId if it doesn't come from
    *        the corresponding value accessor.
-   * @param always_mark_full If \c true, always mark the blocks full after
-   *        insertion from ValueAccessor even when partially full.
    **/
   virtual void bulkInsertTuplesFromValueAccessors(
-      const std::vector<std::pair<ValueAccessor *, std::vector<attribute_id>>> &accessor_attribute_map,
-      bool always_mark_full = false) = 0;
+      const std::vector<std::pair<ValueAccessor *, std::vector<attribute_id>>> &accessor_attribute_map) = 0;
 
   /**
    * @brief Insert tuples from a range of Tuples in a vector.


[26/46] incubator-quickstep git commit: Get the list of referenced base relations

Posted by ji...@apache.org.
Get the list of referenced base relations

- Find the base relations that are referenced in the query.
- The referenced relations are stored in the QueryHandle.
- Separate method in QueryProcessor class to just get this list of relations,
  without needing to fully optimize the query.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/8a84039e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/8a84039e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/8a84039e

Branch: refs/heads/fix-iwyu
Commit: 8a84039e140ed80376505b6da950c08a6112470e
Parents: 39c6214
Author: Harshad Deshmukh <hb...@apache.org>
Authored: Tue Nov 28 16:16:59 2017 -0600
Committer: Harshad Deshmukh <hb...@apache.org>
Committed: Fri Dec 1 14:26:19 2017 -0600

----------------------------------------------------------------------
 query_optimizer/CMakeLists.txt                  |  2 +
 query_optimizer/LogicalGenerator.cpp            |  1 -
 query_optimizer/Optimizer.cpp                   | 11 +++
 query_optimizer/Optimizer.hpp                   | 15 ++++
 query_optimizer/QueryHandle.hpp                 | 21 +++++
 query_optimizer/QueryProcessor.cpp              |  7 ++
 query_optimizer/QueryProcessor.hpp              | 11 +++
 query_optimizer/resolver/CMakeLists.txt         |  1 +
 query_optimizer/resolver/Resolver.cpp           |  7 ++
 query_optimizer/resolver/Resolver.hpp           |  5 ++
 query_optimizer/rules/CMakeLists.txt            | 13 ++++
 .../rules/ReferencedBaseRelations.cpp           | 66 ++++++++++++++++
 .../rules/ReferencedBaseRelations.hpp           | 80 ++++++++++++++++++++
 13 files changed, 239 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a84039e/query_optimizer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt
index 1e4e346..9128c63 100644
--- a/query_optimizer/CMakeLists.txt
+++ b/query_optimizer/CMakeLists.txt
@@ -206,7 +206,9 @@ target_link_libraries(quickstep_queryoptimizer_LogicalToPhysicalMapper
 target_link_libraries(quickstep_queryoptimizer_Optimizer
                       quickstep_queryoptimizer_ExecutionGenerator
                       quickstep_queryoptimizer_LogicalGenerator
+                      quickstep_queryoptimizer_OptimizerContext
                       quickstep_queryoptimizer_PhysicalGenerator
+                      quickstep_queryoptimizer_resolver_Resolver
                       quickstep_utility_Macros)
 target_link_libraries(quickstep_queryoptimizer_OptimizerContext
                       quickstep_queryoptimizer_expressions_ExprId

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a84039e/query_optimizer/LogicalGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/LogicalGenerator.cpp b/query_optimizer/LogicalGenerator.cpp
index abeca53..111fa1f 100644
--- a/query_optimizer/LogicalGenerator.cpp
+++ b/query_optimizer/LogicalGenerator.cpp
@@ -23,7 +23,6 @@
 #include <vector>
 
 #include "parser/ParseStatement.hpp"
-
 #include "query_optimizer/OptimizerContext.hpp"
 #include "query_optimizer/Validator.hpp"
 #include "query_optimizer/logical/Logical.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a84039e/query_optimizer/Optimizer.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/Optimizer.cpp b/query_optimizer/Optimizer.cpp
index 1b91574..d002ca1 100644
--- a/query_optimizer/Optimizer.cpp
+++ b/query_optimizer/Optimizer.cpp
@@ -21,6 +21,8 @@
 
 #include "query_optimizer/ExecutionGenerator.hpp"
 #include "query_optimizer/LogicalGenerator.hpp"
+#include "query_optimizer/OptimizerContext.hpp"
+#include "query_optimizer/resolver/Resolver.hpp"
 
 namespace quickstep {
 namespace optimizer {
@@ -38,5 +40,14 @@ void Optimizer::generateQueryHandle(const ParseStatement &parse_statement,
           logical_generator.generatePlan(*catalog_database, parse_statement)));
 }
 
+void Optimizer::findReferencedBaseRelations(const ParseStatement &parse_statement,
+                                            CatalogDatabase *catalog_database,
+                                            QueryHandle *query_handle) {
+  OptimizerContext optimizer_context;
+  resolver::Resolver resolver(*catalog_database, &optimizer_context);
+  resolver.resolve(parse_statement);
+  query_handle->setReferencedBaseRelations(resolver.getReferencedBaseRelations());
+}
+
 }  // namespace optimizer
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a84039e/query_optimizer/Optimizer.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/Optimizer.hpp b/query_optimizer/Optimizer.hpp
index 227dd04..16f4122 100644
--- a/query_optimizer/Optimizer.hpp
+++ b/query_optimizer/Optimizer.hpp
@@ -69,6 +69,21 @@ class Optimizer {
                            OptimizerContext *optimizer_context,
                            QueryHandle *query_handle);
 
+  /**
+   * @brief Find the reference base relations in the query and set them in the
+   *        QueryHandle.
+   *
+   * @note This function is useful if the objective is to only find the
+   *       referenced relations in the query and not to optimize the query.
+   *
+   * @param parse_statement The parse tree of the input query.
+   * @param catalog_database The database that the query is executed on.
+   * @param query_handle The QueryHandle for this query.
+   */
+  void findReferencedBaseRelations(const ParseStatement &parse_statement,
+                                   CatalogDatabase *catalog_database,
+                                   QueryHandle *query_handle);
+
  private:
   DISALLOW_COPY_AND_ASSIGN(Optimizer);
 };

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a84039e/query_optimizer/QueryHandle.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/QueryHandle.hpp b/query_optimizer/QueryHandle.hpp
index 6feeb4c..3e76463 100644
--- a/query_optimizer/QueryHandle.hpp
+++ b/query_optimizer/QueryHandle.hpp
@@ -23,6 +23,7 @@
 #include <cstddef>
 #include <cstdint>
 #include <memory>
+#include <vector>
 
 #include "catalog/Catalog.pb.h"
 #include "catalog/CatalogTypedefs.hpp"
@@ -178,6 +179,23 @@ class QueryHandle {
     query_result_relation_ = relation;
   }
 
+  /**
+   * @brief Get the referenced base relations in this query.
+   **/
+  const std::vector<const CatalogRelation*>& getReferencedBaseRelations() const {
+    return referenced_base_relations_;
+  }
+
+  /**
+   * @brief Set the referenced base relations in this query.
+   * @param referenced_base_relations_ The list of referenced base relations
+   *        in this query.
+   **/
+  void setReferencedBaseRelations(
+      const std::vector<const CatalogRelation*> &referenced_base_relations) {
+    referenced_base_relations_ = referenced_base_relations;
+  }
+
 #ifdef QUICKSTEP_DISTRIBUTED
   /**
    * @brief Whether the query will be executed in the single node.
@@ -214,6 +232,9 @@ class QueryHandle {
   //             and deleted by the Cli shell.
   const CatalogRelation *query_result_relation_;
 
+  std::vector<const CatalogRelation*> referenced_base_relations_;
+
+ private:
 #ifdef QUICKSTEP_DISTRIBUTED
   // Indicate whether the query should be executed on the default Shiftboss for
   // correctness purpose.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a84039e/query_optimizer/QueryProcessor.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/QueryProcessor.cpp b/query_optimizer/QueryProcessor.cpp
index d74eeba..2b5011e 100644
--- a/query_optimizer/QueryProcessor.cpp
+++ b/query_optimizer/QueryProcessor.cpp
@@ -33,6 +33,8 @@ using std::ofstream;
 
 namespace quickstep {
 
+class QueryHandle;
+
 void QueryProcessor::generateQueryHandle(const ParseStatement &statement,
                                          QueryHandle *query_handle) {
   optimizer::OptimizerContext optimizer_context;
@@ -76,4 +78,9 @@ void QueryProcessor::loadCatalog() {
   catalog_altered_ = false;
 }
 
+void QueryProcessor::findReferencedBaseRelationsInQuery(
+    const ParseStatement &statement, QueryHandle *query_handle) {
+  optimizer_.findReferencedBaseRelations(statement, getDefaultDatabase(), query_handle);
+}
+
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a84039e/query_optimizer/QueryProcessor.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/QueryProcessor.hpp b/query_optimizer/QueryProcessor.hpp
index 2b39b84..1e16acc 100644
--- a/query_optimizer/QueryProcessor.hpp
+++ b/query_optimizer/QueryProcessor.hpp
@@ -161,6 +161,17 @@ class QueryProcessor {
                            QueryHandle *query_handle);
 
   /**
+   * @brief Find the reference base relations in the query and set them in the
+   *        QueryHandle.
+   *
+   * @note This function does not fully optimize the query plan.
+   *
+   * @param statement The parsed SQL statement of the query.
+   * @param query_handle The QueryHandle of the given query.
+   */
+  void findReferencedBaseRelationsInQuery(const ParseStatement &statement, QueryHandle *query_handle);
+
+  /**
    * @brief Save the catalog back to disk.
    **/
   void saveCatalog();

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a84039e/query_optimizer/resolver/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/CMakeLists.txt b/query_optimizer/resolver/CMakeLists.txt
index 6feb1e8..0746275 100644
--- a/query_optimizer/resolver/CMakeLists.txt
+++ b/query_optimizer/resolver/CMakeLists.txt
@@ -119,6 +119,7 @@ target_link_libraries(quickstep_queryoptimizer_resolver_Resolver
                       quickstep_queryoptimizer_logical_UpdateTable
                       quickstep_queryoptimizer_logical_WindowAggregate
                       quickstep_queryoptimizer_resolver_NameResolver
+                      quickstep_queryoptimizer_rules_ReferencedBaseRelations
                       quickstep_storage_StorageBlockLayout_proto
                       quickstep_storage_StorageConstants
                       quickstep_types_IntType

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a84039e/query_optimizer/resolver/Resolver.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp
index 0b6dc22..b07cf10 100644
--- a/query_optimizer/resolver/Resolver.cpp
+++ b/query_optimizer/resolver/Resolver.cpp
@@ -114,6 +114,7 @@
 #include "query_optimizer/logical/UpdateTable.hpp"
 #include "query_optimizer/logical/WindowAggregate.hpp"
 #include "query_optimizer/resolver/NameResolver.hpp"
+#include "query_optimizer/rules/ReferencedBaseRelations.hpp"
 #include "storage/StorageBlockLayout.pb.h"
 #include "storage/StorageConstants.hpp"
 #include "types/IntType.hpp"
@@ -454,6 +455,12 @@ L::LogicalPtr Resolver::resolve(const ParseStatement &parse_query) {
   return logical_plan_;
 }
 
+std::vector<const CatalogRelation*> Resolver::getReferencedBaseRelations() {
+  std::unique_ptr<ReferencedBaseRelations> base_relations(new ReferencedBaseRelations(context_));
+  base_relations->apply(logical_plan_);
+  return base_relations->getReferencedBaseRelations();
+}
+
 L::LogicalPtr Resolver::resolveCopyFrom(
     const ParseStatementCopy &copy_from_statement) {
   DCHECK(copy_from_statement.getCopyDirection() == ParseStatementCopy::kFrom);

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a84039e/query_optimizer/resolver/Resolver.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.hpp b/query_optimizer/resolver/Resolver.hpp
index 1784782..be5eebf 100644
--- a/query_optimizer/resolver/Resolver.hpp
+++ b/query_optimizer/resolver/Resolver.hpp
@@ -114,6 +114,11 @@ class Resolver {
    */
   logical::LogicalPtr resolve(const ParseStatement &parse_query);
 
+  /**
+   * @brief Get the referenced base relations in the query.
+   */
+  std::vector<const CatalogRelation*> getReferencedBaseRelations();
+
  private:
   /**
    * @brief Expression-scoped info that contains both constant and non-constant

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a84039e/query_optimizer/rules/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/CMakeLists.txt b/query_optimizer/rules/CMakeLists.txt
index d6c043f..f9cd51c 100644
--- a/query_optimizer/rules/CMakeLists.txt
+++ b/query_optimizer/rules/CMakeLists.txt
@@ -39,6 +39,9 @@ add_library(quickstep_queryoptimizer_rules_PushDownSemiAntiJoin PushDownSemiAnti
 add_library(quickstep_queryoptimizer_rules_ReduceGroupByAttributes
             ReduceGroupByAttributes.cpp
             ReduceGroupByAttributes.hpp)
+add_library(quickstep_queryoptimizer_rules_ReferencedBaseRelations
+            ReferencedBaseRelations.cpp
+            ReferencedBaseRelations.hpp)
 add_library(quickstep_queryoptimizer_rules_ReorderColumns ReorderColumns.cpp ReorderColumns.hpp)
 add_library(quickstep_queryoptimizer_rules_ReuseAggregateExpressions
             ReuseAggregateExpressions.cpp
@@ -270,6 +273,15 @@ target_link_libraries(quickstep_queryoptimizer_rules_ReduceGroupByAttributes
                       quickstep_queryoptimizer_rules_PruneColumns
                       quickstep_queryoptimizer_rules_Rule
                       quickstep_utility_Macros)
+target_link_libraries(quickstep_queryoptimizer_rules_ReferencedBaseRelations
+                      quickstep_catalog_CatalogRelation
+                      quickstep_catalog_CatalogTypedefs
+                      quickstep_queryoptimizer_logical_Logical
+                      quickstep_queryoptimizer_logical_PatternMatcher
+                      quickstep_queryoptimizer_logical_TableReference
+                      quickstep_queryoptimizer_rules_Rule
+                      quickstep_queryoptimizer_rules_UnnestSubqueries
+                      quickstep_utility_Macros)
 target_link_libraries(quickstep_queryoptimizer_rules_ReorderColumns
                       quickstep_queryoptimizer_expressions_AttributeReference
                       quickstep_queryoptimizer_expressions_ExprId
@@ -433,6 +445,7 @@ target_link_libraries(quickstep_queryoptimizer_rules
                       quickstep_queryoptimizer_rules_PushDownLowCostDisjunctivePredicate
                       quickstep_queryoptimizer_rules_PushDownSemiAntiJoin
                       quickstep_queryoptimizer_rules_ReduceGroupByAttributes
+                      quickstep_queryoptimizer_rules_ReferencedBaseRelations
                       quickstep_queryoptimizer_rules_ReorderColumns
                       quickstep_queryoptimizer_rules_ReuseAggregateExpressions
                       quickstep_queryoptimizer_rules_Rule

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a84039e/query_optimizer/rules/ReferencedBaseRelations.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/ReferencedBaseRelations.cpp b/query_optimizer/rules/ReferencedBaseRelations.cpp
new file mode 100644
index 0000000..8af3295
--- /dev/null
+++ b/query_optimizer/rules/ReferencedBaseRelations.cpp
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ **/
+
+#include <stack>
+
+#include "query_optimizer/rules/ReferencedBaseRelations.hpp"
+
+#include "catalog/CatalogRelation.hpp"
+#include "query_optimizer/logical/Logical.hpp"
+#include "query_optimizer/logical/PatternMatcher.hpp"
+#include "query_optimizer/logical/TableReference.hpp"
+#include "query_optimizer/rules/UnnestSubqueries.hpp"
+
+namespace quickstep {
+namespace optimizer {
+
+class OptimizerContext;
+
+namespace L = ::quickstep::optimizer::logical;
+
+void ReferencedBaseRelations::applyToNode(const L::LogicalPtr &input) {
+  L::TableReferencePtr table_reference;
+  const CatalogRelation *input_relation = nullptr;
+  if (L::SomeTableReference::MatchesWithConditionalCast(input, &table_reference)) {
+    input_relation = table_reference->catalog_relation();
+    referenced_base_relations_[input_relation->getID()] = input_relation;
+  }
+}
+
+L::LogicalPtr ReferencedBaseRelations::apply(const L::LogicalPtr &input) {
+  L::LogicalPtr unnested_tree = UnnestSubqueries(optimizer_context_).apply(input);
+
+  std::stack<L::LogicalPtr> to_be_visited;
+  to_be_visited.push(unnested_tree);
+
+  while (!to_be_visited.empty()) {
+    const L::LogicalPtr &curr_node = to_be_visited.top();
+    to_be_visited.pop();
+
+    applyToNode(curr_node);
+
+    for (auto child : curr_node->children()) {
+      to_be_visited.push(child);
+    }
+  }
+  return input;
+}
+
+}  // namespace optimizer
+}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8a84039e/query_optimizer/rules/ReferencedBaseRelations.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/ReferencedBaseRelations.hpp b/query_optimizer/rules/ReferencedBaseRelations.hpp
new file mode 100644
index 0000000..b24a148
--- /dev/null
+++ b/query_optimizer/rules/ReferencedBaseRelations.hpp
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ **/
+
+#ifndef QUICKSTEP_QUERY_OPTIMIZER_RULES_REFERENCED_BASE_RELATIONS_HPP_
+#define QUICKSTEP_QUERY_OPTIMIZER_RULES_REFERENCED_BASE_RELATIONS_HPP_
+
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "catalog/CatalogTypedefs.hpp"
+#include "query_optimizer/logical/Logical.hpp"
+#include "query_optimizer/rules/Rule.hpp"
+#include "utility/Macros.hpp"
+
+namespace quickstep {
+
+class CatalogRelation;
+
+namespace optimizer {
+
+class OptimizerContext;
+
+class ReferencedBaseRelations : public Rule<logical::Logical> {
+ public:
+  /**
+   * @brief Constructor
+   * @param optimizer_context The optimizer context.
+   */
+  explicit ReferencedBaseRelations(OptimizerContext *optimizer_context)
+      : optimizer_context_(optimizer_context) {
+  }
+
+  std::string getName() const override { return "ReferencedBaseRelations"; }
+
+  logical::LogicalPtr apply(const logical::LogicalPtr &input) override;
+
+  /**
+   * @brief Get the base relations referenced in a query.
+   */
+  std::vector<const CatalogRelation*> getReferencedBaseRelations() const {
+    std::vector<const CatalogRelation*> ret;
+    for (auto it = referenced_base_relations_.begin();
+         it != referenced_base_relations_.end();
+         ++it) {
+      ret.push_back(it->second);
+    }
+    return ret;
+  }
+
+ private:
+  void applyToNode(const logical::LogicalPtr &input);
+
+  OptimizerContext *optimizer_context_;
+
+  std::unordered_map<relation_id, const CatalogRelation*> referenced_base_relations_;
+
+  DISALLOW_COPY_AND_ASSIGN(ReferencedBaseRelations);
+};
+
+}  // namespace optimizer
+}  // namespace quickstep
+
+#endif  // QUICKSTEP_QUERY_OPTIMIZER_RULES_REFERENCED_BASE_RELATIONS_HPP_


[45/46] incubator-quickstep git commit: Small adjust in star schema cost model for # distinct values

Posted by ji...@apache.org.
Small adjust in star schema cost model for # distinct values


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/023c43a4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/023c43a4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/023c43a4

Branch: refs/heads/fix-iwyu
Commit: 023c43a40b145c225c6deab103655156a034fa90
Parents: d1dbb0d
Author: Jianqiao Zhu <ji...@cs.wisc.edu>
Authored: Wed Feb 7 15:42:15 2018 -0600
Committer: Jianqiao Zhu <ji...@cs.wisc.edu>
Committed: Fri Feb 23 14:59:06 2018 -0600

----------------------------------------------------------------------
 .../cost_model/StarSchemaSimpleCostModel.cpp        |  4 ++--
 .../tests/execution_generator/Partition.test        | 16 ++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/023c43a4/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
index 5aec4b4..6ab86e5 100644
--- a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
+++ b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
@@ -493,7 +493,7 @@ std::size_t StarSchemaSimpleCostModel::getNumDistinctValues(
       return stat.getNumDistinctValues(rel_attr_id);
     }
   }
-  return estimateCardinalityForTableReference(table_reference);
+  return estimateCardinalityForTableReference(table_reference) * 0.1;
 }
 
 bool StarSchemaSimpleCostModel::impliesUniqueAttributes(
@@ -527,7 +527,7 @@ bool StarSchemaSimpleCostModel::impliesUniqueAttributes(
           std::static_pointer_cast<const P::TableReference>(physical_plan);
       const CatalogRelationStatistics &stat =
           table_reference->relation()->getStatistics();
-      if (stat.hasNumTuples()) {
+      if (stat.isExact() && stat.hasNumTuples()) {
         const std::size_t num_tuples = stat.getNumTuples();
         for (const auto &attr : attributes) {
           const attribute_id rel_attr_id =

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/023c43a4/query_optimizer/tests/execution_generator/Partition.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/execution_generator/Partition.test b/query_optimizer/tests/execution_generator/Partition.test
index 747b969..4b11a04 100644
--- a/query_optimizer/tests/execution_generator/Partition.test
+++ b/query_optimizer/tests/execution_generator/Partition.test
@@ -116,16 +116,16 @@ WHERE dim_2_hash_partitions.id = fact.id
 +-----------+--------------------+
 |id         |char_col            |
 +-----------+--------------------+
-|          2|          2 1.414214|
 |          4|          4 2.000000|
-|          6|          6 2.449490|
 |          8|          8 2.828427|
 |         12|         12 3.464102|
-|         14|         14 3.741657|
 |         16|         16 4.000000|
+|         24|         24 4.898979|
+|          2|          2 1.414214|
+|          6|          6 2.449490|
+|         14|         14 3.741657|
 |         18|         18 4.242641|
 |         22|         22 4.690416|
-|         24|         24 4.898979|
 +-----------+--------------------+
 ==
 
@@ -193,15 +193,15 @@ GROUP BY fact.score;
 +------------------------+--------------------+
 |score                   |COUNT(*)            |
 +------------------------+--------------------+
+|                       8|                   1|
 |      41.569219381653056|                   1|
-|      76.367532368147124|                   1|
 |                      64|                   1|
 |       52.38320341483518|                   1|
-|                       8|                   1|
-|      2.8284271247461903|                   1|
-|      14.696938456699067|                   1|
+|      76.367532368147124|                   1|
 |      22.627416997969522|                   1|
 |      117.57550765359254|                   1|
+|      2.8284271247461903|                   1|
+|      14.696938456699067|                   1|
 |      103.18914671611546|                   1|
 +------------------------+--------------------+
 ==


[23/46] incubator-quickstep git commit: Temporary Build Support for OS X 10.13

Posted by ji...@apache.org.
Temporary Build Support for OS X 10.13

Change of Regular Expression


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

Branch: refs/heads/fix-iwyu
Commit: b237969cb490519ffc9a1403dc327432c3625e7b
Parents: 0fe838d
Author: Yuanchen Li <yl...@y-l.me>
Authored: Thu Nov 9 02:18:42 2017 -0600
Committer: Yuanchen Li <yl...@y-l.me>
Committed: Sat Nov 18 16:01:15 2017 -0600

----------------------------------------------------------------------
 CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b237969c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 071f8fc..60d8a2d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -302,11 +302,11 @@ else()
     endif()
   endif()
 
-  # OSX 10.12 has deprecated certain system-level APIs which causes protobuf & glog
+  # OSX 10.12+ has deprecated certain system-level APIs which causes protobuf & glog
   # builds to fail. As a short-term workaround for now, we turn off deprecated
   # warnings so that they do not cause build failures anymore.
   # TODO: Remove this workaround by fixing the protobuf_cmake and glog_cmake.
-  if (${CMAKE_SYSTEM} MATCHES "Darwin-16.[0-9]*.[0-9]*")
+  if (${CMAKE_SYSTEM} MATCHES "Darwin-1[67].[0-9]*.[0-9]*")
     if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
       CHECK_CXX_COMPILER_FLAG("-Wno-error=deprecated-declarations" COMPILER_HAS_WNO_DEPRECATED)
       if (COMPILER_HAS_WNO_DEPRECATED)


[41/46] incubator-quickstep git commit: Upgraded benchmark third party library.

Posted by ji...@apache.org.
Upgraded benchmark third party library.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/5d7aa5f0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/5d7aa5f0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/5d7aa5f0

Branch: refs/heads/fix-iwyu
Commit: 5d7aa5f0d1a898db37c46b772fca986b29c45eaa
Parents: d634772
Author: Harshad Deshmukh <hb...@apache.org>
Authored: Wed Dec 27 13:35:07 2017 -0600
Committer: Harshad Deshmukh <hb...@apache.org>
Committed: Wed Dec 27 13:35:07 2017 -0600

----------------------------------------------------------------------
 third_party/download_and_patch_prerequisites.sh        |  7 +++----
 third_party/patches/benchmark/CMakeLists.patch         | 11 +++++++++++
 third_party/patches/benchmark/benchmarkCMake.patch     | 11 -----------
 .../patches/benchmark/benchmarkSrcCMakeLists.patch     | 13 -------------
 4 files changed, 14 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/5d7aa5f0/third_party/download_and_patch_prerequisites.sh
----------------------------------------------------------------------
diff --git a/third_party/download_and_patch_prerequisites.sh b/third_party/download_and_patch_prerequisites.sh
index 2295525..9d0ff00 100755
--- a/third_party/download_and_patch_prerequisites.sh
+++ b/third_party/download_and_patch_prerequisites.sh
@@ -52,7 +52,7 @@ third_party_dir_names=("benchmark"
                        "glog"
                        )
 
-third_party_lib_urls=("https://github.com/google/benchmark/archive/v1.1.0.tar.gz"
+third_party_lib_urls=("https://github.com/google/benchmark/archive/v1.3.0.tar.gz"
                       "https://github.com/gflags/gflags/archive/v2.1.2.tar.gz"
                       "https://github.com/google/googletest/archive/release-1.8.0.tar.gz"
                       "https://github.com/antirez/linenoise/archive/1.0.tar.gz"
@@ -61,7 +61,7 @@ third_party_lib_urls=("https://github.com/google/benchmark/archive/v1.1.0.tar.gz
                       "https://github.com/google/glog/archive/v0.3.5.tar.gz"
                       )
 
-downloaded_archive_names=("v1.1.0.tar.gz"
+downloaded_archive_names=("v1.3.0.tar.gz"
                           "v2.1.2.tar.gz"
                           "release-1.8.0.tar.gz"
                           "1.0.tar.gz"
@@ -127,8 +127,7 @@ patch ${THIRD_PARTY_SRC_DIR}/gflags/src/gflags_reporting.cc ${PATCH_DIR}/gflags/
 patch ${THIRD_PARTY_SRC_DIR}/re2/CMakeLists.txt ${PATCH_DIR}/re2/re2CMake.patch
 
 # Apply benchmark patches.
-patch ${THIRD_PARTY_SRC_DIR}/benchmark/CMakeLists.txt ${PATCH_DIR}/benchmark/benchmarkCMake.patch
-patch ${THIRD_PARTY_SRC_DIR}/benchmark/src/CMakeLists.txt ${PATCH_DIR}/benchmark/benchmarkSrcCMakeLists.patch
+patch ${THIRD_PARTY_SRC_DIR}/benchmark/CMakeLists.txt ${PATCH_DIR}/benchmark/CMakeLists.patch
 
 # Apply glog patches.
 patch ${THIRD_PARTY_SRC_DIR}/glog/CMakeLists.txt ${PATCH_DIR}/glog/glogCMakeLists.txt.patch

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/5d7aa5f0/third_party/patches/benchmark/CMakeLists.patch
----------------------------------------------------------------------
diff --git a/third_party/patches/benchmark/CMakeLists.patch b/third_party/patches/benchmark/CMakeLists.patch
new file mode 100644
index 0000000..4ef6c9c
--- /dev/null
+++ b/third_party/patches/benchmark/CMakeLists.patch
@@ -0,0 +1,11 @@
+--- CMakeLists.txt	2017-12-27 13:11:46.000000002 -0600
++++ CMakeLists.txt.new	2017-12-27 13:12:28.000000002 -0600
+@@ -11,7 +11,7 @@
+   endif()
+ endforeach()
+ 
+-option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." ON)
++option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." OFF)
+ option(BENCHMARK_ENABLE_EXCEPTIONS "Enable the use of exceptions in the benchmark library." ON)
+ option(BENCHMARK_ENABLE_LTO "Enable link time optimisation of the benchmark library." OFF)
+ option(BENCHMARK_USE_LIBCXX "Build and test using libc++ as the standard library." OFF)

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/5d7aa5f0/third_party/patches/benchmark/benchmarkCMake.patch
----------------------------------------------------------------------
diff --git a/third_party/patches/benchmark/benchmarkCMake.patch b/third_party/patches/benchmark/benchmarkCMake.patch
deleted file mode 100644
index 56b54ba..0000000
--- a/third_party/patches/benchmark/benchmarkCMake.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- CMakeLists.txt	2016-10-28 16:22:22.000000000 -0500
-+++ CMakeLists.txt.new	2017-01-13 15:46:47.626768358 -0600
-@@ -10,7 +10,7 @@
-   endif()
- endforeach()
- 
--option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." ON)
-+option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." OFF)
- option(BENCHMARK_ENABLE_LTO "Enable link time optimisation of the benchmark library." OFF)
- option(BENCHMARK_USE_LIBCXX "Build and test using libc++ as the standard library." OFF)
- # Make sure we can import out CMake functions

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/5d7aa5f0/third_party/patches/benchmark/benchmarkSrcCMakeLists.patch
----------------------------------------------------------------------
diff --git a/third_party/patches/benchmark/benchmarkSrcCMakeLists.patch b/third_party/patches/benchmark/benchmarkSrcCMakeLists.patch
deleted file mode 100644
index 6591b51..0000000
--- a/third_party/patches/benchmark/benchmarkSrcCMakeLists.patch
+++ /dev/null
@@ -1,13 +0,0 @@
---- CMakeLists.txt	2016-10-28 16:22:22.000000000 -0500
-+++ CMakeLists.txt.new	2017-01-24 16:31:51.045598240 -0600
-@@ -21,6 +21,10 @@
- 
- # Link threads.
- target_link_libraries(benchmark  ${BENCHMARK_CXX_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
-+find_library(LIBRT rt)
-+if(LIBRT)
-+  target_link_libraries(benchmark ${LIBRT})
-+endif()
- 
- # We need extra libraries on Windows
- if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")


[07/46] incubator-quickstep git commit: Optimized the mod operation in HashPartition.

Posted by ji...@apache.org.
Optimized the mod operation in HashPartition.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/7fb7a775
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/7fb7a775
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/7fb7a775

Branch: refs/heads/fix-iwyu
Commit: 7fb7a775568b49178af80f15383b641bc1b267bf
Parents: 1b2698d
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Fri Sep 29 15:37:14 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Fri Sep 29 18:03:21 2017 -0500

----------------------------------------------------------------------
 catalog/PartitionSchemeHeader.hpp | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/7fb7a775/catalog/PartitionSchemeHeader.hpp
----------------------------------------------------------------------
diff --git a/catalog/PartitionSchemeHeader.hpp b/catalog/PartitionSchemeHeader.hpp
index d34ca1f..35d4081 100644
--- a/catalog/PartitionSchemeHeader.hpp
+++ b/catalog/PartitionSchemeHeader.hpp
@@ -187,7 +187,8 @@ class HashPartitionSchemeHeader final : public PartitionSchemeHeader {
    **/
   HashPartitionSchemeHeader(const std::size_t num_partitions,
                             PartitionAttributeIds &&attributes)  // NOLINT(whitespace/operators)
-      : PartitionSchemeHeader(PartitionType::kHash, num_partitions, std::move(attributes)) {
+      : PartitionSchemeHeader(PartitionType::kHash, num_partitions, std::move(attributes)),
+        is_power_of_two_(!(num_partitions & (num_partitions - 1))) {
   }
 
   /**
@@ -199,13 +200,20 @@ class HashPartitionSchemeHeader final : public PartitionSchemeHeader {
   partition_id getPartitionId(
       const PartitionValues &value_of_attributes) const override {
     DCHECK_EQ(partition_attribute_ids_.size(), value_of_attributes.size());
-    // TODO(gerald): Optimize for the case where the number of partitions is a
-    // power of 2. We can just mask out the lower-order hash bits rather than
-    // doing a division operation.
-    return HashCompositeKey(value_of_attributes) % num_partitions_;
+    return getPartitionId(HashCompositeKey(value_of_attributes));
   }
 
  private:
+  partition_id getPartitionId(const std::size_t hash_code) const {
+    if (is_power_of_two_) {
+      return hash_code & (num_partitions_ - 1);
+    }
+
+    return (hash_code >= num_partitions_) ? hash_code % num_partitions_
+                                          : hash_code;
+  }
+
+  const bool is_power_of_two_;
   DISALLOW_COPY_AND_ASSIGN(HashPartitionSchemeHeader);
 };
 


[13/46] incubator-quickstep git commit: Added a new set API for TupleIdSequence.

Posted by ji...@apache.org.
Added a new set API for TupleIdSequence.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/69fd94b8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/69fd94b8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/69fd94b8

Branch: refs/heads/fix-iwyu
Commit: 69fd94b8917c53e5a7a3e5899382c6ba12cf1c2b
Parents: a61b03d
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Thu Sep 28 19:28:30 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Mon Oct 9 13:14:07 2017 -0500

----------------------------------------------------------------------
 expressions/scalar/ScalarCaseExpression.cpp     |   2 +-
 relational_operators/HashJoinOperator.cpp       |   2 +-
 storage/AggregationOperationState.cpp           |   3 +-
 storage/BloomFilterIndexSubBlock.cpp            |   2 +-
 storage/CMakeLists.txt                          |   1 +
 storage/CSBTreeIndexSubBlock.cpp                |  22 +-
 ...ompressedColumnStoreTupleStorageSubBlock.cpp |  36 +--
 ...ressedPackedRowStoreTupleStorageSubBlock.cpp |  36 +--
 storage/InsertDestination.hpp                   |   4 +-
 storage/SMAIndexSubBlock.cpp                    |   2 +-
 storage/StorageBlock.cpp                        |   9 +-
 storage/TupleIdSequence.hpp                     |  15 ++
 storage/TupleStorageSubBlock.cpp                |   2 +-
 utility/BitVector.hpp                           |  16 ++
 utility/lip_filter/LIPFilterAdaptiveProber.hpp  |   4 +-
 utility/tests/BitVector_unittest.cpp            | 226 +++++++++----------
 16 files changed, 206 insertions(+), 176 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/expressions/scalar/ScalarCaseExpression.cpp
----------------------------------------------------------------------
diff --git a/expressions/scalar/ScalarCaseExpression.cpp b/expressions/scalar/ScalarCaseExpression.cpp
index 00a7710..6847425 100644
--- a/expressions/scalar/ScalarCaseExpression.cpp
+++ b/expressions/scalar/ScalarCaseExpression.cpp
@@ -319,7 +319,7 @@ ColumnVectorPtr ScalarCaseExpression::getAllValuesForJoin(
                                                 *right_accessor,
                                                 right_relation_id,
                                                 check_pair.second)) {
-        current_case_positions->set(pos, true);
+        current_case_positions->set(pos);
         current_case_matches.emplace_back(check_pair);
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/relational_operators/HashJoinOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/HashJoinOperator.cpp b/relational_operators/HashJoinOperator.cpp
index b07e4cb..4083bd3 100644
--- a/relational_operators/HashJoinOperator.cpp
+++ b/relational_operators/HashJoinOperator.cpp
@@ -758,7 +758,7 @@ void HashSemiJoinWorkOrder::executeWithResidualPredicate() {
                                                       *probe_accessor,
                                                       probe_relation_id,
                                                       hash_match.second)) {
-        filter.set(hash_match.second, true);
+        filter.set(hash_match.second);
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/storage/AggregationOperationState.cpp
----------------------------------------------------------------------
diff --git a/storage/AggregationOperationState.cpp b/storage/AggregationOperationState.cpp
index 0f4795f..73f1983 100644
--- a/storage/AggregationOperationState.cpp
+++ b/storage/AggregationOperationState.cpp
@@ -579,8 +579,7 @@ void AggregationOperationState::aggregateBlockHashTableImplPartitioned(
           accessor->getTupleWithAttributes(group_by_key_ids));
       const std::size_t curr_tuple_partition_id =
           curr_tuple->getTupleHash() % num_partitions;
-      partition_membership[curr_tuple_partition_id]->set(
-          accessor->getCurrentPosition(), true);
+      partition_membership[curr_tuple_partition_id]->set(accessor->getCurrentPosition());
     }
 
     // Aggregate each partition.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/storage/BloomFilterIndexSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/BloomFilterIndexSubBlock.cpp b/storage/BloomFilterIndexSubBlock.cpp
index 4351c05..1af3872 100644
--- a/storage/BloomFilterIndexSubBlock.cpp
+++ b/storage/BloomFilterIndexSubBlock.cpp
@@ -206,7 +206,7 @@ TupleIdSequence* BloomFilterIndexSubBlock::getMatchesForPredicate(
     } else {
       for (tuple_id tid = 0; tid <= tuple_store_.getMaxTupleID(); ++tid) {
         if (tuple_store_.hasTupleWithID(tid)) {
-          tuple_sequence->set(tid, true);
+          tuple_sequence->set(tid);
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/storage/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/storage/CMakeLists.txt b/storage/CMakeLists.txt
index 92a3292..fb09e49 100644
--- a/storage/CMakeLists.txt
+++ b/storage/CMakeLists.txt
@@ -1065,6 +1065,7 @@ target_link_libraries(quickstep_storage_ThreadPrivateCompactKeyHashTable
                       quickstep_utility_Macros
                       quickstep_utility_ScopedBuffer)
 target_link_libraries(quickstep_storage_TupleIdSequence
+                      glog
                       quickstep_storage_StorageBlockInfo
                       quickstep_utility_BitVector
                       quickstep_utility_Macros)

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/storage/CSBTreeIndexSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/CSBTreeIndexSubBlock.cpp b/storage/CSBTreeIndexSubBlock.cpp
index dd75467..cc18e89 100644
--- a/storage/CSBTreeIndexSubBlock.cpp
+++ b/storage/CSBTreeIndexSubBlock.cpp
@@ -1791,7 +1791,7 @@ TupleIdSequence* CSBTreeIndexSubBlock::evaluateEqualPredicate(
           // End of matches.
           return matches.release();
         }
-        matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_), true);
+        matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_));
       }
       key_ptr += key_tuple_id_pair_length_bytes_;
     }
@@ -1824,7 +1824,7 @@ TupleIdSequence* CSBTreeIndexSubBlock::evaluateNotEqualPredicate(
                                + sizeof(NodeHeader)
                                + key_length_bytes_;
     for (uint16_t entry_num = 0; entry_num < num_keys; ++entry_num) {
-      matches->set(*reinterpret_cast<const tuple_id*>(tuple_id_ptr), true);
+      matches->set(*reinterpret_cast<const tuple_id*>(tuple_id_ptr));
       tuple_id_ptr += key_tuple_id_pair_length_bytes_;
     }
     search_node = getRightSiblingOfLeafNode(search_node);
@@ -1841,7 +1841,7 @@ TupleIdSequence* CSBTreeIndexSubBlock::evaluateNotEqualPredicate(
       if (!equal_found) {
         if (key_less_literal_comparator.compareDataPtrsInl(key_ptr, literal)) {
           // key < literal
-          matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_), true);
+          matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_));
         } else {
           equal_found = true;
         }
@@ -1854,7 +1854,7 @@ TupleIdSequence* CSBTreeIndexSubBlock::evaluateNotEqualPredicate(
           for (uint16_t subsequent_num = entry_num;
                subsequent_num < num_keys;
                ++subsequent_num) {
-            matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_), true);
+            matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_));
             key_ptr += key_tuple_id_pair_length_bytes_;
           }
           past_equal = true;
@@ -1877,7 +1877,7 @@ TupleIdSequence* CSBTreeIndexSubBlock::evaluateNotEqualPredicate(
                                + sizeof(NodeHeader)
                                + key_length_bytes_;
     for (uint16_t entry_num = 0; entry_num < num_keys; ++entry_num) {
-      matches->set(*reinterpret_cast<const tuple_id*>(tuple_id_ptr), true);
+      matches->set(*reinterpret_cast<const tuple_id*>(tuple_id_ptr));
       tuple_id_ptr += key_tuple_id_pair_length_bytes_;
     }
     search_node = getRightSiblingOfLeafNode(search_node);
@@ -1910,7 +1910,7 @@ TupleIdSequence* CSBTreeIndexSubBlock::evaluateLessPredicate(
                                + sizeof(NodeHeader)
                                + key_length_bytes_;
     for (uint16_t entry_num = 0; entry_num < num_keys; ++entry_num) {
-      matches->set(*reinterpret_cast<const tuple_id*>(tuple_id_ptr), true);
+      matches->set(*reinterpret_cast<const tuple_id*>(tuple_id_ptr));
       tuple_id_ptr += key_tuple_id_pair_length_bytes_;
     }
     search_node = getRightSiblingOfLeafNode(search_node);
@@ -1927,7 +1927,7 @@ TupleIdSequence* CSBTreeIndexSubBlock::evaluateLessPredicate(
         if (!equal_found) {
           if (key_less_literal_comparator.compareDataPtrsInl(key_ptr, literal)) {
             // key < literal
-            matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_), true);
+            matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_));
           } else {
             equal_found = true;
           }
@@ -1938,7 +1938,7 @@ TupleIdSequence* CSBTreeIndexSubBlock::evaluateLessPredicate(
             // literal < key
             return matches.release();
           } else {
-            matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_), true);
+            matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_));
           }
         }
 
@@ -1954,7 +1954,7 @@ TupleIdSequence* CSBTreeIndexSubBlock::evaluateLessPredicate(
       for (uint16_t entry_num = 0; entry_num < num_keys; ++entry_num) {
         if (key_less_literal_comparator.compareDataPtrsInl(key_ptr, literal)) {
           // key < literal
-          matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_), true);
+          matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_));
         } else {
           return matches.release();
         }
@@ -2001,7 +2001,7 @@ TupleIdSequence* CSBTreeIndexSubBlock::evaluateGreaterPredicate(
       if (match_found) {
         // Fill in the matching entries from this leaf.
         for (uint16_t match_num = entry_num; match_num < num_keys; ++match_num) {
-          matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_), true);
+          matches->set(*reinterpret_cast<const tuple_id*>(key_ptr + key_length_bytes_));
           key_ptr += key_tuple_id_pair_length_bytes_;
         }
         break;
@@ -2024,7 +2024,7 @@ TupleIdSequence* CSBTreeIndexSubBlock::evaluateGreaterPredicate(
                                + sizeof(NodeHeader)
                                + key_length_bytes_;
     for (uint16_t entry_num = 0; entry_num < num_keys; ++entry_num) {
-      matches->set(*reinterpret_cast<const tuple_id*>(tuple_id_ptr), true);
+      matches->set(*reinterpret_cast<const tuple_id*>(tuple_id_ptr));
       tuple_id_ptr += key_tuple_id_pair_length_bytes_;
     }
     search_node = getRightSiblingOfLeafNode(search_node);

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/storage/CompressedColumnStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/CompressedColumnStoreTupleStorageSubBlock.cpp b/storage/CompressedColumnStoreTupleStorageSubBlock.cpp
index 3bd0c3a..cc23445 100644
--- a/storage/CompressedColumnStoreTupleStorageSubBlock.cpp
+++ b/storage/CompressedColumnStoreTupleStorageSubBlock.cpp
@@ -538,7 +538,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getNotEqualCodesExcl
                ++tid) {
             if ((code != static_cast<const uint8_t*>(attr_stripe)[tid])
                 && (null_code != static_cast<const uint8_t*>(attr_stripe)[tid])) {
-              matches->set(tid, true);
+              matches->set(tid);
             }
           }
           break;
@@ -548,7 +548,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getNotEqualCodesExcl
                ++tid) {
             if ((code != static_cast<const uint16_t*>(attr_stripe)[tid])
                 && (null_code != static_cast<const uint16_t*>(attr_stripe)[tid])) {
-              matches->set(tid, true);
+              matches->set(tid);
             }
           }
           break;
@@ -558,7 +558,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getNotEqualCodesExcl
                ++tid) {
             if ((code != static_cast<const uint16_t*>(attr_stripe)[tid])
                 && (null_code != static_cast<const uint16_t*>(attr_stripe)[tid])) {
-              matches->set(tid, true);
+              matches->set(tid);
             }
           }
           break;
@@ -578,7 +578,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getNotEqualCodesExcl
                ++filter_it) {
             if ((code != static_cast<const uint8_t*>(attr_stripe)[*filter_it])
                 && (null_code != static_cast<const uint8_t*>(attr_stripe)[*filter_it])) {
-              matches->set(*filter_it, true);
+              matches->set(*filter_it);
             }
           }
           break;
@@ -588,7 +588,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getNotEqualCodesExcl
                ++filter_it) {
             if ((code != static_cast<const uint16_t*>(attr_stripe)[*filter_it])
                 && (null_code != static_cast<const uint16_t*>(attr_stripe)[*filter_it])) {
-              matches->set(*filter_it, true);
+              matches->set(*filter_it);
             }
           }
           break;
@@ -598,7 +598,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getNotEqualCodesExcl
                ++filter_it) {
             if ((code != static_cast<const uint16_t*>(attr_stripe)[*filter_it])
                 && (null_code != static_cast<const uint16_t*>(attr_stripe)[*filter_it])) {
-              matches->set(*filter_it, true);
+              matches->set(*filter_it);
             }
           }
           break;
@@ -677,7 +677,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesInRange(
                ++tid) {
             if (range.first <= (static_cast<const uint8_t*>(attr_stripe)[tid])
                 && (static_cast<const uint8_t*>(attr_stripe)[tid] < range.second)) {
-              matches->set(tid, true);
+              matches->set(tid);
             }
           }
           break;
@@ -687,7 +687,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesInRange(
                ++tid) {
             if (range.first <= (static_cast<const uint16_t*>(attr_stripe)[tid])
                 && (static_cast<const uint16_t*>(attr_stripe)[tid] < range.second)) {
-              matches->set(tid, true);
+              matches->set(tid);
             }
           }
           break;
@@ -697,7 +697,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesInRange(
                ++tid) {
             if (range.first <= (static_cast<const uint32_t*>(attr_stripe)[tid])
                 && (static_cast<const uint32_t*>(attr_stripe)[tid] < range.second)) {
-              matches->set(tid, true);
+              matches->set(tid);
             }
           }
           break;
@@ -717,7 +717,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesInRange(
                ++filter_it) {
             if (range.first <= (static_cast<const uint8_t*>(attr_stripe)[*filter_it])
                 && (static_cast<const uint8_t*>(attr_stripe)[*filter_it] < range.second)) {
-              matches->set(*filter_it, true);
+              matches->set(*filter_it);
             }
           }
           break;
@@ -727,7 +727,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesInRange(
                ++filter_it) {
             if (range.first <= (static_cast<const uint16_t*>(attr_stripe)[*filter_it])
                 && (static_cast<const uint16_t*>(attr_stripe)[*filter_it] < range.second)) {
-              matches->set(*filter_it, true);
+              matches->set(*filter_it);
             }
           }
           break;
@@ -737,7 +737,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesInRange(
                ++filter_it) {
             if (range.first <= (static_cast<const uint32_t*>(attr_stripe)[*filter_it])
                 && (static_cast<const uint32_t*>(attr_stripe)[*filter_it] < range.second)) {
-              matches->set(*filter_it, true);
+              matches->set(*filter_it);
             }
           }
           break;
@@ -924,7 +924,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesSatisfyingCo
              tid < *static_cast<const tuple_id*>(sub_block_memory_);
              ++tid) {
           if (comp(code, static_cast<const uint8_t*>(attr_stripe)[tid])) {
-            matches->set(tid, true);
+            matches->set(tid);
           }
         }
         break;
@@ -933,7 +933,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesSatisfyingCo
              tid < *static_cast<const tuple_id*>(sub_block_memory_);
              ++tid) {
           if (comp(code, static_cast<const uint16_t*>(attr_stripe)[tid])) {
-            matches->set(tid, true);
+            matches->set(tid);
           }
         }
         break;
@@ -942,7 +942,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesSatisfyingCo
              tid < *static_cast<const tuple_id*>(sub_block_memory_);
              ++tid) {
           if (comp(code, static_cast<const uint32_t*>(attr_stripe)[tid])) {
-            matches->set(tid, true);
+            matches->set(tid);
           }
         }
         break;
@@ -961,7 +961,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesSatisfyingCo
              filter_it != filter->end();
              ++filter_it) {
           if (comp(code, static_cast<const uint8_t*>(attr_stripe)[*filter_it])) {
-            matches->set(*filter_it, true);
+            matches->set(*filter_it);
           }
         }
         break;
@@ -970,7 +970,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesSatisfyingCo
              filter_it != filter->end();
              ++filter_it) {
           if (comp(code, static_cast<const uint16_t*>(attr_stripe)[*filter_it])) {
-            matches->set(*filter_it, true);
+            matches->set(*filter_it);
           }
         }
         break;
@@ -979,7 +979,7 @@ TupleIdSequence* CompressedColumnStoreTupleStorageSubBlock::getCodesSatisfyingCo
              filter_it != filter->end();
              ++filter_it) {
           if (comp(code, static_cast<const uint32_t*>(attr_stripe)[*filter_it])) {
-            matches->set(*filter_it, true);
+            matches->set(*filter_it);
           }
         }
         break;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/storage/CompressedPackedRowStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/CompressedPackedRowStoreTupleStorageSubBlock.cpp b/storage/CompressedPackedRowStoreTupleStorageSubBlock.cpp
index d362f98..f087293 100644
--- a/storage/CompressedPackedRowStoreTupleStorageSubBlock.cpp
+++ b/storage/CompressedPackedRowStoreTupleStorageSubBlock.cpp
@@ -403,7 +403,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getNotEqualCodesE
              ++tid, attr_location += tuple_length_bytes_) {
           if ((code != *reinterpret_cast<const uint8_t*>(attr_location))
               && (null_code != *reinterpret_cast<const uint8_t*>(attr_location))) {
-            matches->set(tid, true);
+            matches->set(tid);
           }
         }
         break;
@@ -413,7 +413,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getNotEqualCodesE
              ++tid, attr_location += tuple_length_bytes_) {
           if ((code != *reinterpret_cast<const uint16_t*>(attr_location))
               && (null_code != *reinterpret_cast<const uint16_t*>(attr_location))) {
-            matches->set(tid, true);
+            matches->set(tid);
           }
         }
         break;
@@ -423,7 +423,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getNotEqualCodesE
              ++tid, attr_location += tuple_length_bytes_) {
           if ((code != *reinterpret_cast<const uint32_t*>(attr_location))
               && (null_code != *reinterpret_cast<const uint32_t*>(attr_location))) {
-            matches->set(tid, true);
+            matches->set(tid);
           }
         }
         break;
@@ -444,7 +444,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getNotEqualCodesE
           const void *local_attr_location = attr_location + (*filter_it) * tuple_length_bytes_;
           if ((code != *reinterpret_cast<const uint8_t*>(local_attr_location))
               && (null_code != *reinterpret_cast<const uint8_t*>(local_attr_location))) {
-            matches->set(*filter_it, true);
+            matches->set(*filter_it);
           }
         }
         break;
@@ -455,7 +455,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getNotEqualCodesE
           const void *local_attr_location = attr_location + (*filter_it) * tuple_length_bytes_;
           if ((code != *reinterpret_cast<const uint16_t*>(local_attr_location))
               && (null_code != *reinterpret_cast<const uint16_t*>(local_attr_location))) {
-            matches->set(*filter_it, true);
+            matches->set(*filter_it);
           }
         }
         break;
@@ -466,7 +466,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getNotEqualCodesE
           const void *local_attr_location = attr_location + (*filter_it) * tuple_length_bytes_;
           if ((code != *reinterpret_cast<const uint32_t*>(local_attr_location))
               && (null_code != *reinterpret_cast<const uint32_t*>(local_attr_location))) {
-            matches->set(*filter_it, true);
+            matches->set(*filter_it);
           }
         }
         break;
@@ -513,7 +513,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesInRange(
              ++tid, attr_location += tuple_length_bytes_) {
           if (range.first <= (*reinterpret_cast<const uint8_t*>(attr_location))
               && (*reinterpret_cast<const uint8_t*>(attr_location) < range.second)) {
-            matches->set(tid, true);
+            matches->set(tid);
           }
         }
         break;
@@ -523,7 +523,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesInRange(
              ++tid, attr_location += tuple_length_bytes_) {
           if (range.first <= (*reinterpret_cast<const uint16_t*>(attr_location))
               && (*reinterpret_cast<const uint16_t*>(attr_location) < range.second)) {
-            matches->set(tid, true);
+            matches->set(tid);
           }
         }
         break;
@@ -533,7 +533,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesInRange(
              ++tid, attr_location += tuple_length_bytes_) {
           if (range.first <= (*reinterpret_cast<const uint32_t*>(attr_location))
               && (*reinterpret_cast<const uint32_t*>(attr_location) < range.second)) {
-            matches->set(tid, true);
+            matches->set(tid);
           }
         }
         break;
@@ -554,7 +554,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesInRange(
           const void *local_attr_location = attr_location + (*filter_it) * tuple_length_bytes_;
           if (range.first <= (*reinterpret_cast<const uint8_t*>(local_attr_location))
               && (*reinterpret_cast<const uint8_t*>(local_attr_location) < range.second)) {
-            matches->set(*filter_it, true);
+            matches->set(*filter_it);
           }
         }
         break;
@@ -565,7 +565,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesInRange(
           const void *local_attr_location = attr_location + (*filter_it) * tuple_length_bytes_;
           if (range.first <= (*reinterpret_cast<const uint16_t*>(local_attr_location))
               && (*reinterpret_cast<const uint16_t*>(local_attr_location) < range.second)) {
-            matches->set(*filter_it, true);
+            matches->set(*filter_it);
           }
         }
         break;
@@ -576,7 +576,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesInRange(
           const void *local_attr_location = attr_location + (*filter_it) * tuple_length_bytes_;
           if (range.first <= (*reinterpret_cast<const uint32_t*>(local_attr_location))
               && (*reinterpret_cast<const uint32_t*>(local_attr_location) < range.second)) {
-            matches->set(*filter_it, true);
+            matches->set(*filter_it);
           }
         }
         break;
@@ -638,7 +638,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesSatisfyin
              tid < *static_cast<const tuple_id*>(sub_block_memory_);
              ++tid, attr_location += tuple_length_bytes_) {
           if (comp(code, *reinterpret_cast<const uint8_t*>(attr_location))) {
-            matches->set(tid, true);
+            matches->set(tid);
           }
         }
         break;
@@ -647,7 +647,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesSatisfyin
              tid < *static_cast<const tuple_id*>(sub_block_memory_);
              ++tid, attr_location += tuple_length_bytes_) {
           if (comp(code, *reinterpret_cast<const uint16_t*>(attr_location))) {
-            matches->set(tid, true);
+            matches->set(tid);
           }
         }
         break;
@@ -656,7 +656,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesSatisfyin
              tid < *static_cast<const tuple_id*>(sub_block_memory_);
              ++tid, attr_location += tuple_length_bytes_) {
           if (comp(code, *reinterpret_cast<const uint32_t*>(attr_location))) {
-            matches->set(tid, true);
+            matches->set(tid);
           }
         }
         break;
@@ -676,7 +676,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesSatisfyin
              ++filter_it) {
           const void *local_attr_location = attr_location + (*filter_it) * tuple_length_bytes_;
           if (comp(code, *reinterpret_cast<const uint8_t*>(local_attr_location))) {
-            matches->set(*filter_it, true);
+            matches->set(*filter_it);
           }
         }
         break;
@@ -686,7 +686,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesSatisfyin
              ++filter_it) {
           const void *local_attr_location = attr_location + (*filter_it) * tuple_length_bytes_;
           if (comp(code, *reinterpret_cast<const uint16_t*>(local_attr_location))) {
-            matches->set(*filter_it, true);
+            matches->set(*filter_it);
           }
         }
         break;
@@ -696,7 +696,7 @@ TupleIdSequence* CompressedPackedRowStoreTupleStorageSubBlock::getCodesSatisfyin
              ++filter_it) {
           const void *local_attr_location = attr_location + (*filter_it) * tuple_length_bytes_;
           if (comp(code, *reinterpret_cast<const uint32_t*>(local_attr_location))) {
-            matches->set(*filter_it, true);
+            matches->set(*filter_it);
           }
         }
         break;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/storage/InsertDestination.hpp
----------------------------------------------------------------------
diff --git a/storage/InsertDestination.hpp b/storage/InsertDestination.hpp
index a0a7bc2..ab791b1 100644
--- a/storage/InsertDestination.hpp
+++ b/storage/InsertDestination.hpp
@@ -646,7 +646,7 @@ class PartitionAwareInsertDestination : public InsertDestination {
 
     if (partition_attr_ids.empty()) {
       while (accessor->next()) {
-        (*partition_membership)[input_partition_id_]->set(accessor->getCurrentPosition(), true);
+        (*partition_membership)[input_partition_id_]->set(accessor->getCurrentPosition());
       }
     } else {
       PartitionSchemeHeader::PartitionValues values(partition_attr_ids.size());
@@ -655,7 +655,7 @@ class PartitionAwareInsertDestination : public InsertDestination {
           values[i] = accessor->getTypedValue(partition_attr_ids[i]);
         }
         (*partition_membership)[partition_scheme_header_->getPartitionId(values)]->set(
-            accessor->getCurrentPosition(), true);
+            accessor->getCurrentPosition());
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/storage/SMAIndexSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/SMAIndexSubBlock.cpp b/storage/SMAIndexSubBlock.cpp
index 3b3b879..81cf6c0 100644
--- a/storage/SMAIndexSubBlock.cpp
+++ b/storage/SMAIndexSubBlock.cpp
@@ -685,7 +685,7 @@ TupleIdSequence* SMAIndexSubBlock::getMatchesForPredicate(
       } else {
         for (tuple_id tid = 0; tid <= tuple_store_.getMaxTupleID(); ++tid) {
           if (tuple_store_.hasTupleWithID(tid)) {
-            tidseq->set(tid, true);
+            tidseq->set(tid);
           }
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/storage/StorageBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/StorageBlock.cpp b/storage/StorageBlock.cpp
index 31f1db2..e3e47d1 100644
--- a/storage/StorageBlock.cpp
+++ b/storage/StorageBlock.cpp
@@ -347,8 +347,7 @@ void StorageBlock::sample(const bool is_block_sample,
         sequence_mask->set(tuple_index_mapping.find(random_number) ==
                                    tuple_index_mapping.end()
                                ? random_number
-                               : tuple_index_mapping[random_number],
-                           true);
+                               : tuple_index_mapping[random_number]);
         tuple_index_mapping[random_number] = sequence->length() - (n + 1);
     }
 
@@ -461,7 +460,7 @@ StorageBlock::UpdateResult StorageBlock::update(
         tuple_store_->setAttributeValueInPlaceTyped(*match_it, update_it->first, update_it->second);
       }
 
-      in_place_ids.set(*match_it, true);
+      in_place_ids.set(*match_it);
     } else {
       // Make a copy of the tuple with the updated values.
       std::vector<TypedValue> updated_tuple_values;
@@ -479,7 +478,7 @@ StorageBlock::UpdateResult StorageBlock::update(
       }
 
       relocation_buffer.emplace_back(std::move(updated_tuple_values));
-      relocate_ids.set(*match_it, true);
+      relocate_ids.set(*match_it);
     }
   }
 
@@ -526,7 +525,7 @@ StorageBlock::UpdateResult StorageBlock::update(
             rebuild_all = true;
           } else {
             // Only bother adding 'reinsert_id' to 'in_place_ids' if not rebuilding.
-            in_place_ids.set(reinsert_result.inserted_id, true);
+            in_place_ids.set(reinsert_result.inserted_id);
           }
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/storage/TupleIdSequence.hpp
----------------------------------------------------------------------
diff --git a/storage/TupleIdSequence.hpp b/storage/TupleIdSequence.hpp
index 5047270..8c3a074 100644
--- a/storage/TupleIdSequence.hpp
+++ b/storage/TupleIdSequence.hpp
@@ -28,6 +28,8 @@
 #include "utility/BitVector.hpp"
 #include "utility/Macros.hpp"
 
+#include "glog/logging.h"
+
 namespace quickstep {
 
 /** \addtogroup Storage
@@ -155,6 +157,19 @@ class TupleIdSequence {
   }
 
   /**
+   * @brief Set a particular tuple ID as being on or off in this sequence.
+   *
+   * @param on If true, tuple should be part of this sequence. If false,
+   *        remove tuple from this sequence (if it was present).
+   **/
+  inline void set(const tuple_id tuple) {
+    DCHECK_GE(tuple, 0);
+    DCHECK_LT(static_cast<std::size_t>(tuple), internal_bitvector_.size());
+
+    internal_bitvector_.setBit(tuple);
+  }
+
+  /**
    * @brief Set a range of tuple IDs all at once.
    *
    * @param first_tuple The first ID to set.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/storage/TupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/TupleStorageSubBlock.cpp b/storage/TupleStorageSubBlock.cpp
index c5d482f..f2eef49 100644
--- a/storage/TupleStorageSubBlock.cpp
+++ b/storage/TupleStorageSubBlock.cpp
@@ -65,7 +65,7 @@ TupleIdSequence* TupleStorageSubBlock::getExistenceMap() const {
   } else {
     for (tuple_id tid = 0; tid <= max_tid; ++tid) {
       if (hasTupleWithID(tid)) {
-        existing_tuples->set(tid, true);
+        existing_tuples->set(tid);
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/utility/BitVector.hpp
----------------------------------------------------------------------
diff --git a/utility/BitVector.hpp b/utility/BitVector.hpp
index c404b7e..4472407 100644
--- a/utility/BitVector.hpp
+++ b/utility/BitVector.hpp
@@ -279,6 +279,18 @@ class BitVector {
   }
 
   /**
+   * @brief Set the value of a single bit.
+   *
+   * @param bit_num The desired bit in this BitVector.
+   **/
+  inline void setBit(const std::size_t bit_num) {
+    DCHECK(!short_version_) << "Not implemented.";
+    DCHECK_LT(bit_num, num_bits_);
+
+    setBitRegularVersion(bit_num);
+  }
+
+  /**
    * @brief Set the value of a range of bits simulaneously.
    *
    * @param start_bit_num The first bit whose value should be set.
@@ -918,6 +930,10 @@ class BitVector {
     data_array_[index_pos_in_data_array] |= op_value;
   }
 
+  inline void setBitRegularVersion(const std::size_t bit_num) {
+    data_array_[bit_num >> kHigherOrderShift] |= (TopBit<std::size_t>() >> (bit_num & kLowerOrderMask));
+  }
+
   template <typename VectorType>
   inline void setBitShortVersion(const std::size_t bit_num, bool value) {
     if (value) {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/utility/lip_filter/LIPFilterAdaptiveProber.hpp
----------------------------------------------------------------------
diff --git a/utility/lip_filter/LIPFilterAdaptiveProber.hpp b/utility/lip_filter/LIPFilterAdaptiveProber.hpp
index e1a75d6..fb826da 100644
--- a/utility/lip_filter/LIPFilterAdaptiveProber.hpp
+++ b/utility/lip_filter/LIPFilterAdaptiveProber.hpp
@@ -147,7 +147,7 @@ class LIPFilterAdaptiveProber {
 
       const std::uint32_t num_hits = filterBatch(accessor, &batch, batch_size);
       for (std::uint32_t i = 0; i < num_hits; ++i) {
-        matches->set(batch[i], true);
+        matches->set(batch[i]);
       }
 
       batch_start += batch_size;
@@ -181,7 +181,7 @@ class LIPFilterAdaptiveProber {
 
       const std::uint32_t num_hits = filterBatch(accessor, &batch, batch_size);
       for (std::uint32_t i = 0; i < num_hits; ++i) {
-        matches->set(batch[i], true);
+        matches->set(batch[i]);
       }
 
       num_tuples_left -= batch_size;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/69fd94b8/utility/tests/BitVector_unittest.cpp
----------------------------------------------------------------------
diff --git a/utility/tests/BitVector_unittest.cpp b/utility/tests/BitVector_unittest.cpp
index 774b830..053f405 100644
--- a/utility/tests/BitVector_unittest.cpp
+++ b/utility/tests/BitVector_unittest.cpp
@@ -357,14 +357,14 @@ TYPED_TEST(BitVectorTest, SetAndGetTest) {
   big_bit_vector->clear();
 
   // Set some bits, particularly around potential boundaries between size_t strides.
-  big_bit_vector->setBit(0, true);
-  big_bit_vector->setBit(5, true);
-  big_bit_vector->setBit(31, true);
-  big_bit_vector->setBit(32, true);
-  big_bit_vector->setBit(63, true);
-  big_bit_vector->setBit(64, true);
-  big_bit_vector->setBit(127, true);
-  big_bit_vector->setBit(128, true);
+  big_bit_vector->setBit(0);
+  big_bit_vector->setBit(5);
+  big_bit_vector->setBit(31);
+  big_bit_vector->setBit(32);
+  big_bit_vector->setBit(63);
+  big_bit_vector->setBit(64);
+  big_bit_vector->setBit(127);
+  big_bit_vector->setBit(128);
 
   for (size_t i = 0; i < TestFixture::kBigBitSize; ++i) {
     if ((i == 0) || (i == 5) || (i == 31) || (i == 32) || (i == 63) || (i == 64) || (i == 127) || (i == 128)) {
@@ -454,7 +454,7 @@ TYPED_TEST(BitVectorTest, SetAndGetTest) {
 
   // Set all the bits.
   for (size_t i = 0; i < TestFixture::kBigBitSize; ++i) {
-    big_bit_vector->setBit(i, true);
+    big_bit_vector->setBit(i);
   }
   EXPECT_EQ(TestFixture::kBigBitSize, big_bit_vector->onesCount());
   EXPECT_EQ(TestFixture::kBigBitSize, big_bit_vector->firstZero());
@@ -487,10 +487,10 @@ TYPED_TEST(BitVectorTest, AssignFromTest) {
   std::unique_ptr<TypeParam> big_bit_vector(this->createBitVector(TestFixture::kBigBitSize));
   big_bit_vector->clear();
 
-  big_bit_vector->setBit(2, true);
-  big_bit_vector->setBit(4, true);
-  big_bit_vector->setBit(42, true);
-  big_bit_vector->setBit(77, true);
+  big_bit_vector->setBit(2);
+  big_bit_vector->setBit(4);
+  big_bit_vector->setBit(42);
+  big_bit_vector->setBit(77);
 
   std::unique_ptr<TypeParam> big_bit_vector_copy(this->createBitVector(TestFixture::kBigBitSize));
   big_bit_vector_copy->assignFrom(*big_bit_vector);
@@ -693,14 +693,14 @@ TYPED_TEST(BitVectorTest, ShiftTailForwardTest) {
   std::unique_ptr<TypeParam> big_bit_vector(this->createBitVector(TestFixture::kBigBitSize));
   big_bit_vector->clear();
 
-  big_bit_vector->setBit(11, true);
-  big_bit_vector->setBit(13, true);
-  big_bit_vector->setBit(27, true);
-  big_bit_vector->setBit(42, true);
-  big_bit_vector->setBit(84, true);
-  big_bit_vector->setBit(88, true);
-  big_bit_vector->setBit(91, true);
-  big_bit_vector->setBit(123, true);
+  big_bit_vector->setBit(11);
+  big_bit_vector->setBit(13);
+  big_bit_vector->setBit(27);
+  big_bit_vector->setBit(42);
+  big_bit_vector->setBit(84);
+  big_bit_vector->setBit(88);
+  big_bit_vector->setBit(91);
+  big_bit_vector->setBit(123);
 
   big_bit_vector->shiftTailForward(15, 70);
   for (size_t i = 0; i < TestFixture::kBigBitSize; ++i) {
@@ -714,16 +714,16 @@ TYPED_TEST(BitVectorTest, ShiftTailForwardTest) {
 
   // Also try a relatively small shift within the same word.
   big_bit_vector->clear();
-  big_bit_vector->setBit(11, true);
-  big_bit_vector->setBit(13, true);
-  big_bit_vector->setBit(27, true);
-  big_bit_vector->setBit(42, true);
-  big_bit_vector->setBit(45, true);
-  big_bit_vector->setBit(51, true);
-  big_bit_vector->setBit(84, true);
-  big_bit_vector->setBit(88, true);
-  big_bit_vector->setBit(91, true);
-  big_bit_vector->setBit(123, true);
+  big_bit_vector->setBit(11);
+  big_bit_vector->setBit(13);
+  big_bit_vector->setBit(27);
+  big_bit_vector->setBit(42);
+  big_bit_vector->setBit(45);
+  big_bit_vector->setBit(51);
+  big_bit_vector->setBit(84);
+  big_bit_vector->setBit(88);
+  big_bit_vector->setBit(91);
+  big_bit_vector->setBit(123);
 
   big_bit_vector->shiftTailForward(43, 7);
   for (size_t i = 0; i < TestFixture::kBigBitSize; ++i) {
@@ -738,18 +738,18 @@ TYPED_TEST(BitVectorTest, ShiftTailForwardTest) {
 
   // Align the shift distance to size_t.
   big_bit_vector->clear();
-  big_bit_vector->setBit(11, true);
-  big_bit_vector->setBit(13, true);
-  big_bit_vector->setBit(27, true);
-  big_bit_vector->setBit(42, true);
-  big_bit_vector->setBit(45, true);
-  big_bit_vector->setBit(51, true);
-  big_bit_vector->setBit(84, true);
-  big_bit_vector->setBit(88, true);
-  big_bit_vector->setBit(91, true);
-  big_bit_vector->setBit(123, true);
-  big_bit_vector->setBit(128, true);
-  big_bit_vector->setBit(137, true);
+  big_bit_vector->setBit(11);
+  big_bit_vector->setBit(13);
+  big_bit_vector->setBit(27);
+  big_bit_vector->setBit(42);
+  big_bit_vector->setBit(45);
+  big_bit_vector->setBit(51);
+  big_bit_vector->setBit(84);
+  big_bit_vector->setBit(88);
+  big_bit_vector->setBit(91);
+  big_bit_vector->setBit(123);
+  big_bit_vector->setBit(128);
+  big_bit_vector->setBit(137);
 
   big_bit_vector->shiftTailForward(43, 64);
   for (size_t i = 0; i < TestFixture::kBigBitSize; ++i) {
@@ -764,18 +764,18 @@ TYPED_TEST(BitVectorTest, ShiftTailForwardTest) {
 
   // Exactly align both the tail start and the shift distance to size_t.
   big_bit_vector->clear();
-  big_bit_vector->setBit(11, true);
-  big_bit_vector->setBit(13, true);
-  big_bit_vector->setBit(27, true);
-  big_bit_vector->setBit(42, true);
-  big_bit_vector->setBit(45, true);
-  big_bit_vector->setBit(51, true);
-  big_bit_vector->setBit(84, true);
-  big_bit_vector->setBit(88, true);
-  big_bit_vector->setBit(91, true);
-  big_bit_vector->setBit(123, true);
-  big_bit_vector->setBit(128, true);
-  big_bit_vector->setBit(137, true);
+  big_bit_vector->setBit(11);
+  big_bit_vector->setBit(13);
+  big_bit_vector->setBit(27);
+  big_bit_vector->setBit(42);
+  big_bit_vector->setBit(45);
+  big_bit_vector->setBit(51);
+  big_bit_vector->setBit(84);
+  big_bit_vector->setBit(88);
+  big_bit_vector->setBit(91);
+  big_bit_vector->setBit(123);
+  big_bit_vector->setBit(128);
+  big_bit_vector->setBit(137);
 
   big_bit_vector->shiftTailForward(64, 64);
   for (size_t i = 0; i < TestFixture::kBigBitSize; ++i) {
@@ -867,14 +867,14 @@ TYPED_TEST(BitVectorTest, ShiftTailBackwardTest) {
   std::unique_ptr<TypeParam> big_bit_vector(this->createBitVector(TestFixture::kBigBitSize));
   big_bit_vector->clear();
 
-  big_bit_vector->setBit(11, true);
-  big_bit_vector->setBit(13, true);
-  big_bit_vector->setBit(27, true);
-  big_bit_vector->setBit(42, true);
-  big_bit_vector->setBit(84, true);
-  big_bit_vector->setBit(88, true);
-  big_bit_vector->setBit(91, true);
-  big_bit_vector->setBit(123, true);
+  big_bit_vector->setBit(11);
+  big_bit_vector->setBit(13);
+  big_bit_vector->setBit(27);
+  big_bit_vector->setBit(42);
+  big_bit_vector->setBit(84);
+  big_bit_vector->setBit(88);
+  big_bit_vector->setBit(91);
+  big_bit_vector->setBit(123);
 
   big_bit_vector->shiftTailBackward(15, 70);
   for (size_t i = 0; i < TestFixture::kBigBitSize; ++i) {
@@ -889,16 +889,16 @@ TYPED_TEST(BitVectorTest, ShiftTailBackwardTest) {
 
   // Also try a relatively small shift within the same word.
   big_bit_vector->clear();
-  big_bit_vector->setBit(11, true);
-  big_bit_vector->setBit(13, true);
-  big_bit_vector->setBit(27, true);
-  big_bit_vector->setBit(42, true);
-  big_bit_vector->setBit(45, true);
-  big_bit_vector->setBit(51, true);
-  big_bit_vector->setBit(84, true);
-  big_bit_vector->setBit(88, true);
-  big_bit_vector->setBit(91, true);
-  big_bit_vector->setBit(123, true);
+  big_bit_vector->setBit(11);
+  big_bit_vector->setBit(13);
+  big_bit_vector->setBit(27);
+  big_bit_vector->setBit(42);
+  big_bit_vector->setBit(45);
+  big_bit_vector->setBit(51);
+  big_bit_vector->setBit(84);
+  big_bit_vector->setBit(88);
+  big_bit_vector->setBit(91);
+  big_bit_vector->setBit(123);
 
   big_bit_vector->shiftTailBackward(43, 7);
   for (size_t i = 0; i < TestFixture::kBigBitSize; ++i) {
@@ -913,18 +913,18 @@ TYPED_TEST(BitVectorTest, ShiftTailBackwardTest) {
 
   // Align the shift distance to size_t.
   big_bit_vector->clear();
-  big_bit_vector->setBit(11, true);
-  big_bit_vector->setBit(13, true);
-  big_bit_vector->setBit(27, true);
-  big_bit_vector->setBit(42, true);
-  big_bit_vector->setBit(45, true);
-  big_bit_vector->setBit(51, true);
-  big_bit_vector->setBit(84, true);
-  big_bit_vector->setBit(88, true);
-  big_bit_vector->setBit(91, true);
-  big_bit_vector->setBit(123, true);
-  big_bit_vector->setBit(128, true);
-  big_bit_vector->setBit(137, true);
+  big_bit_vector->setBit(11);
+  big_bit_vector->setBit(13);
+  big_bit_vector->setBit(27);
+  big_bit_vector->setBit(42);
+  big_bit_vector->setBit(45);
+  big_bit_vector->setBit(51);
+  big_bit_vector->setBit(84);
+  big_bit_vector->setBit(88);
+  big_bit_vector->setBit(91);
+  big_bit_vector->setBit(123);
+  big_bit_vector->setBit(128);
+  big_bit_vector->setBit(137);
 
   big_bit_vector->shiftTailBackward(43, 64);
   for (size_t i = 0; i < TestFixture::kBigBitSize; ++i) {
@@ -940,18 +940,18 @@ TYPED_TEST(BitVectorTest, ShiftTailBackwardTest) {
 
   // Exactly align both the tail start and the shift distance to size_t.
   big_bit_vector->clear();
-  big_bit_vector->setBit(11, true);
-  big_bit_vector->setBit(13, true);
-  big_bit_vector->setBit(27, true);
-  big_bit_vector->setBit(42, true);
-  big_bit_vector->setBit(45, true);
-  big_bit_vector->setBit(51, true);
-  big_bit_vector->setBit(84, true);
-  big_bit_vector->setBit(88, true);
-  big_bit_vector->setBit(91, true);
-  big_bit_vector->setBit(123, true);
-  big_bit_vector->setBit(128, true);
-  big_bit_vector->setBit(137, true);
+  big_bit_vector->setBit(11);
+  big_bit_vector->setBit(13);
+  big_bit_vector->setBit(27);
+  big_bit_vector->setBit(42);
+  big_bit_vector->setBit(45);
+  big_bit_vector->setBit(51);
+  big_bit_vector->setBit(84);
+  big_bit_vector->setBit(88);
+  big_bit_vector->setBit(91);
+  big_bit_vector->setBit(123);
+  big_bit_vector->setBit(128);
+  big_bit_vector->setBit(137);
 
   big_bit_vector->shiftTailBackward(64, 64);
   for (size_t i = 0; i < TestFixture::kBigBitSize; ++i) {
@@ -1027,14 +1027,14 @@ TYPED_TEST(BitVectorTest, RebindTest) {
 
   // Set some bits, particularly around potential boundaries between size_t
   // strides.
-  big_bit_vector->setBit(0, true);
-  big_bit_vector->setBit(5, true);
-  big_bit_vector->setBit(31, true);
-  big_bit_vector->setBit(32, true);
-  big_bit_vector->setBit(63, true);
-  big_bit_vector->setBit(64, true);
-  big_bit_vector->setBit(127, true);
-  big_bit_vector->setBit(128, true);
+  big_bit_vector->setBit(0);
+  big_bit_vector->setBit(5);
+  big_bit_vector->setBit(31);
+  big_bit_vector->setBit(32);
+  big_bit_vector->setBit(63);
+  big_bit_vector->setBit(64);
+  big_bit_vector->setBit(127);
+  big_bit_vector->setBit(128);
 
   // Destroy the old BitVector and create a new one bound to the same memory.
   ASSERT_EQ(1u, this->allocated_chunks_.size());
@@ -1093,19 +1093,19 @@ TYPED_TEST(BitVectorTest, AnyTest) {
   big_bit_vector->clear();
   EXPECT_FALSE(big_bit_vector->any());
 
-  big_bit_vector->setBit(0, true);
+  big_bit_vector->setBit(0);
   EXPECT_TRUE(big_bit_vector->any());
   big_bit_vector->setBit(0, false);
   EXPECT_FALSE(big_bit_vector->any());
 
-  big_bit_vector->setBit(TestFixture::kBigBitSize - 1, true);
+  big_bit_vector->setBit(TestFixture::kBigBitSize - 1);
   EXPECT_TRUE(big_bit_vector->any());
   big_bit_vector->setBit(TestFixture::kBigBitSize - 1, false);
   EXPECT_FALSE(big_bit_vector->any());
 
-  big_bit_vector->setBit(TestFixture::kBigBitSize / 2, true);
+  big_bit_vector->setBit(TestFixture::kBigBitSize / 2);
   EXPECT_TRUE(big_bit_vector->any());
-  big_bit_vector->setBit(TestFixture::kBigBitSize / 2 + 1, true);
+  big_bit_vector->setBit(TestFixture::kBigBitSize / 2 + 1);
   EXPECT_TRUE(big_bit_vector->any());
   big_bit_vector->setBit(TestFixture::kBigBitSize / 2, false);
   EXPECT_TRUE(big_bit_vector->any());
@@ -1150,21 +1150,21 @@ TYPED_TEST(BitVectorTest, AllTest) {
 
   big_bit_vector->setBit(0, false);
   EXPECT_FALSE(big_bit_vector->all());
-  big_bit_vector->setBit(0, true);
+  big_bit_vector->setBit(0);
   EXPECT_TRUE(big_bit_vector->all());
 
   big_bit_vector->setBit(TestFixture::kBigBitSize - 1, false);
   EXPECT_FALSE(big_bit_vector->all());
-  big_bit_vector->setBit(TestFixture::kBigBitSize - 1, true);
+  big_bit_vector->setBit(TestFixture::kBigBitSize - 1);
   EXPECT_TRUE(big_bit_vector->all());
 
   big_bit_vector->setBit(TestFixture::kBigBitSize / 2, false);
   EXPECT_FALSE(big_bit_vector->all());
   big_bit_vector->setBit(TestFixture::kBigBitSize / 2 + 1, false);
   EXPECT_FALSE(big_bit_vector->all());
-  big_bit_vector->setBit(TestFixture::kBigBitSize / 2, true);
+  big_bit_vector->setBit(TestFixture::kBigBitSize / 2);
   EXPECT_FALSE(big_bit_vector->all());
-  big_bit_vector->setBit(TestFixture::kBigBitSize / 2 + 1, true);
+  big_bit_vector->setBit(TestFixture::kBigBitSize / 2 + 1);
   EXPECT_TRUE(big_bit_vector->all());
 }
 



[28/46] incubator-quickstep git commit: Remove glog source code from third party

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/logging.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/logging.cc b/third_party/src/glog/src/windows/logging.cc
deleted file mode 100644
index 5c09a66..0000000
--- a/third_party/src/glog/src/windows/logging.cc
+++ /dev/null
@@ -1,2050 +0,0 @@
-// Copyright (c) 1999, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#define _GNU_SOURCE 1 // needed for O_NOFOLLOW and pread()/pwrite()
-
-#include "utilities.h"
-
-#include <assert.h>
-#include <algorithm>
-#include <iomanip>
-#include <string>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>  // For _exit.
-#endif
-#include <climits>
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef HAVE_SYS_UTSNAME_H
-# include <sys/utsname.h>  // For uname.
-#endif
-#include <fcntl.h>
-#include <cstdio>
-#include <iostream>
-#include <stdarg.h>
-#include <stdlib.h>
-#ifdef HAVE_PWD_H
-# include <pwd.h>
-#endif
-#ifdef HAVE_SYSLOG_H
-# include <syslog.h>
-#endif
-#include <vector>
-#include <errno.h>                   // for errno
-#include <sstream>
-#include "base/commandlineflags.h"        // to get the program name
-#include "glog/logging.h"
-#include "glog/raw_logging.h"
-#include "base/googleinit.h"
-
-#ifdef HAVE_STACKTRACE
-# include "stacktrace.h"
-#endif
-
-using std::string;
-using std::vector;
-using std::setw;
-using std::setfill;
-using std::hex;
-using std::dec;
-using std::min;
-using std::ostream;
-using std::ostringstream;
-
-using std::FILE;
-using std::fwrite;
-using std::fclose;
-using std::fflush;
-using std::fprintf;
-using std::perror;
-
-#ifdef __QNX__
-using std::fdopen;
-#endif
-
-// There is no thread annotation support.
-#define EXCLUSIVE_LOCKS_REQUIRED(mu)
-
-static bool BoolFromEnv(const char *varname, bool defval) {
-  const char* const valstr = getenv(varname);
-  if (!valstr) {
-    return defval;
-  }
-  return memchr("tTyY1\0", valstr[0], 6) != NULL;
-}
-
-GLOG_DEFINE_bool(logtostderr, BoolFromEnv("GOOGLE_LOGTOSTDERR", false),
-                 "log messages go to stderr instead of logfiles");
-GLOG_DEFINE_bool(alsologtostderr, BoolFromEnv("GOOGLE_ALSOLOGTOSTDERR", false),
-                 "log messages go to stderr in addition to logfiles");
-GLOG_DEFINE_bool(colorlogtostderr, false,
-                 "color messages logged to stderr (if supported by terminal)");
-#ifdef OS_LINUX
-GLOG_DEFINE_bool(drop_log_memory, true, "Drop in-memory buffers of log contents. "
-                 "Logs can grow very quickly and they are rarely read before they "
-                 "need to be evicted from memory. Instead, drop them from memory "
-                 "as soon as they are flushed to disk.");
-_START_GOOGLE_NAMESPACE_
-namespace logging {
-static const int64 kPageSize = getpagesize();
-}
-_END_GOOGLE_NAMESPACE_
-#endif
-
-// By default, errors (including fatal errors) get logged to stderr as
-// well as the file.
-//
-// The default is ERROR instead of FATAL so that users can see problems
-// when they run a program without having to look in another file.
-DEFINE_int32(stderrthreshold,
-             GOOGLE_NAMESPACE::GLOG_ERROR,
-             "log messages at or above this level are copied to stderr in "
-             "addition to logfiles.  This flag obsoletes --alsologtostderr.");
-
-GLOG_DEFINE_string(alsologtoemail, "",
-                   "log messages go to these email addresses "
-                   "in addition to logfiles");
-GLOG_DEFINE_bool(log_prefix, true,
-                 "Prepend the log prefix to the start of each log line");
-GLOG_DEFINE_int32(minloglevel, 0, "Messages logged at a lower level than this don't "
-                  "actually get logged anywhere");
-GLOG_DEFINE_int32(logbuflevel, 0,
-                  "Buffer log messages logged at this level or lower"
-                  " (-1 means don't buffer; 0 means buffer INFO only;"
-                  " ...)");
-GLOG_DEFINE_int32(logbufsecs, 30,
-                  "Buffer log messages for at most this many seconds");
-GLOG_DEFINE_int32(logemaillevel, 999,
-                  "Email log messages logged at this level or higher"
-                  " (0 means email all; 3 means email FATAL only;"
-                  " ...)");
-GLOG_DEFINE_string(logmailer, "/bin/mail",
-                   "Mailer used to send logging email");
-
-// Compute the default value for --log_dir
-static const char* DefaultLogDir() {
-  const char* env;
-  env = getenv("GOOGLE_LOG_DIR");
-  if (env != NULL && env[0] != '\0') {
-    return env;
-  }
-  env = getenv("TEST_TMPDIR");
-  if (env != NULL && env[0] != '\0') {
-    return env;
-  }
-  return "";
-}
-
-GLOG_DEFINE_string(log_dir, DefaultLogDir(),
-                   "If specified, logfiles are written into this directory instead "
-                   "of the default logging directory.");
-GLOG_DEFINE_string(log_link, "", "Put additional links to the log "
-                   "files in this directory");
-
-GLOG_DEFINE_int32(max_log_size, 1800,
-                  "approx. maximum log file size (in MB). A value of 0 will "
-                  "be silently overridden to 1.");
-
-GLOG_DEFINE_bool(stop_logging_if_full_disk, false,
-                 "Stop attempting to log to disk if the disk is full.");
-
-GLOG_DEFINE_string(log_backtrace_at, "",
-                   "Emit a backtrace when logging at file:linenum.");
-
-// TODO(hamaji): consider windows
-#define PATH_SEPARATOR '/'
-
-static void GetHostName(string* hostname) {
-#if defined(HAVE_SYS_UTSNAME_H)
-  struct utsname buf;
-  if (0 != uname(&buf)) {
-    // ensure null termination on failure
-    *buf.nodename = '\0';
-  }
-  *hostname = buf.nodename;
-#elif defined(OS_WINDOWS)
-  char buf[MAX_COMPUTERNAME_LENGTH + 1];
-  DWORD len = MAX_COMPUTERNAME_LENGTH + 1;
-  if (GetComputerNameA(buf, &len)) {
-    *hostname = buf;
-  } else {
-    hostname->clear();
-  }
-#else
-# warning There is no way to retrieve the host name.
-  *hostname = "(unknown)";
-#endif
-}
-
-// Returns true iff terminal supports using colors in output.
-static bool TerminalSupportsColor() {
-  bool term_supports_color = false;
-#ifdef OS_WINDOWS
-  // on Windows TERM variable is usually not set, but the console does
-  // support colors.
-  term_supports_color = true;
-#else
-  // On non-Windows platforms, we rely on the TERM variable.
-  const char* const term = getenv("TERM");
-  if (term != NULL && term[0] != '\0') {
-    term_supports_color =
-      !strcmp(term, "xterm") ||
-      !strcmp(term, "xterm-color") ||
-      !strcmp(term, "xterm-256color") ||
-      !strcmp(term, "screen") ||
-      !strcmp(term, "linux") ||
-      !strcmp(term, "cygwin");
-  }
-#endif
-  return term_supports_color;
-}
-
-_START_GOOGLE_NAMESPACE_
-
-enum GLogColor {
-  COLOR_DEFAULT,
-  COLOR_RED,
-  COLOR_GREEN,
-  COLOR_YELLOW
-};
-
-static GLogColor SeverityToColor(LogSeverity severity) {
-  assert(severity >= 0 && severity < NUM_SEVERITIES);
-  GLogColor color = COLOR_DEFAULT;
-  switch (severity) {
-  case GLOG_INFO:
-    color = COLOR_DEFAULT;
-    break;
-  case GLOG_WARNING:
-    color = COLOR_YELLOW;
-    break;
-  case GLOG_ERROR:
-  case GLOG_FATAL:
-    color = COLOR_RED;
-    break;
-  default:
-    // should never get here.
-    assert(false);
-  }
-  return color;
-}
-
-#ifdef OS_WINDOWS
-
-// Returns the character attribute for the given color.
-WORD GetColorAttribute(GLogColor color) {
-  switch (color) {
-    case COLOR_RED:    return FOREGROUND_RED;
-    case COLOR_GREEN:  return FOREGROUND_GREEN;
-    case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN;
-    default:           return 0;
-  }
-}
-
-#else
-
-// Returns the ANSI color code for the given color.
-const char* GetAnsiColorCode(GLogColor color) {
-  switch (color) {
-  case COLOR_RED:     return "1";
-  case COLOR_GREEN:   return "2";
-  case COLOR_YELLOW:  return "3";
-  case COLOR_DEFAULT:  return "";
-  };
-  return NULL; // stop warning about return type.
-}
-
-#endif  // OS_WINDOWS
-
-// Safely get max_log_size, overriding to 1 if it somehow gets defined as 0
-static int32 MaxLogSize() {
-  return (FLAGS_max_log_size > 0 ? FLAGS_max_log_size : 1);
-}
-
-struct LogMessage::LogMessageData  {
-  LogMessageData() {};
-
-  int preserved_errno_;      // preserved errno
-  char* buf_;                   // buffer space for non FATAL messages
-  char* message_text_;  // Complete message text (points to selected buffer)
-  LogStream* stream_alloc_;
-  LogStream* stream_;
-  char severity_;      // What level is this LogMessage logged at?
-  int line_;                 // line number where logging call is.
-  void (LogMessage::*send_method_)();  // Call this in destructor to send
-  union {  // At most one of these is used: union to keep the size low.
-    LogSink* sink_;             // NULL or sink to send message to
-    std::vector<std::string>* outvec_; // NULL or vector to push message onto
-    std::string* message_;             // NULL or string to write message into
-  };
-  time_t timestamp_;            // Time of creation of LogMessage
-  struct ::tm tm_time_;         // Time of creation of LogMessage
-  size_t num_prefix_chars_;     // # of chars of prefix in this message
-  size_t num_chars_to_log_;     // # of chars of msg to send to log
-  size_t num_chars_to_syslog_;  // # of chars of msg to send to syslog
-  const char* basename_;        // basename of file that called LOG
-  const char* fullname_;        // fullname of file that called LOG
-  bool has_been_flushed_;       // false => data has not been flushed
-  bool first_fatal_;            // true => this was first fatal msg
-
-  ~LogMessageData();
-
- private:
-  LogMessageData(const LogMessageData&);
-  void operator=(const LogMessageData&);
-};
-
-// A mutex that allows only one thread to log at a time, to keep things from
-// getting jumbled.  Some other very uncommon logging operations (like
-// changing the destination file for log messages of a given severity) also
-// lock this mutex.  Please be sure that anybody who might possibly need to
-// lock it does so.
-static Mutex log_mutex;
-
-// Number of messages sent at each severity.  Under log_mutex.
-int64 LogMessage::num_messages_[NUM_SEVERITIES] = {0, 0, 0, 0};
-
-// Globally disable log writing (if disk is full)
-static bool stop_writing = false;
-
-const char*const LogSeverityNames[NUM_SEVERITIES] = {
-  "INFO", "WARNING", "ERROR", "FATAL"
-};
-
-// Has the user called SetExitOnDFatal(true)?
-static bool exit_on_dfatal = true;
-
-const char* GetLogSeverityName(LogSeverity severity) {
-  return LogSeverityNames[severity];
-}
-
-static bool SendEmailInternal(const char*dest, const char *subject,
-                              const char*body, bool use_logging);
-
-base::Logger::~Logger() {
-}
-
-namespace {
-
-// Encapsulates all file-system related state
-class LogFileObject : public base::Logger {
- public:
-  LogFileObject(LogSeverity severity, const char* base_filename);
-  ~LogFileObject();
-
-  virtual void Write(bool force_flush, // Should we force a flush here?
-                     time_t timestamp,  // Timestamp for this entry
-                     const char* message,
-                     int message_len);
-
-  // Configuration options
-  void SetBasename(const char* basename);
-  void SetExtension(const char* ext);
-  void SetSymlinkBasename(const char* symlink_basename);
-
-  // Normal flushing routine
-  virtual void Flush();
-
-  // It is the actual file length for the system loggers,
-  // i.e., INFO, ERROR, etc.
-  virtual uint32 LogSize() {
-    MutexLock l(&lock_);
-    return file_length_;
-  }
-
-  // Internal flush routine.  Exposed so that FlushLogFilesUnsafe()
-  // can avoid grabbing a lock.  Usually Flush() calls it after
-  // acquiring lock_.
-  void FlushUnlocked();
-
- private:
-  static const uint32 kRolloverAttemptFrequency = 0x20;
-
-  Mutex lock_;
-  bool base_filename_selected_;
-  string base_filename_;
-  string symlink_basename_;
-  string filename_extension_;     // option users can specify (eg to add port#)
-  FILE* file_;
-  LogSeverity severity_;
-  uint32 bytes_since_flush_;
-  uint32 file_length_;
-  unsigned int rollover_attempt_;
-  int64 next_flush_time_;         // cycle count at which to flush log
-
-  // Actually create a logfile using the value of base_filename_ and the
-  // supplied argument time_pid_string
-  // REQUIRES: lock_ is held
-  bool CreateLogfile(const string& time_pid_string);
-};
-
-}  // namespace
-
-class LogDestination {
- public:
-  friend class LogMessage;
-  friend void ReprintFatalMessage();
-  friend base::Logger* base::GetLogger(LogSeverity);
-  friend void base::SetLogger(LogSeverity, base::Logger*);
-
-  // These methods are just forwarded to by their global versions.
-  static void SetLogDestination(LogSeverity severity,
-				const char* base_filename);
-  static void SetLogSymlink(LogSeverity severity,
-                            const char* symlink_basename);
-  static void AddLogSink(LogSink *destination);
-  static void RemoveLogSink(LogSink *destination);
-  static void SetLogFilenameExtension(const char* filename_extension);
-  static void SetStderrLogging(LogSeverity min_severity);
-  static void SetEmailLogging(LogSeverity min_severity, const char* addresses);
-  static void LogToStderr();
-  // Flush all log files that are at least at the given severity level
-  static void FlushLogFiles(int min_severity);
-  static void FlushLogFilesUnsafe(int min_severity);
-
-  // we set the maximum size of our packet to be 1400, the logic being
-  // to prevent fragmentation.
-  // Really this number is arbitrary.
-  static const int kNetworkBytes = 1400;
-
-  static const string& hostname();
-  static const bool& terminal_supports_color() {
-    return terminal_supports_color_;
-  }
-
-  static void DeleteLogDestinations();
-
- private:
-  LogDestination(LogSeverity severity, const char* base_filename);
-  ~LogDestination() { }
-
-  // Take a log message of a particular severity and log it to stderr
-  // iff it's of a high enough severity to deserve it.
-  static void MaybeLogToStderr(LogSeverity severity, const char* message,
-			       size_t len);
-
-  // Take a log message of a particular severity and log it to email
-  // iff it's of a high enough severity to deserve it.
-  static void MaybeLogToEmail(LogSeverity severity, const char* message,
-			      size_t len);
-  // Take a log message of a particular severity and log it to a file
-  // iff the base filename is not "" (which means "don't log to me")
-  static void MaybeLogToLogfile(LogSeverity severity,
-                                time_t timestamp,
-				const char* message, size_t len);
-  // Take a log message of a particular severity and log it to the file
-  // for that severity and also for all files with severity less than
-  // this severity.
-  static void LogToAllLogfiles(LogSeverity severity,
-                               time_t timestamp,
-                               const char* message, size_t len);
-
-  // Send logging info to all registered sinks.
-  static void LogToSinks(LogSeverity severity,
-                         const char *full_filename,
-                         const char *base_filename,
-                         int line,
-                         const struct ::tm* tm_time,
-                         const char* message,
-                         size_t message_len);
-
-  // Wait for all registered sinks via WaitTillSent
-  // including the optional one in "data".
-  static void WaitForSinks(LogMessage::LogMessageData* data);
-
-  static LogDestination* log_destination(LogSeverity severity);
-
-  LogFileObject fileobject_;
-  base::Logger* logger_;      // Either &fileobject_, or wrapper around it
-
-  static LogDestination* log_destinations_[NUM_SEVERITIES];
-  static LogSeverity email_logging_severity_;
-  static string addresses_;
-  static string hostname_;
-  static bool terminal_supports_color_;
-
-  // arbitrary global logging destinations.
-  static vector<LogSink*>* sinks_;
-
-  // Protects the vector sinks_,
-  // but not the LogSink objects its elements reference.
-  static Mutex sink_mutex_;
-
-  // Disallow
-  LogDestination(const LogDestination&);
-  LogDestination& operator=(const LogDestination&);
-};
-
-// Errors do not get logged to email by default.
-LogSeverity LogDestination::email_logging_severity_ = 99999;
-
-string LogDestination::addresses_;
-string LogDestination::hostname_;
-
-vector<LogSink*>* LogDestination::sinks_ = NULL;
-Mutex LogDestination::sink_mutex_;
-bool LogDestination::terminal_supports_color_ = TerminalSupportsColor();
-
-/* static */
-const string& LogDestination::hostname() {
-  if (hostname_.empty()) {
-    GetHostName(&hostname_);
-    if (hostname_.empty()) {
-      hostname_ = "(unknown)";
-    }
-  }
-  return hostname_;
-}
-
-LogDestination::LogDestination(LogSeverity severity,
-                               const char* base_filename)
-  : fileobject_(severity, base_filename),
-    logger_(&fileobject_) {
-}
-
-inline void LogDestination::FlushLogFilesUnsafe(int min_severity) {
-  // assume we have the log_mutex or we simply don't care
-  // about it
-  for (int i = min_severity; i < NUM_SEVERITIES; i++) {
-    LogDestination* log = log_destination(i);
-    if (log != NULL) {
-      // Flush the base fileobject_ logger directly instead of going
-      // through any wrappers to reduce chance of deadlock.
-      log->fileobject_.FlushUnlocked();
-    }
-  }
-}
-
-inline void LogDestination::FlushLogFiles(int min_severity) {
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  for (int i = min_severity; i < NUM_SEVERITIES; i++) {
-    LogDestination* log = log_destination(i);
-    if (log != NULL) {
-      log->logger_->Flush();
-    }
-  }
-}
-
-inline void LogDestination::SetLogDestination(LogSeverity severity,
-					      const char* base_filename) {
-  assert(severity >= 0 && severity < NUM_SEVERITIES);
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  log_destination(severity)->fileobject_.SetBasename(base_filename);
-}
-
-inline void LogDestination::SetLogSymlink(LogSeverity severity,
-                                          const char* symlink_basename) {
-  CHECK_GE(severity, 0);
-  CHECK_LT(severity, NUM_SEVERITIES);
-  MutexLock l(&log_mutex);
-  log_destination(severity)->fileobject_.SetSymlinkBasename(symlink_basename);
-}
-
-inline void LogDestination::AddLogSink(LogSink *destination) {
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&sink_mutex_);
-  if (!sinks_)  sinks_ = new vector<LogSink*>;
-  sinks_->push_back(destination);
-}
-
-inline void LogDestination::RemoveLogSink(LogSink *destination) {
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&sink_mutex_);
-  // This doesn't keep the sinks in order, but who cares?
-  if (sinks_) {
-    for (int i = sinks_->size() - 1; i >= 0; i--) {
-      if ((*sinks_)[i] == destination) {
-        (*sinks_)[i] = (*sinks_)[sinks_->size() - 1];
-        sinks_->pop_back();
-        break;
-      }
-    }
-  }
-}
-
-inline void LogDestination::SetLogFilenameExtension(const char* ext) {
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  for ( int severity = 0; severity < NUM_SEVERITIES; ++severity ) {
-    log_destination(severity)->fileobject_.SetExtension(ext);
-  }
-}
-
-inline void LogDestination::SetStderrLogging(LogSeverity min_severity) {
-  assert(min_severity >= 0 && min_severity < NUM_SEVERITIES);
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  FLAGS_stderrthreshold = min_severity;
-}
-
-inline void LogDestination::LogToStderr() {
-  // *Don't* put this stuff in a mutex lock, since SetStderrLogging &
-  // SetLogDestination already do the locking!
-  SetStderrLogging(0);            // thus everything is "also" logged to stderr
-  for ( int i = 0; i < NUM_SEVERITIES; ++i ) {
-    SetLogDestination(i, "");     // "" turns off logging to a logfile
-  }
-}
-
-inline void LogDestination::SetEmailLogging(LogSeverity min_severity,
-					    const char* addresses) {
-  assert(min_severity >= 0 && min_severity < NUM_SEVERITIES);
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  LogDestination::email_logging_severity_ = min_severity;
-  LogDestination::addresses_ = addresses;
-}
-
-static void ColoredWriteToStderr(LogSeverity severity,
-                                 const char* message, size_t len) {
-  const GLogColor color =
-      (LogDestination::terminal_supports_color() && FLAGS_colorlogtostderr) ?
-      SeverityToColor(severity) : COLOR_DEFAULT;
-
-  // Avoid using cerr from this module since we may get called during
-  // exit code, and cerr may be partially or fully destroyed by then.
-  if (COLOR_DEFAULT == color) {
-    fwrite(message, len, 1, stderr);
-    return;
-  }
-#ifdef OS_WINDOWS
-  const HANDLE stderr_handle = GetStdHandle(STD_ERROR_HANDLE);
-
-  // Gets the current text color.
-  CONSOLE_SCREEN_BUFFER_INFO buffer_info;
-  GetConsoleScreenBufferInfo(stderr_handle, &buffer_info);
-  const WORD old_color_attrs = buffer_info.wAttributes;
-
-  // We need to flush the stream buffers into the console before each
-  // SetConsoleTextAttribute call lest it affect the text that is already
-  // printed but has not yet reached the console.
-  fflush(stderr);
-  SetConsoleTextAttribute(stderr_handle,
-                          GetColorAttribute(color) | FOREGROUND_INTENSITY);
-  fwrite(message, len, 1, stderr);
-  fflush(stderr);
-  // Restores the text color.
-  SetConsoleTextAttribute(stderr_handle, old_color_attrs);
-#else
-  fprintf(stderr, "\033[0;3%sm", GetAnsiColorCode(color));
-  fwrite(message, len, 1, stderr);
-  fprintf(stderr, "\033[m");  // Resets the terminal to default.
-#endif  // OS_WINDOWS
-}
-
-static void WriteToStderr(const char* message, size_t len) {
-  // Avoid using cerr from this module since we may get called during
-  // exit code, and cerr may be partially or fully destroyed by then.
-  fwrite(message, len, 1, stderr);
-}
-
-inline void LogDestination::MaybeLogToStderr(LogSeverity severity,
-					     const char* message, size_t len) {
-  if ((severity >= FLAGS_stderrthreshold) || FLAGS_alsologtostderr) {
-    ColoredWriteToStderr(severity, message, len);
-#ifdef OS_WINDOWS
-    // On Windows, also output to the debugger
-    ::OutputDebugStringA(string(message,len).c_str());
-#endif
-  }
-}
-
-
-inline void LogDestination::MaybeLogToEmail(LogSeverity severity,
-					    const char* message, size_t len) {
-  if (severity >= email_logging_severity_ ||
-      severity >= FLAGS_logemaillevel) {
-    string to(FLAGS_alsologtoemail);
-    if (!addresses_.empty()) {
-      if (!to.empty()) {
-        to += ",";
-      }
-      to += addresses_;
-    }
-    const string subject(string("[LOG] ") + LogSeverityNames[severity] + ": " +
-                         glog_internal_namespace_::ProgramInvocationShortName());
-    string body(hostname());
-    body += "\n\n";
-    body.append(message, len);
-
-    // should NOT use SendEmail().  The caller of this function holds the
-    // log_mutex and SendEmail() calls LOG/VLOG which will block trying to
-    // acquire the log_mutex object.  Use SendEmailInternal() and set
-    // use_logging to false.
-    SendEmailInternal(to.c_str(), subject.c_str(), body.c_str(), false);
-  }
-}
-
-
-inline void LogDestination::MaybeLogToLogfile(LogSeverity severity,
-                                              time_t timestamp,
-					      const char* message,
-					      size_t len) {
-  const bool should_flush = severity > FLAGS_logbuflevel;
-  LogDestination* destination = log_destination(severity);
-  destination->logger_->Write(should_flush, timestamp, message, len);
-}
-
-inline void LogDestination::LogToAllLogfiles(LogSeverity severity,
-                                             time_t timestamp,
-                                             const char* message,
-                                             size_t len) {
-
-  if ( FLAGS_logtostderr ) {           // global flag: never log to file
-    ColoredWriteToStderr(severity, message, len);
-  } else {
-    for (int i = severity; i >= 0; --i)
-      LogDestination::MaybeLogToLogfile(i, timestamp, message, len);
-  }
-}
-
-inline void LogDestination::LogToSinks(LogSeverity severity,
-                                       const char *full_filename,
-                                       const char *base_filename,
-                                       int line,
-                                       const struct ::tm* tm_time,
-                                       const char* message,
-                                       size_t message_len) {
-  ReaderMutexLock l(&sink_mutex_);
-  if (sinks_) {
-    for (int i = sinks_->size() - 1; i >= 0; i--) {
-      (*sinks_)[i]->send(severity, full_filename, base_filename,
-                         line, tm_time, message, message_len);
-    }
-  }
-}
-
-inline void LogDestination::WaitForSinks(LogMessage::LogMessageData* data) {
-  ReaderMutexLock l(&sink_mutex_);
-  if (sinks_) {
-    for (int i = sinks_->size() - 1; i >= 0; i--) {
-      (*sinks_)[i]->WaitTillSent();
-    }
-  }
-  const bool send_to_sink =
-      (data->send_method_ == &LogMessage::SendToSink) ||
-      (data->send_method_ == &LogMessage::SendToSinkAndLog);
-  if (send_to_sink && data->sink_ != NULL) {
-    data->sink_->WaitTillSent();
-  }
-}
-
-LogDestination* LogDestination::log_destinations_[NUM_SEVERITIES];
-
-inline LogDestination* LogDestination::log_destination(LogSeverity severity) {
-  assert(severity >=0 && severity < NUM_SEVERITIES);
-  if (!log_destinations_[severity]) {
-    log_destinations_[severity] = new LogDestination(severity, NULL);
-  }
-  return log_destinations_[severity];
-}
-
-void LogDestination::DeleteLogDestinations() {
-  for (int severity = 0; severity < NUM_SEVERITIES; ++severity) {
-    delete log_destinations_[severity];
-    log_destinations_[severity] = NULL;
-  }
-}
-
-namespace {
-
-LogFileObject::LogFileObject(LogSeverity severity,
-                             const char* base_filename)
-  : base_filename_selected_(base_filename != NULL),
-    base_filename_((base_filename != NULL) ? base_filename : ""),
-    symlink_basename_(glog_internal_namespace_::ProgramInvocationShortName()),
-    filename_extension_(),
-    file_(NULL),
-    severity_(severity),
-    bytes_since_flush_(0),
-    file_length_(0),
-    rollover_attempt_(kRolloverAttemptFrequency-1),
-    next_flush_time_(0) {
-  assert(severity >= 0);
-  assert(severity < NUM_SEVERITIES);
-}
-
-LogFileObject::~LogFileObject() {
-  MutexLock l(&lock_);
-  if (file_ != NULL) {
-    fclose(file_);
-    file_ = NULL;
-  }
-}
-
-void LogFileObject::SetBasename(const char* basename) {
-  MutexLock l(&lock_);
-  base_filename_selected_ = true;
-  if (base_filename_ != basename) {
-    // Get rid of old log file since we are changing names
-    if (file_ != NULL) {
-      fclose(file_);
-      file_ = NULL;
-      rollover_attempt_ = kRolloverAttemptFrequency-1;
-    }
-    base_filename_ = basename;
-  }
-}
-
-void LogFileObject::SetExtension(const char* ext) {
-  MutexLock l(&lock_);
-  if (filename_extension_ != ext) {
-    // Get rid of old log file since we are changing names
-    if (file_ != NULL) {
-      fclose(file_);
-      file_ = NULL;
-      rollover_attempt_ = kRolloverAttemptFrequency-1;
-    }
-    filename_extension_ = ext;
-  }
-}
-
-void LogFileObject::SetSymlinkBasename(const char* symlink_basename) {
-  MutexLock l(&lock_);
-  symlink_basename_ = symlink_basename;
-}
-
-void LogFileObject::Flush() {
-  MutexLock l(&lock_);
-  FlushUnlocked();
-}
-
-void LogFileObject::FlushUnlocked(){
-  if (file_ != NULL) {
-    fflush(file_);
-    bytes_since_flush_ = 0;
-  }
-  // Figure out when we are due for another flush.
-  const int64 next = (FLAGS_logbufsecs
-                      * static_cast<int64>(1000000));  // in usec
-  next_flush_time_ = CycleClock_Now() + UsecToCycles(next);
-}
-
-bool LogFileObject::CreateLogfile(const string& time_pid_string) {
-  string string_filename = base_filename_+filename_extension_+
-                           time_pid_string;
-  const char* filename = string_filename.c_str();
-  int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0664);
-  if (fd == -1) return false;
-#ifdef HAVE_FCNTL
-  // Mark the file close-on-exec. We don't really care if this fails
-  fcntl(fd, F_SETFD, FD_CLOEXEC);
-#endif
-
-  file_ = fdopen(fd, "a");  // Make a FILE*.
-  if (file_ == NULL) {  // Man, we're screwed!
-    close(fd);
-    unlink(filename);  // Erase the half-baked evidence: an unusable log file
-    return false;
-  }
-
-  // We try to create a symlink called <program_name>.<severity>,
-  // which is easier to use.  (Every time we create a new logfile,
-  // we destroy the old symlink and create a new one, so it always
-  // points to the latest logfile.)  If it fails, we're sad but it's
-  // no error.
-  if (!symlink_basename_.empty()) {
-    // take directory from filename
-    const char* slash = strrchr(filename, PATH_SEPARATOR);
-    const string linkname =
-      symlink_basename_ + '.' + LogSeverityNames[severity_];
-    string linkpath;
-    if ( slash ) linkpath = string(filename, slash-filename+1);  // get dirname
-    linkpath += linkname;
-    unlink(linkpath.c_str());                    // delete old one if it exists
-
-    // We must have unistd.h.
-#ifdef HAVE_UNISTD_H
-    // Make the symlink be relative (in the same dir) so that if the
-    // entire log directory gets relocated the link is still valid.
-    const char *linkdest = slash ? (slash + 1) : filename;
-    if (symlink(linkdest, linkpath.c_str()) != 0) {
-      // silently ignore failures
-    }
-
-    // Make an additional link to the log file in a place specified by
-    // FLAGS_log_link, if indicated
-    if (!FLAGS_log_link.empty()) {
-      linkpath = FLAGS_log_link + "/" + linkname;
-      unlink(linkpath.c_str());                  // delete old one if it exists
-      if (symlink(filename, linkpath.c_str()) != 0) {
-        // silently ignore failures
-      }
-    }
-#endif
-  }
-
-  return true;  // Everything worked
-}
-
-void LogFileObject::Write(bool force_flush,
-                          time_t timestamp,
-                          const char* message,
-                          int message_len) {
-  MutexLock l(&lock_);
-
-  // We don't log if the base_name_ is "" (which means "don't write")
-  if (base_filename_selected_ && base_filename_.empty()) {
-    return;
-  }
-
-  if (static_cast<int>(file_length_ >> 20) >= MaxLogSize() ||
-      PidHasChanged()) {
-    if (file_ != NULL) fclose(file_);
-    file_ = NULL;
-    file_length_ = bytes_since_flush_ = 0;
-    rollover_attempt_ = kRolloverAttemptFrequency-1;
-  }
-
-  // If there's no destination file, make one before outputting
-  if (file_ == NULL) {
-    // Try to rollover the log file every 32 log messages.  The only time
-    // this could matter would be when we have trouble creating the log
-    // file.  If that happens, we'll lose lots of log messages, of course!
-    if (++rollover_attempt_ != kRolloverAttemptFrequency) return;
-    rollover_attempt_ = 0;
-
-    struct ::tm tm_time;
-    localtime_r(&timestamp, &tm_time);
-
-    // The logfile's filename will have the date/time & pid in it
-    ostringstream time_pid_stream;
-    time_pid_stream.fill('0');
-    time_pid_stream << 1900+tm_time.tm_year
-                    << setw(2) << 1+tm_time.tm_mon
-                    << setw(2) << tm_time.tm_mday
-                    << '-'
-                    << setw(2) << tm_time.tm_hour
-                    << setw(2) << tm_time.tm_min
-                    << setw(2) << tm_time.tm_sec
-                    << '.'
-                    << GetMainThreadPid();
-    const string& time_pid_string = time_pid_stream.str();
-
-    if (base_filename_selected_) {
-      if (!CreateLogfile(time_pid_string)) {
-        perror("Could not create log file");
-        fprintf(stderr, "COULD NOT CREATE LOGFILE '%s'!\n",
-                time_pid_string.c_str());
-        return;
-      }
-    } else {
-      // If no base filename for logs of this severity has been set, use a
-      // default base filename of
-      // "<program name>.<hostname>.<user name>.log.<severity level>.".  So
-      // logfiles will have names like
-      // webserver.examplehost.root.log.INFO.19990817-150000.4354, where
-      // 19990817 is a date (1999 August 17), 150000 is a time (15:00:00),
-      // and 4354 is the pid of the logging process.  The date & time reflect
-      // when the file was created for output.
-      //
-      // Where does the file get put?  Successively try the directories
-      // "/tmp", and "."
-      string stripped_filename(
-          glog_internal_namespace_::ProgramInvocationShortName());
-      string hostname;
-      GetHostName(&hostname);
-
-      string uidname = MyUserName();
-      // We should not call CHECK() here because this function can be
-      // called after holding on to log_mutex. We don't want to
-      // attempt to hold on to the same mutex, and get into a
-      // deadlock. Simply use a name like invalid-user.
-      if (uidname.empty()) uidname = "invalid-user";
-
-      stripped_filename = stripped_filename+'.'+hostname+'.'
-                          +uidname+".log."
-                          +LogSeverityNames[severity_]+'.';
-      // We're going to (potentially) try to put logs in several different dirs
-      const vector<string> & log_dirs = GetLoggingDirectories();
-
-      // Go through the list of dirs, and try to create the log file in each
-      // until we succeed or run out of options
-      bool success = false;
-      for (vector<string>::const_iterator dir = log_dirs.begin();
-           dir != log_dirs.end();
-           ++dir) {
-        base_filename_ = *dir + "/" + stripped_filename;
-        if ( CreateLogfile(time_pid_string) ) {
-          success = true;
-          break;
-        }
-      }
-      // If we never succeeded, we have to give up
-      if ( success == false ) {
-        perror("Could not create logging file");
-        fprintf(stderr, "COULD NOT CREATE A LOGGINGFILE %s!",
-                time_pid_string.c_str());
-        return;
-      }
-    }
-
-    // Write a header message into the log file
-    ostringstream file_header_stream;
-    file_header_stream.fill('0');
-    file_header_stream << "Log file created at: "
-                       << 1900+tm_time.tm_year << '/'
-                       << setw(2) << 1+tm_time.tm_mon << '/'
-                       << setw(2) << tm_time.tm_mday
-                       << ' '
-                       << setw(2) << tm_time.tm_hour << ':'
-                       << setw(2) << tm_time.tm_min << ':'
-                       << setw(2) << tm_time.tm_sec << '\n'
-                       << "Running on machine: "
-                       << LogDestination::hostname() << '\n'
-                       << "Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu "
-                       << "threadid file:line] msg" << '\n';
-    const string& file_header_string = file_header_stream.str();
-
-    const int header_len = file_header_string.size();
-    fwrite(file_header_string.data(), 1, header_len, file_);
-    file_length_ += header_len;
-    bytes_since_flush_ += header_len;
-  }
-
-  // Write to LOG file
-  if ( !stop_writing ) {
-    // fwrite() doesn't return an error when the disk is full, for
-    // messages that are less than 4096 bytes. When the disk is full,
-    // it returns the message length for messages that are less than
-    // 4096 bytes. fwrite() returns 4096 for message lengths that are
-    // greater than 4096, thereby indicating an error.
-    errno = 0;
-    fwrite(message, 1, message_len, file_);
-    if ( FLAGS_stop_logging_if_full_disk &&
-         errno == ENOSPC ) {  // disk full, stop writing to disk
-      stop_writing = true;  // until the disk is
-      return;
-    } else {
-      file_length_ += message_len;
-      bytes_since_flush_ += message_len;
-    }
-  } else {
-    if ( CycleClock_Now() >= next_flush_time_ )
-      stop_writing = false;  // check to see if disk has free space.
-    return;  // no need to flush
-  }
-
-  // See important msgs *now*.  Also, flush logs at least every 10^6 chars,
-  // or every "FLAGS_logbufsecs" seconds.
-  if ( force_flush ||
-       (bytes_since_flush_ >= 1000000) ||
-       (CycleClock_Now() >= next_flush_time_) ) {
-    FlushUnlocked();
-#ifdef OS_LINUX
-    if (FLAGS_drop_log_memory) {
-      if (file_length_ >= logging::kPageSize) {
-        // don't evict the most recent page
-        uint32 len = file_length_ & ~(logging::kPageSize - 1);
-        posix_fadvise(fileno(file_), 0, len, POSIX_FADV_DONTNEED);
-      }
-    }
-#endif
-  }
-}
-
-}  // namespace
-
-// An arbitrary limit on the length of a single log message.  This
-// is so that streaming can be done more efficiently.
-const size_t LogMessage::kMaxLogMessageLen = 30000;
-
-// Static log data space to avoid alloc failures in a LOG(FATAL)
-//
-// Since multiple threads may call LOG(FATAL), and we want to preserve
-// the data from the first call, we allocate two sets of space.  One
-// for exclusive use by the first thread, and one for shared use by
-// all other threads.
-static Mutex fatal_msg_lock;
-static CrashReason crash_reason;
-static bool fatal_msg_exclusive = true;
-static char fatal_msg_buf_exclusive[LogMessage::kMaxLogMessageLen+1];
-static char fatal_msg_buf_shared[LogMessage::kMaxLogMessageLen+1];
-static LogMessage::LogStream fatal_msg_stream_exclusive(
-    fatal_msg_buf_exclusive, LogMessage::kMaxLogMessageLen, 0);
-static LogMessage::LogStream fatal_msg_stream_shared(
-    fatal_msg_buf_shared, LogMessage::kMaxLogMessageLen, 0);
-static LogMessage::LogMessageData fatal_msg_data_exclusive;
-static LogMessage::LogMessageData fatal_msg_data_shared;
-
-LogMessage::LogMessageData::~LogMessageData() {
-  delete[] buf_;
-  delete stream_alloc_;
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
-                       int ctr, void (LogMessage::*send_method)())
-    : allocated_(NULL) {
-  Init(file, line, severity, send_method);
-  data_->stream_->set_ctr(ctr);
-}
-
-LogMessage::LogMessage(const char* file, int line,
-                       const CheckOpString& result)
-    : allocated_(NULL) {
-  Init(file, line, GLOG_FATAL, &LogMessage::SendToLog);
-  stream() << "Check failed: " << (*result.str_) << " ";
-}
-
-LogMessage::LogMessage(const char* file, int line)
-    : allocated_(NULL) {
-  Init(file, line, GLOG_INFO, &LogMessage::SendToLog);
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity)
-    : allocated_(NULL) {
-  Init(file, line, severity, &LogMessage::SendToLog);
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
-                       LogSink* sink, bool also_send_to_log)
-    : allocated_(NULL) {
-  Init(file, line, severity, also_send_to_log ? &LogMessage::SendToSinkAndLog :
-                                                &LogMessage::SendToSink);
-  data_->sink_ = sink;  // override Init()'s setting to NULL
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
-                       vector<string> *outvec)
-    : allocated_(NULL) {
-  Init(file, line, severity, &LogMessage::SaveOrSendToLog);
-  data_->outvec_ = outvec; // override Init()'s setting to NULL
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
-                       string *message)
-    : allocated_(NULL) {
-  Init(file, line, severity, &LogMessage::WriteToStringAndLog);
-  data_->message_ = message;  // override Init()'s setting to NULL
-}
-
-void LogMessage::Init(const char* file,
-                      int line,
-                      LogSeverity severity,
-                      void (LogMessage::*send_method)()) {
-  allocated_ = NULL;
-  if (severity != GLOG_FATAL || !exit_on_dfatal) {
-    allocated_ = new LogMessageData();
-    data_ = allocated_;
-    data_->buf_ = new char[kMaxLogMessageLen+1];
-    data_->message_text_ = data_->buf_;
-    data_->stream_alloc_ =
-        new LogStream(data_->message_text_, kMaxLogMessageLen, 0);
-    data_->stream_ = data_->stream_alloc_;
-    data_->first_fatal_ = false;
-  } else {
-    MutexLock l(&fatal_msg_lock);
-    if (fatal_msg_exclusive) {
-      fatal_msg_exclusive = false;
-      data_ = &fatal_msg_data_exclusive;
-      data_->message_text_ = fatal_msg_buf_exclusive;
-      data_->stream_ = &fatal_msg_stream_exclusive;
-      data_->first_fatal_ = true;
-    } else {
-      data_ = &fatal_msg_data_shared;
-      data_->message_text_ = fatal_msg_buf_shared;
-      data_->stream_ = &fatal_msg_stream_shared;
-      data_->first_fatal_ = false;
-    }
-    data_->stream_alloc_ = NULL;
-  }
-
-  stream().fill('0');
-  data_->preserved_errno_ = errno;
-  data_->severity_ = severity;
-  data_->line_ = line;
-  data_->send_method_ = send_method;
-  data_->sink_ = NULL;
-  data_->outvec_ = NULL;
-  WallTime now = WallTime_Now();
-  data_->timestamp_ = static_cast<time_t>(now);
-  localtime_r(&data_->timestamp_, &data_->tm_time_);
-  int usecs = static_cast<int>((now - data_->timestamp_) * 1000000);
-  RawLog__SetLastTime(data_->tm_time_, usecs);
-
-  data_->num_chars_to_log_ = 0;
-  data_->num_chars_to_syslog_ = 0;
-  data_->basename_ = const_basename(file);
-  data_->fullname_ = file;
-  data_->has_been_flushed_ = false;
-
-  // If specified, prepend a prefix to each line.  For example:
-  //    I1018 160715 f5d4fbb0 logging.cc:1153]
-  //    (log level, GMT month, date, time, thread_id, file basename, line)
-  // We exclude the thread_id for the default thread.
-  if (FLAGS_log_prefix && (line != kNoLogPrefix)) {
-    stream() << LogSeverityNames[severity][0]
-             << setw(2) << 1+data_->tm_time_.tm_mon
-             << setw(2) << data_->tm_time_.tm_mday
-             << ' '
-             << setw(2) << data_->tm_time_.tm_hour  << ':'
-             << setw(2) << data_->tm_time_.tm_min   << ':'
-             << setw(2) << data_->tm_time_.tm_sec   << "."
-             << setw(6) << usecs
-             << ' '
-             << setfill(' ') << setw(5)
-             << static_cast<unsigned int>(GetTID()) << setfill('0')
-             << ' '
-             << data_->basename_ << ':' << data_->line_ << "] ";
-  }
-  data_->num_prefix_chars_ = data_->stream_->pcount();
-
-  if (!FLAGS_log_backtrace_at.empty()) {
-    char fileline[128];
-    snprintf(fileline, sizeof(fileline), "%s:%d", data_->basename_, line);
-#ifdef HAVE_STACKTRACE
-    if (!strcmp(FLAGS_log_backtrace_at.c_str(), fileline)) {
-      string stacktrace;
-      DumpStackTraceToString(&stacktrace);
-      stream() << " (stacktrace:\n" << stacktrace << ") ";
-    }
-#endif
-  }
-}
-
-LogMessage::~LogMessage() {
-  Flush();
-  delete allocated_;
-}
-
-int LogMessage::preserved_errno() const {
-  return data_->preserved_errno_;
-}
-
-ostream& LogMessage::stream() {
-  return *(data_->stream_);
-}
-
-// Flush buffered message, called by the destructor, or any other function
-// that needs to synchronize the log.
-void LogMessage::Flush() {
-  if (data_->has_been_flushed_ || data_->severity_ < FLAGS_minloglevel)
-    return;
-
-  data_->num_chars_to_log_ = data_->stream_->pcount();
-  data_->num_chars_to_syslog_ =
-    data_->num_chars_to_log_ - data_->num_prefix_chars_;
-
-  // Do we need to add a \n to the end of this message?
-  bool append_newline =
-      (data_->message_text_[data_->num_chars_to_log_-1] != '\n');
-  char original_final_char = '\0';
-
-  // If we do need to add a \n, we'll do it by violating the memory of the
-  // ostrstream buffer.  This is quick, and we'll make sure to undo our
-  // modification before anything else is done with the ostrstream.  It
-  // would be preferable not to do things this way, but it seems to be
-  // the best way to deal with this.
-  if (append_newline) {
-    original_final_char = data_->message_text_[data_->num_chars_to_log_];
-    data_->message_text_[data_->num_chars_to_log_++] = '\n';
-  }
-
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // the actual logging action per se.
-  {
-    MutexLock l(&log_mutex);
-    (this->*(data_->send_method_))();
-    ++num_messages_[static_cast<int>(data_->severity_)];
-  }
-  LogDestination::WaitForSinks(data_);
-
-  if (append_newline) {
-    // Fix the ostrstream back how it was before we screwed with it.
-    // It's 99.44% certain that we don't need to worry about doing this.
-    data_->message_text_[data_->num_chars_to_log_-1] = original_final_char;
-  }
-
-  // If errno was already set before we enter the logging call, we'll
-  // set it back to that value when we return from the logging call.
-  // It happens often that we log an error message after a syscall
-  // failure, which can potentially set the errno to some other
-  // values.  We would like to preserve the original errno.
-  if (data_->preserved_errno_ != 0) {
-    errno = data_->preserved_errno_;
-  }
-
-  // Note that this message is now safely logged.  If we're asked to flush
-  // again, as a result of destruction, say, we'll do nothing on future calls.
-  data_->has_been_flushed_ = true;
-}
-
-// Copy of first FATAL log message so that we can print it out again
-// after all the stack traces.  To preserve legacy behavior, we don't
-// use fatal_msg_buf_exclusive.
-static time_t fatal_time;
-static char fatal_message[256];
-
-void ReprintFatalMessage() {
-  if (fatal_message[0]) {
-    const int n = strlen(fatal_message);
-    if (!FLAGS_logtostderr) {
-      // Also write to stderr (don't color to avoid terminal checks)
-      WriteToStderr(fatal_message, n);
-    }
-    LogDestination::LogToAllLogfiles(GLOG_ERROR, fatal_time, fatal_message, n);
-  }
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  static bool already_warned_before_initgoogle = false;
-
-  log_mutex.AssertHeld();
-
-  RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
-             data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
-
-  // Messages of a given severity get logged to lower severity logs, too
-
-  if (!already_warned_before_initgoogle && !IsGoogleLoggingInitialized()) {
-    const char w[] = "WARNING: Logging before InitGoogleLogging() is "
-                     "written to STDERR\n";
-    WriteToStderr(w, strlen(w));
-    already_warned_before_initgoogle = true;
-  }
-
-  // global flag: never log to file if set.  Also -- don't log to a
-  // file if we haven't parsed the command line flags to get the
-  // program name.
-  if (FLAGS_logtostderr || !IsGoogleLoggingInitialized()) {
-    ColoredWriteToStderr(data_->severity_,
-                         data_->message_text_, data_->num_chars_to_log_);
-
-    // this could be protected by a flag if necessary.
-    LogDestination::LogToSinks(data_->severity_,
-                               data_->fullname_, data_->basename_,
-                               data_->line_, &data_->tm_time_,
-                               data_->message_text_ + data_->num_prefix_chars_,
-                               (data_->num_chars_to_log_ -
-                                data_->num_prefix_chars_ - 1));
-  } else {
-
-    // log this message to all log files of severity <= severity_
-    LogDestination::LogToAllLogfiles(data_->severity_, data_->timestamp_,
-                                     data_->message_text_,
-                                     data_->num_chars_to_log_);
-
-    LogDestination::MaybeLogToStderr(data_->severity_, data_->message_text_,
-                                     data_->num_chars_to_log_);
-    LogDestination::MaybeLogToEmail(data_->severity_, data_->message_text_,
-                                    data_->num_chars_to_log_);
-    LogDestination::LogToSinks(data_->severity_,
-                               data_->fullname_, data_->basename_,
-                               data_->line_, &data_->tm_time_,
-                               data_->message_text_ + data_->num_prefix_chars_,
-                               (data_->num_chars_to_log_
-                                - data_->num_prefix_chars_ - 1));
-    // NOTE: -1 removes trailing \n
-  }
-
-  // If we log a FATAL message, flush all the log destinations, then toss
-  // a signal for others to catch. We leave the logs in a state that
-  // someone else can use them (as long as they flush afterwards)
-  if (data_->severity_ == GLOG_FATAL && exit_on_dfatal) {
-    if (data_->first_fatal_) {
-      // Store crash information so that it is accessible from within signal
-      // handlers that may be invoked later.
-      RecordCrashReason(&crash_reason);
-      SetCrashReason(&crash_reason);
-
-      // Store shortened fatal message for other logs and GWQ status
-      const int copy = min<int>(data_->num_chars_to_log_,
-                                sizeof(fatal_message)-1);
-      memcpy(fatal_message, data_->message_text_, copy);
-      fatal_message[copy] = '\0';
-      fatal_time = data_->timestamp_;
-    }
-
-    if (!FLAGS_logtostderr) {
-      for (int i = 0; i < NUM_SEVERITIES; ++i) {
-        if ( LogDestination::log_destinations_[i] )
-          LogDestination::log_destinations_[i]->logger_->Write(true, 0, "", 0);
-      }
-    }
-
-    // release the lock that our caller (directly or indirectly)
-    // LogMessage::~LogMessage() grabbed so that signal handlers
-    // can use the logging facility. Alternately, we could add
-    // an entire unsafe logging interface to bypass locking
-    // for signal handlers but this seems simpler.
-    log_mutex.Unlock();
-    LogDestination::WaitForSinks(data_);
-
-    const char* message = "*** Check failure stack trace: ***\n";
-    if (write(STDERR_FILENO, message, strlen(message)) < 0) {
-      // Ignore errors.
-    }
-    Fail();
-  }
-}
-
-void LogMessage::RecordCrashReason(
-    glog_internal_namespace_::CrashReason* reason) {
-  reason->filename = fatal_msg_data_exclusive.fullname_;
-  reason->line_number = fatal_msg_data_exclusive.line_;
-  reason->message = fatal_msg_buf_exclusive +
-                    fatal_msg_data_exclusive.num_prefix_chars_;
-#ifdef HAVE_STACKTRACE
-  // Retrieve the stack trace, omitting the logging frames that got us here.
-  reason->depth = GetStackTrace(reason->stack, ARRAYSIZE(reason->stack), 4);
-#else
-  reason->depth = 0;
-#endif
-}
-
-#ifdef HAVE___ATTRIBUTE__
-# define ATTRIBUTE_NORETURN __attribute__((noreturn))
-#else
-# define ATTRIBUTE_NORETURN
-#endif
-
-static void logging_fail() ATTRIBUTE_NORETURN;
-
-static void logging_fail() {
-#if defined(_DEBUG) && defined(_MSC_VER) && defined(_M_IX86)
-  // When debugging on windows, avoid the obnoxious dialog and make
-  // it possible to continue past a LOG(FATAL) in the debugger
-  _asm int 3
-#else
-  abort();
-#endif
-}
-
-typedef void (*logging_fail_func_t)() ATTRIBUTE_NORETURN;
-
-GOOGLE_GLOG_DLL_DECL
-logging_fail_func_t g_logging_fail_func = &logging_fail;
-
-void InstallFailureFunction(void (*fail_func)()) {
-  g_logging_fail_func = (logging_fail_func_t)fail_func;
-}
-
-void LogMessage::Fail() {
-  g_logging_fail_func();
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SendToSink() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  if (data_->sink_ != NULL) {
-    RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
-               data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
-    data_->sink_->send(data_->severity_, data_->fullname_, data_->basename_,
-                       data_->line_, &data_->tm_time_,
-                       data_->message_text_ + data_->num_prefix_chars_,
-                       (data_->num_chars_to_log_ -
-                        data_->num_prefix_chars_ - 1));
-  }
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SendToSinkAndLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  SendToSink();
-  SendToLog();
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SaveOrSendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  if (data_->outvec_ != NULL) {
-    RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
-               data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
-    // Omit prefix of message and trailing newline when recording in outvec_.
-    const char *start = data_->message_text_ + data_->num_prefix_chars_;
-    int len = data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1;
-    data_->outvec_->push_back(string(start, len));
-  } else {
-    SendToLog();
-  }
-}
-
-void LogMessage::WriteToStringAndLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  if (data_->message_ != NULL) {
-    RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
-               data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
-    // Omit prefix of message and trailing newline when writing to message_.
-    const char *start = data_->message_text_ + data_->num_prefix_chars_;
-    int len = data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1;
-    data_->message_->assign(start, len);
-  }
-  SendToLog();
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SendToSyslogAndLog() {
-#ifdef HAVE_SYSLOG_H
-  // Before any calls to syslog(), make a single call to openlog()
-  static bool openlog_already_called = false;
-  if (!openlog_already_called) {
-    openlog(glog_internal_namespace_::ProgramInvocationShortName(),
-            LOG_CONS | LOG_NDELAY | LOG_PID,
-            LOG_USER);
-    openlog_already_called = true;
-  }
-
-  // This array maps Google severity levels to syslog levels
-  const int SEVERITY_TO_LEVEL[] = { LOG_INFO, LOG_WARNING, LOG_ERR, LOG_EMERG };
-  syslog(LOG_USER | SEVERITY_TO_LEVEL[static_cast<int>(data_->severity_)], "%.*s",
-         int(data_->num_chars_to_syslog_),
-         data_->message_text_ + data_->num_prefix_chars_);
-  SendToLog();
-#else
-  LOG(ERROR) << "No syslog support: message=" << data_->message_text_;
-#endif
-}
-
-base::Logger* base::GetLogger(LogSeverity severity) {
-  MutexLock l(&log_mutex);
-  return LogDestination::log_destination(severity)->logger_;
-}
-
-void base::SetLogger(LogSeverity severity, base::Logger* logger) {
-  MutexLock l(&log_mutex);
-  LogDestination::log_destination(severity)->logger_ = logger;
-}
-
-// L < log_mutex.  Acquires and releases mutex_.
-int64 LogMessage::num_messages(int severity) {
-  MutexLock l(&log_mutex);
-  return num_messages_[severity];
-}
-
-// Output the COUNTER value. This is only valid if ostream is a
-// LogStream.
-ostream& operator<<(ostream &os, const PRIVATE_Counter&) {
-#ifdef DISABLE_RTTI
-  LogMessage::LogStream *log = static_cast<LogMessage::LogStream*>(&os);
-#else
-  LogMessage::LogStream *log = dynamic_cast<LogMessage::LogStream*>(&os);
-#endif
-  CHECK(log && log == log->self())
-      << "You must not use COUNTER with non-glog ostream";
-  os << log->ctr();
-  return os;
-}
-
-ErrnoLogMessage::ErrnoLogMessage(const char* file, int line,
-                                 LogSeverity severity, int ctr,
-                                 void (LogMessage::*send_method)())
-    : LogMessage(file, line, severity, ctr, send_method) {
-}
-
-ErrnoLogMessage::~ErrnoLogMessage() {
-  // Don't access errno directly because it may have been altered
-  // while streaming the message.
-  char buf[100];
-  posix_strerror_r(preserved_errno(), buf, sizeof(buf));
-  stream() << ": " << buf << " [" << preserved_errno() << "]";
-}
-
-void FlushLogFiles(LogSeverity min_severity) {
-  LogDestination::FlushLogFiles(min_severity);
-}
-
-void FlushLogFilesUnsafe(LogSeverity min_severity) {
-  LogDestination::FlushLogFilesUnsafe(min_severity);
-}
-
-void SetLogDestination(LogSeverity severity, const char* base_filename) {
-  LogDestination::SetLogDestination(severity, base_filename);
-}
-
-void SetLogSymlink(LogSeverity severity, const char* symlink_basename) {
-  LogDestination::SetLogSymlink(severity, symlink_basename);
-}
-
-LogSink::~LogSink() {
-}
-
-void LogSink::WaitTillSent() {
-  // noop default
-}
-
-string LogSink::ToString(LogSeverity severity, const char* file, int line,
-                         const struct ::tm* tm_time,
-                         const char* message, size_t message_len) {
-  ostringstream stream(string(message, message_len));
-  stream.fill('0');
-
-  // FIXME(jrvb): Updating this to use the correct value for usecs
-  // requires changing the signature for both this method and
-  // LogSink::send().  This change needs to be done in a separate CL
-  // so subclasses of LogSink can be updated at the same time.
-  int usecs = 0;
-
-  stream << LogSeverityNames[severity][0]
-         << setw(2) << 1+tm_time->tm_mon
-         << setw(2) << tm_time->tm_mday
-         << ' '
-         << setw(2) << tm_time->tm_hour << ':'
-         << setw(2) << tm_time->tm_min << ':'
-         << setw(2) << tm_time->tm_sec << '.'
-         << setw(6) << usecs
-         << ' '
-         << setfill(' ') << setw(5) << GetTID() << setfill('0')
-         << ' '
-         << file << ':' << line << "] ";
-
-  stream << string(message, message_len);
-  return stream.str();
-}
-
-void AddLogSink(LogSink *destination) {
-  LogDestination::AddLogSink(destination);
-}
-
-void RemoveLogSink(LogSink *destination) {
-  LogDestination::RemoveLogSink(destination);
-}
-
-void SetLogFilenameExtension(const char* ext) {
-  LogDestination::SetLogFilenameExtension(ext);
-}
-
-void SetStderrLogging(LogSeverity min_severity) {
-  LogDestination::SetStderrLogging(min_severity);
-}
-
-void SetEmailLogging(LogSeverity min_severity, const char* addresses) {
-  LogDestination::SetEmailLogging(min_severity, addresses);
-}
-
-void LogToStderr() {
-  LogDestination::LogToStderr();
-}
-
-namespace base {
-namespace internal {
-
-bool GetExitOnDFatal() {
-  MutexLock l(&log_mutex);
-  return exit_on_dfatal;
-}
-
-// Determines whether we exit the program for a LOG(DFATAL) message in
-// debug mode.  It does this by skipping the call to Fail/FailQuietly.
-// This is intended for testing only.
-//
-// This can have some effects on LOG(FATAL) as well.  Failure messages
-// are always allocated (rather than sharing a buffer), the crash
-// reason is not recorded, the "gwq" status message is not updated,
-// and the stack trace is not recorded.  The LOG(FATAL) *will* still
-// exit the program.  Since this function is used only in testing,
-// these differences are acceptable.
-void SetExitOnDFatal(bool value) {
-  MutexLock l(&log_mutex);
-  exit_on_dfatal = value;
-}
-
-}  // namespace internal
-}  // namespace base
-
-// use_logging controls whether the logging functions LOG/VLOG are used
-// to log errors.  It should be set to false when the caller holds the
-// log_mutex.
-static bool SendEmailInternal(const char*dest, const char *subject,
-                              const char*body, bool use_logging) {
-  if (dest && *dest) {
-    if ( use_logging ) {
-      VLOG(1) << "Trying to send TITLE:" << subject
-              << " BODY:" << body << " to " << dest;
-    } else {
-      fprintf(stderr, "Trying to send TITLE: %s BODY: %s to %s\n",
-              subject, body, dest);
-    }
-
-    string cmd =
-        FLAGS_logmailer + " -s\"" + subject + "\" " + dest;
-    FILE* pipe = popen(cmd.c_str(), "w");
-    if (pipe != NULL) {
-      // Add the body if we have one
-      if (body)
-        fwrite(body, sizeof(char), strlen(body), pipe);
-      bool ok = pclose(pipe) != -1;
-      if ( !ok ) {
-        if ( use_logging ) {
-          char buf[100];
-          posix_strerror_r(errno, buf, sizeof(buf));
-          LOG(ERROR) << "Problems sending mail to " << dest << ": " << buf;
-        } else {
-          char buf[100];
-          posix_strerror_r(errno, buf, sizeof(buf));
-          fprintf(stderr, "Problems sending mail to %s: %s\n", dest, buf);
-        }
-      }
-      return ok;
-    } else {
-      if ( use_logging ) {
-        LOG(ERROR) << "Unable to send mail to " << dest;
-      } else {
-        fprintf(stderr, "Unable to send mail to %s\n", dest);
-      }
-    }
-  }
-  return false;
-}
-
-bool SendEmail(const char*dest, const char *subject, const char*body){
-  return SendEmailInternal(dest, subject, body, true);
-}
-
-static void GetTempDirectories(vector<string>* list) {
-  list->clear();
-#ifdef OS_WINDOWS
-  // On windows we'll try to find a directory in this order:
-  //   C:/Documents & Settings/whomever/TEMP (or whatever GetTempPath() is)
-  //   C:/TMP/
-  //   C:/TEMP/
-  //   C:/WINDOWS/ or C:/WINNT/
-  //   .
-  char tmp[MAX_PATH];
-  if (GetTempPathA(MAX_PATH, tmp))
-    list->push_back(tmp);
-  list->push_back("C:\\tmp\\");
-  list->push_back("C:\\temp\\");
-#else
-  // Directories, in order of preference. If we find a dir that
-  // exists, we stop adding other less-preferred dirs
-  const char * candidates[] = {
-    // Non-null only during unittest/regtest
-    getenv("TEST_TMPDIR"),
-
-    // Explicitly-supplied temp dirs
-    getenv("TMPDIR"), getenv("TMP"),
-
-    // If all else fails
-    "/tmp",
-  };
-
-  for (size_t i = 0; i < ARRAYSIZE(candidates); i++) {
-    const char *d = candidates[i];
-    if (!d) continue;  // Empty env var
-
-    // Make sure we don't surprise anyone who's expecting a '/'
-    string dstr = d;
-    if (dstr[dstr.size() - 1] != '/') {
-      dstr += "/";
-    }
-    list->push_back(dstr);
-
-    struct stat statbuf;
-    if (!stat(d, &statbuf) && S_ISDIR(statbuf.st_mode)) {
-      // We found a dir that exists - we're done.
-      return;
-    }
-  }
-
-#endif
-}
-
-static vector<string>* logging_directories_list;
-
-const vector<string>& GetLoggingDirectories() {
-  // Not strictly thread-safe but we're called early in InitGoogle().
-  if (logging_directories_list == NULL) {
-    logging_directories_list = new vector<string>;
-
-    if ( !FLAGS_log_dir.empty() ) {
-      // A dir was specified, we should use it
-      logging_directories_list->push_back(FLAGS_log_dir.c_str());
-    } else {
-      GetTempDirectories(logging_directories_list);
-#ifdef OS_WINDOWS
-      char tmp[MAX_PATH];
-      if (GetWindowsDirectoryA(tmp, MAX_PATH))
-        logging_directories_list->push_back(tmp);
-      logging_directories_list->push_back(".\\");
-#else
-      logging_directories_list->push_back("./");
-#endif
-    }
-  }
-  return *logging_directories_list;
-}
-
-void TestOnly_ClearLoggingDirectoriesList() {
-  fprintf(stderr, "TestOnly_ClearLoggingDirectoriesList should only be "
-          "called from test code.\n");
-  delete logging_directories_list;
-  logging_directories_list = NULL;
-}
-
-void GetExistingTempDirectories(vector<string>* list) {
-  GetTempDirectories(list);
-  vector<string>::iterator i_dir = list->begin();
-  while( i_dir != list->end() ) {
-    // zero arg to access means test for existence; no constant
-    // defined on windows
-    if ( access(i_dir->c_str(), 0) ) {
-      i_dir = list->erase(i_dir);
-    } else {
-      ++i_dir;
-    }
-  }
-}
-
-void TruncateLogFile(const char *path, int64 limit, int64 keep) {
-#ifdef HAVE_UNISTD_H
-  struct stat statbuf;
-  const int kCopyBlockSize = 8 << 10;
-  char copybuf[kCopyBlockSize];
-  int64 read_offset, write_offset;
-  // Don't follow symlinks unless they're our own fd symlinks in /proc
-  int flags = O_RDWR;
-  const char *procfd_prefix = "/proc/self/fd/";
-  if (strncmp(procfd_prefix, path, strlen(procfd_prefix))) flags |= O_NOFOLLOW;
-
-  int fd = open(path, flags);
-  if (fd == -1) {
-    if (errno == EFBIG) {
-      // The log file in question has got too big for us to open. The
-      // real fix for this would be to compile logging.cc (or probably
-      // all of base/...) with -D_FILE_OFFSET_BITS=64 but that's
-      // rather scary.
-      // Instead just truncate the file to something we can manage
-      if (truncate(path, 0) == -1) {
-        PLOG(ERROR) << "Unable to truncate " << path;
-      } else {
-        LOG(ERROR) << "Truncated " << path << " due to EFBIG error";
-      }
-    } else {
-      PLOG(ERROR) << "Unable to open " << path;
-    }
-    return;
-  }
-
-  if (fstat(fd, &statbuf) == -1) {
-    PLOG(ERROR) << "Unable to fstat()";
-    goto out_close_fd;
-  }
-
-  // See if the path refers to a regular file bigger than the
-  // specified limit
-  if (!S_ISREG(statbuf.st_mode)) goto out_close_fd;
-  if (statbuf.st_size <= limit)  goto out_close_fd;
-  if (statbuf.st_size <= keep) goto out_close_fd;
-
-  // This log file is too large - we need to truncate it
-  LOG(INFO) << "Truncating " << path << " to " << keep << " bytes";
-
-  // Copy the last "keep" bytes of the file to the beginning of the file
-  read_offset = statbuf.st_size - keep;
-  write_offset = 0;
-  int bytesin, bytesout;
-  while ((bytesin = pread(fd, copybuf, sizeof(copybuf), read_offset)) > 0) {
-    bytesout = pwrite(fd, copybuf, bytesin, write_offset);
-    if (bytesout == -1) {
-      PLOG(ERROR) << "Unable to write to " << path;
-      break;
-    } else if (bytesout != bytesin) {
-      LOG(ERROR) << "Expected to write " << bytesin << ", wrote " << bytesout;
-    }
-    read_offset += bytesin;
-    write_offset += bytesout;
-  }
-  if (bytesin == -1) PLOG(ERROR) << "Unable to read from " << path;
-
-  // Truncate the remainder of the file. If someone else writes to the
-  // end of the file after our last read() above, we lose their latest
-  // data. Too bad ...
-  if (ftruncate(fd, write_offset) == -1) {
-    PLOG(ERROR) << "Unable to truncate " << path;
-  }
-
- out_close_fd:
-  close(fd);
-#else
-  LOG(ERROR) << "No log truncation support.";
-#endif
-}
-
-void TruncateStdoutStderr() {
-#ifdef HAVE_UNISTD_H
-  int64 limit = MaxLogSize() << 20;
-  int64 keep = 1 << 20;
-  TruncateLogFile("/proc/self/fd/1", limit, keep);
-  TruncateLogFile("/proc/self/fd/2", limit, keep);
-#else
-  LOG(ERROR) << "No log truncation support.";
-#endif
-}
-
-
-// Helper functions for string comparisons.
-#define DEFINE_CHECK_STROP_IMPL(name, func, expected)                   \
-  string* Check##func##expected##Impl(const char* s1, const char* s2,   \
-                                      const char* names) {              \
-    bool equal = s1 == s2 || (s1 && s2 && !func(s1, s2));               \
-    if (equal == expected) return NULL;                                 \
-    else {                                                              \
-      ostringstream ss;                                                 \
-      if (!s1) s1 = "";                                                 \
-      if (!s2) s2 = "";                                                 \
-      ss << #name " failed: " << names << " (" << s1 << " vs. " << s2 << ")"; \
-      return new string(ss.str());                                      \
-    }                                                                   \
-  }
-DEFINE_CHECK_STROP_IMPL(CHECK_STREQ, strcmp, true)
-DEFINE_CHECK_STROP_IMPL(CHECK_STRNE, strcmp, false)
-DEFINE_CHECK_STROP_IMPL(CHECK_STRCASEEQ, strcasecmp, true)
-DEFINE_CHECK_STROP_IMPL(CHECK_STRCASENE, strcasecmp, false)
-#undef DEFINE_CHECK_STROP_IMPL
-
-int posix_strerror_r(int err, char *buf, size_t len) {
-  // Sanity check input parameters
-  if (buf == NULL || len <= 0) {
-    errno = EINVAL;
-    return -1;
-  }
-
-  // Reset buf and errno, and try calling whatever version of strerror_r()
-  // is implemented by glibc
-  buf[0] = '\000';
-  int old_errno = errno;
-  errno = 0;
-  char *rc = reinterpret_cast<char *>(strerror_r(err, buf, len));
-
-  // Both versions set errno on failure
-  if (errno) {
-    // Should already be there, but better safe than sorry
-    buf[0]     = '\000';
-    return -1;
-  }
-  errno = old_errno;
-
-  // POSIX is vague about whether the string will be terminated, although
-  // is indirectly implies that typically ERANGE will be returned, instead
-  // of truncating the string. This is different from the GNU implementation.
-  // We play it safe by always terminating the string explicitly.
-  buf[len-1] = '\000';
-
-  // If the function succeeded, we can use its exit code to determine the
-  // semantics implemented by glibc
-  if (!rc) {
-    return 0;
-  } else {
-    // GNU semantics detected
-    if (rc == buf) {
-      return 0;
-    } else {
-      buf[0] = '\000';
-#if defined(OS_MACOSX) || defined(OS_FREEBSD) || defined(OS_OPENBSD)
-      if (reinterpret_cast<intptr_t>(rc) < sys_nerr) {
-        // This means an error on MacOSX or FreeBSD.
-        return -1;
-      }
-#endif
-      strncat(buf, rc, len-1);
-      return 0;
-    }
-  }
-}
-
-LogMessageFatal::LogMessageFatal(const char* file, int line) :
-    LogMessage(file, line, GLOG_FATAL) {}
-
-LogMessageFatal::LogMessageFatal(const char* file, int line,
-                                 const CheckOpString& result) :
-    LogMessage(file, line, result) {}
-
-LogMessageFatal::~LogMessageFatal() {
-    Flush();
-    LogMessage::Fail();
-}
-
-namespace base {
-
-CheckOpMessageBuilder::CheckOpMessageBuilder(const char *exprtext)
-    : stream_(new ostringstream) {
-  *stream_ << exprtext << " (";
-}
-
-CheckOpMessageBuilder::~CheckOpMessageBuilder() {
-  delete stream_;
-}
-
-ostream* CheckOpMessageBuilder::ForVar2() {
-  *stream_ << " vs. ";
-  return stream_;
-}
-
-string* CheckOpMessageBuilder::NewString() {
-  *stream_ << ")";
-  return new string(stream_->str());
-}
-
-}  // namespace base
-
-template <>
-void MakeCheckOpValueString(std::ostream* os, const char& v) {
-  if (v >= 32 && v <= 126) {
-    (*os) << "'" << v << "'";
-  } else {
-    (*os) << "char value " << (short)v;
-  }
-}
-
-template <>
-void MakeCheckOpValueString(std::ostream* os, const signed char& v) {
-  if (v >= 32 && v <= 126) {
-    (*os) << "'" << v << "'";
-  } else {
-    (*os) << "signed char value " << (short)v;
-  }
-}
-
-template <>
-void MakeCheckOpValueString(std::ostream* os, const unsigned char& v) {
-  if (v >= 32 && v <= 126) {
-    (*os) << "'" << v << "'";
-  } else {
-    (*os) << "unsigned char value " << (unsigned short)v;
-  }
-}
-
-void InitGoogleLogging(const char* argv0) {
-  glog_internal_namespace_::InitGoogleLoggingUtilities(argv0);
-}
-
-void ShutdownGoogleLogging() {
-  glog_internal_namespace_::ShutdownGoogleLoggingUtilities();
-  LogDestination::DeleteLogDestinations();
-  delete logging_directories_list;
-  logging_directories_list = NULL;
-}
-
-_END_GOOGLE_NAMESPACE_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/port.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/port.cc b/third_party/src/glog/src/windows/port.cc
deleted file mode 100644
index d994325..0000000
--- a/third_party/src/glog/src/windows/port.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Copyright (c) 2008, Google Inc.
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * 
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ---
- * Author: Craig Silverstein
- * Copied from google-perftools and modified by Shinichiro Hamaji
- */
-
-#ifndef _WIN32
-# error You should only be including windows/port.cc in a windows environment!
-#endif
-
-#include "config.h"
-#include <stdarg.h>    // for va_list, va_start, va_end
-#include <string.h>    // for strstr()
-#include <assert.h>
-#include <string>
-#include <vector>
-#include "port.h"
-
-using std::string;
-using std::vector;
-
-// These call the windows _vsnprintf, but always NUL-terminate.
-int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
-  if (size == 0)        // not even room for a \0?
-    return -1;          // not what C99 says to do, but what windows does
-  str[size-1] = '\0';
-  return _vsnprintf(str, size-1, format, ap);
-}
-
-#ifndef HAVE_SNPRINTF
-int snprintf(char *str, size_t size, const char *format, ...) {
-  va_list ap;
-  va_start(ap, format);
-  const int r = vsnprintf(str, size, format, ap);
-  va_end(ap);
-  return r;
-}
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/port.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/port.h b/third_party/src/glog/src/windows/port.h
deleted file mode 100644
index 4f09c87..0000000
--- a/third_party/src/glog/src/windows/port.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/* Copyright (c) 2008, Google Inc.
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * 
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ---
- * Author: Craig Silverstein
- * Copied from google-perftools and modified by Shinichiro Hamaji
- *
- * These are some portability typedefs and defines to make it a bit
- * easier to compile this code under VC++.
- *
- * Several of these are taken from glib:
- *    http://developer.gnome.org/doc/API/glib/glib-windows-compatability-functions.html
- */
-
-#ifndef CTEMPLATE_WINDOWS_PORT_H_
-#define CTEMPLATE_WINDOWS_PORT_H_
-
-#include "config.h"
-
-#ifdef _WIN32
-
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN  /* We always want minimal includes */
-#endif
-
-#include <windows.h>
-#include <winsock.h>         /* for gethostname */
-#include <io.h>              /* because we so often use open/close/etc */
-#include <direct.h>          /* for _getcwd() */
-#include <process.h>         /* for _getpid() */
-#include <stdio.h>           /* read in vsnprintf decl. before redifining it */
-#include <stdarg.h>          /* template_dictionary.cc uses va_copy */
-#include <string.h>          /* for _strnicmp(), strerror_s() */
-#include <time.h>            /* for localtime_s() */
-/* Note: the C++ #includes are all together at the bottom.  This file is
- * used by both C and C++ code, so we put all the C++ together.
- */
-
-/* 4244: otherwise we get problems when substracting two size_t's to an int
- * 4251: it's complaining about a private struct I've chosen not to dllexport
- * 4355: we use this in a constructor, but we do it safely
- * 4715: for some reason VC++ stopped realizing you can't return after abort()
- * 4800: we know we're casting ints/char*'s to bools, and we're ok with that
- * 4996: Yes, we're ok using "unsafe" functions like fopen() and strerror()
- */
-#pragma warning(disable:4244 4251 4355 4715 4800 4996)
-
-/* file I/O */
-#ifndef PATH_MAX
-#define PATH_MAX 1024
-#endif
-#define access  _access
-#define getcwd  _getcwd
-#define open    _open
-#define read    _read
-#define write   _write
-#define lseek   _lseek
-#define close   _close
-#define popen   _popen
-#define pclose  _pclose
-#ifndef R_OK
-#define R_OK    04           /* read-only (for access()) */
-#endif
-#define S_ISDIR(m)  (((m) & _S_IFMT) == _S_IFDIR)
-#ifndef __MINGW32__
-enum { STDIN_FILENO = 0, STDOUT_FILENO = 1, STDERR_FILENO = 2 };
-#endif
-#define S_IRUSR S_IREAD
-#define S_IWUSR S_IWRITE
-
-/* Not quite as lightweight as a hard-link, but more than good enough for us. */
-#define link(oldpath, newpath)  CopyFileA(oldpath, newpath, false)
-
-#define strcasecmp   _stricmp
-#define strncasecmp  _strnicmp
-
-/* In windows-land, hash<> is called hash_compare<> (from xhash.h) */
-/* VC11 provides std::hash */
-#if defined(_MSC_VER) && (_MSC_VER < 1700)
-#define hash  hash_compare
-#endif
-
-/* Sleep is in ms, on windows */
-#define sleep(secs)  Sleep((secs) * 1000)
-
-/* We can't just use _vsnprintf and _snprintf as drop-in-replacements,
- * because they don't always NUL-terminate. :-(  We also can't use the
- * name vsnprintf, since windows defines that (but not snprintf (!)).
- */
-#ifndef HAVE_SNPRINTF
-extern int snprintf(char *str, size_t size,
-                                       const char *format, ...);
-#endif
-extern int safe_vsnprintf(char *str, size_t size,
-                          const char *format, va_list ap);
-#define vsnprintf(str, size, format, ap)  safe_vsnprintf(str, size, format, ap)
-#ifndef va_copy
-#define va_copy(dst, src)  (dst) = (src)
-#endif
-
-/* Windows doesn't support specifying the number of buckets as a
- * hash_map constructor arg, so we leave this blank.
- */
-#define CTEMPLATE_SMALL_HASHTABLE
-
-#define DEFAULT_TEMPLATE_ROOTDIR  ".."
-
-// ----------------------------------- SYSTEM/PROCESS
-#ifndef HAVE_PID_T
-typedef int pid_t;
-#endif
-#define getpid  _getpid
-
-// ----------------------------------- THREADS
-typedef DWORD pthread_t;
-typedef DWORD pthread_key_t;
-typedef LONG pthread_once_t;
-enum { PTHREAD_ONCE_INIT = 0 };   // important that this be 0! for SpinLock
-#define pthread_self  GetCurrentThreadId
-#define pthread_equal(pthread_t_1, pthread_t_2)  ((pthread_t_1)==(pthread_t_2))
-
-inline struct tm* localtime_r(const time_t* timep, struct tm* result) {
-  localtime_s(result, timep);
-  return result;
-}
-
-inline char* strerror_r(int errnum, char* buf, size_t buflen) {
-  strerror_s(buf, buflen, errnum);
-  return buf;
-}
-
-#ifndef __cplusplus
-/* I don't see how to get inlining for C code in MSVC.  Ah well. */
-#define inline
-#endif
-
-#endif  /* _WIN32 */
-
-#endif  /* CTEMPLATE_WINDOWS_PORT_H_ */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/preprocess.sh
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/preprocess.sh b/third_party/src/glog/src/windows/preprocess.sh
deleted file mode 100644
index 5398988..0000000
--- a/third_party/src/glog/src/windows/preprocess.sh
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/bin/sh
-
-# Copyright (c) 2008, Google Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# ---
-# Author: Craig Silverstein
-# Copied from google-perftools and modified by Shinichiro Hamaji
-#
-# This script is meant to be run at distribution-generation time, for
-# instance by autogen.sh.  It does some of the work configure would
-# normally do, for windows systems.  In particular, it expands all the
-# @...@ variables found in .in files, and puts them here, in the windows
-# directory.
-#
-# This script should be run before any new release.
-
-if [ -z "$1" ]; then
-   echo "USAGE: $0 <src/ directory>"
-   exit 1
-fi
-
-DLLDEF_MACRO_NAME="GLOG_DLL_DECL"
-
-# The text we put in every .h files we create.  As a courtesy, we'll
-# include a helpful comment for windows users as to how to use
-# GLOG_DLL_DECL.  Apparently sed expands \n into a newline.  Good!
-DLLDEF_DEFINES="\
-// NOTE: if you are statically linking the template library into your binary\n\
-// (rather than using the template .dll), set '/D $DLLDEF_MACRO_NAME='\n\
-// as a compiler flag in your project file to turn off the dllimports.\n\
-#ifndef $DLLDEF_MACRO_NAME\n\
-# define $DLLDEF_MACRO_NAME  __declspec(dllimport)\n\
-#endif"
-
-# Read all the windows config info into variables
-# In order for the 'set' to take, this requires putting all in a subshell.
-(
-  while read define varname value; do
-    [ "$define" != "#define" ] && continue
-    eval "$varname='$value'"
-  done
-
-  # Process all the .in files in the "glog" subdirectory
-  mkdir -p "$1/windows/glog"
-  for file in `echo "$1"/glog/*.in`; do
-     echo "Processing $file"
-     outfile="$1/windows/glog/`basename $file .in`"
-
-     echo "\
-// This file is automatically generated from $file
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-" > "$outfile"
-     # Besides replacing @...@, we also need to turn on dllimport
-     # We also need to replace hash by hash_compare (annoying we hard-code :-( )
-     sed -e "s!@ac_windows_dllexport@!$DLLDEF_MACRO_NAME!g" \
-         -e "s!@ac_windows_dllexport_defines@!$DLLDEF_DEFINES!g" \
-         -e "s!@ac_cv_cxx_hash_map@!$HASH_MAP_H!g" \
-         -e "s!@ac_cv_cxx_hash_namespace@!$HASH_NAMESPACE!g" \
-         -e "s!@ac_cv_cxx_hash_set@!$HASH_SET_H!g" \
-         -e "s!@ac_cv_have_stdint_h@!0!g" \
-         -e "s!@ac_cv_have_systypes_h@!0!g" \
-         -e "s!@ac_cv_have_inttypes_h@!0!g" \
-         -e "s!@ac_cv_have_unistd_h@!0!g" \
-         -e "s!@ac_cv_have_uint16_t@!0!g" \
-         -e "s!@ac_cv_have_u_int16_t@!0!g" \
-         -e "s!@ac_cv_have___uint16@!1!g" \
-         -e "s!@ac_cv_have_libgflags@!0!g" \
-         -e "s!@ac_cv_have___builtin_expect@!0!g" \
-         -e "s!@ac_cv_cxx_using_operator@!1!g" \
-         -e "s!@ac_cv___attribute___noreturn@!!g" \
-         -e "s!@ac_cv___attribute___noinline@!!g" \
-         -e "s!@ac_cv___attribute___printf_4_5@!!g" \
-         -e "s!@ac_google_attribute@!${HAVE___ATTRIBUTE__:-0}!g" \
-         -e "s!@ac_google_end_namespace@!$_END_GOOGLE_NAMESPACE_!g" \
-         -e "s!@ac_google_namespace@!$GOOGLE_NAMESPACE!g" \
-         -e "s!@ac_google_start_namespace@!$_START_GOOGLE_NAMESPACE_!g" \
-         -e "s!@ac_htmlparser_namespace@!$HTMLPARSER_NAMESPACE!g" \
-         -e "s!\\bhash\\b!hash_compare!g" \
-         "$file" >> "$outfile"
-  done
-) < "$1/windows/config.h"
-
-# log_severity.h isn't a .in file.
-echo "\
-// This file is automatically generated from $1/glog/log_severity.h
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-" > "$1/windows/glog/log_severity.h"
-cat "$1/glog/log_severity.h" >> "$1/windows/glog/log_severity.h"
-
-echo "DONE"


[19/46] incubator-quickstep git commit: Fixed the include path for farmhash.

Posted by ji...@apache.org.
Fixed the include path for farmhash.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/79bfcf9e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/79bfcf9e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/79bfcf9e

Branch: refs/heads/fix-iwyu
Commit: 79bfcf9ed294477a24823b00bd814df0de54ee5e
Parents: b5130fe
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Fri Oct 13 16:07:51 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Fri Oct 13 16:07:51 2017 -0500

----------------------------------------------------------------------
 CMakeLists.txt       | 1 +
 types/TypedValue.hpp | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/79bfcf9e/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e0d020b..071f8fc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -635,6 +635,7 @@ endif()
 
 # Add required cmake-controlled third-party libraries (farmhash, gflags, glog, and re2).
 add_subdirectory ("${THIRD_PARTY_SOURCE_DIR}/farmhash" "${CMAKE_CURRENT_BINARY_DIR}/third_party/farmhash")
+include_directories("${THIRD_PARTY_SOURCE_DIR}")
 
 add_subdirectory ("${THIRD_PARTY_SOURCE_DIR}/gflags" "${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags")
 include_directories("${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include")

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/79bfcf9e/types/TypedValue.hpp
----------------------------------------------------------------------
diff --git a/types/TypedValue.hpp b/types/TypedValue.hpp
index 0ba3d53..3075061 100644
--- a/types/TypedValue.hpp
+++ b/types/TypedValue.hpp
@@ -34,7 +34,7 @@
 #include "utility/HashPair.hpp"
 #include "utility/Macros.hpp"
 
-#include "third_party/src/farmhash/farmhash.h"
+#include "farmhash/farmhash.h"
 
 #include "glog/logging.h"
 


[06/46] incubator-quickstep git commit: Created a class to track execution statistics

Posted by ji...@apache.org.
Created a class to track execution statistics

- Stats are maintained for active operators in the query.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/1b2698d2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/1b2698d2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/1b2698d2

Branch: refs/heads/fix-iwyu
Commit: 1b2698d2225bfab59fb675da5f92a2285dd5650c
Parents: 9cbb930
Author: Harshad Deshmukh <hb...@apache.org>
Authored: Wed Sep 27 14:55:16 2017 -0500
Committer: Harshad Deshmukh <hb...@apache.org>
Committed: Fri Sep 29 12:10:52 2017 -0500

----------------------------------------------------------------------
 query_execution/CMakeLists.txt     |   5 +
 query_execution/ExecutionStats.hpp | 211 ++++++++++++++++++++++++++++++++
 2 files changed, 216 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1b2698d2/query_execution/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_execution/CMakeLists.txt b/query_execution/CMakeLists.txt
index 9394c00..8f797f7 100644
--- a/query_execution/CMakeLists.txt
+++ b/query_execution/CMakeLists.txt
@@ -29,6 +29,7 @@ if (ENABLE_DISTRIBUTED)
   add_library(quickstep_queryexecution_BlockLocator BlockLocator.cpp BlockLocator.hpp)
   add_library(quickstep_queryexecution_BlockLocatorUtil BlockLocatorUtil.cpp BlockLocatorUtil.hpp)
 endif(ENABLE_DISTRIBUTED)
+add_library(quickstep_queryexecution_ExecutionStats ../empty_src.cpp ExecutionStats.hpp)
 add_library(quickstep_queryexecution_ForemanBase ../empty_src.cpp ForemanBase.hpp)
 if (ENABLE_DISTRIBUTED)
   add_library(quickstep_queryexecution_ForemanDistributed ForemanDistributed.cpp ForemanDistributed.hpp)
@@ -123,6 +124,9 @@ if (ENABLE_DISTRIBUTED)
                         tmb
                         ${GFLAGS_LIB_NAME})
 endif(ENABLE_DISTRIBUTED)
+target_link_libraries(quickstep_queryexecution_ExecutionStats
+                      glog
+                      quickstep_utility_Macros)
 target_link_libraries(quickstep_queryexecution_ForemanSingleNode
                       glog
                       quickstep_queryexecution_AdmitRequestMessage
@@ -363,6 +367,7 @@ target_link_libraries(quickstep_queryexecution_WorkerSelectionPolicy
 add_library(quickstep_queryexecution ../empty_src.cpp QueryExecutionModule.hpp)
 target_link_libraries(quickstep_queryexecution
                       quickstep_queryexecution_AdmitRequestMessage
+                      quickstep_queryexecution_ExecutionStats
                       quickstep_queryexecution_ForemanBase
                       quickstep_queryexecution_ForemanSingleNode
                       quickstep_queryexecution_PolicyEnforcerBase

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/1b2698d2/query_execution/ExecutionStats.hpp
----------------------------------------------------------------------
diff --git a/query_execution/ExecutionStats.hpp b/query_execution/ExecutionStats.hpp
new file mode 100644
index 0000000..8d19651
--- /dev/null
+++ b/query_execution/ExecutionStats.hpp
@@ -0,0 +1,211 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ **/
+
+#ifndef QUICKSTEP_QUERY_EXECUTION_EXECUTION_STATS_HPP_
+#define QUICKSTEP_QUERY_EXECUTION_EXECUTION_STATS_HPP_
+
+#include <algorithm>
+#include <cstddef>
+#include <cstdint>
+#include <deque>
+#include <memory>
+#include <unordered_map>
+#include <utility>
+
+#include "utility/Macros.hpp"
+
+#include "glog/logging.h"
+
+namespace quickstep {
+
+/** \addtogroup QueryExecution
+ *  @{
+ */
+
+/**
+ * @brief Record the execution stats of a query.
+ *
+ * @note The time is measured in microseconds.
+ **/
+class ExecutionStats {
+ public:
+  /**
+   * @brief Constructor
+   *
+   * @param max_entries The maximum number of entries we remember for each
+   *        operator.
+   **/
+  explicit ExecutionStats(const std::size_t max_entries)
+      : max_entries_(max_entries) {}
+
+  /**
+   * @brief Get the number of active operators in stats.
+   **/
+  std::size_t getNumActiveOperators() const {
+    return active_operators_.size();
+  }
+
+  /**
+   * @brief Check if there are stats present for at least one active operator.
+   **/
+  inline bool hasStats() const {
+    for (auto it = active_operators_.begin(); it != active_operators_.end(); ++it) {
+      if (it->second->hasStatsForOperator()) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  /**
+   * @brief Get the current stats for the query.
+   *
+   * @return A pair - 1st element is total time, 2nd element is total number of
+   *         WorkOrders for the whole query.
+   **/
+  std::pair<std::uint64_t, std::uint64_t> getCurrentStatsForQuery() const {
+    std::uint64_t total_time = 0;
+    std::uint64_t num_workorders = 0;
+    for (auto it = active_operators_.begin(); it != active_operators_.end(); ++it) {
+      auto operator_stats = getCurrentStatsForOperator(it->first);
+      total_time += operator_stats.first;
+      num_workorders += operator_stats.second;
+    }
+    return std::make_pair(total_time, num_workorders);
+  }
+
+  /**
+   * @brief Get the average work order time for the query.
+   */
+  double getAverageWorkOrderTimeForQuery() const {
+    auto result = getCurrentStatsForQuery();
+    if (result.second != 0) {
+      return result.first / static_cast<double>(result.second);
+    }
+    return 0.0;
+  }
+
+  /**
+   * @brief Get the current stats for the given operator.
+   * @param operator_id The ID of the operator.
+   * @return A pair - 1st element is total time, 2nd element is total number of
+   *         WorkOrders for the operator.
+   */
+  std::pair<std::uint64_t, std::uint64_t> getCurrentStatsForOperator(const std::size_t operator_id) const {
+    if (hasOperator(operator_id)) {
+      DCHECK(active_operators_.at(operator_id) != nullptr);
+      return active_operators_.at(operator_id)->getStats();
+    }
+    return std::make_pair(0, 0);
+  }
+
+  double getAverageWorkOrderTimeForOperator(const std::size_t operator_id) const {
+    auto result = getCurrentStatsForOperator(operator_id);
+    if (result.second != 0) {
+      return result.first / static_cast<double>(result.second);
+    }
+    return 0.0;
+  }
+
+  /**
+   * @brief Add a new entry to stats.
+   *
+   * @param value The value to be added.
+   * @param operator_index The operator index which the value belongs to.
+   **/
+  void addEntry(const std::size_t value, const std::size_t operator_index) {
+    if (!hasOperator(operator_index)) {
+      // This is the first entry for the given operator.
+      // Create the OperatorStats object for this operator.
+      active_operators_[operator_index] =
+          std::make_unique<OperatorStats>(max_entries_);
+    }
+    active_operators_[operator_index]->addEntry(value);
+  }
+
+  /**
+   * @brief Remove the operator with given index. This should be called only
+   *        when the given operator finishes its execution.
+   **/
+  void removeOperator(const std::size_t operator_index) {
+    DCHECK(hasOperator(operator_index));
+    active_operators_.erase(operator_index);
+  }
+
+ private:
+  /**
+   * @brief Stats for an operator within the query.
+   *
+   * @note We remember only the last N entries for the operator.
+   **/
+  class OperatorStats {
+   public:
+    /**
+     * @brief Constructor.
+     *
+     * @param max_entries The maximum number of entries we remember. Typically
+     *        these are the last N (=max_entries) entries.
+     **/
+    explicit OperatorStats(const std::size_t max_entries) : max_entries_(max_entries) {}
+
+    inline std::pair<std::uint64_t, std::size_t> getStats() const {
+      return std::make_pair(std::accumulate(times_.begin(), times_.end(), 0),
+                            times_.size());
+    }
+
+    inline void addEntry(const std::uint64_t time_value) {
+      if (times_.size() == max_entries_) {
+        times_.pop_front();
+      }
+      times_.push_back(time_value);
+      DCHECK_LE(times_.size(), max_entries_);
+    }
+
+    inline bool hasStatsForOperator() const {
+      return !times_.empty();
+    }
+
+   private:
+    const std::size_t max_entries_;
+    // Times are measured in microseconds.
+    std::deque<std::uint64_t> times_;
+
+    DISALLOW_COPY_AND_ASSIGN(OperatorStats);
+  };
+
+  /**
+   * @brief Check if the operator with given index is present in the stats.
+   **/
+  inline bool hasOperator(const std::size_t operator_index) const {
+    return active_operators_.find(operator_index) != active_operators_.end();
+  }
+
+  const std::size_t max_entries_;
+
+  std::unordered_map<std::size_t, std::unique_ptr<OperatorStats>>
+      active_operators_;
+
+  DISALLOW_COPY_AND_ASSIGN(ExecutionStats);
+};
+
+/** @} */
+
+}  // namespace quickstep
+
+#endif  // QUICKSTEP_QUERY_EXECUTION_EXECUTION_STATS_HPP_


[18/46] incubator-quickstep git commit: Fixed gcc compiler warning.

Posted by ji...@apache.org.
Fixed gcc compiler warning.


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

Branch: refs/heads/fix-iwyu
Commit: b5130feabc571010924cacd1fa6287f4518be8d6
Parents: e79b520
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Thu Oct 12 23:01:22 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Thu Oct 12 23:01:22 2017 -0500

----------------------------------------------------------------------
 storage/Flags.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/b5130fea/storage/Flags.cpp
----------------------------------------------------------------------
diff --git a/storage/Flags.cpp b/storage/Flags.cpp
index 4672f81..7312cd3 100644
--- a/storage/Flags.cpp
+++ b/storage/Flags.cpp
@@ -40,7 +40,7 @@ static bool ValidateHdfsNameNodePort(const char *flagname,
   }
 }
 DEFINE_int32(hdfs_namenode_port, 9000, "Port of HDFS namenode.");
-static const bool hdfs_namenode_port_dummy
+static volatile const bool hdfs_namenode_port_dummy
     = gflags::RegisterFlagValidator(&FLAGS_hdfs_namenode_port, &ValidateHdfsNameNodePort);
 
 static bool ValidateHdfsNumReplications(const char *flagname,
@@ -55,7 +55,7 @@ static bool ValidateHdfsNumReplications(const char *flagname,
   }
 }
 DEFINE_int32(hdfs_num_replications, 1, "Number of HDFS file replications.");
-static const bool hdfs_num_replications_dummy
+static volatile const bool hdfs_num_replications_dummy
     = gflags::RegisterFlagValidator(&FLAGS_hdfs_num_replications, &ValidateHdfsNumReplications);
 #endif
 


[02/46] incubator-quickstep git commit: Fix a bug in LineReader for recognizing command

Posted by ji...@apache.org.
Fix a bug in LineReader for recognizing command


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/77960a42
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/77960a42
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/77960a42

Branch: refs/heads/fix-iwyu
Commit: 77960a42dcfb3d27de5601548a04d81a6be79375
Parents: 71aa8d2
Author: Jianqiao Zhu <ji...@cs.wisc.edu>
Authored: Tue Sep 19 22:02:02 2017 -0500
Committer: Jianqiao Zhu <ji...@cs.wisc.edu>
Committed: Tue Sep 19 23:00:20 2017 -0500

----------------------------------------------------------------------
 cli/CMakeLists.txt                 |  2 ++
 cli/LineReader.cpp                 | 11 +++++++++--
 cli/tests/command_executor/D.test  | 23 +++++++++++++++++++++++
 cli/tests/command_executor/Dt.test |  4 ++++
 4 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/77960a42/cli/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt
index 33d10e3..03c5408 100644
--- a/cli/CMakeLists.txt
+++ b/cli/CMakeLists.txt
@@ -189,10 +189,12 @@ if(QUICKSTEP_HAVE_LIBNUMA)
 endif()
 if(USE_LINENOISE)
   target_link_libraries(quickstep_cli_LineReader
+                        glog
                         linenoise
                         quickstep_utility_Macros)
 else()
   target_link_libraries(quickstep_cli_LineReader
+                        glog
                         quickstep_utility_Macros)
 endif()
 target_link_libraries(quickstep_cli_LineReaderBuffered

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/77960a42/cli/LineReader.cpp
----------------------------------------------------------------------
diff --git a/cli/LineReader.cpp b/cli/LineReader.cpp
index 002727d..1a23dd3 100644
--- a/cli/LineReader.cpp
+++ b/cli/LineReader.cpp
@@ -23,6 +23,8 @@
 #include <cctype>
 #include <string>
 
+#include "glog/logging.h"
+
 using std::ispunct;
 using std::size_t;
 using std::string;
@@ -171,7 +173,7 @@ std::string LineReader::getNextCommand() {
             case '.':
             case '\\':  //  Fall Through.
               // If the dot or forward slash begins the line, begin a command search.
-              if (scan_position == 0) {
+              if (special_char_location == multiline_buffer.find_first_not_of(" \t\r\n")) {
                 line_state = kCommand;
               } else {
                 // This is a regular character, so skip over it.
@@ -217,7 +219,12 @@ std::string LineReader::getNextCommand() {
             if (std::all_of(leftover_.begin(), leftover_.end(), ::isspace)) {
               leftover_.clear();
             }
-            return multiline_buffer.substr(0, special_char_location + 1);
+            // Skip all the whitespaces before the command.
+            const std::size_t start_position =
+                multiline_buffer.find_first_not_of(" \t\r\n");
+            DCHECK_LT(start_position, special_char_location + 1);
+            return multiline_buffer.substr(start_position,
+                                           special_char_location + 1 - start_position);
           }
           break;
       }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/77960a42/cli/tests/command_executor/D.test
----------------------------------------------------------------------
diff --git a/cli/tests/command_executor/D.test b/cli/tests/command_executor/D.test
index 36e9a92..c3564a6 100644
--- a/cli/tests/command_executor/D.test
+++ b/cli/tests/command_executor/D.test
@@ -58,6 +58,8 @@ INSERT INTO foo2 values(5, 1, 1.0, 1.0, 'XYZ');
 INSERT INTO foo3 values(5, 1, 1.0, 1.0, 'XYZZ');
 --
 ==
+
+
 \d foo
 --
  Table "foo"
@@ -69,6 +71,7 @@ INSERT INTO foo3 values(5, 1, 1.0, 1.0, 'XYZZ');
  col4   | Float  
  col5   | Char(5)
 ==
+
 \d foo2
 --
  Table "foo2"
@@ -80,6 +83,7 @@ INSERT INTO foo3 values(5, 1, 1.0, 1.0, 'XYZZ');
  col4                           | Float  
  averyverylongcolumnnamefortest | Char(5)
 ==
+
 \d foo3
 --
  Table "foo3"
@@ -93,6 +97,7 @@ INSERT INTO foo3 values(5, 1, 1.0, 1.0, 'XYZZ');
  Indexes
   "foo3_index_1" CSB_TREE (col1)
 ==
+
 \d foo4
 --
  Table "foo4"
@@ -107,6 +112,7 @@ INSERT INTO foo3 values(5, 1, 1.0, 1.0, 'XYZZ');
   "foo4_index_2" CSB_TREE (col3, col4)
   "foo4_index_1" CSB_TREE (col1, col2)
 ==
+
 \d foo_hash_part
 --
  Table "foo_hash_part"
@@ -118,6 +124,7 @@ INSERT INTO foo3 values(5, 1, 1.0, 1.0, 'XYZZ');
   PARTITION BY HASH ( col1 ) PARTITIONS 4
   | 1 | 1 | 1 | 1 |
 ==
+
 \d
 --
        List of relations
@@ -132,6 +139,22 @@ INSERT INTO foo3 values(5, 1, 1.0, 1.0, 'XYZZ');
  averylongtablenamethatseemstoneverend | table | 1      
 
 ==
+
+\d
+--
+       List of relations
+
+ Name                                  | Type  | Blocks 
++--------------------------------------+-------+---------+
+ foo                                   | table | 1      
+ foo2                                  | table | 1      
+ foo3                                  | table | 1      
+ foo4                                  | table | 0      
+ foo_hash_part                         | table | 4      
+ averylongtablenamethatseemstoneverend | table | 1      
+
+==
+
 \d invalidtable
 --
 ERROR:  Unrecognized relation invalidtable (1 : 4)

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/77960a42/cli/tests/command_executor/Dt.test
----------------------------------------------------------------------
diff --git a/cli/tests/command_executor/Dt.test b/cli/tests/command_executor/Dt.test
index 8d81029..022cae6 100644
--- a/cli/tests/command_executor/Dt.test
+++ b/cli/tests/command_executor/Dt.test
@@ -50,6 +50,8 @@ INSERT INTO foo2 values(5, 1, 1.0, 1.0, 'XYZ');
 INSERT INTO foo3 values(5, 1, 1.0, 1.0, 'XYZZ');
 --
 ==
+
+
 \dt
 --
        List of relations
@@ -63,6 +65,7 @@ INSERT INTO foo3 values(5, 1, 1.0, 1.0, 'XYZZ');
  averylongtablenamethatseemstoneverend | table | 1      
 
 ==
+
 \dt foo
 --
        List of relations
@@ -72,6 +75,7 @@ INSERT INTO foo3 values(5, 1, 1.0, 1.0, 'XYZZ');
  foo    | table | 1      
 
 ==
+
 \dt invalidtable
 --
 ERROR:  Unrecognized relation invalidtable (1 : 5)


[10/46] incubator-quickstep git commit: Fixed a flaky case in Catalog test.

Posted by ji...@apache.org.
Fixed a flaky case in Catalog test.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/696a783e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/696a783e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/696a783e

Branch: refs/heads/fix-iwyu
Commit: 696a783e5d8adb3ca62ca9044a8d7ccd89f67b3a
Parents: e496cb5
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Sun Oct 8 14:20:41 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Mon Oct 9 11:34:50 2017 -0500

----------------------------------------------------------------------
 catalog/tests/Catalog_unittest.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/696a783e/catalog/tests/Catalog_unittest.cpp
----------------------------------------------------------------------
diff --git a/catalog/tests/Catalog_unittest.cpp b/catalog/tests/Catalog_unittest.cpp
index f761026..7b121fa 100644
--- a/catalog/tests/Catalog_unittest.cpp
+++ b/catalog/tests/Catalog_unittest.cpp
@@ -552,13 +552,15 @@ TEST_F(CatalogTest, CatalogIndexTest) {
   IndexSubBlockDescription index_description;
   index_description.set_sub_block_type(IndexSubBlockDescription::CSB_TREE);
   index_description.add_indexed_attribute_ids(rel->getAttributeByName("attr_idx1")->getID());
+  IndexSubBlockDescription index_description_copy;
+  index_description_copy.MergeFrom(index_description);
 
   EXPECT_TRUE(rel->addIndex("idx1", std::move(index_description)));
   EXPECT_TRUE(rel->hasIndexWithName("idx1"));
   // Adding an index with duplicate name should return false.
-  EXPECT_FALSE(rel->addIndex("idx1", std::move(index_description)));
+  EXPECT_FALSE(rel->addIndex("idx1", IndexSubBlockDescription()));
   // Adding an index of same type with different name on the same attribute should return false.
-  EXPECT_FALSE(rel->addIndex("idx2", std::move(index_description)));
+  EXPECT_FALSE(rel->addIndex("idx2", std::move(index_description_copy)));
 
   index_description.Clear();
   index_description.set_sub_block_type(IndexSubBlockDescription::CSB_TREE);


[38/46] incubator-quickstep git commit: Upgrade cpplint

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/third_party/src/cpplint/cpplint.py
----------------------------------------------------------------------
diff --git a/third_party/src/cpplint/cpplint.py b/third_party/src/cpplint/cpplint.py
index 469283f..431c112 100755
--- a/third_party/src/cpplint/cpplint.py
+++ b/third_party/src/cpplint/cpplint.py
@@ -1,15 +1,4 @@
-#!/usr/bin/env python2
-#
-# Original version: svn revision 141
-#
-# This file modified for quickstep as follows:
-#   - Allow no copyright message at the top of the file.
-#   - Allow line length up to 120 characters by default.
-#   - Recognize .hpp files as C++ source.
-#   - Allow use of C++11 <chrono> header.
-#   - Supress IWYU warnings for std::tuple (since we use "tuple" as a variable
-#     name in many places).
-#   - Allow C++11 rvalue references anywhere.
+#!/usr/bin/env python
 #
 # Copyright (c) 2009 Google Inc. All rights reserved.
 #
@@ -52,6 +41,13 @@ We do a small hack, which is to ignore //'s with "'s after them on the
 same line, but it is far from perfect (in either direction).
 """
 
+"""
+Additional notes from Quickstep developers:
+commit ID: e8ffd7ce60e5c0e98ba37745749fed0222982668
+Repo: https://github.com/google/styleguide
+Changes: Remove chrono from the banned C++11 headers' list as it appears to be
+just a matter of preference for the Google chromium team.
+"""
 import codecs
 import copy
 import getopt
@@ -67,11 +63,12 @@ import unicodedata
 _USAGE = """
 Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
                    [--counting=total|toplevel|detailed] [--root=subdir]
-                   [--linelength=digits]
+                   [--linelength=digits] [--headers=x,y,...]
+                   [--quiet]
         <file> [file] ...
 
   The style guidelines this tries to follow are those in
-    http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
+    https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
 
   Every problem is given a confidence score from 1-5, with 5 meaning we are
   certain of the problem, and 1 meaning it could be a legitimate construct.
@@ -94,6 +91,9 @@ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
     verbose=#
       Specify a number 0-5 to restrict errors to certain verbosity levels.
 
+    quiet
+      Don't print anything if no errors are found.
+
     filter=-x,+y,...
       Specify a comma-separated list of category-filters to apply: only
       error messages whose category names pass the filters will be printed.
@@ -125,12 +125,13 @@ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
       ignored.
 
       Examples:
-        Assuming that src/.git exists, the header guard CPP variables for
-        src/chrome/browser/ui/browser.h are:
+        Assuming that top/src/.git exists (and cwd=top/src), the header guard
+        CPP variables for top/src/chrome/browser/ui/browser.h are:
 
         No flag => CHROME_BROWSER_UI_BROWSER_H_
         --root=chrome => BROWSER_UI_BROWSER_H_
         --root=chrome/browser => UI_BROWSER_H_
+        --root=.. => SRC_CHROME_BROWSER_UI_BROWSER_H_
 
     linelength=digits
       This is the allowed line length for the project. The default value is
@@ -145,6 +146,14 @@ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
       Examples:
         --extensions=hpp,cpp
 
+    headers=x,y,...
+      The header extensions that cpplint will treat as .h in checks. Values are
+      automatically added to --extensions list.
+
+      Examples:
+        --headers=hpp,hxx
+        --headers=hpp
+
     cpplint.py supports per-directory configurations specified in CPPLINT.cfg
     files. CPPLINT.cfg file can contain a number of key=value pairs.
     Currently the following options are supported:
@@ -153,6 +162,8 @@ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
       filter=+filter1,-filter2,...
       exclude_files=regex
       linelength=80
+      root=subdir
+      headers=x,y,...
 
     "set noparent" option prevents cpplint from traversing directory tree
     upwards looking for more .cfg files in parent directories. This option
@@ -168,6 +179,12 @@ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
 
     "linelength" allows to specify the allowed line length for the project.
 
+    The "root" option is similar in function to the --root flag (see example
+    above). Paths are relative to the directory of the CPPLINT.cfg.
+
+    The "headers" option is similar in function to the --headers flag
+    (see example above).
+
     CPPLINT.cfg has an effect on files in the same directory and all
     sub-directories, unless overridden by a nested configuration file.
 
@@ -188,6 +205,8 @@ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
 _ERROR_CATEGORIES = [
     'build/class',
     'build/c++11',
+    'build/c++14',
+    'build/c++tr1',
     'build/deprecated',
     'build/endif_comment',
     'build/explicit_make_pair',
@@ -207,7 +226,6 @@ _ERROR_CATEGORIES = [
     'readability/check',
     'readability/constructors',
     'readability/fn_size',
-    'readability/function',
     'readability/inheritance',
     'readability/multiline_comment',
     'readability/multiline_string',
@@ -238,6 +256,7 @@ _ERROR_CATEGORIES = [
     'whitespace/comma',
     'whitespace/comments',
     'whitespace/empty_conditional_body',
+    'whitespace/empty_if_body',
     'whitespace/empty_loop_body',
     'whitespace/end_of_line',
     'whitespace/ending_newline',
@@ -256,6 +275,7 @@ _ERROR_CATEGORIES = [
 # compatibility they may still appear in NOLINT comments.
 _LEGACY_ERROR_CATEGORIES = [
     'readability/streams',
+    'readability/function',
     ]
 
 # The default state of the category filter. This is overridden by the --filter=
@@ -264,6 +284,16 @@ _LEGACY_ERROR_CATEGORIES = [
 # All entries here should start with a '-' or '+', as in the --filter= flag.
 _DEFAULT_FILTERS = ['-build/include_alpha']
 
+# The default list of categories suppressed for C (not C++) files.
+_DEFAULT_C_SUPPRESSED_CATEGORIES = [
+    'readability/casting',
+    ]
+
+# The default list of categories suppressed for Linux Kernel files.
+_DEFAULT_KERNEL_SUPPRESSED_CATEGORIES = [
+    'whitespace/tab',
+    ]
+
 # We used to check for high-bit characters, but after much discussion we
 # decided those were OK, as long as they were in UTF-8 and didn't represent
 # hard-coded international strings, which belong in a separate i18n file.
@@ -357,6 +387,7 @@ _CPP_HEADERS = frozenset([
     'random',
     'ratio',
     'regex',
+    'scoped_allocator',
     'set',
     'sstream',
     'stack',
@@ -404,6 +435,19 @@ _CPP_HEADERS = frozenset([
     'cwctype',
     ])
 
+# Type names
+_TYPES = re.compile(
+    r'^(?:'
+    # [dcl.type.simple]
+    r'(char(16_t|32_t)?)|wchar_t|'
+    r'bool|short|int|long|signed|unsigned|float|double|'
+    # [support.types]
+    r'(ptrdiff_t|size_t|max_align_t|nullptr_t)|'
+    # [cstdint.syn]
+    r'(u?int(_fast|_least)?(8|16|32|64)_t)|'
+    r'(u?int(max|ptr)_t)|'
+    r')$')
+
 
 # These headers are excluded from [build/include] and [build/include_order]
 # checks:
@@ -413,16 +457,18 @@ _CPP_HEADERS = frozenset([
 _THIRD_PARTY_HEADERS_PATTERN = re.compile(
     r'^(?:[^/]*[A-Z][^/]*\.h|lua\.h|lauxlib\.h|lualib\.h)$')
 
+# Pattern for matching FileInfo.BaseName() against test file name
+_TEST_FILE_SUFFIX = r'(_test|_unittest|_regtest)$'
+
+# Pattern that matches only complete whitespace, possibly across multiple lines.
+_EMPTY_CONDITIONAL_BODY_PATTERN = re.compile(r'^\s*$', re.DOTALL)
 
 # Assertion macros.  These are defined in base/logging.h and
-# testing/base/gunit.h.  Note that the _M versions need to come first
-# for substring matching to work.
+# testing/base/public/gunit.h.
 _CHECK_MACROS = [
     'DCHECK', 'CHECK',
-    'EXPECT_TRUE_M', 'EXPECT_TRUE',
-    'ASSERT_TRUE_M', 'ASSERT_TRUE',
-    'EXPECT_FALSE_M', 'EXPECT_FALSE',
-    'ASSERT_FALSE_M', 'ASSERT_FALSE',
+    'EXPECT_TRUE', 'ASSERT_TRUE',
+    'EXPECT_FALSE', 'ASSERT_FALSE',
     ]
 
 # Replacement macros for CHECK/DCHECK/EXPECT_TRUE/EXPECT_FALSE
@@ -435,16 +481,12 @@ for op, replacement in [('==', 'EQ'), ('!=', 'NE'),
   _CHECK_REPLACEMENT['CHECK'][op] = 'CHECK_%s' % replacement
   _CHECK_REPLACEMENT['EXPECT_TRUE'][op] = 'EXPECT_%s' % replacement
   _CHECK_REPLACEMENT['ASSERT_TRUE'][op] = 'ASSERT_%s' % replacement
-  _CHECK_REPLACEMENT['EXPECT_TRUE_M'][op] = 'EXPECT_%s_M' % replacement
-  _CHECK_REPLACEMENT['ASSERT_TRUE_M'][op] = 'ASSERT_%s_M' % replacement
 
 for op, inv_replacement in [('==', 'NE'), ('!=', 'EQ'),
                             ('>=', 'LT'), ('>', 'LE'),
                             ('<=', 'GT'), ('<', 'GE')]:
   _CHECK_REPLACEMENT['EXPECT_FALSE'][op] = 'EXPECT_%s' % inv_replacement
   _CHECK_REPLACEMENT['ASSERT_FALSE'][op] = 'ASSERT_%s' % inv_replacement
-  _CHECK_REPLACEMENT['EXPECT_FALSE_M'][op] = 'EXPECT_%s_M' % inv_replacement
-  _CHECK_REPLACEMENT['ASSERT_FALSE_M'][op] = 'ASSERT_%s_M' % inv_replacement
 
 # Alternative tokens and their replacements.  For full list, see section 2.5
 # Alternative tokens [lex.digraph] in the C++ standard.
@@ -493,6 +535,12 @@ _MATCH_ASM = re.compile(r'^\s*(?:asm|_asm|__asm|__asm__)'
                         r'(?:\s+(volatile|__volatile__))?'
                         r'\s*[{(]')
 
+# Match strings that indicate we're working on a C (not C++) file.
+_SEARCH_C_FILE = re.compile(r'\b(?:LINT_C_FILE|'
+                            r'vim?:\s*.*(\s*|:)filetype=c(\s*|:|$))')
+
+# Match string that indicates we're working on a Linux Kernel file.
+_SEARCH_KERNEL_FILE = re.compile(r'\b(?:LINT_KERNEL_FILE)')
 
 _regexp_compile_cache = {}
 
@@ -503,17 +551,38 @@ _error_suppressions = {}
 # The root directory used for deriving header guard CPP variable.
 # This is set by --root flag.
 _root = None
+_root_debug = False
 
 # The allowed line length of files.
 # This is set by --linelength flag.
-_line_length = 120
+_line_length = 80
 
 # The allowed extensions for file names
 # This is set by --extensions flag.
-_valid_extensions = set(['cc', 'h', 'hpp', 'cpp', 'cu', 'cuh'])
+_valid_extensions = set(['cc', 'h', 'cpp', 'cu', 'cuh'])
+
+# Treat all headers starting with 'h' equally: .h, .hpp, .hxx etc.
+# This is set by --headers flag.
+_hpp_headers = set(['h'])
+
+# {str, bool}: a map from error categories to booleans which indicate if the
+# category should be suppressed for every line.
+_global_error_suppressions = {}
+
+def ProcessHppHeadersOption(val):
+  global _hpp_headers
+  try:
+    _hpp_headers = set(val.split(','))
+    # Automatically append to extensions list so it does not have to be set 2 times
+    _valid_extensions.update(_hpp_headers)
+  except ValueError:
+    PrintUsage('Header extensions must be comma seperated list.')
+
+def IsHeaderExtension(file_extension):
+  return file_extension in _hpp_headers
 
 def ParseNolintSuppressions(filename, raw_line, linenum, error):
-  """Updates the global list of error-suppressions.
+  """Updates the global list of line error-suppressions.
 
   Parses any NOLINT comments on the current line, updating the global
   error_suppressions store.  Reports an error if the NOLINT comment
@@ -544,24 +613,45 @@ def ParseNolintSuppressions(filename, raw_line, linenum, error):
                 'Unknown NOLINT error category: %s' % category)
 
 
+def ProcessGlobalSuppresions(lines):
+  """Updates the list of global error suppressions.
+
+  Parses any lint directives in the file that have global effect.
+
+  Args:
+    lines: An array of strings, each representing a line of the file, with the
+           last element being empty if the file is terminated with a newline.
+  """
+  for line in lines:
+    if _SEARCH_C_FILE.search(line):
+      for category in _DEFAULT_C_SUPPRESSED_CATEGORIES:
+        _global_error_suppressions[category] = True
+    if _SEARCH_KERNEL_FILE.search(line):
+      for category in _DEFAULT_KERNEL_SUPPRESSED_CATEGORIES:
+        _global_error_suppressions[category] = True
+
+
 def ResetNolintSuppressions():
   """Resets the set of NOLINT suppressions to empty."""
   _error_suppressions.clear()
+  _global_error_suppressions.clear()
 
 
 def IsErrorSuppressedByNolint(category, linenum):
   """Returns true if the specified error category is suppressed on this line.
 
   Consults the global error_suppressions map populated by
-  ParseNolintSuppressions/ResetNolintSuppressions.
+  ParseNolintSuppressions/ProcessGlobalSuppresions/ResetNolintSuppressions.
 
   Args:
     category: str, the category of the error.
     linenum: int, the current line number.
   Returns:
-    bool, True iff the error should be suppressed due to a NOLINT comment.
+    bool, True iff the error should be suppressed due to a NOLINT comment or
+    global suppression.
   """
-  return (linenum in _error_suppressions.get(category, set()) or
+  return (_global_error_suppressions.get(category, False) or
+          linenum in _error_suppressions.get(category, set()) or
           linenum in _error_suppressions.get(None, set()))
 
 
@@ -600,6 +690,11 @@ def Search(pattern, s):
   return _regexp_compile_cache[pattern].search(s)
 
 
+def _IsSourceExtension(s):
+  """File extension (excluding dot) matches a source file extension."""
+  return s in ('c', 'cc', 'cpp', 'cxx')
+
+
 class _IncludeState(object):
   """Tracks line numbers for includes, and the order in which includes appear.
 
@@ -777,6 +872,7 @@ class _CppLintState(object):
     self._filters_backup = self.filters[:]
     self.counting = 'total'  # In what way are we counting errors?
     self.errors_by_category = {}  # string to int dict storing error counts
+    self.quiet = False  # Suppress non-error messagess?
 
     # output format:
     # "emacs" - format that emacs can parse (default)
@@ -787,6 +883,12 @@ class _CppLintState(object):
     """Sets the output format for errors."""
     self.output_format = output_format
 
+  def SetQuiet(self, quiet):
+    """Sets the module's quiet settings, and returns the previous setting."""
+    last_quiet = self.quiet
+    self.quiet = quiet
+    return last_quiet
+
   def SetVerboseLevel(self, level):
     """Sets the module's verbosity, and returns the previous setting."""
     last_verbose_level = self.verbose_level
@@ -854,7 +956,7 @@ class _CppLintState(object):
     for category, count in self.errors_by_category.iteritems():
       sys.stderr.write('Category \'%s\' errors found: %d\n' %
                        (category, count))
-    sys.stderr.write('Total errors found: %d\n' % self.error_count)
+    sys.stdout.write('Total errors found: %d\n' % self.error_count)
 
 _cpplint_state = _CppLintState()
 
@@ -868,6 +970,14 @@ def _SetOutputFormat(output_format):
   """Sets the module's output format."""
   _cpplint_state.SetOutputFormat(output_format)
 
+def _Quiet():
+  """Return's the module's quiet setting."""
+  return _cpplint_state.quiet
+
+def _SetQuiet(quiet):
+  """Set the module's quiet status, and return previous setting."""
+  return _cpplint_state.SetQuiet(quiet)
+
 
 def _VerboseLevel():
   """Returns the module's verbosity setting."""
@@ -955,6 +1065,9 @@ class _FunctionState(object):
       filename: The name of the current file.
       linenum: The number of the line to check.
     """
+    if not self.in_a_function:
+      return
+
     if Match(r'T(EST|est)', self.current_function):
       base_trigger = self._TEST_TRIGGER
     else:
@@ -1025,12 +1138,13 @@ class FileInfo(object):
 
       # Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by
       # searching up from the current path.
-      root_dir = os.path.dirname(fullname)
-      while (root_dir != os.path.dirname(root_dir) and
-             not os.path.exists(os.path.join(root_dir, ".git")) and
-             not os.path.exists(os.path.join(root_dir, ".hg")) and
-             not os.path.exists(os.path.join(root_dir, ".svn"))):
-        root_dir = os.path.dirname(root_dir)
+      root_dir = current_dir = os.path.dirname(fullname)
+      while current_dir != os.path.dirname(current_dir):
+        if (os.path.exists(os.path.join(current_dir, ".git")) or
+            os.path.exists(os.path.join(current_dir, ".hg")) or
+            os.path.exists(os.path.join(current_dir, ".svn"))):
+          root_dir = current_dir
+        current_dir = os.path.dirname(current_dir)
 
       if (os.path.exists(os.path.join(root_dir, ".git")) or
           os.path.exists(os.path.join(root_dir, ".hg")) or
@@ -1069,7 +1183,7 @@ class FileInfo(object):
 
   def IsSource(self):
     """File has a source file extension."""
-    return self.Extension()[1:] in ('c', 'cc', 'cpp', 'cxx')
+    return _IsSourceExtension(self.Extension()[1:])
 
 
 def _ShouldPrintError(category, confidence, linenum):
@@ -1125,8 +1239,8 @@ def Error(filename, linenum, category, confidence, message):
   if _ShouldPrintError(category, confidence, linenum):
     _cpplint_state.IncrementErrorCount(category)
     if _cpplint_state.output_format == 'vs7':
-      sys.stderr.write('%s(%s):  %s  [%s] [%d]\n' % (
-          filename, linenum, message, category, confidence))
+      sys.stderr.write('%s(%s): error cpplint: [%s] %s [%d]\n' % (
+          filename, linenum, category, message, confidence))
     elif _cpplint_state.output_format == 'eclipse':
       sys.stderr.write('%s:%s: warning: %s  [%s] [%d]\n' % (
           filename, linenum, message, category, confidence))
@@ -1215,8 +1329,18 @@ def CleanseRawStrings(raw_lines):
     while delimiter is None:
       # Look for beginning of a raw string.
       # See 2.14.15 [lex.string] for syntax.
-      matched = Match(r'^(.*)\b(?:R|u8R|uR|UR|LR)"([^\s\\()]*)\((.*)$', line)
-      if matched:
+      #
+      # Once we have matched a raw string, we check the prefix of the
+      # line to make sure that the line is not part of a single line
+      # comment.  It's done this way because we remove raw strings
+      # before removing comments as opposed to removing comments
+      # before removing raw strings.  This is because there are some
+      # cpplint checks that requires the comments to be preserved, but
+      # we don't want to check comments that are inside raw strings.
+      matched = Match(r'^(.*?)\b(?:R|u8R|uR|UR|LR)"([^\s\\()]*)\((.*)$', line)
+      if (matched and
+          not Match(r'^([^\'"]|\'(\\.|[^\'])*\'|"(\\.|[^"])*")*//',
+                    matched.group(1))):
         delimiter = ')' + matched.group(2) + '"'
 
         end = matched.group(3).find(delimiter)
@@ -1658,6 +1782,30 @@ def GetIndentLevel(line):
   else:
     return 0
 
+def PathSplitToList(path):
+  """Returns the path split into a list by the separator.
+
+  Args:
+    path: An absolute or relative path (e.g. '/a/b/c/' or '../a')
+
+  Returns:
+    A list of path components (e.g. ['a', 'b', 'c]).
+  """
+  lst = []
+  while True:
+    (head, tail) = os.path.split(path)
+    if head == path: # absolute paths end
+      lst.append(head)
+      break
+    if tail == path: # relative paths end
+      lst.append(tail)
+      break
+
+    path = head
+    lst.append(tail)
+
+  lst.reverse()
+  return lst
 
 def GetHeaderGuardCPPVariable(filename):
   """Returns the CPP variable that should be used as a header guard.
@@ -1680,8 +1828,58 @@ def GetHeaderGuardCPPVariable(filename):
 
   fileinfo = FileInfo(filename)
   file_path_from_root = fileinfo.RepositoryName()
-  if _root:
-    file_path_from_root = re.sub('^' + _root + os.sep, '', file_path_from_root)
+
+  def FixupPathFromRoot():
+    if _root_debug:
+      sys.stderr.write("\n_root fixup, _root = '%s', repository name = '%s'\n"
+          %(_root, fileinfo.RepositoryName()))
+
+    # Process the file path with the --root flag if it was set.
+    if not _root:
+      if _root_debug:
+        sys.stderr.write("_root unspecified\n")
+      return file_path_from_root
+
+    def StripListPrefix(lst, prefix):
+      # f(['x', 'y'], ['w, z']) -> None  (not a valid prefix)
+      if lst[:len(prefix)] != prefix:
+        return None
+      # f(['a, 'b', 'c', 'd'], ['a', 'b']) -> ['c', 'd']
+      return lst[(len(prefix)):]
+
+    # root behavior:
+    #   --root=subdir , lstrips subdir from the header guard
+    maybe_path = StripListPrefix(PathSplitToList(file_path_from_root),
+                                 PathSplitToList(_root))
+
+    if _root_debug:
+      sys.stderr.write("_root lstrip (maybe_path=%s, file_path_from_root=%s," +
+          " _root=%s)\n" %(maybe_path, file_path_from_root, _root))
+
+    if maybe_path:
+      return os.path.join(*maybe_path)
+
+    #   --root=.. , will prepend the outer directory to the header guard
+    full_path = fileinfo.FullName()
+    root_abspath = os.path.abspath(_root)
+
+    maybe_path = StripListPrefix(PathSplitToList(full_path),
+                                 PathSplitToList(root_abspath))
+
+    if _root_debug:
+      sys.stderr.write("_root prepend (maybe_path=%s, full_path=%s, " +
+          "root_abspath=%s)\n" %(maybe_path, full_path, root_abspath))
+
+    if maybe_path:
+      return os.path.join(*maybe_path)
+
+    if _root_debug:
+      sys.stderr.write("_root ignore, returning %s\n" %(file_path_from_root))
+
+    #   --root=FAKE_DIR is ignored
+    return file_path_from_root
+
+  file_path_from_root = FixupPathFromRoot()
   return re.sub(r'[^a-zA-Z0-9]', '_', file_path_from_root).upper() + '_'
 
 
@@ -1787,11 +1985,11 @@ def CheckHeaderFileIncluded(filename, include_state, error):
   """Logs an error if a .cc file does not include its header."""
 
   # Do not check test files
-  if filename.endswith('_test.cc') or filename.endswith('_unittest.cc'):
+  fileinfo = FileInfo(filename)
+  if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()):
     return
 
-  fileinfo = FileInfo(filename)
-  headerfile = filename[0:len(filename) - 2] + 'h'
+  headerfile = filename[0:len(filename) - len(fileinfo.Extension())] + '.h'
   if not os.path.exists(headerfile):
     return
   headername = FileInfo(headerfile).RepositoryName()
@@ -2008,7 +2206,8 @@ def IsForwardClassDeclaration(clean_lines, linenum):
 class _BlockInfo(object):
   """Stores information about a generic block of code."""
 
-  def __init__(self, seen_open_brace):
+  def __init__(self, linenum, seen_open_brace):
+    self.starting_linenum = linenum
     self.seen_open_brace = seen_open_brace
     self.open_parentheses = 0
     self.inline_asm = _NO_ASM
@@ -2057,17 +2256,16 @@ class _BlockInfo(object):
 class _ExternCInfo(_BlockInfo):
   """Stores information about an 'extern "C"' block."""
 
-  def __init__(self):
-    _BlockInfo.__init__(self, True)
+  def __init__(self, linenum):
+    _BlockInfo.__init__(self, linenum, True)
 
 
 class _ClassInfo(_BlockInfo):
   """Stores information about a class."""
 
   def __init__(self, name, class_or_struct, clean_lines, linenum):
-    _BlockInfo.__init__(self, False)
+    _BlockInfo.__init__(self, linenum, False)
     self.name = name
-    self.starting_linenum = linenum
     self.is_derived = False
     self.check_namespace_indentation = True
     if class_or_struct == 'struct':
@@ -2135,9 +2333,8 @@ class _NamespaceInfo(_BlockInfo):
   """Stores information about a namespace."""
 
   def __init__(self, name, linenum):
-    _BlockInfo.__init__(self, False)
+    _BlockInfo.__init__(self, linenum, False)
     self.name = name or ''
-    self.starting_linenum = linenum
     self.check_namespace_indentation = True
 
   def CheckEnd(self, filename, clean_lines, linenum, error):
@@ -2156,7 +2353,7 @@ class _NamespaceInfo(_BlockInfo):
     # deciding what these nontrivial things are, so this check is
     # triggered by namespace size only, which works most of the time.
     if (linenum - self.starting_linenum < 10
-        and not Match(r'};*\s*(//|/\*).*\bnamespace\b', line)):
+        and not Match(r'^\s*};*\s*(//|/\*).*\bnamespace\b', line)):
       return
 
     # Look for matching comment at end of namespace.
@@ -2173,18 +2370,18 @@ class _NamespaceInfo(_BlockInfo):
     # expected namespace.
     if self.name:
       # Named namespace
-      if not Match((r'};*\s*(//|/\*).*\bnamespace\s+' + re.escape(self.name) +
-                    r'[\*/\.\\\s]*$'),
+      if not Match((r'^\s*};*\s*(//|/\*).*\bnamespace\s+' +
+                    re.escape(self.name) + r'[\*/\.\\\s]*$'),
                    line):
         error(filename, linenum, 'readability/namespace', 5,
               'Namespace should be terminated with "// namespace %s"' %
               self.name)
     else:
       # Anonymous namespace
-      if not Match(r'};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line):
+      if not Match(r'^\s*};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line):
         # If "// namespace anonymous" or "// anonymous namespace (more text)",
         # mention "// anonymous namespace" as an acceptable form
-        if Match(r'}.*\b(namespace anonymous|anonymous namespace)\b', line):
+        if Match(r'^\s*}.*\b(namespace anonymous|anonymous namespace)\b', line):
           error(filename, linenum, 'readability/namespace', 5,
                 'Anonymous namespace should be terminated with "// namespace"'
                 ' or "// anonymous namespace"')
@@ -2523,9 +2720,9 @@ class NestingState(object):
         if not self.SeenOpenBrace():
           self.stack[-1].seen_open_brace = True
         elif Match(r'^extern\s*"[^"]*"\s*\{', line):
-          self.stack.append(_ExternCInfo())
+          self.stack.append(_ExternCInfo(linenum))
         else:
-          self.stack.append(_BlockInfo(True))
+          self.stack.append(_BlockInfo(linenum, True))
           if _MATCH_ASM.match(line):
             self.stack[-1].inline_asm = _BLOCK_ASM
 
@@ -2637,7 +2834,8 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum,
             r'\s+(register|static|extern|typedef)\b',
             line):
     error(filename, linenum, 'build/storage_class', 5,
-          'Storage class (static, extern, typedef, etc) should be first.')
+          'Storage-class specifier (static, extern, typedef, etc) should be '
+          'at the beginning of the declaration.')
 
   if Match(r'\s*#\s*endif\s*[^/\s]+', line):
     error(filename, linenum, 'build/endif_comment', 5,
@@ -2676,11 +2874,10 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum,
   base_classname = classinfo.name.split('::')[-1]
 
   # Look for single-argument constructors that aren't marked explicit.
-  # Technically a valid construct, but against style. Also look for
-  # non-single-argument constructors which are also technically valid, but
-  # strongly suggest something is wrong.
+  # Technically a valid construct, but against style.
   explicit_constructor_match = Match(
-      r'\s+(?:inline\s+)?(explicit\s+)?(?:inline\s+)?%s\s*'
+      r'\s+(?:(?:inline|constexpr)\s+)*(explicit\s+)?'
+      r'(?:(?:inline|constexpr)\s+)*%s\s*'
       r'\(((?:[^()]|\([^()]*\))*)\)'
       % re.escape(base_classname),
       line)
@@ -2739,10 +2936,6 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum,
       if noarg_constructor:
         error(filename, linenum, 'runtime/explicit', 5,
               'Zero-parameter constructors should not be marked explicit.')
-      else:
-        error(filename, linenum, 'runtime/explicit', 0,
-              'Constructors that require multiple arguments '
-              'should not be marked explicit.')
 
 
 def CheckSpacingForFunctionCall(filename, clean_lines, linenum, error):
@@ -2797,6 +2990,7 @@ def CheckSpacingForFunctionCall(filename, clean_lines, linenum, error):
       error(filename, linenum, 'whitespace/parens', 2,
             'Extra space after (')
     if (Search(r'\w\s+\(', fncall) and
+        not Search(r'_{0,2}asm_{0,2}\s+_{0,2}volatile_{0,2}\s+\(', fncall) and
         not Search(r'#\s*define|typedef|using\s+\w+\s*=', fncall) and
         not Search(r'\w\s+\((\w+::)*\*\w+\)\(', fncall) and
         not Search(r'\bcase\s+\(', fncall)):
@@ -2855,7 +3049,7 @@ def CheckForFunctionLengths(filename, clean_lines, linenum,
   """Reports for long function bodies.
 
   For an overview why this is done, see:
-  http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions
+  https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions
 
   Uses a simplistic algorithm assuming other style guidelines
   (especially spacing) are followed.
@@ -2934,9 +3128,7 @@ def CheckComment(line, filename, linenum, next_line_start, error):
   commentpos = line.find('//')
   if commentpos != -1:
     # Check if the // may be in quotes.  If so, ignore it
-    # Comparisons made explicit for clarity -- pylint: disable=g-explicit-bool-comparison
-    if (line.count('"', 0, commentpos) -
-        line.count('\\"', 0, commentpos)) % 2 == 0:   # not in quotes
+    if re.sub(r'\\.', '', line[0:commentpos]).count('"') % 2 == 0:
       # Allow one space for new scopes, two spaces otherwise:
       if (not (Match(r'^.*{ *//', line) and next_line_start == commentpos) and
           ((commentpos >= 1 and
@@ -2977,36 +3169,6 @@ def CheckComment(line, filename, linenum, next_line_start, error):
               'Should have a space between // and comment')
 
 
-def CheckAccess(filename, clean_lines, linenum, nesting_state, error):
-  """Checks for improper use of DISALLOW* macros.
-
-  Args:
-    filename: The name of the current file.
-    clean_lines: A CleansedLines instance containing the file.
-    linenum: The number of the line to check.
-    nesting_state: A NestingState instance which maintains information about
-                   the current stack of nested blocks being parsed.
-    error: The function to call with any errors found.
-  """
-  line = clean_lines.elided[linenum]  # get rid of comments and strings
-
-  matched = Match((r'\s*(DISALLOW_COPY_AND_ASSIGN|'
-                   r'DISALLOW_IMPLICIT_CONSTRUCTORS)'), line)
-  if not matched:
-    return
-  if nesting_state.stack and isinstance(nesting_state.stack[-1], _ClassInfo):
-    if nesting_state.stack[-1].access != 'private':
-      error(filename, linenum, 'readability/constructors', 3,
-            '%s must be in the private: section' % matched.group(1))
-
-  else:
-    # Found DISALLOW* macro outside a class declaration, or perhaps it
-    # was used inside a function when it should have been part of the
-    # class declaration.  We could issue a warning here, but it
-    # probably resulted in a compiler error already.
-    pass
-
-
 def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
   """Checks for the correctness of various spacing issues in the code.
 
@@ -3185,8 +3347,8 @@ def CheckOperatorSpacing(filename, clean_lines, linenum, error):
   # macro context and don't do any checks.  This avoids false
   # positives.
   #
-  # Note that && is not included here.  Those are checked separately
-  # in CheckRValueReference
+  # Note that && is not included here.  This is because there are too
+  # many false positives due to RValue references.
   match = Search(r'[^<>=!\s](==|!=|<=|>=|\|\|)[^<>=!\s,;\)]', line)
   if match:
     error(filename, linenum, 'whitespace/operators', 3,
@@ -3220,7 +3382,7 @@ def CheckOperatorSpacing(filename, clean_lines, linenum, error):
   #
   # We also allow operators following an opening parenthesis, since
   # those tend to be macros that deal with operators.
-  match = Search(r'(operator|[^\s(<])(?:L|UL|ULL|l|ul|ull)?<<([^\s,=<])', line)
+  match = Search(r'(operator|[^\s(<])(?:L|UL|LL|ULL|l|ul|ll|ull)?<<([^\s,=<])', line)
   if (match and not (match.group(1).isdigit() and match.group(2).isdigit()) and
       not (match.group(1) == 'operator' and match.group(2) == ';')):
     error(filename, linenum, 'whitespace/operators', 3,
@@ -3324,22 +3486,90 @@ def CheckCommaSpacing(filename, clean_lines, linenum, error):
           'Missing space after ;')
 
 
-def CheckBracesSpacing(filename, clean_lines, linenum, error):
+def _IsType(clean_lines, nesting_state, expr):
+  """Check if expression looks like a type name, returns true if so.
+
+  Args:
+    clean_lines: A CleansedLines instance containing the file.
+    nesting_state: A NestingState instance which maintains information about
+                   the current stack of nested blocks being parsed.
+    expr: The expression to check.
+  Returns:
+    True, if token looks like a type.
+  """
+  # Keep only the last token in the expression
+  last_word = Match(r'^.*(\b\S+)$', expr)
+  if last_word:
+    token = last_word.group(1)
+  else:
+    token = expr
+
+  # Match native types and stdint types
+  if _TYPES.match(token):
+    return True
+
+  # Try a bit harder to match templated types.  Walk up the nesting
+  # stack until we find something that resembles a typename
+  # declaration for what we are looking for.
+  typename_pattern = (r'\b(?:typename|class|struct)\s+' + re.escape(token) +
+                      r'\b')
+  block_index = len(nesting_state.stack) - 1
+  while block_index >= 0:
+    if isinstance(nesting_state.stack[block_index], _NamespaceInfo):
+      return False
+
+    # Found where the opening brace is.  We want to scan from this
+    # line up to the beginning of the function, minus a few lines.
+    #   template <typename Type1,  // stop scanning here
+    #             ...>
+    #   class C
+    #     : public ... {  // start scanning here
+    last_line = nesting_state.stack[block_index].starting_linenum
+
+    next_block_start = 0
+    if block_index > 0:
+      next_block_start = nesting_state.stack[block_index - 1].starting_linenum
+    first_line = last_line
+    while first_line >= next_block_start:
+      if clean_lines.elided[first_line].find('template') >= 0:
+        break
+      first_line -= 1
+    if first_line < next_block_start:
+      # Didn't find any "template" keyword before reaching the next block,
+      # there are probably no template things to check for this block
+      block_index -= 1
+      continue
+
+    # Look for typename in the specified range
+    for i in xrange(first_line, last_line + 1, 1):
+      if Search(typename_pattern, clean_lines.elided[i]):
+        return True
+    block_index -= 1
+
+  return False
+
+
+def CheckBracesSpacing(filename, clean_lines, linenum, nesting_state, error):
   """Checks for horizontal spacing near commas.
 
   Args:
     filename: The name of the current file.
     clean_lines: A CleansedLines instance containing the file.
     linenum: The number of the line to check.
+    nesting_state: A NestingState instance which maintains information about
+                   the current stack of nested blocks being parsed.
     error: The function to call with any errors found.
   """
   line = clean_lines.elided[linenum]
 
   # Except after an opening paren, or after another opening brace (in case of
   # an initializer list, for instance), you should have spaces before your
-  # braces. And since you should never have braces at the beginning of a line,
-  # this is an easy test.
+  # braces when they are delimiting blocks, classes, namespaces etc.
+  # And since you should never have braces at the beginning of a line,
+  # this is an easy test.  Except that braces used for initialization don't
+  # follow the same rule; we often don't want spaces before those.
   match = Match(r'^(.*[^ ({>]){', line)
+
   if match:
     # Try a bit harder to check for brace initialization.  This
     # happens in one of the following forms:
@@ -3369,6 +3599,7 @@ def CheckBracesSpacing(filename, clean_lines, linenum, error):
     # There is a false negative with this approach if people inserted
     # spurious semicolons, e.g. "if (cond){};", but we will catch the
     # spurious semicolon with a separate check.
+    leading_text = match.group(1)
     (endline, endlinenum, endpos) = CloseExpression(
         clean_lines, linenum, len(match.group(1)))
     trailing_text = ''
@@ -3377,7 +3608,11 @@ def CheckBracesSpacing(filename, clean_lines, linenum, error):
     for offset in xrange(endlinenum + 1,
                          min(endlinenum + 3, clean_lines.NumLines() - 1)):
       trailing_text += clean_lines.elided[offset]
-    if not Match(r'^[\s}]*[{.;,)<>\]:]', trailing_text):
+    # We also suppress warnings for `uint64_t{expression}` etc., as the style
+    # guide recommends brace initialization for integral types to avoid
+    # overflow/truncation.
+    if (not Match(r'^[\s}]*[{.;,)<>\]:]', trailing_text)
+        and not _IsType(clean_lines, nesting_state, leading_text)):
       error(filename, linenum, 'whitespace/braces', 5,
             'Missing space before {')
 
@@ -3421,361 +3656,6 @@ def IsDecltype(clean_lines, linenum, column):
   return False
 
 
-def IsTemplateParameterList(clean_lines, linenum, column):
-  """Check if the token ending on (linenum, column) is the end of template<>.
-
-  Args:
-    clean_lines: A CleansedLines instance containing the file.
-    linenum: the number of the line to check.
-    column: end column of the token to check.
-  Returns:
-    True if this token is end of a template parameter list, False otherwise.
-  """
-  (_, startline, startpos) = ReverseCloseExpression(
-      clean_lines, linenum, column)
-  if (startpos > -1 and
-      Search(r'\btemplate\s*$', clean_lines.elided[startline][0:startpos])):
-    return True
-  return False
-
-
-def IsRValueType(typenames, clean_lines, nesting_state, linenum, column):
-  """Check if the token ending on (linenum, column) is a type.
-
-  Assumes that text to the right of the column is "&&" or a function
-  name.
-
-  Args:
-    typenames: set of type names from template-argument-list.
-    clean_lines: A CleansedLines instance containing the file.
-    nesting_state: A NestingState instance which maintains information about
-                   the current stack of nested blocks being parsed.
-    linenum: the number of the line to check.
-    column: end column of the token to check.
-  Returns:
-    True if this token is a type, False if we are not sure.
-  """
-  prefix = clean_lines.elided[linenum][0:column]
-
-  # Get one word to the left.  If we failed to do so, this is most
-  # likely not a type, since it's unlikely that the type name and "&&"
-  # would be split across multiple lines.
-  match = Match(r'^(.*)(\b\w+|[>*)&])\s*$', prefix)
-  if not match:
-    return False
-
-  # Check text following the token.  If it's "&&>" or "&&," or "&&...", it's
-  # most likely a rvalue reference used inside a template.
-  suffix = clean_lines.elided[linenum][column:]
-  if Match(r'&&\s*(?:[>,]|\.\.\.)', suffix):
-    return True
-
-  # Check for known types and end of templates:
-  #   int&& variable
-  #   vector<int>&& variable
-  #
-  # Because this function is called recursively, we also need to
-  # recognize pointer and reference types:
-  #   int* Function()
-  #   int& Function()
-  if (match.group(2) in typenames or
-      match.group(2) in ['char', 'char16_t', 'char32_t', 'wchar_t', 'bool',
-                         'short', 'int', 'long', 'signed', 'unsigned',
-                         'float', 'double', 'void', 'auto', '>', '*', '&']):
-    return True
-
-  # If we see a close parenthesis, look for decltype on the other side.
-  # decltype would unambiguously identify a type, anything else is
-  # probably a parenthesized expression and not a type.
-  if match.group(2) == ')':
-    return IsDecltype(
-        clean_lines, linenum, len(match.group(1)) + len(match.group(2)) - 1)
-
-  # Check for casts and cv-qualifiers.
-  #   match.group(1)  remainder
-  #   --------------  ---------
-  #   const_cast<     type&&
-  #   const           type&&
-  #   type            const&&
-  if Search(r'\b(?:const_cast\s*<|static_cast\s*<|dynamic_cast\s*<|'
-            r'reinterpret_cast\s*<|\w+\s)\s*$',
-            match.group(1)):
-    return True
-
-  # Look for a preceding symbol that might help differentiate the context.
-  # These are the cases that would be ambiguous:
-  #   match.group(1)  remainder
-  #   --------------  ---------
-  #   Call         (   expression &&
-  #   Declaration  (   type&&
-  #   sizeof       (   type&&
-  #   if           (   expression &&
-  #   while        (   expression &&
-  #   for          (   type&&
-  #   for(         ;   expression &&
-  #   statement    ;   type&&
-  #   block        {   type&&
-  #   constructor  {   expression &&
-  start = linenum
-  line = match.group(1)
-  match_symbol = None
-  while start >= 0:
-    # We want to skip over identifiers and commas to get to a symbol.
-    # Commas are skipped so that we can find the opening parenthesis
-    # for function parameter lists.
-    match_symbol = Match(r'^(.*)([^\w\s,])[\w\s,]*$', line)
-    if match_symbol:
-      break
-    start -= 1
-    line = clean_lines.elided[start]
-
-  if not match_symbol:
-    # Probably the first statement in the file is an rvalue reference
-    return True
-
-  if match_symbol.group(2) == '}':
-    # Found closing brace, probably an indicate of this:
-    #   block{} type&&
-    return True
-
-  if match_symbol.group(2) == ';':
-    # Found semicolon, probably one of these:
-    #   for(; expression &&
-    #   statement; type&&
-
-    # Look for the previous 'for(' in the previous lines.
-    before_text = match_symbol.group(1)
-    for i in xrange(start - 1, max(start - 6, 0), -1):
-      before_text = clean_lines.elided[i] + before_text
-    if Search(r'for\s*\([^{};]*$', before_text):
-      # This is the condition inside a for-loop
-      return False
-
-    # Did not find a for-init-statement before this semicolon, so this
-    # is probably a new statement and not a condition.
-    return True
-
-  if match_symbol.group(2) == '{':
-    # Found opening brace, probably one of these:
-    #   block{ type&& = ... ; }
-    #   constructor{ expression && expression }
-
-    # Look for a closing brace or a semicolon.  If we see a semicolon
-    # first, this is probably a rvalue reference.
-    line = clean_lines.elided[start][0:len(match_symbol.group(1)) + 1]
-    end = start
-    depth = 1
-    while True:
-      for ch in line:
-        if ch == ';':
-          return True
-        elif ch == '{':
-          depth += 1
-        elif ch == '}':
-          depth -= 1
-          if depth == 0:
-            return False
-      end += 1
-      if end >= clean_lines.NumLines():
-        break
-      line = clean_lines.elided[end]
-    # Incomplete program?
-    return False
-
-  if match_symbol.group(2) == '(':
-    # Opening parenthesis.  Need to check what's to the left of the
-    # parenthesis.  Look back one extra line for additional context.
-    before_text = match_symbol.group(1)
-    if linenum > 1:
-      before_text = clean_lines.elided[linenum - 1] + before_text
-    before_text = match_symbol.group(1)
-
-    # Patterns that are likely to be types:
-    #   [](type&&
-    #   for (type&&
-    #   sizeof(type&&
-    #   operator=(type&&
-    #
-    if Search(r'(?:\]|\bfor|\bsizeof|\boperator\s*\S+\s*)\s*$', before_text):
-      return True
-
-    # Patterns that are likely to be expressions:
-    #   if (expression &&
-    #   while (expression &&
-    #   : initializer(expression &&
-    #   , initializer(expression &&
-    #   ( FunctionCall(expression &&
-    #   + FunctionCall(expression &&
-    #   + (expression &&
-    #
-    # The last '+' represents operators such as '+' and '-'.
-    if Search(r'(?:\bif|\bwhile|[-+=%^(<!?:,&*]\s*)$', before_text):
-      return False
-
-    # Something else.  Check that tokens to the left look like
-    #   return_type function_name
-    match_func = Match(r'^(.*\S.*)\s+\w(?:\w|::)*(?:<[^<>]*>)?\s*$',
-                       match_symbol.group(1))
-    if match_func:
-      # Check for constructors, which don't have return types.
-      if Search(r'\b(?:explicit|inline)$', match_func.group(1)):
-        return True
-      implicit_constructor = Match(r'\s*(\w+)\((?:const\s+)?(\w+)', prefix)
-      if (implicit_constructor and
-          implicit_constructor.group(1) == implicit_constructor.group(2)):
-        return True
-      return IsRValueType(typenames, clean_lines, nesting_state, linenum,
-                          len(match_func.group(1)))
-
-    # Nothing before the function name.  If this is inside a block scope,
-    # this is probably a function call.
-    return not (nesting_state.previous_stack_top and
-                nesting_state.previous_stack_top.IsBlockInfo())
-
-  if match_symbol.group(2) == '>':
-    # Possibly a closing bracket, check that what's on the other side
-    # looks like the start of a template.
-    return IsTemplateParameterList(
-        clean_lines, start, len(match_symbol.group(1)))
-
-  # Some other symbol, usually something like "a=b&&c".  This is most
-  # likely not a type.
-  return False
-
-
-def IsDeletedOrDefault(clean_lines, linenum):
-  """Check if current constructor or operator is deleted or default.
-
-  Args:
-    clean_lines: A CleansedLines instance containing the file.
-    linenum: The number of the line to check.
-  Returns:
-    True if this is a deleted or default constructor.
-  """
-  open_paren = clean_lines.elided[linenum].find('(')
-  if open_paren < 0:
-    return False
-  (close_line, _, close_paren) = CloseExpression(
-      clean_lines, linenum, open_paren)
-  if close_paren < 0:
-    return False
-  return Match(r'\s*=\s*(?:delete|default)\b', close_line[close_paren:])
-
-
-def IsRValueAllowed(clean_lines, linenum, typenames):
-  """Check if RValue reference is allowed on a particular line.
-
-  Args:
-    clean_lines: A CleansedLines instance containing the file.
-    linenum: The number of the line to check.
-    typenames: set of type names from template-argument-list.
-  Returns:
-    True if line is within the region where RValue references are allowed.
-  """
-  # Allow region marked by PUSH/POP macros
-  return True
-
-
-def GetTemplateArgs(clean_lines, linenum):
-  """Find list of template arguments associated with this function declaration.
-
-  Args:
-    clean_lines: A CleansedLines instance containing the file.
-    linenum: Line number containing the start of the function declaration,
-             usually one line after the end of the template-argument-list.
-  Returns:
-    Set of type names, or empty set if this does not appear to have
-    any template parameters.
-  """
-  # Find start of function
-  func_line = linenum
-  while func_line > 0:
-    line = clean_lines.elided[func_line]
-    if Match(r'^\s*$', line):
-      return set()
-    if line.find('(') >= 0:
-      break
-    func_line -= 1
-  if func_line == 0:
-    return set()
-
-  # Collapse template-argument-list into a single string
-  argument_list = ''
-  match = Match(r'^(\s*template\s*)<', clean_lines.elided[func_line])
-  if match:
-    # template-argument-list on the same line as function name
-    start_col = len(match.group(1))
-    _, end_line, end_col = CloseExpression(clean_lines, func_line, start_col)
-    if end_col > -1 and end_line == func_line:
-      start_col += 1  # Skip the opening bracket
-      argument_list = clean_lines.elided[func_line][start_col:end_col]
-
-  elif func_line > 1:
-    # template-argument-list one line before function name
-    match = Match(r'^(.*)>\s*$', clean_lines.elided[func_line - 1])
-    if match:
-      end_col = len(match.group(1))
-      _, start_line, start_col = ReverseCloseExpression(
-          clean_lines, func_line - 1, end_col)
-      if start_col > -1:
-        start_col += 1  # Skip the opening bracket
-        while start_line < func_line - 1:
-          argument_list += clean_lines.elided[start_line][start_col:]
-          start_col = 0
-          start_line += 1
-        argument_list += clean_lines.elided[func_line - 1][start_col:end_col]
-
-  if not argument_list:
-    return set()
-
-  # Extract type names
-  typenames = set()
-  while True:
-    match = Match(r'^[,\s]*(?:typename|class)(?:\.\.\.)?\s+(\w+)(.*)$',
-                  argument_list)
-    if not match:
-      break
-    typenames.add(match.group(1))
-    argument_list = match.group(2)
-  return typenames
-
-
-def CheckRValueReference(filename, clean_lines, linenum, nesting_state, error):
-  """Check for rvalue references.
-
-  Args:
-    filename: The name of the current file.
-    clean_lines: A CleansedLines instance containing the file.
-    linenum: The number of the line to check.
-    nesting_state: A NestingState instance which maintains information about
-                   the current stack of nested blocks being parsed.
-    error: The function to call with any errors found.
-  """
-  # Find lines missing spaces around &&.
-  # TODO(unknown): currently we don't check for rvalue references
-  # with spaces surrounding the && to avoid false positives with
-  # boolean expressions.
-  line = clean_lines.elided[linenum]
-  match = Match(r'^(.*\S)&&', line)
-  if not match:
-    match = Match(r'(.*)&&\S', line)
-  if (not match) or '(&&)' in line or Search(r'\boperator\s*$', match.group(1)):
-    return
-
-  # Either poorly formed && or an rvalue reference, check the context
-  # to get a more accurate error message.  Mostly we want to determine
-  # if what's to the left of "&&" is a type or not.
-  typenames = GetTemplateArgs(clean_lines, linenum)
-  and_pos = len(match.group(1))
-  if IsRValueType(typenames, clean_lines, nesting_state, linenum, and_pos):
-    if not IsRValueAllowed(clean_lines, linenum, typenames):
-      error(filename, linenum, 'build/c++11', 3,
-            'RValue references are an unapproved C++ feature.')
-  else:
-    error(filename, linenum, 'whitespace/operators', 3,
-          'Missing spaces around &&')
-
-
 def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error):
   """Checks for additional blank line issues related to sections.
 
@@ -3873,10 +3753,13 @@ def CheckBraces(filename, clean_lines, linenum, error):
     # used for brace initializers inside function calls.  We don't detect this
     # perfectly: we just don't complain if the last non-whitespace character on
     # the previous non-blank line is ',', ';', ':', '(', '{', or '}', or if the
-    # previous line starts a preprocessor block.
+    # previous line starts a preprocessor block. We also allow a brace on the
+    # following line if it is part of an array initialization and would not fit
+    # within the 80 character limit of the preceding line.
     prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0]
     if (not Search(r'[,;:}{(]\s*$', prevline) and
-        not Match(r'\s*#', prevline)):
+        not Match(r'\s*#', prevline) and
+        not (GetLineWidth(prevline) > _line_length - 2 and '[]' in prevline)):
       error(filename, linenum, 'whitespace/braces', 4,
             '{ should almost always be at the end of the previous line')
 
@@ -4052,13 +3935,14 @@ def CheckTrailingSemicolon(filename, clean_lines, linenum, error):
     # In addition to macros, we also don't want to warn on
     #  - Compound literals
     #  - Lambdas
-    #  - alignas specifier with anonymous structs:
+    #  - alignas specifier with anonymous structs
+    #  - decltype
     closing_brace_pos = match.group(1).rfind(')')
     opening_parenthesis = ReverseCloseExpression(
         clean_lines, linenum, closing_brace_pos)
     if opening_parenthesis[2] > -1:
       line_prefix = opening_parenthesis[0][0:opening_parenthesis[2]]
-      macro = Search(r'\b([A-Z_]+)\s*$', line_prefix)
+      macro = Search(r'\b([A-Z_][A-Z0-9_]*)\s*$', line_prefix)
       func = Match(r'^(.*\])\s*$', line_prefix)
       if ((macro and
            macro.group(1) not in (
@@ -4067,6 +3951,7 @@ def CheckTrailingSemicolon(filename, clean_lines, linenum, error):
                'LOCKS_EXCLUDED', 'INTERFACE_DEF')) or
           (func and not Search(r'\boperator\s*\[\s*\]', func.group(1))) or
           Search(r'\b(?:struct|union)\s+alignas\s*$', line_prefix) or
+          Search(r'\bdecltype$', line_prefix) or
           Search(r'\s+=\s*$', line_prefix)):
         match = None
     if (match and
@@ -4103,6 +3988,14 @@ def CheckTrailingSemicolon(filename, clean_lines, linenum, error):
       # outputting warnings for the matching closing brace, if there are
       # nested blocks with trailing semicolons, we will get the error
       # messages in reversed order.
+
+      # We need to check the line forward for NOLINT
+      raw_lines = clean_lines.raw_lines
+      ParseNolintSuppressions(filename, raw_lines[endlinenum-1], endlinenum-1,
+                              error)
+      ParseNolintSuppressions(filename, raw_lines[endlinenum], endlinenum,
+                              error)
+
       error(filename, endlinenum, 'readability/braces', 4,
             "You don't need a ; after a }")
 
@@ -4126,7 +4019,7 @@ def CheckEmptyBlockBody(filename, clean_lines, linenum, error):
   line = clean_lines.elided[linenum]
   matched = Match(r'\s*(for|while|if)\s*\(', line)
   if matched:
-    # Find the end of the conditional expression
+    # Find the end of the conditional expression.
     (end_line, end_linenum, end_pos) = CloseExpression(
         clean_lines, linenum, line.find('('))
 
@@ -4141,6 +4034,75 @@ def CheckEmptyBlockBody(filename, clean_lines, linenum, error):
         error(filename, end_linenum, 'whitespace/empty_loop_body', 5,
               'Empty loop bodies should use {} or continue')
 
+    # Check for if statements that have completely empty bodies (no comments)
+    # and no else clauses.
+    if end_pos >= 0 and matched.group(1) == 'if':
+      # Find the position of the opening { for the if statement.
+      # Return without logging an error if it has no brackets.
+      opening_linenum = end_linenum
+      opening_line_fragment = end_line[end_pos:]
+      # Loop until EOF or find anything that's not whitespace or opening {.
+      while not Search(r'^\s*\{', opening_line_fragment):
+        if Search(r'^(?!\s*$)', opening_line_fragment):
+          # Conditional has no brackets.
+          return
+        opening_linenum += 1
+        if opening_linenum == len(clean_lines.elided):
+          # Couldn't find conditional's opening { or any code before EOF.
+          return
+        opening_line_fragment = clean_lines.elided[opening_linenum]
+      # Set opening_line (opening_line_fragment may not be entire opening line).
+      opening_line = clean_lines.elided[opening_linenum]
+
+      # Find the position of the closing }.
+      opening_pos = opening_line_fragment.find('{')
+      if opening_linenum == end_linenum:
+        # We need to make opening_pos relative to the start of the entire line.
+        opening_pos += end_pos
+      (closing_line, closing_linenum, closing_pos) = CloseExpression(
+          clean_lines, opening_linenum, opening_pos)
+      if closing_pos < 0:
+        return
+
+      # Now construct the body of the conditional. This consists of the portion
+      # of the opening line after the {, all lines until the closing line,
+      # and the portion of the closing line before the }.
+      if (clean_lines.raw_lines[opening_linenum] !=
+          CleanseComments(clean_lines.raw_lines[opening_linenum])):
+        # Opening line ends with a comment, so conditional isn't empty.
+        return
+      if closing_linenum > opening_linenum:
+        # Opening line after the {. Ignore comments here since we checked above.
+        body = list(opening_line[opening_pos+1:])
+        # All lines until closing line, excluding closing line, with comments.
+        body.extend(clean_lines.raw_lines[opening_linenum+1:closing_linenum])
+        # Closing line before the }. Won't (and can't) have comments.
+        body.append(clean_lines.elided[closing_linenum][:closing_pos-1])
+        body = '\n'.join(body)
+      else:
+        # If statement has brackets and fits on a single line.
+        body = opening_line[opening_pos+1:closing_pos-1]
+
+      # Check if the body is empty
+      if not _EMPTY_CONDITIONAL_BODY_PATTERN.search(body):
+        return
+      # The body is empty. Now make sure there's not an else clause.
+      current_linenum = closing_linenum
+      current_line_fragment = closing_line[closing_pos:]
+      # Loop until EOF or find anything that's not whitespace or else clause.
+      while Search(r'^\s*$|^(?=\s*else)', current_line_fragment):
+        if Search(r'^(?=\s*else)', current_line_fragment):
+          # Found an else clause, so don't log an error.
+          return
+        current_linenum += 1
+        if current_linenum == len(clean_lines.elided):
+          break
+        current_line_fragment = clean_lines.elided[current_linenum]
+
+      # The body is empty and there's no else clause until EOF or other code.
+      error(filename, end_linenum, 'whitespace/empty_if_body', 4,
+            ('If statement had no body and no else clause'))
+
 
 def FindCheckMacro(line):
   """Find a replaceable CHECK-like macro.
@@ -4360,6 +4322,7 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
   # raw strings,
   raw_lines = clean_lines.lines_without_raw_strings
   line = raw_lines[linenum]
+  prev = raw_lines[linenum - 1] if linenum > 0 else ''
 
   if line.find('\t') != -1:
     error(filename, linenum, 'whitespace/tab', 1,
@@ -4383,22 +4346,27 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
   cleansed_line = clean_lines.elided[linenum]
   while initial_spaces < len(line) and line[initial_spaces] == ' ':
     initial_spaces += 1
-  if line and line[-1].isspace():
-    error(filename, linenum, 'whitespace/end_of_line', 4,
-          'Line ends in whitespace.  Consider deleting these extra spaces.')
   # There are certain situations we allow one space, notably for
   # section labels, and also lines containing multi-line raw strings.
-  elif ((initial_spaces == 1 or initial_spaces == 3) and
-        not Match(scope_or_label_pattern, cleansed_line) and
-        not (clean_lines.raw_lines[linenum] != line and
-             Match(r'^\s*""', line))):
+  # We also don't check for lines that look like continuation lines
+  # (of lines ending in double quotes, commas, equals, or angle brackets)
+  # because the rules for how to indent those are non-trivial.
+  if (not Search(r'[",=><] *$', prev) and
+      (initial_spaces == 1 or initial_spaces == 3) and
+      not Match(scope_or_label_pattern, cleansed_line) and
+      not (clean_lines.raw_lines[linenum] != line and
+           Match(r'^\s*""', line))):
     error(filename, linenum, 'whitespace/indent', 3,
           'Weird number of spaces at line-start.  '
           'Are you using a 2-space indent?')
 
+  if line and line[-1].isspace():
+    error(filename, linenum, 'whitespace/end_of_line', 4,
+          'Line ends in whitespace.  Consider deleting these extra spaces.')
+
   # Check if the line is a header guard.
   is_header_guard = False
-  if file_extension == 'h':
+  if IsHeaderExtension(file_extension):
     cppvar = GetHeaderGuardCPPVariable(filename)
     if (line.startswith('#ifndef %s' % cppvar) or
         line.startswith('#define %s' % cppvar) or
@@ -4414,14 +4382,10 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
   # developers fault.
   if (not line.startswith('#include') and not is_header_guard and
       not Match(r'^\s*//.*http(s?)://\S*$', line) and
+      not Match(r'^\s*//\s*[^\s]*$', line) and
       not Match(r'^// \$Id:.*#[0-9]+ \$$', line)):
     line_width = GetLineWidth(line)
-    extended_length = int((_line_length * 1.25))
-    if line_width > extended_length:
-      error(filename, linenum, 'whitespace/line_length', 4,
-            'Lines should very rarely be longer than %i characters' %
-            extended_length)
-    elif line_width > _line_length:
+    if line_width > _line_length:
       error(filename, linenum, 'whitespace/line_length', 2,
             'Lines should be <= %i characters long' % _line_length)
 
@@ -4441,14 +4405,12 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
   CheckBraces(filename, clean_lines, linenum, error)
   CheckTrailingSemicolon(filename, clean_lines, linenum, error)
   CheckEmptyBlockBody(filename, clean_lines, linenum, error)
-  CheckAccess(filename, clean_lines, linenum, nesting_state, error)
   CheckSpacing(filename, clean_lines, linenum, nesting_state, error)
   CheckOperatorSpacing(filename, clean_lines, linenum, error)
   CheckParenthesisSpacing(filename, clean_lines, linenum, error)
   CheckCommaSpacing(filename, clean_lines, linenum, error)
-  CheckBracesSpacing(filename, clean_lines, linenum, error)
+  CheckBracesSpacing(filename, clean_lines, linenum, nesting_state, error)
   CheckSpacingForFunctionCall(filename, clean_lines, linenum, error)
-  CheckRValueReference(filename, clean_lines, linenum, nesting_state, error)
   CheckCheck(filename, clean_lines, linenum, error)
   CheckAltTokens(filename, clean_lines, linenum, error)
   classinfo = nesting_state.InnermostClass()
@@ -4492,23 +4454,6 @@ def _DropCommonSuffixes(filename):
   return os.path.splitext(filename)[0]
 
 
-def _IsTestFilename(filename):
-  """Determines if the given filename has a suffix that identifies it as a test.
-
-  Args:
-    filename: The input filename.
-
-  Returns:
-    True if 'filename' looks like a test, False otherwise.
-  """
-  if (filename.endswith('_test.cc') or
-      filename.endswith('_unittest.cc') or
-      filename.endswith('_regtest.cc')):
-    return True
-  else:
-    return False
-
-
 def _ClassifyInclude(fileinfo, include, is_system):
   """Figures out what kind of header 'include' is.
 
@@ -4723,6 +4668,9 @@ _RE_PATTERN_REF_PARAM = re.compile(
 _RE_PATTERN_CONST_REF_PARAM = (
     r'(?:.*\s*\bconst\s*&\s*' + _RE_PATTERN_IDENT +
     r'|const\s+' + _RE_PATTERN_TYPE + r'\s*&\s*' + _RE_PATTERN_IDENT + r')')
+# Stream types.
+_RE_PATTERN_REF_STREAM_PARAM = (
+    r'(?:.*stream\s*&\s*' + _RE_PATTERN_IDENT + r')')
 
 
 def CheckLanguage(filename, clean_lines, linenum, file_extension,
@@ -4767,7 +4715,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension,
   CheckGlobalStatic(filename, clean_lines, linenum, error)
   CheckPrintf(filename, clean_lines, linenum, error)
 
-  if file_extension == 'h':
+  if IsHeaderExtension(file_extension):
     # TODO(unknown): check that 1-arg constructors are explicit.
     #                How to tell it's a constructor?
     #                (handled in CheckForNonStandardConstructs for now)
@@ -4874,12 +4822,12 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension,
   # Check for use of unnamed namespaces in header files.  Registration
   # macros are typically OK, so we allow use of "namespace {" on lines
   # that end with backslashes.
-  if (file_extension == 'h'
+  if (IsHeaderExtension(file_extension)
       and Search(r'\bnamespace\s*{', line)
       and line[-1] != '\\'):
     error(filename, linenum, 'build/namespaces', 4,
           'Do not use unnamed namespaces in header files.  See '
-          'http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces'
+          'https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces'
           ' for more information.')
 
 
@@ -4900,9 +4848,13 @@ def CheckGlobalStatic(filename, clean_lines, linenum, error):
 
   # Check for people declaring static/global STL strings at the top level.
   # This is dangerous because the C++ language does not guarantee that
-  # globals with constructors are initialized before the first access.
+  # globals with constructors are initialized before the first access, and
+  # also because globals can be destroyed when some threads are still running.
+  # TODO(unknown): Generalize this to also find static unique_ptr instances.
+  # TODO(unknown): File bugs for clang-tidy to find these.
   match = Match(
-      r'((?:|static +)(?:|const +))string +([a-zA-Z0-9_:]+)\b(.*)',
+      r'((?:|static +)(?:|const +))(?::*std::)?string( +const)? +'
+      r'([a-zA-Z0-9_:]+)\b(.*)',
       line)
 
   # Remove false positives:
@@ -4922,15 +4874,20 @@ def CheckGlobalStatic(filename, clean_lines, linenum, error):
   #   matching identifiers.
   #    string Class::operator*()
   if (match and
-      not Search(r'\bstring\b(\s+const)?\s*\*\s*(const\s+)?\w', line) and
+      not Search(r'\bstring\b(\s+const)?\s*[\*\&]\s*(const\s+)?\w', line) and
       not Search(r'\boperator\W', line) and
-      not Match(r'\s*(<.*>)?(::[a-zA-Z0-9_]+)*\s*\(([^"]|$)', match.group(3))):
-    error(filename, linenum, 'runtime/string', 4,
-          'For a static/global string constant, use a C style string instead: '
-          '"%schar %s[]".' %
-          (match.group(1), match.group(2)))
+      not Match(r'\s*(<.*>)?(::[a-zA-Z0-9_]+)*\s*\(([^"]|$)', match.group(4))):
+    if Search(r'\bconst\b', line):
+      error(filename, linenum, 'runtime/string', 4,
+            'For a static/global string constant, use a C style string '
+            'instead: "%schar%s %s[]".' %
+            (match.group(1), match.group(2) or '', match.group(3)))
+    else:
+      error(filename, linenum, 'runtime/string', 4,
+            'Static/global string variables are not permitted.')
 
-  if Search(r'\b([A-Za-z0-9_]*_)\(\1\)', line):
+  if (Search(r'\b([A-Za-z0-9_]*_)\(\1\)', line) or
+      Search(r'\b([A-Za-z0-9_]*_)\(CHECK_NOTNULL\(\1\)\)', line)):
     error(filename, linenum, 'runtime/init', 4,
           'You seem to be initializing a member variable with itself.')
 
@@ -5175,7 +5132,8 @@ def CheckForNonConstReference(filename, clean_lines, linenum,
 
   decls = ReplaceAll(r'{[^}]*}', ' ', line)  # exclude function body
   for parameter in re.findall(_RE_PATTERN_REF_PARAM, decls):
-    if not Match(_RE_PATTERN_CONST_REF_PARAM, parameter):
+    if (not Match(_RE_PATTERN_CONST_REF_PARAM, parameter) and
+        not Match(_RE_PATTERN_REF_STREAM_PARAM, parameter)):
       error(filename, linenum, 'runtime/references', 2,
             'Is this a non-const reference? '
             'If so, make const or use a pointer: ' +
@@ -5198,7 +5156,7 @@ def CheckCasts(filename, clean_lines, linenum, error):
   # Parameterless conversion functions, such as bool(), are allowed as they are
   # probably a member operator declaration or default constructor.
   match = Search(
-      r'(\bnew\s+|\S<\s*(?:const\s+)?)?\b'
+      r'(\bnew\s+(?:const\s+)?|\S<\s*(?:const\s+)?)?\b'
       r'(int|float|double|bool|char|int32|uint32|int64|uint64)'
       r'(\([^)].*)', line)
   expecting_function = ExpectingFunctionArgs(clean_lines, linenum)
@@ -5339,63 +5297,12 @@ def CheckCStyleCast(filename, clean_lines, linenum, cast_type, pattern, error):
   if context.endswith(' operator++') or context.endswith(' operator--'):
     return False
 
-  # A single unnamed argument for a function tends to look like old
-  # style cast.  If we see those, don't issue warnings for deprecated
-  # casts, instead issue warnings for unnamed arguments where
-  # appropriate.
-  #
-  # These are things that we want warnings for, since the style guide
-  # explicitly require all parameters to be named:
-  #   Function(int);
-  #   Function(int) {
-  #   ConstMember(int) const;
-  #   ConstMember(int) const {
-  #   ExceptionMember(int) throw (...);
-  #   ExceptionMember(int) throw (...) {
-  #   PureVirtual(int) = 0;
-  #   [](int) -> bool {
-  #
-  # These are functions of some sort, where the compiler would be fine
-  # if they had named parameters, but people often omit those
-  # identifiers to reduce clutter:
-  #   (FunctionPointer)(int);
-  #   (FunctionPointer)(int) = value;
-  #   Function((function_pointer_arg)(int))
-  #   Function((function_pointer_arg)(int), int param)
-  #   <TemplateArgument(int)>;
-  #   <(FunctionPointerTemplateArgument)(int)>;
+  # A single unnamed argument for a function tends to look like old style cast.
+  # If we see those, don't issue warnings for deprecated casts.
   remainder = line[match.end(0):]
   if Match(r'^\s*(?:;|const\b|throw\b|final\b|override\b|[=>{),]|->)',
            remainder):
-    # Looks like an unnamed parameter.
-
-    # Don't warn on any kind of template arguments.
-    if Match(r'^\s*>', remainder):
-      return False
-
-    # Don't warn on assignments to function pointers, but keep warnings for
-    # unnamed parameters to pure virtual functions.  Note that this pattern
-    # will also pass on assignments of "0" to function pointers, but the
-    # preferred values for those would be "nullptr" or "NULL".
-    matched_zero = Match(r'^\s=\s*(\S+)\s*;', remainder)
-    if matched_zero and matched_zero.group(1) != '0':
-      return False
-
-    # Don't warn on function pointer declarations.  For this we need
-    # to check what came before the "(type)" string.
-    if Match(r'.*\)\s*$', line[0:match.start(0)]):
-      return False
-
-    # Don't warn if the parameter is named with block comments, e.g.:
-    #  Function(int /*unused_param*/);
-    raw_line = clean_lines.raw_lines[linenum]
-    if '/*' in raw_line:
-      return False
-
-    # Passed all filters, issue warning here.
-    error(filename, linenum, 'readability/function', 3,
-          'All parameters should be named in a function')
-    return True
+    return False
 
   # At this point, all that should be left is actual casts.
   error(filename, linenum, 'readability/casting', 4,
@@ -5449,11 +5356,15 @@ _HEADERS_CONTAINING_TEMPLATES = (
     ('<limits>', ('numeric_limits',)),
     ('<list>', ('list',)),
     ('<map>', ('map', 'multimap',)),
-    ('<memory>', ('allocator',)),
+    ('<memory>', ('allocator', 'make_shared', 'make_unique', 'shared_ptr',
+                  'unique_ptr', 'weak_ptr')),
     ('<queue>', ('queue', 'priority_queue',)),
     ('<set>', ('set', 'multiset',)),
     ('<stack>', ('stack',)),
     ('<string>', ('char_traits', 'basic_string',)),
+    ('<tuple>', ('tuple',)),
+    ('<unordered_map>', ('unordered_map', 'unordered_multimap')),
+    ('<unordered_set>', ('unordered_set', 'unordered_multiset')),
     ('<utility>', ('pair',)),
     ('<vector>', ('vector',)),
 
@@ -5464,18 +5375,26 @@ _HEADERS_CONTAINING_TEMPLATES = (
     ('<slist>', ('slist',)),
     )
 
-_RE_PATTERN_STRING = re.compile(r'\bstring\b')
+_HEADERS_MAYBE_TEMPLATES = (
+    ('<algorithm>', ('copy', 'max', 'min', 'min_element', 'sort',
+                     'transform',
+                    )),
+    ('<utility>', ('forward', 'make_pair', 'move', 'swap')),
+    )
 
-_re_pattern_algorithm_header = []
-for _template in ('copy', 'max', 'min', 'min_element', 'sort', 'swap',
-                  'transform'):
-  # Match max<type>(..., ...), max(..., ...), but not foo->max, foo.max or
-  # type::max().
-  _re_pattern_algorithm_header.append(
-      (re.compile(r'[^>.]\b' + _template + r'(<.*?>)?\([^\)]'),
-       _template,
-       '<algorithm>'))
+_RE_PATTERN_STRING = re.compile(r'\bstring\b')
 
+_re_pattern_headers_maybe_templates = []
+for _header, _templates in _HEADERS_MAYBE_TEMPLATES:
+  for _template in _templates:
+    # Match max<type>(..., ...), max(..., ...), but not foo->max, foo.max or
+    # type::max().
+    _re_pattern_headers_maybe_templates.append(
+        (re.compile(r'[^>.]\b' + _template + r'(<.*?>)?\([^\)]'),
+            _template,
+            _header))
+
+# Other scripts may reach in and modify this pattern.
 _re_pattern_templates = []
 for _header, _templates in _HEADERS_CONTAINING_TEMPLATES:
   for _template in _templates:
@@ -5515,13 +5434,13 @@ def FilesBelongToSameModule(filename_cc, filename_h):
     string: the additional prefix needed to open the header file.
   """
 
-  if not filename_cc.endswith('.cc'):
+  fileinfo = FileInfo(filename_cc)
+  if not fileinfo.IsSource():
     return (False, '')
-  filename_cc = filename_cc[:-len('.cc')]
-  if filename_cc.endswith('_unittest'):
-    filename_cc = filename_cc[:-len('_unittest')]
-  elif filename_cc.endswith('_test'):
-    filename_cc = filename_cc[:-len('_test')]
+  filename_cc = filename_cc[:-len(fileinfo.Extension())]
+  matched_test_suffix = Search(_TEST_FILE_SUFFIX, fileinfo.BaseName())
+  if matched_test_suffix:
+    filename_cc = filename_cc[:-len(matched_test_suffix.group(1))]
   filename_cc = filename_cc.replace('/public/', '/')
   filename_cc = filename_cc.replace('/internal/', '/')
 
@@ -5602,7 +5521,7 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error,
       if prefix.endswith('std::') or not prefix.endswith('::'):
         required['<string>'] = (linenum, 'string')
 
-    for pattern, template, header in _re_pattern_algorithm_header:
+    for pattern, template, header in _re_pattern_headers_maybe_templates:
       if pattern.search(line):
         required[header] = (linenum, template)
 
@@ -5611,8 +5530,13 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error,
       continue
 
     for pattern, template, header in _re_pattern_templates:
-      if pattern.search(line):
-        required[header] = (linenum, template)
+      matched = pattern.search(line)
+      if matched:
+        # Don't warn about IWYU in non-STL namespaces:
+        # (We check only the first match per line; good enough.)
+        prefix = line[:matched.start()]
+        if prefix.endswith('std::') or not prefix.endswith('::'):
+          required[header] = (linenum, template)
 
   # The policy is that if you #include something in foo.h you don't need to
   # include it again in foo.cc. Here, we will look at possible includes.
@@ -5685,31 +5609,6 @@ def CheckMakePairUsesDeduction(filename, clean_lines, linenum, error):
           ' OR use pair directly OR if appropriate, construct a pair directly')
 
 
-def CheckDefaultLambdaCaptures(filename, clean_lines, linenum, error):
-  """Check that default lambda captures are not used.
-
-  Args:
-    filename: The name of the current file.
-    clean_lines: A CleansedLines instance containing the file.
-    linenum: The number of the line to check.
-    error: The function to call with any errors found.
-  """
-  line = clean_lines.elided[linenum]
-
-  # A lambda introducer specifies a default capture if it starts with "[="
-  # or if it starts with "[&" _not_ followed by an identifier.
-  match = Match(r'^(.*)\[\s*(?:=|&[^\w])', line)
-  if match:
-    # Found a potential error, check what comes after the lambda-introducer.
-    # If it's not open parenthesis (for lambda-declarator) or open brace
-    # (for compound-statement), it's not a lambda.
-    line, _, pos = CloseExpression(clean_lines, linenum, len(match.group(1)))
-    if pos >= 0 and Match(r'^\s*[{(]', line[pos:]):
-      error(filename, linenum, 'build/c++11',
-            4,  # 4 = high confidence
-            'Default lambda captures are an unapproved C++ feature.')
-
-
 def CheckRedundantVirtual(filename, clean_lines, linenum, error):
   """Check if line contains a redundant "virtual" function-specifier.
 
@@ -5908,7 +5807,6 @@ def ProcessLine(filename, file_extension, clean_lines, line,
   CheckPosixThreading(filename, clean_lines, line, error)
   CheckInvalidIncrement(filename, clean_lines, line, error)
   CheckMakePairUsesDeduction(filename, clean_lines, line, error)
-  CheckDefaultLambdaCaptures(filename, clean_lines, line, error)
   CheckRedundantVirtual(filename, clean_lines, line, error)
   CheckRedundantOverrideOrFinal(filename, clean_lines, line, error)
   for check_fn in extra_check_functions:
@@ -5925,8 +5823,14 @@ def FlagCxx11Features(filename, clean_lines, linenum, error):
   """
   line = clean_lines.elided[linenum]
 
-  # Flag unapproved C++11 headers.
   include = Match(r'\s*#\s*include\s+[<"]([^<"]+)[">]', line)
+
+  # Flag unapproved C++ TR1 headers.
+  if include and include.group(1).startswith('tr1/'):
+    error(filename, linenum, 'build/c++tr1', 5,
+          ('C++ TR1 headers such as <%s> are unapproved.') % include.group(1))
+
+  # Flag unapproved C++11 headers.
   if include and include.group(1) in ('cfenv',
                                       'condition_variable',
                                       'fenv.h',
@@ -5959,6 +5863,25 @@ def FlagCxx11Features(filename, clean_lines, linenum, error):
              'they may let you use it.') % top_name)
 
 
+def FlagCxx14Features(filename, clean_lines, linenum, error):
+  """Flag those C++14 features that we restrict.
+
+  Args:
+    filename: The name of the current file.
+    clean_lines: A CleansedLines instance containing the file.
+    linenum: The number of the line to check.
+    error: The function to call with any errors found.
+  """
+  line = clean_lines.elided[linenum]
+
+  include = Match(r'\s*#\s*include\s+[<"]([^<"]+)[">]', line)
+
+  # Flag unapproved C++14 headers.
+  if include and include.group(1) in ('scoped_allocator', 'shared_mutex'):
+    error(filename, linenum, 'build/c++14', 5,
+          ('<%s> is an unapproved C++14 header.') % include.group(1))
+
+
 def ProcessFileData(filename, file_extension, lines, error,
                     extra_check_functions=[]):
   """Performs lint checks and reports any errors to the given error function.
@@ -5983,12 +5906,12 @@ def ProcessFileData(filename, file_extension, lines, error,
 
   ResetNolintSuppressions()
 
-  # CheckForCopyright(filename, lines, error)
-
+  CheckForCopyright(filename, lines, error)
+  ProcessGlobalSuppresions(lines)
   RemoveMultiLineComments(filename, lines, error)
   clean_lines = CleansedLines(lines)
 
-  if file_extension == 'h':
+  if IsHeaderExtension(file_extension):
     CheckForHeaderGuard(filename, clean_lines, error)
 
   for line in xrange(clean_lines.NumLines()):
@@ -6001,7 +5924,7 @@ def ProcessFileData(filename, file_extension, lines, error,
   CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error)
 
   # Check that the .cc file has included its header if it exists.
-  if file_extension == 'cc':
+  if _IsSourceExtension(file_extension):
     CheckHeaderFileIncluded(filename, include_state, error)
 
   # We check here rather than inside ProcessLine so that we see raw
@@ -6057,6 +5980,9 @@ def ProcessConfigOverrides(filename):
             if base_name:
               pattern = re.compile(val)
               if pattern.match(base_name):
+                if _cpplint_state.quiet:
+                  # Suppress "Ignoring file" warning when using --quiet.
+                  return False
                 sys.stderr.write('Ignoring "%s": file excluded by "%s". '
                                  'File path component "%s" matches '
                                  'pattern "%s"\n' %
@@ -6068,6 +5994,12 @@ def ProcessConfigOverrides(filename):
                 _line_length = int(val)
             except ValueError:
                 sys.stderr.write('Line length must be numeric.')
+          elif name == 'root':
+            global _root
+            # root directories are specified relative to CPPLINT.cfg dir.
+            _root = os.path.join(os.path.dirname(cfg_file), val)
+          elif name == 'headers':
+            ProcessHppHeadersOption(val)
           else:
             sys.stderr.write(
                 'Invalid configuration option (%s) in file %s\n' %
@@ -6102,6 +6034,7 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]):
 
   _SetVerboseLevel(vlevel)
   _BackupFilters()
+  old_errors = _cpplint_state.error_count
 
   if not ProcessConfigOverrides(filename):
     _RestoreFilters()
@@ -6170,6 +6103,10 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]):
         Error(filename, linenum, 'whitespace/newline', 1,
               'Unexpected \\r (^M) found; better to use only \\n')
 
+  # Suppress printing anything if --quiet was passed unless the error
+  # count has increased after processing this file.
+  if not _cpplint_state.quiet or old_errors != _cpplint_state.error_count:
+    sys.stdout.write('Done processing %s\n' % filename)
   _RestoreFilters()
 
 
@@ -6212,13 +6149,16 @@ def ParseArguments(args):
                                                  'filter=',
                                                  'root=',
                                                  'linelength=',
-                                                 'extensions='])
+                                                 'extensions=',
+                                                 'headers=',
+                                                 'quiet'])
   except getopt.GetoptError:
     PrintUsage('Invalid arguments.')
 
   verbosity = _VerboseLevel()
   output_format = _OutputFormat()
   filters = ''
+  quiet = _Quiet()
   counting_style = ''
 
   for (opt, val) in opts:
@@ -6228,6 +6168,8 @@ def ParseArguments(args):
       if val not in ('emacs', 'vs7', 'eclipse'):
         PrintUsage('The only allowed output formats are emacs, vs7 and eclipse.')
       output_format = val
+    elif opt == '--quiet':
+      quiet = True
     elif opt == '--verbose':
       verbosity = int(val)
     elif opt == '--filter':
@@ -6253,11 +6195,14 @@ def ParseArguments(args):
           _valid_extensions = set(val.split(','))
       except ValueError:
           PrintUsage('Extensions must be comma seperated list.')
+    elif opt == '--headers':
+      ProcessHppHeadersOption(val)
 
   if not filenames:
     PrintUsage('No files were specified.')
 
   _SetOutputFormat(output_format)
+  _SetQuiet(quiet)
   _SetVerboseLevel(verbosity)
   _SetFilters(filters)
   _SetCountingStyle(counting_style)
@@ -6278,7 +6223,9 @@ def main():
   _cpplint_state.ResetErrorCounts()
   for filename in filenames:
     ProcessFile(filename, _cpplint_state.verbose_level)
-  _cpplint_state.PrintErrorCounts()
+  # If --quiet is passed, suppress printing error count unless there are errors.
+  if not _cpplint_state.quiet or _cpplint_state.error_count > 0:
+    _cpplint_state.PrintErrorCounts()
 
   sys.exit(_cpplint_state.error_count > 0)
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/third_party/src/cpplint/lint_everything.py
----------------------------------------------------------------------
diff --git a/third_party/src/cpplint/lint_everything.py b/third_party/src/cpplint/lint_everything.py
deleted file mode 100755
index b95f21c..0000000
--- a/third_party/src/cpplint/lint_everything.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env python2
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import os
-import subprocess
-import sys
-
-EXCLUDED_PREFIXES = ['./.', './third_party', './build', './parser/preprocessed']
-
-call_args = ['/usr/bin/env', 'python2', './third_party/src/cpplint/cpplint.py']
-
-print "Running cpplint on entire source tree. This may take a minute or two..."
-
-for (dirpath, dirnames, filenames) in os.walk('.'):
-    filtered = False
-    for prefix in EXCLUDED_PREFIXES:
-        if dirpath.startswith(prefix):
-            filtered = True
-    if not filtered:
-        for filename in filenames:
-            if filename.endswith('.hpp') or filename.endswith('.cpp'):
-                call_args.append(dirpath + '/' + filename)
-
-sys.exit(subprocess.call(call_args))

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/transaction/LockManager.cpp
----------------------------------------------------------------------
diff --git a/transaction/LockManager.cpp b/transaction/LockManager.cpp
index c917b4b..845a53b 100644
--- a/transaction/LockManager.cpp
+++ b/transaction/LockManager.cpp
@@ -20,6 +20,7 @@
 #include "transaction/LockManager.hpp"
 
 #include <cstdint>
+#include <memory>
 #include <stack>
 #include <string>
 #include <utility>

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/types/operations/comparisons/AsciiStringComparators-inl.hpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/AsciiStringComparators-inl.hpp b/types/operations/comparisons/AsciiStringComparators-inl.hpp
index 87d7168..fd0d17d 100644
--- a/types/operations/comparisons/AsciiStringComparators-inl.hpp
+++ b/types/operations/comparisons/AsciiStringComparators-inl.hpp
@@ -27,6 +27,7 @@
 #define QUICKSTEP_TYPES_OPERATIONS_COMPARISONS_ASCII_STRING_COMPARATORS_INL_HPP_
 
 #include <cstddef>
+#include <memory>
 
 #include "catalog/CatalogTypedefs.hpp"
 #include "storage/TupleIdSequence.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/types/operations/comparisons/Comparison-inl.hpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/Comparison-inl.hpp b/types/operations/comparisons/Comparison-inl.hpp
index c892a16..48167ee 100644
--- a/types/operations/comparisons/Comparison-inl.hpp
+++ b/types/operations/comparisons/Comparison-inl.hpp
@@ -23,6 +23,7 @@
 #include "types/operations/comparisons/Comparison.hpp"
 
 #include <cstddef>
+#include <memory>
 
 #include "catalog/CatalogTypedefs.hpp"
 #include "storage/TupleIdSequence.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/types/operations/comparisons/LiteralComparators-inl.hpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/LiteralComparators-inl.hpp b/types/operations/comparisons/LiteralComparators-inl.hpp
index ad54d4e..5fc9bfe 100644
--- a/types/operations/comparisons/LiteralComparators-inl.hpp
+++ b/types/operations/comparisons/LiteralComparators-inl.hpp
@@ -27,6 +27,7 @@
 #define QUICKSTEP_TYPES_OPERATIONS_COMPARISONS_LITERAL_COMPARATORS_INL_HPP_
 
 #include <cstddef>
+#include <memory>
 #include <type_traits>
 
 #include "catalog/CatalogTypedefs.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/types/operations/comparisons/PatternMatchingComparators-inl.hpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/PatternMatchingComparators-inl.hpp b/types/operations/comparisons/PatternMatchingComparators-inl.hpp
index a7f0777..c8170a1 100644
--- a/types/operations/comparisons/PatternMatchingComparators-inl.hpp
+++ b/types/operations/comparisons/PatternMatchingComparators-inl.hpp
@@ -23,6 +23,7 @@
 #include "types/operations/comparisons/PatternMatchingComparators.hpp"
 
 #include <cstddef>
+#include <memory>
 #include <string>
 
 #include "catalog/CatalogTypedefs.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/utility/tests/DAG_unittest.cpp
----------------------------------------------------------------------
diff --git a/utility/tests/DAG_unittest.cpp b/utility/tests/DAG_unittest.cpp
index 3e8d167..f398471 100644
--- a/utility/tests/DAG_unittest.cpp
+++ b/utility/tests/DAG_unittest.cpp
@@ -19,6 +19,8 @@
 
 #include <algorithm>
 #include <cstddef>
+#include <tuple>
+#include <unordered_map>
 #include <utility>
 #include <vector>
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/utility/tests/ScopedReassignment_unittest.cpp
----------------------------------------------------------------------
diff --git a/utility/tests/ScopedReassignment_unittest.cpp b/utility/tests/ScopedReassignment_unittest.cpp
index b7da017..1a69197 100644
--- a/utility/tests/ScopedReassignment_unittest.cpp
+++ b/utility/tests/ScopedReassignment_unittest.cpp
@@ -19,6 +19,8 @@
 
 #include "utility/ScopedReassignment.hpp"
 
+#include <utility>
+
 #include "utility/Macros.hpp"
 
 #include "gtest/gtest.h"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d886ddb0/utility/textbased_test/TextBasedTestDriver.cpp
----------------------------------------------------------------------
diff --git a/utility/textbased_test/TextBasedTestDriver.cpp b/utility/textbased_test/TextBasedTestDriver.cpp
index 5acfc8e..d711664 100644
--- a/utility/textbased_test/TextBasedTestDriver.cpp
+++ b/utility/textbased_test/TextBasedTestDriver.cpp
@@ -27,6 +27,7 @@
 #include <istream>
 #include <set>
 #include <string>
+#include <utility>
 #include <vector>
 
 #include "utility/textbased_test/TextBasedTest.hpp"



[27/46] incubator-quickstep git commit: Remove glog source code from third party

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/raw_logging.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/raw_logging.cc b/third_party/src/glog/src/windows/raw_logging.cc
deleted file mode 100644
index 7a7409b..0000000
--- a/third_party/src/glog/src/windows/raw_logging.cc
+++ /dev/null
@@ -1,172 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Maxim Lifantsev
-//
-// logging_unittest.cc covers the functionality herein
-
-#include "utilities.h"
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <errno.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>               // for close() and write()
-#endif
-#include <fcntl.h>                 // for open()
-#include <time.h>
-#include "config.h"
-#include "glog/logging.h"          // To pick up flag settings etc.
-#include "glog/raw_logging.h"
-#include "base/commandlineflags.h"
-
-#ifdef HAVE_STACKTRACE
-# include "stacktrace.h"
-#endif
-
-#if defined(HAVE_SYSCALL_H)
-#include <syscall.h>                 // for syscall()
-#elif defined(HAVE_SYS_SYSCALL_H)
-#include <sys/syscall.h>                 // for syscall()
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)
-# define safe_write(fd, s, len)  syscall(SYS_write, fd, s, len)
-#else
-  // Not so safe, but what can you do?
-# define safe_write(fd, s, len)  write(fd, s, len)
-#endif
-
-_START_GOOGLE_NAMESPACE_
-
-// Data for RawLog__ below. We simply pick up the latest
-// time data created by a normal log message to avoid calling
-// localtime_r which can allocate memory.
-static struct ::tm last_tm_time_for_raw_log;
-static int last_usecs_for_raw_log;
-
-void RawLog__SetLastTime(const struct ::tm& t, int usecs) {
-  memcpy(&last_tm_time_for_raw_log, &t, sizeof(last_tm_time_for_raw_log));
-  last_usecs_for_raw_log = usecs;
-}
-
-// CAVEAT: vsnprintf called from *DoRawLog below has some (exotic) code paths
-// that invoke malloc() and getenv() that might acquire some locks.
-// If this becomes a problem we should reimplement a subset of vsnprintf
-// that does not need locks and malloc.
-
-// Helper for RawLog__ below.
-// *DoRawLog writes to *buf of *size and move them past the written portion.
-// It returns true iff there was no overflow or error.
-static bool DoRawLog(char** buf, int* size, const char* format, ...) {
-  va_list ap;
-  va_start(ap, format);
-  int n = vsnprintf(*buf, *size, format, ap);
-  va_end(ap);
-  if (n < 0 || n > *size) return false;
-  *size -= n;
-  *buf += n;
-  return true;
-}
-
-// Helper for RawLog__ below.
-inline static bool VADoRawLog(char** buf, int* size,
-                              const char* format, va_list ap) {
-  int n = vsnprintf(*buf, *size, format, ap);
-  if (n < 0 || n > *size) return false;
-  *size -= n;
-  *buf += n;
-  return true;
-}
-
-static const int kLogBufSize = 3000;
-static bool crashed = false;
-static CrashReason crash_reason;
-static char crash_buf[kLogBufSize + 1] = { 0 };  // Will end in '\0'
-
-void RawLog__(LogSeverity severity, const char* file, int line,
-              const char* format, ...) {
-  if (!(FLAGS_logtostderr || severity >= FLAGS_stderrthreshold ||
-        FLAGS_alsologtostderr || !IsGoogleLoggingInitialized())) {
-    return;  // this stderr log message is suppressed
-  }
-  // can't call localtime_r here: it can allocate
-  struct ::tm& t = last_tm_time_for_raw_log;
-  char buffer[kLogBufSize];
-  char* buf = buffer;
-  int size = sizeof(buffer);
-
-  // NOTE: this format should match the specification in base/logging.h
-  DoRawLog(&buf, &size, "%c%02d%02d %02d:%02d:%02d.%06d %5u %s:%d] RAW: ",
-           LogSeverityNames[severity][0],
-           1 + t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec,
-           last_usecs_for_raw_log,
-           static_cast<unsigned int>(GetTID()),
-           const_basename(const_cast<char *>(file)), line);
-
-  // Record the position and size of the buffer after the prefix
-  const char* msg_start = buf;
-  const int msg_size = size;
-
-  va_list ap;
-  va_start(ap, format);
-  bool no_chop = VADoRawLog(&buf, &size, format, ap);
-  va_end(ap);
-  if (no_chop) {
-    DoRawLog(&buf, &size, "\n");
-  } else {
-    DoRawLog(&buf, &size, "RAW_LOG ERROR: The Message was too long!\n");
-  }
-  // We make a raw syscall to write directly to the stderr file descriptor,
-  // avoiding FILE buffering (to avoid invoking malloc()), and bypassing
-  // libc (to side-step any libc interception).
-  // We write just once to avoid races with other invocations of RawLog__.
-  safe_write(STDERR_FILENO, buffer, strlen(buffer));
-  if (severity == GLOG_FATAL)  {
-    if (!sync_val_compare_and_swap(&crashed, false, true)) {
-      crash_reason.filename = file;
-      crash_reason.line_number = line;
-      memcpy(crash_buf, msg_start, msg_size);  // Don't include prefix
-      crash_reason.message = crash_buf;
-#ifdef HAVE_STACKTRACE
-      crash_reason.depth =
-          GetStackTrace(crash_reason.stack, ARRAYSIZE(crash_reason.stack), 1);
-#else
-      crash_reason.depth = 0;
-#endif
-      SetCrashReason(&crash_reason);
-    }
-    LogMessage::Fail();  // abort()
-  }
-}
-
-_END_GOOGLE_NAMESPACE_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/utilities.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/utilities.cc b/third_party/src/glog/src/windows/utilities.cc
deleted file mode 100644
index a6d1961..0000000
--- a/third_party/src/glog/src/windows/utilities.cc
+++ /dev/null
@@ -1,347 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Shinichiro Hamaji
-
-#include "utilities.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <signal.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#include <time.h>
-#if defined(HAVE_SYSCALL_H)
-#include <syscall.h>                 // for syscall()
-#elif defined(HAVE_SYS_SYSCALL_H)
-#include <sys/syscall.h>                 // for syscall()
-#endif
-#ifdef HAVE_SYSLOG_H
-# include <syslog.h>
-#endif
-
-#include "base/googleinit.h"
-
-using std::string;
-
-_START_GOOGLE_NAMESPACE_
-
-static const char* g_program_invocation_short_name = NULL;
-static pthread_t g_main_thread_id;
-
-_END_GOOGLE_NAMESPACE_
-
-// The following APIs are all internal.
-#ifdef HAVE_STACKTRACE
-
-#include "stacktrace.h"
-#include "symbolize.h"
-#include "base/commandlineflags.h"
-
-GLOG_DEFINE_bool(symbolize_stacktrace, true,
-                 "Symbolize the stack trace in the tombstone");
-
-_START_GOOGLE_NAMESPACE_
-
-typedef void DebugWriter(const char*, void*);
-
-// The %p field width for printf() functions is two characters per byte.
-// For some environments, add two extra bytes for the leading "0x".
-static const int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*);
-
-static void DebugWriteToStderr(const char* data, void *) {
-  // This one is signal-safe.
-  if (write(STDERR_FILENO, data, strlen(data)) < 0) {
-    // Ignore errors.
-  }
-}
-
-void DebugWriteToString(const char* data, void *arg) {
-  reinterpret_cast<string*>(arg)->append(data);
-}
-
-#ifdef HAVE_SYMBOLIZE
-// Print a program counter and its symbol name.
-static void DumpPCAndSymbol(DebugWriter *writerfn, void *arg, void *pc,
-                            const char * const prefix) {
-  char tmp[1024];
-  const char *symbol = "(unknown)";
-  // Symbolizes the previous address of pc because pc may be in the
-  // next function.  The overrun happens when the function ends with
-  // a call to a function annotated noreturn (e.g. CHECK).
-  if (Symbolize(reinterpret_cast<char *>(pc) - 1, tmp, sizeof(tmp))) {
-      symbol = tmp;
-  }
-  char buf[1024];
-  snprintf(buf, sizeof(buf), "%s@ %*p  %s\n",
-           prefix, kPrintfPointerFieldWidth, pc, symbol);
-  writerfn(buf, arg);
-}
-#endif
-
-static void DumpPC(DebugWriter *writerfn, void *arg, void *pc,
-                   const char * const prefix) {
-  char buf[100];
-  snprintf(buf, sizeof(buf), "%s@ %*p\n",
-           prefix, kPrintfPointerFieldWidth, pc);
-  writerfn(buf, arg);
-}
-
-// Dump current stack trace as directed by writerfn
-static void DumpStackTrace(int skip_count, DebugWriter *writerfn, void *arg) {
-  // Print stack trace
-  void* stack[32];
-  int depth = GetStackTrace(stack, ARRAYSIZE(stack), skip_count+1);
-  for (int i = 0; i < depth; i++) {
-#if defined(HAVE_SYMBOLIZE)
-    if (FLAGS_symbolize_stacktrace) {
-      DumpPCAndSymbol(writerfn, arg, stack[i], "    ");
-    } else {
-      DumpPC(writerfn, arg, stack[i], "    ");
-    }
-#else
-    DumpPC(writerfn, arg, stack[i], "    ");
-#endif
-  }
-}
-
-static void DumpStackTraceAndExit() {
-  DumpStackTrace(1, DebugWriteToStderr, NULL);
-
-  // Set the default signal handler for SIGABRT, to avoid invoking our
-  // own signal handler installed by InstallFailedSignalHandler().
-  struct sigaction sig_action;
-  memset(&sig_action, 0, sizeof(sig_action));
-  sigemptyset(&sig_action.sa_mask);
-  sig_action.sa_handler = SIG_DFL;
-  sigaction(SIGABRT, &sig_action, NULL);
-
-  abort();
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#endif  // HAVE_STACKTRACE
-
-_START_GOOGLE_NAMESPACE_
-
-namespace glog_internal_namespace_ {
-
-const char* ProgramInvocationShortName() {
-  if (g_program_invocation_short_name != NULL) {
-    return g_program_invocation_short_name;
-  } else {
-    // TODO(hamaji): Use /proc/self/cmdline and so?
-    return "UNKNOWN";
-  }
-}
-
-bool IsGoogleLoggingInitialized() {
-  return g_program_invocation_short_name != NULL;
-}
-
-bool is_default_thread() {
-  if (g_program_invocation_short_name == NULL) {
-    // InitGoogleLogging() not yet called, so unlikely to be in a different
-    // thread
-    return true;
-  } else {
-    return pthread_equal(pthread_self(), g_main_thread_id);
-  }
-}
-
-#ifdef OS_WINDOWS
-struct timeval {
-  long tv_sec, tv_usec;
-};
-
-// Based on: http://www.google.com/codesearch/p?hl=en#dR3YEbitojA/os_win32.c&q=GetSystemTimeAsFileTime%20license:bsd
-// See COPYING for copyright information.
-static int gettimeofday(struct timeval *tv, void* tz) {
-#define EPOCHFILETIME (116444736000000000ULL)
-  FILETIME ft;
-  LARGE_INTEGER li;
-  uint64 tt;
-
-  GetSystemTimeAsFileTime(&ft);
-  li.LowPart = ft.dwLowDateTime;
-  li.HighPart = ft.dwHighDateTime;
-  tt = (li.QuadPart - EPOCHFILETIME) / 10;
-  tv->tv_sec = tt / 1000000;
-  tv->tv_usec = tt % 1000000;
-
-  return 0;
-}
-#endif
-
-int64 CycleClock_Now() {
-  // TODO(hamaji): temporary impementation - it might be too slow.
-  struct timeval tv;
-  gettimeofday(&tv, NULL);
-  return static_cast<int64>(tv.tv_sec) * 1000000 + tv.tv_usec;
-}
-
-int64 UsecToCycles(int64 usec) {
-  return usec;
-}
-
-WallTime WallTime_Now() {
-  // Now, cycle clock is retuning microseconds since the epoch.
-  return CycleClock_Now() * 0.000001;
-}
-
-static int32 g_main_thread_pid = getpid();
-int32 GetMainThreadPid() {
-  return g_main_thread_pid;
-}
-
-bool PidHasChanged() {
-  int32 pid = getpid();
-  if (g_main_thread_pid == pid) {
-    return false;
-  }
-  g_main_thread_pid = pid;
-  return true;
-}
-
-pid_t GetTID() {
-  // On Linux and MacOSX, we try to use gettid().
-#if defined OS_LINUX || defined OS_MACOSX
-#ifndef __NR_gettid
-#ifdef OS_MACOSX
-#define __NR_gettid SYS_gettid
-#elif ! defined __i386__
-#error "Must define __NR_gettid for non-x86 platforms"
-#else
-#define __NR_gettid 224
-#endif
-#endif
-  static bool lacks_gettid = false;
-  if (!lacks_gettid) {
-    pid_t tid = syscall(__NR_gettid);
-    if (tid != -1) {
-      return tid;
-    }
-    // Technically, this variable has to be volatile, but there is a small
-    // performance penalty in accessing volatile variables and there should
-    // not be any serious adverse effect if a thread does not immediately see
-    // the value change to "true".
-    lacks_gettid = true;
-  }
-#endif  // OS_LINUX || OS_MACOSX
-
-  // If gettid() could not be used, we use one of the following.
-#if defined OS_LINUX
-  return getpid();  // Linux:  getpid returns thread ID when gettid is absent
-#elif defined OS_WINDOWS || defined OS_CYGWIN
-  return GetCurrentThreadId();
-#else
-  // If none of the techniques above worked, we use pthread_self().
-  return (pid_t)(uintptr_t)pthread_self();
-#endif
-}
-
-const char* const_basename(const char* filepath) {
-  const char* base = strrchr(filepath, '/');
-#ifdef OS_WINDOWS  // Look for either path separator in Windows
-  if (!base)
-    base = strrchr(filepath, '\\');
-#endif
-  return base ? (base+1) : filepath;
-}
-
-static string g_my_user_name;
-const string& MyUserName() {
-  return g_my_user_name;
-}
-static void MyUserNameInitializer() {
-  // TODO(hamaji): Probably this is not portable.
-#if defined(OS_WINDOWS)
-  const char* user = getenv("USERNAME");
-#else
-  const char* user = getenv("USER");
-#endif
-  if (user != NULL) {
-    g_my_user_name = user;
-  } else {
-    g_my_user_name = "invalid-user";
-  }
-}
-REGISTER_MODULE_INITIALIZER(utilities, MyUserNameInitializer());
-
-#ifdef HAVE_STACKTRACE
-void DumpStackTraceToString(string* stacktrace) {
-  DumpStackTrace(1, DebugWriteToString, stacktrace);
-}
-#endif
-
-// We use an atomic operation to prevent problems with calling CrashReason
-// from inside the Mutex implementation (potentially through RAW_CHECK).
-static const CrashReason* g_reason = 0;
-
-void SetCrashReason(const CrashReason* r) {
-  sync_val_compare_and_swap(&g_reason,
-                            reinterpret_cast<const CrashReason*>(0),
-                            r);
-}
-
-void InitGoogleLoggingUtilities(const char* argv0) {
-  CHECK(!IsGoogleLoggingInitialized())
-      << "You called InitGoogleLogging() twice!";
-  const char* slash = strrchr(argv0, '/');
-#ifdef OS_WINDOWS
-  if (!slash)  slash = strrchr(argv0, '\\');
-#endif
-  g_program_invocation_short_name = slash ? slash + 1 : argv0;
-  g_main_thread_id = pthread_self();
-
-#ifdef HAVE_STACKTRACE
-  InstallFailureFunction(&DumpStackTraceAndExit);
-#endif
-}
-
-void ShutdownGoogleLoggingUtilities() {
-  CHECK(IsGoogleLoggingInitialized())
-      << "You called ShutdownGoogleLogging() without calling InitGoogleLogging() first!";
-  g_program_invocation_short_name = NULL;
-#ifdef HAVE_SYSLOG_H
-  closelog();
-#endif
-}
-
-}  // namespace glog_internal_namespace_
-
-_END_GOOGLE_NAMESPACE_
-
-// Make an implementation of stacktrace compiled.
-#ifdef STACKTRACE_H
-# include STACKTRACE_H
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/utilities.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/utilities.h b/third_party/src/glog/src/windows/utilities.h
deleted file mode 100644
index 5f79968..0000000
--- a/third_party/src/glog/src/windows/utilities.h
+++ /dev/null
@@ -1,226 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Shinichiro Hamaji
-//
-// Define utilties for glog internal usage.
-
-#ifndef UTILITIES_H__
-#define UTILITIES_H__
-
-#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
-# define OS_WINDOWS
-#elif defined(__CYGWIN__) || defined(__CYGWIN32__)
-# define OS_CYGWIN
-#elif defined(linux) || defined(__linux) || defined(__linux__)
-# define OS_LINUX
-#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
-# define OS_MACOSX
-#elif defined(__FreeBSD__)
-# define OS_FREEBSD
-#elif defined(__NetBSD__)
-# define OS_NETBSD
-#elif defined(__OpenBSD__)
-# define OS_OPENBSD
-#else
-// TODO(hamaji): Add other platforms.
-#endif
-
-// printf macros for size_t, in the style of inttypes.h
-#ifdef _LP64
-#define __PRIS_PREFIX "z"
-#else
-#define __PRIS_PREFIX
-#endif
-
-// Use these macros after a % in a printf format string
-// to get correct 32/64 bit behavior, like this:
-// size_t size = records.size();
-// printf("%"PRIuS"\n", size);
-
-#define PRIdS __PRIS_PREFIX "d"
-#define PRIxS __PRIS_PREFIX "x"
-#define PRIuS __PRIS_PREFIX "u"
-#define PRIXS __PRIS_PREFIX "X"
-#define PRIoS __PRIS_PREFIX "o"
-
-#include "base/mutex.h"  // This must go first so we get _XOPEN_SOURCE
-
-#include <string>
-
-#if defined(OS_WINDOWS)
-# include "port.h"
-#endif
-
-#include "config.h"
-#include "glog/logging.h"
-
-// There are three different ways we can try to get the stack trace:
-//
-// 1) The libunwind library.  This is still in development, and as a
-//    separate library adds a new dependency, but doesn't need a frame
-//    pointer.  It also doesn't call malloc.
-//
-// 2) Our hand-coded stack-unwinder.  This depends on a certain stack
-//    layout, which is used by gcc (and those systems using a
-//    gcc-compatible ABI) on x86 systems, at least since gcc 2.95.
-//    It uses the frame pointer to do its work.
-//
-// 3) The gdb unwinder -- also the one used by the c++ exception code.
-//    It's obviously well-tested, but has a fatal flaw: it can call
-//    malloc() from the unwinder.  This is a problem because we're
-//    trying to use the unwinder to instrument malloc().
-//
-// Note: if you add a new implementation here, make sure it works
-// correctly when GetStackTrace() is called with max_depth == 0.
-// Some code may do that.
-
-#if defined(HAVE_LIB_UNWIND)
-# define STACKTRACE_H "stacktrace_libunwind-inl.h"
-#elif !defined(NO_FRAME_POINTER)
-# if defined(__i386__) && __GNUC__ >= 2
-#  define STACKTRACE_H "stacktrace_x86-inl.h"
-# elif defined(__x86_64__) && __GNUC__ >= 2 && HAVE_UNWIND_H
-#  define STACKTRACE_H "stacktrace_x86_64-inl.h"
-# elif (defined(__ppc__) || defined(__PPC__)) && __GNUC__ >= 2
-#  define STACKTRACE_H "stacktrace_powerpc-inl.h"
-# endif
-#endif
-
-#if !defined(STACKTRACE_H) && defined(HAVE_EXECINFO_H)
-# define STACKTRACE_H "stacktrace_generic-inl.h"
-#endif
-
-#if defined(STACKTRACE_H)
-# define HAVE_STACKTRACE
-#endif
-
-// defined by gcc
-#if defined(__ELF__) && defined(OS_LINUX)
-# define HAVE_SYMBOLIZE
-#elif defined(OS_MACOSX) && defined(HAVE_DLADDR)
-// Use dladdr to symbolize.
-# define HAVE_SYMBOLIZE
-#endif
-
-#ifndef ARRAYSIZE
-// There is a better way, but this is good enough for our purpose.
-# define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a)))
-#endif
-
-_START_GOOGLE_NAMESPACE_
-
-namespace glog_internal_namespace_ {
-
-#ifdef HAVE___ATTRIBUTE__
-# define ATTRIBUTE_NOINLINE __attribute__ ((noinline))
-# define HAVE_ATTRIBUTE_NOINLINE
-#else
-# define ATTRIBUTE_NOINLINE
-#endif
-
-const char* ProgramInvocationShortName();
-
-bool IsGoogleLoggingInitialized();
-
-bool is_default_thread();
-
-int64 CycleClock_Now();
-
-int64 UsecToCycles(int64 usec);
-
-typedef double WallTime;
-WallTime WallTime_Now();
-
-int32 GetMainThreadPid();
-bool PidHasChanged();
-
-pid_t GetTID();
-
-const std::string& MyUserName();
-
-// Get the part of filepath after the last path separator.
-// (Doesn't modify filepath, contrary to basename() in libgen.h.)
-const char* const_basename(const char* filepath);
-
-// Wrapper of __sync_val_compare_and_swap. If the GCC extension isn't
-// defined, we try the CPU specific logics (we only support x86 and
-// x86_64 for now) first, then use a naive implementation, which has a
-// race condition.
-template<typename T>
-inline T sync_val_compare_and_swap(T* ptr, T oldval, T newval) {
-#if defined(HAVE___SYNC_VAL_COMPARE_AND_SWAP)
-  return __sync_val_compare_and_swap(ptr, oldval, newval);
-#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
-  T ret;
-  __asm__ __volatile__("lock; cmpxchg %1, (%2);"
-                       :"=a"(ret)
-                        // GCC may produces %sil or %dil for
-                        // constraint "r", but some of apple's gas
-                        // dosn't know the 8 bit registers.
-                        // We use "q" to avoid these registers.
-                       :"q"(newval), "q"(ptr), "a"(oldval)
-                       :"memory", "cc");
-  return ret;
-#else
-  T ret = *ptr;
-  if (ret == oldval) {
-    *ptr = newval;
-  }
-  return ret;
-#endif
-}
-
-void DumpStackTraceToString(std::string* stacktrace);
-
-struct CrashReason {
-  CrashReason() : filename(0), line_number(0), message(0), depth(0) {}
-
-  const char* filename;
-  int line_number;
-  const char* message;
-
-  // We'll also store a bit of stack trace context at the time of crash as
-  // it may not be available later on.
-  void* stack[32];
-  int depth;
-};
-
-void SetCrashReason(const CrashReason* r);
-
-void InitGoogleLoggingUtilities(const char* argv0);
-void ShutdownGoogleLoggingUtilities();
-
-}  // namespace glog_internal_namespace_
-
-_END_GOOGLE_NAMESPACE_
-
-using namespace GOOGLE_NAMESPACE::glog_internal_namespace_;
-
-#endif  // UTILITIES_H__

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/vlog_is_on.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/vlog_is_on.cc b/third_party/src/glog/src/windows/vlog_is_on.cc
deleted file mode 100644
index 8a79df5..0000000
--- a/third_party/src/glog/src/windows/vlog_is_on.cc
+++ /dev/null
@@ -1,249 +0,0 @@
-// Copyright (c) 1999, 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney and many others
-//
-// Broken out from logging.cc by Soren Lassen
-// logging_unittest.cc covers the functionality herein
-
-#include "utilities.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <cstdio>
-#include <string>
-#include "base/commandlineflags.h"
-#include "glog/logging.h"
-#include "glog/raw_logging.h"
-#include "base/googleinit.h"
-
-// glog doesn't have annotation
-#define ANNOTATE_BENIGN_RACE(address, description)
-
-using std::string;
-
-GLOG_DEFINE_int32(v, 0, "Show all VLOG(m) messages for m <= this."
-" Overridable by --vmodule.");
-
-GLOG_DEFINE_string(vmodule, "", "per-module verbose level."
-" Argument is a comma-separated list of <module name>=<log level>."
-" <module name> is a glob pattern, matched against the filename base"
-" (that is, name ignoring .cc/.h./-inl.h)."
-" <log level> overrides any value given by --v.");
-
-_START_GOOGLE_NAMESPACE_
-
-namespace glog_internal_namespace_ {
-
-// Implementation of fnmatch that does not need 0-termination
-// of arguments and does not allocate any memory,
-// but we only support "*" and "?" wildcards, not the "[...]" patterns.
-// It's not a static function for the unittest.
-GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern,
-                                       size_t patt_len,
-                                       const char* str,
-                                       size_t str_len) {
-  size_t p = 0;
-  size_t s = 0;
-  while (1) {
-    if (p == patt_len  &&  s == str_len) return true;
-    if (p == patt_len) return false;
-    if (s == str_len) return p+1 == patt_len  &&  pattern[p] == '*';
-    if (pattern[p] == str[s]  ||  pattern[p] == '?') {
-      p += 1;
-      s += 1;
-      continue;
-    }
-    if (pattern[p] == '*') {
-      if (p+1 == patt_len) return true;
-      do {
-        if (SafeFNMatch_(pattern+(p+1), patt_len-(p+1), str+s, str_len-s)) {
-          return true;
-        }
-        s += 1;
-      } while (s != str_len);
-      return false;
-    }
-    return false;
-  }
-}
-
-}  // namespace glog_internal_namespace_
-
-using glog_internal_namespace_::SafeFNMatch_;
-
-int32 kLogSiteUninitialized = 1000;
-
-// List of per-module log levels from FLAGS_vmodule.
-// Once created each element is never deleted/modified
-// except for the vlog_level: other threads will read VModuleInfo blobs
-// w/o locks and we'll store pointers to vlog_level at VLOG locations
-// that will never go away.
-// We can't use an STL struct here as we wouldn't know
-// when it's safe to delete/update it: other threads need to use it w/o locks.
-struct VModuleInfo {
-  string module_pattern;
-  mutable int32 vlog_level;  // Conceptually this is an AtomicWord, but it's
-                             // too much work to use AtomicWord type here
-                             // w/o much actual benefit.
-  const VModuleInfo* next;
-};
-
-// This protects the following global variables.
-static Mutex vmodule_lock;
-// Pointer to head of the VModuleInfo list.
-// It's a map from module pattern to logging level for those module(s).
-static VModuleInfo* vmodule_list = 0;
-// Boolean initialization flag.
-static bool inited_vmodule = false;
-
-// L >= vmodule_lock.
-static void VLOG2Initializer() {
-  vmodule_lock.AssertHeld();
-  // Can now parse --vmodule flag and initialize mapping of module-specific
-  // logging levels.
-  inited_vmodule = false;
-  const char* vmodule = FLAGS_vmodule.c_str();
-  const char* sep;
-  VModuleInfo* head = NULL;
-  VModuleInfo* tail = NULL;
-  while ((sep = strchr(vmodule, '=')) != NULL) {
-    string pattern(vmodule, sep - vmodule);
-    int module_level;
-    if (sscanf(sep, "=%d", &module_level) == 1) {
-      VModuleInfo* info = new VModuleInfo;
-      info->module_pattern = pattern;
-      info->vlog_level = module_level;
-      if (head)  tail->next = info;
-      else  head = info;
-      tail = info;
-    }
-    // Skip past this entry
-    vmodule = strchr(sep, ',');
-    if (vmodule == NULL) break;
-    vmodule++;  // Skip past ","
-  }
-  if (head) {  // Put them into the list at the head:
-    tail->next = vmodule_list;
-    vmodule_list = head;
-  }
-  inited_vmodule = true;
-}
-
-// This can be called very early, so we use SpinLock and RAW_VLOG here.
-int SetVLOGLevel(const char* module_pattern, int log_level) {
-  int result = FLAGS_v;
-  int const pattern_len = strlen(module_pattern);
-  bool found = false;
-  MutexLock l(&vmodule_lock);  // protect whole read-modify-write
-  for (const VModuleInfo* info = vmodule_list;
-       info != NULL; info = info->next) {
-    if (info->module_pattern == module_pattern) {
-      if (!found) {
-        result = info->vlog_level;
-        found = true;
-      }
-      info->vlog_level = log_level;
-    } else if (!found  &&
-               SafeFNMatch_(info->module_pattern.c_str(),
-                            info->module_pattern.size(),
-                            module_pattern, pattern_len)) {
-      result = info->vlog_level;
-      found = true;
-    }
-  }
-  if (!found) {
-    VModuleInfo* info = new VModuleInfo;
-    info->module_pattern = module_pattern;
-    info->vlog_level = log_level;
-    info->next = vmodule_list;
-    vmodule_list = info;
-  }
-  RAW_VLOG(1, "Set VLOG level for \"%s\" to %d", module_pattern, log_level);
-  return result;
-}
-
-// NOTE: Individual VLOG statements cache the integer log level pointers.
-// NOTE: This function must not allocate memory or require any locks.
-bool InitVLOG3__(int32** site_flag, int32* site_default,
-                 const char* fname, int32 verbose_level) {
-  MutexLock l(&vmodule_lock);
-  bool read_vmodule_flag = inited_vmodule;
-  if (!read_vmodule_flag) {
-    VLOG2Initializer();
-  }
-
-  // protect the errno global in case someone writes:
-  // VLOG(..) << "The last error was " << strerror(errno)
-  int old_errno = errno;
-
-  // site_default normally points to FLAGS_v
-  int32* site_flag_value = site_default;
-
-  // Get basename for file
-  const char* base = strrchr(fname, '/');
-  base = base ? (base+1) : fname;
-  const char* base_end = strchr(base, '.');
-  size_t base_length = base_end ? size_t(base_end - base) : strlen(base);
-
-  // Trim out trailing "-inl" if any
-  if (base_length >= 4 && (memcmp(base+base_length-4, "-inl", 4) == 0)) {
-    base_length -= 4;
-  }
-
-  // TODO: Trim out _unittest suffix?  Perhaps it is better to have
-  // the extra control and just leave it there.
-
-  // find target in vector of modules, replace site_flag_value with
-  // a module-specific verbose level, if any.
-  for (const VModuleInfo* info = vmodule_list;
-       info != NULL; info = info->next) {
-    if (SafeFNMatch_(info->module_pattern.c_str(), info->module_pattern.size(),
-                     base, base_length)) {
-      site_flag_value = &info->vlog_level;
-        // value at info->vlog_level is now what controls
-        // the VLOG at the caller site forever
-      break;
-    }
-  }
-
-  // Cache the vlog value pointer if --vmodule flag has been parsed.
-  ANNOTATE_BENIGN_RACE(site_flag,
-                       "*site_flag may be written by several threads,"
-                       " but the value will be the same");
-  if (read_vmodule_flag) *site_flag = site_flag_value;
-
-  // restore the errno in case something recoverable went wrong during
-  // the initialization of the VLOG mechanism (see above note "protect the..")
-  errno = old_errno;
-  return *site_flag_value >= verbose_level;
-}
-
-_END_GOOGLE_NAMESPACE_


[33/46] incubator-quickstep git commit: Remove glog source code from third party

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/logging.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/logging.cc b/third_party/src/glog/src/logging.cc
deleted file mode 100644
index ec334a9..0000000
--- a/third_party/src/glog/src/logging.cc
+++ /dev/null
@@ -1,2049 +0,0 @@
-// Copyright (c) 1999, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#define _GNU_SOURCE 1 // needed for O_NOFOLLOW and pread()/pwrite()
-
-#include "utilities.h"
-
-#include <assert.h>
-#include <iomanip>
-#include <string>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>  // For _exit.
-#endif
-#include <climits>
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef HAVE_SYS_UTSNAME_H
-# include <sys/utsname.h>  // For uname.
-#endif
-#include <fcntl.h>
-#include <cstdio>
-#include <iostream>
-#include <stdarg.h>
-#include <stdlib.h>
-#ifdef HAVE_PWD_H
-# include <pwd.h>
-#endif
-#ifdef HAVE_SYSLOG_H
-# include <syslog.h>
-#endif
-#include <vector>
-#include <errno.h>                   // for errno
-#include <sstream>
-#include "base/commandlineflags.h"        // to get the program name
-#include "glog/logging.h"
-#include "glog/raw_logging.h"
-#include "base/googleinit.h"
-
-#ifdef HAVE_STACKTRACE
-# include "stacktrace.h"
-#endif
-
-using std::string;
-using std::vector;
-using std::setw;
-using std::setfill;
-using std::hex;
-using std::dec;
-using std::min;
-using std::ostream;
-using std::ostringstream;
-
-using std::FILE;
-using std::fwrite;
-using std::fclose;
-using std::fflush;
-using std::fprintf;
-using std::perror;
-
-#ifdef __QNX__
-using std::fdopen;
-#endif
-
-// There is no thread annotation support.
-#define EXCLUSIVE_LOCKS_REQUIRED(mu)
-
-static bool BoolFromEnv(const char *varname, bool defval) {
-  const char* const valstr = getenv(varname);
-  if (!valstr) {
-    return defval;
-  }
-  return memchr("tTyY1\0", valstr[0], 6) != NULL;
-}
-
-GLOG_DEFINE_bool(logtostderr, BoolFromEnv("GOOGLE_LOGTOSTDERR", false),
-                 "log messages go to stderr instead of logfiles");
-GLOG_DEFINE_bool(alsologtostderr, BoolFromEnv("GOOGLE_ALSOLOGTOSTDERR", false),
-                 "log messages go to stderr in addition to logfiles");
-GLOG_DEFINE_bool(colorlogtostderr, false,
-                 "color messages logged to stderr (if supported by terminal)");
-#ifdef OS_LINUX
-GLOG_DEFINE_bool(drop_log_memory, true, "Drop in-memory buffers of log contents. "
-                 "Logs can grow very quickly and they are rarely read before they "
-                 "need to be evicted from memory. Instead, drop them from memory "
-                 "as soon as they are flushed to disk.");
-_START_GOOGLE_NAMESPACE_
-namespace logging {
-static const int64 kPageSize = getpagesize();
-}
-_END_GOOGLE_NAMESPACE_
-#endif
-
-// By default, errors (including fatal errors) get logged to stderr as
-// well as the file.
-//
-// The default is ERROR instead of FATAL so that users can see problems
-// when they run a program without having to look in another file.
-DEFINE_int32(stderrthreshold,
-             GOOGLE_NAMESPACE::GLOG_ERROR,
-             "log messages at or above this level are copied to stderr in "
-             "addition to logfiles.  This flag obsoletes --alsologtostderr.");
-
-GLOG_DEFINE_string(alsologtoemail, "",
-                   "log messages go to these email addresses "
-                   "in addition to logfiles");
-GLOG_DEFINE_bool(log_prefix, true,
-                 "Prepend the log prefix to the start of each log line");
-GLOG_DEFINE_int32(minloglevel, 0, "Messages logged at a lower level than this don't "
-                  "actually get logged anywhere");
-GLOG_DEFINE_int32(logbuflevel, 0,
-                  "Buffer log messages logged at this level or lower"
-                  " (-1 means don't buffer; 0 means buffer INFO only;"
-                  " ...)");
-GLOG_DEFINE_int32(logbufsecs, 30,
-                  "Buffer log messages for at most this many seconds");
-GLOG_DEFINE_int32(logemaillevel, 999,
-                  "Email log messages logged at this level or higher"
-                  " (0 means email all; 3 means email FATAL only;"
-                  " ...)");
-GLOG_DEFINE_string(logmailer, "/bin/mail",
-                   "Mailer used to send logging email");
-
-// Compute the default value for --log_dir
-static const char* DefaultLogDir() {
-  const char* env;
-  env = getenv("GOOGLE_LOG_DIR");
-  if (env != NULL && env[0] != '\0') {
-    return env;
-  }
-  env = getenv("TEST_TMPDIR");
-  if (env != NULL && env[0] != '\0') {
-    return env;
-  }
-  return "";
-}
-
-GLOG_DEFINE_string(log_dir, DefaultLogDir(),
-                   "If specified, logfiles are written into this directory instead "
-                   "of the default logging directory.");
-GLOG_DEFINE_string(log_link, "", "Put additional links to the log "
-                   "files in this directory");
-
-GLOG_DEFINE_int32(max_log_size, 1800,
-                  "approx. maximum log file size (in MB). A value of 0 will "
-                  "be silently overridden to 1.");
-
-GLOG_DEFINE_bool(stop_logging_if_full_disk, false,
-                 "Stop attempting to log to disk if the disk is full.");
-
-GLOG_DEFINE_string(log_backtrace_at, "",
-                   "Emit a backtrace when logging at file:linenum.");
-
-// TODO(hamaji): consider windows
-#define PATH_SEPARATOR '/'
-
-static void GetHostName(string* hostname) {
-#if defined(HAVE_SYS_UTSNAME_H)
-  struct utsname buf;
-  if (0 != uname(&buf)) {
-    // ensure null termination on failure
-    *buf.nodename = '\0';
-  }
-  *hostname = buf.nodename;
-#elif defined(OS_WINDOWS)
-  char buf[MAX_COMPUTERNAME_LENGTH + 1];
-  DWORD len = MAX_COMPUTERNAME_LENGTH + 1;
-  if (GetComputerNameA(buf, &len)) {
-    *hostname = buf;
-  } else {
-    hostname->clear();
-  }
-#else
-# warning There is no way to retrieve the host name.
-  *hostname = "(unknown)";
-#endif
-}
-
-// Returns true iff terminal supports using colors in output.
-static bool TerminalSupportsColor() {
-  bool term_supports_color = false;
-#ifdef OS_WINDOWS
-  // on Windows TERM variable is usually not set, but the console does
-  // support colors.
-  term_supports_color = true;
-#else
-  // On non-Windows platforms, we rely on the TERM variable.
-  const char* const term = getenv("TERM");
-  if (term != NULL && term[0] != '\0') {
-    term_supports_color =
-      !strcmp(term, "xterm") ||
-      !strcmp(term, "xterm-color") ||
-      !strcmp(term, "xterm-256color") ||
-      !strcmp(term, "screen") ||
-      !strcmp(term, "linux") ||
-      !strcmp(term, "cygwin");
-  }
-#endif
-  return term_supports_color;
-}
-
-_START_GOOGLE_NAMESPACE_
-
-enum GLogColor {
-  COLOR_DEFAULT,
-  COLOR_RED,
-  COLOR_GREEN,
-  COLOR_YELLOW
-};
-
-static GLogColor SeverityToColor(LogSeverity severity) {
-  assert(severity >= 0 && severity < NUM_SEVERITIES);
-  GLogColor color = COLOR_DEFAULT;
-  switch (severity) {
-  case GLOG_INFO:
-    color = COLOR_DEFAULT;
-    break;
-  case GLOG_WARNING:
-    color = COLOR_YELLOW;
-    break;
-  case GLOG_ERROR:
-  case GLOG_FATAL:
-    color = COLOR_RED;
-    break;
-  default:
-    // should never get here.
-    assert(false);
-  }
-  return color;
-}
-
-#ifdef OS_WINDOWS
-
-// Returns the character attribute for the given color.
-WORD GetColorAttribute(GLogColor color) {
-  switch (color) {
-    case COLOR_RED:    return FOREGROUND_RED;
-    case COLOR_GREEN:  return FOREGROUND_GREEN;
-    case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN;
-    default:           return 0;
-  }
-}
-
-#else
-
-// Returns the ANSI color code for the given color.
-const char* GetAnsiColorCode(GLogColor color) {
-  switch (color) {
-  case COLOR_RED:     return "1";
-  case COLOR_GREEN:   return "2";
-  case COLOR_YELLOW:  return "3";
-  case COLOR_DEFAULT:  return "";
-  };
-  return NULL; // stop warning about return type.
-}
-
-#endif  // OS_WINDOWS
-
-// Safely get max_log_size, overriding to 1 if it somehow gets defined as 0
-static int32 MaxLogSize() {
-  return (FLAGS_max_log_size > 0 ? FLAGS_max_log_size : 1);
-}
-
-struct LogMessage::LogMessageData  {
-  LogMessageData() {};
-
-  int preserved_errno_;      // preserved errno
-  char* buf_;                   // buffer space for non FATAL messages
-  char* message_text_;  // Complete message text (points to selected buffer)
-  LogStream* stream_alloc_;
-  LogStream* stream_;
-  char severity_;      // What level is this LogMessage logged at?
-  int line_;                 // line number where logging call is.
-  void (LogMessage::*send_method_)();  // Call this in destructor to send
-  union {  // At most one of these is used: union to keep the size low.
-    LogSink* sink_;             // NULL or sink to send message to
-    std::vector<std::string>* outvec_; // NULL or vector to push message onto
-    std::string* message_;             // NULL or string to write message into
-  };
-  time_t timestamp_;            // Time of creation of LogMessage
-  struct ::tm tm_time_;         // Time of creation of LogMessage
-  size_t num_prefix_chars_;     // # of chars of prefix in this message
-  size_t num_chars_to_log_;     // # of chars of msg to send to log
-  size_t num_chars_to_syslog_;  // # of chars of msg to send to syslog
-  const char* basename_;        // basename of file that called LOG
-  const char* fullname_;        // fullname of file that called LOG
-  bool has_been_flushed_;       // false => data has not been flushed
-  bool first_fatal_;            // true => this was first fatal msg
-
-  ~LogMessageData();
-
- private:
-  LogMessageData(const LogMessageData&);
-  void operator=(const LogMessageData&);
-};
-
-// A mutex that allows only one thread to log at a time, to keep things from
-// getting jumbled.  Some other very uncommon logging operations (like
-// changing the destination file for log messages of a given severity) also
-// lock this mutex.  Please be sure that anybody who might possibly need to
-// lock it does so.
-static Mutex log_mutex;
-
-// Number of messages sent at each severity.  Under log_mutex.
-int64 LogMessage::num_messages_[NUM_SEVERITIES] = {0, 0, 0, 0};
-
-// Globally disable log writing (if disk is full)
-static bool stop_writing = false;
-
-const char*const LogSeverityNames[NUM_SEVERITIES] = {
-  "INFO", "WARNING", "ERROR", "FATAL"
-};
-
-// Has the user called SetExitOnDFatal(true)?
-static bool exit_on_dfatal = true;
-
-const char* GetLogSeverityName(LogSeverity severity) {
-  return LogSeverityNames[severity];
-}
-
-static bool SendEmailInternal(const char*dest, const char *subject,
-                              const char*body, bool use_logging);
-
-base::Logger::~Logger() {
-}
-
-namespace {
-
-// Encapsulates all file-system related state
-class LogFileObject : public base::Logger {
- public:
-  LogFileObject(LogSeverity severity, const char* base_filename);
-  ~LogFileObject();
-
-  virtual void Write(bool force_flush, // Should we force a flush here?
-                     time_t timestamp,  // Timestamp for this entry
-                     const char* message,
-                     int message_len);
-
-  // Configuration options
-  void SetBasename(const char* basename);
-  void SetExtension(const char* ext);
-  void SetSymlinkBasename(const char* symlink_basename);
-
-  // Normal flushing routine
-  virtual void Flush();
-
-  // It is the actual file length for the system loggers,
-  // i.e., INFO, ERROR, etc.
-  virtual uint32 LogSize() {
-    MutexLock l(&lock_);
-    return file_length_;
-  }
-
-  // Internal flush routine.  Exposed so that FlushLogFilesUnsafe()
-  // can avoid grabbing a lock.  Usually Flush() calls it after
-  // acquiring lock_.
-  void FlushUnlocked();
-
- private:
-  static const uint32 kRolloverAttemptFrequency = 0x20;
-
-  Mutex lock_;
-  bool base_filename_selected_;
-  string base_filename_;
-  string symlink_basename_;
-  string filename_extension_;     // option users can specify (eg to add port#)
-  FILE* file_;
-  LogSeverity severity_;
-  uint32 bytes_since_flush_;
-  uint32 file_length_;
-  unsigned int rollover_attempt_;
-  int64 next_flush_time_;         // cycle count at which to flush log
-
-  // Actually create a logfile using the value of base_filename_ and the
-  // supplied argument time_pid_string
-  // REQUIRES: lock_ is held
-  bool CreateLogfile(const string& time_pid_string);
-};
-
-}  // namespace
-
-class LogDestination {
- public:
-  friend class LogMessage;
-  friend void ReprintFatalMessage();
-  friend base::Logger* base::GetLogger(LogSeverity);
-  friend void base::SetLogger(LogSeverity, base::Logger*);
-
-  // These methods are just forwarded to by their global versions.
-  static void SetLogDestination(LogSeverity severity,
-				const char* base_filename);
-  static void SetLogSymlink(LogSeverity severity,
-                            const char* symlink_basename);
-  static void AddLogSink(LogSink *destination);
-  static void RemoveLogSink(LogSink *destination);
-  static void SetLogFilenameExtension(const char* filename_extension);
-  static void SetStderrLogging(LogSeverity min_severity);
-  static void SetEmailLogging(LogSeverity min_severity, const char* addresses);
-  static void LogToStderr();
-  // Flush all log files that are at least at the given severity level
-  static void FlushLogFiles(int min_severity);
-  static void FlushLogFilesUnsafe(int min_severity);
-
-  // we set the maximum size of our packet to be 1400, the logic being
-  // to prevent fragmentation.
-  // Really this number is arbitrary.
-  static const int kNetworkBytes = 1400;
-
-  static const string& hostname();
-  static const bool& terminal_supports_color() {
-    return terminal_supports_color_;
-  }
-
-  static void DeleteLogDestinations();
-
- private:
-  LogDestination(LogSeverity severity, const char* base_filename);
-  ~LogDestination() { }
-
-  // Take a log message of a particular severity and log it to stderr
-  // iff it's of a high enough severity to deserve it.
-  static void MaybeLogToStderr(LogSeverity severity, const char* message,
-			       size_t len);
-
-  // Take a log message of a particular severity and log it to email
-  // iff it's of a high enough severity to deserve it.
-  static void MaybeLogToEmail(LogSeverity severity, const char* message,
-			      size_t len);
-  // Take a log message of a particular severity and log it to a file
-  // iff the base filename is not "" (which means "don't log to me")
-  static void MaybeLogToLogfile(LogSeverity severity,
-                                time_t timestamp,
-				const char* message, size_t len);
-  // Take a log message of a particular severity and log it to the file
-  // for that severity and also for all files with severity less than
-  // this severity.
-  static void LogToAllLogfiles(LogSeverity severity,
-                               time_t timestamp,
-                               const char* message, size_t len);
-
-  // Send logging info to all registered sinks.
-  static void LogToSinks(LogSeverity severity,
-                         const char *full_filename,
-                         const char *base_filename,
-                         int line,
-                         const struct ::tm* tm_time,
-                         const char* message,
-                         size_t message_len);
-
-  // Wait for all registered sinks via WaitTillSent
-  // including the optional one in "data".
-  static void WaitForSinks(LogMessage::LogMessageData* data);
-
-  static LogDestination* log_destination(LogSeverity severity);
-
-  LogFileObject fileobject_;
-  base::Logger* logger_;      // Either &fileobject_, or wrapper around it
-
-  static LogDestination* log_destinations_[NUM_SEVERITIES];
-  static LogSeverity email_logging_severity_;
-  static string addresses_;
-  static string hostname_;
-  static bool terminal_supports_color_;
-
-  // arbitrary global logging destinations.
-  static vector<LogSink*>* sinks_;
-
-  // Protects the vector sinks_,
-  // but not the LogSink objects its elements reference.
-  static Mutex sink_mutex_;
-
-  // Disallow
-  LogDestination(const LogDestination&);
-  LogDestination& operator=(const LogDestination&);
-};
-
-// Errors do not get logged to email by default.
-LogSeverity LogDestination::email_logging_severity_ = 99999;
-
-string LogDestination::addresses_;
-string LogDestination::hostname_;
-
-vector<LogSink*>* LogDestination::sinks_ = NULL;
-Mutex LogDestination::sink_mutex_;
-bool LogDestination::terminal_supports_color_ = TerminalSupportsColor();
-
-/* static */
-const string& LogDestination::hostname() {
-  if (hostname_.empty()) {
-    GetHostName(&hostname_);
-    if (hostname_.empty()) {
-      hostname_ = "(unknown)";
-    }
-  }
-  return hostname_;
-}
-
-LogDestination::LogDestination(LogSeverity severity,
-                               const char* base_filename)
-  : fileobject_(severity, base_filename),
-    logger_(&fileobject_) {
-}
-
-inline void LogDestination::FlushLogFilesUnsafe(int min_severity) {
-  // assume we have the log_mutex or we simply don't care
-  // about it
-  for (int i = min_severity; i < NUM_SEVERITIES; i++) {
-    LogDestination* log = log_destination(i);
-    if (log != NULL) {
-      // Flush the base fileobject_ logger directly instead of going
-      // through any wrappers to reduce chance of deadlock.
-      log->fileobject_.FlushUnlocked();
-    }
-  }
-}
-
-inline void LogDestination::FlushLogFiles(int min_severity) {
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  for (int i = min_severity; i < NUM_SEVERITIES; i++) {
-    LogDestination* log = log_destination(i);
-    if (log != NULL) {
-      log->logger_->Flush();
-    }
-  }
-}
-
-inline void LogDestination::SetLogDestination(LogSeverity severity,
-					      const char* base_filename) {
-  assert(severity >= 0 && severity < NUM_SEVERITIES);
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  log_destination(severity)->fileobject_.SetBasename(base_filename);
-}
-
-inline void LogDestination::SetLogSymlink(LogSeverity severity,
-                                          const char* symlink_basename) {
-  CHECK_GE(severity, 0);
-  CHECK_LT(severity, NUM_SEVERITIES);
-  MutexLock l(&log_mutex);
-  log_destination(severity)->fileobject_.SetSymlinkBasename(symlink_basename);
-}
-
-inline void LogDestination::AddLogSink(LogSink *destination) {
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&sink_mutex_);
-  if (!sinks_)  sinks_ = new vector<LogSink*>;
-  sinks_->push_back(destination);
-}
-
-inline void LogDestination::RemoveLogSink(LogSink *destination) {
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&sink_mutex_);
-  // This doesn't keep the sinks in order, but who cares?
-  if (sinks_) {
-    for (int i = sinks_->size() - 1; i >= 0; i--) {
-      if ((*sinks_)[i] == destination) {
-        (*sinks_)[i] = (*sinks_)[sinks_->size() - 1];
-        sinks_->pop_back();
-        break;
-      }
-    }
-  }
-}
-
-inline void LogDestination::SetLogFilenameExtension(const char* ext) {
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  for ( int severity = 0; severity < NUM_SEVERITIES; ++severity ) {
-    log_destination(severity)->fileobject_.SetExtension(ext);
-  }
-}
-
-inline void LogDestination::SetStderrLogging(LogSeverity min_severity) {
-  assert(min_severity >= 0 && min_severity < NUM_SEVERITIES);
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  FLAGS_stderrthreshold = min_severity;
-}
-
-inline void LogDestination::LogToStderr() {
-  // *Don't* put this stuff in a mutex lock, since SetStderrLogging &
-  // SetLogDestination already do the locking!
-  SetStderrLogging(0);            // thus everything is "also" logged to stderr
-  for ( int i = 0; i < NUM_SEVERITIES; ++i ) {
-    SetLogDestination(i, "");     // "" turns off logging to a logfile
-  }
-}
-
-inline void LogDestination::SetEmailLogging(LogSeverity min_severity,
-					    const char* addresses) {
-  assert(min_severity >= 0 && min_severity < NUM_SEVERITIES);
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // all this stuff.
-  MutexLock l(&log_mutex);
-  LogDestination::email_logging_severity_ = min_severity;
-  LogDestination::addresses_ = addresses;
-}
-
-static void ColoredWriteToStderr(LogSeverity severity,
-                                 const char* message, size_t len) {
-  const GLogColor color =
-      (LogDestination::terminal_supports_color() && FLAGS_colorlogtostderr) ?
-      SeverityToColor(severity) : COLOR_DEFAULT;
-
-  // Avoid using cerr from this module since we may get called during
-  // exit code, and cerr may be partially or fully destroyed by then.
-  if (COLOR_DEFAULT == color) {
-    fwrite(message, len, 1, stderr);
-    return;
-  }
-#ifdef OS_WINDOWS
-  const HANDLE stderr_handle = GetStdHandle(STD_ERROR_HANDLE);
-
-  // Gets the current text color.
-  CONSOLE_SCREEN_BUFFER_INFO buffer_info;
-  GetConsoleScreenBufferInfo(stderr_handle, &buffer_info);
-  const WORD old_color_attrs = buffer_info.wAttributes;
-
-  // We need to flush the stream buffers into the console before each
-  // SetConsoleTextAttribute call lest it affect the text that is already
-  // printed but has not yet reached the console.
-  fflush(stderr);
-  SetConsoleTextAttribute(stderr_handle,
-                          GetColorAttribute(color) | FOREGROUND_INTENSITY);
-  fwrite(message, len, 1, stderr);
-  fflush(stderr);
-  // Restores the text color.
-  SetConsoleTextAttribute(stderr_handle, old_color_attrs);
-#else
-  fprintf(stderr, "\033[0;3%sm", GetAnsiColorCode(color));
-  fwrite(message, len, 1, stderr);
-  fprintf(stderr, "\033[m");  // Resets the terminal to default.
-#endif  // OS_WINDOWS
-}
-
-static void WriteToStderr(const char* message, size_t len) {
-  // Avoid using cerr from this module since we may get called during
-  // exit code, and cerr may be partially or fully destroyed by then.
-  fwrite(message, len, 1, stderr);
-}
-
-inline void LogDestination::MaybeLogToStderr(LogSeverity severity,
-					     const char* message, size_t len) {
-  if ((severity >= FLAGS_stderrthreshold) || FLAGS_alsologtostderr) {
-    ColoredWriteToStderr(severity, message, len);
-#ifdef OS_WINDOWS
-    // On Windows, also output to the debugger
-    ::OutputDebugStringA(string(message,len).c_str());
-#endif
-  }
-}
-
-
-inline void LogDestination::MaybeLogToEmail(LogSeverity severity,
-					    const char* message, size_t len) {
-  if (severity >= email_logging_severity_ ||
-      severity >= FLAGS_logemaillevel) {
-    string to(FLAGS_alsologtoemail);
-    if (!addresses_.empty()) {
-      if (!to.empty()) {
-        to += ",";
-      }
-      to += addresses_;
-    }
-    const string subject(string("[LOG] ") + LogSeverityNames[severity] + ": " +
-                         glog_internal_namespace_::ProgramInvocationShortName());
-    string body(hostname());
-    body += "\n\n";
-    body.append(message, len);
-
-    // should NOT use SendEmail().  The caller of this function holds the
-    // log_mutex and SendEmail() calls LOG/VLOG which will block trying to
-    // acquire the log_mutex object.  Use SendEmailInternal() and set
-    // use_logging to false.
-    SendEmailInternal(to.c_str(), subject.c_str(), body.c_str(), false);
-  }
-}
-
-
-inline void LogDestination::MaybeLogToLogfile(LogSeverity severity,
-                                              time_t timestamp,
-					      const char* message,
-					      size_t len) {
-  const bool should_flush = severity > FLAGS_logbuflevel;
-  LogDestination* destination = log_destination(severity);
-  destination->logger_->Write(should_flush, timestamp, message, len);
-}
-
-inline void LogDestination::LogToAllLogfiles(LogSeverity severity,
-                                             time_t timestamp,
-                                             const char* message,
-                                             size_t len) {
-
-  if ( FLAGS_logtostderr ) {           // global flag: never log to file
-    ColoredWriteToStderr(severity, message, len);
-  } else {
-    for (int i = severity; i >= 0; --i)
-      LogDestination::MaybeLogToLogfile(i, timestamp, message, len);
-  }
-}
-
-inline void LogDestination::LogToSinks(LogSeverity severity,
-                                       const char *full_filename,
-                                       const char *base_filename,
-                                       int line,
-                                       const struct ::tm* tm_time,
-                                       const char* message,
-                                       size_t message_len) {
-  ReaderMutexLock l(&sink_mutex_);
-  if (sinks_) {
-    for (int i = sinks_->size() - 1; i >= 0; i--) {
-      (*sinks_)[i]->send(severity, full_filename, base_filename,
-                         line, tm_time, message, message_len);
-    }
-  }
-}
-
-inline void LogDestination::WaitForSinks(LogMessage::LogMessageData* data) {
-  ReaderMutexLock l(&sink_mutex_);
-  if (sinks_) {
-    for (int i = sinks_->size() - 1; i >= 0; i--) {
-      (*sinks_)[i]->WaitTillSent();
-    }
-  }
-  const bool send_to_sink =
-      (data->send_method_ == &LogMessage::SendToSink) ||
-      (data->send_method_ == &LogMessage::SendToSinkAndLog);
-  if (send_to_sink && data->sink_ != NULL) {
-    data->sink_->WaitTillSent();
-  }
-}
-
-LogDestination* LogDestination::log_destinations_[NUM_SEVERITIES];
-
-inline LogDestination* LogDestination::log_destination(LogSeverity severity) {
-  assert(severity >=0 && severity < NUM_SEVERITIES);
-  if (!log_destinations_[severity]) {
-    log_destinations_[severity] = new LogDestination(severity, NULL);
-  }
-  return log_destinations_[severity];
-}
-
-void LogDestination::DeleteLogDestinations() {
-  for (int severity = 0; severity < NUM_SEVERITIES; ++severity) {
-    delete log_destinations_[severity];
-    log_destinations_[severity] = NULL;
-  }
-}
-
-namespace {
-
-LogFileObject::LogFileObject(LogSeverity severity,
-                             const char* base_filename)
-  : base_filename_selected_(base_filename != NULL),
-    base_filename_((base_filename != NULL) ? base_filename : ""),
-    symlink_basename_(glog_internal_namespace_::ProgramInvocationShortName()),
-    filename_extension_(),
-    file_(NULL),
-    severity_(severity),
-    bytes_since_flush_(0),
-    file_length_(0),
-    rollover_attempt_(kRolloverAttemptFrequency-1),
-    next_flush_time_(0) {
-  assert(severity >= 0);
-  assert(severity < NUM_SEVERITIES);
-}
-
-LogFileObject::~LogFileObject() {
-  MutexLock l(&lock_);
-  if (file_ != NULL) {
-    fclose(file_);
-    file_ = NULL;
-  }
-}
-
-void LogFileObject::SetBasename(const char* basename) {
-  MutexLock l(&lock_);
-  base_filename_selected_ = true;
-  if (base_filename_ != basename) {
-    // Get rid of old log file since we are changing names
-    if (file_ != NULL) {
-      fclose(file_);
-      file_ = NULL;
-      rollover_attempt_ = kRolloverAttemptFrequency-1;
-    }
-    base_filename_ = basename;
-  }
-}
-
-void LogFileObject::SetExtension(const char* ext) {
-  MutexLock l(&lock_);
-  if (filename_extension_ != ext) {
-    // Get rid of old log file since we are changing names
-    if (file_ != NULL) {
-      fclose(file_);
-      file_ = NULL;
-      rollover_attempt_ = kRolloverAttemptFrequency-1;
-    }
-    filename_extension_ = ext;
-  }
-}
-
-void LogFileObject::SetSymlinkBasename(const char* symlink_basename) {
-  MutexLock l(&lock_);
-  symlink_basename_ = symlink_basename;
-}
-
-void LogFileObject::Flush() {
-  MutexLock l(&lock_);
-  FlushUnlocked();
-}
-
-void LogFileObject::FlushUnlocked(){
-  if (file_ != NULL) {
-    fflush(file_);
-    bytes_since_flush_ = 0;
-  }
-  // Figure out when we are due for another flush.
-  const int64 next = (FLAGS_logbufsecs
-                      * static_cast<int64>(1000000));  // in usec
-  next_flush_time_ = CycleClock_Now() + UsecToCycles(next);
-}
-
-bool LogFileObject::CreateLogfile(const string& time_pid_string) {
-  string string_filename = base_filename_+filename_extension_+
-                           time_pid_string;
-  const char* filename = string_filename.c_str();
-  int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0664);
-  if (fd == -1) return false;
-#ifdef HAVE_FCNTL
-  // Mark the file close-on-exec. We don't really care if this fails
-  fcntl(fd, F_SETFD, FD_CLOEXEC);
-#endif
-
-  file_ = fdopen(fd, "a");  // Make a FILE*.
-  if (file_ == NULL) {  // Man, we're screwed!
-    close(fd);
-    unlink(filename);  // Erase the half-baked evidence: an unusable log file
-    return false;
-  }
-
-  // We try to create a symlink called <program_name>.<severity>,
-  // which is easier to use.  (Every time we create a new logfile,
-  // we destroy the old symlink and create a new one, so it always
-  // points to the latest logfile.)  If it fails, we're sad but it's
-  // no error.
-  if (!symlink_basename_.empty()) {
-    // take directory from filename
-    const char* slash = strrchr(filename, PATH_SEPARATOR);
-    const string linkname =
-      symlink_basename_ + '.' + LogSeverityNames[severity_];
-    string linkpath;
-    if ( slash ) linkpath = string(filename, slash-filename+1);  // get dirname
-    linkpath += linkname;
-    unlink(linkpath.c_str());                    // delete old one if it exists
-
-    // We must have unistd.h.
-#ifdef HAVE_UNISTD_H
-    // Make the symlink be relative (in the same dir) so that if the
-    // entire log directory gets relocated the link is still valid.
-    const char *linkdest = slash ? (slash + 1) : filename;
-    if (symlink(linkdest, linkpath.c_str()) != 0) {
-      // silently ignore failures
-    }
-
-    // Make an additional link to the log file in a place specified by
-    // FLAGS_log_link, if indicated
-    if (!FLAGS_log_link.empty()) {
-      linkpath = FLAGS_log_link + "/" + linkname;
-      unlink(linkpath.c_str());                  // delete old one if it exists
-      if (symlink(filename, linkpath.c_str()) != 0) {
-        // silently ignore failures
-      }
-    }
-#endif
-  }
-
-  return true;  // Everything worked
-}
-
-void LogFileObject::Write(bool force_flush,
-                          time_t timestamp,
-                          const char* message,
-                          int message_len) {
-  MutexLock l(&lock_);
-
-  // We don't log if the base_name_ is "" (which means "don't write")
-  if (base_filename_selected_ && base_filename_.empty()) {
-    return;
-  }
-
-  if (static_cast<int>(file_length_ >> 20) >= MaxLogSize() ||
-      PidHasChanged()) {
-    if (file_ != NULL) fclose(file_);
-    file_ = NULL;
-    file_length_ = bytes_since_flush_ = 0;
-    rollover_attempt_ = kRolloverAttemptFrequency-1;
-  }
-
-  // If there's no destination file, make one before outputting
-  if (file_ == NULL) {
-    // Try to rollover the log file every 32 log messages.  The only time
-    // this could matter would be when we have trouble creating the log
-    // file.  If that happens, we'll lose lots of log messages, of course!
-    if (++rollover_attempt_ != kRolloverAttemptFrequency) return;
-    rollover_attempt_ = 0;
-
-    struct ::tm tm_time;
-    localtime_r(&timestamp, &tm_time);
-
-    // The logfile's filename will have the date/time & pid in it
-    ostringstream time_pid_stream;
-    time_pid_stream.fill('0');
-    time_pid_stream << 1900+tm_time.tm_year
-                    << setw(2) << 1+tm_time.tm_mon
-                    << setw(2) << tm_time.tm_mday
-                    << '-'
-                    << setw(2) << tm_time.tm_hour
-                    << setw(2) << tm_time.tm_min
-                    << setw(2) << tm_time.tm_sec
-                    << '.'
-                    << GetMainThreadPid();
-    const string& time_pid_string = time_pid_stream.str();
-
-    if (base_filename_selected_) {
-      if (!CreateLogfile(time_pid_string)) {
-        perror("Could not create log file");
-        fprintf(stderr, "COULD NOT CREATE LOGFILE '%s'!\n",
-                time_pid_string.c_str());
-        return;
-      }
-    } else {
-      // If no base filename for logs of this severity has been set, use a
-      // default base filename of
-      // "<program name>.<hostname>.<user name>.log.<severity level>.".  So
-      // logfiles will have names like
-      // webserver.examplehost.root.log.INFO.19990817-150000.4354, where
-      // 19990817 is a date (1999 August 17), 150000 is a time (15:00:00),
-      // and 4354 is the pid of the logging process.  The date & time reflect
-      // when the file was created for output.
-      //
-      // Where does the file get put?  Successively try the directories
-      // "/tmp", and "."
-      string stripped_filename(
-          glog_internal_namespace_::ProgramInvocationShortName());
-      string hostname;
-      GetHostName(&hostname);
-
-      string uidname = MyUserName();
-      // We should not call CHECK() here because this function can be
-      // called after holding on to log_mutex. We don't want to
-      // attempt to hold on to the same mutex, and get into a
-      // deadlock. Simply use a name like invalid-user.
-      if (uidname.empty()) uidname = "invalid-user";
-
-      stripped_filename = stripped_filename+'.'+hostname+'.'
-                          +uidname+".log."
-                          +LogSeverityNames[severity_]+'.';
-      // We're going to (potentially) try to put logs in several different dirs
-      const vector<string> & log_dirs = GetLoggingDirectories();
-
-      // Go through the list of dirs, and try to create the log file in each
-      // until we succeed or run out of options
-      bool success = false;
-      for (vector<string>::const_iterator dir = log_dirs.begin();
-           dir != log_dirs.end();
-           ++dir) {
-        base_filename_ = *dir + "/" + stripped_filename;
-        if ( CreateLogfile(time_pid_string) ) {
-          success = true;
-          break;
-        }
-      }
-      // If we never succeeded, we have to give up
-      if ( success == false ) {
-        perror("Could not create logging file");
-        fprintf(stderr, "COULD NOT CREATE A LOGGINGFILE %s!",
-                time_pid_string.c_str());
-        return;
-      }
-    }
-
-    // Write a header message into the log file
-    ostringstream file_header_stream;
-    file_header_stream.fill('0');
-    file_header_stream << "Log file created at: "
-                       << 1900+tm_time.tm_year << '/'
-                       << setw(2) << 1+tm_time.tm_mon << '/'
-                       << setw(2) << tm_time.tm_mday
-                       << ' '
-                       << setw(2) << tm_time.tm_hour << ':'
-                       << setw(2) << tm_time.tm_min << ':'
-                       << setw(2) << tm_time.tm_sec << '\n'
-                       << "Running on machine: "
-                       << LogDestination::hostname() << '\n'
-                       << "Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu "
-                       << "threadid file:line] msg" << '\n';
-    const string& file_header_string = file_header_stream.str();
-
-    const int header_len = file_header_string.size();
-    fwrite(file_header_string.data(), 1, header_len, file_);
-    file_length_ += header_len;
-    bytes_since_flush_ += header_len;
-  }
-
-  // Write to LOG file
-  if ( !stop_writing ) {
-    // fwrite() doesn't return an error when the disk is full, for
-    // messages that are less than 4096 bytes. When the disk is full,
-    // it returns the message length for messages that are less than
-    // 4096 bytes. fwrite() returns 4096 for message lengths that are
-    // greater than 4096, thereby indicating an error.
-    errno = 0;
-    fwrite(message, 1, message_len, file_);
-    if ( FLAGS_stop_logging_if_full_disk &&
-         errno == ENOSPC ) {  // disk full, stop writing to disk
-      stop_writing = true;  // until the disk is
-      return;
-    } else {
-      file_length_ += message_len;
-      bytes_since_flush_ += message_len;
-    }
-  } else {
-    if ( CycleClock_Now() >= next_flush_time_ )
-      stop_writing = false;  // check to see if disk has free space.
-    return;  // no need to flush
-  }
-
-  // See important msgs *now*.  Also, flush logs at least every 10^6 chars,
-  // or every "FLAGS_logbufsecs" seconds.
-  if ( force_flush ||
-       (bytes_since_flush_ >= 1000000) ||
-       (CycleClock_Now() >= next_flush_time_) ) {
-    FlushUnlocked();
-#ifdef OS_LINUX
-    if (FLAGS_drop_log_memory) {
-      if (file_length_ >= logging::kPageSize) {
-        // don't evict the most recent page
-        uint32 len = file_length_ & ~(logging::kPageSize - 1);
-        posix_fadvise(fileno(file_), 0, len, POSIX_FADV_DONTNEED);
-      }
-    }
-#endif
-  }
-}
-
-}  // namespace
-
-// An arbitrary limit on the length of a single log message.  This
-// is so that streaming can be done more efficiently.
-const size_t LogMessage::kMaxLogMessageLen = 30000;
-
-// Static log data space to avoid alloc failures in a LOG(FATAL)
-//
-// Since multiple threads may call LOG(FATAL), and we want to preserve
-// the data from the first call, we allocate two sets of space.  One
-// for exclusive use by the first thread, and one for shared use by
-// all other threads.
-static Mutex fatal_msg_lock;
-static CrashReason crash_reason;
-static bool fatal_msg_exclusive = true;
-static char fatal_msg_buf_exclusive[LogMessage::kMaxLogMessageLen+1];
-static char fatal_msg_buf_shared[LogMessage::kMaxLogMessageLen+1];
-static LogMessage::LogStream fatal_msg_stream_exclusive(
-    fatal_msg_buf_exclusive, LogMessage::kMaxLogMessageLen, 0);
-static LogMessage::LogStream fatal_msg_stream_shared(
-    fatal_msg_buf_shared, LogMessage::kMaxLogMessageLen, 0);
-static LogMessage::LogMessageData fatal_msg_data_exclusive;
-static LogMessage::LogMessageData fatal_msg_data_shared;
-
-LogMessage::LogMessageData::~LogMessageData() {
-  delete[] buf_;
-  delete stream_alloc_;
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
-                       int ctr, void (LogMessage::*send_method)())
-    : allocated_(NULL) {
-  Init(file, line, severity, send_method);
-  data_->stream_->set_ctr(ctr);
-}
-
-LogMessage::LogMessage(const char* file, int line,
-                       const CheckOpString& result)
-    : allocated_(NULL) {
-  Init(file, line, GLOG_FATAL, &LogMessage::SendToLog);
-  stream() << "Check failed: " << (*result.str_) << " ";
-}
-
-LogMessage::LogMessage(const char* file, int line)
-    : allocated_(NULL) {
-  Init(file, line, GLOG_INFO, &LogMessage::SendToLog);
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity)
-    : allocated_(NULL) {
-  Init(file, line, severity, &LogMessage::SendToLog);
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
-                       LogSink* sink, bool also_send_to_log)
-    : allocated_(NULL) {
-  Init(file, line, severity, also_send_to_log ? &LogMessage::SendToSinkAndLog :
-                                                &LogMessage::SendToSink);
-  data_->sink_ = sink;  // override Init()'s setting to NULL
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
-                       vector<string> *outvec)
-    : allocated_(NULL) {
-  Init(file, line, severity, &LogMessage::SaveOrSendToLog);
-  data_->outvec_ = outvec; // override Init()'s setting to NULL
-}
-
-LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
-                       string *message)
-    : allocated_(NULL) {
-  Init(file, line, severity, &LogMessage::WriteToStringAndLog);
-  data_->message_ = message;  // override Init()'s setting to NULL
-}
-
-void LogMessage::Init(const char* file,
-                      int line,
-                      LogSeverity severity,
-                      void (LogMessage::*send_method)()) {
-  allocated_ = NULL;
-  if (severity != GLOG_FATAL || !exit_on_dfatal) {
-    allocated_ = new LogMessageData();
-    data_ = allocated_;
-    data_->buf_ = new char[kMaxLogMessageLen+1];
-    data_->message_text_ = data_->buf_;
-    data_->stream_alloc_ =
-        new LogStream(data_->message_text_, kMaxLogMessageLen, 0);
-    data_->stream_ = data_->stream_alloc_;
-    data_->first_fatal_ = false;
-  } else {
-    MutexLock l(&fatal_msg_lock);
-    if (fatal_msg_exclusive) {
-      fatal_msg_exclusive = false;
-      data_ = &fatal_msg_data_exclusive;
-      data_->message_text_ = fatal_msg_buf_exclusive;
-      data_->stream_ = &fatal_msg_stream_exclusive;
-      data_->first_fatal_ = true;
-    } else {
-      data_ = &fatal_msg_data_shared;
-      data_->message_text_ = fatal_msg_buf_shared;
-      data_->stream_ = &fatal_msg_stream_shared;
-      data_->first_fatal_ = false;
-    }
-    data_->stream_alloc_ = NULL;
-  }
-
-  stream().fill('0');
-  data_->preserved_errno_ = errno;
-  data_->severity_ = severity;
-  data_->line_ = line;
-  data_->send_method_ = send_method;
-  data_->sink_ = NULL;
-  data_->outvec_ = NULL;
-  WallTime now = WallTime_Now();
-  data_->timestamp_ = static_cast<time_t>(now);
-  localtime_r(&data_->timestamp_, &data_->tm_time_);
-  int usecs = static_cast<int>((now - data_->timestamp_) * 1000000);
-  RawLog__SetLastTime(data_->tm_time_, usecs);
-
-  data_->num_chars_to_log_ = 0;
-  data_->num_chars_to_syslog_ = 0;
-  data_->basename_ = const_basename(file);
-  data_->fullname_ = file;
-  data_->has_been_flushed_ = false;
-
-  // If specified, prepend a prefix to each line.  For example:
-  //    I1018 160715 f5d4fbb0 logging.cc:1153]
-  //    (log level, GMT month, date, time, thread_id, file basename, line)
-  // We exclude the thread_id for the default thread.
-  if (FLAGS_log_prefix && (line != kNoLogPrefix)) {
-    stream() << LogSeverityNames[severity][0]
-             << setw(2) << 1+data_->tm_time_.tm_mon
-             << setw(2) << data_->tm_time_.tm_mday
-             << ' '
-             << setw(2) << data_->tm_time_.tm_hour  << ':'
-             << setw(2) << data_->tm_time_.tm_min   << ':'
-             << setw(2) << data_->tm_time_.tm_sec   << "."
-             << setw(6) << usecs
-             << ' '
-             << setfill(' ') << setw(5)
-             << static_cast<unsigned int>(GetTID()) << setfill('0')
-             << ' '
-             << data_->basename_ << ':' << data_->line_ << "] ";
-  }
-  data_->num_prefix_chars_ = data_->stream_->pcount();
-
-  if (!FLAGS_log_backtrace_at.empty()) {
-    char fileline[128];
-    snprintf(fileline, sizeof(fileline), "%s:%d", data_->basename_, line);
-#ifdef HAVE_STACKTRACE
-    if (!strcmp(FLAGS_log_backtrace_at.c_str(), fileline)) {
-      string stacktrace;
-      DumpStackTraceToString(&stacktrace);
-      stream() << " (stacktrace:\n" << stacktrace << ") ";
-    }
-#endif
-  }
-}
-
-LogMessage::~LogMessage() {
-  Flush();
-  delete allocated_;
-}
-
-int LogMessage::preserved_errno() const {
-  return data_->preserved_errno_;
-}
-
-ostream& LogMessage::stream() {
-  return *(data_->stream_);
-}
-
-// Flush buffered message, called by the destructor, or any other function
-// that needs to synchronize the log.
-void LogMessage::Flush() {
-  if (data_->has_been_flushed_ || data_->severity_ < FLAGS_minloglevel)
-    return;
-
-  data_->num_chars_to_log_ = data_->stream_->pcount();
-  data_->num_chars_to_syslog_ =
-    data_->num_chars_to_log_ - data_->num_prefix_chars_;
-
-  // Do we need to add a \n to the end of this message?
-  bool append_newline =
-      (data_->message_text_[data_->num_chars_to_log_-1] != '\n');
-  char original_final_char = '\0';
-
-  // If we do need to add a \n, we'll do it by violating the memory of the
-  // ostrstream buffer.  This is quick, and we'll make sure to undo our
-  // modification before anything else is done with the ostrstream.  It
-  // would be preferable not to do things this way, but it seems to be
-  // the best way to deal with this.
-  if (append_newline) {
-    original_final_char = data_->message_text_[data_->num_chars_to_log_];
-    data_->message_text_[data_->num_chars_to_log_++] = '\n';
-  }
-
-  // Prevent any subtle race conditions by wrapping a mutex lock around
-  // the actual logging action per se.
-  {
-    MutexLock l(&log_mutex);
-    (this->*(data_->send_method_))();
-    ++num_messages_[static_cast<int>(data_->severity_)];
-  }
-  LogDestination::WaitForSinks(data_);
-
-  if (append_newline) {
-    // Fix the ostrstream back how it was before we screwed with it.
-    // It's 99.44% certain that we don't need to worry about doing this.
-    data_->message_text_[data_->num_chars_to_log_-1] = original_final_char;
-  }
-
-  // If errno was already set before we enter the logging call, we'll
-  // set it back to that value when we return from the logging call.
-  // It happens often that we log an error message after a syscall
-  // failure, which can potentially set the errno to some other
-  // values.  We would like to preserve the original errno.
-  if (data_->preserved_errno_ != 0) {
-    errno = data_->preserved_errno_;
-  }
-
-  // Note that this message is now safely logged.  If we're asked to flush
-  // again, as a result of destruction, say, we'll do nothing on future calls.
-  data_->has_been_flushed_ = true;
-}
-
-// Copy of first FATAL log message so that we can print it out again
-// after all the stack traces.  To preserve legacy behavior, we don't
-// use fatal_msg_buf_exclusive.
-static time_t fatal_time;
-static char fatal_message[256];
-
-void ReprintFatalMessage() {
-  if (fatal_message[0]) {
-    const int n = strlen(fatal_message);
-    if (!FLAGS_logtostderr) {
-      // Also write to stderr (don't color to avoid terminal checks)
-      WriteToStderr(fatal_message, n);
-    }
-    LogDestination::LogToAllLogfiles(GLOG_ERROR, fatal_time, fatal_message, n);
-  }
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  static bool already_warned_before_initgoogle = false;
-
-  log_mutex.AssertHeld();
-
-  RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
-             data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
-
-  // Messages of a given severity get logged to lower severity logs, too
-
-  if (!already_warned_before_initgoogle && !IsGoogleLoggingInitialized()) {
-    const char w[] = "WARNING: Logging before InitGoogleLogging() is "
-                     "written to STDERR\n";
-    WriteToStderr(w, strlen(w));
-    already_warned_before_initgoogle = true;
-  }
-
-  // global flag: never log to file if set.  Also -- don't log to a
-  // file if we haven't parsed the command line flags to get the
-  // program name.
-  if (FLAGS_logtostderr || !IsGoogleLoggingInitialized()) {
-    ColoredWriteToStderr(data_->severity_,
-                         data_->message_text_, data_->num_chars_to_log_);
-
-    // this could be protected by a flag if necessary.
-    LogDestination::LogToSinks(data_->severity_,
-                               data_->fullname_, data_->basename_,
-                               data_->line_, &data_->tm_time_,
-                               data_->message_text_ + data_->num_prefix_chars_,
-                               (data_->num_chars_to_log_ -
-                                data_->num_prefix_chars_ - 1));
-  } else {
-
-    // log this message to all log files of severity <= severity_
-    LogDestination::LogToAllLogfiles(data_->severity_, data_->timestamp_,
-                                     data_->message_text_,
-                                     data_->num_chars_to_log_);
-
-    LogDestination::MaybeLogToStderr(data_->severity_, data_->message_text_,
-                                     data_->num_chars_to_log_);
-    LogDestination::MaybeLogToEmail(data_->severity_, data_->message_text_,
-                                    data_->num_chars_to_log_);
-    LogDestination::LogToSinks(data_->severity_,
-                               data_->fullname_, data_->basename_,
-                               data_->line_, &data_->tm_time_,
-                               data_->message_text_ + data_->num_prefix_chars_,
-                               (data_->num_chars_to_log_
-                                - data_->num_prefix_chars_ - 1));
-    // NOTE: -1 removes trailing \n
-  }
-
-  // If we log a FATAL message, flush all the log destinations, then toss
-  // a signal for others to catch. We leave the logs in a state that
-  // someone else can use them (as long as they flush afterwards)
-  if (data_->severity_ == GLOG_FATAL && exit_on_dfatal) {
-    if (data_->first_fatal_) {
-      // Store crash information so that it is accessible from within signal
-      // handlers that may be invoked later.
-      RecordCrashReason(&crash_reason);
-      SetCrashReason(&crash_reason);
-
-      // Store shortened fatal message for other logs and GWQ status
-      const int copy = min<int>(data_->num_chars_to_log_,
-                                sizeof(fatal_message)-1);
-      memcpy(fatal_message, data_->message_text_, copy);
-      fatal_message[copy] = '\0';
-      fatal_time = data_->timestamp_;
-    }
-
-    if (!FLAGS_logtostderr) {
-      for (int i = 0; i < NUM_SEVERITIES; ++i) {
-        if ( LogDestination::log_destinations_[i] )
-          LogDestination::log_destinations_[i]->logger_->Write(true, 0, "", 0);
-      }
-    }
-
-    // release the lock that our caller (directly or indirectly)
-    // LogMessage::~LogMessage() grabbed so that signal handlers
-    // can use the logging facility. Alternately, we could add
-    // an entire unsafe logging interface to bypass locking
-    // for signal handlers but this seems simpler.
-    log_mutex.Unlock();
-    LogDestination::WaitForSinks(data_);
-
-    const char* message = "*** Check failure stack trace: ***\n";
-    if (write(STDERR_FILENO, message, strlen(message)) < 0) {
-      // Ignore errors.
-    }
-    Fail();
-  }
-}
-
-void LogMessage::RecordCrashReason(
-    glog_internal_namespace_::CrashReason* reason) {
-  reason->filename = fatal_msg_data_exclusive.fullname_;
-  reason->line_number = fatal_msg_data_exclusive.line_;
-  reason->message = fatal_msg_buf_exclusive +
-                    fatal_msg_data_exclusive.num_prefix_chars_;
-#ifdef HAVE_STACKTRACE
-  // Retrieve the stack trace, omitting the logging frames that got us here.
-  reason->depth = GetStackTrace(reason->stack, ARRAYSIZE(reason->stack), 4);
-#else
-  reason->depth = 0;
-#endif
-}
-
-#ifdef HAVE___ATTRIBUTE__
-# define ATTRIBUTE_NORETURN __attribute__((noreturn))
-#else
-# define ATTRIBUTE_NORETURN
-#endif
-
-static void logging_fail() ATTRIBUTE_NORETURN;
-
-static void logging_fail() {
-#if defined(_DEBUG) && defined(_MSC_VER)
-  // When debugging on windows, avoid the obnoxious dialog and make
-  // it possible to continue past a LOG(FATAL) in the debugger
-  _asm int 3
-#else
-  abort();
-#endif
-}
-
-typedef void (*logging_fail_func_t)() ATTRIBUTE_NORETURN;
-
-GOOGLE_GLOG_DLL_DECL
-logging_fail_func_t g_logging_fail_func = &logging_fail;
-
-void InstallFailureFunction(void (*fail_func)()) {
-  g_logging_fail_func = (logging_fail_func_t)fail_func;
-}
-
-void LogMessage::Fail() {
-  g_logging_fail_func();
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SendToSink() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  if (data_->sink_ != NULL) {
-    RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
-               data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
-    data_->sink_->send(data_->severity_, data_->fullname_, data_->basename_,
-                       data_->line_, &data_->tm_time_,
-                       data_->message_text_ + data_->num_prefix_chars_,
-                       (data_->num_chars_to_log_ -
-                        data_->num_prefix_chars_ - 1));
-  }
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SendToSinkAndLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  SendToSink();
-  SendToLog();
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SaveOrSendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  if (data_->outvec_ != NULL) {
-    RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
-               data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
-    // Omit prefix of message and trailing newline when recording in outvec_.
-    const char *start = data_->message_text_ + data_->num_prefix_chars_;
-    int len = data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1;
-    data_->outvec_->push_back(string(start, len));
-  } else {
-    SendToLog();
-  }
-}
-
-void LogMessage::WriteToStringAndLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
-  if (data_->message_ != NULL) {
-    RAW_DCHECK(data_->num_chars_to_log_ > 0 &&
-               data_->message_text_[data_->num_chars_to_log_-1] == '\n', "");
-    // Omit prefix of message and trailing newline when writing to message_.
-    const char *start = data_->message_text_ + data_->num_prefix_chars_;
-    int len = data_->num_chars_to_log_ - data_->num_prefix_chars_ - 1;
-    data_->message_->assign(start, len);
-  }
-  SendToLog();
-}
-
-// L >= log_mutex (callers must hold the log_mutex).
-void LogMessage::SendToSyslogAndLog() {
-#ifdef HAVE_SYSLOG_H
-  // Before any calls to syslog(), make a single call to openlog()
-  static bool openlog_already_called = false;
-  if (!openlog_already_called) {
-    openlog(glog_internal_namespace_::ProgramInvocationShortName(),
-            LOG_CONS | LOG_NDELAY | LOG_PID,
-            LOG_USER);
-    openlog_already_called = true;
-  }
-
-  // This array maps Google severity levels to syslog levels
-  const int SEVERITY_TO_LEVEL[] = { LOG_INFO, LOG_WARNING, LOG_ERR, LOG_EMERG };
-  syslog(LOG_USER | SEVERITY_TO_LEVEL[static_cast<int>(data_->severity_)], "%.*s",
-         int(data_->num_chars_to_syslog_),
-         data_->message_text_ + data_->num_prefix_chars_);
-  SendToLog();
-#else
-  LOG(ERROR) << "No syslog support: message=" << data_->message_text_;
-#endif
-}
-
-base::Logger* base::GetLogger(LogSeverity severity) {
-  MutexLock l(&log_mutex);
-  return LogDestination::log_destination(severity)->logger_;
-}
-
-void base::SetLogger(LogSeverity severity, base::Logger* logger) {
-  MutexLock l(&log_mutex);
-  LogDestination::log_destination(severity)->logger_ = logger;
-}
-
-// L < log_mutex.  Acquires and releases mutex_.
-int64 LogMessage::num_messages(int severity) {
-  MutexLock l(&log_mutex);
-  return num_messages_[severity];
-}
-
-// Output the COUNTER value. This is only valid if ostream is a
-// LogStream.
-ostream& operator<<(ostream &os, const PRIVATE_Counter&) {
-#ifdef DISABLE_RTTI
-  LogMessage::LogStream *log = static_cast<LogMessage::LogStream*>(&os);
-#else
-  LogMessage::LogStream *log = dynamic_cast<LogMessage::LogStream*>(&os);
-#endif
-  CHECK(log && log == log->self())
-      << "You must not use COUNTER with non-glog ostream";
-  os << log->ctr();
-  return os;
-}
-
-ErrnoLogMessage::ErrnoLogMessage(const char* file, int line,
-                                 LogSeverity severity, int ctr,
-                                 void (LogMessage::*send_method)())
-    : LogMessage(file, line, severity, ctr, send_method) {
-}
-
-ErrnoLogMessage::~ErrnoLogMessage() {
-  // Don't access errno directly because it may have been altered
-  // while streaming the message.
-  char buf[100];
-  posix_strerror_r(preserved_errno(), buf, sizeof(buf));
-  stream() << ": " << buf << " [" << preserved_errno() << "]";
-}
-
-void FlushLogFiles(LogSeverity min_severity) {
-  LogDestination::FlushLogFiles(min_severity);
-}
-
-void FlushLogFilesUnsafe(LogSeverity min_severity) {
-  LogDestination::FlushLogFilesUnsafe(min_severity);
-}
-
-void SetLogDestination(LogSeverity severity, const char* base_filename) {
-  LogDestination::SetLogDestination(severity, base_filename);
-}
-
-void SetLogSymlink(LogSeverity severity, const char* symlink_basename) {
-  LogDestination::SetLogSymlink(severity, symlink_basename);
-}
-
-LogSink::~LogSink() {
-}
-
-void LogSink::WaitTillSent() {
-  // noop default
-}
-
-string LogSink::ToString(LogSeverity severity, const char* file, int line,
-                         const struct ::tm* tm_time,
-                         const char* message, size_t message_len) {
-  ostringstream stream(string(message, message_len));
-  stream.fill('0');
-
-  // FIXME(jrvb): Updating this to use the correct value for usecs
-  // requires changing the signature for both this method and
-  // LogSink::send().  This change needs to be done in a separate CL
-  // so subclasses of LogSink can be updated at the same time.
-  int usecs = 0;
-
-  stream << LogSeverityNames[severity][0]
-         << setw(2) << 1+tm_time->tm_mon
-         << setw(2) << tm_time->tm_mday
-         << ' '
-         << setw(2) << tm_time->tm_hour << ':'
-         << setw(2) << tm_time->tm_min << ':'
-         << setw(2) << tm_time->tm_sec << '.'
-         << setw(6) << usecs
-         << ' '
-         << setfill(' ') << setw(5) << GetTID() << setfill('0')
-         << ' '
-         << file << ':' << line << "] ";
-
-  stream << string(message, message_len);
-  return stream.str();
-}
-
-void AddLogSink(LogSink *destination) {
-  LogDestination::AddLogSink(destination);
-}
-
-void RemoveLogSink(LogSink *destination) {
-  LogDestination::RemoveLogSink(destination);
-}
-
-void SetLogFilenameExtension(const char* ext) {
-  LogDestination::SetLogFilenameExtension(ext);
-}
-
-void SetStderrLogging(LogSeverity min_severity) {
-  LogDestination::SetStderrLogging(min_severity);
-}
-
-void SetEmailLogging(LogSeverity min_severity, const char* addresses) {
-  LogDestination::SetEmailLogging(min_severity, addresses);
-}
-
-void LogToStderr() {
-  LogDestination::LogToStderr();
-}
-
-namespace base {
-namespace internal {
-
-bool GetExitOnDFatal() {
-  MutexLock l(&log_mutex);
-  return exit_on_dfatal;
-}
-
-// Determines whether we exit the program for a LOG(DFATAL) message in
-// debug mode.  It does this by skipping the call to Fail/FailQuietly.
-// This is intended for testing only.
-//
-// This can have some effects on LOG(FATAL) as well.  Failure messages
-// are always allocated (rather than sharing a buffer), the crash
-// reason is not recorded, the "gwq" status message is not updated,
-// and the stack trace is not recorded.  The LOG(FATAL) *will* still
-// exit the program.  Since this function is used only in testing,
-// these differences are acceptable.
-void SetExitOnDFatal(bool value) {
-  MutexLock l(&log_mutex);
-  exit_on_dfatal = value;
-}
-
-}  // namespace internal
-}  // namespace base
-
-// use_logging controls whether the logging functions LOG/VLOG are used
-// to log errors.  It should be set to false when the caller holds the
-// log_mutex.
-static bool SendEmailInternal(const char*dest, const char *subject,
-                              const char*body, bool use_logging) {
-  if (dest && *dest) {
-    if ( use_logging ) {
-      VLOG(1) << "Trying to send TITLE:" << subject
-              << " BODY:" << body << " to " << dest;
-    } else {
-      fprintf(stderr, "Trying to send TITLE: %s BODY: %s to %s\n",
-              subject, body, dest);
-    }
-
-    string cmd =
-        FLAGS_logmailer + " -s\"" + subject + "\" " + dest;
-    FILE* pipe = popen(cmd.c_str(), "w");
-    if (pipe != NULL) {
-      // Add the body if we have one
-      if (body)
-        fwrite(body, sizeof(char), strlen(body), pipe);
-      bool ok = pclose(pipe) != -1;
-      if ( !ok ) {
-        if ( use_logging ) {
-          char buf[100];
-          posix_strerror_r(errno, buf, sizeof(buf));
-          LOG(ERROR) << "Problems sending mail to " << dest << ": " << buf;
-        } else {
-          char buf[100];
-          posix_strerror_r(errno, buf, sizeof(buf));
-          fprintf(stderr, "Problems sending mail to %s: %s\n", dest, buf);
-        }
-      }
-      return ok;
-    } else {
-      if ( use_logging ) {
-        LOG(ERROR) << "Unable to send mail to " << dest;
-      } else {
-        fprintf(stderr, "Unable to send mail to %s\n", dest);
-      }
-    }
-  }
-  return false;
-}
-
-bool SendEmail(const char*dest, const char *subject, const char*body){
-  return SendEmailInternal(dest, subject, body, true);
-}
-
-static void GetTempDirectories(vector<string>* list) {
-  list->clear();
-#ifdef OS_WINDOWS
-  // On windows we'll try to find a directory in this order:
-  //   C:/Documents & Settings/whomever/TEMP (or whatever GetTempPath() is)
-  //   C:/TMP/
-  //   C:/TEMP/
-  //   C:/WINDOWS/ or C:/WINNT/
-  //   .
-  char tmp[MAX_PATH];
-  if (GetTempPathA(MAX_PATH, tmp))
-    list->push_back(tmp);
-  list->push_back("C:\\tmp\\");
-  list->push_back("C:\\temp\\");
-#else
-  // Directories, in order of preference. If we find a dir that
-  // exists, we stop adding other less-preferred dirs
-  const char * candidates[] = {
-    // Non-null only during unittest/regtest
-    getenv("TEST_TMPDIR"),
-
-    // Explicitly-supplied temp dirs
-    getenv("TMPDIR"), getenv("TMP"),
-
-    // If all else fails
-    "/tmp",
-  };
-
-  for (size_t i = 0; i < ARRAYSIZE(candidates); i++) {
-    const char *d = candidates[i];
-    if (!d) continue;  // Empty env var
-
-    // Make sure we don't surprise anyone who's expecting a '/'
-    string dstr = d;
-    if (dstr[dstr.size() - 1] != '/') {
-      dstr += "/";
-    }
-    list->push_back(dstr);
-
-    struct stat statbuf;
-    if (!stat(d, &statbuf) && S_ISDIR(statbuf.st_mode)) {
-      // We found a dir that exists - we're done.
-      return;
-    }
-  }
-
-#endif
-}
-
-static vector<string>* logging_directories_list;
-
-const vector<string>& GetLoggingDirectories() {
-  // Not strictly thread-safe but we're called early in InitGoogle().
-  if (logging_directories_list == NULL) {
-    logging_directories_list = new vector<string>;
-
-    if ( !FLAGS_log_dir.empty() ) {
-      // A dir was specified, we should use it
-      logging_directories_list->push_back(FLAGS_log_dir.c_str());
-    } else {
-      GetTempDirectories(logging_directories_list);
-#ifdef OS_WINDOWS
-      char tmp[MAX_PATH];
-      if (GetWindowsDirectoryA(tmp, MAX_PATH))
-        logging_directories_list->push_back(tmp);
-      logging_directories_list->push_back(".\\");
-#else
-      logging_directories_list->push_back("./");
-#endif
-    }
-  }
-  return *logging_directories_list;
-}
-
-void TestOnly_ClearLoggingDirectoriesList() {
-  fprintf(stderr, "TestOnly_ClearLoggingDirectoriesList should only be "
-          "called from test code.\n");
-  delete logging_directories_list;
-  logging_directories_list = NULL;
-}
-
-void GetExistingTempDirectories(vector<string>* list) {
-  GetTempDirectories(list);
-  vector<string>::iterator i_dir = list->begin();
-  while( i_dir != list->end() ) {
-    // zero arg to access means test for existence; no constant
-    // defined on windows
-    if ( access(i_dir->c_str(), 0) ) {
-      i_dir = list->erase(i_dir);
-    } else {
-      ++i_dir;
-    }
-  }
-}
-
-void TruncateLogFile(const char *path, int64 limit, int64 keep) {
-#ifdef HAVE_UNISTD_H
-  struct stat statbuf;
-  const int kCopyBlockSize = 8 << 10;
-  char copybuf[kCopyBlockSize];
-  int64 read_offset, write_offset;
-  // Don't follow symlinks unless they're our own fd symlinks in /proc
-  int flags = O_RDWR;
-  const char *procfd_prefix = "/proc/self/fd/";
-  if (strncmp(procfd_prefix, path, strlen(procfd_prefix))) flags |= O_NOFOLLOW;
-
-  int fd = open(path, flags);
-  if (fd == -1) {
-    if (errno == EFBIG) {
-      // The log file in question has got too big for us to open. The
-      // real fix for this would be to compile logging.cc (or probably
-      // all of base/...) with -D_FILE_OFFSET_BITS=64 but that's
-      // rather scary.
-      // Instead just truncate the file to something we can manage
-      if (truncate(path, 0) == -1) {
-        PLOG(ERROR) << "Unable to truncate " << path;
-      } else {
-        LOG(ERROR) << "Truncated " << path << " due to EFBIG error";
-      }
-    } else {
-      PLOG(ERROR) << "Unable to open " << path;
-    }
-    return;
-  }
-
-  if (fstat(fd, &statbuf) == -1) {
-    PLOG(ERROR) << "Unable to fstat()";
-    goto out_close_fd;
-  }
-
-  // See if the path refers to a regular file bigger than the
-  // specified limit
-  if (!S_ISREG(statbuf.st_mode)) goto out_close_fd;
-  if (statbuf.st_size <= limit)  goto out_close_fd;
-  if (statbuf.st_size <= keep) goto out_close_fd;
-
-  // This log file is too large - we need to truncate it
-  LOG(INFO) << "Truncating " << path << " to " << keep << " bytes";
-
-  // Copy the last "keep" bytes of the file to the beginning of the file
-  read_offset = statbuf.st_size - keep;
-  write_offset = 0;
-  int bytesin, bytesout;
-  while ((bytesin = pread(fd, copybuf, sizeof(copybuf), read_offset)) > 0) {
-    bytesout = pwrite(fd, copybuf, bytesin, write_offset);
-    if (bytesout == -1) {
-      PLOG(ERROR) << "Unable to write to " << path;
-      break;
-    } else if (bytesout != bytesin) {
-      LOG(ERROR) << "Expected to write " << bytesin << ", wrote " << bytesout;
-    }
-    read_offset += bytesin;
-    write_offset += bytesout;
-  }
-  if (bytesin == -1) PLOG(ERROR) << "Unable to read from " << path;
-
-  // Truncate the remainder of the file. If someone else writes to the
-  // end of the file after our last read() above, we lose their latest
-  // data. Too bad ...
-  if (ftruncate(fd, write_offset) == -1) {
-    PLOG(ERROR) << "Unable to truncate " << path;
-  }
-
- out_close_fd:
-  close(fd);
-#else
-  LOG(ERROR) << "No log truncation support.";
-#endif
-}
-
-void TruncateStdoutStderr() {
-#ifdef HAVE_UNISTD_H
-  int64 limit = MaxLogSize() << 20;
-  int64 keep = 1 << 20;
-  TruncateLogFile("/proc/self/fd/1", limit, keep);
-  TruncateLogFile("/proc/self/fd/2", limit, keep);
-#else
-  LOG(ERROR) << "No log truncation support.";
-#endif
-}
-
-
-// Helper functions for string comparisons.
-#define DEFINE_CHECK_STROP_IMPL(name, func, expected)                   \
-  string* Check##func##expected##Impl(const char* s1, const char* s2,   \
-                                      const char* names) {              \
-    bool equal = s1 == s2 || (s1 && s2 && !func(s1, s2));               \
-    if (equal == expected) return NULL;                                 \
-    else {                                                              \
-      ostringstream ss;                                                 \
-      if (!s1) s1 = "";                                                 \
-      if (!s2) s2 = "";                                                 \
-      ss << #name " failed: " << names << " (" << s1 << " vs. " << s2 << ")"; \
-      return new string(ss.str());                                      \
-    }                                                                   \
-  }
-DEFINE_CHECK_STROP_IMPL(CHECK_STREQ, strcmp, true)
-DEFINE_CHECK_STROP_IMPL(CHECK_STRNE, strcmp, false)
-DEFINE_CHECK_STROP_IMPL(CHECK_STRCASEEQ, strcasecmp, true)
-DEFINE_CHECK_STROP_IMPL(CHECK_STRCASENE, strcasecmp, false)
-#undef DEFINE_CHECK_STROP_IMPL
-
-int posix_strerror_r(int err, char *buf, size_t len) {
-  // Sanity check input parameters
-  if (buf == NULL || len <= 0) {
-    errno = EINVAL;
-    return -1;
-  }
-
-  // Reset buf and errno, and try calling whatever version of strerror_r()
-  // is implemented by glibc
-  buf[0] = '\000';
-  int old_errno = errno;
-  errno = 0;
-  char *rc = reinterpret_cast<char *>(strerror_r(err, buf, len));
-
-  // Both versions set errno on failure
-  if (errno) {
-    // Should already be there, but better safe than sorry
-    buf[0]     = '\000';
-    return -1;
-  }
-  errno = old_errno;
-
-  // POSIX is vague about whether the string will be terminated, although
-  // is indirectly implies that typically ERANGE will be returned, instead
-  // of truncating the string. This is different from the GNU implementation.
-  // We play it safe by always terminating the string explicitly.
-  buf[len-1] = '\000';
-
-  // If the function succeeded, we can use its exit code to determine the
-  // semantics implemented by glibc
-  if (!rc) {
-    return 0;
-  } else {
-    // GNU semantics detected
-    if (rc == buf) {
-      return 0;
-    } else {
-      buf[0] = '\000';
-#if defined(OS_MACOSX) || defined(OS_FREEBSD) || defined(OS_OPENBSD)
-      if (reinterpret_cast<intptr_t>(rc) < sys_nerr) {
-        // This means an error on MacOSX or FreeBSD.
-        return -1;
-      }
-#endif
-      strncat(buf, rc, len-1);
-      return 0;
-    }
-  }
-}
-
-LogMessageFatal::LogMessageFatal(const char* file, int line) :
-    LogMessage(file, line, GLOG_FATAL) {}
-
-LogMessageFatal::LogMessageFatal(const char* file, int line,
-                                 const CheckOpString& result) :
-    LogMessage(file, line, result) {}
-
-LogMessageFatal::~LogMessageFatal() {
-    Flush();
-    LogMessage::Fail();
-}
-
-namespace base {
-
-CheckOpMessageBuilder::CheckOpMessageBuilder(const char *exprtext)
-    : stream_(new ostringstream) {
-  *stream_ << exprtext << " (";
-}
-
-CheckOpMessageBuilder::~CheckOpMessageBuilder() {
-  delete stream_;
-}
-
-ostream* CheckOpMessageBuilder::ForVar2() {
-  *stream_ << " vs. ";
-  return stream_;
-}
-
-string* CheckOpMessageBuilder::NewString() {
-  *stream_ << ")";
-  return new string(stream_->str());
-}
-
-}  // namespace base
-
-template <>
-void MakeCheckOpValueString(std::ostream* os, const char& v) {
-  if (v >= 32 && v <= 126) {
-    (*os) << "'" << v << "'";
-  } else {
-    (*os) << "char value " << (short)v;
-  }
-}
-
-template <>
-void MakeCheckOpValueString(std::ostream* os, const signed char& v) {
-  if (v >= 32 && v <= 126) {
-    (*os) << "'" << v << "'";
-  } else {
-    (*os) << "signed char value " << (short)v;
-  }
-}
-
-template <>
-void MakeCheckOpValueString(std::ostream* os, const unsigned char& v) {
-  if (v >= 32 && v <= 126) {
-    (*os) << "'" << v << "'";
-  } else {
-    (*os) << "unsigned char value " << (unsigned short)v;
-  }
-}
-
-void InitGoogleLogging(const char* argv0) {
-  glog_internal_namespace_::InitGoogleLoggingUtilities(argv0);
-}
-
-void ShutdownGoogleLogging() {
-  glog_internal_namespace_::ShutdownGoogleLoggingUtilities();
-  LogDestination::DeleteLogDestinations();
-  delete logging_directories_list;
-  logging_directories_list = NULL;
-}
-
-_END_GOOGLE_NAMESPACE_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/logging_striplog_test.sh
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/logging_striplog_test.sh b/third_party/src/glog/src/logging_striplog_test.sh
deleted file mode 100644
index 73492bd..0000000
--- a/third_party/src/glog/src/logging_striplog_test.sh
+++ /dev/null
@@ -1,79 +0,0 @@
-#! /bin/sh
-#
-# Copyright (c) 2007, Google Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# Author: Sergey Ioffe
-
-get_strings () {
-    if test -e ".libs/$1"; then
-        binary=".libs/$1"
-    elif test -e "$1.exe"; then
-        binary="$1.exe"
-    else
-        echo "We coundn't find $1 binary."
-        exit 1
-    fi
-    
-    strings -n 10 $binary | sort | awk '/TESTMESSAGE/ {printf "%s ", $2}'
-}
-
-# Die if "$1" != "$2", print $3 as death reason
-check_eq () {
-    if [ "$1" != "$2" ]; then
-        echo "Check failed: '$1' == '$2' ${3:+ ($3)}"
-        exit 1
-    fi
-}
-
-die () {
-    echo $1
-    exit 1
-}
-
-# Check that the string literals are appropriately stripped. This will
-# not be the case in debug mode.
-
-mode=`GLOG_check_mode=1 ./logging_striptest0 2> /dev/null`
-if [ "$mode" = "opt" ];
-then
-    echo "In OPT mode"
-    check_eq "`get_strings logging_striptest0`" "COND ERROR FATAL INFO USAGE WARNING "
-    check_eq "`get_strings logging_striptest2`" "COND ERROR FATAL USAGE "
-    check_eq "`get_strings logging_striptest10`" "" 
-else
-    echo "In DBG mode; not checking strings"
-fi
-
-# Check that LOG(FATAL) aborts even for large STRIP_LOG
-
-./logging_striptest2 2>/dev/null && die "Did not abort for STRIP_LOG=2"
-./logging_striptest10 2>/dev/null && die "Did not abort for STRIP_LOG=10"
-
-echo "PASS"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/logging_striptest10.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/logging_striptest10.cc b/third_party/src/glog/src/logging_striptest10.cc
deleted file mode 100644
index f6e1078..0000000
--- a/third_party/src/glog/src/logging_striptest10.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Sergey Ioffe
-
-#define GOOGLE_STRIP_LOG 10
-
-// Include the actual test.
-#include "logging_striptest_main.cc"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/logging_striptest2.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/logging_striptest2.cc b/third_party/src/glog/src/logging_striptest2.cc
deleted file mode 100644
index a64685c..0000000
--- a/third_party/src/glog/src/logging_striptest2.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Sergey Ioffe
-
-#define GOOGLE_STRIP_LOG 2
-
-// Include the actual test.
-#include "logging_striptest_main.cc"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/logging_striptest_main.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/logging_striptest_main.cc b/third_party/src/glog/src/logging_striptest_main.cc
deleted file mode 100644
index 2fb9127..0000000
--- a/third_party/src/glog/src/logging_striptest_main.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Sergey Ioffe
-
-// The common part of the striplog tests.
-
-#include <stdio.h>
-#include <string>
-#include <iosfwd>
-#include "glog/logging.h"
-#include "base/commandlineflags.h"
-#include "config.h"
-
-DECLARE_bool(logtostderr);
-GLOG_DEFINE_bool(check_mode, false, "Prints 'opt' or 'dbg'");
-
-using std::string;
-using namespace GOOGLE_NAMESPACE;
-
-int CheckNoReturn(bool b) {
-  string s;
-  if (b) {
-    LOG(FATAL) << "Fatal";
-  } else {
-    return 0;
-  }
-}
-
-struct A { };
-std::ostream &operator<<(std::ostream &str, const A&) {return str;}
-
-int main(int, char* argv[]) {
-  FLAGS_logtostderr = true;
-  InitGoogleLogging(argv[0]);
-  if (FLAGS_check_mode) {
-    printf("%s\n", DEBUG_MODE ? "dbg" : "opt");
-    return 0;
-  }
-  LOG(INFO) << "TESTMESSAGE INFO";
-  LOG(WARNING) << 2 << "something" << "TESTMESSAGE WARNING"
-               << 1 << 'c' << A() << std::endl;
-  LOG(ERROR) << "TESTMESSAGE ERROR";
-  bool flag = true;
-  (flag ? LOG(INFO) : LOG(ERROR)) << "TESTMESSAGE COND";
-  LOG(FATAL) << "TESTMESSAGE FATAL";
-}


[32/46] incubator-quickstep git commit: Remove glog source code from third party

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/logging_unittest.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/logging_unittest.cc b/third_party/src/glog/src/logging_unittest.cc
deleted file mode 100644
index d7e95cf..0000000
--- a/third_party/src/glog/src/logging_unittest.cc
+++ /dev/null
@@ -1,1215 +0,0 @@
-// Copyright (c) 2002, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney
-
-#include "config_for_unittests.h"
-#include "utilities.h"
-
-#include <fcntl.h>
-#ifdef HAVE_GLOB_H
-# include <glob.h>
-#endif
-#include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#include <iomanip>
-#include <iostream>
-#include <memory>
-#include <queue>
-#include <sstream>
-#include <string>
-#include <vector>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "base/commandlineflags.h"
-#include "glog/logging.h"
-#include "glog/raw_logging.h"
-#include "googletest.h"
-
-DECLARE_string(log_backtrace_at);  // logging.cc
-
-#ifdef HAVE_LIB_GFLAGS
-#include <gflags/gflags.h>
-#endif
-
-#ifdef HAVE_LIB_GMOCK
-#include <gmock/gmock.h>
-#include "mock-log.h"
-// Introduce several symbols from gmock.
-using testing::_;
-using testing::AnyNumber;
-using testing::HasSubstr;
-using testing::AllOf;
-using testing::StrNe;
-using testing::StrictMock;
-using testing::InitGoogleMock;
-using GOOGLE_NAMESPACE::glog_testing::ScopedMockLog;
-#endif
-
-using namespace std;
-using namespace GOOGLE_NAMESPACE;
-
-// Some non-advertised functions that we want to test or use.
-_START_GOOGLE_NAMESPACE_
-namespace base {
-namespace internal {
-bool GetExitOnDFatal();
-void SetExitOnDFatal(bool value);
-}  // namespace internal
-}  // namespace base
-_END_GOOGLE_NAMESPACE_
-
-static void TestLogging(bool check_counts);
-static void TestRawLogging();
-static void LogWithLevels(int v, int severity, bool err, bool alsoerr);
-static void TestLoggingLevels();
-static void TestLogString();
-static void TestLogSink();
-static void TestLogToString();
-static void TestLogSinkWaitTillSent();
-static void TestCHECK();
-static void TestDCHECK();
-static void TestSTREQ();
-static void TestBasename();
-static void TestSymlink();
-static void TestExtension();
-static void TestWrapper();
-static void TestErrno();
-static void TestTruncate();
-
-static int x = -1;
-static void BM_Check1(int n) {
-  while (n-- > 0) {
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-    CHECK_GE(n, x);
-  }
-}
-BENCHMARK(BM_Check1);
-
-static void CheckFailure(int a, int b, const char* file, int line, const char* msg);
-static void BM_Check3(int n) {
-  while (n-- > 0) {
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-    if (n < x) CheckFailure(n, x, __FILE__, __LINE__, "n < x");
-  }
-}
-BENCHMARK(BM_Check3);
-
-static void BM_Check2(int n) {
-  if (n == 17) {
-    x = 5;
-  }
-  while (n-- > 0) {
-    CHECK(n >= x);
-    CHECK(n >= x);
-    CHECK(n >= x);
-    CHECK(n >= x);
-    CHECK(n >= x);
-    CHECK(n >= x);
-    CHECK(n >= x);
-    CHECK(n >= x);
-  }
-}
-BENCHMARK(BM_Check2);
-
-static void CheckFailure(int, int, const char* /* file */, int /* line */,
-                         const char* /* msg */) {
-}
-
-static void BM_logspeed(int n) {
-  while (n-- > 0) {
-    LOG(INFO) << "test message";
-  }
-}
-BENCHMARK(BM_logspeed);
-
-static void BM_vlog(int n) {
-  while (n-- > 0) {
-    VLOG(1) << "test message";
-  }
-}
-BENCHMARK(BM_vlog);
-
-int main(int argc, char **argv) {
-  FLAGS_colorlogtostderr = false;
-#ifdef HAVE_LIB_GFLAGS
-  ParseCommandLineFlags(&argc, &argv, true);
-#endif
-  // Make sure stderr is not buffered as stderr seems to be buffered
-  // on recent windows.
-  setbuf(stderr, NULL);
-
-  // Test some basics before InitGoogleLogging:
-  CaptureTestStderr();
-  LogWithLevels(FLAGS_v, FLAGS_stderrthreshold,
-                FLAGS_logtostderr, FLAGS_alsologtostderr);
-  LogWithLevels(0, 0, 0, 0);  // simulate "before global c-tors"
-  const string early_stderr = GetCapturedTestStderr();
-
-  InitGoogleLogging(argv[0]);
-
-  RunSpecifiedBenchmarks();
-
-  FLAGS_logtostderr = true;
-
-  InitGoogleTest(&argc, argv);
-#ifdef HAVE_LIB_GMOCK
-  InitGoogleMock(&argc, argv);
-#endif
-
-  // so that death tests run before we use threads
-  CHECK_EQ(RUN_ALL_TESTS(), 0);
-
-  CaptureTestStderr();
-
-  // re-emit early_stderr
-  LogMessage("dummy", LogMessage::kNoLogPrefix, GLOG_INFO).stream() << early_stderr;
-
-  TestLogging(true);
-  TestRawLogging();
-  TestLoggingLevels();
-  TestLogString();
-  TestLogSink();
-  TestLogToString();
-  TestLogSinkWaitTillSent();
-  TestCHECK();
-  TestDCHECK();
-  TestSTREQ();
-
-  // TODO: The golden test portion of this test is very flakey.
-  EXPECT_TRUE(
-      MungeAndDiffTestStderr(FLAGS_test_srcdir + "/src/logging_unittest.err"));
-
-  FLAGS_logtostderr = false;
-
-  TestBasename();
-  TestSymlink();
-  TestExtension();
-  TestWrapper();
-  TestErrno();
-  TestTruncate();
-
-  ShutdownGoogleLogging();
-
-  fprintf(stdout, "PASS\n");
-  return 0;
-}
-
-void TestLogging(bool check_counts) {
-  int64 base_num_infos   = LogMessage::num_messages(GLOG_INFO);
-  int64 base_num_warning = LogMessage::num_messages(GLOG_WARNING);
-  int64 base_num_errors  = LogMessage::num_messages(GLOG_ERROR);
-
-  LOG(INFO) << string("foo ") << "bar " << 10 << ' ' << 3.4;
-  for ( int i = 0; i < 10; ++i ) {
-    int old_errno = errno;
-    errno = i;
-    PLOG_EVERY_N(ERROR, 2) << "Plog every 2, iteration " << COUNTER;
-    errno = old_errno;
-
-    LOG_EVERY_N(ERROR, 3) << "Log every 3, iteration " << COUNTER << endl;
-    LOG_EVERY_N(ERROR, 4) << "Log every 4, iteration " << COUNTER << endl;
-
-    LOG_IF_EVERY_N(WARNING, true, 5) << "Log if every 5, iteration " << COUNTER;
-    LOG_IF_EVERY_N(WARNING, false, 3)
-        << "Log if every 3, iteration " << COUNTER;
-    LOG_IF_EVERY_N(INFO, true, 1) << "Log if every 1, iteration " << COUNTER;
-    LOG_IF_EVERY_N(ERROR, (i < 3), 2)
-        << "Log if less than 3 every 2, iteration " << COUNTER;
-  }
-  LOG_IF(WARNING, true) << "log_if this";
-  LOG_IF(WARNING, false) << "don't log_if this";
-
-  char s[] = "array";
-  LOG(INFO) << s;
-  const char const_s[] = "const array";
-  LOG(INFO) << const_s;
-  int j = 1000;
-  LOG(ERROR) << string("foo") << ' '<< j << ' ' << setw(10) << j << " "
-             << setw(1) << hex << j;
-
-  LogMessage("foo", LogMessage::kNoLogPrefix, GLOG_INFO).stream() << "no prefix";
-
-  if (check_counts) {
-    CHECK_EQ(base_num_infos   + 14, LogMessage::num_messages(GLOG_INFO));
-    CHECK_EQ(base_num_warning + 3,  LogMessage::num_messages(GLOG_WARNING));
-    CHECK_EQ(base_num_errors  + 15, LogMessage::num_messages(GLOG_ERROR));
-  }
-}
-
-static void NoAllocNewHook() {
-  CHECK(false) << "unexpected new";
-}
-
-struct NewHook {
-  NewHook() {
-    g_new_hook = &NoAllocNewHook;
-  }
-  ~NewHook() {
-    g_new_hook = NULL;
-  }
-};
-
-TEST(DeathNoAllocNewHook, logging) {
-  // tests that NewHook used below works
-  NewHook new_hook;
-  ASSERT_DEATH({
-    new int;
-  }, "unexpected new");
-}
-
-void TestRawLogging() {
-  string* foo = new string("foo ");
-  string huge_str(50000, 'a');
-
-  FlagSaver saver;
-
-  // Check that RAW loggging does not use mallocs.
-  NewHook new_hook;
-
-  RAW_LOG(INFO, "%s%s%d%c%f", foo->c_str(), "bar ", 10, ' ', 3.4);
-  char s[] = "array";
-  RAW_LOG(WARNING, "%s", s);
-  const char const_s[] = "const array";
-  RAW_LOG(INFO, "%s", const_s);
-  void* p = reinterpret_cast<void*>(0x12345678);
-  RAW_LOG(INFO, "ptr %p", p);
-  p = NULL;
-  RAW_LOG(INFO, "ptr %p", p);
-  int j = 1000;
-  RAW_LOG(ERROR, "%s%d%c%010d%s%1x", foo->c_str(), j, ' ', j, " ", j);
-  RAW_VLOG(0, "foo %d", j);
-
-#ifdef NDEBUG
-  RAW_LOG(INFO, "foo %d", j);  // so that have same stderr to compare
-#else
-  RAW_DLOG(INFO, "foo %d", j);  // test RAW_DLOG in debug mode
-#endif
-
-  // test how long messages are chopped:
-  RAW_LOG(WARNING, "Huge string: %s", huge_str.c_str());
-  RAW_VLOG(0, "Huge string: %s", huge_str.c_str());
-
-  FLAGS_v = 0;
-  RAW_LOG(INFO, "log");
-  RAW_VLOG(0, "vlog 0 on");
-  RAW_VLOG(1, "vlog 1 off");
-  RAW_VLOG(2, "vlog 2 off");
-  RAW_VLOG(3, "vlog 3 off");
-  FLAGS_v = 2;
-  RAW_LOG(INFO, "log");
-  RAW_VLOG(1, "vlog 1 on");
-  RAW_VLOG(2, "vlog 2 on");
-  RAW_VLOG(3, "vlog 3 off");
-
-#ifdef NDEBUG
-  RAW_DCHECK(1 == 2, " RAW_DCHECK's shouldn't be compiled in normal mode");
-#endif
-
-  RAW_CHECK(1 == 1, "should be ok");
-  RAW_DCHECK(true, "should be ok");
-
-  delete foo;
-}
-
-void LogWithLevels(int v, int severity, bool err, bool alsoerr) {
-  RAW_LOG(INFO,
-          "Test: v=%d stderrthreshold=%d logtostderr=%d alsologtostderr=%d",
-          v, severity, err, alsoerr);
-
-  FlagSaver saver;
-
-  FLAGS_v = v;
-  FLAGS_stderrthreshold = severity;
-  FLAGS_logtostderr = err;
-  FLAGS_alsologtostderr = alsoerr;
-
-  RAW_VLOG(-1, "vlog -1");
-  RAW_VLOG(0, "vlog 0");
-  RAW_VLOG(1, "vlog 1");
-  RAW_LOG(INFO, "log info");
-  RAW_LOG(WARNING, "log warning");
-  RAW_LOG(ERROR, "log error");
-
-  VLOG(-1) << "vlog -1";
-  VLOG(0) << "vlog 0";
-  VLOG(1) << "vlog 1";
-  LOG(INFO) << "log info";
-  LOG(WARNING) << "log warning";
-  LOG(ERROR) << "log error";
-
-  VLOG_IF(-1, true) << "vlog_if -1";
-  VLOG_IF(-1, false) << "don't vlog_if -1";
-  VLOG_IF(0, true) << "vlog_if 0";
-  VLOG_IF(0, false) << "don't vlog_if 0";
-  VLOG_IF(1, true) << "vlog_if 1";
-  VLOG_IF(1, false) << "don't vlog_if 1";
-  LOG_IF(INFO, true) << "log_if info";
-  LOG_IF(INFO, false) << "don't log_if info";
-  LOG_IF(WARNING, true) << "log_if warning";
-  LOG_IF(WARNING, false) << "don't log_if warning";
-  LOG_IF(ERROR, true) << "log_if error";
-  LOG_IF(ERROR, false) << "don't log_if error";
-
-  int c;
-  c = 1; VLOG_IF(100, c -= 2) << "vlog_if 100 expr"; EXPECT_EQ(c, -1);
-  c = 1; VLOG_IF(0, c -= 2) << "vlog_if 0 expr"; EXPECT_EQ(c, -1);
-  c = 1; LOG_IF(INFO, c -= 2) << "log_if info expr"; EXPECT_EQ(c, -1);
-  c = 1; LOG_IF(ERROR, c -= 2) << "log_if error expr"; EXPECT_EQ(c, -1);
-  c = 2; VLOG_IF(0, c -= 2) << "don't vlog_if 0 expr"; EXPECT_EQ(c, 0);
-  c = 2; LOG_IF(ERROR, c -= 2) << "don't log_if error expr"; EXPECT_EQ(c, 0);
-
-  c = 3; LOG_IF_EVERY_N(INFO, c -= 4, 1) << "log_if info every 1 expr";
-  EXPECT_EQ(c, -1);
-  c = 3; LOG_IF_EVERY_N(ERROR, c -= 4, 1) << "log_if error every 1 expr";
-  EXPECT_EQ(c, -1);
-  c = 4; LOG_IF_EVERY_N(ERROR, c -= 4, 3) << "don't log_if info every 3 expr";
-  EXPECT_EQ(c, 0);
-  c = 4; LOG_IF_EVERY_N(ERROR, c -= 4, 3) << "don't log_if error every 3 expr";
-  EXPECT_EQ(c, 0);
-  c = 5; VLOG_IF_EVERY_N(0, c -= 4, 1) << "vlog_if 0 every 1 expr";
-  EXPECT_EQ(c, 1);
-  c = 5; VLOG_IF_EVERY_N(100, c -= 4, 3) << "vlog_if 100 every 3 expr";
-  EXPECT_EQ(c, 1);
-  c = 6; VLOG_IF_EVERY_N(0, c -= 6, 1) << "don't vlog_if 0 every 1 expr";
-  EXPECT_EQ(c, 0);
-  c = 6; VLOG_IF_EVERY_N(100, c -= 6, 3) << "don't vlog_if 100 every 1 expr";
-  EXPECT_EQ(c, 0);
-}
-
-void TestLoggingLevels() {
-  LogWithLevels(0, GLOG_INFO, false, false);
-  LogWithLevels(1, GLOG_INFO, false, false);
-  LogWithLevels(-1, GLOG_INFO, false, false);
-  LogWithLevels(0, GLOG_WARNING, false, false);
-  LogWithLevels(0, GLOG_ERROR, false, false);
-  LogWithLevels(0, GLOG_FATAL, false, false);
-  LogWithLevels(0, GLOG_FATAL, true, false);
-  LogWithLevels(0, GLOG_FATAL, false, true);
-  LogWithLevels(1, GLOG_WARNING, false, false);
-  LogWithLevels(1, GLOG_FATAL, false, true);
-}
-
-TEST(DeathRawCHECK, logging) {
-  ASSERT_DEATH(RAW_CHECK(false, "failure 1"),
-               "RAW: Check false failed: failure 1");
-  ASSERT_DEBUG_DEATH(RAW_DCHECK(1 == 2, "failure 2"),
-               "RAW: Check 1 == 2 failed: failure 2");
-}
-
-void TestLogString() {
-  vector<string> errors;
-  vector<string> *no_errors = NULL;
-
-  LOG_STRING(INFO, &errors) << "LOG_STRING: " << "collected info";
-  LOG_STRING(WARNING, &errors) << "LOG_STRING: " << "collected warning";
-  LOG_STRING(ERROR, &errors) << "LOG_STRING: " << "collected error";
-
-  LOG_STRING(INFO, no_errors) << "LOG_STRING: " << "reported info";
-  LOG_STRING(WARNING, no_errors) << "LOG_STRING: " << "reported warning";
-  LOG_STRING(ERROR, NULL) << "LOG_STRING: " << "reported error";
-
-  for (size_t i = 0; i < errors.size(); ++i) {
-    LOG(INFO) << "Captured by LOG_STRING:  " << errors[i];
-  }
-}
-
-void TestLogToString() {
-  string error;
-  string* no_error = NULL;
-
-  LOG_TO_STRING(INFO, &error) << "LOG_TO_STRING: " << "collected info";
-  LOG(INFO) << "Captured by LOG_TO_STRING:  " << error;
-  LOG_TO_STRING(WARNING, &error) << "LOG_TO_STRING: " << "collected warning";
-  LOG(INFO) << "Captured by LOG_TO_STRING:  " << error;
-  LOG_TO_STRING(ERROR, &error) << "LOG_TO_STRING: " << "collected error";
-  LOG(INFO) << "Captured by LOG_TO_STRING:  " << error;
-
-  LOG_TO_STRING(INFO, no_error) << "LOG_TO_STRING: " << "reported info";
-  LOG_TO_STRING(WARNING, no_error) << "LOG_TO_STRING: " << "reported warning";
-  LOG_TO_STRING(ERROR, NULL) << "LOG_TO_STRING: " << "reported error";
-}
-
-class TestLogSinkImpl : public LogSink {
- public:
-  vector<string> errors;
-  virtual void send(LogSeverity severity, const char* /* full_filename */,
-                    const char* base_filename, int line,
-                    const struct tm* tm_time,
-                    const char* message, size_t message_len) {
-    errors.push_back(
-      ToString(severity, base_filename, line, tm_time, message, message_len));
-  }
-};
-
-void TestLogSink() {
-  TestLogSinkImpl sink;
-  LogSink *no_sink = NULL;
-
-  LOG_TO_SINK(&sink, INFO) << "LOG_TO_SINK: " << "collected info";
-  LOG_TO_SINK(&sink, WARNING) << "LOG_TO_SINK: " << "collected warning";
-  LOG_TO_SINK(&sink, ERROR) << "LOG_TO_SINK: " << "collected error";
-
-  LOG_TO_SINK(no_sink, INFO) << "LOG_TO_SINK: " << "reported info";
-  LOG_TO_SINK(no_sink, WARNING) << "LOG_TO_SINK: " << "reported warning";
-  LOG_TO_SINK(NULL, ERROR) << "LOG_TO_SINK: " << "reported error";
-
-  LOG_TO_SINK_BUT_NOT_TO_LOGFILE(&sink, INFO)
-      << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "collected info";
-  LOG_TO_SINK_BUT_NOT_TO_LOGFILE(&sink, WARNING)
-      << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "collected warning";
-  LOG_TO_SINK_BUT_NOT_TO_LOGFILE(&sink, ERROR)
-      << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "collected error";
-
-  LOG_TO_SINK_BUT_NOT_TO_LOGFILE(no_sink, INFO)
-      << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "thrashed info";
-  LOG_TO_SINK_BUT_NOT_TO_LOGFILE(no_sink, WARNING)
-      << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "thrashed warning";
-  LOG_TO_SINK_BUT_NOT_TO_LOGFILE(NULL, ERROR)
-      << "LOG_TO_SINK_BUT_NOT_TO_LOGFILE: " << "thrashed error";
-
-  LOG(INFO) << "Captured by LOG_TO_SINK:";
-  for (size_t i = 0; i < sink.errors.size(); ++i) {
-    LogMessage("foo", LogMessage::kNoLogPrefix, GLOG_INFO).stream()
-      << sink.errors[i];
-  }
-}
-
-// For testing using CHECK*() on anonymous enums.
-enum {
-  CASE_A,
-  CASE_B
-};
-
-void TestCHECK() {
-  // Tests using CHECK*() on int values.
-  CHECK(1 == 1);
-  CHECK_EQ(1, 1);
-  CHECK_NE(1, 2);
-  CHECK_GE(1, 1);
-  CHECK_GE(2, 1);
-  CHECK_LE(1, 1);
-  CHECK_LE(1, 2);
-  CHECK_GT(2, 1);
-  CHECK_LT(1, 2);
-
-  // Tests using CHECK*() on anonymous enums.
-  // Apple's GCC doesn't like this.
-#if !defined(OS_MACOSX)
-  CHECK_EQ(CASE_A, CASE_A);
-  CHECK_NE(CASE_A, CASE_B);
-  CHECK_GE(CASE_A, CASE_A);
-  CHECK_GE(CASE_B, CASE_A);
-  CHECK_LE(CASE_A, CASE_A);
-  CHECK_LE(CASE_A, CASE_B);
-  CHECK_GT(CASE_B, CASE_A);
-  CHECK_LT(CASE_A, CASE_B);
-#endif
-}
-
-void TestDCHECK() {
-#ifdef NDEBUG
-  DCHECK( 1 == 2 ) << " DCHECK's shouldn't be compiled in normal mode";
-#endif
-  DCHECK( 1 == 1 );
-  DCHECK_EQ(1, 1);
-  DCHECK_NE(1, 2);
-  DCHECK_GE(1, 1);
-  DCHECK_GE(2, 1);
-  DCHECK_LE(1, 1);
-  DCHECK_LE(1, 2);
-  DCHECK_GT(2, 1);
-  DCHECK_LT(1, 2);
-
-  auto_ptr<int64> sptr(new int64);
-  int64* ptr = DCHECK_NOTNULL(sptr.get());
-  CHECK_EQ(ptr, sptr.get());
-}
-
-void TestSTREQ() {
-  CHECK_STREQ("this", "this");
-  CHECK_STREQ(NULL, NULL);
-  CHECK_STRCASEEQ("this", "tHiS");
-  CHECK_STRCASEEQ(NULL, NULL);
-  CHECK_STRNE("this", "tHiS");
-  CHECK_STRNE("this", NULL);
-  CHECK_STRCASENE("this", "that");
-  CHECK_STRCASENE(NULL, "that");
-  CHECK_STREQ((string("a")+"b").c_str(), "ab");
-  CHECK_STREQ(string("test").c_str(),
-              (string("te") + string("st")).c_str());
-}
-
-TEST(DeathSTREQ, logging) {
-  ASSERT_DEATH(CHECK_STREQ(NULL, "this"), "");
-  ASSERT_DEATH(CHECK_STREQ("this", "siht"), "");
-  ASSERT_DEATH(CHECK_STRCASEEQ(NULL, "siht"), "");
-  ASSERT_DEATH(CHECK_STRCASEEQ("this", "siht"), "");
-  ASSERT_DEATH(CHECK_STRNE(NULL, NULL), "");
-  ASSERT_DEATH(CHECK_STRNE("this", "this"), "");
-  ASSERT_DEATH(CHECK_STREQ((string("a")+"b").c_str(), "abc"), "");
-}
-
-TEST(CheckNOTNULL, Simple) {
-  int64 t;
-  void *ptr = static_cast<void *>(&t);
-  void *ref = CHECK_NOTNULL(ptr);
-  EXPECT_EQ(ptr, ref);
-  CHECK_NOTNULL(reinterpret_cast<char *>(ptr));
-  CHECK_NOTNULL(reinterpret_cast<unsigned char *>(ptr));
-  CHECK_NOTNULL(reinterpret_cast<int *>(ptr));
-  CHECK_NOTNULL(reinterpret_cast<int64 *>(ptr));
-}
-
-TEST(DeathCheckNN, Simple) {
-  ASSERT_DEATH(CHECK_NOTNULL(static_cast<void *>(NULL)), "");
-}
-
-// Get list of file names that match pattern
-static void GetFiles(const string& pattern, vector<string>* files) {
-  files->clear();
-#if defined(HAVE_GLOB_H)
-  glob_t g;
-  const int r = glob(pattern.c_str(), 0, NULL, &g);
-  CHECK((r == 0) || (r == GLOB_NOMATCH)) << ": error matching " << pattern;
-  for (size_t i = 0; i < g.gl_pathc; i++) {
-    files->push_back(string(g.gl_pathv[i]));
-  }
-  globfree(&g);
-#elif defined(OS_WINDOWS)
-  WIN32_FIND_DATAA data;
-  HANDLE handle = FindFirstFileA(pattern.c_str(), &data);
-  size_t index = pattern.rfind('\\');
-  if (index == string::npos) {
-    LOG(FATAL) << "No directory separator.";
-  }
-  const string dirname = pattern.substr(0, index + 1);
-  if (FAILED(handle)) {
-    // Finding no files is OK.
-    return;
-  }
-  do {
-    files->push_back(dirname + data.cFileName);
-  } while (FindNextFileA(handle, &data));
-  LOG_SYSRESULT(FindClose(handle));
-#else
-# error There is no way to do glob.
-#endif
-}
-
-// Delete files patching pattern
-static void DeleteFiles(const string& pattern) {
-  vector<string> files;
-  GetFiles(pattern, &files);
-  for (size_t i = 0; i < files.size(); i++) {
-    CHECK(unlink(files[i].c_str()) == 0) << ": " << strerror(errno);
-  }
-}
-
-static void CheckFile(const string& name, const string& expected_string) {
-  vector<string> files;
-  GetFiles(name + "*", &files);
-  CHECK_EQ(files.size(), 1UL);
-
-  FILE* file = fopen(files[0].c_str(), "r");
-  CHECK(file != NULL) << ": could not open " << files[0];
-  char buf[1000];
-  while (fgets(buf, sizeof(buf), file) != NULL) {
-    if (strstr(buf, expected_string.c_str()) != NULL) {
-      fclose(file);
-      return;
-    }
-  }
-  fclose(file);
-  LOG(FATAL) << "Did not find " << expected_string << " in " << files[0];
-}
-
-static void TestBasename() {
-  fprintf(stderr, "==== Test setting log file basename\n");
-  const string dest = FLAGS_test_tmpdir + "/logging_test_basename";
-  DeleteFiles(dest + "*");
-
-  SetLogDestination(GLOG_INFO, dest.c_str());
-  LOG(INFO) << "message to new base";
-  FlushLogFiles(GLOG_INFO);
-
-  CheckFile(dest, "message to new base");
-
-  // Release file handle for the destination file to unlock the file in Windows.
-  LogToStderr();
-  DeleteFiles(dest + "*");
-}
-
-static void TestSymlink() {
-#ifndef OS_WINDOWS
-  fprintf(stderr, "==== Test setting log file symlink\n");
-  string dest = FLAGS_test_tmpdir + "/logging_test_symlink";
-  string sym = FLAGS_test_tmpdir + "/symlinkbase";
-  DeleteFiles(dest + "*");
-  DeleteFiles(sym + "*");
-
-  SetLogSymlink(GLOG_INFO, "symlinkbase");
-  SetLogDestination(GLOG_INFO, dest.c_str());
-  LOG(INFO) << "message to new symlink";
-  FlushLogFiles(GLOG_INFO);
-  CheckFile(sym, "message to new symlink");
-
-  DeleteFiles(dest + "*");
-  DeleteFiles(sym + "*");
-#endif
-}
-
-static void TestExtension() {
-  fprintf(stderr, "==== Test setting log file extension\n");
-  string dest = FLAGS_test_tmpdir + "/logging_test_extension";
-  DeleteFiles(dest + "*");
-
-  SetLogDestination(GLOG_INFO, dest.c_str());
-  SetLogFilenameExtension("specialextension");
-  LOG(INFO) << "message to new extension";
-  FlushLogFiles(GLOG_INFO);
-  CheckFile(dest, "message to new extension");
-
-  // Check that file name ends with extension
-  vector<string> filenames;
-  GetFiles(dest + "*", &filenames);
-  CHECK_EQ(filenames.size(), 1UL);
-  CHECK(strstr(filenames[0].c_str(), "specialextension") != NULL);
-
-  // Release file handle for the destination file to unlock the file in Windows.
-  LogToStderr();
-  DeleteFiles(dest + "*");
-}
-
-struct MyLogger : public base::Logger {
-  string data;
-
-  virtual void Write(bool /* should_flush */,
-                     time_t /* timestamp */,
-                     const char* message,
-                     int length) {
-    data.append(message, length);
-  }
-
-  virtual void Flush() { }
-
-  virtual uint32 LogSize() { return data.length(); }
-};
-
-static void TestWrapper() {
-  fprintf(stderr, "==== Test log wrapper\n");
-
-  MyLogger my_logger;
-  base::Logger* old_logger = base::GetLogger(GLOG_INFO);
-  base::SetLogger(GLOG_INFO, &my_logger);
-  LOG(INFO) << "Send to wrapped logger";
-  FlushLogFiles(GLOG_INFO);
-  base::SetLogger(GLOG_INFO, old_logger);
-
-  CHECK(strstr(my_logger.data.c_str(), "Send to wrapped logger") != NULL);
-}
-
-static void TestErrno() {
-  fprintf(stderr, "==== Test errno preservation\n");
-
-  errno = ENOENT;
-  TestLogging(false);
-  CHECK_EQ(errno, ENOENT);
-}
-
-static void TestOneTruncate(const char *path, int64 limit, int64 keep,
-                            int64 dsize, int64 ksize, int64 expect) {
-  int fd;
-  CHECK_ERR(fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0600));
-
-  const char *discardstr = "DISCARDME!", *keepstr = "KEEPME!";
-
-  // Fill the file with the requested data; first discard data, then kept data
-  int64 written = 0;
-  while (written < dsize) {
-    int bytes = min<int64>(dsize - written, strlen(discardstr));
-    CHECK_ERR(write(fd, discardstr, bytes));
-    written += bytes;
-  }
-  written = 0;
-  while (written < ksize) {
-    int bytes = min<int64>(ksize - written, strlen(keepstr));
-    CHECK_ERR(write(fd, keepstr, bytes));
-    written += bytes;
-  }
-
-  TruncateLogFile(path, limit, keep);
-
-  // File should now be shorter
-  struct stat statbuf;
-  CHECK_ERR(fstat(fd, &statbuf));
-  CHECK_EQ(statbuf.st_size, expect);
-  CHECK_ERR(lseek(fd, 0, SEEK_SET));
-
-  // File should contain the suffix of the original file
-  const size_t buf_size = statbuf.st_size + 1;
-  char* buf = new char[buf_size];
-  memset(buf, 0, buf_size);
-  CHECK_ERR(read(fd, buf, buf_size));
-
-  const char *p = buf;
-  int64 checked = 0;
-  while (checked < expect) {
-    int bytes = min<int64>(expect - checked, strlen(keepstr));
-    CHECK(!memcmp(p, keepstr, bytes));
-    checked += bytes;
-  }
-  close(fd);
-  delete[] buf;
-}
-
-static void TestTruncate() {
-#ifdef HAVE_UNISTD_H
-  fprintf(stderr, "==== Test log truncation\n");
-  string path = FLAGS_test_tmpdir + "/truncatefile";
-
-  // Test on a small file
-  TestOneTruncate(path.c_str(), 10, 10, 10, 10, 10);
-
-  // And a big file (multiple blocks to copy)
-  TestOneTruncate(path.c_str(), 2<<20, 4<<10, 3<<20, 4<<10, 4<<10);
-
-  // Check edge-case limits
-  TestOneTruncate(path.c_str(), 10, 20, 0, 20, 20);
-  TestOneTruncate(path.c_str(), 10, 0, 0, 0, 0);
-  TestOneTruncate(path.c_str(), 10, 50, 0, 10, 10);
-  TestOneTruncate(path.c_str(), 50, 100, 0, 30, 30);
-
-  // MacOSX 10.4 doesn't fail in this case.
-  // Windows doesn't have symlink.
-  // Let's just ignore this test for these cases.
-#if !defined(OS_MACOSX) && !defined(OS_WINDOWS)
-  // Through a symlink should fail to truncate
-  string linkname = path + ".link";
-  unlink(linkname.c_str());
-  CHECK_ERR(symlink(path.c_str(), linkname.c_str()));
-  TestOneTruncate(linkname.c_str(), 10, 10, 0, 30, 30);
-#endif
-
-  // The /proc/self path makes sense only for linux.
-#if defined(OS_LINUX)
-  // Through an open fd symlink should work
-  int fd;
-  CHECK_ERR(fd = open(path.c_str(), O_APPEND | O_WRONLY));
-  char fdpath[64];
-  snprintf(fdpath, sizeof(fdpath), "/proc/self/fd/%d", fd);
-  TestOneTruncate(fdpath, 10, 10, 10, 10, 10);
-#endif
-
-#endif
-}
-
-_START_GOOGLE_NAMESPACE_
-namespace glog_internal_namespace_ {
-extern  // in logging.cc
-bool SafeFNMatch_(const char* pattern, size_t patt_len,
-                  const char* str, size_t str_len);
-} // namespace glog_internal_namespace_
-using glog_internal_namespace_::SafeFNMatch_;
-_END_GOOGLE_NAMESPACE_
-
-static bool WrapSafeFNMatch(string pattern, string str) {
-  pattern += "abc";
-  str += "defgh";
-  return SafeFNMatch_(pattern.data(), pattern.size() - 3,
-                      str.data(), str.size() - 5);
-}
-
-TEST(SafeFNMatch, logging) {
-  CHECK(WrapSafeFNMatch("foo", "foo"));
-  CHECK(!WrapSafeFNMatch("foo", "bar"));
-  CHECK(!WrapSafeFNMatch("foo", "fo"));
-  CHECK(!WrapSafeFNMatch("foo", "foo2"));
-  CHECK(WrapSafeFNMatch("bar/foo.ext", "bar/foo.ext"));
-  CHECK(WrapSafeFNMatch("*ba*r/fo*o.ext*", "bar/foo.ext"));
-  CHECK(!WrapSafeFNMatch("bar/foo.ext", "bar/baz.ext"));
-  CHECK(!WrapSafeFNMatch("bar/foo.ext", "bar/foo"));
-  CHECK(!WrapSafeFNMatch("bar/foo.ext", "bar/foo.ext.zip"));
-  CHECK(WrapSafeFNMatch("ba?/*.ext", "bar/foo.ext"));
-  CHECK(WrapSafeFNMatch("ba?/*.ext", "baZ/FOO.ext"));
-  CHECK(!WrapSafeFNMatch("ba?/*.ext", "barr/foo.ext"));
-  CHECK(!WrapSafeFNMatch("ba?/*.ext", "bar/foo.ext2"));
-  CHECK(WrapSafeFNMatch("ba?/*", "bar/foo.ext2"));
-  CHECK(WrapSafeFNMatch("ba?/*", "bar/"));
-  CHECK(!WrapSafeFNMatch("ba?/?", "bar/"));
-  CHECK(!WrapSafeFNMatch("ba?/*", "bar"));
-}
-
-// TestWaitingLogSink will save messages here
-// No lock: Accessed only by TestLogSinkWriter thread
-// and after its demise by its creator.
-static vector<string> global_messages;
-
-// helper for TestWaitingLogSink below.
-// Thread that does the logic of TestWaitingLogSink
-// It's free to use LOG() itself.
-class TestLogSinkWriter : public Thread {
- public:
-
-  TestLogSinkWriter() : should_exit_(false) {
-    SetJoinable(true);
-    Start();
-  }
-
-  // Just buffer it (can't use LOG() here).
-  void Buffer(const string& message) {
-    mutex_.Lock();
-    RAW_LOG(INFO, "Buffering");
-    messages_.push(message);
-    mutex_.Unlock();
-    RAW_LOG(INFO, "Buffered");
-  }
-
-  // Wait for the buffer to clear (can't use LOG() here).
-  void Wait() {
-    RAW_LOG(INFO, "Waiting");
-    mutex_.Lock();
-    while (!NoWork()) {
-      mutex_.Unlock();
-      SleepForMilliseconds(1);
-      mutex_.Lock();
-    }
-    RAW_LOG(INFO, "Waited");
-    mutex_.Unlock();
-  }
-
-  // Trigger thread exit.
-  void Stop() {
-    MutexLock l(&mutex_);
-    should_exit_ = true;
-  }
-
- private:
-
-  // helpers ---------------
-
-  // For creating a "Condition".
-  bool NoWork() { return messages_.empty(); }
-  bool HaveWork() { return !messages_.empty() || should_exit_; }
-
-  // Thread body; CAN use LOG() here!
-  virtual void Run() {
-    while (1) {
-      mutex_.Lock();
-      while (!HaveWork()) {
-        mutex_.Unlock();
-        SleepForMilliseconds(1);
-        mutex_.Lock();
-      }
-      if (should_exit_ && messages_.empty()) {
-        mutex_.Unlock();
-        break;
-      }
-      // Give the main thread time to log its message,
-      // so that we get a reliable log capture to compare to golden file.
-      // Same for the other sleep below.
-      SleepForMilliseconds(20);
-      RAW_LOG(INFO, "Sink got a messages");  // only RAW_LOG under mutex_ here
-      string message = messages_.front();
-      messages_.pop();
-      // Normally this would be some more real/involved logging logic
-      // where LOG() usage can't be eliminated,
-      // e.g. pushing the message over with an RPC:
-      int messages_left = messages_.size();
-      mutex_.Unlock();
-      SleepForMilliseconds(20);
-      // May not use LOG while holding mutex_, because Buffer()
-      // acquires mutex_, and Buffer is called from LOG(),
-      // which has its own internal mutex:
-      // LOG()->LogToSinks()->TestWaitingLogSink::send()->Buffer()
-      LOG(INFO) << "Sink is sending out a message: " << message;
-      LOG(INFO) << "Have " << messages_left << " left";
-      global_messages.push_back(message);
-    }
-  }
-
-  // data ---------------
-
-  Mutex mutex_;
-  bool should_exit_;
-  queue<string> messages_;  // messages to be logged
-};
-
-// A log sink that exercises WaitTillSent:
-// it pushes data to a buffer and wakes up another thread to do the logging
-// (that other thread can than use LOG() itself),
-class TestWaitingLogSink : public LogSink {
- public:
-
-  TestWaitingLogSink() {
-    tid_ = pthread_self();  // for thread-specific behavior
-    AddLogSink(this);
-  }
-  ~TestWaitingLogSink() {
-    RemoveLogSink(this);
-    writer_.Stop();
-    writer_.Join();
-  }
-
-  // (re)define LogSink interface
-
-  virtual void send(LogSeverity severity, const char* /* full_filename */,
-                    const char* base_filename, int line,
-                    const struct tm* tm_time,
-                    const char* message, size_t message_len) {
-    // Push it to Writer thread if we are the original logging thread.
-    // Note: Something like ThreadLocalLogSink is a better choice
-    //       to do thread-specific LogSink logic for real.
-    if (pthread_equal(tid_, pthread_self())) {
-      writer_.Buffer(ToString(severity, base_filename, line,
-                              tm_time, message, message_len));
-    }
-  }
-  virtual void WaitTillSent() {
-    // Wait for Writer thread if we are the original logging thread.
-    if (pthread_equal(tid_, pthread_self()))  writer_.Wait();
-  }
-
- private:
-
-  pthread_t tid_;
-  TestLogSinkWriter writer_;
-};
-
-// Check that LogSink::WaitTillSent can be used in the advertised way.
-// We also do golden-stderr comparison.
-static void TestLogSinkWaitTillSent() {
-  { TestWaitingLogSink sink;
-    // Sleeps give the sink threads time to do all their work,
-    // so that we get a reliable log capture to compare to the golden file.
-    LOG(INFO) << "Message 1";
-    SleepForMilliseconds(60);
-    LOG(ERROR) << "Message 2";
-    SleepForMilliseconds(60);
-    LOG(WARNING) << "Message 3";
-    SleepForMilliseconds(60);
-  }
-  for (size_t i = 0; i < global_messages.size(); ++i) {
-    LOG(INFO) << "Sink capture: " << global_messages[i];
-  }
-  CHECK_EQ(global_messages.size(), 3UL);
-}
-
-TEST(Strerror, logging) {
-  int errcode = EINTR;
-  char *msg = strdup(strerror(errcode));
-  const size_t buf_size = strlen(msg) + 1;
-  char *buf = new char[buf_size];
-  CHECK_EQ(posix_strerror_r(errcode, NULL, 0), -1);
-  buf[0] = 'A';
-  CHECK_EQ(posix_strerror_r(errcode, buf, 0), -1);
-  CHECK_EQ(buf[0], 'A');
-  CHECK_EQ(posix_strerror_r(errcode, NULL, buf_size), -1);
-#if defined(OS_MACOSX) || defined(OS_FREEBSD) || defined(OS_OPENBSD)
-  // MacOSX or FreeBSD considers this case is an error since there is
-  // no enough space.
-  CHECK_EQ(posix_strerror_r(errcode, buf, 1), -1);
-#else
-  CHECK_EQ(posix_strerror_r(errcode, buf, 1), 0);
-#endif
-  CHECK_STREQ(buf, "");
-  CHECK_EQ(posix_strerror_r(errcode, buf, buf_size), 0);
-  CHECK_STREQ(buf, msg);
-  free(msg);
-  delete[] buf;
-}
-
-// Simple routines to look at the sizes of generated code for LOG(FATAL) and
-// CHECK(..) via objdump
-void MyFatal() {
-  LOG(FATAL) << "Failed";
-}
-void MyCheck(bool a, bool b) {
-  CHECK_EQ(a, b);
-}
-
-#ifdef HAVE_LIB_GMOCK
-
-TEST(DVLog, Basic) {
-  ScopedMockLog log;
-
-#if NDEBUG
-  // We are expecting that nothing is logged.
-  EXPECT_CALL(log, Log(_, _, _)).Times(0);
-#else
-  EXPECT_CALL(log, Log(INFO, __FILE__, "debug log"));
-#endif
-
-  FLAGS_v = 1;
-  DVLOG(1) << "debug log";
-}
-
-TEST(DVLog, V0) {
-  ScopedMockLog log;
-
-  // We are expecting that nothing is logged.
-  EXPECT_CALL(log, Log(_, _, _)).Times(0);
-
-  FLAGS_v = 0;
-  DVLOG(1) << "debug log";
-}
-
-TEST(LogAtLevel, Basic) {
-  ScopedMockLog log;
-
-  // The function version outputs "logging.h" as a file name.
-  EXPECT_CALL(log, Log(WARNING, StrNe(__FILE__), "function version"));
-  EXPECT_CALL(log, Log(INFO, __FILE__, "macro version"));
-
-  int severity = WARNING;
-  LogAtLevel(severity, "function version");
-
-  severity = INFO;
-  // We can use the macro version as a C++ stream.
-  LOG_AT_LEVEL(severity) << "macro" << ' ' << "version";
-}
-
-TEST(TestExitOnDFatal, ToBeOrNotToBe) {
-  // Check the default setting...
-  EXPECT_TRUE(base::internal::GetExitOnDFatal());
-
-  // Turn off...
-  base::internal::SetExitOnDFatal(false);
-  EXPECT_FALSE(base::internal::GetExitOnDFatal());
-
-  // We don't die.
-  {
-    ScopedMockLog log;
-    //EXPECT_CALL(log, Log(_, _, _)).Times(AnyNumber());
-    // LOG(DFATAL) has severity FATAL if debugging, but is
-    // downgraded to ERROR if not debugging.
-    const LogSeverity severity =
-#ifdef NDEBUG
-        ERROR;
-#else
-        FATAL;
-#endif
-    EXPECT_CALL(log, Log(severity, __FILE__, "This should not be fatal"));
-    LOG(DFATAL) << "This should not be fatal";
-  }
-
-  // Turn back on...
-  base::internal::SetExitOnDFatal(true);
-  EXPECT_TRUE(base::internal::GetExitOnDFatal());
-
-#ifdef GTEST_HAS_DEATH_TEST
-  // Death comes on little cats' feet.
-  EXPECT_DEBUG_DEATH({
-      LOG(DFATAL) << "This should be fatal in debug mode";
-    }, "This should be fatal in debug mode");
-#endif
-}
-
-#ifdef HAVE_STACKTRACE
-
-static void BacktraceAtHelper() {
-  LOG(INFO) << "Not me";
-
-// The vertical spacing of the next 3 lines is significant.
-  LOG(INFO) << "Backtrace me";
-}
-static int kBacktraceAtLine = __LINE__ - 2;  // The line of the LOG(INFO) above
-
-TEST(LogBacktraceAt, DoesNotBacktraceWhenDisabled) {
-  StrictMock<ScopedMockLog> log;
-
-  FLAGS_log_backtrace_at = "";
-
-  EXPECT_CALL(log, Log(_, _, "Backtrace me"));
-  EXPECT_CALL(log, Log(_, _, "Not me"));
-
-  BacktraceAtHelper();
-}
-
-TEST(LogBacktraceAt, DoesBacktraceAtRightLineWhenEnabled) {
-  StrictMock<ScopedMockLog> log;
-
-  char where[100];
-  snprintf(where, 100, "%s:%d", const_basename(__FILE__), kBacktraceAtLine);
-  FLAGS_log_backtrace_at = where;
-
-  // The LOG at the specified line should include a stacktrace which includes
-  // the name of the containing function, followed by the log message.
-  // We use HasSubstr()s instead of ContainsRegex() for environments
-  // which don't have regexp.
-  EXPECT_CALL(log, Log(_, _, AllOf(HasSubstr("stacktrace:"),
-                                   HasSubstr("BacktraceAtHelper"),
-                                   HasSubstr("main"),
-                                   HasSubstr("Backtrace me"))));
-  // Other LOGs should not include a backtrace.
-  EXPECT_CALL(log, Log(_, _, "Not me"));
-
-  BacktraceAtHelper();
-}
-
-#endif // HAVE_STACKTRACE
-
-#endif // HAVE_LIB_GMOCK
-
-struct UserDefinedClass {
-  bool operator==(const UserDefinedClass&) const { return true; }
-};
-
-inline ostream& operator<<(ostream& out, const UserDefinedClass&) {
-  out << "OK";
-  return out;
-}
-
-TEST(UserDefinedClass, logging) {
-  UserDefinedClass u;
-  vector<string> buf;
-  LOG_STRING(INFO, &buf) << u;
-  CHECK_EQ(1UL, buf.size());
-  CHECK(buf[0].find("OK") != string::npos);
-
-  // We must be able to compile this.
-  CHECK_EQ(u, u);
-}

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/logging_unittest.err
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/logging_unittest.err b/third_party/src/glog/src/logging_unittest.err
deleted file mode 100644
index 4f80bf5..0000000
--- a/third_party/src/glog/src/logging_unittest.err
+++ /dev/null
@@ -1,305 +0,0 @@
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=2 logtostderr=0 alsologtostderr=0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error
-WARNING: Logging before InitGoogleLogging() is written to STDERR
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=0 logtostderr=0 alsologtostderr=0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] foo bar 10 3.4
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 1: __SUCCESS__ [0]
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 3, iteration 1
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 4, iteration 1
-WDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 5, iteration 1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 1
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Log if less than 3 every 2, iteration 1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 2
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 3: __ENOENT__ [2]
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 3
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Log if less than 3 every 2, iteration 3
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 3, iteration 4
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 4
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 5: __EINTR__ [4]
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 4, iteration 5
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 5
-WDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 5, iteration 6
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 6
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 7: __ENXIO__ [6]
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 3, iteration 7
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 7
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 8
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Plog every 2, iteration 9: __ENOEXEC__ [8]
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 4, iteration 9
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 9
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Log every 3, iteration 10
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Log if every 1, iteration 10
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log_if this
-IDATE TIME__ THREADID logging_unittest.cc:LINE] array
-IDATE TIME__ THREADID logging_unittest.cc:LINE] const array
-EDATE TIME__ THREADID logging_unittest.cc:LINE] foo 1000 0000001000 3e8
-no prefix
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo bar 10 3.400000
-WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: array
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: const array
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: ptr 0x12345678
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: ptr __NULLP__
-EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo 1000 0000001000 3e8
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo 1000
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo 1000
-WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: RAW_LOG ERROR: The Message was too long!
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: RAW_LOG ERROR: The Message was too long!
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0 on
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 1 on
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 2 on
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=0 logtostderr=0 alsologtostderr=0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=1 stderrthreshold=0 logtostderr=0 alsologtostderr=0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=-1 stderrthreshold=0 logtostderr=0 alsologtostderr=0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=1 logtostderr=0 alsologtostderr=0
-WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log error
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=2 logtostderr=0 alsologtostderr=0
-EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log error
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=3 logtostderr=0 alsologtostderr=0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=3 logtostderr=1 alsologtostderr=0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=0 stderrthreshold=3 logtostderr=0 alsologtostderr=1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=1 stderrthreshold=1 logtostderr=0 alsologtostderr=0
-WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log error
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Test: v=1 stderrthreshold=3 logtostderr=0 alsologtostderr=1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: vlog 1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog 1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if -1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] log_if warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] log_if info every 1 expr
-EDATE TIME__ THREADID logging_unittest.cc:LINE] log_if error every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] vlog_if 0 every 1 expr
-IDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_STRING: reported info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_STRING: reported warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_STRING: reported error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_STRING:  LOG_STRING: collected info
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_STRING:  LOG_STRING: collected warning
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_STRING:  LOG_STRING: collected error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: reported info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: reported warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: reported error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_TO_SINK:
-IDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK: collected error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK_BUT_NOT_TO_LOGFILE: collected info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK_BUT_NOT_TO_LOGFILE: collected warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_SINK_BUT_NOT_TO_LOGFILE: collected error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: collected info
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_TO_STRING:  LOG_TO_STRING: collected info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: collected warning
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_TO_STRING:  LOG_TO_STRING: collected warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: collected error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Captured by LOG_TO_STRING:  LOG_TO_STRING: collected error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: reported info
-WDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: reported warning
-EDATE TIME__ THREADID logging_unittest.cc:LINE] LOG_TO_STRING: reported error
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Message 1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Buffering
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Buffered
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Waiting
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Sink got a messages
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Waited
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Sink is sending out a message: IDATE TIME__ THREADID logging_unittest.cc:LINE] Message 1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Have 0 left
-EDATE TIME__ THREADID logging_unittest.cc:LINE] Message 2
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Buffering
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Buffered
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Waiting
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Sink got a messages
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Waited
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Sink is sending out a message: EDATE TIME__ THREADID logging_unittest.cc:LINE] Message 2
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Have 0 left
-WDATE TIME__ THREADID logging_unittest.cc:LINE] Message 3
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Buffering
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Buffered
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Waiting
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Sink got a messages
-IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: Waited
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Sink is sending out a message: WDATE TIME__ THREADID logging_unittest.cc:LINE] Message 3
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Have 0 left
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Sink capture: IDATE TIME__ THREADID logging_unittest.cc:LINE] Message 1
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Sink capture: EDATE TIME__ THREADID logging_unittest.cc:LINE] Message 2
-IDATE TIME__ THREADID logging_unittest.cc:LINE] Sink capture: WDATE TIME__ THREADID logging_unittest.cc:LINE] Message 3

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/mock-log.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/mock-log.h b/third_party/src/glog/src/mock-log.h
deleted file mode 100644
index 5b21811..0000000
--- a/third_party/src/glog/src/mock-log.h
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Zhanyong Wan
-//
-// Defines the ScopedMockLog class (using Google C++ Mocking
-// Framework), which is convenient for testing code that uses LOG().
-
-#ifndef GLOG_SRC_MOCK_LOG_H_
-#define GLOG_SRC_MOCK_LOG_H_
-
-// For GOOGLE_NAMESPACE. This must go first so we get _XOPEN_SOURCE.
-#include "utilities.h"
-
-#include <string>
-
-#include <gmock/gmock.h>
-
-#include "glog/logging.h"
-
-_START_GOOGLE_NAMESPACE_
-namespace glog_testing {
-
-// A ScopedMockLog object intercepts LOG() messages issued during its
-// lifespan.  Using this together with Google C++ Mocking Framework,
-// it's very easy to test how a piece of code calls LOG().  The
-// typical usage:
-//
-//   TEST(FooTest, LogsCorrectly) {
-//     ScopedMockLog log;
-//
-//     // We expect the WARNING "Something bad!" exactly twice.
-//     EXPECT_CALL(log, Log(WARNING, _, "Something bad!"))
-//         .Times(2);
-//
-//     // We allow foo.cc to call LOG(INFO) any number of times.
-//     EXPECT_CALL(log, Log(INFO, HasSubstr("/foo.cc"), _))
-//         .Times(AnyNumber());
-//
-//     Foo();  // Exercises the code under test.
-//   }
-class ScopedMockLog : public GOOGLE_NAMESPACE::LogSink {
- public:
-  // When a ScopedMockLog object is constructed, it starts to
-  // intercept logs.
-  ScopedMockLog() { AddLogSink(this); }
-
-  // When the object is destructed, it stops intercepting logs.
-  virtual ~ScopedMockLog() { RemoveLogSink(this); }
-
-  // Implements the mock method:
-  //
-  //   void Log(LogSeverity severity, const string& file_path,
-  //            const string& message);
-  //
-  // The second argument to Send() is the full path of the source file
-  // in which the LOG() was issued.
-  //
-  // Note, that in a multi-threaded environment, all LOG() messages from a
-  // single thread will be handled in sequence, but that cannot be guaranteed
-  // for messages from different threads. In fact, if the same or multiple
-  // expectations are matched on two threads concurrently, their actions will
-  // be executed concurrently as well and may interleave.
-  MOCK_METHOD3(Log, void(GOOGLE_NAMESPACE::LogSeverity severity,
-                         const std::string& file_path,
-                         const std::string& message));
-
- private:
-  // Implements the send() virtual function in class LogSink.
-  // Whenever a LOG() statement is executed, this function will be
-  // invoked with information presented in the LOG().
-  //
-  // The method argument list is long and carries much information a
-  // test usually doesn't care about, so we trim the list before
-  // forwarding the call to Log(), which is much easier to use in
-  // tests.
-  //
-  // We still cannot call Log() directly, as it may invoke other LOG()
-  // messages, either due to Invoke, or due to an error logged in
-  // Google C++ Mocking Framework code, which would trigger a deadlock
-  // since a lock is held during send().
-  //
-  // Hence, we save the message for WaitTillSent() which will be called after
-  // the lock on send() is released, and we'll call Log() inside
-  // WaitTillSent(). Since while a single send() call may be running at a
-  // time, multiple WaitTillSent() calls (along with the one send() call) may
-  // be running simultaneously, we ensure thread-safety of the exchange between
-  // send() and WaitTillSent(), and that for each message, LOG(), send(),
-  // WaitTillSent() and Log() are executed in the same thread.
-  virtual void send(GOOGLE_NAMESPACE::LogSeverity severity,
-                    const char* full_filename,
-                    const char* base_filename, int line, const tm* tm_time,
-                    const char* message, size_t message_len) {
-    // We are only interested in the log severity, full file name, and
-    // log message.
-    message_info_.severity = severity;
-    message_info_.file_path = full_filename;
-    message_info_.message = std::string(message, message_len);
-  }
-
-  // Implements the WaitTillSent() virtual function in class LogSink.
-  // It will be executed after send() and after the global logging lock is
-  // released, so calls within it (or rather within the Log() method called
-  // within) may also issue LOG() statements.
-  //
-  // LOG(), send(), WaitTillSent() and Log() will occur in the same thread for
-  // a given log message.
-  virtual void WaitTillSent() {
-    // First, and very importantly, we save a copy of the message being
-    // processed before calling Log(), since Log() may indirectly call send()
-    // and WaitTillSent() in the same thread again.
-    MessageInfo message_info = message_info_;
-    Log(message_info.severity, message_info.file_path, message_info.message);
-  }
-
-  // All relevant information about a logged message that needs to be passed
-  // from send() to WaitTillSent().
-  struct MessageInfo {
-    GOOGLE_NAMESPACE::LogSeverity severity;
-    std::string file_path;
-    std::string message;
-  };
-  MessageInfo message_info_;
-};
-
-}  // namespace glog_testing
-_END_GOOGLE_NAMESPACE_
-
-#endif  // GLOG_SRC_MOCK_LOG_H_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/mock-log_test.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/mock-log_test.cc b/third_party/src/glog/src/mock-log_test.cc
deleted file mode 100644
index 7d58a30..0000000
--- a/third_party/src/glog/src/mock-log_test.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Zhanyong Wan
-
-// Tests the ScopedMockLog class.
-
-#include "mock-log.h"
-
-#include <string>
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-namespace {
-
-using GOOGLE_NAMESPACE::INFO;
-using GOOGLE_NAMESPACE::WARNING;
-using GOOGLE_NAMESPACE::ERROR;
-using GOOGLE_NAMESPACE::glog_testing::ScopedMockLog;
-using std::string;
-using testing::_;
-using testing::HasSubstr;
-using testing::InSequence;
-using testing::InvokeWithoutArgs;
-
-// Tests that ScopedMockLog intercepts LOG()s when it's alive.
-TEST(ScopedMockLogTest, InterceptsLog) {
-  ScopedMockLog log;
-
-  InSequence s;
-  EXPECT_CALL(log, Log(WARNING, HasSubstr("/mock-log_test.cc"), "Fishy."));
-  EXPECT_CALL(log, Log(INFO, _, "Working..."))
-      .Times(2);
-  EXPECT_CALL(log, Log(ERROR, _, "Bad!!"));
-
-  LOG(WARNING) << "Fishy.";
-  LOG(INFO) << "Working...";
-  LOG(INFO) << "Working...";
-  LOG(ERROR) << "Bad!!";
-}
-
-void LogBranch() {
-  LOG(INFO) << "Logging a branch...";
-}
-
-void LogTree() {
-  LOG(INFO) << "Logging the whole tree...";
-}
-
-void LogForest() {
-  LOG(INFO) << "Logging the entire forest.";
-  LOG(INFO) << "Logging the entire forest..";
-  LOG(INFO) << "Logging the entire forest...";
-}
-
-// The purpose of the following test is to verify that intercepting logging
-// continues to work properly if a LOG statement is executed within the scope
-// of a mocked call.
-TEST(ScopedMockLogTest, LogDuringIntercept) {
-  ScopedMockLog log;
-  InSequence s;
-  EXPECT_CALL(log, Log(INFO, __FILE__, "Logging a branch..."))
-      .WillOnce(InvokeWithoutArgs(LogTree));
-  EXPECT_CALL(log, Log(INFO, __FILE__, "Logging the whole tree..."))
-      .WillOnce(InvokeWithoutArgs(LogForest));
-  EXPECT_CALL(log, Log(INFO, __FILE__, "Logging the entire forest."));
-  EXPECT_CALL(log, Log(INFO, __FILE__, "Logging the entire forest.."));
-  EXPECT_CALL(log, Log(INFO, __FILE__, "Logging the entire forest..."));
-  LogBranch();
-}
-
-}  // namespace
-
-int main(int argc, char **argv) {
-  GOOGLE_NAMESPACE::InitGoogleLogging(argv[0]);
-  testing::InitGoogleMock(&argc, argv);
-
-  return RUN_ALL_TESTS();
-}

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/raw_logging.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/raw_logging.cc b/third_party/src/glog/src/raw_logging.cc
deleted file mode 100644
index 7a7409b..0000000
--- a/third_party/src/glog/src/raw_logging.cc
+++ /dev/null
@@ -1,172 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Maxim Lifantsev
-//
-// logging_unittest.cc covers the functionality herein
-
-#include "utilities.h"
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <errno.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>               // for close() and write()
-#endif
-#include <fcntl.h>                 // for open()
-#include <time.h>
-#include "config.h"
-#include "glog/logging.h"          // To pick up flag settings etc.
-#include "glog/raw_logging.h"
-#include "base/commandlineflags.h"
-
-#ifdef HAVE_STACKTRACE
-# include "stacktrace.h"
-#endif
-
-#if defined(HAVE_SYSCALL_H)
-#include <syscall.h>                 // for syscall()
-#elif defined(HAVE_SYS_SYSCALL_H)
-#include <sys/syscall.h>                 // for syscall()
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)
-# define safe_write(fd, s, len)  syscall(SYS_write, fd, s, len)
-#else
-  // Not so safe, but what can you do?
-# define safe_write(fd, s, len)  write(fd, s, len)
-#endif
-
-_START_GOOGLE_NAMESPACE_
-
-// Data for RawLog__ below. We simply pick up the latest
-// time data created by a normal log message to avoid calling
-// localtime_r which can allocate memory.
-static struct ::tm last_tm_time_for_raw_log;
-static int last_usecs_for_raw_log;
-
-void RawLog__SetLastTime(const struct ::tm& t, int usecs) {
-  memcpy(&last_tm_time_for_raw_log, &t, sizeof(last_tm_time_for_raw_log));
-  last_usecs_for_raw_log = usecs;
-}
-
-// CAVEAT: vsnprintf called from *DoRawLog below has some (exotic) code paths
-// that invoke malloc() and getenv() that might acquire some locks.
-// If this becomes a problem we should reimplement a subset of vsnprintf
-// that does not need locks and malloc.
-
-// Helper for RawLog__ below.
-// *DoRawLog writes to *buf of *size and move them past the written portion.
-// It returns true iff there was no overflow or error.
-static bool DoRawLog(char** buf, int* size, const char* format, ...) {
-  va_list ap;
-  va_start(ap, format);
-  int n = vsnprintf(*buf, *size, format, ap);
-  va_end(ap);
-  if (n < 0 || n > *size) return false;
-  *size -= n;
-  *buf += n;
-  return true;
-}
-
-// Helper for RawLog__ below.
-inline static bool VADoRawLog(char** buf, int* size,
-                              const char* format, va_list ap) {
-  int n = vsnprintf(*buf, *size, format, ap);
-  if (n < 0 || n > *size) return false;
-  *size -= n;
-  *buf += n;
-  return true;
-}
-
-static const int kLogBufSize = 3000;
-static bool crashed = false;
-static CrashReason crash_reason;
-static char crash_buf[kLogBufSize + 1] = { 0 };  // Will end in '\0'
-
-void RawLog__(LogSeverity severity, const char* file, int line,
-              const char* format, ...) {
-  if (!(FLAGS_logtostderr || severity >= FLAGS_stderrthreshold ||
-        FLAGS_alsologtostderr || !IsGoogleLoggingInitialized())) {
-    return;  // this stderr log message is suppressed
-  }
-  // can't call localtime_r here: it can allocate
-  struct ::tm& t = last_tm_time_for_raw_log;
-  char buffer[kLogBufSize];
-  char* buf = buffer;
-  int size = sizeof(buffer);
-
-  // NOTE: this format should match the specification in base/logging.h
-  DoRawLog(&buf, &size, "%c%02d%02d %02d:%02d:%02d.%06d %5u %s:%d] RAW: ",
-           LogSeverityNames[severity][0],
-           1 + t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec,
-           last_usecs_for_raw_log,
-           static_cast<unsigned int>(GetTID()),
-           const_basename(const_cast<char *>(file)), line);
-
-  // Record the position and size of the buffer after the prefix
-  const char* msg_start = buf;
-  const int msg_size = size;
-
-  va_list ap;
-  va_start(ap, format);
-  bool no_chop = VADoRawLog(&buf, &size, format, ap);
-  va_end(ap);
-  if (no_chop) {
-    DoRawLog(&buf, &size, "\n");
-  } else {
-    DoRawLog(&buf, &size, "RAW_LOG ERROR: The Message was too long!\n");
-  }
-  // We make a raw syscall to write directly to the stderr file descriptor,
-  // avoiding FILE buffering (to avoid invoking malloc()), and bypassing
-  // libc (to side-step any libc interception).
-  // We write just once to avoid races with other invocations of RawLog__.
-  safe_write(STDERR_FILENO, buffer, strlen(buffer));
-  if (severity == GLOG_FATAL)  {
-    if (!sync_val_compare_and_swap(&crashed, false, true)) {
-      crash_reason.filename = file;
-      crash_reason.line_number = line;
-      memcpy(crash_buf, msg_start, msg_size);  // Don't include prefix
-      crash_reason.message = crash_buf;
-#ifdef HAVE_STACKTRACE
-      crash_reason.depth =
-          GetStackTrace(crash_reason.stack, ARRAYSIZE(crash_reason.stack), 1);
-#else
-      crash_reason.depth = 0;
-#endif
-      SetCrashReason(&crash_reason);
-    }
-    LogMessage::Fail();  // abort()
-  }
-}
-
-_END_GOOGLE_NAMESPACE_


[37/46] incubator-quickstep git commit: Remove glog source code from third party

Posted by ji...@apache.org.
Remove glog source code from third party

- glog source code is now downloaded through the download script.
- Added patches for glog.


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

Branch: refs/heads/fix-iwyu
Commit: c43107d1fed5f96770024d52c10cd7bd061bb7c1
Parents: 8a84039
Author: Harshad Deshmukh <hb...@apache.org>
Authored: Fri Dec 15 15:06:49 2017 -0600
Committer: Harshad Deshmukh <hb...@apache.org>
Committed: Sat Dec 16 18:53:45 2017 -0600

----------------------------------------------------------------------
 CMakeLists.txt                                  |    3 +-
 third_party/download_and_patch_prerequisites.sh |    8 +
 .../patches/glog/glogCMakeLists.txt.patch       |   23 +
 third_party/patches/glog/utilities.cc.patch     |   11 +
 third_party/reset_third_party_dir.sh            |    1 +
 third_party/src/glog/AUTHORS                    |    2 -
 third_party/src/glog/CMakeLists.txt             |  208 --
 third_party/src/glog/COPYING                    |   65 -
 third_party/src/glog/ChangeLog                  |   84 -
 third_party/src/glog/INSTALL                    |  297 ---
 third_party/src/glog/NEWS                       |    0
 third_party/src/glog/README                     |    5 -
 third_party/src/glog/README.windows             |   26 -
 third_party/src/glog/doc/designstyle.css        |  115 -
 third_party/src/glog/doc/glog.html              |  613 ------
 .../src/glog/src/base/commandlineflags.h        |  133 --
 third_party/src/glog/src/base/googleinit.h      |   51 -
 third_party/src/glog/src/base/mutex.h           |  331 ---
 third_party/src/glog/src/config.h.in            |  171 --
 third_party/src/glog/src/config_cmake.h.in      |  169 --
 third_party/src/glog/src/config_for_unittests.h |   66 -
 third_party/src/glog/src/demangle.cc            | 1304 -----------
 third_party/src/glog/src/demangle.h             |   84 -
 third_party/src/glog/src/demangle_unittest.cc   |  142 --
 third_party/src/glog/src/demangle_unittest.sh   |   95 -
 third_party/src/glog/src/demangle_unittest.txt  |  137 --
 third_party/src/glog/src/glog/log_severity.h    |   92 -
 third_party/src/glog/src/glog/logging.h         | 1619 --------------
 third_party/src/glog/src/glog/raw_logging.h     |  191 --
 third_party/src/glog/src/glog/stl_logging.h     |  183 --
 third_party/src/glog/src/glog/vlog_is_on.h      |  129 --
 third_party/src/glog/src/googletest.h           |  604 ------
 third_party/src/glog/src/logging.cc             | 2049 -----------------
 .../src/glog/src/logging_striplog_test.sh       |   79 -
 third_party/src/glog/src/logging_striptest10.cc |   35 -
 third_party/src/glog/src/logging_striptest2.cc  |   35 -
 .../src/glog/src/logging_striptest_main.cc      |   73 -
 third_party/src/glog/src/logging_unittest.cc    | 1215 -----------
 third_party/src/glog/src/logging_unittest.err   |  305 ---
 third_party/src/glog/src/mock-log.h             |  155 --
 third_party/src/glog/src/mock-log_test.cc       |  106 -
 third_party/src/glog/src/raw_logging.cc         |  172 --
 third_party/src/glog/src/signalhandler.cc       |  350 ---
 .../src/glog/src/signalhandler_unittest.cc      |   97 -
 .../src/glog/src/signalhandler_unittest.sh      |  131 --
 third_party/src/glog/src/stacktrace.h           |   60 -
 .../src/glog/src/stacktrace_generic-inl.h       |   59 -
 .../src/glog/src/stacktrace_libunwind-inl.h     |   87 -
 .../src/glog/src/stacktrace_powerpc-inl.h       |  130 --
 third_party/src/glog/src/stacktrace_unittest.cc |  208 --
 third_party/src/glog/src/stacktrace_x86-inl.h   |  139 --
 .../src/glog/src/stacktrace_x86_64-inl.h        |  109 -
 .../src/glog/src/stl_logging_unittest.cc        |  182 --
 third_party/src/glog/src/symbolize.cc           |  681 ------
 third_party/src/glog/src/symbolize.h            |  116 -
 third_party/src/glog/src/symbolize_unittest.cc  |  365 ----
 third_party/src/glog/src/utilities.cc           |  347 ---
 third_party/src/glog/src/utilities.h            |  226 --
 third_party/src/glog/src/utilities_unittest.cc  |   54 -
 third_party/src/glog/src/vlog_is_on.cc          |  249 ---
 .../glog/src/windows/base/commandlineflags.h    |  133 --
 .../src/glog/src/windows/base/googleinit.h      |   51 -
 third_party/src/glog/src/windows/base/mutex.h   |  331 ---
 .../src/glog/src/windows/config_cmake.h.in      |  142 --
 .../src/glog/src/windows/glog/log_severity.h    |   96 -
 third_party/src/glog/src/windows/glog/logging.h | 1603 --------------
 .../src/glog/src/windows/glog/raw_logging.h     |  189 --
 .../src/glog/src/windows/glog/stl_logging.h     |  187 --
 .../src/glog/src/windows/glog/vlog_is_on.h      |  133 --
 third_party/src/glog/src/windows/logging.cc     | 2050 ------------------
 third_party/src/glog/src/windows/port.cc        |   66 -
 third_party/src/glog/src/windows/port.h         |  165 --
 third_party/src/glog/src/windows/preprocess.sh  |  119 -
 third_party/src/glog/src/windows/raw_logging.cc |  172 --
 third_party/src/glog/src/windows/utilities.cc   |  347 ---
 third_party/src/glog/src/windows/utilities.h    |  226 --
 third_party/src/glog/src/windows/vlog_is_on.cc  |  249 ---
 77 files changed, 45 insertions(+), 20990 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 60d8a2d..88835ac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -587,6 +587,7 @@ if(USE_TCMALLOC)
   if (COMPILER_HAS_WNO_RETURN_TYPE_C_LINKAGE)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage")
   endif()
+  include_directories(${CMAKE_CURRENT_BINARY_DIR}/third_party)
 endif()
 
 # Add Protocol Buffers.
@@ -649,7 +650,7 @@ if (WIN32)
   include_directories(${THIRD_PARTY_SOURCE_DIR}/glog/src/windows)
 else()
   include_directories(${THIRD_PARTY_SOURCE_DIR}/glog/src)
-  include_directories(${CMAKE_CURRENT_BINARY_DIR}/third_party)
+  include_directories(${CMAKE_CURRENT_BINARY_DIR}/third_party/glog)
 endif()
 
 include_directories("${THIRD_PARTY_SOURCE_DIR}/re2")

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/download_and_patch_prerequisites.sh
----------------------------------------------------------------------
diff --git a/third_party/download_and_patch_prerequisites.sh b/third_party/download_and_patch_prerequisites.sh
index b9b3d53..2295525 100755
--- a/third_party/download_and_patch_prerequisites.sh
+++ b/third_party/download_and_patch_prerequisites.sh
@@ -49,6 +49,7 @@ third_party_dir_names=("benchmark"
                        "linenoise"
                        "re2"
                        "gperftools"
+                       "glog"
                        )
 
 third_party_lib_urls=("https://github.com/google/benchmark/archive/v1.1.0.tar.gz"
@@ -57,6 +58,7 @@ third_party_lib_urls=("https://github.com/google/benchmark/archive/v1.1.0.tar.gz
                       "https://github.com/antirez/linenoise/archive/1.0.tar.gz"
                       "https://github.com/google/re2/archive/2017-01-01.tar.gz"
                       "https://github.com/gperftools/gperftools/releases/download/gperftools-2.5/gperftools-2.5.tar.gz"
+                      "https://github.com/google/glog/archive/v0.3.5.tar.gz"
                       )
 
 downloaded_archive_names=("v1.1.0.tar.gz"
@@ -65,6 +67,7 @@ downloaded_archive_names=("v1.1.0.tar.gz"
                           "1.0.tar.gz"
                           "2017-01-01.tar.gz"
                           "gperftools-2.5.tar.gz"
+                          "v0.3.5.tar.gz"
                           )
 
 tar_options=("-xzf"
@@ -73,6 +76,7 @@ tar_options=("-xzf"
              "-xzf"
              "-xzf"
              "-xzf"
+             "-xzf"
              )
 
 for ((lib_index=0; lib_index < ${#third_party_dir_names[*]}; lib_index++))
@@ -125,3 +129,7 @@ patch ${THIRD_PARTY_SRC_DIR}/re2/CMakeLists.txt ${PATCH_DIR}/re2/re2CMake.patch
 # Apply benchmark patches.
 patch ${THIRD_PARTY_SRC_DIR}/benchmark/CMakeLists.txt ${PATCH_DIR}/benchmark/benchmarkCMake.patch
 patch ${THIRD_PARTY_SRC_DIR}/benchmark/src/CMakeLists.txt ${PATCH_DIR}/benchmark/benchmarkSrcCMakeLists.patch
+
+# Apply glog patches.
+patch ${THIRD_PARTY_SRC_DIR}/glog/CMakeLists.txt ${PATCH_DIR}/glog/glogCMakeLists.txt.patch
+patch ${THIRD_PARTY_SRC_DIR}/glog/src/utilities.cc ${PATCH_DIR}/glog/utilities.cc.patch

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/patches/glog/glogCMakeLists.txt.patch
----------------------------------------------------------------------
diff --git a/third_party/patches/glog/glogCMakeLists.txt.patch b/third_party/patches/glog/glogCMakeLists.txt.patch
new file mode 100644
index 0000000..94c1d95
--- /dev/null
+++ b/third_party/patches/glog/glogCMakeLists.txt.patch
@@ -0,0 +1,23 @@
+--- CMakeLists.txt	2017-12-15 14:10:23.000000002 -0600
++++ CMakeLists-new.txt	2017-12-15 14:07:52.000000002 -0600
+@@ -26,7 +26,7 @@
+ set (CPACK_PACKAGE_VERSION_PATCH ${GLOG_PATCH_VERSION})
+ set (CPACK_PACKAGE_VERSION ${GLOG_VERSION})
+ 
+-option (WITH_GFLAGS "Use gflags" ON)
++option (WITH_GFLAGS "Use gflags" OFF)
+ option (WITH_THREADS "Enable multithreading support" ON)
+ 
+ list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+@@ -377,6 +377,11 @@
+ 
+ add_compile_options ($<$<BOOL:${HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS}>:-Wno-unnamed-type-template-args>)
+ 
++CHECK_CXX_COMPILER_FLAG("-Wno-sign-compare" COMPILER_HAS_WNO_SIGN_ERROR)
++if (COMPILER_HAS_WNO_SIGN_ERROR)
++  add_compile_options(-Wno-sign-compare)
++endif()
++
+ add_library (glog
+   ${GLOG_SRCS}
+ )

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/patches/glog/utilities.cc.patch
----------------------------------------------------------------------
diff --git a/third_party/patches/glog/utilities.cc.patch b/third_party/patches/glog/utilities.cc.patch
new file mode 100644
index 0000000..cdd626f
--- /dev/null
+++ b/third_party/patches/glog/utilities.cc.patch
@@ -0,0 +1,11 @@
+--- utilities.cc	2017-12-15 14:10:40.000000002 -0600
++++ utilities.cc.new	2017-12-15 14:08:13.000000002 -0600
+@@ -300,7 +300,7 @@
+     g_my_user_name = "invalid-user";
+   }
+ }
+-REGISTER_MODULE_INITIALIZER(utilities, MyUserNameInitializer());
++REGISTER_MODULE_INITIALIZER(utilities, MyUserNameInitializer())
+ 
+ #ifdef HAVE_STACKTRACE
+ void DumpStackTraceToString(string* stacktrace) {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/reset_third_party_dir.sh
----------------------------------------------------------------------
diff --git a/third_party/reset_third_party_dir.sh b/third_party/reset_third_party_dir.sh
index 3c04381..a98ee3e 100755
--- a/third_party/reset_third_party_dir.sh
+++ b/third_party/reset_third_party_dir.sh
@@ -32,6 +32,7 @@ third_party_dir_names=("benchmark"
                        "linenoise"
                        "re2"
                        "gperftools"
+                       "glog"
                        )
 
 for ((lib_index=0; lib_index < ${#third_party_dir_names[*]}; lib_index++))

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/AUTHORS
----------------------------------------------------------------------
diff --git a/third_party/src/glog/AUTHORS b/third_party/src/glog/AUTHORS
deleted file mode 100644
index ee92be8..0000000
--- a/third_party/src/glog/AUTHORS
+++ /dev/null
@@ -1,2 +0,0 @@
-opensource@google.com
-

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/third_party/src/glog/CMakeLists.txt b/third_party/src/glog/CMakeLists.txt
deleted file mode 100644
index a916b96..0000000
--- a/third_party/src/glog/CMakeLists.txt
+++ /dev/null
@@ -1,208 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# This file allows building glog with CMake instead of autotools. glog itself
-# is copyright Google, Inc. and is covered by the license described in the
-# COPYING file in this directory.
-
-if(CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang"))
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
-endif()
-
-if (WIN32)
-  # Windows uses a preprocessed config file and some other wierdness.
-  set_property(
-    DIRECTORY
-    APPEND PROPERTY COMPILE_DEFINITIONS GOOGLE_GLOG_DLL_DECL=
-  )
-
-  # Check if snprintf is available. It usually isn't on Windows, but MinGW
-  # provides it.
-  include(CheckCXXSymbolExists)
-  check_cxx_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
-
-  # Similarly, check if pid_t is defined in process.h. Usually the answer is no
-  # on Windows, but MinGW has it.
-  include(CheckTypeSize)
-  check_type_size("pid_t" PID_T)
-  configure_file (
-    "${CMAKE_CURRENT_SOURCE_DIR}/src/windows/config_cmake.h.in"
-    "${CMAKE_CURRENT_BINARY_DIR}/config.h"
-  )
-  include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-  include_directories(src/windows)
-  add_library(glog
-              src/windows/logging.cc
-              src/windows/port.cc
-              src/windows/raw_logging.cc
-              src/windows/utilities.cc
-              src/windows/vlog_is_on.cc)
-else()
-  # The big, happy UNIX family (and friends).
-
-  # System headers.
-  include(CheckIncludeFileCXX)
-  check_include_file_cxx(dlfcn.h HAVE_DLFCN_H)
-  check_include_file_cxx(execinfo.h HAVE_EXECINFO_H)
-  check_include_file_cxx(glob.h HAVE_GLOB_H)
-  check_include_file_cxx(inttypes.h HAVE_INTTYPES_H)
-  check_include_file_cxx(libunwind.h HAVE_LIBUNWIND_H)
-  check_include_file_cxx(memory.h HAVE_MEMORY_H)
-  check_include_file_cxx(pwd.h HAVE_PWD_H)
-  check_include_file_cxx(libunwind.h HAVE_LIBUNWIND_H)
-  check_include_file_cxx(stdint.h HAVE_STDINT_H)
-  check_include_file_cxx(stdlib.h HAVE_STDLIB_H)
-  check_include_file_cxx(strings.h HAVE_STRINGS_H)
-  check_include_file_cxx(string.h HAVE_STRING_H)
-  check_include_file_cxx(syscall.h HAVE_SYSCALL_H)
-  check_include_file_cxx(syslog.h HAVE_SYSLOG_H)
-  check_include_file_cxx(sys/stat.h HAVE_SYS_STAT_H)
-  check_include_file_cxx(sys/syscall.h HAVE_SYS_SYSCALL_H)
-  check_include_file_cxx(sys/time.h HAVE_SYS_TIME_H)
-  check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H)
-  check_include_file_cxx(sys/ucontext.h HAVE_SYS_UCONTEXT_H)
-  check_include_file_cxx(sys/utsname.h HAVE_SYS_UTSNAME_H)
-  check_include_file_cxx(ucontext.h HAVE_UCONTEXT_H)
-  check_include_file_cxx(unistd.h HAVE_UNISTD_H)
-  check_include_file_cxx(unwind.h HAVE_UNWIND_H)
-
-  # Check if functions exist.
-  include(CheckFunctionExists)
-  check_function_exists(fcntl HAVE_FCNTL)
-  check_function_exists(sigalstack HAVE_SIGALSTACK)
-
-  # Check if we are using pthreads.
-  find_package(Threads)
-  if (CMAKE_HAVE_PTHREAD_H)
-    set(HAVE_LIBPTHREAD 1)
-    set(HAVE_PTHREAD 1)
-    set(HAVE_RWLOCK 1)
-  endif()
-
-  # Check pointer size.
-  include(CheckTypeSize)
-  check_type_size("void*" SIZEOF_VOID_P)
-
-  # Check compiler builtins.
-  include(CheckCXXSourceCompiles)
-
-  CHECK_CXX_SOURCE_COMPILES("
-    int main(int argc, char **argv) {
-      if (__builtin_expect(argc, 1)) {
-        return 0;
-      } else {
-        return argc;
-      }
-    }
-  " HAVE___BUILTIN_EXPECT)
-
-  CHECK_CXX_SOURCE_COMPILES("
-    int numfun(int n) __attribute__((const));
-
-    int main(int argc, char **argv) {
-      return numfun(argc);
-    }
-
-    int numfun(int n) {
-      return n + 1;
-    }
-  " HAVE___ATTRIBUTE__)
-
-  CHECK_CXX_SOURCE_COMPILES("
-    int atomicswap(int *ptr, int oldval, int newval) {
-      return __sync_val_compare_and_swap(ptr, oldval, newval);
-    }
-
-    int main(int argc, char **argv) {
-      return atomicswap(&argc, 1, 2);
-    }
-  " HAVE___SYNC_VAL_COMPARE_AND_SWAP)
-
-  # Try a bunch of different platform-specific ways to get the program counter
-  # from a ucontext_t. This particular code snippet is based on Apache-licensed
-  # code from https://maiter.googlecode.com/svn/trunk/Maiter/cmake/PcFromUcontext.cmake
-  set(UCONTEXT_INCLUDES)
-  if (HAVE_SYS_UCONTEXT_H)
-    set(UCONTEXT_INCLUDES "${UCONTEXT_INCLUDES}\n#include <sys/ucontext.h>")
-  endif()
-  if (HAVE_UCONTEXT_H)
-    set(UCONTEXT_INCLUDES "${UCONTEXT_INCLUDES}\n#include <ucontext.h>")
-  endif()
-
-  foreach (pc_field
-           "uc_mcontext.gregs[REG_EIP]"
-           "uc_mcontext.gregs[REG_RIP]"
-           "uc_mcontext.sc_ip"
-           "uc_mcontext.uc_regs->gregs[PT_NIP]"
-           "uc_mcontext.gregs[R15]"
-           "uc_mcontext.arm_pc"
-           "uc_mcontext.mc_eip"
-           "uc_mcontext.mc_rip"
-           "uc_mcontext.__gregs[_REG_EIP]"
-           "uc_mcontext.__gregs[_REG_RIP]"
-           "uc_mcontext->ss.eip"
-           "uc_mcontext->__ss.__eip"
-           "uc_mcontext->ss.rip"
-           "uc_mcontext->__ss.__rip"
-           "uc_mcontext->ss.srr0"
-           "uc_mcontext->__ss.__srr0")
-    message(STATUS "Checking program counter fetch from ucontext_t member: ${pc_field}")
-
-    CHECK_CXX_SOURCE_COMPILES("
-      ${UCONTEXT_INCLUDES}
-      int main(int argc, char **argv) {
-        ucontext_t ctx;
-        return ctx.${pc_field} == 0;
-      }
-    " PC_FROM_UCONTEXT_COMPILES)
-
-    if (PC_FROM_UCONTEXT_COMPILES)
-      unset(PC_FROM_UCONTEXT_COMPILES CACHE)
-      message(STATUS "Found program counter field in ucontext_t: ${pc_field}")
-      set(PC_FROM_UCONTEXT ${pc_field})
-      break()
-    else()
-      unset(PC_FROM_UCONTEXT_COMPILES CACHE)
-    endif()
-  endforeach()
-
-  if (NOT PC_FROM_UCONTEXT)
-    message(WARNING "Unable to find program counter field in ucontext_t. GLOG "
-                    "signal handler will not be able to report precise PC "
-                    "position.")
-  endif()
-
-  # Generate config.h
-  configure_file (
-    "${CMAKE_CURRENT_SOURCE_DIR}/src/config_cmake.h.in"
-    "${CMAKE_CURRENT_BINARY_DIR}/config.h"
-  )
-  include_directories(${CMAKE_CURRENT_BINARY_DIR})
-  include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
-
-  include_directories(src)
-  add_library(glog
-              src/demangle.cc
-              src/logging.cc
-              src/raw_logging.cc
-              src/signalhandler.cc
-              src/symbolize.cc
-              src/utilities.cc
-              src/vlog_is_on.cc)
-  target_link_libraries(glog ${CMAKE_THREAD_LIBS_INIT})
-endif()

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/COPYING
----------------------------------------------------------------------
diff --git a/third_party/src/glog/COPYING b/third_party/src/glog/COPYING
deleted file mode 100644
index 38396b5..0000000
--- a/third_party/src/glog/COPYING
+++ /dev/null
@@ -1,65 +0,0 @@
-Copyright (c) 2008, Google Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
-    * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-A function gettimeofday in utilities.cc is based on
-
-http://www.google.com/codesearch/p?hl=en#dR3YEbitojA/COPYING&q=GetSystemTimeAsFileTime%20license:bsd
-
-The license of this code is:
-
-Copyright (c) 2003-2008, Jouni Malinen <j...@w1.fi> and contributors
-All Rights Reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-3. Neither the name(s) of the above-listed copyright holder(s) nor the
-   names of its contributors may be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/ChangeLog
----------------------------------------------------------------------
diff --git a/third_party/src/glog/ChangeLog b/third_party/src/glog/ChangeLog
deleted file mode 100644
index d1b4248..0000000
--- a/third_party/src/glog/ChangeLog
+++ /dev/null
@@ -1,84 +0,0 @@
-2013-02-01  Google Inc. <op...@google.com>
-
-	* google-glog: version 0.3.3
-	* Add --disable-rtti option for configure.
-	* Visual Studio build and test fix.
-	* QNX build fix (thanks vanuan).
-	* Reduce warnings.
-	* Fixed LOG_SYSRESULT (thanks ukai).
-	* FreeBSD build fix (thanks yyanagisawa).
-	* Clang build fix.
-	* Now users can re-initialize glog after ShutdownGoogleLogging.
-	* Color output support by GLOG_colorlogtostderr (thanks alexs).
-	* Now glog's ABI around flags are compatible with gflags.
-	* Document mentions how to modify flags from user programs.
-
-2012-01-12  Google Inc. <op...@google.com>
-
-	* google-glog: version 0.3.2
-	* Clang support.
-	* Demangler and stacktrace improvement for newer GCCs.
-	* Now fork(2) doesn't mess up log files.
-	* Make valgrind happier.
-	* Reduce warnings for more -W options.
-	* Provide a workaround for ERROR defined by windows.h.
-
-2010-06-15  Google Inc. <op...@google.com>
-
-	* google-glog: version 0.3.1
-	* GLOG_* environment variables now work even when gflags is installed.
-	* Snow leopard support.
-	* Now we can build and test from out side tree.
-	* Add DCHECK_NOTNULL.
-	* Add ShutdownGoogleLogging to close syslog (thanks DGunchev)
-	* Fix --enable-frame-pointers option (thanks kazuki.ohta)
-	* Fix libunwind detection (thanks giantchen)
-
-2009-07-30  Google Inc. <op...@google.com>
-
-	* google-glog: version 0.3.0
-	* Fix a deadlock happened when user uses glog with recent gflags.
-	* Suppress several unnecessary warnings (thanks keir).
-	* NetBSD and OpenBSD support.
-	* Use Win32API GetComputeNameA properly (thanks magila).
-	* Fix user name detection for Windows (thanks ademin).
-	* Fix several minor bugs.
-
-2009-04-10  Google Inc. <op...@google.com>
-	* google-glog: version 0.2.1
-	* Fix timestamps of VC++ version.
-	* Add pkg-config support (thanks Tomasz)
-	* Fix build problem when building with gtest (thanks Michael)
-	* Add --with-gflags option for configure (thanks Michael)
-	* Fixes for GCC 4.4 (thanks John)
-
-2009-01-23  Google Inc. <op...@google.com>
-	* google-glog: version 0.2
-	* Add initial Windows VC++ support.
-	* Google testing/mocking frameworks integration.
-	* Link pthread library automatically.
-	* Flush logs in signal handlers.
-	* Add macros LOG_TO_STRING, LOG_AT_LEVEL, DVLOG, and LOG_TO_SINK_ONLY.
-	* Log microseconds.
-	* Add --log_backtrace_at option.
-	* Fix some minor bugs.
-
-2008-11-18  Google Inc. <op...@google.com>
-	* google-glog: version 0.1.2
-	* Add InstallFailureSignalHandler(). (satorux)
-	* Re-organize the way to produce stacktraces.
-	* Don't define unnecessary macro DISALLOW_EVIL_CONSTRUCTORS.
-
-2008-10-15  Google Inc. <op...@google.com>
-	* google-glog: version 0.1.1
-	* Support symbolize for MacOSX 10.5.
-	* BUG FIX: --vmodule didn't work with gflags.
-	* BUG FIX: symbolize_unittest failed with GCC 4.3.
-	* Several fixes on the document.
-
-2008-10-07  Google Inc. <op...@google.com>
-
-	* google-glog: initial release:
-	The glog package contains a library that implements application-level
-	logging.  This library provides logging APIs based on C++-style
-	streams and various helper macros.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/INSTALL
----------------------------------------------------------------------
diff --git a/third_party/src/glog/INSTALL b/third_party/src/glog/INSTALL
deleted file mode 100644
index 0babe24..0000000
--- a/third_party/src/glog/INSTALL
+++ /dev/null
@@ -1,297 +0,0 @@
-Installation Instructions
-*************************
-
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006, 2007 Free Software Foundation, Inc.
-
-This file is free documentation; the Free Software Foundation gives
-unlimited permission to copy, distribute and modify it.
-
-Glog-Specific Install Notes
-================================
-
-*** NOTE FOR 64-BIT LINUX SYSTEMS
-
-The glibc built-in stack-unwinder on 64-bit systems has some problems
-with the glog libraries.  (In particular, if you are using
-InstallFailureSignalHandler(), the signal may be raised in the middle
-of malloc, holding some malloc-related locks when they invoke the
-stack unwinder.  The built-in stack unwinder may call malloc
-recursively, which may require the thread to acquire a lock it already
-holds: deadlock.)
-
-For that reason, if you use a 64-bit system and you need
-InstallFailureSignalHandler(), we strongly recommend you install
-libunwind before trying to configure or install google glog.
-libunwind can be found at
-
-   http://download.savannah.nongnu.org/releases/libunwind/libunwind-snap-070410.tar.gz
-
-Even if you already have libunwind installed, you will probably still
-need to install from the snapshot to get the latest version.
-
-CAUTION: if you install libunwind from the URL above, be aware that
-you may have trouble if you try to statically link your binary with
-glog: that is, if you link with 'gcc -static -lgcc_eh ...'.  This
-is because both libunwind and libgcc implement the same C++ exception
-handling APIs, but they implement them differently on some platforms.
-This is not likely to be a problem on ia64, but may be on x86-64.
-
-Also, if you link binaries statically, make sure that you add
--Wl,--eh-frame-hdr to your linker options. This is required so that
-libunwind can find the information generated by the compiler required
-for stack unwinding.
-
-Using -static is rare, though, so unless you know this will affect you
-it probably won't.
-
-If you cannot or do not wish to install libunwind, you can still try
-to use two kinds of stack-unwinder: 1. glibc built-in stack-unwinder
-and 2. frame pointer based stack-unwinder.
-
-1. As we already mentioned, glibc's unwinder has a deadlock issue.
-However, if you don't use InstallFailureSignalHandler() or you don't
-worry about the rare possibilities of deadlocks, you can use this
-stack-unwinder.  If you specify no options and libunwind isn't
-detected on your system, the configure script chooses this unwinder by
-default.
-
-2. The frame pointer based stack unwinder requires that your
-application, the glog library, and system libraries like libc, all be
-compiled with a frame pointer.  This is *not* the default for x86-64.
-
-If you are on x86-64 system, know that you have a set of system
-libraries with frame-pointers enabled, and compile all your
-applications with -fno-omit-frame-pointer, then you can enable the
-frame pointer based stack unwinder by passing the
---enable-frame-pointers flag to configure.
-
-
-Basic Installation
-==================
-
-Briefly, the shell commands `./configure; make; make install' should
-configure, build, and install this package.  The following
-more-detailed instructions are generic; see the `README' file for
-instructions specific to this package.
-
-   The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation.  It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions.  Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
-
-   It can also use an optional file (typically called `config.cache'
-and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring.  Caching is
-disabled by default to prevent problems with accidental use of stale
-cache files.
-
-   If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release.  If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
-may remove or edit it.
-
-   The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'.  You need `configure.ac' if
-you want to change it or regenerate `configure' using a newer version
-of `autoconf'.
-
-The simplest way to compile this package is:
-
-  1. `cd' to the directory containing the package's source code and type
-     `./configure' to configure the package for your system.
-
-     Running `configure' might take a while.  While running, it prints
-     some messages telling which features it is checking for.
-
-  2. Type `make' to compile the package.
-
-  3. Optionally, type `make check' to run any self-tests that come with
-     the package.
-
-  4. Type `make install' to install the programs and any data files and
-     documentation.
-
-  5. You can remove the program binaries and object files from the
-     source code directory by typing `make clean'.  To also remove the
-     files that `configure' created (so you can compile the package for
-     a different kind of computer), type `make distclean'.  There is
-     also a `make maintainer-clean' target, but that is intended mainly
-     for the package's developers.  If you use it, you may have to get
-     all sorts of other programs in order to regenerate files that came
-     with the distribution.
-
-  6. Often, you can also type `make uninstall' to remove the installed
-     files again.
-
-Compilers and Options
-=====================
-
-Some systems require unusual options for compilation or linking that the
-`configure' script does not know about.  Run `./configure --help' for
-details on some of the pertinent environment variables.
-
-   You can give `configure' initial values for configuration parameters
-by setting variables in the command line or in the environment.  Here
-is an example:
-
-     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
-
-   *Note Defining Variables::, for more details.
-
-Compiling For Multiple Architectures
-====================================
-
-You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory.  To do this, you can use GNU `make'.  `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script.  `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.
-
-   With a non-GNU `make', it is safer to compile the package for one
-architecture at a time in the source code directory.  After you have
-installed the package for one architecture, use `make distclean' before
-reconfiguring for another architecture.
-
-Installation Names
-==================
-
-By default, `make install' installs the package's commands under
-`/usr/local/bin', include files under `/usr/local/include', etc.  You
-can specify an installation prefix other than `/usr/local' by giving
-`configure' the option `--prefix=PREFIX'.
-
-   You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files.  If you
-pass the option `--exec-prefix=PREFIX' to `configure', the package uses
-PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files still use the regular prefix.
-
-   In addition, if you use an unusual directory layout you can give
-options like `--bindir=DIR' to specify different values for particular
-kinds of files.  Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
-
-   If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-Optional Features
-=================
-
-Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System).  The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
-   For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
-Specifying the System Type
-==========================
-
-There may be some features `configure' cannot figure out automatically,
-but needs to determine by the type of machine the package will run on.
-Usually, assuming the package is built to be run on the _same_
-architectures, `configure' can figure that out, but if it prints a
-message saying it cannot guess the machine type, give it the
-`--build=TYPE' option.  TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name which has the form:
-
-     CPU-COMPANY-SYSTEM
-
-where SYSTEM can have one of these forms:
-
-     OS KERNEL-OS
-
-   See the file `config.sub' for the possible values of each field.  If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the machine type.
-
-   If you are _building_ compiler tools for cross-compiling, you should
-use the option `--target=TYPE' to select the type of system they will
-produce code for.
-
-   If you want to _use_ a cross compiler, that generates code for a
-platform different from the build platform, you should specify the
-"host" platform (i.e., that on which the generated programs will
-eventually be run) with `--host=TYPE'.
-
-Sharing Defaults
-================
-
-If you want to set default values for `configure' scripts to share, you
-can create a site shell script called `config.site' that gives default
-values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists.  Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-Defining Variables
-==================
-
-Variables not defined in a site shell script can be set in the
-environment passed to `configure'.  However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost.  In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'.  For example:
-
-     ./configure CC=/usr/local2/bin/gcc
-
-causes the specified `gcc' to be used as the C compiler (unless it is
-overridden in the site shell script).
-
-Unfortunately, this technique does not work for `CONFIG_SHELL' due to
-an Autoconf bug.  Until the bug is fixed you can use this workaround:
-
-     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
-
-`configure' Invocation
-======================
-
-`configure' recognizes the following options to control how it operates.
-
-`--help'
-`-h'
-     Print a summary of the options to `configure', and exit.
-
-`--version'
-`-V'
-     Print the version of Autoconf used to generate the `configure'
-     script, and exit.
-
-`--cache-file=FILE'
-     Enable the cache: use and save the results of the tests in FILE,
-     traditionally `config.cache'.  FILE defaults to `/dev/null' to
-     disable caching.
-
-`--config-cache'
-`-C'
-     Alias for `--cache-file=config.cache'.
-
-`--quiet'
-`--silent'
-`-q'
-     Do not print messages saying which checks are being made.  To
-     suppress all normal output, redirect it to `/dev/null' (any error
-     messages will still be shown).
-
-`--srcdir=DIR'
-     Look for the package's source code in directory DIR.  Usually
-     `configure' can determine that directory automatically.
-
-`configure' also accepts some other, not widely useful, options.  Run
-`configure --help' for more details.
-

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/NEWS
----------------------------------------------------------------------
diff --git a/third_party/src/glog/NEWS b/third_party/src/glog/NEWS
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/README
----------------------------------------------------------------------
diff --git a/third_party/src/glog/README b/third_party/src/glog/README
deleted file mode 100644
index 77efd37..0000000
--- a/third_party/src/glog/README
+++ /dev/null
@@ -1,5 +0,0 @@
-This repository contains a C++ implementation of the Google logging
-module.  Documentation for the implementation is in doc/.
-
-See INSTALL for (generic) installation instructions for C++: basically
-   ./configure && make && make install

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/README.windows
----------------------------------------------------------------------
diff --git a/third_party/src/glog/README.windows b/third_party/src/glog/README.windows
deleted file mode 100644
index 74ff690..0000000
--- a/third_party/src/glog/README.windows
+++ /dev/null
@@ -1,26 +0,0 @@
-This project has begun being ported to Windows.  A working solution
-file exists in this directory:
-    google-glog.sln
-
-You can load this solution file into VC++ 9.0 (Visual Studio
-2008).  You may also be able to use this solution file with older
-Visual Studios by converting the solution file.
-
-Note that stack tracing and some unittests are not ported
-yet.
-
-You can also link glog code in statically -- see the example project
-libglog_static and logging_unittest_static, which does this.  For this
-to work, you'll need to add "/D GOOGLE_GLOG_DLL_DECL=" to the compile
-line of every glog's .cc file.
-
-I have little experience with Windows programming, so there may be
-better ways to set this up than I've done!  If you run across any
-problems, please post to the google-glog Google Group, or report
-them on the google-glog Google Code site:
-   http://groups.google.com/group/google-glog
-   http://code.google.com/p/google-glog/issues/list
-
--- Shinichiro Hamaji
-
-Last modified: 23 January 2009

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/doc/designstyle.css
----------------------------------------------------------------------
diff --git a/third_party/src/glog/doc/designstyle.css b/third_party/src/glog/doc/designstyle.css
deleted file mode 100644
index f5d1ec2..0000000
--- a/third_party/src/glog/doc/designstyle.css
+++ /dev/null
@@ -1,115 +0,0 @@
-body {
-  background-color: #ffffff;
-  color: black;
-  margin-right: 1in;
-  margin-left: 1in;
-}
-
-
-h1, h2, h3, h4, h5, h6 {
-  color: #3366ff;
-  font-family: sans-serif;
-}
-@media print {
-  /* Darker version for printing */
-  h1, h2, h3, h4, h5, h6 {
-    color: #000080;
-    font-family: helvetica, sans-serif;
-  }
-}
-
-h1 { 
-  text-align: center;
-  font-size: 18pt;
-}
-h2 {
-  margin-left: -0.5in;
-}
-h3 {
-  margin-left: -0.25in;
-}
-h4 {
-  margin-left: -0.125in;
-}
-hr {
-  margin-left: -1in;
-}
-
-/* Definition lists: definition term bold */
-dt {
-  font-weight: bold;
-}
-
-address {
-  text-align: right;
-}
-/* Use the <code> tag for bits of code and <var> for variables and objects. */
-code,pre,samp,var {
-  color: #006000;
-}
-/* Use the <file> tag for file and directory paths and names. */
-file {
-  color: #905050;
-  font-family: monospace;
-}
-/* Use the <kbd> tag for stuff the user should type. */
-kbd {
-  color: #600000;
-}
-div.note p {
-  float: right;
-  width: 3in;
-  margin-right: 0%;
-  padding: 1px;
-  border: 2px solid #6060a0;
-  background-color: #fffff0;
-}
-
-UL.nobullets {
-  list-style-type: none;
-  list-style-image: none;
-  margin-left: -1em;
-}
-
-/*
-body:after {
-  content: "Google Confidential";
-}
-*/
-
-/* pretty printing styles.  See prettify.js */
-.str { color: #080; }
-.kwd { color: #008; }
-.com { color: #800; }
-.typ { color: #606; }
-.lit { color: #066; }
-.pun { color: #660; }
-.pln { color: #000; }
-.tag { color: #008; }
-.atn { color: #606; }
-.atv { color: #080; }
-pre.prettyprint { padding: 2px; border: 1px solid #888; }
-
-.embsrc { background: #eee; }
-
-@media print {
-  .str { color: #060; }
-  .kwd { color: #006; font-weight: bold; }
-  .com { color: #600; font-style: italic; }
-  .typ { color: #404; font-weight: bold; }
-  .lit { color: #044; }
-  .pun { color: #440; }
-  .pln { color: #000; }
-  .tag { color: #006; font-weight: bold; }
-  .atn { color: #404; }
-  .atv { color: #060; }
-}
-
-/* Table Column Headers */
-.hdr { 
-  color: #006; 
-  font-weight: bold; 
-  background-color: #dddddd; }
-.hdr2 { 
-  color: #006; 
-  background-color: #eeeeee; }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/doc/glog.html
----------------------------------------------------------------------
diff --git a/third_party/src/glog/doc/glog.html b/third_party/src/glog/doc/glog.html
deleted file mode 100644
index 8b200ba..0000000
--- a/third_party/src/glog/doc/glog.html
+++ /dev/null
@@ -1,613 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
-<title>How To Use Google Logging Library (glog)</title>
-
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-<link href="http://www.google.com/favicon.ico" type="image/x-icon"
-      rel="shortcut icon">
-<link href="designstyle.css" type="text/css" rel="stylesheet">
-<style type="text/css">
-<!--
-  ol.bluelist li {
-    color: #3366ff;
-    font-family: sans-serif;
-  }
-  ol.bluelist li p {
-    color: #000;
-    font-family: "Times Roman", times, serif;
-  }
-  ul.blacklist li {
-    color: #000;
-    font-family: "Times Roman", times, serif;
-  }
-//-->
-</style>
-</head>
-
-<body>
-
-<h1>How To Use Google Logging Library (glog)</h1>
-<small>(as of
-<script type=text/javascript>
-  var lm = new Date(document.lastModified);
-  document.write(lm.toDateString());
-</script>)
-</small>
-<br>
-
-<h2> <A NAME=intro>Introduction</A> </h2>
-
-<p><b>Google glog</b> is a library that implements application-level
-logging.  This library provides logging APIs based on C++-style
-streams and various helper macros.
-You can log a message by simply streaming things to LOG(&lt;a
-particular <a href="#severity">severity level</a>&gt;), e.g.
-
-<pre>
-   #include &lt;glog/logging.h&gt;
-
-   int main(int argc, char* argv[]) {
-     // Initialize Google's logging library.
-     google::InitGoogleLogging(argv[0]);
-
-     // ...
-     LOG(INFO) &lt;&lt; "Found " &lt;&lt; num_cookies &lt;&lt; " cookies";
-   }
-</pre>
-
-<p>Google glog defines a series of macros that simplify many common logging
-tasks.  You can log messages by severity level, control logging
-behavior from the command line, log based on conditionals, abort the
-program when expected conditions are not met, introduce your own
-verbose logging levels, and more.  This document describes the
-functionality supported by glog.  Please note that this document
-doesn't describe all features in this library, but the most useful
-ones.  If you want to find less common features, please check
-header files under <code>src/glog</code> directory.
-
-<h2> <A NAME=severity>Severity Level</A> </h2>
-
-<p>
-You can specify one of the following severity levels (in
-increasing order of severity): <code>INFO</code>, <code>WARNING</code>,
-<code>ERROR</code>, and <code>FATAL</code>.
-Logging a <code>FATAL</code> message terminates the program (after the
-message is logged).
-Note that messages of a given severity are logged not only in the
-logfile for that severity, but also in all logfiles of lower severity.
-E.g., a message of severity <code>FATAL</code> will be logged to the
-logfiles of severity <code>FATAL</code>, <code>ERROR</code>,
-<code>WARNING</code>, and <code>INFO</code>.
-
-<p>
-The <code>DFATAL</code> severity logs a <code>FATAL</code> error in
-debug mode (i.e., there is no <code>NDEBUG</code> macro defined), but
-avoids halting the program in production by automatically reducing the
-severity to <code>ERROR</code>.
-
-<p>Unless otherwise specified, glog writes to the filename
-"/tmp/&lt;program name&gt;.&lt;hostname&gt;.&lt;user name&gt;.log.&lt;severity level&gt;.&lt;date&gt;.&lt;time&gt;.&lt;pid&gt;"
-(e.g., "/tmp/hello_world.example.com.hamaji.log.INFO.20080709-222411.10474").
-By default, glog copies the log messages of severity level
-<code>ERROR</code> or <code>FATAL</code> to standard error (stderr)
-in addition to log files.
-
-<h2><A NAME=flags>Setting Flags</A></h2>
-
-<p>Several flags influence glog's output behavior.
-If the <a href="http://code.google.com/p/google-gflags/">Google
-gflags library</a> is installed on your machine, the
-<code>configure</code> script (see the INSTALL file in the package for
-detail of this script) will automatically detect and use it,
-allowing you to pass flags on the command line.  For example, if you
-want to turn the flag <code>--logtostderr</code> on, you can start
-your application with the following command line:
-
-<pre>
-   ./your_application --logtostderr=1
-</pre>
-
-If the Google gflags library isn't installed, you set flags via
-environment variables, prefixing the flag name with "GLOG_", e.g.
-
-<pre>
-   GLOG_logtostderr=1 ./your_application
-</pre>
-
-<!-- TODO(hamaji): Fill the version number
-<p>By glog version 0.x.x, you can use GLOG_* environment variables
-even if you have gflags. If both an environment variable and a flag
-are specified, the value specified by a flag wins. E.g., if GLOG_v=0
-and --v=1, the verbosity will be 1, not 0.
--->
-
-<p>The following flags are most commonly used:
-
-<dl>
-<dt><code>logtostderr</code> (<code>bool</code>, default=<code>false</code>)
-<dd>Log messages to stderr instead of logfiles.<br>
-Note: you can set binary flags to <code>true</code> by specifying
-<code>1</code>, <code>true</code>, or <code>yes</code> (case
-insensitive).
-Also, you can set binary flags to <code>false</code> by specifying
-<code>0</code>, <code>false</code>, or <code>no</code> (again, case
-insensitive).
-<dt><code>stderrthreshold</code> (<code>int</code>, default=2, which
-is <code>ERROR</code>)
-<dd>Copy log messages at or above this level to stderr in
-addition to logfiles.  The numbers of severity levels
-<code>INFO</code>, <code>WARNING</code>, <code>ERROR</code>, and
-<code>FATAL</code> are 0, 1, 2, and 3, respectively.
-<dt><code>minloglevel</code> (<code>int</code>, default=0, which
-is <code>INFO</code>)
-<dd>Log messages at or above this level.  Again, the numbers of
-severity levels <code>INFO</code>, <code>WARNING</code>,
-<code>ERROR</code>, and <code>FATAL</code> are 0, 1, 2, and 3,
-respectively.
-<dt><code>log_dir</code> (<code>string</code>, default="")
-<dd>If specified, logfiles are written into this directory instead
-of the default logging directory.
-<dt><code>v</code> (<code>int</code>, default=0)
-<dd>Show all <code>VLOG(m)</code> messages for <code>m</code> less or
-equal the value of this flag.  Overridable by --vmodule.
-See <a href="#verbose">the section about verbose logging</a> for more
-detail.
-<dt><code>vmodule</code> (<code>string</code>, default="")
-<dd>Per-module verbose level.  The argument has to contain a
-comma-separated list of &lt;module name&gt;=&lt;log level&gt;.
-&lt;module name&gt;
-is a glob pattern (e.g., <code>gfs*</code> for all modules whose name
-starts with "gfs"), matched against the filename base
-(that is, name ignoring .cc/.h./-inl.h).
-&lt;log level&gt; overrides any value given by --v.
-See also <a href="#verbose">the section about verbose logging</a>.
-</dl>
-
-<p>There are some other flags defined in logging.cc.  Please grep the
-source code for "DEFINE_" to see a complete list of all flags.
-
-<p>You can also modify flag values in your program by modifying global
-variables <code>FLAGS_*</code> . Most settings start working
-immediately after you update <code>FLAGS_*</code> . The exceptions are
-the flags related to destination files. For example, you might want to
-set <code>FLAGS_log_dir</code> before
-calling <code>google::InitGoogleLogging</code> . Here is an example:
-
-<pre>
-   LOG(INFO) << "file";
-   // Most flags work immediately after updating values.
-   FLAGS_logtostderr = 1;
-   LOG(INFO) << "stderr";
-   FLAGS_logtostderr = 0;
-   // This won't change the log destination. If you want to set this
-   // value, you should do this before google::InitGoogleLogging .
-   FLAGS_log_dir = "/some/log/directory";
-   LOG(INFO) << "the same file";
-</pre>
-
-<h2><A NAME=conditional>Conditional / Occasional Logging</A></h2>
-
-<p>Sometimes, you may only want to log a message under certain
-conditions. You can use the following macros to perform conditional
-logging:
-
-<pre>
-   LOG_IF(INFO, num_cookies &gt; 10) &lt;&lt; "Got lots of cookies";
-</pre>
-
-The "Got lots of cookies" message is logged only when the variable
-<code>num_cookies</code> exceeds 10.
-
-If a line of code is executed many times, it may be useful to only log
-a message at certain intervals.  This kind of logging is most useful
-for informational messages.
-
-<pre>
-   LOG_EVERY_N(INFO, 10) &lt;&lt; "Got the " &lt;&lt; google::COUNTER &lt;&lt; "th cookie";
-</pre>
-
-<p>The above line outputs a log messages on the 1st, 11th,
-21st, ... times it is executed.  Note that the special
-<code>google::COUNTER</code> value is used to identify which repetition is
-happening.
-
-<p>You can combine conditional and occasional logging with the
-following macro.
-
-<pre>
-   LOG_IF_EVERY_N(INFO, (size &gt; 1024), 10) &lt;&lt; "Got the " &lt;&lt; google::COUNTER
-                                           &lt;&lt; "th big cookie";
-</pre>
-
-<p>Instead of outputting a message every nth time, you can also limit
-the output to the first n occurrences:
-
-<pre>
-   LOG_FIRST_N(INFO, 20) &lt;&lt; "Got the " &lt;&lt; google::COUNTER &lt;&lt; "th cookie";
-</pre>
-
-<p>Outputs log messages for the first 20 times it is executed.  Again,
-the <code>google::COUNTER</code> identifier indicates which repetition is
-happening.
-
-<h2><A NAME=debug>Debug Mode Support</A></h2>
-
-<p>Special "debug mode" logging macros only have an effect in debug
-mode and are compiled away to nothing for non-debug mode
-compiles.  Use these macros to avoid slowing down your production
-application due to excessive logging.
-
-<pre>
-   DLOG(INFO) &lt;&lt; "Found cookies";
-
-   DLOG_IF(INFO, num_cookies &gt; 10) &lt;&lt; "Got lots of cookies";
-
-   DLOG_EVERY_N(INFO, 10) &lt;&lt; "Got the " &lt;&lt; google::COUNTER &lt;&lt; "th cookie";
-</pre>
-
-<h2><A NAME=check>CHECK Macros</A></h2>
-
-<p>It is a good practice to check expected conditions in your program
-frequently to detect errors as early as possible. The
-<code>CHECK</code> macro provides the ability to abort the application
-when a condition is not met, similar to the <code>assert</code> macro
-defined in the standard C library.
-
-<p><code>CHECK</code> aborts the application if a condition is not
-true.  Unlike <code>assert</code>, it is *not* controlled by
-<code>NDEBUG</code>, so the check will be executed regardless of
-compilation mode.  Therefore, <code>fp-&gt;Write(x)</code> in the
-following example is always executed:
-
-<pre>
-   CHECK(fp-&gt;Write(x) == 4) &lt;&lt; "Write failed!";
-</pre>
-
-<p>There are various helper macros for
-equality/inequality checks - <code>CHECK_EQ</code>,
-<code>CHECK_NE</code>, <code>CHECK_LE</code>, <code>CHECK_LT</code>,
-<code>CHECK_GE</code>, and <code>CHECK_GT</code>.
-They compare two values, and log a
-<code>FATAL</code> message including the two values when the result is
-not as expected.  The values must have <code>operator&lt;&lt;(ostream,
-...)</code> defined.
-
-<p>You may append to the error message like so:
-
-<pre>
-   CHECK_NE(1, 2) &lt;&lt; ": The world must be ending!";
-</pre>
-
-<p>We are very careful to ensure that each argument is evaluated exactly
-once, and that anything which is legal to pass as a function argument is
-legal here.  In particular, the arguments may be temporary expressions
-which will end up being destroyed at the end of the apparent statement,
-for example:
-
-<pre>
-   CHECK_EQ(string("abc")[1], 'b');
-</pre>
-
-<p>The compiler reports an error if one of the arguments is a
-pointer and the other is NULL. To work around this, simply static_cast
-NULL to the type of the desired pointer.
-
-<pre>
-   CHECK_EQ(some_ptr, static_cast&lt;SomeType*&gt;(NULL));
-</pre>
-
-<p>Better yet, use the CHECK_NOTNULL macro:
-
-<pre>
-   CHECK_NOTNULL(some_ptr);
-   some_ptr-&gt;DoSomething();
-</pre>
-
-<p>Since this macro returns the given pointer, this is very useful in
-constructor initializer lists.
-
-<pre>
-   struct S {
-     S(Something* ptr) : ptr_(CHECK_NOTNULL(ptr)) {}
-     Something* ptr_;
-   };
-</pre>
-
-<p>Note that you cannot use this macro as a C++ stream due to this
-feature.  Please use <code>CHECK_EQ</code> described above to log a
-custom message before aborting the application.
-
-<p>If you are comparing C strings (char *), a handy set of macros
-performs case sensitive as well as case insensitive comparisons -
-<code>CHECK_STREQ</code>, <code>CHECK_STRNE</code>,
-<code>CHECK_STRCASEEQ</code>, and <code>CHECK_STRCASENE</code>.  The
-CASE versions are case-insensitive.  You can safely pass <code>NULL</code>
-pointers for this macro.  They treat <code>NULL</code> and any
-non-<code>NULL</code> string as not equal.  Two <code>NULL</code>s are
-equal.
-
-<p>Note that both arguments may be temporary strings which are
-destructed at the end of the current "full expression"
-(e.g., <code>CHECK_STREQ(Foo().c_str(), Bar().c_str())</code> where
-<code>Foo</code> and <code>Bar</code> return C++'s
-<code>std::string</code>).
-
-<p>The <code>CHECK_DOUBLE_EQ</code> macro checks the equality of two
-floating point values, accepting a small error margin.
-<code>CHECK_NEAR</code> accepts a third floating point argument, which
-specifies the acceptable error margin.
-
-<h2><A NAME=verbose>Verbose Logging</A></h2>
-
-<p>When you are chasing difficult bugs, thorough log messages are very
-useful.  However, you may want to ignore too verbose messages in usual
-development.  For such verbose logging, glog provides the
-<code>VLOG</code> macro, which allows you to define your own numeric
-logging levels.  The <code>--v</code> command line option controls
-which verbose messages are logged:
-
-<pre>
-   VLOG(1) &lt;&lt; "I'm printed when you run the program with --v=1 or higher";
-   VLOG(2) &lt;&lt; "I'm printed when you run the program with --v=2 or higher";
-</pre>
-
-<p>With <code>VLOG</code>, the lower the verbose level, the more
-likely messages are to be logged.  For example, if
-<code>--v==1</code>, <code>VLOG(1)</code> will log, but
-<code>VLOG(2)</code> will not log.  This is opposite of the severity
-level, where <code>INFO</code> is 0, and <code>ERROR</code> is 2.
-<code>--minloglevel</code> of 1 will log <code>WARNING</code> and
-above.  Though you can specify any integers for both <code>VLOG</code>
-macro and <code>--v</code> flag, the common values for them are small
-positive integers.  For example, if you write <code>VLOG(0)</code>,
-you should specify <code>--v=-1</code> or lower to silence it.  This
-is less useful since we may not want verbose logs by default in most
-cases.  The <code>VLOG</code> macros always log at the
-<code>INFO</code> log level (when they log at all).
-
-<p>Verbose logging can be controlled from the command line on a
-per-module basis:
-
-<pre>
-   --vmodule=mapreduce=2,file=1,gfs*=3 --v=0
-</pre>
-
-<p>will:
-
-<ul>
-  <li>a. Print VLOG(2) and lower messages from mapreduce.{h,cc}
-  <li>b. Print VLOG(1) and lower messages from file.{h,cc}
-  <li>c. Print VLOG(3) and lower messages from files prefixed with "gfs"
-  <li>d. Print VLOG(0) and lower messages from elsewhere
-</ul>
-
-<p>The wildcarding functionality shown by (c) supports both '*'
-(matches 0 or more characters) and '?' (matches any single character)
-wildcards.  Please also check the section about <a
-href="#flags">command line flags</a>.
-
-<p>There's also <code>VLOG_IS_ON(n)</code> "verbose level" condition
-macro.  This macro returns true when the <code>--v</code> is equal or
-greater than <code>n</code>.  To be used as
-
-<pre>
-   if (VLOG_IS_ON(2)) {
-     // do some logging preparation and logging
-     // that can't be accomplished with just VLOG(2) &lt;&lt; ...;
-   }
-</pre>
-
-<p>Verbose level condition macros <code>VLOG_IF</code>,
-<code>VLOG_EVERY_N</code> and <code>VLOG_IF_EVERY_N</code> behave
-analogous to <code>LOG_IF</code>, <code>LOG_EVERY_N</code>,
-<code>LOF_IF_EVERY</code>, but accept a numeric verbosity level as
-opposed to a severity level.
-
-<pre>
-   VLOG_IF(1, (size &gt; 1024))
-      &lt;&lt; "I'm printed when size is more than 1024 and when you run the "
-         "program with --v=1 or more";
-   VLOG_EVERY_N(1, 10)
-      &lt;&lt; "I'm printed every 10th occurrence, and when you run the program "
-         "with --v=1 or more. Present occurence is " &lt;&lt; google::COUNTER;
-   VLOG_IF_EVERY_N(1, (size &gt; 1024), 10)
-      &lt;&lt; "I'm printed on every 10th occurence of case when size is more "
-         " than 1024, when you run the program with --v=1 or more. ";
-         "Present occurence is " &lt;&lt; google::COUNTER;
-</pre>
-
-<h2> <A name="signal">Failure Signal Handler</A> </h2>
-
-<p>
-The library provides a convenient signal handler that will dump useful
-information when the program crashes on certain signals such as SIGSEGV.
-The signal handler can be installed by
-google::InstallFailureSignalHandler().  The following is an example of output
-from the signal handler.
-
-<pre>
-*** Aborted at 1225095260 (unix time) try "date -d @1225095260" if you are using GNU date ***
-*** SIGSEGV (@0x0) received by PID 17711 (TID 0x7f893090a6f0) from PID 0; stack trace: ***
-PC: @           0x412eb1 TestWaitingLogSink::send()
-    @     0x7f892fb417d0 (unknown)
-    @           0x412eb1 TestWaitingLogSink::send()
-    @     0x7f89304f7f06 google::LogMessage::SendToLog()
-    @     0x7f89304f35af google::LogMessage::Flush()
-    @     0x7f89304f3739 google::LogMessage::~LogMessage()
-    @           0x408cf4 TestLogSinkWaitTillSent()
-    @           0x4115de main
-    @     0x7f892f7ef1c4 (unknown)
-    @           0x4046f9 (unknown)
-</pre>
-
-<p>
-By default, the signal handler writes the failure dump to the standard
-error.  You can customize the destination by InstallFailureWriter().
-
-<h2> <A name="misc">Miscellaneous Notes</A> </h2>
-
-<h3><A NAME=message>Performance of Messages</A></h3>
-
-<p>The conditional logging macros provided by glog (e.g.,
-<code>CHECK</code>, <code>LOG_IF</code>, <code>VLOG</code>, ...) are
-carefully implemented and don't execute the right hand side
-expressions when the conditions are false.  So, the following check
-may not sacrifice the performance of your application.
-
-<pre>
-   CHECK(obj.ok) &lt;&lt; obj.CreatePrettyFormattedStringButVerySlow();
-</pre>
-
-<h3><A NAME=failure>User-defined Failure Function</A></h3>
-
-<p><code>FATAL</code> severity level messages or unsatisfied
-<code>CHECK</code> condition terminate your program.  You can change
-the behavior of the termination by
-<code>InstallFailureFunction</code>.
-
-<pre>
-   void YourFailureFunction() {
-     // Reports something...
-     exit(1);
-   }
-
-   int main(int argc, char* argv[]) {
-     google::InstallFailureFunction(&amp;YourFailureFunction);
-   }
-</pre>
-
-<p>By default, glog tries to dump stacktrace and makes the program
-exit with status 1.  The stacktrace is produced only when you run the
-program on an architecture for which glog supports stack tracing (as
-of September 2008, glog supports stack tracing for x86 and x86_64).
-
-<h3><A NAME=raw>Raw Logging</A></h3>
-
-<p>The header file <code>&lt;glog/raw_logging.h&gt;</code> can be
-used for thread-safe logging, which does not allocate any memory or
-acquire any locks.  Therefore, the macros defined in this
-header file can be used by low-level memory allocation and
-synchronization code.
-Please check <code>src/glog/raw_logging.h.in</code> for detail.
-</p>
-
-<h3><A NAME=plog>Google Style perror()</A></h3>
-
-<p><code>PLOG()</code> and <code>PLOG_IF()</code> and
-<code>PCHECK()</code> behave exactly like their <code>LOG*</code> and
-<code>CHECK</code> equivalents with the addition that they append a
-description of the current state of errno to their output lines.
-E.g.
-
-<pre>
-   PCHECK(write(1, NULL, 2) &gt;= 0) &lt;&lt; "Write NULL failed";
-</pre>
-
-<p>This check fails with the following error message.
-
-<pre>
-   F0825 185142 test.cc:22] Check failed: write(1, NULL, 2) &gt;= 0 Write NULL failed: Bad address [14]
-</pre>
-
-<h3><A NAME=syslog>Syslog</A></h3>
-
-<p><code>SYSLOG</code>, <code>SYSLOG_IF</code>, and
-<code>SYSLOG_EVERY_N</code> macros are available.
-These log to syslog in addition to the normal logs.  Be aware that
-logging to syslog can drastically impact performance, especially if
-syslog is configured for remote logging!  Make sure you understand the
-implications of outputting to syslog before you use these macros. In
-general, it's wise to use these macros sparingly.
-
-<h3><A NAME=strip>Strip Logging Messages</A></h3>
-
-<p>Strings used in log messages can increase the size of your binary
-and present a privacy concern.  You can therefore instruct glog to
-remove all strings which fall below a certain severity level by using
-the GOOGLE_STRIP_LOG macro:
-
-<p>If your application has code like this:
-
-<pre>
-   #define GOOGLE_STRIP_LOG 1    // this must go before the #include!
-   #include &lt;glog/logging.h&gt;
-</pre>
-
-<p>The compiler will remove the log messages whose severities are less
-than the specified integer value.  Since
-<code>VLOG</code> logs at the severity level <code>INFO</code>
-(numeric value <code>0</code>),
-setting <code>GOOGLE_STRIP_LOG</code> to 1 or greater removes
-all log messages associated with <code>VLOG</code>s as well as
-<code>INFO</code> log statements.
-
-<h3><A NAME=windows>Notes for Windows users</A></h3>
-
-<p>Google glog defines a severity level <code>ERROR</code>, which is
-also defined in <code>windows.h</code> . You can make glog not define
-<code>INFO</code>, <code>WARNING</code>, <code>ERROR</code>,
-and <code>FATAL</code> by defining
-<code>GLOG_NO_ABBREVIATED_SEVERITIES</code> before
-including <code>glog/logging.h</code> . Even with this macro, you can
-still use the iostream like logging facilities:
-
-<pre>
-  #define GLOG_NO_ABBREVIATED_SEVERITIES
-  #include &lt;windows.h&gt;
-  #include &lt;glog/logging.h&gt;
-
-  // ...
-
-  LOG(ERROR) &lt;&lt; "This should work";
-  LOG_IF(ERROR, x &gt; y) &lt;&lt; "This should be also OK";
-</pre>
-
-<p>
-However, you cannot
-use <code>INFO</code>, <code>WARNING</code>, <code>ERROR</code>,
-and <code>FATAL</code> anymore for functions defined
-in <code>glog/logging.h</code> .
-
-<pre>
-  #define GLOG_NO_ABBREVIATED_SEVERITIES
-  #include &lt;windows.h&gt;
-  #include &lt;glog/logging.h&gt;
-
-  // ...
-
-  // This won't work.
-  // google::FlushLogFiles(google::ERROR);
-
-  // Use this instead.
-  google::FlushLogFiles(google::GLOG_ERROR);
-</pre>
-
-<p>
-If you don't need <code>ERROR</code> defined
-by <code>windows.h</code>, there are a couple of more workarounds
-which sometimes don't work:
-
-<ul>
-  <li>#define <code>WIN32_LEAN_AND_MEAN</code> or <code>NOGDI</code>
-      <strong>before</strong> you #include <code>windows.h</code> .
-  <li>#undef <code>ERROR</code> <strong>after</strong> you #include
-      <code>windows.h</code> .
-</ul>
-
-<p>See <a href="http://code.google.com/p/google-glog/issues/detail?id=33">
-this issue</a> for more detail.
-
-<hr>
-<address>
-Shinichiro Hamaji<br>
-Gregor Hohpe<br>
-<script type=text/javascript>
-  var lm = new Date(document.lastModified);
-  document.write(lm.toDateString());
-</script>
-</address>
-
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/base/commandlineflags.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/base/commandlineflags.h b/third_party/src/glog/src/base/commandlineflags.h
deleted file mode 100644
index c8d5089..0000000
--- a/third_party/src/glog/src/base/commandlineflags.h
+++ /dev/null
@@ -1,133 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-// 
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// This file is a compatibility layer that defines Google's version of
-// command line flags that are used for configuration.
-//
-// We put flags into their own namespace.  It is purposefully
-// named in an opaque way that people should have trouble typing
-// directly.  The idea is that DEFINE puts the flag in the weird
-// namespace, and DECLARE imports the flag from there into the
-// current namespace.  The net result is to force people to use
-// DECLARE to get access to a flag, rather than saying
-//   extern bool FLAGS_logtostderr;
-// or some such instead.  We want this so we can put extra
-// functionality (like sanity-checking) in DECLARE if we want,
-// and make sure it is picked up everywhere.
-//
-// We also put the type of the variable in the namespace, so that
-// people can't DECLARE_int32 something that they DEFINE_bool'd
-// elsewhere.
-#ifndef BASE_COMMANDLINEFLAGS_H__
-#define BASE_COMMANDLINEFLAGS_H__
-
-#include "config.h"
-#include <string>
-#include <string.h>               // for memchr
-#include <stdlib.h>               // for getenv
-
-#ifdef HAVE_LIB_GFLAGS
-
-#include <gflags/gflags.h>
-
-#else
-
-#include "glog/logging.h"
-
-#define DECLARE_VARIABLE(type, shorttype, name, tn)                     \
-  namespace fL##shorttype {                                             \
-    extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name;                      \
-  }                                                                     \
-  using fL##shorttype::FLAGS_##name
-#define DEFINE_VARIABLE(type, shorttype, name, value, meaning, tn)      \
-  namespace fL##shorttype {                                             \
-    GOOGLE_GLOG_DLL_DECL type FLAGS_##name(value);                      \
-    char FLAGS_no##name;                                                \
-  }                                                                     \
-  using fL##shorttype::FLAGS_##name
-
-// bool specialization
-#define DECLARE_bool(name) \
-  DECLARE_VARIABLE(bool, B, name, bool)
-#define DEFINE_bool(name, value, meaning) \
-  DEFINE_VARIABLE(bool, B, name, value, meaning, bool)
-
-// int32 specialization
-#define DECLARE_int32(name) \
-  DECLARE_VARIABLE(GOOGLE_NAMESPACE::int32, I, name, int32)
-#define DEFINE_int32(name, value, meaning) \
-  DEFINE_VARIABLE(GOOGLE_NAMESPACE::int32, I, name, value, meaning, int32)
-
-// Special case for string, because we have to specify the namespace
-// std::string, which doesn't play nicely with our FLAG__namespace hackery.
-#define DECLARE_string(name)                                            \
-  namespace fLS {                                                       \
-    extern GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name;              \
-  }                                                                     \
-  using fLS::FLAGS_##name
-#define DEFINE_string(name, value, meaning)                             \
-  namespace fLS {                                                       \
-    std::string FLAGS_##name##_buf(value);                              \
-    GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name = FLAGS_##name##_buf; \
-    char FLAGS_no##name;                                                \
-  }                                                                     \
-  using fLS::FLAGS_##name
-
-#endif  // HAVE_LIB_GFLAGS
-
-// Define GLOG_DEFINE_* using DEFINE_* . By using these macros, we
-// have GLOG_* environ variables even if we have gflags installed.
-//
-// If both an environment variable and a flag are specified, the value
-// specified by a flag wins. E.g., if GLOG_v=0 and --v=1, the
-// verbosity will be 1, not 0.
-
-#define GLOG_DEFINE_bool(name, value, meaning) \
-  DEFINE_bool(name, EnvToBool("GLOG_" #name, value), meaning)
-
-#define GLOG_DEFINE_int32(name, value, meaning) \
-  DEFINE_int32(name, EnvToInt("GLOG_" #name, value), meaning)
-
-#define GLOG_DEFINE_string(name, value, meaning) \
-  DEFINE_string(name, EnvToString("GLOG_" #name, value), meaning)
-
-// These macros (could be functions, but I don't want to bother with a .cc
-// file), make it easier to initialize flags from the environment.
-
-#define EnvToString(envname, dflt)   \
-  (!getenv(envname) ? (dflt) : getenv(envname))
-
-#define EnvToBool(envname, dflt)   \
-  (!getenv(envname) ? (dflt) : memchr("tTyY1\0", getenv(envname)[0], 6) != NULL)
-
-#define EnvToInt(envname, dflt)  \
-  (!getenv(envname) ? (dflt) : strtol(getenv(envname), NULL, 10))
-
-#endif  // BASE_COMMANDLINEFLAGS_H__

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/base/googleinit.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/base/googleinit.h b/third_party/src/glog/src/base/googleinit.h
deleted file mode 100644
index 5a8b515..0000000
--- a/third_party/src/glog/src/base/googleinit.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-// 
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ---
-// Author: Jacob Hoffman-Andrews
-
-#ifndef _GOOGLEINIT_H
-#define _GOOGLEINIT_H
-
-class GoogleInitializer {
- public:
-  typedef void (*void_function)(void);
-  GoogleInitializer(const char*, void_function f) {
-    f();
-  }
-};
-
-#define REGISTER_MODULE_INITIALIZER(name, body)                 \
-  namespace {                                                   \
-    static void google_init_module_##name () { body; }          \
-    GoogleInitializer google_initializer_module_##name(#name,   \
-            google_init_module_##name);                         \
-  }
-
-#endif /* _GOOGLEINIT_H */


[09/46] incubator-quickstep git commit: Fixed the distributed version due to query execution engine simplification.

Posted by ji...@apache.org.
Fixed the distributed version due to query execution engine simplification.


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

Branch: refs/heads/fix-iwyu
Commit: e496cb58e10d32de9dc83d69ece84df3f5b62747
Parents: 0898a77
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Fri Oct 6 22:33:02 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Fri Oct 6 22:33:02 2017 -0500

----------------------------------------------------------------------
 query_execution/QueryManagerDistributed.cpp | 24 +++++++++---------------
 relational_operators/WorkOrderFactory.cpp   |  4 ++--
 2 files changed, 11 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e496cb58/query_execution/QueryManagerDistributed.cpp
----------------------------------------------------------------------
diff --git a/query_execution/QueryManagerDistributed.cpp b/query_execution/QueryManagerDistributed.cpp
index 30a1396..97b451f 100644
--- a/query_execution/QueryManagerDistributed.cpp
+++ b/query_execution/QueryManagerDistributed.cpp
@@ -70,8 +70,11 @@ QueryManagerDistributed::QueryManagerDistributed(QueryHandle *query_handle,
   // Collect all the workorders from all the non-blocking relational operators in the DAG.
   for (const dag_node_index index : non_dependent_operators_) {
     if (!fetchNormalWorkOrders(index)) {
-      DCHECK(!checkRebuildRequired(index) || initiateRebuild(index));
-      markOperatorFinished(index);
+      if (checkRebuildRequired(index)) {
+        initiateRebuild(index);
+      } else {
+        markOperatorFinished(index);
+      }
     }
   }
 
@@ -201,21 +204,12 @@ void QueryManagerDistributed::processInitiateRebuildResponseMessage(const dag_no
                                                                     const std::size_t shiftboss_index) {
   query_exec_state_->updateRebuildStatus(op_index, num_rebuild_work_orders, shiftboss_index);
 
-  if (!query_exec_state_->hasRebuildFinished(op_index, num_shiftbosses_)) {
-    // Wait for the rebuild work orders to finish.
-    return;
+  if (query_exec_state_->hasRebuildFinished(op_index, num_shiftbosses_)) {
+    // No needs for rebuilds, or the rebuild has finished.
+    markOperatorFinished(op_index);
   }
 
-  // No needs for rebuilds, or the rebuild has finished.
-  markOperatorFinished(op_index);
-
-  for (const std::pair<dag_node_index, bool> &dependent_link :
-       query_dag_->getDependents(op_index)) {
-    const dag_node_index dependent_op_index = dependent_link.first;
-    if (checkAllBlockingDependenciesMet(dependent_op_index)) {
-      fetchNormalWorkOrders(dependent_op_index);
-    }
-  }
+  // Wait for the rebuild work orders to finish.
 }
 
 bool QueryManagerDistributed::initiateRebuild(const dag_node_index index) {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e496cb58/relational_operators/WorkOrderFactory.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/WorkOrderFactory.cpp b/relational_operators/WorkOrderFactory.cpp
index 5baa21b..25cc81a 100644
--- a/relational_operators/WorkOrderFactory.cpp
+++ b/relational_operators/WorkOrderFactory.cpp
@@ -741,7 +741,7 @@ bool WorkOrderFactory::ProtoIsValid(const serialization::WorkOrder &proto,
                  proto.GetExtension(serialization::DeleteWorkOrder::predicate_index)) &&
              proto.HasExtension(serialization::DeleteWorkOrder::block_id) &&
              proto.HasExtension(serialization::DeleteWorkOrder::operator_index) &&
-             proto.GetExtension(serialization::DeleteWorkOrder::partition_id);
+             proto.HasExtension(serialization::DeleteWorkOrder::partition_id);
     }
     case serialization::DESTROY_AGGREGATION_STATE: {
       return proto.HasExtension(serialization::DestroyAggregationStateWorkOrder::aggr_state_index) &&
@@ -1033,7 +1033,7 @@ bool WorkOrderFactory::ProtoIsValid(const serialization::WorkOrder &proto,
                  proto.GetExtension(serialization::UpdateWorkOrder::update_group_index)) &&
              proto.HasExtension(serialization::UpdateWorkOrder::operator_index) &&
              proto.HasExtension(serialization::UpdateWorkOrder::block_id) &&
-             proto.GetExtension(serialization::UpdateWorkOrder::partition_id);
+             proto.HasExtension(serialization::UpdateWorkOrder::partition_id);
     }
     case serialization::WINDOW_AGGREGATION: {
       return proto.HasExtension(serialization::WindowAggregationWorkOrder::window_aggr_state_index) &&


[29/46] incubator-quickstep git commit: Remove glog source code from third party

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/glog/logging.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/glog/logging.h b/third_party/src/glog/src/windows/glog/logging.h
deleted file mode 100644
index 1d91b12..0000000
--- a/third_party/src/glog/src/windows/glog/logging.h
+++ /dev/null
@@ -1,1603 +0,0 @@
-// This file is automatically generated from src/glog/logging.h.in
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-
-// Copyright (c) 1999, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney
-//
-// This file contains #include information about logging-related stuff.
-// Pretty much everybody needs to #include this file so that they can
-// log various happenings.
-//
-#ifndef _LOGGING_H_
-#define _LOGGING_H_
-
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <iosfwd>
-#include <ostream>
-#include <sstream>
-#include <string>
-#if 0
-# include <unistd.h>
-#endif
-#include <vector>
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-#if defined(_MSC_VER)
-#define GLOG_MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
-                                     __pragma(warning(disable:n))
-#define GLOG_MSVC_POP_WARNING() __pragma(warning(pop))
-#else
-#define GLOG_MSVC_PUSH_DISABLE_WARNING(n)
-#define GLOG_MSVC_POP_WARNING()
-#endif
-
-// We care a lot about number of bits things take up.  Unfortunately,
-// systems define their bit-specific ints in a lot of different ways.
-// We use our own way, and have a typedef to get there.
-// Note: these commands below may look like "#if 1" or "#if 0", but
-// that's because they were constructed that way at ./configure time.
-// Look at logging.h.in to see how they're calculated (based on your config).
-#if 0
-#include <stdint.h>             // the normal place uint16_t is defined
-#endif
-#if 0
-#include <sys/types.h>          // the normal place u_int16_t is defined
-#endif
-#if 0
-#include <inttypes.h>           // a third place for uint16_t or u_int16_t
-#endif
-
-#if 0
-#include <gflags/gflags.h>
-#endif
-
-namespace google {
-
-#if 0      // the C99 format
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#elif 0   // the BSD format
-typedef int32_t int32;
-typedef u_int32_t uint32;
-typedef int64_t int64;
-typedef u_int64_t uint64;
-#elif 1    // the windows (vc7) format
-typedef __int32 int32;
-typedef unsigned __int32 uint32;
-typedef __int64 int64;
-typedef unsigned __int64 uint64;
-#else
-#error Do not know how to define a 32-bit integer quantity on your system
-#endif
-
-}
-
-// The global value of GOOGLE_STRIP_LOG. All the messages logged to
-// LOG(XXX) with severity less than GOOGLE_STRIP_LOG will not be displayed.
-// If it can be determined at compile time that the message will not be
-// printed, the statement will be compiled out.
-//
-// Example: to strip out all INFO and WARNING messages, use the value
-// of 2 below. To make an exception for WARNING messages from a single
-// file, add "#define GOOGLE_STRIP_LOG 1" to that file _before_ including
-// base/logging.h
-#ifndef GOOGLE_STRIP_LOG
-#define GOOGLE_STRIP_LOG 0
-#endif
-
-// GCC can be told that a certain branch is not likely to be taken (for
-// instance, a CHECK failure), and use that information in static analysis.
-// Giving it this information can help it optimize for the common case in
-// the absence of better information (ie. -fprofile-arcs).
-//
-#ifndef GOOGLE_PREDICT_BRANCH_NOT_TAKEN
-#if 0
-#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) (__builtin_expect(x, 0))
-#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0))
-#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
-#else
-#define GOOGLE_PREDICT_BRANCH_NOT_TAKEN(x) x
-#define GOOGLE_PREDICT_FALSE(x) x
-#define GOOGLE_PREDICT_TRUE(x) x
-#endif
-#endif
-
-// Make a bunch of macros for logging.  The way to log things is to stream
-// things to LOG(<a particular severity level>).  E.g.,
-//
-//   LOG(INFO) << "Found " << num_cookies << " cookies";
-//
-// You can capture log messages in a string, rather than reporting them
-// immediately:
-//
-//   vector<string> errors;
-//   LOG_STRING(ERROR, &errors) << "Couldn't parse cookie #" << cookie_num;
-//
-// This pushes back the new error onto 'errors'; if given a NULL pointer,
-// it reports the error via LOG(ERROR).
-//
-// You can also do conditional logging:
-//
-//   LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
-//
-// You can also do occasional logging (log every n'th occurrence of an
-// event):
-//
-//   LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
-//
-// The above will cause log messages to be output on the 1st, 11th, 21st, ...
-// times it is executed.  Note that the special google::COUNTER value is used
-// to identify which repetition is happening.
-//
-// You can also do occasional conditional logging (log every n'th
-// occurrence of an event, when condition is satisfied):
-//
-//   LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << google::COUNTER
-//                                           << "th big cookie";
-//
-// You can log messages the first N times your code executes a line. E.g.
-//
-//   LOG_FIRST_N(INFO, 20) << "Got the " << google::COUNTER << "th cookie";
-//
-// Outputs log messages for the first 20 times it is executed.
-//
-// Analogous SYSLOG, SYSLOG_IF, and SYSLOG_EVERY_N macros are available.
-// These log to syslog as well as to the normal logs.  If you use these at
-// all, you need to be aware that syslog can drastically reduce performance,
-// especially if it is configured for remote logging!  Don't use these
-// unless you fully understand this and have a concrete need to use them.
-// Even then, try to minimize your use of them.
-//
-// There are also "debug mode" logging macros like the ones above:
-//
-//   DLOG(INFO) << "Found cookies";
-//
-//   DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
-//
-//   DLOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
-//
-// All "debug mode" logging is compiled away to nothing for non-debug mode
-// compiles.
-//
-// We also have
-//
-//   LOG_ASSERT(assertion);
-//   DLOG_ASSERT(assertion);
-//
-// which is syntactic sugar for {,D}LOG_IF(FATAL, assert fails) << assertion;
-//
-// There are "verbose level" logging macros.  They look like
-//
-//   VLOG(1) << "I'm printed when you run the program with --v=1 or more";
-//   VLOG(2) << "I'm printed when you run the program with --v=2 or more";
-//
-// These always log at the INFO log level (when they log at all).
-// The verbose logging can also be turned on module-by-module.  For instance,
-//    --vmodule=mapreduce=2,file=1,gfs*=3 --v=0
-// will cause:
-//   a. VLOG(2) and lower messages to be printed from mapreduce.{h,cc}
-//   b. VLOG(1) and lower messages to be printed from file.{h,cc}
-//   c. VLOG(3) and lower messages to be printed from files prefixed with "gfs"
-//   d. VLOG(0) and lower messages to be printed from elsewhere
-//
-// The wildcarding functionality shown by (c) supports both '*' (match
-// 0 or more characters) and '?' (match any single character) wildcards.
-//
-// There's also VLOG_IS_ON(n) "verbose level" condition macro. To be used as
-//
-//   if (VLOG_IS_ON(2)) {
-//     // do some logging preparation and logging
-//     // that can't be accomplished with just VLOG(2) << ...;
-//   }
-//
-// There are also VLOG_IF, VLOG_EVERY_N and VLOG_IF_EVERY_N "verbose level"
-// condition macros for sample cases, when some extra computation and
-// preparation for logs is not needed.
-//   VLOG_IF(1, (size > 1024))
-//      << "I'm printed when size is more than 1024 and when you run the "
-//         "program with --v=1 or more";
-//   VLOG_EVERY_N(1, 10)
-//      << "I'm printed every 10th occurrence, and when you run the program "
-//         "with --v=1 or more. Present occurence is " << google::COUNTER;
-//   VLOG_IF_EVERY_N(1, (size > 1024), 10)
-//      << "I'm printed on every 10th occurence of case when size is more "
-//         " than 1024, when you run the program with --v=1 or more. ";
-//         "Present occurence is " << google::COUNTER;
-//
-// The supported severity levels for macros that allow you to specify one
-// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
-// Note that messages of a given severity are logged not only in the
-// logfile for that severity, but also in all logfiles of lower severity.
-// E.g., a message of severity FATAL will be logged to the logfiles of
-// severity FATAL, ERROR, WARNING, and INFO.
-//
-// There is also the special severity of DFATAL, which logs FATAL in
-// debug mode, ERROR in normal mode.
-//
-// Very important: logging a message at the FATAL severity level causes
-// the program to terminate (after the message is logged).
-//
-// Unless otherwise specified, logs will be written to the filename
-// "<program name>.<hostname>.<user name>.log.<severity level>.", followed
-// by the date, time, and pid (you can't prevent the date, time, and pid
-// from being in the filename).
-//
-// The logging code takes two flags:
-//     --v=#           set the verbose level
-//     --logtostderr   log all the messages to stderr instead of to logfiles
-
-// LOG LINE PREFIX FORMAT
-//
-// Log lines have this form:
-//
-//     Lmmdd hh:mm:ss.uuuuuu threadid file:line] msg...
-//
-// where the fields are defined as follows:
-//
-//   L                A single character, representing the log level
-//                    (eg 'I' for INFO)
-//   mm               The month (zero padded; ie May is '05')
-//   dd               The day (zero padded)
-//   hh:mm:ss.uuuuuu  Time in hours, minutes and fractional seconds
-//   threadid         The space-padded thread ID as returned by GetTID()
-//                    (this matches the PID on Linux)
-//   file             The file name
-//   line             The line number
-//   msg              The user-supplied message
-//
-// Example:
-//
-//   I1103 11:57:31.739339 24395 google.cc:2341] Command line: ./some_prog
-//   I1103 11:57:31.739403 24395 google.cc:2342] Process id 24395
-//
-// NOTE: although the microseconds are useful for comparing events on
-// a single machine, clocks on different machines may not be well
-// synchronized.  Hence, use caution when comparing the low bits of
-// timestamps from different machines.
-
-#ifndef DECLARE_VARIABLE
-#define MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#define DECLARE_VARIABLE(type, shorttype, name, tn)                     \
-  namespace fL##shorttype {                                             \
-    extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name;                      \
-  }                                                                     \
-  using fL##shorttype::FLAGS_##name
-
-// bool specialization
-#define DECLARE_bool(name) \
-  DECLARE_VARIABLE(bool, B, name, bool)
-
-// int32 specialization
-#define DECLARE_int32(name) \
-  DECLARE_VARIABLE(google::int32, I, name, int32)
-
-// Special case for string, because we have to specify the namespace
-// std::string, which doesn't play nicely with our FLAG__namespace hackery.
-#define DECLARE_string(name)                                            \
-  namespace fLS {                                                       \
-    extern GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name;              \
-  }                                                                     \
-  using fLS::FLAGS_##name
-#endif
-
-// Set whether log messages go to stderr instead of logfiles
-DECLARE_bool(logtostderr);
-
-// Set whether log messages go to stderr in addition to logfiles.
-DECLARE_bool(alsologtostderr);
-
-// Set color messages logged to stderr (if supported by terminal).
-DECLARE_bool(colorlogtostderr);
-
-// Log messages at a level >= this flag are automatically sent to
-// stderr in addition to log files.
-DECLARE_int32(stderrthreshold);
-
-// Set whether the log prefix should be prepended to each line of output.
-DECLARE_bool(log_prefix);
-
-// Log messages at a level <= this flag are buffered.
-// Log messages at a higher level are flushed immediately.
-DECLARE_int32(logbuflevel);
-
-// Sets the maximum number of seconds which logs may be buffered for.
-DECLARE_int32(logbufsecs);
-
-// Log suppression level: messages logged at a lower level than this
-// are suppressed.
-DECLARE_int32(minloglevel);
-
-// If specified, logfiles are written into this directory instead of the
-// default logging directory.
-DECLARE_string(log_dir);
-
-// Sets the path of the directory into which to put additional links
-// to the log files.
-DECLARE_string(log_link);
-
-DECLARE_int32(v);  // in vlog_is_on.cc
-
-// Sets the maximum log file size (in MB).
-DECLARE_int32(max_log_size);
-
-// Sets whether to avoid logging to the disk if the disk is full.
-DECLARE_bool(stop_logging_if_full_disk);
-
-#ifdef MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#undef MUST_UNDEF_GFLAGS_DECLARE_MACROS
-#undef DECLARE_VARIABLE
-#undef DECLARE_bool
-#undef DECLARE_int32
-#undef DECLARE_string
-#endif
-
-// Log messages below the GOOGLE_STRIP_LOG level will be compiled away for
-// security reasons. See LOG(severtiy) below.
-
-// A few definitions of macros that don't generate much code.  Since
-// LOG(INFO) and its ilk are used all over our code, it's
-// better to have compact code for these operations.
-
-#if GOOGLE_STRIP_LOG == 0
-#define COMPACT_GOOGLE_LOG_INFO google::LogMessage( \
-      __FILE__, __LINE__)
-#define LOG_TO_STRING_INFO(message) google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_INFO, message)
-#else
-#define COMPACT_GOOGLE_LOG_INFO google::NullStream()
-#define LOG_TO_STRING_INFO(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 1
-#define COMPACT_GOOGLE_LOG_WARNING google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_WARNING)
-#define LOG_TO_STRING_WARNING(message) google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_WARNING, message)
-#else
-#define COMPACT_GOOGLE_LOG_WARNING google::NullStream()
-#define LOG_TO_STRING_WARNING(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 2
-#define COMPACT_GOOGLE_LOG_ERROR google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_ERROR)
-#define LOG_TO_STRING_ERROR(message) google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_ERROR, message)
-#else
-#define COMPACT_GOOGLE_LOG_ERROR google::NullStream()
-#define LOG_TO_STRING_ERROR(message) google::NullStream()
-#endif
-
-#if GOOGLE_STRIP_LOG <= 3
-#define COMPACT_GOOGLE_LOG_FATAL google::LogMessageFatal( \
-      __FILE__, __LINE__)
-#define LOG_TO_STRING_FATAL(message) google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_FATAL, message)
-#else
-#define COMPACT_GOOGLE_LOG_FATAL google::NullStreamFatal()
-#define LOG_TO_STRING_FATAL(message) google::NullStreamFatal()
-#endif
-
-// For DFATAL, we want to use LogMessage (as opposed to
-// LogMessageFatal), to be consistent with the original behavior.
-#ifdef NDEBUG
-#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
-#elif GOOGLE_STRIP_LOG <= 3
-#define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \
-      __FILE__, __LINE__, google::GLOG_FATAL)
-#else
-#define COMPACT_GOOGLE_LOG_DFATAL google::NullStreamFatal()
-#endif
-
-#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, &google::LogMessage::SendToLog)
-#define SYSLOG_INFO(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_WARNING(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_WARNING(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_ERROR(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_ERROR(counter)  \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_FATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_FATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-#define GOOGLE_LOG_DFATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
-  &google::LogMessage::SendToLog)
-#define SYSLOG_DFATAL(counter) \
-  google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
-  &google::LogMessage::SendToSyslogAndLog)
-
-#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) || defined(__CYGWIN32__)
-// A very useful logging macro to log windows errors:
-#define LOG_SYSRESULT(result) \
-  if (FAILED(HRESULT_FROM_WIN32(result))) { \
-    LPSTR message = NULL; \
-    LPSTR msg = reinterpret_cast<LPSTR>(&message); \
-    DWORD message_length = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | \
-                         FORMAT_MESSAGE_FROM_SYSTEM, \
-                         0, result, 0, msg, 100, NULL); \
-    if (message_length > 0) { \
-      google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, 0, \
-          &google::LogMessage::SendToLog).stream() \
-          << reinterpret_cast<const char*>(message); \
-      LocalFree(message); \
-    } \
-  }
-#endif
-
-// We use the preprocessor's merging operator, "##", so that, e.g.,
-// LOG(INFO) becomes the token GOOGLE_LOG_INFO.  There's some funny
-// subtle difference between ostream member streaming functions (e.g.,
-// ostream::operator<<(int) and ostream non-member streaming functions
-// (e.g., ::operator<<(ostream&, string&): it turns out that it's
-// impossible to stream something like a string directly to an unnamed
-// ostream. We employ a neat hack by calling the stream() member
-// function of LogMessage which seems to avoid the problem.
-#define LOG(severity) COMPACT_GOOGLE_LOG_ ## severity.stream()
-#define SYSLOG(severity) SYSLOG_ ## severity(0).stream()
-
-namespace google {
-
-// They need the definitions of integer types.
-#include "glog/log_severity.h"
-#include "glog/vlog_is_on.h"
-
-// Initialize google's logging library. You will see the program name
-// specified by argv0 in log outputs.
-GOOGLE_GLOG_DLL_DECL void InitGoogleLogging(const char* argv0);
-
-// Shutdown google's logging library.
-GOOGLE_GLOG_DLL_DECL void ShutdownGoogleLogging();
-
-// Install a function which will be called after LOG(FATAL).
-GOOGLE_GLOG_DLL_DECL void InstallFailureFunction(void (*fail_func)());
-
-class LogSink;  // defined below
-
-// If a non-NULL sink pointer is given, we push this message to that sink.
-// For LOG_TO_SINK we then do normal LOG(severity) logging as well.
-// This is useful for capturing messages and passing/storing them
-// somewhere more specific than the global log of the process.
-// Argument types:
-//   LogSink* sink;
-//   LogSeverity severity;
-// The cast is to disambiguate NULL arguments.
-#define LOG_TO_SINK(sink, severity) \
-  google::LogMessage(                                    \
-      __FILE__, __LINE__,                                               \
-      google::GLOG_ ## severity,                         \
-      static_cast<google::LogSink*>(sink), true).stream()
-#define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity)                  \
-  google::LogMessage(                                    \
-      __FILE__, __LINE__,                                               \
-      google::GLOG_ ## severity,                         \
-      static_cast<google::LogSink*>(sink), false).stream()
-
-// If a non-NULL string pointer is given, we write this message to that string.
-// We then do normal LOG(severity) logging as well.
-// This is useful for capturing messages and storing them somewhere more
-// specific than the global log of the process.
-// Argument types:
-//   string* message;
-//   LogSeverity severity;
-// The cast is to disambiguate NULL arguments.
-// NOTE: LOG(severity) expands to LogMessage().stream() for the specified
-// severity.
-#define LOG_TO_STRING(severity, message) \
-  LOG_TO_STRING_##severity(static_cast<string*>(message)).stream()
-
-// If a non-NULL pointer is given, we push the message onto the end
-// of a vector of strings; otherwise, we report it with LOG(severity).
-// This is handy for capturing messages and perhaps passing them back
-// to the caller, rather than reporting them immediately.
-// Argument types:
-//   LogSeverity severity;
-//   vector<string> *outvec;
-// The cast is to disambiguate NULL arguments.
-#define LOG_STRING(severity, outvec) \
-  LOG_TO_STRING_##severity(static_cast<vector<string>*>(outvec)).stream()
-
-#define LOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-#define SYSLOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & SYSLOG(severity)
-
-#define LOG_ASSERT(condition)  \
-  LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
-#define SYSLOG_ASSERT(condition) \
-  SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition
-
-// CHECK dies with a fatal error if condition is not true.  It is *not*
-// controlled by NDEBUG, so the check will be executed regardless of
-// compilation mode.  Therefore, it is safe to do things like:
-//    CHECK(fp->Write(x) == 4)
-#define CHECK(condition)  \
-      LOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN(!(condition))) \
-             << "Check failed: " #condition " "
-
-// A container for a string pointer which can be evaluated to a bool -
-// true iff the pointer is NULL.
-struct CheckOpString {
-  CheckOpString(std::string* str) : str_(str) { }
-  // No destructor: if str_ is non-NULL, we're about to LOG(FATAL),
-  // so there's no point in cleaning up str_.
-  operator bool() const {
-    return GOOGLE_PREDICT_BRANCH_NOT_TAKEN(str_ != NULL);
-  }
-  std::string* str_;
-};
-
-// Function is overloaded for integral types to allow static const
-// integrals declared in classes and not defined to be used as arguments to
-// CHECK* macros. It's not encouraged though.
-template <class T>
-inline const T&       GetReferenceableValue(const T&           t) { return t; }
-inline char           GetReferenceableValue(char               t) { return t; }
-inline unsigned char  GetReferenceableValue(unsigned char      t) { return t; }
-inline signed char    GetReferenceableValue(signed char        t) { return t; }
-inline short          GetReferenceableValue(short              t) { return t; }
-inline unsigned short GetReferenceableValue(unsigned short     t) { return t; }
-inline int            GetReferenceableValue(int                t) { return t; }
-inline unsigned int   GetReferenceableValue(unsigned int       t) { return t; }
-inline long           GetReferenceableValue(long               t) { return t; }
-inline unsigned long  GetReferenceableValue(unsigned long      t) { return t; }
-inline long long      GetReferenceableValue(long long          t) { return t; }
-inline unsigned long long GetReferenceableValue(unsigned long long t) {
-  return t;
-}
-
-// This is a dummy class to define the following operator.
-struct DummyClassToDefineOperator {};
-
-}
-
-// Define global operator<< to declare using ::operator<<.
-// This declaration will allow use to use CHECK macros for user
-// defined classes which have operator<< (e.g., stl_logging.h).
-inline std::ostream& operator<<(
-    std::ostream& out, const google::DummyClassToDefineOperator&) {
-  return out;
-}
-
-namespace google {
-
-// This formats a value for a failing CHECK_XX statement.  Ordinarily,
-// it uses the definition for operator<<, with a few special cases below.
-template <typename T>
-inline void MakeCheckOpValueString(std::ostream* os, const T& v) {
-  (*os) << v;
-}
-
-// Overrides for char types provide readable values for unprintable
-// characters.
-template <> GOOGLE_GLOG_DLL_DECL
-void MakeCheckOpValueString(std::ostream* os, const char& v);
-template <> GOOGLE_GLOG_DLL_DECL
-void MakeCheckOpValueString(std::ostream* os, const signed char& v);
-template <> GOOGLE_GLOG_DLL_DECL
-void MakeCheckOpValueString(std::ostream* os, const unsigned char& v);
-
-// Build the error message string. Specify no inlining for code size.
-template <typename T1, typename T2>
-std::string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext)
-    ;
-
-namespace base {
-namespace internal {
-
-// If "s" is less than base_logging::INFO, returns base_logging::INFO.
-// If "s" is greater than base_logging::FATAL, returns
-// base_logging::ERROR.  Otherwise, returns "s".
-LogSeverity NormalizeSeverity(LogSeverity s);
-
-}  // namespace internal
-
-// A helper class for formatting "expr (V1 vs. V2)" in a CHECK_XX
-// statement.  See MakeCheckOpString for sample usage.  Other
-// approaches were considered: use of a template method (e.g.,
-// base::BuildCheckOpString(exprtext, base::Print<T1>, &v1,
-// base::Print<T2>, &v2), however this approach has complications
-// related to volatile arguments and function-pointer arguments).
-class GOOGLE_GLOG_DLL_DECL CheckOpMessageBuilder {
- public:
-  // Inserts "exprtext" and " (" to the stream.
-  explicit CheckOpMessageBuilder(const char *exprtext);
-  // Deletes "stream_".
-  ~CheckOpMessageBuilder();
-  // For inserting the first variable.
-  std::ostream* ForVar1() { return stream_; }
-  // For inserting the second variable (adds an intermediate " vs. ").
-  std::ostream* ForVar2();
-  // Get the result (inserts the closing ")").
-  std::string* NewString();
-
- private:
-  std::ostringstream *stream_;
-};
-
-}  // namespace base
-
-template <typename T1, typename T2>
-std::string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext) {
-  base::CheckOpMessageBuilder comb(exprtext);
-  MakeCheckOpValueString(comb.ForVar1(), v1);
-  MakeCheckOpValueString(comb.ForVar2(), v2);
-  return comb.NewString();
-}
-
-// Helper functions for CHECK_OP macro.
-// The (int, int) specialization works around the issue that the compiler
-// will not instantiate the template version of the function on values of
-// unnamed enum type - see comment below.
-#define DEFINE_CHECK_OP_IMPL(name, op) \
-  template <typename T1, typename T2> \
-  inline std::string* name##Impl(const T1& v1, const T2& v2,    \
-                            const char* exprtext) { \
-    if (GOOGLE_PREDICT_TRUE(v1 op v2)) return NULL; \
-    else return MakeCheckOpString(v1, v2, exprtext); \
-  } \
-  inline std::string* name##Impl(int v1, int v2, const char* exprtext) { \
-    return name##Impl<int, int>(v1, v2, exprtext); \
-  }
-
-// We use the full name Check_EQ, Check_NE, etc. in case the file including
-// base/logging.h provides its own #defines for the simpler names EQ, NE, etc.
-// This happens if, for example, those are used as token names in a
-// yacc grammar.
-DEFINE_CHECK_OP_IMPL(Check_EQ, ==)  // Compilation error with CHECK_EQ(NULL, x)?
-DEFINE_CHECK_OP_IMPL(Check_NE, !=)  // Use CHECK(x == NULL) instead.
-DEFINE_CHECK_OP_IMPL(Check_LE, <=)
-DEFINE_CHECK_OP_IMPL(Check_LT, < )
-DEFINE_CHECK_OP_IMPL(Check_GE, >=)
-DEFINE_CHECK_OP_IMPL(Check_GT, > )
-#undef DEFINE_CHECK_OP_IMPL
-
-// Helper macro for binary operators.
-// Don't use this macro directly in your code, use CHECK_EQ et al below.
-
-#if defined(STATIC_ANALYSIS)
-// Only for static analysis tool to know that it is equivalent to assert
-#define CHECK_OP_LOG(name, op, val1, val2, log) CHECK((val1) op (val2))
-#elif !defined(NDEBUG)
-// In debug mode, avoid constructing CheckOpStrings if possible,
-// to reduce the overhead of CHECK statments by 2x.
-// Real DCHECK-heavy tests have seen 1.5x speedups.
-
-// The meaning of "string" might be different between now and 
-// when this macro gets invoked (e.g., if someone is experimenting
-// with other string implementations that get defined after this
-// file is included).  Save the current meaning now and use it 
-// in the macro.
-typedef std::string _Check_string;
-#define CHECK_OP_LOG(name, op, val1, val2, log)                         \
-  while (google::_Check_string* _result =                \
-         google::Check##name##Impl(                      \
-             google::GetReferenceableValue(val1),        \
-             google::GetReferenceableValue(val2),        \
-             #val1 " " #op " " #val2))                                  \
-    log(__FILE__, __LINE__,                                             \
-        google::CheckOpString(_result)).stream()
-#else
-// In optimized mode, use CheckOpString to hint to compiler that
-// the while condition is unlikely.
-#define CHECK_OP_LOG(name, op, val1, val2, log)                         \
-  while (google::CheckOpString _result =                 \
-         google::Check##name##Impl(                      \
-             google::GetReferenceableValue(val1),        \
-             google::GetReferenceableValue(val2),        \
-             #val1 " " #op " " #val2))                                  \
-    log(__FILE__, __LINE__, _result).stream()
-#endif  // STATIC_ANALYSIS, !NDEBUG
-
-#if GOOGLE_STRIP_LOG <= 3
-#define CHECK_OP(name, op, val1, val2) \
-  CHECK_OP_LOG(name, op, val1, val2, google::LogMessageFatal)
-#else
-#define CHECK_OP(name, op, val1, val2) \
-  CHECK_OP_LOG(name, op, val1, val2, google::NullStreamFatal)
-#endif // STRIP_LOG <= 3
-
-// Equality/Inequality checks - compare two values, and log a FATAL message
-// including the two values when the result is not as expected.  The values
-// must have operator<<(ostream, ...) defined.
-//
-// You may append to the error message like so:
-//   CHECK_NE(1, 2) << ": The world must be ending!";
-//
-// We are very careful to ensure that each argument is evaluated exactly
-// once, and that anything which is legal to pass as a function argument is
-// legal here.  In particular, the arguments may be temporary expressions
-// which will end up being destroyed at the end of the apparent statement,
-// for example:
-//   CHECK_EQ(string("abc")[1], 'b');
-//
-// WARNING: These don't compile correctly if one of the arguments is a pointer
-// and the other is NULL. To work around this, simply static_cast NULL to the
-// type of the desired pointer.
-
-#define CHECK_EQ(val1, val2) CHECK_OP(_EQ, ==, val1, val2)
-#define CHECK_NE(val1, val2) CHECK_OP(_NE, !=, val1, val2)
-#define CHECK_LE(val1, val2) CHECK_OP(_LE, <=, val1, val2)
-#define CHECK_LT(val1, val2) CHECK_OP(_LT, < , val1, val2)
-#define CHECK_GE(val1, val2) CHECK_OP(_GE, >=, val1, val2)
-#define CHECK_GT(val1, val2) CHECK_OP(_GT, > , val1, val2)
-
-// Check that the input is non NULL.  This very useful in constructor
-// initializer lists.
-
-#define CHECK_NOTNULL(val) \
-  google::CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val))
-
-// Helper functions for string comparisons.
-// To avoid bloat, the definitions are in logging.cc.
-#define DECLARE_CHECK_STROP_IMPL(func, expected) \
-  GOOGLE_GLOG_DLL_DECL std::string* Check##func##expected##Impl( \
-      const char* s1, const char* s2, const char* names);
-DECLARE_CHECK_STROP_IMPL(strcmp, true)
-DECLARE_CHECK_STROP_IMPL(strcmp, false)
-DECLARE_CHECK_STROP_IMPL(strcasecmp, true)
-DECLARE_CHECK_STROP_IMPL(strcasecmp, false)
-#undef DECLARE_CHECK_STROP_IMPL
-
-// Helper macro for string comparisons.
-// Don't use this macro directly in your code, use CHECK_STREQ et al below.
-#define CHECK_STROP(func, op, expected, s1, s2) \
-  while (google::CheckOpString _result = \
-         google::Check##func##expected##Impl((s1), (s2), \
-                                     #s1 " " #op " " #s2)) \
-    LOG(FATAL) << *_result.str_
-
-
-// String (char*) equality/inequality checks.
-// CASE versions are case-insensitive.
-//
-// Note that "s1" and "s2" may be temporary strings which are destroyed
-// by the compiler at the end of the current "full expression"
-// (e.g. CHECK_STREQ(Foo().c_str(), Bar().c_str())).
-
-#define CHECK_STREQ(s1, s2) CHECK_STROP(strcmp, ==, true, s1, s2)
-#define CHECK_STRNE(s1, s2) CHECK_STROP(strcmp, !=, false, s1, s2)
-#define CHECK_STRCASEEQ(s1, s2) CHECK_STROP(strcasecmp, ==, true, s1, s2)
-#define CHECK_STRCASENE(s1, s2) CHECK_STROP(strcasecmp, !=, false, s1, s2)
-
-#define CHECK_INDEX(I,A) CHECK(I < (sizeof(A)/sizeof(A[0])))
-#define CHECK_BOUND(B,A) CHECK(B <= (sizeof(A)/sizeof(A[0])))
-
-#define CHECK_DOUBLE_EQ(val1, val2)              \
-  do {                                           \
-    CHECK_LE((val1), (val2)+0.000000000000001L); \
-    CHECK_GE((val1), (val2)-0.000000000000001L); \
-  } while (0)
-
-#define CHECK_NEAR(val1, val2, margin)           \
-  do {                                           \
-    CHECK_LE((val1), (val2)+(margin));           \
-    CHECK_GE((val1), (val2)-(margin));           \
-  } while (0)
-
-// perror()..googly style!
-//
-// PLOG() and PLOG_IF() and PCHECK() behave exactly like their LOG* and
-// CHECK equivalents with the addition that they postpend a description
-// of the current state of errno to their output lines.
-
-#define PLOG(severity) GOOGLE_PLOG(severity, 0).stream()
-
-#define GOOGLE_PLOG(severity, counter)  \
-  google::ErrnoLogMessage( \
-      __FILE__, __LINE__, google::GLOG_ ## severity, counter, \
-      &google::LogMessage::SendToLog)
-
-#define PLOG_IF(severity, condition) \
-  !(condition) ? (void) 0 : google::LogMessageVoidify() & PLOG(severity)
-
-// A CHECK() macro that postpends errno if the condition is false. E.g.
-//
-// if (poll(fds, nfds, timeout) == -1) { PCHECK(errno == EINTR); ... }
-#define PCHECK(condition)  \
-      PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN(!(condition))) \
-              << "Check failed: " #condition " "
-
-// A CHECK() macro that lets you assert the success of a function that
-// returns -1 and sets errno in case of an error. E.g.
-//
-// CHECK_ERR(mkdir(path, 0700));
-//
-// or
-//
-// int fd = open(filename, flags); CHECK_ERR(fd) << ": open " << filename;
-#define CHECK_ERR(invocation)                                          \
-PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1))    \
-        << #invocation
-
-// Use macro expansion to create, for each use of LOG_EVERY_N(), static
-// variables with the __LINE__ expansion as part of the variable name.
-#define LOG_EVERY_N_VARNAME(base, line) LOG_EVERY_N_VARNAME_CONCAT(base, line)
-#define LOG_EVERY_N_VARNAME_CONCAT(base, line) base ## line
-
-#define LOG_OCCURRENCES LOG_EVERY_N_VARNAME(occurrences_, __LINE__)
-#define LOG_OCCURRENCES_MOD_N LOG_EVERY_N_VARNAME(occurrences_mod_n_, __LINE__)
-
-#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
-  if (LOG_OCCURRENCES_MOD_N == 1) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (condition && \
-      ((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
-                 &what_to_do).stream()
-
-#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
-  ++LOG_OCCURRENCES; \
-  if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
-  if (LOG_OCCURRENCES_MOD_N == 1) \
-    google::ErrnoLogMessage( \
-        __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
-  static int LOG_OCCURRENCES = 0; \
-  if (LOG_OCCURRENCES <= n) \
-    ++LOG_OCCURRENCES; \
-  if (LOG_OCCURRENCES <= n) \
-    google::LogMessage( \
-        __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
-        &what_to_do).stream()
-
-namespace glog_internal_namespace_ {
-template <bool>
-struct CompileAssert {
-};
-struct CrashReason;
-}  // namespace glog_internal_namespace_
-
-#define GOOGLE_GLOG_COMPILE_ASSERT(expr, msg) \
-  typedef google::glog_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
-
-#define LOG_EVERY_N(severity, n)                                        \
-  GOOGLE_GLOG_COMPILE_ASSERT(google::GLOG_ ## severity < \
-                             google::NUM_SEVERITIES,     \
-                             INVALID_REQUESTED_LOG_SEVERITY);           \
-  SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
-
-#define SYSLOG_EVERY_N(severity, n) \
-  SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToSyslogAndLog)
-
-#define PLOG_EVERY_N(severity, n) \
-  SOME_KIND_OF_PLOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
-
-#define LOG_FIRST_N(severity, n) \
-  SOME_KIND_OF_LOG_FIRST_N(severity, (n), google::LogMessage::SendToLog)
-
-#define LOG_IF_EVERY_N(severity, condition, n) \
-  SOME_KIND_OF_LOG_IF_EVERY_N(severity, (condition), (n), google::LogMessage::SendToLog)
-
-// We want the special COUNTER value available for LOG_EVERY_X()'ed messages
-enum PRIVATE_Counter {COUNTER};
-
-#ifdef GLOG_NO_ABBREVIATED_SEVERITIES
-// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets
-// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us
-// to keep using this syntax, we define this macro to do the same thing
-// as COMPACT_GOOGLE_LOG_ERROR.
-#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR
-#define SYSLOG_0 SYSLOG_ERROR
-#define LOG_TO_STRING_0 LOG_TO_STRING_ERROR
-// Needed for LOG_IS_ON(ERROR).
-const LogSeverity GLOG_0 = GLOG_ERROR;
-#else
-// Users may include windows.h after logging.h without
-// GLOG_NO_ABBREVIATED_SEVERITIES nor WIN32_LEAN_AND_MEAN.
-// For this case, we cannot detect if ERROR is defined before users
-// actually use ERROR. Let's make an undefined symbol to warn users.
-# define GLOG_ERROR_MSG ERROR_macro_is_defined_Define_GLOG_NO_ABBREVIATED_SEVERITIES_before_including_logging_h_See_the_document_for_detail
-# define COMPACT_GOOGLE_LOG_0 GLOG_ERROR_MSG
-# define SYSLOG_0 GLOG_ERROR_MSG
-# define LOG_TO_STRING_0 GLOG_ERROR_MSG
-# define GLOG_0 GLOG_ERROR_MSG
-#endif
-
-// Plus some debug-logging macros that get compiled to nothing for production
-
-#ifndef NDEBUG
-
-#define DLOG(severity) LOG(severity)
-#define DVLOG(verboselevel) VLOG(verboselevel)
-#define DLOG_IF(severity, condition) LOG_IF(severity, condition)
-#define DLOG_EVERY_N(severity, n) LOG_EVERY_N(severity, n)
-#define DLOG_IF_EVERY_N(severity, condition, n) \
-  LOG_IF_EVERY_N(severity, condition, n)
-#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
-
-// debug-only checking.  not executed in NDEBUG mode.
-#define DCHECK(condition) CHECK(condition)
-#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2)
-#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2)
-#define DCHECK_LE(val1, val2) CHECK_LE(val1, val2)
-#define DCHECK_LT(val1, val2) CHECK_LT(val1, val2)
-#define DCHECK_GE(val1, val2) CHECK_GE(val1, val2)
-#define DCHECK_GT(val1, val2) CHECK_GT(val1, val2)
-#define DCHECK_NOTNULL(val) CHECK_NOTNULL(val)
-#define DCHECK_STREQ(str1, str2) CHECK_STREQ(str1, str2)
-#define DCHECK_STRCASEEQ(str1, str2) CHECK_STRCASEEQ(str1, str2)
-#define DCHECK_STRNE(str1, str2) CHECK_STRNE(str1, str2)
-#define DCHECK_STRCASENE(str1, str2) CHECK_STRCASENE(str1, str2)
-
-#else  // NDEBUG
-
-#define DLOG(severity) \
-  true ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DVLOG(verboselevel) \
-  (true || !VLOG_IS_ON(verboselevel)) ?\
-    (void) 0 : google::LogMessageVoidify() & LOG(INFO)
-
-#define DLOG_IF(severity, condition) \
-  (true || !(condition)) ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_EVERY_N(severity, n) \
-  true ? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_IF_EVERY_N(severity, condition, n) \
-  (true || !(condition))? (void) 0 : google::LogMessageVoidify() & LOG(severity)
-
-#define DLOG_ASSERT(condition) \
-  true ? (void) 0 : LOG_ASSERT(condition)
-
-// MSVC warning C4127: conditional expression is constant
-#define DCHECK(condition) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK(condition)
-
-#define DCHECK_EQ(val1, val2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_EQ(val1, val2)
-
-#define DCHECK_NE(val1, val2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_NE(val1, val2)
-
-#define DCHECK_LE(val1, val2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_LE(val1, val2)
-
-#define DCHECK_LT(val1, val2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_LT(val1, val2)
-
-#define DCHECK_GE(val1, val2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_GE(val1, val2)
-
-#define DCHECK_GT(val1, val2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_GT(val1, val2)
-
-// You may see warnings in release mode if you don't use the return
-// value of DCHECK_NOTNULL. Please just use DCHECK for such cases.
-#define DCHECK_NOTNULL(val) (val)
-
-#define DCHECK_STREQ(str1, str2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_STREQ(str1, str2)
-
-#define DCHECK_STRCASEEQ(str1, str2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_STRCASEEQ(str1, str2)
-
-#define DCHECK_STRNE(str1, str2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_STRNE(str1, str2)
-
-#define DCHECK_STRCASENE(str1, str2) \
-  GLOG_MSVC_PUSH_DISABLE_WARNING(4127) \
-  while (false) \
-    GLOG_MSVC_POP_WARNING() CHECK_STRCASENE(str1, str2)
-
-#endif  // NDEBUG
-
-// Log only in verbose mode.
-
-#define VLOG(verboselevel) LOG_IF(INFO, VLOG_IS_ON(verboselevel))
-
-#define VLOG_IF(verboselevel, condition) \
-  LOG_IF(INFO, (condition) && VLOG_IS_ON(verboselevel))
-
-#define VLOG_EVERY_N(verboselevel, n) \
-  LOG_IF_EVERY_N(INFO, VLOG_IS_ON(verboselevel), n)
-
-#define VLOG_IF_EVERY_N(verboselevel, condition, n) \
-  LOG_IF_EVERY_N(INFO, (condition) && VLOG_IS_ON(verboselevel), n)
-
-namespace base_logging {
-
-// LogMessage::LogStream is a std::ostream backed by this streambuf.
-// This class ignores overflow and leaves two bytes at the end of the
-// buffer to allow for a '\n' and '\0'.
-class LogStreamBuf : public std::streambuf {
- public:
-  // REQUIREMENTS: "len" must be >= 2 to account for the '\n' and '\n'.
-  LogStreamBuf(char *buf, int len) {
-    setp(buf, buf + len - 2);
-  }
-  // This effectively ignores overflow.
-  virtual int_type overflow(int_type ch) {
-    return ch;
-  }
-
-  // Legacy public ostrstream method.
-  size_t pcount() const { return pptr() - pbase(); }
-  char* pbase() const { return std::streambuf::pbase(); }
-};
-
-}  // namespace base_logging
-
-//
-// This class more or less represents a particular log message.  You
-// create an instance of LogMessage and then stream stuff to it.
-// When you finish streaming to it, ~LogMessage is called and the
-// full message gets streamed to the appropriate destination.
-//
-// You shouldn't actually use LogMessage's constructor to log things,
-// though.  You should use the LOG() macro (and variants thereof)
-// above.
-class GOOGLE_GLOG_DLL_DECL LogMessage {
-public:
-  enum {
-    // Passing kNoLogPrefix for the line number disables the
-    // log-message prefix. Useful for using the LogMessage
-    // infrastructure as a printing utility. See also the --log_prefix
-    // flag for controlling the log-message prefix on an
-    // application-wide basis.
-    kNoLogPrefix = -1
-  };
-
-  // LogStream inherit from non-DLL-exported class (std::ostrstream)
-  // and VC++ produces a warning for this situation.
-  // However, MSDN says "C4275 can be ignored in Microsoft Visual C++
-  // 2005 if you are deriving from a type in the Standard C++ Library"
-  // http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx
-  // Let's just ignore the warning.
-#ifdef _MSC_VER
-# pragma warning(disable: 4275)
-#endif
-  class GOOGLE_GLOG_DLL_DECL LogStream : public std::ostream {
-#ifdef _MSC_VER
-# pragma warning(default: 4275)
-#endif
-  public:
-    LogStream(char *buf, int len, int ctr)
-        : std::ostream(NULL),
-          streambuf_(buf, len),
-          ctr_(ctr),
-          self_(this) {
-      rdbuf(&streambuf_);
-    }
-
-    int ctr() const { return ctr_; }
-    void set_ctr(int ctr) { ctr_ = ctr; }
-    LogStream* self() const { return self_; }
-
-    // Legacy std::streambuf methods.
-    size_t pcount() const { return streambuf_.pcount(); }
-    char* pbase() const { return streambuf_.pbase(); }
-    char* str() const { return pbase(); }
-
-  private:
-    base_logging::LogStreamBuf streambuf_;
-    int ctr_;  // Counter hack (for the LOG_EVERY_X() macro)
-    LogStream *self_;  // Consistency check hack
-  };
-
-public:
-  // icc 8 requires this typedef to avoid an internal compiler error.
-  typedef void (LogMessage::*SendMethod)();
-
-  LogMessage(const char* file, int line, LogSeverity severity, int ctr,
-             SendMethod send_method);
-
-  // Two special constructors that generate reduced amounts of code at
-  // LOG call sites for common cases.
-
-  // Used for LOG(INFO): Implied are:
-  // severity = INFO, ctr = 0, send_method = &LogMessage::SendToLog.
-  //
-  // Using this constructor instead of the more complex constructor above
-  // saves 19 bytes per call site.
-  LogMessage(const char* file, int line);
-
-  // Used for LOG(severity) where severity != INFO.  Implied
-  // are: ctr = 0, send_method = &LogMessage::SendToLog
-  //
-  // Using this constructor instead of the more complex constructor above
-  // saves 17 bytes per call site.
-  LogMessage(const char* file, int line, LogSeverity severity);
-
-  // Constructor to log this message to a specified sink (if not NULL).
-  // Implied are: ctr = 0, send_method = &LogMessage::SendToSinkAndLog if
-  // also_send_to_log is true, send_method = &LogMessage::SendToSink otherwise.
-  LogMessage(const char* file, int line, LogSeverity severity, LogSink* sink,
-             bool also_send_to_log);
-
-  // Constructor where we also give a vector<string> pointer
-  // for storing the messages (if the pointer is not NULL).
-  // Implied are: ctr = 0, send_method = &LogMessage::SaveOrSendToLog.
-  LogMessage(const char* file, int line, LogSeverity severity,
-             std::vector<std::string>* outvec);
-
-  // Constructor where we also give a string pointer for storing the
-  // message (if the pointer is not NULL).  Implied are: ctr = 0,
-  // send_method = &LogMessage::WriteToStringAndLog.
-  LogMessage(const char* file, int line, LogSeverity severity,
-             std::string* message);
-
-  // A special constructor used for check failures
-  LogMessage(const char* file, int line, const CheckOpString& result);
-
-  ~LogMessage();
-
-  // Flush a buffered message to the sink set in the constructor.  Always
-  // called by the destructor, it may also be called from elsewhere if
-  // needed.  Only the first call is actioned; any later ones are ignored.
-  void Flush();
-
-  // An arbitrary limit on the length of a single log message.  This
-  // is so that streaming can be done more efficiently.
-  static const size_t kMaxLogMessageLen;
-
-  // Theses should not be called directly outside of logging.*,
-  // only passed as SendMethod arguments to other LogMessage methods:
-  void SendToLog();  // Actually dispatch to the logs
-  void SendToSyslogAndLog();  // Actually dispatch to syslog and the logs
-
-  // Call abort() or similar to perform LOG(FATAL) crash.
-  static void Fail() ;
-
-  std::ostream& stream();
-
-  int preserved_errno() const;
-
-  // Must be called without the log_mutex held.  (L < log_mutex)
-  static int64 num_messages(int severity);
-
-  struct LogMessageData;
-
-private:
-  // Fully internal SendMethod cases:
-  void SendToSinkAndLog();  // Send to sink if provided and dispatch to the logs
-  void SendToSink();  // Send to sink if provided, do nothing otherwise.
-
-  // Write to string if provided and dispatch to the logs.
-  void WriteToStringAndLog();
-
-  void SaveOrSendToLog();  // Save to stringvec if provided, else to logs
-
-  void Init(const char* file, int line, LogSeverity severity,
-            void (LogMessage::*send_method)());
-
-  // Used to fill in crash information during LOG(FATAL) failures.
-  void RecordCrashReason(glog_internal_namespace_::CrashReason* reason);
-
-  // Counts of messages sent at each priority:
-  static int64 num_messages_[NUM_SEVERITIES];  // under log_mutex
-
-  // We keep the data in a separate struct so that each instance of
-  // LogMessage uses less stack space.
-  LogMessageData* allocated_;
-  LogMessageData* data_;
-
-  friend class LogDestination;
-
-  LogMessage(const LogMessage&);
-  void operator=(const LogMessage&);
-};
-
-// This class happens to be thread-hostile because all instances share
-// a single data buffer, but since it can only be created just before
-// the process dies, we don't worry so much.
-class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage {
- public:
-  LogMessageFatal(const char* file, int line);
-  LogMessageFatal(const char* file, int line, const CheckOpString& result);
-  ~LogMessageFatal() ;
-};
-
-// A non-macro interface to the log facility; (useful
-// when the logging level is not a compile-time constant).
-inline void LogAtLevel(int const severity, std::string const &msg) {
-  LogMessage(__FILE__, __LINE__, severity).stream() << msg;
-}
-
-// A macro alternative of LogAtLevel. New code may want to use this
-// version since there are two advantages: 1. this version outputs the
-// file name and the line number where this macro is put like other
-// LOG macros, 2. this macro can be used as C++ stream.
-#define LOG_AT_LEVEL(severity) google::LogMessage(__FILE__, __LINE__, severity).stream()
-
-// A small helper for CHECK_NOTNULL().
-template <typename T>
-T* CheckNotNull(const char *file, int line, const char *names, T* t) {
-  if (t == NULL) {
-    LogMessageFatal(file, line, new std::string(names));
-  }
-  return t;
-}
-
-// Allow folks to put a counter in the LOG_EVERY_X()'ed messages. This
-// only works if ostream is a LogStream. If the ostream is not a
-// LogStream you'll get an assert saying as much at runtime.
-GOOGLE_GLOG_DLL_DECL std::ostream& operator<<(std::ostream &os,
-                                              const PRIVATE_Counter&);
-
-
-// Derived class for PLOG*() above.
-class GOOGLE_GLOG_DLL_DECL ErrnoLogMessage : public LogMessage {
- public:
-
-  ErrnoLogMessage(const char* file, int line, LogSeverity severity, int ctr,
-                  void (LogMessage::*send_method)());
-
-  // Postpends ": strerror(errno) [errno]".
-  ~ErrnoLogMessage();
-
- private:
-  ErrnoLogMessage(const ErrnoLogMessage&);
-  void operator=(const ErrnoLogMessage&);
-};
-
-
-// This class is used to explicitly ignore values in the conditional
-// logging macros.  This avoids compiler warnings like "value computed
-// is not used" and "statement has no effect".
-
-class GOOGLE_GLOG_DLL_DECL LogMessageVoidify {
- public:
-  LogMessageVoidify() { }
-  // This has to be an operator with a precedence lower than << but
-  // higher than ?:
-  void operator&(std::ostream&) { }
-};
-
-
-// Flushes all log files that contains messages that are at least of
-// the specified severity level.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL void FlushLogFiles(LogSeverity min_severity);
-
-// Flushes all log files that contains messages that are at least of
-// the specified severity level. Thread-hostile because it ignores
-// locking -- used for catastrophic failures.
-GOOGLE_GLOG_DLL_DECL void FlushLogFilesUnsafe(LogSeverity min_severity);
-
-//
-// Set the destination to which a particular severity level of log
-// messages is sent.  If base_filename is "", it means "don't log this
-// severity".  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogDestination(LogSeverity severity,
-                                            const char* base_filename);
-
-//
-// Set the basename of the symlink to the latest log file at a given
-// severity.  If symlink_basename is empty, do not make a symlink.  If
-// you don't call this function, the symlink basename is the
-// invocation name of the program.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogSymlink(LogSeverity severity,
-                                        const char* symlink_basename);
-
-//
-// Used to send logs to some other kind of destination
-// Users should subclass LogSink and override send to do whatever they want.
-// Implementations must be thread-safe because a shared instance will
-// be called from whichever thread ran the LOG(XXX) line.
-class GOOGLE_GLOG_DLL_DECL LogSink {
- public:
-  virtual ~LogSink();
-
-  // Sink's logging logic (message_len is such as to exclude '\n' at the end).
-  // This method can't use LOG() or CHECK() as logging system mutex(s) are held
-  // during this call.
-  virtual void send(LogSeverity severity, const char* full_filename,
-                    const char* base_filename, int line,
-                    const struct ::tm* tm_time,
-                    const char* message, size_t message_len) = 0;
-
-  // Redefine this to implement waiting for
-  // the sink's logging logic to complete.
-  // It will be called after each send() returns,
-  // but before that LogMessage exits or crashes.
-  // By default this function does nothing.
-  // Using this function one can implement complex logic for send()
-  // that itself involves logging; and do all this w/o causing deadlocks and
-  // inconsistent rearrangement of log messages.
-  // E.g. if a LogSink has thread-specific actions, the send() method
-  // can simply add the message to a queue and wake up another thread that
-  // handles real logging while itself making some LOG() calls;
-  // WaitTillSent() can be implemented to wait for that logic to complete.
-  // See our unittest for an example.
-  virtual void WaitTillSent();
-
-  // Returns the normal text output of the log message.
-  // Can be useful to implement send().
-  static std::string ToString(LogSeverity severity, const char* file, int line,
-                              const struct ::tm* tm_time,
-                              const char* message, size_t message_len);
-};
-
-// Add or remove a LogSink as a consumer of logging data.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL void AddLogSink(LogSink *destination);
-GOOGLE_GLOG_DLL_DECL void RemoveLogSink(LogSink *destination);
-
-//
-// Specify an "extension" added to the filename specified via
-// SetLogDestination.  This applies to all severity levels.  It's
-// often used to append the port we're listening on to the logfile
-// name.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetLogFilenameExtension(
-    const char* filename_extension);
-
-//
-// Make it so that all log messages of at least a particular severity
-// are logged to stderr (in addition to logging to the usual log
-// file(s)).  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetStderrLogging(LogSeverity min_severity);
-
-//
-// Make it so that all log messages go only to stderr.  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void LogToStderr();
-
-//
-// Make it so that all log messages of at least a particular severity are
-// logged via email to a list of addresses (in addition to logging to the
-// usual log file(s)).  The list of addresses is just a string containing
-// the email addresses to send to (separated by spaces, say).  Thread-safe.
-//
-GOOGLE_GLOG_DLL_DECL void SetEmailLogging(LogSeverity min_severity,
-                                          const char* addresses);
-
-// A simple function that sends email. dest is a commma-separated
-// list of addressess.  Thread-safe.
-GOOGLE_GLOG_DLL_DECL bool SendEmail(const char *dest,
-                                    const char *subject, const char *body);
-
-GOOGLE_GLOG_DLL_DECL const std::vector<std::string>& GetLoggingDirectories();
-
-// For tests only:  Clear the internal [cached] list of logging directories to
-// force a refresh the next time GetLoggingDirectories is called.
-// Thread-hostile.
-void TestOnly_ClearLoggingDirectoriesList();
-
-// Returns a set of existing temporary directories, which will be a
-// subset of the directories returned by GetLogginDirectories().
-// Thread-safe.
-GOOGLE_GLOG_DLL_DECL void GetExistingTempDirectories(
-    std::vector<std::string>* list);
-
-// Print any fatal message again -- useful to call from signal handler
-// so that the last thing in the output is the fatal message.
-// Thread-hostile, but a race is unlikely.
-GOOGLE_GLOG_DLL_DECL void ReprintFatalMessage();
-
-// Truncate a log file that may be the append-only output of multiple
-// processes and hence can't simply be renamed/reopened (typically a
-// stdout/stderr).  If the file "path" is > "limit" bytes, copy the
-// last "keep" bytes to offset 0 and truncate the rest. Since we could
-// be racing with other writers, this approach has the potential to
-// lose very small amounts of data. For security, only follow symlinks
-// if the path is /proc/self/fd/*
-GOOGLE_GLOG_DLL_DECL void TruncateLogFile(const char *path,
-                                          int64 limit, int64 keep);
-
-// Truncate stdout and stderr if they are over the value specified by
-// --max_log_size; keep the final 1MB.  This function has the same
-// race condition as TruncateLogFile.
-GOOGLE_GLOG_DLL_DECL void TruncateStdoutStderr();
-
-// Return the string representation of the provided LogSeverity level.
-// Thread-safe.
-GOOGLE_GLOG_DLL_DECL const char* GetLogSeverityName(LogSeverity severity);
-
-// ---------------------------------------------------------------------
-// Implementation details that are not useful to most clients
-// ---------------------------------------------------------------------
-
-// A Logger is the interface used by logging modules to emit entries
-// to a log.  A typical implementation will dump formatted data to a
-// sequence of files.  We also provide interfaces that will forward
-// the data to another thread so that the invoker never blocks.
-// Implementations should be thread-safe since the logging system
-// will write to them from multiple threads.
-
-namespace base {
-
-class GOOGLE_GLOG_DLL_DECL Logger {
- public:
-  virtual ~Logger();
-
-  // Writes "message[0,message_len-1]" corresponding to an event that
-  // occurred at "timestamp".  If "force_flush" is true, the log file
-  // is flushed immediately.
-  //
-  // The input message has already been formatted as deemed
-  // appropriate by the higher level logging facility.  For example,
-  // textual log messages already contain timestamps, and the
-  // file:linenumber header.
-  virtual void Write(bool force_flush,
-                     time_t timestamp,
-                     const char* message,
-                     int message_len) = 0;
-
-  // Flush any buffered messages
-  virtual void Flush() = 0;
-
-  // Get the current LOG file size.
-  // The returned value is approximate since some
-  // logged data may not have been flushed to disk yet.
-  virtual uint32 LogSize() = 0;
-};
-
-// Get the logger for the specified severity level.  The logger
-// remains the property of the logging module and should not be
-// deleted by the caller.  Thread-safe.
-extern GOOGLE_GLOG_DLL_DECL Logger* GetLogger(LogSeverity level);
-
-// Set the logger for the specified severity level.  The logger
-// becomes the property of the logging module and should not
-// be deleted by the caller.  Thread-safe.
-extern GOOGLE_GLOG_DLL_DECL void SetLogger(LogSeverity level, Logger* logger);
-
-}
-
-// glibc has traditionally implemented two incompatible versions of
-// strerror_r(). There is a poorly defined convention for picking the
-// version that we want, but it is not clear whether it even works with
-// all versions of glibc.
-// So, instead, we provide this wrapper that automatically detects the
-// version that is in use, and then implements POSIX semantics.
-// N.B. In addition to what POSIX says, we also guarantee that "buf" will
-// be set to an empty string, if this function failed. This means, in most
-// cases, you do not need to check the error code and you can directly
-// use the value of "buf". It will never have an undefined value.
-GOOGLE_GLOG_DLL_DECL int posix_strerror_r(int err, char *buf, size_t len);
-
-
-// A class for which we define operator<<, which does nothing.
-class GOOGLE_GLOG_DLL_DECL NullStream : public LogMessage::LogStream {
- public:
-  // Initialize the LogStream so the messages can be written somewhere
-  // (they'll never be actually displayed). This will be needed if a
-  // NullStream& is implicitly converted to LogStream&, in which case
-  // the overloaded NullStream::operator<< will not be invoked.
-  NullStream() : LogMessage::LogStream(message_buffer_, 1, 0) { }
-  NullStream(const char* /*file*/, int /*line*/,
-             const CheckOpString& /*result*/) :
-      LogMessage::LogStream(message_buffer_, 1, 0) { }
-  NullStream &stream() { return *this; }
- private:
-  // A very short buffer for messages (which we discard anyway). This
-  // will be needed if NullStream& converted to LogStream& (e.g. as a
-  // result of a conditional expression).
-  char message_buffer_[2];
-};
-
-// Do nothing. This operator is inline, allowing the message to be
-// compiled away. The message will not be compiled away if we do
-// something like (flag ? LOG(INFO) : LOG(ERROR)) << message; when
-// SKIP_LOG=WARNING. In those cases, NullStream will be implicitly
-// converted to LogStream and the message will be computed and then
-// quietly discarded.
-template<class T>
-inline NullStream& operator<<(NullStream &str, const T &) { return str; }
-
-// Similar to NullStream, but aborts the program (without stack
-// trace), like LogMessageFatal.
-class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream {
- public:
-  NullStreamFatal() { }
-  NullStreamFatal(const char* file, int line, const CheckOpString& result) :
-      NullStream(file, line, result) { }
-   ~NullStreamFatal() { _exit(1); }
-};
-
-// Install a signal handler that will dump signal information and a stack
-// trace when the program crashes on certain signals.  We'll install the
-// signal handler for the following signals.
-//
-// SIGSEGV, SIGILL, SIGFPE, SIGABRT, SIGBUS, and SIGTERM.
-//
-// By default, the signal handler will write the failure dump to the
-// standard error.  You can customize the destination by installing your
-// own writer function by InstallFailureWriter() below.
-//
-// Note on threading:
-//
-// The function should be called before threads are created, if you want
-// to use the failure signal handler for all threads.  The stack trace
-// will be shown only for the thread that receives the signal.  In other
-// words, stack traces of other threads won't be shown.
-GOOGLE_GLOG_DLL_DECL void InstallFailureSignalHandler();
-
-// Installs a function that is used for writing the failure dump.  "data"
-// is the pointer to the beginning of a message to be written, and "size"
-// is the size of the message.  You should not expect the data is
-// terminated with '\0'.
-GOOGLE_GLOG_DLL_DECL void InstallFailureWriter(
-    void (*writer)(const char* data, int size));
-
-}
-
-#endif // _LOGGING_H_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/glog/raw_logging.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/glog/raw_logging.h b/third_party/src/glog/src/windows/glog/raw_logging.h
deleted file mode 100644
index 4757a71..0000000
--- a/third_party/src/glog/src/windows/glog/raw_logging.h
+++ /dev/null
@@ -1,189 +0,0 @@
-// This file is automatically generated from src/glog/raw_logging.h.in
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Maxim Lifantsev
-//
-// Thread-safe logging routines that do not allocate any memory or
-// acquire any locks, and can therefore be used by low-level memory
-// allocation and synchronization code.
-
-#ifndef BASE_RAW_LOGGING_H_
-#define BASE_RAW_LOGGING_H_
-
-#include <time.h>
-
-namespace google {
-
-#include "glog/log_severity.h"
-#include "glog/vlog_is_on.h"
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-// This is similar to LOG(severity) << format... and VLOG(level) << format..,
-// but
-// * it is to be used ONLY by low-level modules that can't use normal LOG()
-// * it is desiged to be a low-level logger that does not allocate any
-//   memory and does not need any locks, hence:
-// * it logs straight and ONLY to STDERR w/o buffering
-// * it uses an explicit format and arguments list
-// * it will silently chop off really long message strings
-// Usage example:
-//   RAW_LOG(ERROR, "Failed foo with %i: %s", status, error);
-//   RAW_VLOG(3, "status is %i", status);
-// These will print an almost standard log lines like this to stderr only:
-//   E0821 211317 file.cc:123] RAW: Failed foo with 22: bad_file
-//   I0821 211317 file.cc:142] RAW: status is 20
-#define RAW_LOG(severity, ...) \
-  do { \
-    switch (google::GLOG_ ## severity) {  \
-      case 0: \
-        RAW_LOG_INFO(__VA_ARGS__); \
-        break; \
-      case 1: \
-        RAW_LOG_WARNING(__VA_ARGS__); \
-        break; \
-      case 2: \
-        RAW_LOG_ERROR(__VA_ARGS__); \
-        break; \
-      case 3: \
-        RAW_LOG_FATAL(__VA_ARGS__); \
-        break; \
-      default: \
-        break; \
-    } \
-  } while (0)
-
-// The following STRIP_LOG testing is performed in the header file so that it's
-// possible to completely compile out the logging code and the log messages.
-#if STRIP_LOG == 0
-#define RAW_VLOG(verboselevel, ...) \
-  do { \
-    if (VLOG_IS_ON(verboselevel)) { \
-      RAW_LOG_INFO(__VA_ARGS__); \
-    } \
-  } while (0)
-#else
-#define RAW_VLOG(verboselevel, ...) RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG == 0
-
-#if STRIP_LOG == 0
-#define RAW_LOG_INFO(...) google::RawLog__(google::GLOG_INFO, \
-                                   __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG == 0
-
-#if STRIP_LOG <= 1
-#define RAW_LOG_WARNING(...) google::RawLog__(google::GLOG_WARNING,   \
-                                      __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG <= 1
-
-#if STRIP_LOG <= 2
-#define RAW_LOG_ERROR(...) google::RawLog__(google::GLOG_ERROR,       \
-                                    __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__)
-#endif // STRIP_LOG <= 2
-
-#if STRIP_LOG <= 3
-#define RAW_LOG_FATAL(...) google::RawLog__(google::GLOG_FATAL,       \
-                                    __FILE__, __LINE__, __VA_ARGS__)
-#else
-#define RAW_LOG_FATAL(...) \
-  do { \
-    google::RawLogStub__(0, __VA_ARGS__);        \
-    exit(1); \
-  } while (0)
-#endif // STRIP_LOG <= 3
-
-// Similar to CHECK(condition) << message,
-// but for low-level modules: we use only RAW_LOG that does not allocate memory.
-// We do not want to provide args list here to encourage this usage:
-//   if (!cond)  RAW_LOG(FATAL, "foo ...", hard_to_compute_args);
-// so that the args are not computed when not needed.
-#define RAW_CHECK(condition, message)                                   \
-  do {                                                                  \
-    if (!(condition)) {                                                 \
-      RAW_LOG(FATAL, "Check %s failed: %s", #condition, message);       \
-    }                                                                   \
-  } while (0)
-
-// Debug versions of RAW_LOG and RAW_CHECK
-#ifndef NDEBUG
-
-#define RAW_DLOG(severity, ...) RAW_LOG(severity, __VA_ARGS__)
-#define RAW_DCHECK(condition, message) RAW_CHECK(condition, message)
-
-#else  // NDEBUG
-
-#define RAW_DLOG(severity, ...)                                 \
-  while (false)                                                 \
-    RAW_LOG(severity, __VA_ARGS__)
-#define RAW_DCHECK(condition, message) \
-  while (false) \
-    RAW_CHECK(condition, message)
-
-#endif  // NDEBUG
-
-// Stub log function used to work around for unused variable warnings when
-// building with STRIP_LOG > 0.
-static inline void RawLogStub__(int /* ignored */, ...) {
-}
-
-// Helper function to implement RAW_LOG and RAW_VLOG
-// Logs format... at "severity" level, reporting it
-// as called from file:line.
-// This does not allocate memory or acquire locks.
-GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity,
-                                   const char* file,
-                                   int line,
-                                   const char* format, ...)
-   ;
-
-// Hack to propagate time information into this module so that
-// this module does not have to directly call localtime_r(),
-// which could allocate memory.
-GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct tm& t, int usecs);
-
-}
-
-#endif  // BASE_RAW_LOGGING_H_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/glog/stl_logging.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/glog/stl_logging.h b/third_party/src/glog/src/windows/glog/stl_logging.h
deleted file mode 100644
index d2e7495..0000000
--- a/third_party/src/glog/src/windows/glog/stl_logging.h
+++ /dev/null
@@ -1,187 +0,0 @@
-// This file is automatically generated from src/glog/stl_logging.h.in
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-
-// Copyright (c) 2003, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Stream output operators for STL containers; to be used for logging *only*.
-// Inclusion of this file lets you do:
-//
-// list<string> x;
-// LOG(INFO) << "data: " << x;
-// vector<int> v1, v2;
-// CHECK_EQ(v1, v2);
-
-#ifndef UTIL_GTL_STL_LOGGING_INL_H_
-#define UTIL_GTL_STL_LOGGING_INL_H_
-
-#if !1
-# error We do not support stl_logging for this compiler
-#endif
-
-#include <deque>
-#include <list>
-#include <map>
-#include <ostream>
-#include <set>
-#include <utility>
-#include <vector>
-
-#ifdef __GNUC__
-# include <ext/hash_set>
-# include <ext/hash_map>
-# include <ext/slist>
-#endif
-
-// Forward declare these two, and define them after all the container streams
-// operators so that we can recurse from pair -> container -> container -> pair
-// properly.
-template<class First, class Second>
-std::ostream& operator<<(std::ostream& out, const std::pair<First, Second>& p);
-
-namespace google {
-
-template<class Iter>
-void PrintSequence(std::ostream& out, Iter begin, Iter end);
-
-}
-
-#define OUTPUT_TWO_ARG_CONTAINER(Sequence) \
-template<class T1, class T2> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_TWO_ARG_CONTAINER(std::vector)
-OUTPUT_TWO_ARG_CONTAINER(std::deque)
-OUTPUT_TWO_ARG_CONTAINER(std::list)
-#ifdef __GNUC__
-OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist)
-#endif
-
-#undef OUTPUT_TWO_ARG_CONTAINER
-
-#define OUTPUT_THREE_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_THREE_ARG_CONTAINER(std::set)
-OUTPUT_THREE_ARG_CONTAINER(std::multiset)
-
-#undef OUTPUT_THREE_ARG_CONTAINER
-
-#define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3, class T4> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3, T4>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-OUTPUT_FOUR_ARG_CONTAINER(std::map)
-OUTPUT_FOUR_ARG_CONTAINER(std::multimap)
-#ifdef __GNUC__
-OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set)
-OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset)
-#endif
-
-#undef OUTPUT_FOUR_ARG_CONTAINER
-
-#define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \
-template<class T1, class T2, class T3, class T4, class T5> \
-inline std::ostream& operator<<(std::ostream& out, \
-                                const Sequence<T1, T2, T3, T4, T5>& seq) { \
-  google::PrintSequence(out, seq.begin(), seq.end()); \
-  return out; \
-}
-
-#ifdef __GNUC__
-OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map)
-OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap)
-#endif
-
-#undef OUTPUT_FIVE_ARG_CONTAINER
-
-template<class First, class Second>
-inline std::ostream& operator<<(std::ostream& out,
-                                const std::pair<First, Second>& p) {
-  out << '(' << p.first << ", " << p.second << ')';
-  return out;
-}
-
-namespace google {
-
-template<class Iter>
-inline void PrintSequence(std::ostream& out, Iter begin, Iter end) {
-  // Output at most 100 elements -- appropriate if used for logging.
-  for (int i = 0; begin != end && i < 100; ++i, ++begin) {
-    if (i > 0) out << ' ';
-    out << *begin;
-  }
-  if (begin != end) {
-    out << " ...";
-  }
-}
-
-}
-
-// Note that this is technically undefined behavior! We are adding things into
-// the std namespace for a reason though -- we are providing new operations on
-// types which are themselves defined with this namespace. Without this, these
-// operator overloads cannot be found via ADL. If these definitions are not
-// found via ADL, they must be #included before they're used, which requires
-// this header to be included before apparently independent other headers.
-//
-// For example, base/logging.h defines various template functions to implement
-// CHECK_EQ(x, y) and stream x and y into the log in the event the check fails.
-// It does so via the function template MakeCheckOpValueString:
-//   template<class T>
-//   void MakeCheckOpValueString(strstream* ss, const T& v) {
-//     (*ss) << v;
-//   }
-// Because 'glog/logging.h' is included before 'glog/stl_logging.h',
-// subsequent CHECK_EQ(v1, v2) for vector<...> typed variable v1 and v2 can only
-// find these operator definitions via ADL.
-//
-// Even this solution has problems -- it may pull unintended operators into the
-// namespace as well, allowing them to also be found via ADL, and creating code
-// that only works with a particular order of includes. Long term, we need to
-// move all of the *definitions* into namespace std, bet we need to ensure no
-// one references them first. This lets us take that step. We cannot define them
-// in both because that would create ambiguous overloads when both are found.
-namespace std { using ::operator<<; }
-
-#endif  // UTIL_GTL_STL_LOGGING_INL_H_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/windows/glog/vlog_is_on.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/windows/glog/vlog_is_on.h b/third_party/src/glog/src/windows/glog/vlog_is_on.h
deleted file mode 100644
index 409a401..0000000
--- a/third_party/src/glog/src/windows/glog/vlog_is_on.h
+++ /dev/null
@@ -1,133 +0,0 @@
-// This file is automatically generated from src/glog/vlog_is_on.h.in
-// using src/windows/preprocess.sh.
-// DO NOT EDIT!
-
-// Copyright (c) 1999, 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Ray Sidney and many others
-//
-// Defines the VLOG_IS_ON macro that controls the variable-verbosity
-// conditional logging.
-//
-// It's used by VLOG and VLOG_IF in logging.h
-// and by RAW_VLOG in raw_logging.h to trigger the logging.
-//
-// It can also be used directly e.g. like this:
-//   if (VLOG_IS_ON(2)) {
-//     // do some logging preparation and logging
-//     // that can't be accomplished e.g. via just VLOG(2) << ...;
-//   }
-//
-// The truth value that VLOG_IS_ON(level) returns is determined by 
-// the three verbosity level flags:
-//   --v=<n>  Gives the default maximal active V-logging level;
-//            0 is the default.
-//            Normally positive values are used for V-logging levels.
-//   --vmodule=<str>  Gives the per-module maximal V-logging levels to override
-//                    the value given by --v.
-//                    E.g. "my_module=2,foo*=3" would change the logging level
-//                    for all code in source files "my_module.*" and "foo*.*"
-//                    ("-inl" suffixes are also disregarded for this matching).
-//
-// SetVLOGLevel helper function is provided to do limited dynamic control over
-// V-logging by overriding the per-module settings given via --vmodule flag.
-//
-// CAVEAT: --vmodule functionality is not available in non gcc compilers.
-//
-
-#ifndef BASE_VLOG_IS_ON_H_
-#define BASE_VLOG_IS_ON_H_
-
-#include "glog/log_severity.h"
-
-// Annoying stuff for windows -- makes sure clients can import these functions
-#ifndef GOOGLE_GLOG_DLL_DECL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
-# else
-#   define GOOGLE_GLOG_DLL_DECL
-# endif
-#endif
-
-#if defined(__GNUC__)
-// We emit an anonymous static int* variable at every VLOG_IS_ON(n) site.
-// (Normally) the first time every VLOG_IS_ON(n) site is hit,
-// we determine what variable will dynamically control logging at this site:
-// it's either FLAGS_v or an appropriate internal variable
-// matching the current source file that represents results of
-// parsing of --vmodule flag and/or SetVLOGLevel calls.
-#define VLOG_IS_ON(verboselevel)                                \
-  __extension__  \
-  ({ static google::int32* vlocal__ = &google::kLogSiteUninitialized;           \
-     google::int32 verbose_level__ = (verboselevel);                    \
-     (*vlocal__ >= verbose_level__) &&                          \
-     ((vlocal__ != &google::kLogSiteUninitialized) ||                   \
-      (google::InitVLOG3__(&vlocal__, &FLAGS_v,                         \
-                   __FILE__, verbose_level__))); })
-#else
-// GNU extensions not available, so we do not support --vmodule.
-// Dynamic value of FLAGS_v always controls the logging level.
-#define VLOG_IS_ON(verboselevel) (FLAGS_v >= (verboselevel))
-#endif
-
-// Set VLOG(_IS_ON) level for module_pattern to log_level.
-// This lets us dynamically control what is normally set by the --vmodule flag.
-// Returns the level that previously applied to module_pattern.
-// NOTE: To change the log level for VLOG(_IS_ON) sites
-//	 that have already executed after/during InitGoogleLogging,
-//	 one needs to supply the exact --vmodule pattern that applied to them.
-//       (If no --vmodule pattern applied to them
-//       the value of FLAGS_v will continue to control them.)
-extern GOOGLE_GLOG_DLL_DECL int SetVLOGLevel(const char* module_pattern,
-                                             int log_level);
-
-// Various declarations needed for VLOG_IS_ON above: =========================
-
-// Special value used to indicate that a VLOG_IS_ON site has not been
-// initialized.  We make this a large value, so the common-case check
-// of "*vlocal__ >= verbose_level__" in VLOG_IS_ON definition
-// passes in such cases and InitVLOG3__ is then triggered.
-extern google::int32 kLogSiteUninitialized;
-
-// Helper routine which determines the logging info for a particalur VLOG site.
-//   site_flag     is the address of the site-local pointer to the controlling
-//                 verbosity level
-//   site_default  is the default to use for *site_flag
-//   fname         is the current source file name
-//   verbose_level is the argument to VLOG_IS_ON
-// We will return the return value for VLOG_IS_ON
-// and if possible set *site_flag appropriately.
-extern GOOGLE_GLOG_DLL_DECL bool InitVLOG3__(
-    google::int32** site_flag,
-    google::int32* site_default,
-    const char* fname,
-    google::int32 verbose_level);
-
-#endif  // BASE_VLOG_IS_ON_H_


[22/46] incubator-quickstep git commit: Support Multiple Tuple Inserts

Posted by ji...@apache.org.
Support Multiple Tuple Inserts

Update Fetch


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/0fe838df
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/0fe838df
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/0fe838df

Branch: refs/heads/fix-iwyu
Commit: 0fe838dfeac901ff03b8334da46b7b9f364447e3
Parents: 79bfcf9
Author: Robert Claus <ro...@gmail.com>
Authored: Tue Oct 24 18:08:57 2017 -0500
Committer: Robert Claus <ro...@gmail.com>
Committed: Wed Oct 25 13:24:02 2017 -0500

----------------------------------------------------------------------
 parser/ParseStatement.hpp                |   22 +-
 parser/SqlParser.ypp                     |   18 +-
 parser/preprocessed/SqlParser_gen.cpp    | 2646 +++++++++++++------------
 parser/preprocessed/SqlParser_gen.hpp    |    3 +-
 query_optimizer/ExecutionGenerator.cpp   |  110 +-
 query_optimizer/logical/InsertTuple.cpp  |    6 +-
 query_optimizer/logical/InsertTuple.hpp  |   10 +-
 query_optimizer/physical/InsertTuple.cpp |    6 +-
 query_optimizer/physical/InsertTuple.hpp |    8 +-
 query_optimizer/resolver/Resolver.cpp    |  122 +-
 10 files changed, 1503 insertions(+), 1448 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fe838df/parser/ParseStatement.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseStatement.hpp b/parser/ParseStatement.hpp
index cee7221..456bdc2 100644
--- a/parser/ParseStatement.hpp
+++ b/parser/ParseStatement.hpp
@@ -653,9 +653,9 @@ class ParseStatementInsertTuple : public ParseStatementInsert {
   ParseStatementInsertTuple(const int line_number,
                             const int column_number,
                             const ParseString *relation_name,
-                            PtrList<ParseScalarLiteral> *literal_values)
+                            PtrList<PtrList<ParseScalarLiteral>> *literal_values_list)
       : ParseStatementInsert(line_number, column_number, relation_name),
-        literal_values_(literal_values) {
+        literal_values_(literal_values_list) {
   }
 
   ~ParseStatementInsertTuple() override {
@@ -666,11 +666,11 @@ class ParseStatementInsertTuple : public ParseStatementInsert {
   }
 
   /**
-   * @brief Get the parsed literal attribute values to insert.
+   * @brief Get the list of list of parsed literal attribute values to insert.
    *
-   * @return The list of literal values to insert.
+   * @return The list of lists of literal values to insert.
    **/
-  const PtrList<ParseScalarLiteral>& getLiteralValues() const {
+  const PtrList<PtrList<ParseScalarLiteral>>& getLiteralValues() const {
     return *literal_values_;
   }
 
@@ -685,15 +685,17 @@ class ParseStatementInsertTuple : public ParseStatementInsert {
     inline_field_names->push_back("relation_name");
     inline_field_values->push_back(relation_name()->value());
 
-    container_child_field_names->push_back("tuple");
-    container_child_fields->emplace_back();
-    for (const ParseScalarLiteral& literal_value : *literal_values_) {
-      container_child_fields->back().push_back(&literal_value);
+    for (const PtrList<ParseScalarLiteral>& literal_values_single_tuple : *literal_values_) {
+      container_child_field_names->push_back("tuple");
+      container_child_fields->emplace_back();
+      for (const ParseScalarLiteral& literal_value : literal_values_single_tuple) {
+        container_child_fields->back().push_back(&literal_value);
+      }
     }
   }
 
  private:
-  std::unique_ptr<PtrList<ParseScalarLiteral> > literal_values_;
+  std::unique_ptr<PtrList<PtrList<ParseScalarLiteral>>> literal_values_;
 
   DISALLOW_COPY_AND_ASSIGN(ParseStatementInsertTuple);
 };

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fe838df/parser/SqlParser.ypp
----------------------------------------------------------------------
diff --git a/parser/SqlParser.ypp b/parser/SqlParser.ypp
index 8fbcdd7..ba69b3d 100644
--- a/parser/SqlParser.ypp
+++ b/parser/SqlParser.ypp
@@ -128,6 +128,7 @@ typedef void* yyscan_t;
   quickstep::NumericParseLiteralValue *numeric_literal_value_;
   quickstep::ParseLiteralValue *literal_value_;
   quickstep::PtrList<quickstep::ParseScalarLiteral> *literal_value_list_;
+  quickstep::PtrList<quickstep::PtrList<quickstep::ParseScalarLiteral>> *literal_value_list_multiple_;
 
   quickstep::ParseExpression *expression_;
 
@@ -387,6 +388,9 @@ void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string
 %type <literal_value_list_>
   literal_value_commalist
 
+%type <literal_value_list_multiple_>
+  literal_value_commalist_multiple
+
 %type <expression_>
   expression_base
   unary_expression
@@ -1101,8 +1105,8 @@ insert_statement:
     NotSupported(&@4, yyscanner, "list of column names in INSERT statement");
     YYERROR;
   }
-  | TOKEN_INSERT TOKEN_INTO any_name TOKEN_VALUES '(' literal_value_commalist ')' {
-    $$ = new quickstep::ParseStatementInsertTuple(@1.first_line, @1.first_column, $3, $6);
+  | TOKEN_INSERT TOKEN_INTO any_name TOKEN_VALUES literal_value_commalist_multiple {
+    $$ = new quickstep::ParseStatementInsertTuple(@1.first_line, @1.first_column, $3, $5);
   }
   | TOKEN_INSERT TOKEN_INTO any_name select_query {
     $$ = new quickstep::ParseStatementInsertSelection(@1.first_line, @2.first_column, $3, $4, nullptr);
@@ -1921,6 +1925,16 @@ literal_value_commalist:
     $$->push_back(new quickstep::ParseScalarLiteral($3));
   };
 
+literal_value_commalist_multiple:
+  '(' literal_value_commalist ')' {
+    $$ = new quickstep::PtrList<quickstep::PtrList<quickstep::ParseScalarLiteral>>();
+    $$->push_back($2);
+  }
+  | literal_value_commalist_multiple ',' '(' literal_value_commalist ')' {
+    $$ = $1;
+    $$->push_back($4);
+  };
+
 attribute_ref:
   any_name {
     $$ = new quickstep::ParseAttribute(@1.first_line, @1.first_column, $1);


[25/46] incubator-quickstep git commit: Hash-Join-Fuse: Feature added and tests modified.

Posted by ji...@apache.org.
Hash-Join-Fuse: Feature added and tests modified.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/39c6214a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/39c6214a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/39c6214a

Branch: refs/heads/fix-iwyu
Commit: 39c6214a38594460b1827c3016f7ff8f71cac493
Parents: 3595bc1
Author: Dylan Bacon <dy...@gmail.com>
Authored: Wed Sep 20 14:09:32 2017 -0500
Committer: Dylan Bacon <dy...@gmail.com>
Committed: Mon Nov 27 13:28:41 2017 -0600

----------------------------------------------------------------------
 query_optimizer/CMakeLists.txt                  |  1 +
 query_optimizer/ExecutionGenerator.cpp          | 16 +++-
 query_optimizer/PhysicalGenerator.cpp           |  9 ++
 .../cost_model/StarSchemaSimpleCostModel.cpp    | 17 ++--
 query_optimizer/physical/HashJoin.cpp           | 12 +++
 query_optimizer/physical/HashJoin.hpp           | 16 +++-
 query_optimizer/rules/CMakeLists.txt            | 10 +++
 .../rules/ExtractCommonSubexpression.cpp        |  1 +
 query_optimizer/rules/FuseHashSelect.cpp        | 88 ++++++++++++++++++++
 query_optimizer/rules/FuseHashSelect.hpp        | 64 ++++++++++++++
 query_optimizer/rules/InjectJoinFilters.cpp     | 16 ++--
 query_optimizer/rules/Partition.cpp             |  1 +
 .../rules/ReduceGroupByAttributes.cpp           |  1 +
 query_optimizer/rules/ReorderColumns.cpp        |  1 +
 .../StarSchemaHashJoinOrderOptimization.cpp     |  2 +
 query_optimizer/rules/SwapProbeBuild.cpp        |  1 +
 .../rules/tests/PruneColumns_unittest.cpp       |  2 +
 query_optimizer/strategy/Join.cpp               |  1 +
 .../strategy/tests/Join_unittest.cpp            |  6 ++
 .../tests/physical_generator/Join.test          | 32 +++----
 .../tests/physical_generator/Select.test        | 31 ++++---
 relational_operators/BuildHashOperator.cpp      | 28 ++++++-
 relational_operators/BuildHashOperator.hpp      | 13 ++-
 relational_operators/WorkOrder.proto            |  3 +-
 relational_operators/WorkOrderFactory.cpp       |  2 +
 .../tests/HashJoinOperator_unittest.cpp         | 27 ++++--
 26 files changed, 336 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt
index 5e0db44..1e4e346 100644
--- a/query_optimizer/CMakeLists.txt
+++ b/query_optimizer/CMakeLists.txt
@@ -226,6 +226,7 @@ target_link_libraries(quickstep_queryoptimizer_PhysicalGenerator
                       quickstep_queryoptimizer_rules_CollapseSelection
                       quickstep_queryoptimizer_rules_ExtractCommonSubexpression
                       quickstep_queryoptimizer_rules_FuseAggregateJoin
+                      quickstep_queryoptimizer_rules_FuseHashSelect
                       quickstep_queryoptimizer_rules_InjectJoinFilters
                       quickstep_queryoptimizer_rules_Partition
                       quickstep_queryoptimizer_rules_PruneColumns

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/ExecutionGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp
index b0d3c48..5ef58a9 100644
--- a/query_optimizer/ExecutionGenerator.cpp
+++ b/query_optimizer/ExecutionGenerator.cpp
@@ -939,6 +939,15 @@ void ExecutionGenerator::convertHashJoin(const P::HashJoinPtr &physical_plan) {
     query_context_proto_->add_predicates()->CopyFrom(residual_predicate->getProto());
   }
 
+  // Convert the build predicate proto.
+  QueryContext::predicate_id build_predicate_index = QueryContext::kInvalidPredicateId;
+  if (physical_plan->build_predicate()) {
+    build_predicate_index = query_context_proto_->predicates_size();
+
+    unique_ptr<const Predicate> build_predicate(convertPredicate(physical_plan->build_predicate()));
+    query_context_proto_->add_predicates()->MergeFrom(build_predicate->getProto());
+  }
+
   // Convert the project expressions proto.
   const QueryContext::scalar_group_id project_expressions_group_index =
       query_context_proto_->scalar_groups_size();
@@ -966,7 +975,9 @@ void ExecutionGenerator::convertHashJoin(const P::HashJoinPtr &physical_plan) {
   const CatalogRelation *probe_relation = probe_relation_info->relation;
 
   // FIXME(quickstep-team): Add support for self-join.
-  if (build_relation == probe_relation) {
+  // We check to see if the build_predicate is null as certain queries that
+  // support hash-select fuse will result in the first check being true.
+  if (build_relation == probe_relation && physical_plan->build_predicate() == nullptr) {
     THROW_SQL_ERROR() << "Self-join is not supported";
   }
 
@@ -1006,7 +1017,8 @@ void ExecutionGenerator::convertHashJoin(const P::HashJoinPtr &physical_plan) {
               build_attribute_ids,
               any_build_attributes_nullable,
               probe_num_partitions,
-              join_hash_table_index));
+              join_hash_table_index,
+              build_predicate_index));
 
   // Create InsertDestination proto.
   const CatalogRelation *output_relation = nullptr;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/PhysicalGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/PhysicalGenerator.cpp b/query_optimizer/PhysicalGenerator.cpp
index 865cd11..0d15a66 100644
--- a/query_optimizer/PhysicalGenerator.cpp
+++ b/query_optimizer/PhysicalGenerator.cpp
@@ -30,6 +30,7 @@
 #include "query_optimizer/rules/CollapseSelection.hpp"
 #include "query_optimizer/rules/ExtractCommonSubexpression.hpp"
 #include "query_optimizer/rules/FuseAggregateJoin.hpp"
+#include "query_optimizer/rules/FuseHashSelect.hpp"
 #include "query_optimizer/rules/InjectJoinFilters.hpp"
 #include "query_optimizer/rules/Partition.hpp"
 #include "query_optimizer/rules/PruneColumns.hpp"
@@ -67,6 +68,10 @@ DEFINE_bool(use_partition_rule, true,
             "If true, apply an optimization to support partitioned inputs. The "
             "optimization may add additional Selection for repartitioning.");
 
+DEFINE_bool(use_fuse_hash_select, true,
+            "If true, apply an optimization that moves build-side Selection nodes"
+            "into the hash join operator instead.");
+
 DEFINE_bool(use_filter_joins, true,
             "If true, apply an optimization that strength-reduces HashJoins to "
             "FilterJoins (implemented as LIPFilters attached to some anchoring "
@@ -176,6 +181,10 @@ P::PhysicalPtr PhysicalGenerator::optimizePlan() {
     rules.push_back(std::make_unique<PruneColumns>());
   }
 
+  if (FLAGS_use_fuse_hash_select) {
+    rules.emplace_back(new FuseHashSelect());
+  }
+
   // NOTE(jianqiao): Adding rules after InjectJoinFilters (or AttachLIPFilters)
   // requires extra handling of LIPFilterConfiguration for transformed nodes.
   // So currently it is suggested that all the new rules be placed before this

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
index e0e3dff..5aec4b4 100644
--- a/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
+++ b/query_optimizer/cost_model/StarSchemaSimpleCostModel.cpp
@@ -179,8 +179,9 @@ std::size_t StarSchemaSimpleCostModel::estimateCardinalityForHashJoin(
   std::size_t right_cardinality = estimateCardinality(physical_plan->right());
   double left_selectivity = estimateSelectivity(physical_plan->left());
   double right_selectivity = estimateSelectivity(physical_plan->right());
-  return std::max(static_cast<std::size_t>(left_cardinality * right_selectivity + 0.5),
-                  static_cast<std::size_t>(right_cardinality * left_selectivity + 0.5));
+  double build_selectivity = estimateSelectivityForPredicate(physical_plan->build_predicate(), physical_plan);
+  return std::max(static_cast<std::size_t>(left_cardinality * right_selectivity * build_selectivity + 0.5),
+                  static_cast<std::size_t>(right_cardinality * left_selectivity * build_selectivity + 0.5));
 }
 
 std::size_t StarSchemaSimpleCostModel::estimateCardinalityForNestedLoopsJoin(
@@ -295,16 +296,20 @@ std::size_t StarSchemaSimpleCostModel::estimateNumDistinctValues(
             estimateNumDistinctValues(attribute_id, hash_join->left());
         double right_child_selectivity =
             estimateSelectivity(hash_join->right());
+        double build_selectivity =
+            estimateSelectivityForPredicate(hash_join->build_predicate(), hash_join);
         return static_cast<std::size_t>(
-            left_child_num_distinct_values * right_child_selectivity * filter_selectivity + 0.5);
+            left_child_num_distinct_values * right_child_selectivity * filter_selectivity * build_selectivity + 0.5);
       }
       if (E::ContainsExprId(hash_join->right()->getOutputAttributes(), attribute_id)) {
         std::size_t right_child_num_distinct_values =
             estimateNumDistinctValues(attribute_id, hash_join->right());
         double left_child_selectivity =
             estimateSelectivity(hash_join->left());
+        double build_selectivity =
+            estimateSelectivityForPredicate(hash_join->build_predicate(), hash_join);
         return static_cast<std::size_t>(
-            right_child_num_distinct_values * left_child_selectivity * filter_selectivity + 0.5);
+            right_child_num_distinct_values * left_child_selectivity * filter_selectivity * build_selectivity + 0.5);
       }
     }
     default:
@@ -351,9 +356,11 @@ double StarSchemaSimpleCostModel::estimateSelectivity(
           std::static_pointer_cast<const P::HashJoin>(physical_plan);
       double filter_selectivity =
           estimateSelectivityForPredicate(hash_join->residual_predicate(), hash_join);
+      double build_selectivity =
+          estimateSelectivityForPredicate(hash_join->build_predicate(), hash_join);
       double child_selectivity =
           estimateSelectivity(hash_join->left()) * estimateSelectivity(hash_join->right());
-      return filter_selectivity * child_selectivity;
+      return filter_selectivity * child_selectivity * build_selectivity;
     }
     case P::PhysicalType::kNestedLoopsJoin: {
       const P::NestedLoopsJoinPtr &nested_loop_join =

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/physical/HashJoin.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/HashJoin.cpp b/query_optimizer/physical/HashJoin.cpp
index a49bc8e..ca6bf9f 100644
--- a/query_optimizer/physical/HashJoin.cpp
+++ b/query_optimizer/physical/HashJoin.cpp
@@ -57,6 +57,13 @@ std::vector<expressions::AttributeReferencePtr> HashJoin::getReferencedAttribute
                                  referenced_attributes_in_residual.begin(),
                                  referenced_attributes_in_residual.end());
   }
+  if (build_predicate_ != nullptr) {
+    const std::vector<expressions::AttributeReferencePtr> referenced_attributes_in_build =
+        build_predicate_->getReferencedAttributes();
+    referenced_attributes.insert(referenced_attributes.end(),
+                                 referenced_attributes_in_build.begin(),
+                                 referenced_attributes_in_build.end());
+  }
   return referenced_attributes;
 }
 
@@ -79,6 +86,7 @@ bool HashJoin::maybeCopyWithPrunedExpressions(
                      left_join_attributes_,
                      right_join_attributes_,
                      residual_predicate_,
+                     build_predicate_,
                      new_project_expressions,
                      join_type_,
                      has_repartition_,
@@ -105,6 +113,10 @@ void HashJoin::getFieldStringItems(
     non_container_child_field_names->push_back("residual_predicate");
     non_container_child_fields->push_back(residual_predicate_);
   }
+  if (build_predicate_ != nullptr) {
+    non_container_child_field_names->push_back("build_predicate");
+    non_container_child_fields->push_back(build_predicate_);
+  }
   container_child_field_names->push_back("left_join_attributes");
   container_child_fields->push_back(CastSharedPtrVector<OptimizerTreeBase>(left_join_attributes_));
   container_child_field_names->push_back("right_join_attributes");

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/physical/HashJoin.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/HashJoin.hpp b/query_optimizer/physical/HashJoin.hpp
index 2ed83af..1c341df 100644
--- a/query_optimizer/physical/HashJoin.hpp
+++ b/query_optimizer/physical/HashJoin.hpp
@@ -103,6 +103,13 @@ class HashJoin : public BinaryJoin {
   }
 
   /**
+   * @ brief The select predicate for a hash join fuse.
+   */
+  const expressions::PredicatePtr& build_predicate() const {
+    return build_predicate_;
+  }
+
+  /**
    * @return Join type of this hash join.
    */
   JoinType join_type() const {
@@ -117,6 +124,7 @@ class HashJoin : public BinaryJoin {
                   left_join_attributes_,
                   right_join_attributes_,
                   residual_predicate_,
+                  build_predicate_,
                   project_expressions(),
                   join_type_,
                   has_repartition_,
@@ -129,7 +137,7 @@ class HashJoin : public BinaryJoin {
       PartitionSchemeHeader *partition_scheme_header,
       const bool has_repartition = true) const override {
     return Create(left(), right(), left_join_attributes_, right_join_attributes_,
-                  residual_predicate_, project_expressions(), join_type_,
+                  residual_predicate_, build_predicate_, project_expressions(), join_type_,
                   has_repartition, partition_scheme_header);
   }
 
@@ -146,6 +154,7 @@ class HashJoin : public BinaryJoin {
    * @param left_join_attributes The join attributes in the 'left'.
    * @param right_join_attributes The join attributes in the 'right'.
    * @param residual_predicate Optional filtering predicate evaluated after join.
+   * @param build_predicate Optional select predicate for a hash join fuse.
    * @param project_expressions The project expressions.
    * @param Join type of this hash join.
    * @param has_repartition Whether this node has repartition.
@@ -159,6 +168,7 @@ class HashJoin : public BinaryJoin {
       const std::vector<expressions::AttributeReferencePtr> &left_join_attributes,
       const std::vector<expressions::AttributeReferencePtr> &right_join_attributes,
       const expressions::PredicatePtr &residual_predicate,
+      const expressions::PredicatePtr &build_predicate,
       const std::vector<expressions::NamedExpressionPtr> &project_expressions,
       const JoinType join_type,
       const bool has_repartition = false,
@@ -169,6 +179,7 @@ class HashJoin : public BinaryJoin {
                      left_join_attributes,
                      right_join_attributes,
                      residual_predicate,
+                     build_predicate,
                      project_expressions,
                      join_type,
                      has_repartition,
@@ -191,6 +202,7 @@ class HashJoin : public BinaryJoin {
       const std::vector<expressions::AttributeReferencePtr> &left_join_attributes,
       const std::vector<expressions::AttributeReferencePtr> &right_join_attributes,
       const expressions::PredicatePtr &residual_predicate,
+      const expressions::PredicatePtr &build_predicate,
       const std::vector<expressions::NamedExpressionPtr> &project_expressions,
       const JoinType join_type,
       const bool has_repartition,
@@ -199,12 +211,14 @@ class HashJoin : public BinaryJoin {
         left_join_attributes_(left_join_attributes),
         right_join_attributes_(right_join_attributes),
         residual_predicate_(residual_predicate),
+        build_predicate_(build_predicate),
         join_type_(join_type) {
   }
 
   std::vector<expressions::AttributeReferencePtr> left_join_attributes_;
   std::vector<expressions::AttributeReferencePtr> right_join_attributes_;
   expressions::PredicatePtr residual_predicate_;
+  expressions::PredicatePtr build_predicate_;
   JoinType join_type_;
 
   DISALLOW_COPY_AND_ASSIGN(HashJoin);

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/rules/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/CMakeLists.txt b/query_optimizer/rules/CMakeLists.txt
index 73a80d2..d6c043f 100644
--- a/query_optimizer/rules/CMakeLists.txt
+++ b/query_optimizer/rules/CMakeLists.txt
@@ -26,6 +26,7 @@ add_library(quickstep_queryoptimizer_rules_ExtractCommonSubexpression
             ExtractCommonSubexpression.cpp
             ExtractCommonSubexpression.hpp)
 add_library(quickstep_queryoptimizer_rules_FuseAggregateJoin FuseAggregateJoin.cpp FuseAggregateJoin.hpp)
+add_library(quickstep_queryoptimizer_rules_FuseHashSelect FuseHashSelect.cpp FuseHashSelect.hpp)
 add_library(quickstep_queryoptimizer_rules_GenerateJoins GenerateJoins.cpp GenerateJoins.hpp)
 add_library(quickstep_queryoptimizer_rules_InjectJoinFilters InjectJoinFilters.cpp InjectJoinFilters.hpp)
 add_library(quickstep_queryoptimizer_rules_Partition Partition.cpp Partition.hpp)
@@ -138,6 +139,14 @@ target_link_libraries(quickstep_queryoptimizer_rules_FuseAggregateJoin
                       quickstep_queryoptimizer_physical_TopLevelPlan
                       quickstep_queryoptimizer_rules_BottomUpRule
                       quickstep_utility_Macros)
+target_link_libraries(quickstep_queryoptimizer_rules_FuseHashSelect
+                      quickstep_queryoptimizer_expressions_Predicate
+                      quickstep_queryoptimizer_physical_HashJoin
+                      quickstep_queryoptimizer_physical_PatternMatcher
+                      quickstep_queryoptimizer_physical_Physical
+                      quickstep_queryoptimizer_physical_PhysicalType
+                      quickstep_queryoptimizer_physical_Selection
+                      quickstep_queryoptimizer_rules_TopDownRule)
 target_link_libraries(quickstep_queryoptimizer_rules_GenerateJoins
                       glog
                       quickstep_queryoptimizer_expressions_AttributeReference
@@ -415,6 +424,7 @@ target_link_libraries(quickstep_queryoptimizer_rules
                       quickstep_queryoptimizer_rules_CollapseSelection
                       quickstep_queryoptimizer_rules_ExtractCommonSubexpression
                       quickstep_queryoptimizer_rules_FuseAggregateJoin
+                      quickstep_queryoptimizer_rules_FuseHashSelect
                       quickstep_queryoptimizer_rules_GenerateJoins
                       quickstep_queryoptimizer_rules_InjectJoinFilters
                       quickstep_queryoptimizer_rules_Partition

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/rules/ExtractCommonSubexpression.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/ExtractCommonSubexpression.cpp b/query_optimizer/rules/ExtractCommonSubexpression.cpp
index 4c4d33e..eb4adcf 100644
--- a/query_optimizer/rules/ExtractCommonSubexpression.cpp
+++ b/query_optimizer/rules/ExtractCommonSubexpression.cpp
@@ -171,6 +171,7 @@ P::PhysicalPtr ExtractCommonSubexpression::applyToNode(
                                    hash_join->left_join_attributes(),
                                    hash_join->right_join_attributes(),
                                    hash_join->residual_predicate(),
+                                   hash_join->build_predicate(),
                                    new_expressions,
                                    hash_join->join_type());
       }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/rules/FuseHashSelect.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/FuseHashSelect.cpp b/query_optimizer/rules/FuseHashSelect.cpp
new file mode 100644
index 0000000..b260ee9
--- /dev/null
+++ b/query_optimizer/rules/FuseHashSelect.cpp
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ **/
+
+#include "query_optimizer/rules/FuseHashSelect.hpp"
+
+#include <algorithm>
+#include <cstddef>
+#include <unordered_set>
+#include <vector>
+
+#include "query_optimizer/expressions/Predicate.hpp"
+#include "query_optimizer/physical/HashJoin.hpp"
+#include "query_optimizer/physical/PatternMatcher.hpp"
+#include "query_optimizer/physical/Physical.hpp"
+#include "query_optimizer/physical/PhysicalType.hpp"
+#include "query_optimizer/physical/Selection.hpp"
+
+#include "glog/logging.h"
+
+namespace quickstep {
+namespace optimizer {
+
+namespace E = ::quickstep::optimizer::expressions;
+namespace P = ::quickstep::optimizer::physical;
+
+P::PhysicalPtr FuseHashSelect::applyToNode(
+    const P::PhysicalPtr &node) {
+  P::HashJoinPtr hash_join;
+
+  // Check to see if the join is a hash join, if the hash join is an inner
+  // join.. We also check that there are no partitions.
+  // TODO(dbacon): Add support for other join types.
+
+  if ((!P::SomeHashJoin::MatchesWithConditionalCast(node, &hash_join)) ||
+      hash_join->getOutputPartitionSchemeHeader() != nullptr) {
+    return node;
+  }
+
+  // Get the join attributes from the build side.
+
+  P::PhysicalPtr right_child = hash_join->right();
+  const std::vector<E::AttributeReferencePtr> &right_join_attributes =
+      hash_join->right_join_attributes();
+  E::PredicatePtr build_predicate = nullptr;
+
+  // Check that the build side is a Selection and that the join attributes match up.
+  // If so, set the new hash join build side to the Selection input and the build predicate
+  // to the selection's filter.
+
+  P::SelectionPtr selection;
+  if (P::SomeSelection::MatchesWithConditionalCast(right_child, &selection)) {
+    if (E::SubsetOfExpressions(right_join_attributes,
+                               selection->input()->getOutputAttributes())) {
+      right_child = selection->input();
+      build_predicate = selection->filter_predicate();
+    }
+  }
+
+  return P::HashJoin::Create(hash_join->left(),
+                             right_child,
+                             hash_join->left_join_attributes(),
+                             right_join_attributes,
+                             hash_join->residual_predicate(),
+                             build_predicate,
+                             hash_join->project_expressions(),
+                             hash_join->join_type(),
+                             hash_join->hasRepartition(),
+                             hash_join->cloneOutputPartitionSchemeHeader());
+}
+
+}  // namespace optimizer
+}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/rules/FuseHashSelect.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/FuseHashSelect.hpp b/query_optimizer/rules/FuseHashSelect.hpp
new file mode 100644
index 0000000..e88530a
--- /dev/null
+++ b/query_optimizer/rules/FuseHashSelect.hpp
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ **/
+
+#ifndef QUICKSTEP_QUERY_OPTIMIZER_RULES_FUSE_HASH_SELECT_HPP_
+#define QUICKSTEP_QUERY_OPTIMIZER_RULES_FUSE_HASH_SELECT_HPP_
+
+#include <cstdint>
+#include <memory>
+#include <string>
+
+#include "query_optimizer/physical/Physical.hpp"
+#include "query_optimizer/rules/TopDownRule.hpp"
+
+namespace quickstep {
+namespace optimizer {
+
+/** \addtogroup OptimizerRules
+ *  @{
+ */
+
+/**
+ * @brief Rule that applies to a physical plan to fuse a select node in the 
+ *        build predicate of a hash join to the join.
+ */
+class FuseHashSelect : public TopDownRule<physical::Physical> {
+ public:
+    /**
+     * @brief Constructor.
+     */
+    FuseHashSelect() {}
+
+    ~FuseHashSelect() override {}
+
+    std::string getName() const override {
+      return "FuseHashSelect";
+    }
+
+ protected:
+    physical::PhysicalPtr applyToNode(const physical::PhysicalPtr &node) override;
+
+ private:
+    DISALLOW_COPY_AND_ASSIGN(FuseHashSelect);
+};
+
+}  // namespace optimizer
+}  // namespace quickstep
+
+#endif  // QUICKSTEP_QUERY_OPTIMIZER_RULES_FUSE_HASH_SELECT_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/rules/InjectJoinFilters.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/InjectJoinFilters.cpp b/query_optimizer/rules/InjectJoinFilters.cpp
index 0aa2f5b..34d0f83 100644
--- a/query_optimizer/rules/InjectJoinFilters.cpp
+++ b/query_optimizer/rules/InjectJoinFilters.cpp
@@ -165,13 +165,17 @@ P::PhysicalPtr InjectJoinFilters::transformHashJoinToFilters(
     P::PhysicalPtr build_child = new_children[1];
     E::PredicatePtr build_side_filter_predicate = nullptr;
     P::SelectionPtr selection;
-    if (P::SomeSelection::MatchesWithConditionalCast(build_child, &selection) &&
-        E::SubsetOfExpressions(hash_join->right_join_attributes(),
-                               selection->input()->getOutputAttributes())) {
-      build_child = selection->input();
-      build_side_filter_predicate = selection->filter_predicate();
+    if (hash_join->build_predicate() == nullptr) {
+      if (P::SomeSelection::MatchesWithConditionalCast(build_child, &selection) &&
+          E::SubsetOfExpressions(hash_join->right_join_attributes(),
+                                 selection->input()->getOutputAttributes())) {
+        build_child = selection->input();
+        build_side_filter_predicate = selection->filter_predicate();
+      }
+    } else {
+      build_child = hash_join->right();
+      build_side_filter_predicate = hash_join->build_predicate();
     }
-
     return P::FilterJoin::Create(new_children[0],
                                  build_child,
                                  hash_join->left_join_attributes(),

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/rules/Partition.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/Partition.cpp b/query_optimizer/rules/Partition.cpp
index 5f68cd3..fdb5581 100644
--- a/query_optimizer/rules/Partition.cpp
+++ b/query_optimizer/rules/Partition.cpp
@@ -497,6 +497,7 @@ P::PhysicalPtr Partition::applyToNode(const P::PhysicalPtr &node) {
       if (left_needs_repartition || right_needs_repartition) {
         return P::HashJoin::Create(left, right, left_join_attributes, right_join_attributes,
                                    hash_join->residual_predicate(),
+                                   hash_join->build_predicate(),
                                    hash_join->project_expressions(),
                                    hash_join->join_type(),
                                    false /* has_repartition */,

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/rules/ReduceGroupByAttributes.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/ReduceGroupByAttributes.cpp b/query_optimizer/rules/ReduceGroupByAttributes.cpp
index dcdd27a..ff9180c 100644
--- a/query_optimizer/rules/ReduceGroupByAttributes.cpp
+++ b/query_optimizer/rules/ReduceGroupByAttributes.cpp
@@ -206,6 +206,7 @@ P::PhysicalPtr ReduceGroupByAttributes::applyToNode(const P::PhysicalPtr &input)
                                  {probe_attribute},
                                  {build_attribute},
                                  nullptr,
+                                 nullptr,
                                  project_expressions,
                                  P::HashJoin::JoinType::kInnerJoin);
   }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/rules/ReorderColumns.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/ReorderColumns.cpp b/query_optimizer/rules/ReorderColumns.cpp
index 4783a8d..5f52938 100644
--- a/query_optimizer/rules/ReorderColumns.cpp
+++ b/query_optimizer/rules/ReorderColumns.cpp
@@ -180,6 +180,7 @@ P::PhysicalPtr ReorderColumns::applyInternal(const P::PhysicalPtr &input,
                                      old_node->left_join_attributes(),
                                      old_node->right_join_attributes(),
                                      old_node->residual_predicate(),
+                                     old_node->build_predicate(),
                                      project_expressions,
                                      old_node->join_type());
         break;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp b/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp
index 5906b98..340875d 100644
--- a/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp
+++ b/query_optimizer/rules/StarSchemaHashJoinOrderOptimization.cpp
@@ -315,6 +315,7 @@ physical::PhysicalPtr StarSchemaHashJoinOrderOptimization::generatePlan(
                               probe_attributes,
                               build_attributes,
                               nullptr,
+                              nullptr,
                               output_attributes,
                               P::HashJoin::JoinType::kInnerJoin);
 
@@ -347,6 +348,7 @@ physical::PhysicalPtr StarSchemaHashJoinOrderOptimization::generatePlan(
                                  probe_attributes,
                                  build_attributes,
                                  residual_predicate,
+                                 nullptr,
                                  project_expressions,
                                  P::HashJoin::JoinType::kInnerJoin);
     }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/rules/SwapProbeBuild.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/SwapProbeBuild.cpp b/query_optimizer/rules/SwapProbeBuild.cpp
index d707e01..12dd27d 100644
--- a/query_optimizer/rules/SwapProbeBuild.cpp
+++ b/query_optimizer/rules/SwapProbeBuild.cpp
@@ -58,6 +58,7 @@ P::PhysicalPtr SwapProbeBuild::applyToNode(const P::PhysicalPtr &input) {
                                                   right_join_attributes,
                                                   left_join_attributes,
                                                   hash_join->residual_predicate(),
+                                                  hash_join->build_predicate(),
                                                   hash_join->project_expressions(),
                                                   hash_join->join_type());
       LOG_APPLYING_RULE(input, output);

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/rules/tests/PruneColumns_unittest.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/tests/PruneColumns_unittest.cpp b/query_optimizer/rules/tests/PruneColumns_unittest.cpp
index 8781750..02b727d 100644
--- a/query_optimizer/rules/tests/PruneColumns_unittest.cpp
+++ b/query_optimizer/rules/tests/PruneColumns_unittest.cpp
@@ -95,6 +95,7 @@ TEST_F(PruneColumnTest, PrimaryTest) {
                                                        {relation_attribute_reference_0_0_},
                                                        {relation_attribute_reference_1_0_},
                                                        E::PredicatePtr(),
+                                                       E::PredicatePtr(),
                                                        project_expressions_with_redundancy,
                                                        P::HashJoin::JoinType::kInnerJoin);
 
@@ -123,6 +124,7 @@ TEST_F(PruneColumnTest, PrimaryTest) {
       {relation_attribute_reference_0_0_},
       {relation_attribute_reference_1_0_},
       E::PredicatePtr(),
+      E::PredicatePtr(),
       pruned_project_expressions_for_join,
       P::HashJoin::JoinType::kInnerJoin);
   const P::SelectionPtr new_selection = std::static_pointer_cast<const P::Selection>(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/strategy/Join.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/strategy/Join.cpp b/query_optimizer/strategy/Join.cpp
index f7d6d24..f3e6b8d 100644
--- a/query_optimizer/strategy/Join.cpp
+++ b/query_optimizer/strategy/Join.cpp
@@ -371,6 +371,7 @@ void Join::addHashJoin(const logical::ProjectPtr &logical_project,
                           left_join_attributes,
                           right_join_attributes,
                           residual_predicate,
+                          E::PredicatePtr() /* build_predicate */,
                           project_expressions,
                           join_type);
 }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/strategy/tests/Join_unittest.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/strategy/tests/Join_unittest.cpp b/query_optimizer/strategy/tests/Join_unittest.cpp
index 87a8a97..ad34bec 100644
--- a/query_optimizer/strategy/tests/Join_unittest.cpp
+++ b/query_optimizer/strategy/tests/Join_unittest.cpp
@@ -96,6 +96,7 @@ class JoinTest : public StrategyTest {
                             {relation_attribute_reference_0_0_},
                             {relation_attribute_reference_1_0_},
                             E::PredicatePtr(),
+                            E::PredicatePtr(),
                             project_expressions,
                             P::HashJoin::JoinType::kInnerJoin);
   }
@@ -142,6 +143,7 @@ TEST_F(JoinTest, ProjectOnJoin) {
       {relation_attribute_reference_0_0_},
       {relation_attribute_reference_1_0_},
       E::PredicatePtr(),
+      E::PredicatePtr(),
       logical_project_0_->project_expressions(),
       P::HashJoin::JoinType::kInnerJoin);
   EXPECT_CORRECT_PHYSICAL();
@@ -183,6 +185,7 @@ TEST_F(JoinTest, ProjectOnFilterOnHashJoin) {
       {relation_attribute_reference_1_0_,
        relation_attribute_reference_1_1_},
       filter_predicate_0_,
+      E::PredicatePtr(),
       logical_project_1_->project_expressions(),
       P::HashJoin::JoinType::kInnerJoin);
   EXPECT_CORRECT_PHYSICAL();
@@ -212,6 +215,7 @@ TEST_F(JoinTest, FilterOnHashJoin) {
       {relation_attribute_reference_0_0_},
       {relation_attribute_reference_1_0_},
       filter_predicate_0_,
+      E::PredicatePtr(),
       physical_nested_loops_join_->project_expressions(),
       P::HashJoin::JoinType::kInnerJoin);
   EXPECT_CORRECT_PHYSICAL();
@@ -248,6 +252,7 @@ TEST_F(JoinTest, HashJoinOnSelection) {
       {relation_attribute_reference_0_0_},
       {relation_attribute_reference_1_0_},
       E::PredicatePtr(),
+      E::PredicatePtr(),
       {alias_on_alias_reference_after_pullup} /* project_expressions */,
       P::HashJoin::JoinType::kInnerJoin);
   EXPECT_CORRECT_PHYSICAL();
@@ -286,6 +291,7 @@ TEST_F(JoinTest, HashJoinOnSelection) {
                           {E::ToRef(alias_add_literal_0_)},
                           {relation_attribute_reference_1_0_},
                           E::PredicatePtr(),
+                          E::PredicatePtr(),
                           project_expressions,
                           P::HashJoin::JoinType::kInnerJoin);
   EXPECT_CORRECT_PHYSICAL();

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/tests/physical_generator/Join.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/physical_generator/Join.test b/query_optimizer/tests/physical_generator/Join.test
index 45ea0ed..d0b9e4b 100644
--- a/query_optimizer/tests/physical_generator/Join.test
+++ b/query_optimizer/tests/physical_generator/Join.test
@@ -331,16 +331,12 @@ TopLevelPlan
 | | | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
 | | | +-right_join_attributes=
 | | |   +-AttributeReference[id=0,name=w,relation=a,type=Int]
-| | +-right=Selection[has_repartition=false]
-| | | +-input=TableReference[relation=c]
-| | | | +-AttributeReference[id=6,name=x,relation=c,type=Int]
-| | | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
-| | | +-filter_predicate=Greater
-| | | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
-| | | | +-Literal[value=20,type=Int]
-| | | +-project_expressions=
-| | |   +-AttributeReference[id=6,name=x,relation=c,type=Int]
-| | |   +-AttributeReference[id=7,name=y,relation=c,type=Int]
+| | +-right=TableReference[relation=c]
+| | | +-AttributeReference[id=6,name=x,relation=c,type=Int]
+| | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
+| | +-build_predicate=Greater
+| | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
+| | | +-Literal[value=20,type=Int]
 | | +-project_expressions=
 | | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
 | | | +-AttributeReference[id=0,name=w,relation=a,type=Int NULL]
@@ -377,16 +373,12 @@ TopLevelPlan
 | +-left=TableReference[relation=b]
 | | +-AttributeReference[id=0,name=w,relation=b,type=Int]
 | | +-AttributeReference[id=1,name=x,relation=b,type=Int]
-| +-right=Selection[has_repartition=false]
-| | +-input=TableReference[relation=c]
-| | | +-AttributeReference[id=2,name=x,relation=c,type=Int]
-| | | +-AttributeReference[id=3,name=y,relation=c,type=Int]
-| | +-filter_predicate=Greater
-| | | +-AttributeReference[id=2,name=x,relation=c,type=Int]
-| | | +-Literal[value=10,type=Int]
-| | +-project_expressions=
-| |   +-AttributeReference[id=2,name=x,relation=c,type=Int]
-| |   +-AttributeReference[id=3,name=y,relation=c,type=Int]
+| +-right=TableReference[relation=c]
+| | +-AttributeReference[id=2,name=x,relation=c,type=Int]
+| | +-AttributeReference[id=3,name=y,relation=c,type=Int]
+| +-build_predicate=Greater
+| | +-AttributeReference[id=2,name=x,relation=c,type=Int]
+| | +-Literal[value=10,type=Int]
 | +-project_expressions=
 | | +-AttributeReference[id=0,name=w,relation=b,type=Int]
 | | +-AttributeReference[id=1,name=x,relation=b,type=Int]

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/query_optimizer/tests/physical_generator/Select.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/physical_generator/Select.test b/query_optimizer/tests/physical_generator/Select.test
index 8bb6599..720d248 100644
--- a/query_optimizer/tests/physical_generator/Select.test
+++ b/query_optimizer/tests/physical_generator/Select.test
@@ -2113,23 +2113,20 @@ TopLevelPlan
 | | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
 | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
 | | +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
-| +-right=Selection[has_repartition=false]
-| | +-input=TableReference[relation=Test,alias=test]
-| | | +-AttributeReference[id=6,name=int_col,relation=test,type=Int NULL]
-| | | +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
-| | | +-AttributeReference[id=8,name=float_col,relation=test,type=Float]
-| | | +-AttributeReference[id=9,name=double_col,relation=test,type=Double NULL]
-| | | +-AttributeReference[id=10,name=char_col,relation=test,type=Char(20)]
-| | | +-AttributeReference[id=11,name=vchar_col,relation=test,
-| | |   type=VarChar(20) NULL]
-| | +-filter_predicate=InValueList
-| | | +-test_expression=AttributeReference[id=7,name=long_col,relation=test,
-| | | | type=Long]
-| | | +-match_expressions=
-| | |   +-Literal[value=1,type=Long]
-| | |   +-Literal[value=2,type=Long]
-| | +-project_expressions=
-| |   +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| +-right=TableReference[relation=Test,alias=test]
+| | +-AttributeReference[id=6,name=int_col,relation=test,type=Int NULL]
+| | +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| | +-AttributeReference[id=8,name=float_col,relation=test,type=Float]
+| | +-AttributeReference[id=9,name=double_col,relation=test,type=Double NULL]
+| | +-AttributeReference[id=10,name=char_col,relation=test,type=Char(20)]
+| | +-AttributeReference[id=11,name=vchar_col,relation=test,
+| |   type=VarChar(20) NULL]
+| +-build_predicate=InValueList
+| | +-test_expression=AttributeReference[id=7,name=long_col,relation=test,
+| | | type=Long]
+| | +-match_expressions=
+| |   +-Literal[value=1,type=Long]
+| |   +-Literal[value=2,type=Long]
 | +-project_expressions=
 | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
 | +-left_join_attributes=

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/relational_operators/BuildHashOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/BuildHashOperator.cpp b/relational_operators/BuildHashOperator.cpp
index 768c141..3a67993 100644
--- a/relational_operators/BuildHashOperator.cpp
+++ b/relational_operators/BuildHashOperator.cpp
@@ -70,6 +70,10 @@ bool BuildHashOperator::getAllWorkOrders(
     tmb::MessageBus *bus) {
   DCHECK(query_context != nullptr);
 
+  // Get the build predicate from the query context if it exists.
+  const Predicate *predicate =
+      query_context->getPredicate(build_predicate_index_);
+
   if (input_relation_is_stored_) {
     if (started_) {
       return true;
@@ -80,7 +84,7 @@ bool BuildHashOperator::getAllWorkOrders(
       for (const block_id block : input_relation_block_ids_[part_id]) {
         container->addNormalWorkOrder(
             new BuildHashWorkOrder(query_id_, input_relation_, join_key_attributes_, any_join_key_attributes_nullable_,
-                                   part_id, block, hash_table, storage_manager,
+                                   part_id, block, predicate, hash_table, storage_manager,
                                    CreateLIPFilterBuilderHelper(lip_deployment_index_, query_context)),
             op_index_);
       }
@@ -95,7 +99,7 @@ bool BuildHashOperator::getAllWorkOrders(
         container->addNormalWorkOrder(
             new BuildHashWorkOrder(query_id_, input_relation_, join_key_attributes_, any_join_key_attributes_nullable_,
                                    part_id, input_relation_block_ids_[part_id][num_workorders_generated_[part_id]],
-                                   hash_table, storage_manager,
+                                   predicate, hash_table, storage_manager,
                                    CreateLIPFilterBuilderHelper(lip_deployment_index_, query_context)),
             op_index_);
         ++num_workorders_generated_[part_id];
@@ -143,6 +147,7 @@ serialization::WorkOrder* BuildHashOperator::createWorkOrderProto(const block_id
   proto->SetExtension(serialization::BuildHashWorkOrder::any_join_key_attributes_nullable,
                       any_join_key_attributes_nullable_);
   proto->SetExtension(serialization::BuildHashWorkOrder::join_hash_table_index, hash_table_index_);
+  proto->SetExtension(serialization::BuildHashWorkOrder::build_predicate_index, build_predicate_index_);
   proto->SetExtension(serialization::BuildHashWorkOrder::partition_id, part_id);
   proto->SetExtension(serialization::BuildHashWorkOrder::block_id, block);
   proto->SetExtension(serialization::BuildHashWorkOrder::lip_deployment_index, lip_deployment_index_);
@@ -158,8 +163,25 @@ void BuildHashWorkOrder::execute() {
   BlockReference block(
       storage_manager_->getBlock(build_block_id_, input_relation_));
 
+  // Create the ValueAccessor to be initialized later.
+  std::unique_ptr<ValueAccessor> accessor;
+
+  // If there is a build predicate, find the tuples that match it in the block.
+  std::unique_ptr<TupleIdSequence> predicate_matches;
+  if (predicate_ != nullptr) {
+    predicate_matches.reset(
+        block->getMatchesForPredicate(predicate_));
+  }
+
+  // Use the tuples from the build predicate to fill a ValueAccessor, else
+  // initialize it to a default state for normal use.
   TupleReferenceGenerator generator(build_block_id_);
-  std::unique_ptr<ValueAccessor> accessor(block->getTupleStorageSubBlock().createValueAccessor());
+  if (predicate_ != nullptr) {
+    accessor.reset(
+        block->getTupleStorageSubBlock().createValueAccessor(predicate_matches.get()));
+  } else {
+    accessor.reset(block->getTupleStorageSubBlock().createValueAccessor());
+  }
 
   // Build LIPFilters if enabled.
   if (lip_filter_builder_ != nullptr) {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/relational_operators/BuildHashOperator.hpp
----------------------------------------------------------------------
diff --git a/relational_operators/BuildHashOperator.hpp b/relational_operators/BuildHashOperator.hpp
index dfb6dfe..e4a2783 100644
--- a/relational_operators/BuildHashOperator.hpp
+++ b/relational_operators/BuildHashOperator.hpp
@@ -81,6 +81,7 @@ class BuildHashOperator : public RelationalOperator {
    * @param hash_table_index The index of the JoinHashTable in QueryContext.
    *        The HashTable's key Type(s) should be the Type(s) of the
    *        join_key_attributes in input_relation.
+   * @param build_predicate_index The index of the build_predicate in QueryContext.
    **/
   BuildHashOperator(const std::size_t query_id,
                     const CatalogRelation &input_relation,
@@ -88,7 +89,8 @@ class BuildHashOperator : public RelationalOperator {
                     const std::vector<attribute_id> &join_key_attributes,
                     const bool any_join_key_attributes_nullable,
                     const std::size_t num_partitions,
-                    const QueryContext::join_hash_table_id hash_table_index)
+                    const QueryContext::join_hash_table_id hash_table_index,
+                    const QueryContext::predicate_id build_predicate_index)
       : RelationalOperator(query_id, num_partitions),
         input_relation_(input_relation),
         input_relation_is_stored_(input_relation_is_stored),
@@ -96,6 +98,7 @@ class BuildHashOperator : public RelationalOperator {
         any_join_key_attributes_nullable_(any_join_key_attributes_nullable),
         is_broadcast_join_(num_partitions > 1u && !input_relation.hasPartitionScheme()),
         hash_table_index_(hash_table_index),
+        build_predicate_index_(build_predicate_index),
         input_relation_block_ids_(num_partitions),
         num_workorders_generated_(num_partitions),
         started_(false) {
@@ -164,6 +167,7 @@ class BuildHashOperator : public RelationalOperator {
   const bool any_join_key_attributes_nullable_;
   const bool is_broadcast_join_;
   const QueryContext::join_hash_table_id hash_table_index_;
+  const QueryContext::predicate_id build_predicate_index_;
 
   // The index is the partition id.
   std::vector<BlocksInPartition> input_relation_block_ids_;
@@ -189,6 +193,7 @@ class BuildHashWorkOrder : public WorkOrder {
    * @param any_join_key_attributes_nullable If any attribute is nullable.
    * @param part_id The partition id of 'input_relation'.
    * @param build_block_id The block id.
+   * @param predicate The Predicate to use.
    * @param hash_table The JoinHashTable to use.
    * @param storage_manager The StorageManager to use.
    * @param lip_filter_builder The attached LIP filter builer.
@@ -199,6 +204,7 @@ class BuildHashWorkOrder : public WorkOrder {
                      const bool any_join_key_attributes_nullable,
                      const partition_id part_id,
                      const block_id build_block_id,
+                     const Predicate *predicate,
                      JoinHashTable *hash_table,
                      StorageManager *storage_manager,
                      LIPFilterBuilder *lip_filter_builder)
@@ -207,6 +213,7 @@ class BuildHashWorkOrder : public WorkOrder {
         join_key_attributes_(join_key_attributes),
         any_join_key_attributes_nullable_(any_join_key_attributes_nullable),
         build_block_id_(build_block_id),
+        predicate_(predicate),
         hash_table_(DCHECK_NOTNULL(hash_table)),
         storage_manager_(DCHECK_NOTNULL(storage_manager)),
         lip_filter_builder_(lip_filter_builder) {}
@@ -221,6 +228,7 @@ class BuildHashWorkOrder : public WorkOrder {
    * @param any_join_key_attributes_nullable If any attribute is nullable.
    * @param part_id The partition id of 'input_relation'.
    * @param build_block_id The block id.
+   * @param predicate The Predicate to use.
    * @param hash_table The JoinHashTable to use.
    * @param storage_manager The StorageManager to use.
    * @param lip_filter_builder The attached LIP filter builer.
@@ -231,6 +239,7 @@ class BuildHashWorkOrder : public WorkOrder {
                      const bool any_join_key_attributes_nullable,
                      const partition_id part_id,
                      const block_id build_block_id,
+                     const Predicate *predicate,
                      JoinHashTable *hash_table,
                      StorageManager *storage_manager,
                      LIPFilterBuilder *lip_filter_builder)
@@ -239,6 +248,7 @@ class BuildHashWorkOrder : public WorkOrder {
         join_key_attributes_(std::move(join_key_attributes)),
         any_join_key_attributes_nullable_(any_join_key_attributes_nullable),
         build_block_id_(build_block_id),
+        predicate_(predicate),
         hash_table_(DCHECK_NOTNULL(hash_table)),
         storage_manager_(DCHECK_NOTNULL(storage_manager)),
         lip_filter_builder_(lip_filter_builder) {}
@@ -256,6 +266,7 @@ class BuildHashWorkOrder : public WorkOrder {
   const std::vector<attribute_id> join_key_attributes_;
   const bool any_join_key_attributes_nullable_;
   const block_id build_block_id_;
+  const Predicate *predicate_;
 
   JoinHashTable *hash_table_;
   StorageManager *storage_manager_;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/relational_operators/WorkOrder.proto
----------------------------------------------------------------------
diff --git a/relational_operators/WorkOrder.proto b/relational_operators/WorkOrder.proto
index b84e758..15fde92 100644
--- a/relational_operators/WorkOrder.proto
+++ b/relational_operators/WorkOrder.proto
@@ -82,7 +82,7 @@ message BuildAggregationExistenceMapWorkOrder {
   }
 }
 
-// Next tag: 40.
+// Next tag: 41.
 message BuildHashWorkOrder {
   extend WorkOrder {
     // All required.
@@ -94,6 +94,7 @@ message BuildHashWorkOrder {
     optional fixed64 block_id = 36;
     optional int32 lip_deployment_index = 37;
     repeated uint32 lip_filter_indexes = 39;
+    optional uint32 build_predicate_index = 40;
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/relational_operators/WorkOrderFactory.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/WorkOrderFactory.cpp b/relational_operators/WorkOrderFactory.cpp
index 7f11e3e..3c52f67 100644
--- a/relational_operators/WorkOrderFactory.cpp
+++ b/relational_operators/WorkOrderFactory.cpp
@@ -163,6 +163,8 @@ WorkOrder* WorkOrderFactory::ReconstructFromProto(const serialization::WorkOrder
           proto.GetExtension(serialization::BuildHashWorkOrder::any_join_key_attributes_nullable),
           part_id,
           proto.GetExtension(serialization::BuildHashWorkOrder::block_id),
+          query_context->getPredicate(
+              proto.GetExtension(serialization::BuildHashWorkOrder::build_predicate_index)),
           query_context->getJoinHashTable(
               proto.GetExtension(serialization::BuildHashWorkOrder::join_hash_table_index), part_id),
           storage_manager,

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/39c6214a/relational_operators/tests/HashJoinOperator_unittest.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/tests/HashJoinOperator_unittest.cpp b/relational_operators/tests/HashJoinOperator_unittest.cpp
index cfd4314..eeeca4b 100644
--- a/relational_operators/tests/HashJoinOperator_unittest.cpp
+++ b/relational_operators/tests/HashJoinOperator_unittest.cpp
@@ -427,7 +427,8 @@ TEST_P(HashJoinOperatorTest, LongKeyHashJoinTest) {
                             std::vector<attribute_id>(1, dim_col_long.getID()),
                             dim_col_long.getType().isNullable(),
                             kSinglePartition,
-                            join_hash_table_index));
+                            join_hash_table_index,
+                            QueryContext::kInvalidPredicateId));
 
   // Create the prober operator with one selection attribute.
   const QueryContext::scalar_group_id selection_index = query_context_proto.scalar_groups_size();
@@ -573,7 +574,8 @@ TEST_P(HashJoinOperatorTest, IntDuplicateKeyHashJoinTest) {
                             std::vector<attribute_id>(1, dim_col_int.getID()),
                             dim_col_int.getType().isNullable(),
                             kSinglePartition,
-                            join_hash_table_index));
+                            join_hash_table_index,
+                            QueryContext::kInvalidPredicateId));
 
   // Create the prober operator with two selection attributes.
   const QueryContext::scalar_group_id selection_index = query_context_proto.scalar_groups_size();
@@ -738,7 +740,8 @@ TEST_P(HashJoinOperatorTest, CharKeyCartesianProductHashJoinTest) {
                             std::vector<attribute_id>(1, dim_col_char.getID()),
                             dim_col_char.getType().isNullable(),
                             kSinglePartition,
-                            join_hash_table_index));
+                            join_hash_table_index,
+                            QueryContext::kInvalidPredicateId));
 
   // Create prober operator with one selection attribute.
   const QueryContext::scalar_group_id selection_index = query_context_proto.scalar_groups_size();
@@ -877,7 +880,8 @@ TEST_P(HashJoinOperatorTest, VarCharDuplicateKeyHashJoinTest) {
                             std::vector<attribute_id>(1, dim_col_varchar.getID()),
                             dim_col_varchar.getType().isNullable(),
                             kSinglePartition,
-                            join_hash_table_index));
+                            join_hash_table_index,
+                            QueryContext::kInvalidPredicateId));
 
   // Create prober operator with two selection attributes.
   const QueryContext::scalar_group_id selection_index = query_context_proto.scalar_groups_size();
@@ -1052,7 +1056,8 @@ TEST_P(HashJoinOperatorTest, CompositeKeyHashJoinTest) {
                             dim_key_attrs,
                             dim_col_long.getType().isNullable() || dim_col_varchar.getType().isNullable(),
                             kSinglePartition,
-                            join_hash_table_index));
+                            join_hash_table_index,
+                            QueryContext::kInvalidPredicateId));
 
   // Create the prober operator with two selection attributes.
   const QueryContext::scalar_group_id selection_index = query_context_proto.scalar_groups_size();
@@ -1232,7 +1237,8 @@ TEST_P(HashJoinOperatorTest, CompositeKeyHashJoinWithResidualPredicateTest) {
                             dim_key_attrs,
                             dim_col_long.getType().isNullable() || dim_col_varchar.getType().isNullable(),
                             kSinglePartition,
-                            join_hash_table_index));
+                            join_hash_table_index,
+                            QueryContext::kInvalidPredicateId));
 
   // Create prober operator with two selection attributes.
   const QueryContext::scalar_group_id selection_index = query_context_proto.scalar_groups_size();
@@ -1425,7 +1431,8 @@ TEST_P(HashJoinOperatorTest, SingleAttributePartitionedLongKeyHashJoinTest) {
       { dim_col_long.getID() },
       dim_col_long.getType().isNullable(),
       kMultiplePartitions,
-      join_hash_table_index));
+      join_hash_table_index,
+      QueryContext::kInvalidPredicateId));
 
   // Create the prober operator with one selection attribute.
   const QueryContext::scalar_group_id selection_index = query_context_proto.scalar_groups_size();
@@ -1566,7 +1573,8 @@ TEST_P(HashJoinOperatorTest, SingleAttributePartitionedCompositeKeyHashJoinTest)
       { dim_col_long.getID(), dim_col_varchar.getID() },
       dim_col_long.getType().isNullable() || dim_col_varchar.getType().isNullable(),
       kMultiplePartitions,
-      join_hash_table_index));
+      join_hash_table_index,
+      QueryContext::kInvalidPredicateId));
 
   // Create the prober operator with two selection attributes.
   const QueryContext::scalar_group_id selection_index = query_context_proto.scalar_groups_size();
@@ -1737,7 +1745,8 @@ TEST_P(HashJoinOperatorTest, SingleAttributePartitionedCompositeKeyHashJoinWithR
       { dim_col_long.getID(), dim_col_varchar.getID() },
       dim_col_long.getType().isNullable() || dim_col_varchar.getType().isNullable(),
       kMultiplePartitions,
-      join_hash_table_index));
+      join_hash_table_index,
+      QueryContext::kInvalidPredicateId));
 
   // Create prober operator with two selection attributes.
   const QueryContext::scalar_group_id selection_index = query_context_proto.scalar_groups_size();


[17/46] incubator-quickstep git commit: Added Vector Aggregation support in the distributed version.

Posted by ji...@apache.org.
Added Vector Aggregation support in the distributed version.


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

Branch: refs/heads/fix-iwyu
Commit: e79b520ec919fbe101ad72978c02216eeeeb6ca6
Parents: 8f094a1
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Fri Aug 4 17:03:34 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Thu Oct 12 11:44:44 2017 -0500

----------------------------------------------------------------------
 .../FinalizeAggregationOperator.cpp             | 31 ++++++++++----------
 .../InitializeAggregationOperator.cpp           | 23 +++++++--------
 relational_operators/WorkOrderFactory.cpp       |  2 --
 3 files changed, 27 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e79b520e/relational_operators/FinalizeAggregationOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/FinalizeAggregationOperator.cpp b/relational_operators/FinalizeAggregationOperator.cpp
index 68d0ef4..92fc7f6 100644
--- a/relational_operators/FinalizeAggregationOperator.cpp
+++ b/relational_operators/FinalizeAggregationOperator.cpp
@@ -67,28 +67,29 @@ bool FinalizeAggregationOperator::getAllWorkOrders(
   return true;
 }
 
-// TODO(quickstep-team) : Think about how the number of partitions could be
-// accessed in this function. Until then, we can't use partitioned aggregation
-// finalization with the distributed version.
 bool FinalizeAggregationOperator::getAllWorkOrderProtos(WorkOrderProtosContainer *container) {
   if (started_) {
     return true;
   }
 
   for (partition_id part_id = 0; part_id < num_partitions_; ++part_id) {
-    serialization::WorkOrder *proto = new serialization::WorkOrder;
-    proto->set_work_order_type(serialization::FINALIZE_AGGREGATION);
-    proto->set_query_id(query_id_);
-    proto->SetExtension(serialization::FinalizeAggregationWorkOrder::aggr_state_index,
-                        aggr_state_index_);
-    proto->SetExtension(serialization::FinalizeAggregationWorkOrder::partition_id,
-                        part_id);
-    proto->SetExtension(serialization::FinalizeAggregationWorkOrder::state_partition_id,
-                        0u);
-    proto->SetExtension(serialization::FinalizeAggregationWorkOrder::insert_destination_index,
-                        output_destination_index_);
+    for (std::size_t state_part_id = 0;
+         state_part_id < aggr_state_num_partitions_;
+         ++state_part_id) {
+      serialization::WorkOrder *proto = new serialization::WorkOrder;
+      proto->set_work_order_type(serialization::FINALIZE_AGGREGATION);
+      proto->set_query_id(query_id_);
+      proto->SetExtension(serialization::FinalizeAggregationWorkOrder::aggr_state_index,
+                          aggr_state_index_);
+      proto->SetExtension(serialization::FinalizeAggregationWorkOrder::partition_id,
+                          part_id);
+      proto->SetExtension(serialization::FinalizeAggregationWorkOrder::state_partition_id,
+                          state_part_id);
+      proto->SetExtension(serialization::FinalizeAggregationWorkOrder::insert_destination_index,
+                          output_destination_index_);
 
-    container->addWorkOrderProto(proto, op_index_);
+      container->addWorkOrderProto(proto, op_index_);
+    }
   }
 
   started_ = true;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e79b520e/relational_operators/InitializeAggregationOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/InitializeAggregationOperator.cpp b/relational_operators/InitializeAggregationOperator.cpp
index 39a6fb4..89dfd7e 100644
--- a/relational_operators/InitializeAggregationOperator.cpp
+++ b/relational_operators/InitializeAggregationOperator.cpp
@@ -64,26 +64,25 @@ bool InitializeAggregationOperator::getAllWorkOrders(
   return true;
 }
 
-// TODO(quickstep-team) : Think about how the number of partitions could be
-// accessed in this function. Until then, we can't use partitioned aggregation
-// initialization with the distributed version.
 bool InitializeAggregationOperator::getAllWorkOrderProtos(WorkOrderProtosContainer *container) {
-  LOG(FATAL) << "Not supported";
-
   if (started_) {
     return true;
   }
 
   for (partition_id part_id = 0; part_id < num_partitions_; ++part_id) {
-    serialization::WorkOrder *proto = new serialization::WorkOrder;
-    proto->set_work_order_type(serialization::INITIALIZE_AGGREGATION);
-    proto->set_query_id(query_id_);
+    for (std::size_t state_part_id = 0;
+         state_part_id < aggr_state_num_init_partitions_;
+         ++state_part_id) {
+      serialization::WorkOrder *proto = new serialization::WorkOrder;
+      proto->set_work_order_type(serialization::INITIALIZE_AGGREGATION);
+      proto->set_query_id(query_id_);
 
-    proto->SetExtension(serialization::InitializeAggregationWorkOrder::aggr_state_index, aggr_state_index_);
-    proto->SetExtension(serialization::InitializeAggregationWorkOrder::partition_id, part_id);
-    proto->SetExtension(serialization::InitializeAggregationWorkOrder::state_partition_id, 0u);
+      proto->SetExtension(serialization::InitializeAggregationWorkOrder::aggr_state_index, aggr_state_index_);
+      proto->SetExtension(serialization::InitializeAggregationWorkOrder::partition_id, part_id);
+      proto->SetExtension(serialization::InitializeAggregationWorkOrder::state_partition_id, state_part_id);
 
-    container->addWorkOrderProto(proto, op_index_);
+      container->addWorkOrderProto(proto, op_index_);
+    }
   }
   started_ = true;
   return true;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e79b520e/relational_operators/WorkOrderFactory.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/WorkOrderFactory.cpp b/relational_operators/WorkOrderFactory.cpp
index 25cc81a..3a991bd 100644
--- a/relational_operators/WorkOrderFactory.cpp
+++ b/relational_operators/WorkOrderFactory.cpp
@@ -237,8 +237,6 @@ WorkOrder* WorkOrderFactory::ReconstructFromProto(const serialization::WorkOrder
 
       LOG(INFO) << "Creating FinalizeAggregationWorkOrder (Partition " << part_id << ") for Query " << query_id
                 << " in Shiftboss " << shiftboss_index;
-      // TODO(quickstep-team): Handle inner-table partitioning in the distributed
-      // setting.
       return new FinalizeAggregationWorkOrder(
           query_id,
           part_id,


[31/46] incubator-quickstep git commit: Remove glog source code from third party

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/signalhandler.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/signalhandler.cc b/third_party/src/glog/src/signalhandler.cc
deleted file mode 100644
index d6c203b..0000000
--- a/third_party/src/glog/src/signalhandler.cc
+++ /dev/null
@@ -1,350 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-//
-// Implementation of InstallFailureSignalHandler().
-
-#include "utilities.h"
-#include "stacktrace.h"
-#include "symbolize.h"
-#include "glog/logging.h"
-
-#include <signal.h>
-#include <time.h>
-#ifdef HAVE_UCONTEXT_H
-# include <ucontext.h>
-#endif
-#ifdef HAVE_SYS_UCONTEXT_H
-# include <sys/ucontext.h>
-#endif
-#include <algorithm>
-
-_START_GOOGLE_NAMESPACE_
-
-namespace {
-
-// We'll install the failure signal handler for these signals.  We could
-// use strsignal() to get signal names, but we don't use it to avoid
-// introducing yet another #ifdef complication.
-//
-// The list should be synced with the comment in signalhandler.h.
-const struct {
-  int number;
-  const char *name;
-} kFailureSignals[] = {
-  { SIGSEGV, "SIGSEGV" },
-  { SIGILL, "SIGILL" },
-  { SIGFPE, "SIGFPE" },
-  { SIGABRT, "SIGABRT" },
-  { SIGBUS, "SIGBUS" },
-  { SIGTERM, "SIGTERM" },
-};
-
-// Returns the program counter from signal context, NULL if unknown.
-void* GetPC(void* ucontext_in_void) {
-#if (defined(HAVE_UCONTEXT_H) || defined(HAVE_SYS_UCONTEXT_H)) && defined(PC_FROM_UCONTEXT)
-  if (ucontext_in_void != NULL) {
-    ucontext_t *context = reinterpret_cast<ucontext_t *>(ucontext_in_void);
-    return (void*)context->PC_FROM_UCONTEXT;
-  }
-#endif
-  return NULL;
-}
-
-// The class is used for formatting error messages.  We don't use printf()
-// as it's not async signal safe.
-class MinimalFormatter {
- public:
-  MinimalFormatter(char *buffer, int size)
-      : buffer_(buffer),
-        cursor_(buffer),
-        end_(buffer + size) {
-  }
-
-  // Returns the number of bytes written in the buffer.
-  int num_bytes_written() const { return cursor_ - buffer_; }
-
-  // Appends string from "str" and updates the internal cursor.
-  void AppendString(const char* str) {
-    int i = 0;
-    while (str[i] != '\0' && cursor_ + i < end_) {
-      cursor_[i] = str[i];
-      ++i;
-    }
-    cursor_ += i;
-  }
-
-  // Formats "number" in "radix" and updates the internal cursor.
-  // Lowercase letters are used for 'a' - 'z'.
-  void AppendUint64(uint64 number, int radix) {
-    int i = 0;
-    while (cursor_ + i < end_) {
-      const int tmp = number % radix;
-      number /= radix;
-      cursor_[i] = (tmp < 10 ? '0' + tmp : 'a' + tmp - 10);
-      ++i;
-      if (number == 0) {
-        break;
-      }
-    }
-    // Reverse the bytes written.
-    std::reverse(cursor_, cursor_ + i);
-    cursor_ += i;
-  }
-
-  // Formats "number" as hexadecimal number, and updates the internal
-  // cursor.  Padding will be added in front if needed.
-  void AppendHexWithPadding(uint64 number, int width) {
-    char* start = cursor_;
-    AppendString("0x");
-    AppendUint64(number, 16);
-    // Move to right and add padding in front if needed.
-    if (cursor_ < start + width) {
-      const int64 delta = start + width - cursor_;
-      std::copy(start, cursor_, start + delta);
-      std::fill(start, start + delta, ' ');
-      cursor_ = start + width;
-    }
-  }
-
- private:
-  char *buffer_;
-  char *cursor_;
-  const char * const end_;
-};
-
-// Writes the given data with the size to the standard error.
-void WriteToStderr(const char* data, int size) {
-  if (write(STDERR_FILENO, data, size) < 0) {
-    // Ignore errors.
-  }
-}
-
-// The writer function can be changed by InstallFailureWriter().
-void (*g_failure_writer)(const char* data, int size) = WriteToStderr;
-
-// Dumps time information.  We don't dump human-readable time information
-// as localtime() is not guaranteed to be async signal safe.
-void DumpTimeInfo() {
-  time_t time_in_sec = time(NULL);
-  char buf[256];  // Big enough for time info.
-  MinimalFormatter formatter(buf, sizeof(buf));
-  formatter.AppendString("*** Aborted at ");
-  formatter.AppendUint64(time_in_sec, 10);
-  formatter.AppendString(" (unix time)");
-  formatter.AppendString(" try \"date -d @");
-  formatter.AppendUint64(time_in_sec, 10);
-  formatter.AppendString("\" if you are using GNU date ***\n");
-  g_failure_writer(buf, formatter.num_bytes_written());
-}
-
-// Dumps information about the signal to STDERR.
-void DumpSignalInfo(int signal_number, siginfo_t *siginfo) {
-  // Get the signal name.
-  const char* signal_name = NULL;
-  for (size_t i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
-    if (signal_number == kFailureSignals[i].number) {
-      signal_name = kFailureSignals[i].name;
-    }
-  }
-
-  char buf[256];  // Big enough for signal info.
-  MinimalFormatter formatter(buf, sizeof(buf));
-
-  formatter.AppendString("*** ");
-  if (signal_name) {
-    formatter.AppendString(signal_name);
-  } else {
-    // Use the signal number if the name is unknown.  The signal name
-    // should be known, but just in case.
-    formatter.AppendString("Signal ");
-    formatter.AppendUint64(signal_number, 10);
-  }
-  formatter.AppendString(" (@0x");
-  formatter.AppendUint64(reinterpret_cast<uintptr_t>(siginfo->si_addr), 16);
-  formatter.AppendString(")");
-  formatter.AppendString(" received by PID ");
-  formatter.AppendUint64(getpid(), 10);
-  formatter.AppendString(" (TID 0x");
-  // We assume pthread_t is an integral number or a pointer, rather
-  // than a complex struct.  In some environments, pthread_self()
-  // returns an uint64 but in some other environments pthread_self()
-  // returns a pointer.  Hence we use C-style cast here, rather than
-  // reinterpret/static_cast, to support both types of environments.
-  formatter.AppendUint64((uintptr_t)pthread_self(), 16);
-  formatter.AppendString(") ");
-  // Only linux has the PID of the signal sender in si_pid.
-#ifdef OS_LINUX
-  formatter.AppendString("from PID ");
-  formatter.AppendUint64(siginfo->si_pid, 10);
-  formatter.AppendString("; ");
-#endif
-  formatter.AppendString("stack trace: ***\n");
-  g_failure_writer(buf, formatter.num_bytes_written());
-}
-
-// Dumps information about the stack frame to STDERR.
-void DumpStackFrameInfo(const char* prefix, void* pc) {
-  // Get the symbol name.
-  const char *symbol = "(unknown)";
-  char symbolized[1024];  // Big enough for a sane symbol.
-  // Symbolizes the previous address of pc because pc may be in the
-  // next function.
-  if (Symbolize(reinterpret_cast<char *>(pc) - 1,
-                symbolized, sizeof(symbolized))) {
-    symbol = symbolized;
-  }
-
-  char buf[1024];  // Big enough for stack frame info.
-  MinimalFormatter formatter(buf, sizeof(buf));
-
-  formatter.AppendString(prefix);
-  formatter.AppendString("@ ");
-  const int width = 2 * sizeof(void*) + 2;  // + 2  for "0x".
-  formatter.AppendHexWithPadding(reinterpret_cast<uintptr_t>(pc), width);
-  formatter.AppendString(" ");
-  formatter.AppendString(symbol);
-  formatter.AppendString("\n");
-  g_failure_writer(buf, formatter.num_bytes_written());
-}
-
-// Invoke the default signal handler.
-void InvokeDefaultSignalHandler(int signal_number) {
-  struct sigaction sig_action;
-  memset(&sig_action, 0, sizeof(sig_action));
-  sigemptyset(&sig_action.sa_mask);
-  sig_action.sa_handler = SIG_DFL;
-  sigaction(signal_number, &sig_action, NULL);
-  kill(getpid(), signal_number);
-}
-
-// This variable is used for protecting FailureSignalHandler() from
-// dumping stuff while another thread is doing it.  Our policy is to let
-// the first thread dump stuff and let other threads wait.
-// See also comments in FailureSignalHandler().
-static pthread_t* g_entered_thread_id_pointer = NULL;
-
-// Dumps signal and stack frame information, and invokes the default
-// signal handler once our job is done.
-void FailureSignalHandler(int signal_number,
-                          siginfo_t *signal_info,
-                          void *ucontext) {
-  // First check if we've already entered the function.  We use an atomic
-  // compare and swap operation for platforms that support it.  For other
-  // platforms, we use a naive method that could lead to a subtle race.
-
-  // We assume pthread_self() is async signal safe, though it's not
-  // officially guaranteed.
-  pthread_t my_thread_id = pthread_self();
-  // NOTE: We could simply use pthread_t rather than pthread_t* for this,
-  // if pthread_self() is guaranteed to return non-zero value for thread
-  // ids, but there is no such guarantee.  We need to distinguish if the
-  // old value (value returned from __sync_val_compare_and_swap) is
-  // different from the original value (in this case NULL).
-  pthread_t* old_thread_id_pointer =
-      glog_internal_namespace_::sync_val_compare_and_swap(
-          &g_entered_thread_id_pointer,
-          static_cast<pthread_t*>(NULL),
-          &my_thread_id);
-  if (old_thread_id_pointer != NULL) {
-    // We've already entered the signal handler.  What should we do?
-    if (pthread_equal(my_thread_id, *g_entered_thread_id_pointer)) {
-      // It looks the current thread is reentering the signal handler.
-      // Something must be going wrong (maybe we are reentering by another
-      // type of signal?).  Kill ourself by the default signal handler.
-      InvokeDefaultSignalHandler(signal_number);
-    }
-    // Another thread is dumping stuff.  Let's wait until that thread
-    // finishes the job and kills the process.
-    while (true) {
-      sleep(1);
-    }
-  }
-  // This is the first time we enter the signal handler.  We are going to
-  // do some interesting stuff from here.
-  // TODO(satorux): We might want to set timeout here using alarm(), but
-  // mixing alarm() and sleep() can be a bad idea.
-
-  // First dump time info.
-  DumpTimeInfo();
-
-  // Get the program counter from ucontext.
-  void *pc = GetPC(ucontext);
-  DumpStackFrameInfo("PC: ", pc);
-
-#ifdef HAVE_STACKTRACE
-  // Get the stack traces.
-  void *stack[32];
-  // +1 to exclude this function.
-  const int depth = GetStackTrace(stack, ARRAYSIZE(stack), 1);
-  DumpSignalInfo(signal_number, signal_info);
-  // Dump the stack traces.
-  for (int i = 0; i < depth; ++i) {
-    DumpStackFrameInfo("    ", stack[i]);
-  }
-#endif
-
-  // *** TRANSITION ***
-  //
-  // BEFORE this point, all code must be async-termination-safe!
-  // (See WARNING above.)
-  //
-  // AFTER this point, we do unsafe things, like using LOG()!
-  // The process could be terminated or hung at any time.  We try to
-  // do more useful things first and riskier things later.
-
-  // Flush the logs before we do anything in case 'anything'
-  // causes problems.
-  FlushLogFilesUnsafe(0);
-
-  // Kill ourself by the default signal handler.
-  InvokeDefaultSignalHandler(signal_number);
-}
-
-}  // namespace
-
-void InstallFailureSignalHandler() {
-  // Build the sigaction struct.
-  struct sigaction sig_action;
-  memset(&sig_action, 0, sizeof(sig_action));
-  sigemptyset(&sig_action.sa_mask);
-  sig_action.sa_flags |= SA_SIGINFO;
-  sig_action.sa_sigaction = &FailureSignalHandler;
-
-  for (size_t i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
-    CHECK_ERR(sigaction(kFailureSignals[i].number, &sig_action, NULL));
-  }
-}
-
-void InstallFailureWriter(void (*writer)(const char* data, int size)) {
-  g_failure_writer = writer;
-}
-
-_END_GOOGLE_NAMESPACE_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/signalhandler_unittest.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/signalhandler_unittest.cc b/third_party/src/glog/src/signalhandler_unittest.cc
deleted file mode 100644
index 1cd0fa0..0000000
--- a/third_party/src/glog/src/signalhandler_unittest.cc
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-//
-// This is a helper binary for testing signalhandler.cc.  The actual test
-// is done in signalhandler_unittest.sh.
-
-#include "utilities.h"
-
-#include <pthread.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string>
-#include "glog/logging.h"
-
-using namespace GOOGLE_NAMESPACE;
-
-void* DieInThread(void*) {
-  // We assume pthread_t is an integral number or a pointer, rather
-  // than a complex struct.  In some environments, pthread_self()
-  // returns an uint64 but in some other environments pthread_self()
-  // returns a pointer.  Hence we use C-style cast here, rather than
-  // reinterpret/static_cast, to support both types of environments.
-  fprintf(stderr, "0x%lx is dying\n", (long)pthread_self());
-  // Use volatile to prevent from these to be optimized away.
-  volatile int a = 0;
-  volatile int b = 1 / a;
-  fprintf(stderr, "We should have died: b=%d\n", b);
-  return NULL;
-}
-
-void WriteToStdout(const char* data, int size) {
-  if (write(STDOUT_FILENO, data, size) < 0) {
-    // Ignore errors.
-  }
-}
-
-int main(int argc, char **argv) {
-#if defined(HAVE_STACKTRACE) && defined(HAVE_SYMBOLIZE)
-  InitGoogleLogging(argv[0]);
-#ifdef HAVE_LIB_GFLAGS
-  ParseCommandLineFlags(&argc, &argv, true);
-#endif
-  InstallFailureSignalHandler();
-  const std::string command = argc > 1 ? argv[1] : "none";
-  if (command == "segv") {
-    // We'll check if this is outputted.
-    LOG(INFO) << "create the log file";
-    LOG(INFO) << "a message before segv";
-    // We assume 0xDEAD is not writable.
-    int *a = (int*)0xDEAD;
-    *a = 0;
-  } else if (command == "loop") {
-    fprintf(stderr, "looping\n");
-    while (true);
-  } else if (command == "die_in_thread") {
-    pthread_t thread;
-    pthread_create(&thread, NULL, &DieInThread, NULL);
-    pthread_join(thread, NULL);
-  } else if (command == "dump_to_stdout") {
-    InstallFailureWriter(WriteToStdout);
-    abort();
-  } else {
-    // Tell the shell script
-    puts("OK");
-  }
-#endif
-  return 0;
-}

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/signalhandler_unittest.sh
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/signalhandler_unittest.sh b/third_party/src/glog/src/signalhandler_unittest.sh
deleted file mode 100644
index 265cd45..0000000
--- a/third_party/src/glog/src/signalhandler_unittest.sh
+++ /dev/null
@@ -1,131 +0,0 @@
-#! /bin/sh
-#
-# Copyright (c) 2008, Google Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-#     * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#     * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-#     * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# Author: Satoru Takabayashi
-#
-# Unit tests for signalhandler.cc.
-
-die () {
-    echo $1
-    exit 1
-}
-
-BINDIR=".libs"
-LIBGLOG="$BINDIR/libglog.so"
-
-BINARY="$BINDIR/signalhandler_unittest"
-LOG_INFO="./signalhandler_unittest.INFO"
-
-# Remove temporary files.
-rm -f signalhandler.out*
-
-if test -e "$BINARY"; then
-  # We need shared object.
-  export LD_LIBRARY_PATH=$BINDIR
-  export DYLD_LIBRARY_PATH=$BINDIR
-else
-  # For windows
-  BINARY="./signalhandler_unittest.exe"
-  if ! test -e "$BINARY"; then
-    echo "We coundn't find demangle_unittest binary."
-    exit 1
-  fi
-fi
-
-if [ x`$BINARY` != 'xOK' ]; then
-  echo "PASS (No stacktrace support. We don't run this test.)"
-  exit 0
-fi
-
-# The PC cannot be obtained in signal handlers on PowerPC correctly.
-# We just skip the test for PowerPC.
-if [ x`uname -p` = x"powerpc" ]; then
-  echo "PASS (We don't test the signal handler on PowerPC.)"
-  exit 0
-fi
-
-# Test for a case the program kills itself by SIGSEGV.
-GOOGLE_LOG_DIR=. $BINARY segv 2> signalhandler.out1
-for pattern in SIGSEGV 0xdead main "Aborted at [0-9]"; do
-  if ! grep --quiet "$pattern" signalhandler.out1; then
-    die "'$pattern' should appear in the output"
-  fi
-done
-if ! grep --quiet "a message before segv" $LOG_INFO; then
-  die "'a message before segv' should appear in the INFO log"
-fi
-rm -f $LOG_INFO
-
-# Test for a case the program is killed by this shell script.
-# $! = the process id of the last command run in the background.
-# $$ = the process id of this shell.
-$BINARY loop 2> signalhandler.out2 &
-# Wait until "looping" is written in the file.  This indicates the program
-# is ready to accept signals.
-while true; do
-  if grep --quiet looping signalhandler.out2; then
-    break
-  fi
-done
-kill -TERM $!
-wait $!
-
-from_pid=''
-# Only linux has the process ID of the signal sender.
-if [ x`uname` = "xLinux" ]; then
-  from_pid="from PID $$"
-fi
-for pattern in SIGTERM "by PID $!" "$from_pid" main "Aborted at [0-9]"; do
-  if ! grep --quiet "$pattern" signalhandler.out2; then
-    die "'$pattern' should appear in the output"
-  fi
-done
-
-# Test for a case the program dies in a non-main thread.
-$BINARY die_in_thread 2> signalhandler.out3
-EXPECTED_TID="`sed 's/ .*//; q' signalhandler.out3`"
-
-for pattern in SIGFPE DieInThread "TID $EXPECTED_TID" "Aborted at [0-9]"; do
-  if ! grep --quiet "$pattern" signalhandler.out3; then
-    die "'$pattern' should appear in the output"
-  fi
-done
-
-# Test for a case the program installs a custom failure writer that writes
-# stuff to stdout instead of stderr.
-$BINARY dump_to_stdout 1> signalhandler.out4
-for pattern in SIGABRT main "Aborted at [0-9]"; do
-  if ! grep --quiet "$pattern" signalhandler.out4; then
-    die "'$pattern' should appear in the output"
-  fi
-done
-
-echo PASS

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/stacktrace.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/stacktrace.h b/third_party/src/glog/src/stacktrace.h
deleted file mode 100644
index 8c3e8fe..0000000
--- a/third_party/src/glog/src/stacktrace.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (c) 2000 - 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Routines to extract the current stack trace.  These functions are
-// thread-safe.
-
-#ifndef BASE_STACKTRACE_H_
-#define BASE_STACKTRACE_H_
-
-#include "config.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// This is similar to the GetStackFrames routine, except that it returns
-// the stack trace only, and not the stack frame sizes as well.
-// Example:
-//      main() { foo(); }
-//      foo() { bar(); }
-//      bar() {
-//        void* result[10];
-//        int depth = GetStackFrames(result, 10, 1);
-//      }
-//
-// This produces:
-//      result[0]       foo
-//      result[1]       main
-//           ....       ...
-//
-// "result" must not be NULL.
-extern int GetStackTrace(void** result, int max_depth, int skip_count);
-
-_END_GOOGLE_NAMESPACE_
-
-#endif  // BASE_STACKTRACE_H_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/stacktrace_generic-inl.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/stacktrace_generic-inl.h b/third_party/src/glog/src/stacktrace_generic-inl.h
deleted file mode 100644
index fad81d3..0000000
--- a/third_party/src/glog/src/stacktrace_generic-inl.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2000 - 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Portable implementation - just use glibc
-//
-// Note:  The glibc implementation may cause a call to malloc.
-// This can cause a deadlock in HeapProfiler.
-#include <execinfo.h>
-#include <string.h>
-#include "stacktrace.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// If you change this function, also change GetStackFrames below.
-int GetStackTrace(void** result, int max_depth, int skip_count) {
-  static const int kStackLength = 64;
-  void * stack[kStackLength];
-  int size;
-
-  size = backtrace(stack, kStackLength);
-  skip_count++;  // we want to skip the current frame as well
-  int result_count = size - skip_count;
-  if (result_count < 0)
-    result_count = 0;
-  if (result_count > max_depth)
-    result_count = max_depth;
-  for (int i = 0; i < result_count; i++)
-    result[i] = stack[i + skip_count];
-
-  return result_count;
-}
-
-_END_GOOGLE_NAMESPACE_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/stacktrace_libunwind-inl.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/stacktrace_libunwind-inl.h b/third_party/src/glog/src/stacktrace_libunwind-inl.h
deleted file mode 100644
index 0dc14c6..0000000
--- a/third_party/src/glog/src/stacktrace_libunwind-inl.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) 2005 - 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Arun Sharma
-//
-// Produce stack trace using libunwind
-
-#include "utilities.h"
-
-extern "C" {
-#define UNW_LOCAL_ONLY
-#include <libunwind.h>
-}
-#include "glog/raw_logging.h"
-#include "stacktrace.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// Sometimes, we can try to get a stack trace from within a stack
-// trace, because libunwind can call mmap (maybe indirectly via an
-// internal mmap based memory allocator), and that mmap gets trapped
-// and causes a stack-trace request.  If were to try to honor that
-// recursive request, we'd end up with infinite recursion or deadlock.
-// Luckily, it's safe to ignore those subsequent traces.  In such
-// cases, we return 0 to indicate the situation.
-static bool g_now_entering = false;
-
-// If you change this function, also change GetStackFrames below.
-int GetStackTrace(void** result, int max_depth, int skip_count) {
-  void *ip;
-  int n = 0;
-  unw_cursor_t cursor;
-  unw_context_t uc;
-
-  if (sync_val_compare_and_swap(&g_now_entering, false, true)) {
-    return 0;
-  }
-
-  unw_getcontext(&uc);
-  RAW_CHECK(unw_init_local(&cursor, &uc) >= 0, "unw_init_local failed");
-  skip_count++;         // Do not include the "GetStackTrace" frame
-
-  while (n < max_depth) {
-    int ret = unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *) &ip);
-    if (ret < 0)
-      break;
-    if (skip_count > 0) {
-      skip_count--;
-    } else {
-      result[n++] = ip;
-    }
-    ret = unw_step(&cursor);
-    if (ret <= 0)
-      break;
-  }
-
-  g_now_entering = false;
-  return n;
-}
-
-_END_GOOGLE_NAMESPACE_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/stacktrace_powerpc-inl.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/stacktrace_powerpc-inl.h b/third_party/src/glog/src/stacktrace_powerpc-inl.h
deleted file mode 100644
index 1090dde..0000000
--- a/third_party/src/glog/src/stacktrace_powerpc-inl.h
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright (c) 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Craig Silverstein
-//
-// Produce stack trace.  I'm guessing (hoping!) the code is much like
-// for x86.  For apple machines, at least, it seems to be; see
-//    http://developer.apple.com/documentation/mac/runtimehtml/RTArch-59.html
-//    http://www.linux-foundation.org/spec/ELF/ppc64/PPC-elf64abi-1.9.html#STACK
-// Linux has similar code: http://patchwork.ozlabs.org/linuxppc/patch?id=8882
-
-#include <stdio.h>
-#include <stdint.h>   // for uintptr_t
-#include "stacktrace.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// Given a pointer to a stack frame, locate and return the calling
-// stackframe, or return NULL if no stackframe can be found. Perform sanity
-// checks (the strictness of which is controlled by the boolean parameter
-// "STRICT_UNWINDING") to reduce the chance that a bad pointer is returned.
-template<bool STRICT_UNWINDING>
-static void **NextStackFrame(void **old_sp) {
-  void **new_sp = (void **) *old_sp;
-
-  // Check that the transition from frame pointer old_sp to frame
-  // pointer new_sp isn't clearly bogus
-  if (STRICT_UNWINDING) {
-    // With the stack growing downwards, older stack frame must be
-    // at a greater address that the current one.
-    if (new_sp <= old_sp) return NULL;
-    // Assume stack frames larger than 100,000 bytes are bogus.
-    if ((uintptr_t)new_sp - (uintptr_t)old_sp > 100000) return NULL;
-  } else {
-    // In the non-strict mode, allow discontiguous stack frames.
-    // (alternate-signal-stacks for example).
-    if (new_sp == old_sp) return NULL;
-    // And allow frames upto about 1MB.
-    if ((new_sp > old_sp)
-        && ((uintptr_t)new_sp - (uintptr_t)old_sp > 1000000)) return NULL;
-  }
-  if ((uintptr_t)new_sp & (sizeof(void *) - 1)) return NULL;
-  return new_sp;
-}
-
-// This ensures that GetStackTrace stes up the Link Register properly.
-void StacktracePowerPCDummyFunction() __attribute__((noinline));
-void StacktracePowerPCDummyFunction() { __asm__ volatile(""); }
-
-// If you change this function, also change GetStackFrames below.
-int GetStackTrace(void** result, int max_depth, int skip_count) {
-  void **sp;
-  // Apple OS X uses an old version of gnu as -- both Darwin 7.9.0 (Panther)
-  // and Darwin 8.8.1 (Tiger) use as 1.38.  This means we have to use a
-  // different asm syntax.  I don't know quite the best way to discriminate
-  // systems using the old as from the new one; I've gone with __APPLE__.
-#ifdef __APPLE__
-  __asm__ volatile ("mr %0,r1" : "=r" (sp));
-#else
-  __asm__ volatile ("mr %0,1" : "=r" (sp));
-#endif
-
-  // On PowerPC, the "Link Register" or "Link Record" (LR), is a stack
-  // entry that holds the return address of the subroutine call (what
-  // instruction we run after our function finishes).  This is the
-  // same as the stack-pointer of our parent routine, which is what we
-  // want here.  While the compiler will always(?) set up LR for
-  // subroutine calls, it may not for leaf functions (such as this one).
-  // This routine forces the compiler (at least gcc) to push it anyway.
-  StacktracePowerPCDummyFunction();
-
-  // The LR save area is used by the callee, so the top entry is bogus.
-  skip_count++;
-
-  int n = 0;
-  while (sp && n < max_depth) {
-    if (skip_count > 0) {
-      skip_count--;
-    } else {
-      // PowerPC has 3 main ABIs, which say where in the stack the
-      // Link Register is.  For DARWIN and AIX (used by apple and
-      // linux ppc64), it's in sp[2].  For SYSV (used by linux ppc),
-      // it's in sp[1].
-#if defined(_CALL_AIX) || defined(_CALL_DARWIN)
-      result[n++] = *(sp+2);
-#elif defined(_CALL_SYSV)
-      result[n++] = *(sp+1);
-#elif defined(__APPLE__) || (defined(__linux) && defined(__PPC64__))
-      // This check is in case the compiler doesn't define _CALL_AIX/etc.
-      result[n++] = *(sp+2);
-#elif defined(__linux)
-      // This check is in case the compiler doesn't define _CALL_SYSV.
-      result[n++] = *(sp+1);
-#else
-#error Need to specify the PPC ABI for your archiecture.
-#endif
-    }
-    // Use strict unwinding rules.
-    sp = NextStackFrame<true>(sp);
-  }
-  return n;
-}
-
-_END_GOOGLE_NAMESPACE_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/stacktrace_unittest.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/stacktrace_unittest.cc b/third_party/src/glog/src/stacktrace_unittest.cc
deleted file mode 100644
index c1b3b36..0000000
--- a/third_party/src/glog/src/stacktrace_unittest.cc
+++ /dev/null
@@ -1,208 +0,0 @@
-// Copyright (c) 2004, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include "utilities.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "config.h"
-#include "base/commandlineflags.h"
-#include "glog/logging.h"
-#include "stacktrace.h"
-
-#ifdef HAVE_EXECINFO_H
-# include <execinfo.h>
-#endif
-
-using namespace GOOGLE_NAMESPACE;
-
-#ifdef HAVE_STACKTRACE
-
-// Obtain a backtrace, verify that the expected callers are present in the
-// backtrace, and maybe print the backtrace to stdout.
-
-// The sequence of functions whose return addresses we expect to see in the
-// backtrace.
-const int BACKTRACE_STEPS = 6;
-
-struct AddressRange {
-  const void *start, *end;
-};
-
-// Expected function [start,end] range.
-AddressRange expected_range[BACKTRACE_STEPS];
-
-#if __GNUC__
-// Using GCC extension: address of a label can be taken with '&&label'.
-// Start should be a label somewhere before recursive call, end somewhere
-// after it.
-#define INIT_ADDRESS_RANGE(fn, start_label, end_label, prange)           \
-  do {                                                                   \
-    (prange)->start = &&start_label;                                     \
-    (prange)->end = &&end_label;                                         \
-    CHECK_LT((prange)->start, (prange)->end);                            \
-  } while (0)
-// This macro expands into "unmovable" code (opaque to GCC), and that
-// prevents GCC from moving a_label up or down in the code.
-// Without it, there is no code following the 'end' label, and GCC
-// (4.3.1, 4.4.0) thinks it safe to assign &&end an address that is before
-// the recursive call.
-#define DECLARE_ADDRESS_LABEL(a_label)                                   \
-  a_label: do { __asm__ __volatile__(""); } while (0)
-// Gcc 4.4.0 may split function into multiple chunks, and the chunk
-// performing recursive call may end up later in the code then the return
-// instruction (this actually happens with FDO).
-// Adjust function range from __builtin_return_address.
-#define ADJUST_ADDRESS_RANGE_FROM_RA(prange)                             \
-  do {                                                                   \
-    void *ra = __builtin_return_address(0);                              \
-    CHECK_LT((prange)->start, ra);                                       \
-    if (ra > (prange)->end) {                                            \
-      printf("Adjusting range from %p..%p to %p..%p\n",                  \
-             (prange)->start, (prange)->end,                             \
-             (prange)->start, ra);                                       \
-      (prange)->end = ra;                                                \
-    }                                                                    \
-  } while (0)
-#else
-// Assume the Check* functions below are not longer than 256 bytes.
-#define INIT_ADDRESS_RANGE(fn, start_label, end_label, prange)           \
-  do {                                                                   \
-    (prange)->start = reinterpret_cast<const void *>(&fn);               \
-    (prange)->end = reinterpret_cast<const char *>(&fn) + 256;           \
-  } while (0)
-#define DECLARE_ADDRESS_LABEL(a_label) do { } while (0)
-#define ADJUST_ADDRESS_RANGE_FROM_RA(prange) do { } while (0)
-#endif  // __GNUC__
-
-//-----------------------------------------------------------------------//
-
-void CheckRetAddrIsInFunction(void *ret_addr, const AddressRange &range)
-{
-  CHECK_GE(ret_addr, range.start);
-  CHECK_LE(ret_addr, range.end);
-}
-
-//-----------------------------------------------------------------------//
-
-void ATTRIBUTE_NOINLINE CheckStackTrace(int);
-void ATTRIBUTE_NOINLINE CheckStackTraceLeaf(void) {
-  const int STACK_LEN = 10;
-  void *stack[STACK_LEN];
-  int size;
-
-  ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[1]);
-  INIT_ADDRESS_RANGE(CheckStackTraceLeaf, start, end, &expected_range[0]);
-  DECLARE_ADDRESS_LABEL(start);
-  size = GetStackTrace(stack, STACK_LEN, 0);
-  printf("Obtained %d stack frames.\n", size);
-  CHECK_GE(size, 1);
-  CHECK_LE(size, STACK_LEN);
-
-  if (1) {
-#ifdef HAVE_EXECINFO_H
-    char **strings = backtrace_symbols(stack, size);
-    printf("Obtained %d stack frames.\n", size);
-    for (int i = 0; i < size; i++)
-      printf("%s %p\n", strings[i], stack[i]);
-    printf("CheckStackTrace() addr: %p\n", &CheckStackTrace);
-    free(strings);
-#endif
-  }
-  for (int i = 0; i < BACKTRACE_STEPS; i++) {
-    printf("Backtrace %d: expected: %p..%p  actual: %p ... ",
-           i, expected_range[i].start, expected_range[i].end, stack[i]);
-    fflush(stdout);
-    CheckRetAddrIsInFunction(stack[i], expected_range[i]);
-    printf("OK\n");
-  }
-  DECLARE_ADDRESS_LABEL(end);
-}
-
-//-----------------------------------------------------------------------//
-
-/* Dummy functions to make the backtrace more interesting. */
-void ATTRIBUTE_NOINLINE CheckStackTrace4(int i) {
-  ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[2]);
-  INIT_ADDRESS_RANGE(CheckStackTrace4, start, end, &expected_range[1]);
-  DECLARE_ADDRESS_LABEL(start);
-  for (int j = i; j >= 0; j--)
-    CheckStackTraceLeaf();
-  DECLARE_ADDRESS_LABEL(end);
-}
-void ATTRIBUTE_NOINLINE CheckStackTrace3(int i) {
-  ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[3]);
-  INIT_ADDRESS_RANGE(CheckStackTrace3, start, end, &expected_range[2]);
-  DECLARE_ADDRESS_LABEL(start);
-  for (int j = i; j >= 0; j--)
-    CheckStackTrace4(j);
-  DECLARE_ADDRESS_LABEL(end);
-}
-void ATTRIBUTE_NOINLINE CheckStackTrace2(int i) {
-  ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[4]);
-  INIT_ADDRESS_RANGE(CheckStackTrace2, start, end, &expected_range[3]);
-  DECLARE_ADDRESS_LABEL(start);
-  for (int j = i; j >= 0; j--)
-    CheckStackTrace3(j);
-  DECLARE_ADDRESS_LABEL(end);
-}
-void ATTRIBUTE_NOINLINE CheckStackTrace1(int i) {
-  ADJUST_ADDRESS_RANGE_FROM_RA(&expected_range[5]);
-  INIT_ADDRESS_RANGE(CheckStackTrace1, start, end, &expected_range[4]);
-  DECLARE_ADDRESS_LABEL(start);
-  for (int j = i; j >= 0; j--)
-    CheckStackTrace2(j);
-  DECLARE_ADDRESS_LABEL(end);
-}
-void ATTRIBUTE_NOINLINE CheckStackTrace(int i) {
-  INIT_ADDRESS_RANGE(CheckStackTrace, start, end, &expected_range[5]);
-  DECLARE_ADDRESS_LABEL(start);
-  for (int j = i; j >= 0; j--)
-    CheckStackTrace1(j);
-  DECLARE_ADDRESS_LABEL(end);
-}
-
-//-----------------------------------------------------------------------//
-
-int main(int, char ** argv) {
-  FLAGS_logtostderr = true;
-  InitGoogleLogging(argv[0]);
-
-  CheckStackTrace(0);
-
-  printf("PASS\n");
-  return 0;
-}
-
-#else
-int main() {
-  printf("PASS (no stacktrace support)\n");
-  return 0;
-}
-#endif  // HAVE_STACKTRACE

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/stacktrace_x86-inl.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/stacktrace_x86-inl.h b/third_party/src/glog/src/stacktrace_x86-inl.h
deleted file mode 100644
index cfd31f7..0000000
--- a/third_party/src/glog/src/stacktrace_x86-inl.h
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright (c) 2000 - 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Produce stack trace
-
-#include <stdint.h>   // for uintptr_t
-
-#include "utilities.h"   // for OS_* macros
-
-#if !defined(OS_WINDOWS)
-#include <unistd.h>
-#include <sys/mman.h>
-#endif
-
-#include <stdio.h>  // for NULL
-#include "stacktrace.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// Given a pointer to a stack frame, locate and return the calling
-// stackframe, or return NULL if no stackframe can be found. Perform sanity
-// checks (the strictness of which is controlled by the boolean parameter
-// "STRICT_UNWINDING") to reduce the chance that a bad pointer is returned.
-template<bool STRICT_UNWINDING>
-static void **NextStackFrame(void **old_sp) {
-  void **new_sp = (void **) *old_sp;
-
-  // Check that the transition from frame pointer old_sp to frame
-  // pointer new_sp isn't clearly bogus
-  if (STRICT_UNWINDING) {
-    // With the stack growing downwards, older stack frame must be
-    // at a greater address that the current one.
-    if (new_sp <= old_sp) return NULL;
-    // Assume stack frames larger than 100,000 bytes are bogus.
-    if ((uintptr_t)new_sp - (uintptr_t)old_sp > 100000) return NULL;
-  } else {
-    // In the non-strict mode, allow discontiguous stack frames.
-    // (alternate-signal-stacks for example).
-    if (new_sp == old_sp) return NULL;
-    // And allow frames upto about 1MB.
-    if ((new_sp > old_sp)
-        && ((uintptr_t)new_sp - (uintptr_t)old_sp > 1000000)) return NULL;
-  }
-  if ((uintptr_t)new_sp & (sizeof(void *) - 1)) return NULL;
-#ifdef __i386__
-  // On 64-bit machines, the stack pointer can be very close to
-  // 0xffffffff, so we explicitly check for a pointer into the
-  // last two pages in the address space
-  if ((uintptr_t)new_sp >= 0xffffe000) return NULL;
-#endif
-#if !defined(OS_WINDOWS)
-  if (!STRICT_UNWINDING) {
-    // Lax sanity checks cause a crash in 32-bit tcmalloc/crash_reason_test
-    // on AMD-based machines with VDSO-enabled kernels.
-    // Make an extra sanity check to insure new_sp is readable.
-    // Note: NextStackFrame<false>() is only called while the program
-    //       is already on its last leg, so it's ok to be slow here.
-    static int page_size = getpagesize();
-    void *new_sp_aligned = (void *)((uintptr_t)new_sp & ~(page_size - 1));
-    if (msync(new_sp_aligned, page_size, MS_ASYNC) == -1)
-      return NULL;
-  }
-#endif
-  return new_sp;
-}
-
-// If you change this function, also change GetStackFrames below.
-int GetStackTrace(void** result, int max_depth, int skip_count) {
-  void **sp;
-#ifdef __i386__
-  // Stack frame format:
-  //    sp[0]   pointer to previous frame
-  //    sp[1]   caller address
-  //    sp[2]   first argument
-  //    ...
-  sp = (void **)&result - 2;
-#endif
-
-#ifdef __x86_64__
-  // __builtin_frame_address(0) can return the wrong address on gcc-4.1.0-k8
-  unsigned long rbp;
-  // Move the value of the register %rbp into the local variable rbp.
-  // We need 'volatile' to prevent this instruction from getting moved
-  // around during optimization to before function prologue is done.
-  // An alternative way to achieve this
-  // would be (before this __asm__ instruction) to call Noop() defined as
-  //   static void Noop() __attribute__ ((noinline));  // prevent inlining
-  //   static void Noop() { asm(""); }  // prevent optimizing-away
-  __asm__ volatile ("mov %%rbp, %0" : "=r" (rbp));
-  // Arguments are passed in registers on x86-64, so we can't just
-  // offset from &result
-  sp = (void **) rbp;
-#endif
-
-  int n = 0;
-  while (sp && n < max_depth) {
-    if (*(sp+1) == (void *)0) {
-      // In 64-bit code, we often see a frame that
-      // points to itself and has a return address of 0.
-      break;
-    }
-    if (skip_count > 0) {
-      skip_count--;
-    } else {
-      result[n++] = *(sp+1);
-    }
-    // Use strict unwinding rules.
-    sp = NextStackFrame<true>(sp);
-  }
-  return n;
-}
-
-_END_GOOGLE_NAMESPACE_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/stacktrace_x86_64-inl.h
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/stacktrace_x86_64-inl.h b/third_party/src/glog/src/stacktrace_x86_64-inl.h
deleted file mode 100644
index c14482e..0000000
--- a/third_party/src/glog/src/stacktrace_x86_64-inl.h
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright (c) 2005 - 2007, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Arun Sharma
-//
-// Produce stack trace using libgcc
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE 1
-#endif
-
-extern "C" {
-#include <stdlib.h> // for NULL
-#include <unwind.h> // ABI defined unwinder
-}
-#include "stacktrace.h"
-
-_START_GOOGLE_NAMESPACE_
-
-typedef struct {
-  void **result;
-  int max_depth;
-  int skip_count;
-  int count;
-} trace_arg_t;
-
-
-// Workaround for the malloc() in _Unwind_Backtrace() issue.
-static _Unwind_Reason_Code nop_backtrace(struct _Unwind_Context *uc, void *opq) {
-  return _URC_NO_REASON;
-}
-
-
-// This code is not considered ready to run until
-// static initializers run so that we are guaranteed
-// that any malloc-related initialization is done.
-static bool ready_to_run = false;
-class StackTraceInit {
- public:
-   StackTraceInit() {
-     // Extra call to force initialization
-     _Unwind_Backtrace(nop_backtrace, NULL);
-     ready_to_run = true;
-   }
-};
-
-static StackTraceInit module_initializer;  // Force initialization
-
-static _Unwind_Reason_Code GetOneFrame(struct _Unwind_Context *uc, void *opq) {
-  trace_arg_t *targ = (trace_arg_t *) opq;
-
-  if (targ->skip_count > 0) {
-    targ->skip_count--;
-  } else {
-    targ->result[targ->count++] = (void *) _Unwind_GetIP(uc);
-  }
-
-  if (targ->count == targ->max_depth)
-    return _URC_END_OF_STACK;
-
-  return _URC_NO_REASON;
-}
-
-// If you change this function, also change GetStackFrames below.
-int GetStackTrace(void** result, int max_depth, int skip_count) {
-  if (!ready_to_run)
-    return 0;
-
-  trace_arg_t targ;
-
-  skip_count += 1;         // Do not include the "GetStackTrace" frame
-
-  targ.result = result;
-  targ.max_depth = max_depth;
-  targ.skip_count = skip_count;
-  targ.count = 0;
-
-  _Unwind_Backtrace(GetOneFrame, &targ);
-
-  return targ.count;
-}
-
-_END_GOOGLE_NAMESPACE_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/stl_logging_unittest.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/stl_logging_unittest.cc b/third_party/src/glog/src/stl_logging_unittest.cc
deleted file mode 100644
index 5dcbc44..0000000
--- a/third_party/src/glog/src/stl_logging_unittest.cc
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright (c) 2003, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include "config.h"
-
-#ifdef HAVE_USING_OPERATOR
-
-#include "glog/stl_logging.h"
-
-#include <iostream>
-#include <map>
-#include <ostream>
-#include <string>
-#include <vector>
-
-#ifdef __GNUC__
-# include <ext/hash_map>
-# include <ext/hash_set>
-#endif
-
-#include "glog/logging.h"
-#include "googletest.h"
-
-using namespace std;
-#ifdef __GNUC__
-using namespace __gnu_cxx;
-#endif
-
-struct user_hash {
-  size_t operator()(int x) const { return x; }
-};
-
-void TestSTLLogging() {
-  {
-    // Test a sequence.
-    vector<int> v;
-    v.push_back(10);
-    v.push_back(20);
-    v.push_back(30);
-    ostringstream ss;
-    ss << v;
-    EXPECT_EQ(ss.str(), "10 20 30");
-    vector<int> copied_v(v);
-    CHECK_EQ(v, copied_v);  // This must compile.
-  }
-
-  {
-    // Test a sorted pair associative container.
-    map< int, string > m;
-    m[20] = "twenty";
-    m[10] = "ten";
-    m[30] = "thirty";
-    ostringstream ss;
-    ss << m;
-    EXPECT_EQ(ss.str(), "(10, ten) (20, twenty) (30, thirty)");
-    map< int, string > copied_m(m);
-    CHECK_EQ(m, copied_m);  // This must compile.
-  }
-
-#ifdef __GNUC__
-  {
-    // Test a hashed simple associative container.
-    hash_set<int> hs;
-    hs.insert(10);
-    hs.insert(20);
-    hs.insert(30);
-    ostringstream ss;
-    ss << hs;
-    EXPECT_EQ(ss.str(), "10 20 30");
-    hash_set<int> copied_hs(hs);
-    CHECK_EQ(hs, copied_hs);  // This must compile.
-  }
-#endif
-
-#ifdef __GNUC__
-  {
-    // Test a hashed pair associative container.
-    hash_map<int, string> hm;
-    hm[10] = "ten";
-    hm[20] = "twenty";
-    hm[30] = "thirty";
-    ostringstream ss;
-    ss << hm;
-    EXPECT_EQ(ss.str(), "(10, ten) (20, twenty) (30, thirty)");
-    hash_map<int, string> copied_hm(hm);
-    CHECK_EQ(hm, copied_hm);  // this must compile
-  }
-#endif
-
-  {
-    // Test a long sequence.
-    vector<int> v;
-    string expected;
-    for (int i = 0; i < 100; i++) {
-      v.push_back(i);
-      if (i > 0) expected += ' ';
-      char buf[256];
-      sprintf(buf, "%d", i);
-      expected += buf;
-    }
-    v.push_back(100);
-    expected += " ...";
-    ostringstream ss;
-    ss << v;
-    CHECK_EQ(ss.str(), expected.c_str());
-  }
-
-  {
-    // Test a sorted pair associative container.
-    // Use a non-default comparison functor.
-    map< int, string, greater<int> > m;
-    m[20] = "twenty";
-    m[10] = "ten";
-    m[30] = "thirty";
-    ostringstream ss;
-    ss << m;
-    EXPECT_EQ(ss.str(), "(30, thirty) (20, twenty) (10, ten)");
-    map< int, string, greater<int> > copied_m(m);
-    CHECK_EQ(m, copied_m);  // This must compile.
-  }
-
-#ifdef __GNUC__
-  {
-    // Test a hashed simple associative container.
-    // Use a user defined hash function.
-    hash_set<int, user_hash> hs;
-    hs.insert(10);
-    hs.insert(20);
-    hs.insert(30);
-    ostringstream ss;
-    ss << hs;
-    EXPECT_EQ(ss.str(), "10 20 30");
-    hash_set<int, user_hash> copied_hs(hs);
-    CHECK_EQ(hs, copied_hs);  // This must compile.
-  }
-#endif
-}
-
-int main(int, char**) {
-  TestSTLLogging();
-  std::cout << "PASS\n";
-  return 0;
-}
-
-#else
-
-#include <iostream>
-
-int main(int, char**) {
-  std::cout << "We don't support stl_logging for this compiler.\n"
-            << "(we need compiler support of 'using ::operator<<' "
-            << "for this feature.)\n";
-  return 0;
-}
-
-#endif  // HAVE_USING_OPERATOR

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c43107d1/third_party/src/glog/src/symbolize.cc
----------------------------------------------------------------------
diff --git a/third_party/src/glog/src/symbolize.cc b/third_party/src/glog/src/symbolize.cc
deleted file mode 100644
index 157c525..0000000
--- a/third_party/src/glog/src/symbolize.cc
+++ /dev/null
@@ -1,681 +0,0 @@
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Author: Satoru Takabayashi
-// Stack-footprint reduction work done by Raksit Ashok
-//
-// Implementation note:
-//
-// We don't use heaps but only use stacks.  We want to reduce the
-// stack consumption so that the symbolizer can run on small stacks.
-//
-// Here are some numbers collected with GCC 4.1.0 on x86:
-// - sizeof(Elf32_Sym)  = 16
-// - sizeof(Elf32_Shdr) = 40
-// - sizeof(Elf64_Sym)  = 24
-// - sizeof(Elf64_Shdr) = 64
-//
-// This implementation is intended to be async-signal-safe but uses
-// some functions which are not guaranteed to be so, such as memchr()
-// and memmove().  We assume they are async-signal-safe.
-//
-
-#include "utilities.h"
-
-#if defined(HAVE_SYMBOLIZE)
-
-#include <limits>
-
-#include "symbolize.h"
-#include "demangle.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// We don't use assert() since it's not guaranteed to be
-// async-signal-safe.  Instead we define a minimal assertion
-// macro. So far, we don't need pretty printing for __FILE__, etc.
-
-// A wrapper for abort() to make it callable in ? :.
-static int AssertFail() {
-  abort();
-  return 0;  // Should not reach.
-}
-
-#define SAFE_ASSERT(expr) ((expr) ? 0 : AssertFail())
-
-static SymbolizeCallback g_symbolize_callback = NULL;
-void InstallSymbolizeCallback(SymbolizeCallback callback) {
-  g_symbolize_callback = callback;
-}
-
-// This function wraps the Demangle function to provide an interface
-// where the input symbol is demangled in-place.
-// To keep stack consumption low, we would like this function to not
-// get inlined.
-static ATTRIBUTE_NOINLINE void DemangleInplace(char *out, int out_size) {
-  char demangled[256];  // Big enough for sane demangled symbols.
-  if (Demangle(out, demangled, sizeof(demangled))) {
-    // Demangling succeeded. Copy to out if the space allows.
-    size_t len = strlen(demangled);
-    if (len + 1 <= (size_t)out_size) {  // +1 for '\0'.
-      SAFE_ASSERT(len < sizeof(demangled));
-      memmove(out, demangled, len + 1);
-    }
-  }
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#if defined(__ELF__)
-
-#include <dlfcn.h>
-#include <elf.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <link.h>  // For ElfW() macro.
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "symbolize.h"
-#include "config.h"
-#include "glog/raw_logging.h"
-
-// Re-runs fn until it doesn't cause EINTR.
-#define NO_INTR(fn)   do {} while ((fn) < 0 && errno == EINTR)
-
-_START_GOOGLE_NAMESPACE_
-
-// Read up to "count" bytes from file descriptor "fd" into the buffer
-// starting at "buf" while handling short reads and EINTR.  On
-// success, return the number of bytes read.  Otherwise, return -1.
-static ssize_t ReadPersistent(const int fd, void *buf, const size_t count) {
-  SAFE_ASSERT(fd >= 0);
-  SAFE_ASSERT(count >= 0 && count <= std::numeric_limits<ssize_t>::max());
-  char *buf0 = reinterpret_cast<char *>(buf);
-  ssize_t num_bytes = 0;
-  while (num_bytes < count) {
-    ssize_t len;
-    NO_INTR(len = read(fd, buf0 + num_bytes, count - num_bytes));
-    if (len < 0) {  // There was an error other than EINTR.
-      return -1;
-    }
-    if (len == 0) {  // Reached EOF.
-      break;
-    }
-    num_bytes += len;
-  }
-  SAFE_ASSERT(num_bytes <= count);
-  return num_bytes;
-}
-
-// Read up to "count" bytes from "offset" in the file pointed by file
-// descriptor "fd" into the buffer starting at "buf".  On success,
-// return the number of bytes read.  Otherwise, return -1.
-static ssize_t ReadFromOffset(const int fd, void *buf,
-                              const size_t count, const off_t offset) {
-  off_t off = lseek(fd, offset, SEEK_SET);
-  if (off == (off_t)-1) {
-    return -1;
-  }
-  return ReadPersistent(fd, buf, count);
-}
-
-// Try reading exactly "count" bytes from "offset" bytes in a file
-// pointed by "fd" into the buffer starting at "buf" while handling
-// short reads and EINTR.  On success, return true. Otherwise, return
-// false.
-static bool ReadFromOffsetExact(const int fd, void *buf,
-                                const size_t count, const off_t offset) {
-  ssize_t len = ReadFromOffset(fd, buf, count, offset);
-  return len == count;
-}
-
-// Returns elf_header.e_type if the file pointed by fd is an ELF binary.
-static int FileGetElfType(const int fd) {
-  ElfW(Ehdr) elf_header;
-  if (!ReadFromOffsetExact(fd, &elf_header, sizeof(elf_header), 0)) {
-    return -1;
-  }
-  if (memcmp(elf_header.e_ident, ELFMAG, SELFMAG) != 0) {
-    return -1;
-  }
-  return elf_header.e_type;
-}
-
-// Read the section headers in the given ELF binary, and if a section
-// of the specified type is found, set the output to this section header
-// and return true.  Otherwise, return false.
-// To keep stack consumption low, we would like this function to not get
-// inlined.
-static ATTRIBUTE_NOINLINE bool
-GetSectionHeaderByType(const int fd, ElfW(Half) sh_num, const off_t sh_offset,
-                       ElfW(Word) type, ElfW(Shdr) *out) {
-  // Read at most 16 section headers at a time to save read calls.
-  ElfW(Shdr) buf[16];
-  for (int i = 0; i < sh_num;) {
-    const ssize_t num_bytes_left = (sh_num - i) * sizeof(buf[0]);
-    const ssize_t num_bytes_to_read =
-        (sizeof(buf) > num_bytes_left) ? num_bytes_left : sizeof(buf);
-    const ssize_t len = ReadFromOffset(fd, buf, num_bytes_to_read,
-                                       sh_offset + i * sizeof(buf[0]));
-    SAFE_ASSERT(len % sizeof(buf[0]) == 0);
-    const ssize_t num_headers_in_buf = len / sizeof(buf[0]);
-    SAFE_ASSERT(num_headers_in_buf <= sizeof(buf) / sizeof(buf[0]));
-    for (int j = 0; j < num_headers_in_buf; ++j) {
-      if (buf[j].sh_type == type) {
-        *out = buf[j];
-        return true;
-      }
-    }
-    i += num_headers_in_buf;
-  }
-  return false;
-}
-
-// There is no particular reason to limit section name to 63 characters,
-// but there has (as yet) been no need for anything longer either.
-const int kMaxSectionNameLen = 64;
-
-// name_len should include terminating '\0'.
-bool GetSectionHeaderByName(int fd, const char *name, size_t name_len,
-                            ElfW(Shdr) *out) {
-  ElfW(Ehdr) elf_header;
-  if (!ReadFromOffsetExact(fd, &elf_header, sizeof(elf_header), 0)) {
-    return false;
-  }
-
-  ElfW(Shdr) shstrtab;
-  off_t shstrtab_offset = (elf_header.e_shoff +
-                           elf_header.e_shentsize * elf_header.e_shstrndx);
-  if (!ReadFromOffsetExact(fd, &shstrtab, sizeof(shstrtab), shstrtab_offset)) {
-    return false;
-  }
-
-  for (int i = 0; i < elf_header.e_shnum; ++i) {
-    off_t section_header_offset = (elf_header.e_shoff +
-                                   elf_header.e_shentsize * i);
-    if (!ReadFromOffsetExact(fd, out, sizeof(*out), section_header_offset)) {
-      return false;
-    }
-    char header_name[kMaxSectionNameLen];
-    if (sizeof(header_name) < name_len) {
-      RAW_LOG(WARNING, "Section name '%s' is too long (%" PRIuS"); "
-              "section will not be found (even if present).", name, name_len);
-      // No point in even trying.
-      return false;
-    }
-    off_t name_offset = shstrtab.sh_offset + out->sh_name;
-    ssize_t n_read = ReadFromOffset(fd, &header_name, name_len, name_offset);
-    if (n_read == -1) {
-      return false;
-    } else if (n_read != name_len) {
-      // Short read -- name could be at end of file.
-      continue;
-    }
-    if (memcmp(header_name, name, name_len) == 0) {
-      return true;
-    }
-  }
-  return false;
-}
-
-// Read a symbol table and look for the symbol containing the
-// pc. Iterate over symbols in a symbol table and look for the symbol
-// containing "pc".  On success, return true and write the symbol name
-// to out.  Otherwise, return false.
-// To keep stack consumption low, we would like this function to not get
-// inlined.
-static ATTRIBUTE_NOINLINE bool
-FindSymbol(uint64_t pc, const int fd, char *out, int out_size,
-           uint64_t symbol_offset, const ElfW(Shdr) *strtab,
-           const ElfW(Shdr) *symtab) {
-  if (symtab == NULL) {
-    return false;
-  }
-  const int num_symbols = symtab->sh_size / symtab->sh_entsize;
-  for (int i = 0; i < num_symbols;) {
-    off_t offset = symtab->sh_offset + i * symtab->sh_entsize;
-
-    // If we are reading Elf64_Sym's, we want to limit this array to
-    // 32 elements (to keep stack consumption low), otherwise we can
-    // have a 64 element Elf32_Sym array.
-#if __WORDSIZE == 64
-#define NUM_SYMBOLS 32
-#else
-#define NUM_SYMBOLS 64
-#endif
-
-    // Read at most NUM_SYMBOLS symbols at once to save read() calls.
-    ElfW(Sym) buf[NUM_SYMBOLS];
-    const ssize_t len = ReadFromOffset(fd, &buf, sizeof(buf), offset);
-    SAFE_ASSERT(len % sizeof(buf[0]) == 0);
-    const ssize_t num_symbols_in_buf = len / sizeof(buf[0]);
-    SAFE_ASSERT(num_symbols_in_buf <= sizeof(buf)/sizeof(buf[0]));
-    for (int j = 0; j < num_symbols_in_buf; ++j) {
-      const ElfW(Sym)& symbol = buf[j];
-      uint64_t start_address = symbol.st_value;
-      start_address += symbol_offset;
-      uint64_t end_address = start_address + symbol.st_size;
-      if (symbol.st_value != 0 &&  // Skip null value symbols.
-          symbol.st_shndx != 0 &&  // Skip undefined symbols.
-          start_address <= pc && pc < end_address) {
-        ssize_t len1 = ReadFromOffset(fd, out, out_size,
-                                      strtab->sh_offset + symbol.st_name);
-        if (len1 <= 0 || memchr(out, '\0', out_size) == NULL) {
-          return false;
-        }
-        return true;  // Obtained the symbol name.
-      }
-    }
-    i += num_symbols_in_buf;
-  }
-  return false;
-}
-
-// Get the symbol name of "pc" from the file pointed by "fd".  Process
-// both regular and dynamic symbol tables if necessary.  On success,
-// write the symbol name to "out" and return true.  Otherwise, return
-// false.
-static bool GetSymbolFromObjectFile(const int fd, uint64_t pc,
-                                    char *out, int out_size,
-                                    uint64_t map_start_address) {
-  // Read the ELF header.
-  ElfW(Ehdr) elf_header;
-  if (!ReadFromOffsetExact(fd, &elf_header, sizeof(elf_header), 0)) {
-    return false;
-  }
-
-  uint64_t symbol_offset = 0;
-  if (elf_header.e_type == ET_DYN) {  // DSO needs offset adjustment.
-    symbol_offset = map_start_address;
-  }
-
-  ElfW(Shdr) symtab, strtab;
-
-  // Consult a regular symbol table first.
-  if (!GetSectionHeaderByType(fd, elf_header.e_shnum, elf_header.e_shoff,
-                              SHT_SYMTAB, &symtab)) {
-    return false;
-  }
-  if (!ReadFromOffsetExact(fd, &strtab, sizeof(strtab), elf_header.e_shoff +
-                           symtab.sh_link * sizeof(symtab))) {
-    return false;
-  }
-  if (FindSymbol(pc, fd, out, out_size, symbol_offset,
-                 &strtab, &symtab)) {
-    return true;  // Found the symbol in a regular symbol table.
-  }
-
-  // If the symbol is not found, then consult a dynamic symbol table.
-  if (!GetSectionHeaderByType(fd, elf_header.e_shnum, elf_header.e_shoff,
-                              SHT_DYNSYM, &symtab)) {
-    return false;
-  }
-  if (!ReadFromOffsetExact(fd, &strtab, sizeof(strtab), elf_header.e_shoff +
-                           symtab.sh_link * sizeof(symtab))) {
-    return false;
-  }
-  if (FindSymbol(pc, fd, out, out_size, symbol_offset,
-                 &strtab, &symtab)) {
-    return true;  // Found the symbol in a dynamic symbol table.
-  }
-
-  return false;
-}
-
-namespace {
-// Thin wrapper around a file descriptor so that the file descriptor
-// gets closed for sure.
-struct FileDescriptor {
-  const int fd_;
-  explicit FileDescriptor(int fd) : fd_(fd) {}
-  ~FileDescriptor() {
-    if (fd_ >= 0) {
-      NO_INTR(close(fd_));
-    }
-  }
-  int get() { return fd_; }
-
- private:
-  explicit FileDescriptor(const FileDescriptor&);
-  void operator=(const FileDescriptor&);
-};
-
-// Helper class for reading lines from file.
-//
-// Note: we don't use ProcMapsIterator since the object is big (it has
-// a 5k array member) and uses async-unsafe functions such as sscanf()
-// and snprintf().
-class LineReader {
- public:
-  explicit LineReader(int fd, char *buf, int buf_len) : fd_(fd),
-    buf_(buf), buf_len_(buf_len), bol_(buf), eol_(buf), eod_(buf) {
-  }
-
-  // Read '\n'-terminated line from file.  On success, modify "bol"
-  // and "eol", then return true.  Otherwise, return false.
-  //
-  // Note: if the last line doesn't end with '\n', the line will be
-  // dropped.  It's an intentional behavior to make the code simple.
-  bool ReadLine(const char **bol, const char **eol) {
-    if (BufferIsEmpty()) {  // First time.
-      const ssize_t num_bytes = ReadPersistent(fd_, buf_, buf_len_);
-      if (num_bytes <= 0) {  // EOF or error.
-        return false;
-      }
-      eod_ = buf_ + num_bytes;
-      bol_ = buf_;
-    } else {
-      bol_ = eol_ + 1;  // Advance to the next line in the buffer.
-      SAFE_ASSERT(bol_ <= eod_);  // "bol_" can point to "eod_".
-      if (!HasCompleteLine()) {
-        const int incomplete_line_length = eod_ - bol_;
-        // Move the trailing incomplete line to the beginning.
-        memmove(buf_, bol_, incomplete_line_length);
-        // Read text from file and append it.
-        char * const append_pos = buf_ + incomplete_line_length;
-        const int capacity_left = buf_len_ - incomplete_line_length;
-        const ssize_t num_bytes = ReadPersistent(fd_, append_pos,
-                                                 capacity_left);
-        if (num_bytes <= 0) {  // EOF or error.
-          return false;
-        }
-        eod_ = append_pos + num_bytes;
-        bol_ = buf_;
-      }
-    }
-    eol_ = FindLineFeed();
-    if (eol_ == NULL) {  // '\n' not found.  Malformed line.
-      return false;
-    }
-    *eol_ = '\0';  // Replace '\n' with '\0'.
-
-    *bol = bol_;
-    *eol = eol_;
-    return true;
-  }
-
-  // Beginning of line.
-  const char *bol() {
-    return bol_;
-  }
-
-  // End of line.
-  const char *eol() {
-    return eol_;
-  }
-
- private:
-  explicit LineReader(const LineReader&);
-  void operator=(const LineReader&);
-
-  char *FindLineFeed() {
-    return reinterpret_cast<char *>(memchr(bol_, '\n', eod_ - bol_));
-  }
-
-  bool BufferIsEmpty() {
-    return buf_ == eod_;
-  }
-
-  bool HasCompleteLine() {
-    return !BufferIsEmpty() && FindLineFeed() != NULL;
-  }
-
-  const int fd_;
-  char * const buf_;
-  const int buf_len_;
-  char *bol_;
-  char *eol_;
-  const char *eod_;  // End of data in "buf_".
-};
-}  // namespace
-
-// Place the hex number read from "start" into "*hex".  The pointer to
-// the first non-hex character or "end" is returned.
-static char *GetHex(const char *start, const char *end, uint64_t *hex) {
-  *hex = 0;
-  const char *p;
-  for (p = start; p < end; ++p) {
-    int ch = *p;
-    if ((ch >= '0' && ch <= '9') ||
-        (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) {
-      *hex = (*hex << 4) | (ch < 'A' ? ch - '0' : (ch & 0xF) + 9);
-    } else {  // Encountered the first non-hex character.
-      break;
-    }
-  }
-  SAFE_ASSERT(p <= end);
-  return const_cast<char *>(p);
-}
-
-// Search for the object file (from /proc/self/maps) that contains
-// the specified pc. If found, open this file and return the file handle,
-// and also set start_address to the start address of where this object
-// file is mapped to in memory. Otherwise, return -1.
-static ATTRIBUTE_NOINLINE int
-OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc,
-                                             uint64_t &start_address) {
-  int object_fd;
-
-  // Open /proc/self/maps.
-  int maps_fd;
-  NO_INTR(maps_fd = open("/proc/self/maps", O_RDONLY));
-  FileDescriptor wrapped_maps_fd(maps_fd);
-  if (wrapped_maps_fd.get() < 0) {
-    return -1;
-  }
-
-  // Iterate over maps and look for the map containing the pc.  Then
-  // look into the symbol tables inside.
-  char buf[1024];  // Big enough for line of sane /proc/self/maps
-  LineReader reader(wrapped_maps_fd.get(), buf, sizeof(buf));
-  while (true) {
-    const char *cursor;
-    const char *eol;
-    if (!reader.ReadLine(&cursor, &eol)) {  // EOF or malformed line.
-      return -1;
-    }
-
-    // Start parsing line in /proc/self/maps.  Here is an example:
-    //
-    // 08048000-0804c000 r-xp 00000000 08:01 2142121    /bin/cat
-    //
-    // We want start address (08048000), end address (0804c000), flags
-    // (r-xp) and file name (/bin/cat).
-
-    // Read start address.
-    cursor = GetHex(cursor, eol, &start_address);
-    if (cursor == eol || *cursor != '-') {
-      return -1;  // Malformed line.
-    }
-    ++cursor;  // Skip '-'.
-
-    // Read end address.
-    uint64_t end_address;
-    cursor = GetHex(cursor, eol, &end_address);
-    if (cursor == eol || *cursor != ' ') {
-      return -1;  // Malformed line.
-    }
-    ++cursor;  // Skip ' '.
-
-    // Check start and end addresses.
-    if (!(start_address <= pc && pc < end_address)) {
-      continue;  // We skip this map.  PC isn't in this map.
-    }
-
-    // Read flags.  Skip flags until we encounter a space or eol.
-    const char * const flags_start = cursor;
-    while (cursor < eol && *cursor != ' ') {
-      ++cursor;
-    }
-    // We expect at least four letters for flags (ex. "r-xp").
-    if (cursor == eol || cursor < flags_start + 4) {
-      return -1;  // Malformed line.
-    }
-
-    // Check flags.  We are only interested in "r-x" maps.
-    if (memcmp(flags_start, "r-x", 3) != 0) {  // Not a "r-x" map.
-      continue;  // We skip this map.
-    }
-    ++cursor;  // Skip ' '.
-
-    // Skip to file name.  "cursor" now points to file offset.  We need to
-    // skip at least three spaces for file offset, dev, and inode.
-    int num_spaces = 0;
-    while (cursor < eol) {
-      if (*cursor == ' ') {
-        ++num_spaces;
-      } else if (num_spaces >= 3) {
-        // The first non-space character after  skipping three spaces
-        // is the beginning of the file name.
-        break;
-      }
-      ++cursor;
-    }
-    if (cursor == eol) {
-      return -1;  // Malformed line.
-    }
-
-    // Finally, "cursor" now points to file name of our interest.
-    NO_INTR(object_fd = open(cursor, O_RDONLY));
-    if (object_fd < 0) {
-      return -1;
-    }
-    return object_fd;
-  }
-}
-
-// The implementation of our symbolization routine.  If it
-// successfully finds the symbol containing "pc" and obtains the
-// symbol name, returns true and write the symbol name to "out".
-// Otherwise, returns false. If Callback function is installed via
-// InstallSymbolizeCallback(), the function is also called in this function,
-// and "out" is used as its output.
-// To keep stack consumption low, we would like this function to not
-// get inlined.
-static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
-                                                    int out_size) {
-  uint64_t pc0 = reinterpret_cast<uintptr_t>(pc);
-  uint64_t start_address = 0;
-
-  int object_fd = OpenObjectFileContainingPcAndGetStartAddress(pc0,
-                                                               start_address);
-  if (object_fd == -1) {
-    return false;
-  }
-  FileDescriptor wrapped_object_fd(object_fd);
-  int elf_type = FileGetElfType(wrapped_object_fd.get());
-  if (elf_type == -1) {
-    return false;
-  }
-  if (g_symbolize_callback) {
-    // Run the call back if it's installed.
-    // Note: relocation (and much of the rest of this code) will be
-    // wrong for prelinked shared libraries and PIE executables.
-    uint64 relocation = (elf_type == ET_DYN) ? start_address : 0;
-    int num_bytes_written = g_symbolize_callback(wrapped_object_fd.get(),
-                                                 pc, out, out_size,
-                                                 relocation);
-    if (num_bytes_written > 0) {
-      out += num_bytes_written;
-      out_size -= num_bytes_written;
-    }
-  }
-  if (!GetSymbolFromObjectFile(wrapped_object_fd.get(), pc0,
-                               out, out_size, start_address)) {
-    return false;
-  }
-
-  // Symbolization succeeded.  Now we try to demangle the symbol.
-  DemangleInplace(out, out_size);
-  return true;
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#elif defined(OS_MACOSX) && defined(HAVE_DLADDR)
-
-#include <dlfcn.h>
-#include <string.h>
-
-_START_GOOGLE_NAMESPACE_
-
-static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
-                                                    int out_size) {
-  Dl_info info;
-  if (dladdr(pc, &info)) {
-    if ((int)strlen(info.dli_sname) < out_size) {
-      strcpy(out, info.dli_sname);
-      // Symbolization succeeded.  Now we try to demangle the symbol.
-      DemangleInplace(out, out_size);
-      return true;
-    }
-  }
-  return false;
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#else
-# error BUG: HAVE_SYMBOLIZE was wrongly set
-#endif
-
-_START_GOOGLE_NAMESPACE_
-
-bool Symbolize(void *pc, char *out, int out_size) {
-  SAFE_ASSERT(out_size >= 0);
-  return SymbolizeAndDemangle(pc, out, out_size);
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#else  /* HAVE_SYMBOLIZE */
-
-#include <assert.h>
-
-#include "config.h"
-
-_START_GOOGLE_NAMESPACE_
-
-// TODO: Support other environments.
-bool Symbolize(void *pc, char *out, int out_size) {
-  assert(0);
-  return false;
-}
-
-_END_GOOGLE_NAMESPACE_
-
-#endif


[03/46] incubator-quickstep git commit: Simplified the work order generation.

Posted by ji...@apache.org.
Simplified the work order generation.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/8d7284de
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/8d7284de
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/8d7284de

Branch: refs/heads/fix-iwyu
Commit: 8d7284decb7ebf5c0eaac232f39027ddd8bf6144
Parents: 77960a4
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Mon Aug 21 19:51:55 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Fri Sep 22 13:43:08 2017 -0500

----------------------------------------------------------------------
 query_execution/CMakeLists.txt                  |   2 -
 query_execution/ForemanDistributed.cpp          |   5 +-
 query_execution/ForemanSingleNode.cpp           |  16 +--
 query_execution/QueryManagerBase.cpp            | 136 ++++++++-----------
 query_execution/QueryManagerBase.hpp            |  79 ++---------
 query_execution/QueryManagerDistributed.cpp     |  54 +++-----
 query_execution/QueryManagerDistributed.hpp     |   3 +-
 query_execution/QueryManagerSingleNode.cpp      |  58 ++++----
 query_execution/QueryManagerSingleNode.hpp      |   7 +-
 query_execution/WorkOrdersContainer.hpp         |   1 +
 .../tests/QueryManagerSingleNode_unittest.cpp   |  58 ++++----
 11 files changed, 152 insertions(+), 267 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8d7284de/query_execution/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_execution/CMakeLists.txt b/query_execution/CMakeLists.txt
index 5c750f0..9394c00 100644
--- a/query_execution/CMakeLists.txt
+++ b/query_execution/CMakeLists.txt
@@ -119,7 +119,6 @@ if (ENABLE_DISTRIBUTED)
                         quickstep_storage_StorageBlockInfo
                         quickstep_storage_StorageManager
                         quickstep_threading_ThreadUtil
-                        quickstep_utility_EqualsAnyConstant
                         quickstep_utility_Macros
                         tmb
                         ${GFLAGS_LIB_NAME})
@@ -135,7 +134,6 @@ target_link_libraries(quickstep_queryexecution_ForemanSingleNode
                       quickstep_queryexecution_WorkerDirectory
                       quickstep_queryexecution_WorkerMessage
                       quickstep_threading_ThreadUtil
-                      quickstep_utility_EqualsAnyConstant
                       quickstep_utility_Macros
                       tmb
                       ${GFLAGS_LIB_NAME})

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8d7284de/query_execution/ForemanDistributed.cpp
----------------------------------------------------------------------
diff --git a/query_execution/ForemanDistributed.cpp b/query_execution/ForemanDistributed.cpp
index 942f383..82cc624 100644
--- a/query_execution/ForemanDistributed.cpp
+++ b/query_execution/ForemanDistributed.cpp
@@ -48,7 +48,6 @@
 #include "storage/StorageBlockInfo.hpp"
 #include "storage/StorageManager.hpp"
 #include "threading/ThreadUtil.hpp"
-#include "utility/EqualsAnyConstant.hpp"
 
 #include "glog/logging.h"
 
@@ -233,9 +232,7 @@ void ForemanDistributed::run() {
 }
 
 bool ForemanDistributed::canCollectNewMessages(const tmb::message_type_id message_type) {
-  return !QUICKSTEP_EQUALS_ANY_CONSTANT(message_type,
-                                        kCatalogRelationNewBlockMessage,
-                                        kWorkOrderFeedbackMessage);
+  return message_type != kCatalogRelationNewBlockMessage;
 }
 
 bool ForemanDistributed::isAggregationRelatedWorkOrder(const S::WorkOrderMessage &proto,

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8d7284de/query_execution/ForemanSingleNode.cpp
----------------------------------------------------------------------
diff --git a/query_execution/ForemanSingleNode.cpp b/query_execution/ForemanSingleNode.cpp
index 1501408..d66f1f5 100644
--- a/query_execution/ForemanSingleNode.cpp
+++ b/query_execution/ForemanSingleNode.cpp
@@ -33,7 +33,6 @@
 #include "query_execution/WorkerDirectory.hpp"
 #include "query_execution/WorkerMessage.hpp"
 #include "threading/ThreadUtil.hpp"
-#include "utility/EqualsAnyConstant.hpp"
 #include "utility/Macros.hpp"
 
 #include "gflags/gflags.h"
@@ -179,18 +178,13 @@ void ForemanSingleNode::run() {
 }
 
 bool ForemanSingleNode::canCollectNewMessages(const tmb::message_type_id message_type) {
-  if (QUICKSTEP_EQUALS_ANY_CONSTANT(message_type,
-                                    kCatalogRelationNewBlockMessage,
-                                    kWorkOrderFeedbackMessage)) {
-    return false;
-  } else if (worker_directory_->getLeastLoadedWorker().second <=
-             FLAGS_min_load_per_worker) {
-    // If the least loaded worker has only one pending work order, we should
-    // collect new messages and dispatch them.
-    return true;
-  } else {
+  if (message_type == kCatalogRelationNewBlockMessage) {
     return false;
   }
+
+  // If the least loaded worker has only one pending work order, we should
+  // collect new messages and dispatch them.
+  return (worker_directory_->getLeastLoadedWorker().second <= FLAGS_min_load_per_worker);
 }
 
 void ForemanSingleNode::dispatchWorkerMessages(const vector<unique_ptr<WorkerMessage>> &messages) {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8d7284de/query_execution/QueryManagerBase.cpp
----------------------------------------------------------------------
diff --git a/query_execution/QueryManagerBase.cpp b/query_execution/QueryManagerBase.cpp
index 565c6ad..374c96d 100644
--- a/query_execution/QueryManagerBase.cpp
+++ b/query_execution/QueryManagerBase.cpp
@@ -50,7 +50,9 @@ QueryManagerBase::QueryManagerBase(QueryHandle *query_handle)
       num_operators_in_dag_(query_dag_->size()),
       output_consumers_(num_operators_in_dag_),
       blocking_dependencies_(num_operators_in_dag_),
-      query_exec_state_(new QueryExecutionState(num_operators_in_dag_)) {
+      query_exec_state_(new QueryExecutionState(num_operators_in_dag_)),
+      blocking_dependents_(num_operators_in_dag_),
+      non_blocking_dependencies_(num_operators_in_dag_) {
   if (FLAGS_visualize_execution_dag) {
     dag_visualizer_ =
         std::make_unique<quickstep::ExecutionDAGVisualizer>(query_handle_->getQueryPlan());
@@ -66,16 +68,22 @@ QueryManagerBase::QueryManagerBase(QueryHandle *query_handle)
       query_exec_state_->setRebuildRequired(node_index);
     }
 
+    if (query_dag_->getDependencies(node_index).empty()) {
+      non_dependent_operators_.push_back(node_index);
+    }
+
     for (const pair<dag_node_index, bool> &dependent_link :
          query_dag_->getDependents(node_index)) {
       const dag_node_index dependent_op_index = dependent_link.first;
       if (query_dag_->getLinkMetadata(node_index, dependent_op_index)) {
         // The link is a pipeline-breaker. Streaming of blocks is not possible
         // between these two operators.
-        blocking_dependencies_[dependent_op_index].push_back(node_index);
+        blocking_dependencies_[dependent_op_index].insert(node_index);
+        blocking_dependents_[node_index].push_back(dependent_op_index);
       } else {
         // The link is not a pipeline-breaker. Streaming of blocks is possible
         // between these two operators.
+        non_blocking_dependencies_[dependent_op_index].insert(node_index);
         output_consumers_[node_index].push_back(dependent_op_index);
       }
     }
@@ -102,6 +110,12 @@ void QueryManagerBase::processFeedbackMessage(
   RelationalOperator *op =
       query_dag_->getNodePayloadMutable(op_index);
   op->receiveFeedbackMessage(msg);
+
+  if (query_exec_state_->hasDoneGenerationWorkOrders(op_index)) {
+    return;
+  }
+
+  fetchNormalWorkOrders(op_index);
 }
 
 void QueryManagerBase::processWorkOrderCompleteMessage(
@@ -109,97 +123,32 @@ void QueryManagerBase::processWorkOrderCompleteMessage(
     const partition_id part_id) {
   query_exec_state_->decrementNumQueuedWorkOrders(op_index);
 
-  // Check if new work orders are available and fetch them if so.
-  fetchNormalWorkOrders(op_index);
+  if (!checkNormalExecutionOver(op_index)) {
+    // Normal execution under progress for this operator.
+    return;
+  }
 
   if (checkRebuildRequired(op_index)) {
-    if (checkNormalExecutionOver(op_index)) {
-      if (!checkRebuildInitiated(op_index)) {
-        if (initiateRebuild(op_index)) {
-          // Rebuild initiated and completed right away.
-          markOperatorFinished(op_index);
-        } else {
-          // Rebuild under progress.
-        }
-      } else if (checkRebuildOver(op_index)) {
-        // Rebuild was under progress and now it is over.
-        markOperatorFinished(op_index);
-      }
-    } else {
-      // Normal execution under progress for this operator.
+    DCHECK(!checkRebuildInitiated(op_index));
+    if (!initiateRebuild(op_index)) {
+      // Rebuild under progress.
+      return;
     }
-  } else if (checkOperatorExecutionOver(op_index)) {
-    // Rebuild not required for this operator and its normal execution is
-    // complete.
-    markOperatorFinished(op_index);
+    // Rebuild initiated and completed right away.
   }
 
-  for (const pair<dag_node_index, bool> &dependent_link :
-       query_dag_->getDependents(op_index)) {
-    const dag_node_index dependent_op_index = dependent_link.first;
-    if (checkAllBlockingDependenciesMet(dependent_op_index)) {
-      // Process the dependent operator (of the operator whose WorkOrder
-      // was just executed) for which all the dependencies have been met.
-      processOperator(dependent_op_index, true);
-    }
-  }
+  markOperatorFinished(op_index);
 }
 
 void QueryManagerBase::processRebuildWorkOrderCompleteMessage(const dag_node_index op_index,
                                                               const partition_id part_id) {
   query_exec_state_->decrementNumRebuildWorkOrders(op_index);
 
-  if (checkRebuildOver(op_index)) {
-    markOperatorFinished(op_index);
-
-    for (const pair<dag_node_index, bool> &dependent_link :
-         query_dag_->getDependents(op_index)) {
-      const dag_node_index dependent_op_index = dependent_link.first;
-      if (checkAllBlockingDependenciesMet(dependent_op_index)) {
-        processOperator(dependent_op_index, true);
-      }
-    }
-  }
-}
-
-void QueryManagerBase::processOperator(const dag_node_index index,
-                                       const bool recursively_check_dependents) {
-  if (fetchNormalWorkOrders(index)) {
-    // Fetched work orders. Return to wait for the generated work orders to
-    // execute, and skip the execution-finished checks.
+  if (!checkRebuildOver(op_index)) {
     return;
   }
 
-  if (checkNormalExecutionOver(index)) {
-    if (checkRebuildRequired(index)) {
-      if (!checkRebuildInitiated(index)) {
-        // Rebuild hasn't started, initiate it.
-        if (initiateRebuild(index)) {
-          // Rebuild initiated and completed right away.
-          markOperatorFinished(index);
-        } else {
-          // Rebuild WorkOrders have been generated.
-          return;
-        }
-      } else if (checkRebuildOver(index)) {
-        // Rebuild had been initiated and it is over.
-        markOperatorFinished(index);
-      }
-    } else {
-      // Rebuild is not required and normal execution over, mark finished.
-      markOperatorFinished(index);
-    }
-    // If we reach here, that means the operator has been marked as finished.
-    if (recursively_check_dependents) {
-      for (const pair<dag_node_index, bool> &dependent_link :
-           query_dag_->getDependents(index)) {
-        const dag_node_index dependent_op_index = dependent_link.first;
-        if (checkAllBlockingDependenciesMet(dependent_op_index)) {
-          processOperator(dependent_op_index, true);
-        }
-      }
-    }
-  }
+  markOperatorFinished(op_index);
 }
 
 void QueryManagerBase::processDataPipelineMessage(const dag_node_index op_index,
@@ -214,23 +163,44 @@ void QueryManagerBase::processDataPipelineMessage(const dag_node_index op_index,
     query_dag_->getNodePayloadMutable(consumer_index)->feedInputBlock(block, rel_id, part_id);
     // Because of the streamed input just fed, check if there are any new
     // WorkOrders available and if so, fetch them.
-    fetchNormalWorkOrders(consumer_index);
+    if (checkAllBlockingDependenciesMet(consumer_index)) {
+      fetchNormalWorkOrders(consumer_index);
+    }
   }
 }
 
 void QueryManagerBase::markOperatorFinished(const dag_node_index index) {
   query_exec_state_->setExecutionFinished(index);
 
+  for (const dag_node_index dependent_op_index : blocking_dependents_[index]) {
+    blocking_dependencies_[dependent_op_index].erase(index);
+  }
+
+  for (const dag_node_index dependent_op_index : output_consumers_[index]) {
+    non_blocking_dependencies_[dependent_op_index].erase(index);
+  }
+
   RelationalOperator *op = query_dag_->getNodePayloadMutable(index);
   op->updateCatalogOnCompletion();
 
   const relation_id output_rel = op->getOutputRelationID();
+
   for (const pair<dag_node_index, bool> &dependent_link : query_dag_->getDependents(index)) {
     const dag_node_index dependent_op_index = dependent_link.first;
-    RelationalOperator *dependent_op = query_dag_->getNodePayloadMutable(dependent_op_index);
-    // Signal dependent operator that current operator is done feeding input blocks.
     if (output_rel >= 0) {
-      dependent_op->doneFeedingInputBlocks(output_rel);
+      // Signal dependent operator that current operator is done feeding input blocks.
+      query_dag_->getNodePayloadMutable(dependent_op_index)->doneFeedingInputBlocks(output_rel);
+    }
+
+    if (checkAllBlockingDependenciesMet(dependent_op_index)) {
+      // Process the dependent operator (of the operator whose WorkOrder
+      // was just executed) for which all the dependencies have been met.
+      if (!fetchNormalWorkOrders(dependent_op_index) &&
+          non_blocking_dependencies_[dependent_op_index].empty() &&
+          checkNormalExecutionOver(dependent_op_index) &&
+          (!checkRebuildRequired(dependent_op_index) || initiateRebuild(dependent_op_index))) {
+        markOperatorFinished(dependent_op_index);
+      }
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8d7284de/query_execution/QueryManagerBase.hpp
----------------------------------------------------------------------
diff --git a/query_execution/QueryManagerBase.hpp b/query_execution/QueryManagerBase.hpp
index 78d67cc..366ab61 100644
--- a/query_execution/QueryManagerBase.hpp
+++ b/query_execution/QueryManagerBase.hpp
@@ -22,6 +22,7 @@
 
 #include <cstddef>
 #include <memory>
+#include <unordered_set>
 #include <vector>
 
 #include "catalog/CatalogTypedefs.hpp"
@@ -165,56 +166,20 @@ class QueryManagerBase {
 
  protected:
   /**
-   * @brief Process a current relational operator: Get its workorders and store
-   *        them in the WorkOrdersContainer for this query. If the operator can
-   *        be marked as done, do so.
-   *
-   * @param index The index of the relational operator to be processed in the
-   *        query plan DAG.
-   * @param recursively_check_dependents If an operator is done, should we
-   *        call processOperator on its dependents recursively.
-   **/
-  void processOperator(const dag_node_index index,
-                       const bool recursively_check_dependents);
-
-  /**
    * @brief This function does the following things:
    *        1. Mark the given relational operator as "done".
-   *        2. For all the dependents of this operator, check if all of their
-   *        blocking dependencies are met. If so inform them that the blocking
-   *        dependencies are met.
-   *        3. Check if the given operator is done producing output. If it's
-   *        done, inform the dependents that they won't receive input anymore
-   *        from the given operator.
+   *        2. For all the dependents of this operator, check if the given
+   *        operator is done producing output. If it's done, inform the
+   *        dependents that they won't receive input anymore from the given
+   *        operator.
+   *        3. Check if all of their blocking dependencies are met. If so
+   *        fetch normal work orders.
    *
    * @param index The index of the given relational operator in the DAG.
    **/
   void markOperatorFinished(const dag_node_index index);
 
   /**
-   * @brief Check if all the dependencies of the node at specified index have
-   *        finished their execution.
-   *
-   * @note This function's true return value is a pre-requisite for calling
-   *       getRebuildWorkOrders()
-   *
-   * @param node_index The index of the specified node in the query DAG.
-   *
-   * @return True if all the dependencies have finished their execution. False
-   *         otherwise.
-   **/
-  inline bool checkAllDependenciesMet(const dag_node_index node_index) const {
-    for (const dag_node_index dependency_index :
-         query_dag_->getDependencies(node_index)) {
-      // If at least one of the dependencies is not met, return false.
-      if (!query_exec_state_->hasExecutionFinished(dependency_index)) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  /**
    * @brief Check if all the blocking dependencies of the node at specified
    *        index have finished their execution.
    *
@@ -229,27 +194,7 @@ class QueryManagerBase {
    **/
   inline bool checkAllBlockingDependenciesMet(
       const dag_node_index node_index) const {
-    for (const dag_node_index blocking_dependency_index :
-         blocking_dependencies_[node_index]) {
-      if (!query_exec_state_->hasExecutionFinished(
-              blocking_dependency_index)) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  /**
-   * @brief Check if the execution of the given operator is over.
-   *
-   * @param index The index of the given operator in the DAG.
-   *
-   * @return True if the execution of the given operator is over, false
-   *         otherwise.
-   **/
-  inline bool checkOperatorExecutionOver(const dag_node_index index) const {
-    return this->checkNormalExecutionOver(index) &&
-           (!checkRebuildRequired(index) || this->checkRebuildOver(index));
+    return blocking_dependencies_[node_index].empty();
   }
 
   /**
@@ -295,7 +240,9 @@ class QueryManagerBase {
   std::vector<std::vector<dag_node_index>> output_consumers_;
 
   // For all nodes, store their pipeline breaking dependencies (if any).
-  std::vector<std::vector<dag_node_index>> blocking_dependencies_;
+  std::vector<std::unordered_set<dag_node_index>> blocking_dependencies_;
+
+  std::vector<dag_node_index> non_dependent_operators_;
 
   std::unique_ptr<QueryExecutionState> query_exec_state_;
 
@@ -338,6 +285,10 @@ class QueryManagerBase {
    **/
   virtual bool checkRebuildOver(const dag_node_index index) const = 0;
 
+  // For all nodes, store their pipeline breaking dependents (if any).
+  std::vector<std::vector<dag_node_index>> blocking_dependents_;
+  std::vector<std::unordered_set<dag_node_index>> non_blocking_dependencies_;
+
   DISALLOW_COPY_AND_ASSIGN(QueryManagerBase);
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8d7284de/query_execution/QueryManagerDistributed.cpp
----------------------------------------------------------------------
diff --git a/query_execution/QueryManagerDistributed.cpp b/query_execution/QueryManagerDistributed.cpp
index 1144e9f..30a1396 100644
--- a/query_execution/QueryManagerDistributed.cpp
+++ b/query_execution/QueryManagerDistributed.cpp
@@ -67,10 +67,11 @@ QueryManagerDistributed::QueryManagerDistributed(QueryHandle *query_handle,
       bus_(bus),
       normal_workorder_protos_container_(
           new WorkOrderProtosContainer(num_operators_in_dag_)) {
-  // Collect all the workorders from all the relational operators in the DAG.
-  for (dag_node_index index = 0; index < num_operators_in_dag_; ++index) {
-    if (checkAllBlockingDependenciesMet(index)) {
-      processOperator(index, false);
+  // Collect all the workorders from all the non-blocking relational operators in the DAG.
+  for (const dag_node_index index : non_dependent_operators_) {
+    if (!fetchNormalWorkOrders(index)) {
+      DCHECK(!checkRebuildRequired(index) || initiateRebuild(index));
+      markOperatorFinished(index);
     }
   }
 
@@ -177,35 +178,22 @@ serialization::WorkOrderMessage* QueryManagerDistributed::getNextWorkOrderMessag
 }
 
 bool QueryManagerDistributed::fetchNormalWorkOrders(const dag_node_index index) {
-  bool generated_new_workorder_protos = false;
-  if (!query_exec_state_->hasDoneGenerationWorkOrders(index)) {
-    // Do not fetch any work units until all blocking dependencies are met.
-    // The releational operator is not aware of blocking dependencies for
-    // uncorrelated scalar queries.
-    if (!checkAllBlockingDependenciesMet(index)) {
-      return false;
-    }
-    const size_t num_pending_workorder_protos_before =
-        normal_workorder_protos_container_->getNumWorkOrderProtos(index);
-    const bool done_generation =
-        query_dag_->getNodePayloadMutable(index)
-            ->getAllWorkOrderProtos(normal_workorder_protos_container_.get());
-    if (done_generation) {
-      query_exec_state_->setDoneGenerationWorkOrders(index);
-    }
-
-    // TODO(shoban): It would be a good check to see if operator is making
-    // useful progress, i.e., the operator either generates work orders to
-    // execute or still has pending work orders executing. However, this will not
-    // work if Foreman polls operators without feeding data. This check can be
-    // enabled, if Foreman is refactored to call getAllWorkOrders() only when
-    // pending work orders are completed or new input blocks feed.
-
-    generated_new_workorder_protos =
-        (num_pending_workorder_protos_before <
-         normal_workorder_protos_container_->getNumWorkOrderProtos(index));
+  // Do not fetch any work units until all blocking dependencies are met.
+  // The releational operator is not aware of blocking dependencies for
+  // uncorrelated scalar queries.
+  DCHECK(checkAllBlockingDependenciesMet(index));
+  DCHECK(!query_exec_state_->hasDoneGenerationWorkOrders(index));
+
+  const size_t num_pending_workorder_protos_before =
+      normal_workorder_protos_container_->getNumWorkOrderProtos(index);
+  const bool done_generation =
+      query_dag_->getNodePayloadMutable(index)
+          ->getAllWorkOrderProtos(normal_workorder_protos_container_.get());
+  if (done_generation) {
+    query_exec_state_->setDoneGenerationWorkOrders(index);
   }
-  return generated_new_workorder_protos;
+
+  return (num_pending_workorder_protos_before < normal_workorder_protos_container_->getNumWorkOrderProtos(index));
 }
 
 void QueryManagerDistributed::processInitiateRebuildResponseMessage(const dag_node_index op_index,
@@ -225,7 +213,7 @@ void QueryManagerDistributed::processInitiateRebuildResponseMessage(const dag_no
        query_dag_->getDependents(op_index)) {
     const dag_node_index dependent_op_index = dependent_link.first;
     if (checkAllBlockingDependenciesMet(dependent_op_index)) {
-      processOperator(dependent_op_index, true);
+      fetchNormalWorkOrders(dependent_op_index);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8d7284de/query_execution/QueryManagerDistributed.hpp
----------------------------------------------------------------------
diff --git a/query_execution/QueryManagerDistributed.hpp b/query_execution/QueryManagerDistributed.hpp
index a021fdd..8d870c6 100644
--- a/query_execution/QueryManagerDistributed.hpp
+++ b/query_execution/QueryManagerDistributed.hpp
@@ -250,8 +250,7 @@ class QueryManagerDistributed final : public QueryManagerBase {
 
  private:
   bool checkNormalExecutionOver(const dag_node_index index) const override {
-    return (checkAllDependenciesMet(index) &&
-            !normal_workorder_protos_container_->hasWorkOrderProto(index) &&
+    return (!normal_workorder_protos_container_->hasWorkOrderProto(index) &&
             query_exec_state_->getNumQueuedWorkOrders(index) == 0 &&
             query_exec_state_->hasDoneGenerationWorkOrders(index));
   }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8d7284de/query_execution/QueryManagerSingleNode.cpp
----------------------------------------------------------------------
diff --git a/query_execution/QueryManagerSingleNode.cpp b/query_execution/QueryManagerSingleNode.cpp
index 82a0de6..2c9f673 100644
--- a/query_execution/QueryManagerSingleNode.cpp
+++ b/query_execution/QueryManagerSingleNode.cpp
@@ -61,10 +61,11 @@ QueryManagerSingleNode::QueryManagerSingleNode(
       workorders_container_(
           new WorkOrdersContainer(num_operators_in_dag_, num_numa_nodes)),
       database_(static_cast<const CatalogDatabase&>(*catalog_database)) {
-  // Collect all the workorders from all the relational operators in the DAG.
-  for (dag_node_index index = 0; index < num_operators_in_dag_; ++index) {
-    if (checkAllBlockingDependenciesMet(index)) {
-      processOperator(index, false);
+  // Collect all the workorders from all the non-blocking relational operators in the DAG.
+  for (const dag_node_index index : non_dependent_operators_) {
+    if (!fetchNormalWorkOrders(index)) {
+      DCHECK(!checkRebuildRequired(index) || initiateRebuild(index));
+      markOperatorFinished(index);
     }
   }
 }
@@ -87,38 +88,25 @@ WorkerMessage* QueryManagerSingleNode::getNextWorkerMessage(
 }
 
 bool QueryManagerSingleNode::fetchNormalWorkOrders(const dag_node_index index) {
-  bool generated_new_workorders = false;
-  if (!query_exec_state_->hasDoneGenerationWorkOrders(index)) {
-    // Do not fetch any work units until all blocking dependencies are met.
-    // The releational operator is not aware of blocking dependencies for
-    // uncorrelated scalar queries.
-    if (!checkAllBlockingDependenciesMet(index)) {
-      return false;
-    }
-    const size_t num_pending_workorders_before =
-        workorders_container_->getNumNormalWorkOrders(index);
-    const bool done_generation =
-        query_dag_->getNodePayloadMutable(index)->getAllWorkOrders(workorders_container_.get(),
-                                                                   query_context_.get(),
-                                                                   storage_manager_,
-                                                                   foreman_client_id_,
-                                                                   bus_);
-    if (done_generation) {
-      query_exec_state_->setDoneGenerationWorkOrders(index);
-    }
-
-    // TODO(shoban): It would be a good check to see if operator is making
-    // useful progress, i.e., the operator either generates work orders to
-    // execute or still has pending work orders executing. However, this will not
-    // work if Foreman polls operators without feeding data. This check can be
-    // enabled, if Foreman is refactored to call getAllWorkOrders() only when
-    // pending work orders are completed or new input blocks feed.
-
-    generated_new_workorders =
-        (num_pending_workorders_before <
-         workorders_container_->getNumNormalWorkOrders(index));
+  // Do not fetch any work units until all blocking dependencies are met.
+  // The releational operator is not aware of blocking dependencies for
+  // uncorrelated scalar queries.
+  DCHECK(checkAllBlockingDependenciesMet(index));
+  DCHECK(!query_exec_state_->hasDoneGenerationWorkOrders(index));
+
+  const size_t num_pending_workorders_before =
+      workorders_container_->getNumNormalWorkOrders(index);
+  const bool done_generation =
+      query_dag_->getNodePayloadMutable(index)->getAllWorkOrders(workorders_container_.get(),
+                                                                 query_context_.get(),
+                                                                 storage_manager_,
+                                                                 foreman_client_id_,
+                                                                 bus_);
+  if (done_generation) {
+    query_exec_state_->setDoneGenerationWorkOrders(index);
   }
-  return generated_new_workorders;
+
+  return (num_pending_workorders_before < workorders_container_->getNumNormalWorkOrders(index));
 }
 
 bool QueryManagerSingleNode::initiateRebuild(const dag_node_index index) {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8d7284de/query_execution/QueryManagerSingleNode.hpp
----------------------------------------------------------------------
diff --git a/query_execution/QueryManagerSingleNode.hpp b/query_execution/QueryManagerSingleNode.hpp
index f9d038b..a726bbc 100644
--- a/query_execution/QueryManagerSingleNode.hpp
+++ b/query_execution/QueryManagerSingleNode.hpp
@@ -99,8 +99,7 @@ class QueryManagerSingleNode final : public QueryManagerBase {
 
  private:
   bool checkNormalExecutionOver(const dag_node_index index) const override {
-    return (checkAllDependenciesMet(index) &&
-            !workorders_container_->hasNormalWorkOrder(index) &&
+    return (!workorders_container_->hasNormalWorkOrder(index) &&
             query_exec_state_->getNumQueuedWorkOrders(index) == 0 &&
             query_exec_state_->hasDoneGenerationWorkOrders(index));
   }
@@ -108,8 +107,8 @@ class QueryManagerSingleNode final : public QueryManagerBase {
   bool initiateRebuild(const dag_node_index index) override;
 
   bool checkRebuildOver(const dag_node_index index) const override {
-    return query_exec_state_->hasRebuildInitiated(index) &&
-           !workorders_container_->hasRebuildWorkOrder(index) &&
+    DCHECK(query_exec_state_->hasRebuildInitiated(index));
+    return !workorders_container_->hasRebuildWorkOrder(index) &&
            (query_exec_state_->getNumRebuildWorkOrders(index) == 0);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8d7284de/query_execution/WorkOrdersContainer.hpp
----------------------------------------------------------------------
diff --git a/query_execution/WorkOrdersContainer.hpp b/query_execution/WorkOrdersContainer.hpp
index e8d5ff8..3c2d9bf 100644
--- a/query_execution/WorkOrdersContainer.hpp
+++ b/query_execution/WorkOrdersContainer.hpp
@@ -542,6 +542,7 @@ class WorkOrdersContainer {
 
   DISALLOW_COPY_AND_ASSIGN(WorkOrdersContainer);
 };
+
 /** @} */
 
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/8d7284de/query_execution/tests/QueryManagerSingleNode_unittest.cpp
----------------------------------------------------------------------
diff --git a/query_execution/tests/QueryManagerSingleNode_unittest.cpp b/query_execution/tests/QueryManagerSingleNode_unittest.cpp
index 19b42ac..dd3f472 100644
--- a/query_execution/tests/QueryManagerSingleNode_unittest.cpp
+++ b/query_execution/tests/QueryManagerSingleNode_unittest.cpp
@@ -353,14 +353,14 @@ TEST_F(QueryManagerTest, SingleNodeDAGDynamicWorkOrdersTest) {
   // This test creates a DAG of a single node. WorkOrders are generated
   // dynamically as pending work orders complete execution, i.e.,
   // getAllWorkOrders() is called multiple times.  getAllWorkOrders() will be
-  // called 5 times and 3 work orders will be returned, i.e., 1st 3 calls to
-  // getAllWorkOrders() insert 1 WorkOrder and return false, and the next will
-  // insert no WorkOrder and return true.
+  // called 3 times and 3 work orders will be returned, i.e., 2 calls to
+  // getAllWorkOrders() insert 2 WorkOrder and return false, and the last will
+  // insert 1 WorkOrder and return true.
 
   // TODO(shoban): This test can not be more robust than this because of fixed
   // scaffolding of mocking. If we use gMock, we can do much better.
   const QueryPlan::DAGNodeIndex id =
-      query_plan_->addRelationalOperator(new MockOperator(true, false, 4, 3));
+      query_plan_->addRelationalOperator(new MockOperator(true, false, 3, 3));
 
   const MockOperator &op = static_cast<const MockOperator &>(
       query_plan_->getQueryPlanDAG().getNodePayload(id));
@@ -378,7 +378,7 @@ TEST_F(QueryManagerTest, SingleNodeDAGDynamicWorkOrdersTest) {
     unique_ptr<WorkerMessage> worker_message;
     worker_message.reset(query_manager_->getNextWorkerMessage(id, -1));
 
-    EXPECT_TRUE(worker_message != nullptr);
+    ASSERT_TRUE(worker_message != nullptr);
     EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
               worker_message->getType());
     EXPECT_EQ(id, worker_message->getRelationalOpIndex());
@@ -391,6 +391,7 @@ TEST_F(QueryManagerTest, SingleNodeDAGDynamicWorkOrdersTest) {
     if (i < 2) {
       // Send a message to QueryManager upon workorder completion.
       EXPECT_FALSE(placeWorkOrderCompleteMessage(id));
+      query_manager_->fetchNormalWorkOrders(id);
     } else {
       // Send a message to QueryManager upon workorder completion.
       // Last event.
@@ -511,7 +512,7 @@ TEST_F(QueryManagerTest, TwoNodesDAGPipeLinkTest) {
   const QueryPlan::DAGNodeIndex id1 =
       query_plan_->addRelationalOperator(new MockOperator(true, false, 1));
   const QueryPlan::DAGNodeIndex id2 =
-      query_plan_->addRelationalOperator(new MockOperator(true, true, 3));
+      query_plan_->addRelationalOperator(new MockOperator(true, true, 2));
 
   // Create a non-blocking link.
   query_plan_->addDirectDependency(id2, id1, false);
@@ -531,7 +532,7 @@ TEST_F(QueryManagerTest, TwoNodesDAGPipeLinkTest) {
   EXPECT_EQ(1, op1.getNumWorkOrders());
   EXPECT_EQ(0, op1.getNumCalls(MockOperator::kFeedInputBlock));
 
-  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(0, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
   // op2 will generate workorder only after receiving a streaming input.
   EXPECT_EQ(0, op2.getNumWorkOrders());
   EXPECT_EQ(0, op2.getNumCalls(MockOperator::kFeedInputBlock));
@@ -562,7 +563,7 @@ TEST_F(QueryManagerTest, TwoNodesDAGPipeLinkTest) {
   EXPECT_EQ(1, op2.getNumCalls(MockOperator::kFeedInputBlock));
 
   // A call to op2's getAllWorkOrders because of the streamed input.
-  EXPECT_EQ(2, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
   EXPECT_EQ(1, op2.getNumWorkOrders());
 
   // Place a message of a workorder completion of op1 on Foreman's input queue.
@@ -573,7 +574,7 @@ TEST_F(QueryManagerTest, TwoNodesDAGPipeLinkTest) {
   EXPECT_EQ(1, op2.getNumCalls(MockOperator::kDoneFeedingInputBlocks));
 
   // An additional call to op2's getAllWorkOrders because of completion of op1.
-  EXPECT_EQ(3, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(2, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
   EXPECT_EQ(2, op2.getNumWorkOrders());
 
   worker_message.reset(query_manager_->getNextWorkerMessage(id2, -1));
@@ -620,7 +621,7 @@ TEST_F(QueryManagerTest, TwoNodesDAGPartiallyFilledBlocksTest) {
   const QueryPlan::DAGNodeIndex id1 =
       query_plan_->addRelationalOperator(new MockOperator(true, false, 1));
   const QueryPlan::DAGNodeIndex id2 =
-      query_plan_->addRelationalOperator(new MockOperator(true, true, 3, 1));
+      query_plan_->addRelationalOperator(new MockOperator(true, true, 2, 1));
 
   // Create a non-blocking link.
   query_plan_->addDirectDependency(id2, id1, false);
@@ -670,7 +671,7 @@ TEST_F(QueryManagerTest, TwoNodesDAGPartiallyFilledBlocksTest) {
   EXPECT_EQ(1, op1.getNumCalls(MockOperator::kGetAllWorkOrders));
   EXPECT_EQ(1, op1.getNumWorkOrders());
 
-  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(0, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
   EXPECT_EQ(0, op2.getNumWorkOrders());
 
   unique_ptr<WorkerMessage> worker_message;
@@ -704,7 +705,7 @@ TEST_F(QueryManagerTest, TwoNodesDAGPartiallyFilledBlocksTest) {
   EXPECT_FALSE(placeRebuildWorkOrderCompleteMessage(id1));
   // Based on the streamed input, op2's getAllWorkOrders should produce a
   // workorder.
-  EXPECT_EQ(3, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(2, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
   EXPECT_EQ(1, op2.getNumWorkOrders());
 
   worker_message.reset(query_manager_->getNextWorkerMessage(id2, -1));
@@ -734,16 +735,14 @@ TEST_F(QueryManagerTest, MultipleNodesNoOutputTest) {
   // When an operator produces workorders but no output, the QueryManager should
   // check the dependents of this operator to make progress.
   const QueryPlan::DAGNodeIndex kNumNodes = 5;
-  std::vector<QueryPlan::DAGNodeIndex> ids;
-  ids.reserve(kNumNodes);
 
   for (QueryPlan::DAGNodeIndex i = 0; i < kNumNodes; ++i) {
     if (i == 0) {
-      ids[i] = query_plan_->addRelationalOperator(new MockOperator(true, false));
+      query_plan_->addRelationalOperator(new MockOperator(true, false));
     } else {
-      ids[i] = query_plan_->addRelationalOperator(new MockOperator(true, true));
+      query_plan_->addRelationalOperator(new MockOperator(true, true));
     }
-    VLOG(3) << ids[i];
+    VLOG(3) << i;
   }
 
   /**
@@ -753,46 +752,47 @@ TEST_F(QueryManagerTest, MultipleNodesNoOutputTest) {
    *
    **/
   for (QueryPlan::DAGNodeIndex i = 0; i < kNumNodes - 1; ++i) {
-    query_plan_->addDirectDependency(ids[i + 1], ids[i], false);
-    static_cast<MockOperator*>(query_plan_->getQueryPlanDAGMutable()->getNodePayloadMutable(ids[i]))
+    query_plan_->addDirectDependency(i + 1, i, false);
+    static_cast<MockOperator*>(query_plan_->getQueryPlanDAGMutable()->getNodePayloadMutable(i))
         ->setOutputRelationID(0xdead);
   }
 
   std::vector<const MockOperator*> operators;
   for (QueryPlan::DAGNodeIndex i = 0; i < kNumNodes; ++i) {
-    operators.push_back(static_cast<const MockOperator*>(&query_plan_->getQueryPlanDAG().getNodePayload(ids[i])));
+    operators.push_back(static_cast<const MockOperator*>(&query_plan_->getQueryPlanDAG().getNodePayload(i)));
   }
 
   constructQueryManager();
 
   // operators[0] should have produced a workorder by now.
+  EXPECT_EQ(1, operators[0]->getNumCalls(MockOperator::kGetAllWorkOrders));
   EXPECT_EQ(1, operators[0]->getNumWorkOrders());
 
   unique_ptr<WorkerMessage> worker_message;
-  worker_message.reset(query_manager_->getNextWorkerMessage(ids[0], -1));
+  worker_message.reset(query_manager_->getNextWorkerMessage(0, -1));
 
   EXPECT_TRUE(worker_message != nullptr);
   EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
             worker_message->getType());
 
-  EXPECT_EQ(ids[0], worker_message->getRelationalOpIndex());
+  EXPECT_EQ(0, worker_message->getRelationalOpIndex());
 
   delete worker_message->getWorkOrder();
 
-  EXPECT_EQ(1, getNumWorkOrdersInExecution(ids[0]));
-  EXPECT_FALSE(getOperatorFinishedStatus(ids[0]));
+  EXPECT_EQ(1, getNumWorkOrdersInExecution(0));
+  EXPECT_FALSE(getOperatorFinishedStatus(0));
 
-  for (QueryPlan::DAGNodeIndex i = 0; i < kNumNodes; ++i) {
-    EXPECT_EQ(1, operators[ids[i]]->getNumCalls(MockOperator::kGetAllWorkOrders));
+  for (QueryPlan::DAGNodeIndex i = 1; i < kNumNodes; ++i) {
+    EXPECT_EQ(0, operators[i]->getNumCalls(MockOperator::kGetAllWorkOrders));
   }
 
   // Send a message to QueryManager upon workorder (generated by operators[0])
   // completion.
-  EXPECT_TRUE(placeWorkOrderCompleteMessage(ids[0]));
+  EXPECT_TRUE(placeWorkOrderCompleteMessage(0));
 
   for (QueryPlan::DAGNodeIndex i = 0; i < kNumNodes; ++i) {
-    EXPECT_EQ(0, getNumWorkOrdersInExecution(ids[i]));
-    EXPECT_TRUE(getOperatorFinishedStatus(ids[i]));
+    EXPECT_EQ(0, getNumWorkOrdersInExecution(i));
+    EXPECT_TRUE(getOperatorFinishedStatus(i));
     if (i < kNumNodes - 1) {
       EXPECT_EQ(1, operators[i + 1]->getNumCalls(MockOperator::kDoneFeedingInputBlocks));
     }



[24/46] incubator-quickstep git commit: Fix number of work orders generated for insert multiple tuples. (Also added unit tests)

Posted by ji...@apache.org.
Fix number of work orders generated for insert multiple tuples. (Also added unit tests)


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/3595bc1f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/3595bc1f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/3595bc1f

Branch: refs/heads/fix-iwyu
Commit: 3595bc1fdd55bf3979b5a7e98e2263f5bf420406
Parents: b237969
Author: Robert Claus <ro...@gmail.com>
Authored: Fri Nov 3 15:11:11 2017 -0500
Committer: Robert Claus <ro...@gmail.com>
Committed: Mon Nov 20 14:30:17 2017 -0600

----------------------------------------------------------------------
 query_execution/QueryContext.hpp                |  16 +++
 query_optimizer/ExecutionGenerator.cpp          | 105 ++++++++++---------
 .../tests/execution_generator/Insert.test       |  15 +++
 query_optimizer/tests/resolver/Insert.test      |  29 +++++
 relational_operators/InsertOperator.cpp         |  18 +++-
 relational_operators/InsertOperator.hpp         |  13 +--
 relational_operators/WorkOrder.proto            |   2 +-
 relational_operators/WorkOrderFactory.cpp       |  28 ++++-
 8 files changed, 160 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3595bc1f/query_execution/QueryContext.hpp
----------------------------------------------------------------------
diff --git a/query_execution/QueryContext.hpp b/query_execution/QueryContext.hpp
index 7876821..e65f096 100644
--- a/query_execution/QueryContext.hpp
+++ b/query_execution/QueryContext.hpp
@@ -489,6 +489,22 @@ class QueryContext {
   }
 
   /**
+   * @brief Whether the given vector of Tuple ids is valid.
+   *
+   * @param ids The vector of Tuple ids.
+   *
+   * @return True if valid, otherwise false.
+   **/
+  bool areValidTupleIds(const std::vector<tuple_id> &ids) const {
+    for (const tuple_id id : ids) {
+      if (id >= tuples_.size()) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  /**
    * @brief Release the ownership of the Tuple referenced by the id.
    *
    * @note Each id should use only once.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3595bc1f/query_optimizer/ExecutionGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp
index 14d8949..b0d3c48 100644
--- a/query_optimizer/ExecutionGenerator.cpp
+++ b/query_optimizer/ExecutionGenerator.cpp
@@ -1461,72 +1461,75 @@ void ExecutionGenerator::convertInsertTuple(
       *catalog_database_->getRelationById(
           input_relation_info->relation->getID());
 
+
+  // Construct the tuple proto to be inserted.
+  std::vector<QueryContext::tuple_id> tuple_indexes;
+
   for (const std::vector<expressions::ScalarLiteralPtr> &tuple : physical_plan->column_values()) {
-    // Construct the tuple proto to be inserted.
     const QueryContext::tuple_id tuple_index = query_context_proto_->tuples_size();
-
     S::Tuple *tuple_proto = query_context_proto_->add_tuples();
     for (const E::ScalarLiteralPtr &literal : tuple) {
       tuple_proto->add_attribute_values()->CopyFrom(literal->value().getProto());
     }
+    tuple_indexes.push_back(tuple_index);
+  }
 
-    // FIXME(qzeng): A better way is using a traits struct to look up whether a storage
-    //               block supports ad-hoc insertion instead of hard-coding the block types.
-    const StorageBlockLayout &storage_block_layout =
-        input_relation.getDefaultStorageBlockLayout();
-    if (storage_block_layout.getDescription().tuple_store_description().sub_block_type() ==
-        TupleStorageSubBlockDescription::COMPRESSED_COLUMN_STORE ||
-        storage_block_layout.getDescription().tuple_store_description().sub_block_type() ==
-              TupleStorageSubBlockDescription::COMPRESSED_PACKED_ROW_STORE) {
-      THROW_SQL_ERROR() << "INSERT statement is not supported for the relation "
-                        << input_relation.getName()
-                        << ", because its storage blocks do not support ad-hoc insertion";
-    }
+  // FIXME(qzeng): A better way is using a traits struct to look up whether a storage
+  //               block supports ad-hoc insertion instead of hard-coding the block types.
+  const StorageBlockLayout &storage_block_layout =
+      input_relation.getDefaultStorageBlockLayout();
+  if (storage_block_layout.getDescription().tuple_store_description().sub_block_type() ==
+      TupleStorageSubBlockDescription::COMPRESSED_COLUMN_STORE ||
+      storage_block_layout.getDescription().tuple_store_description().sub_block_type() ==
+            TupleStorageSubBlockDescription::COMPRESSED_PACKED_ROW_STORE) {
+    THROW_SQL_ERROR() << "INSERT statement is not supported for the relation "
+                      << input_relation.getName()
+                      << ", because its storage blocks do not support ad-hoc insertion";
+  }
 
-    // Create InsertDestination proto.
-    const QueryContext::insert_destination_id insert_destination_index =
-        query_context_proto_->insert_destinations_size();
-    S::InsertDestination *insert_destination_proto = query_context_proto_->add_insert_destinations();
+  // Create InsertDestination proto.
+  const QueryContext::insert_destination_id insert_destination_index =
+      query_context_proto_->insert_destinations_size();
+  S::InsertDestination *insert_destination_proto = query_context_proto_->add_insert_destinations();
 
-    insert_destination_proto->set_relation_id(input_relation.getID());
-    insert_destination_proto->mutable_layout()->MergeFrom(
-        input_relation.getDefaultStorageBlockLayout().getDescription());
+  insert_destination_proto->set_relation_id(input_relation.getID());
+  insert_destination_proto->mutable_layout()->MergeFrom(
+      input_relation.getDefaultStorageBlockLayout().getDescription());
 
-    if (input_relation.hasPartitionScheme()) {
-      insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::PARTITION_AWARE);
-      insert_destination_proto->MutableExtension(S::PartitionAwareInsertDestination::partition_scheme)
-          ->MergeFrom(input_relation.getPartitionScheme()->getProto());
-    } else {
-      insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::BLOCK_POOL);
+  if (input_relation.hasPartitionScheme()) {
+    insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::PARTITION_AWARE);
+    insert_destination_proto->MutableExtension(S::PartitionAwareInsertDestination::partition_scheme)
+        ->MergeFrom(input_relation.getPartitionScheme()->getProto());
+  } else {
+    insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::BLOCK_POOL);
 
-      const vector<block_id> blocks(input_relation.getBlocksSnapshot());
-      for (const block_id block : blocks) {
-        insert_destination_proto->AddExtension(S::BlockPoolInsertDestination::blocks, block);
-      }
+    const vector<block_id> blocks(input_relation.getBlocksSnapshot());
+    for (const block_id block : blocks) {
+      insert_destination_proto->AddExtension(S::BlockPoolInsertDestination::blocks, block);
     }
+  }
 
-    const QueryPlan::DAGNodeIndex insert_operator_index =
-        execution_plan_->addRelationalOperator(
-            new InsertOperator(query_handle_->query_id(),
-                               input_relation,
-                               insert_destination_index,
-                               tuple_index));
-    insert_destination_proto->set_relational_op_index(insert_operator_index);
+  const QueryPlan::DAGNodeIndex insert_operator_index =
+      execution_plan_->addRelationalOperator(
+          new InsertOperator(query_handle_->query_id(),
+                             input_relation,
+                             insert_destination_index,
+                             tuple_indexes));
+  insert_destination_proto->set_relational_op_index(insert_operator_index);
 
-    CatalogRelation *mutable_relation =
-        catalog_database_->getRelationByIdMutable(input_relation.getID());
-    const QueryPlan::DAGNodeIndex save_blocks_index =
-        execution_plan_->addRelationalOperator(
-            new SaveBlocksOperator(query_handle_->query_id(), mutable_relation));
-    if (!input_relation_info->isStoredRelation()) {
-      execution_plan_->addDirectDependency(insert_operator_index,
-                                           input_relation_info->producer_operator_index,
-                                           true /* is_pipeline_breaker */);
-    }
-    execution_plan_->addDirectDependency(save_blocks_index,
-                                         insert_operator_index,
-                                         false /* is_pipeline_breaker */);
+  CatalogRelation *mutable_relation =
+      catalog_database_->getRelationByIdMutable(input_relation.getID());
+  const QueryPlan::DAGNodeIndex save_blocks_index =
+      execution_plan_->addRelationalOperator(
+          new SaveBlocksOperator(query_handle_->query_id(), mutable_relation));
+  if (!input_relation_info->isStoredRelation()) {
+    execution_plan_->addDirectDependency(insert_operator_index,
+                                         input_relation_info->producer_operator_index,
+                                         true /* is_pipeline_breaker */);
   }
+  execution_plan_->addDirectDependency(save_blocks_index,
+                                       insert_operator_index,
+                                       false /* is_pipeline_breaker */);
 }
 
 void ExecutionGenerator::convertInsertSelection(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3595bc1f/query_optimizer/tests/execution_generator/Insert.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/execution_generator/Insert.test b/query_optimizer/tests/execution_generator/Insert.test
index 1be7be9..8131fb2 100644
--- a/query_optimizer/tests/execution_generator/Insert.test
+++ b/query_optimizer/tests/execution_generator/Insert.test
@@ -132,3 +132,18 @@ SELECT * FROM bar4;
 |          5|                      2016-01-01T00:00:00|                    NULL|                             abc|
 +-----------+-----------------------------------------+------------------------+--------------------------------+
 ==
+
+CREATE TABLE bar5 (x INT NULL, y INT);
+
+INSERT INTO bar5 VALUES (1,2),(3,4),(5,6);
+
+SELECT * FROM bar5;
+--
++-----------+-----------+
+|x          |y          |
++-----------+-----------+
+|          1|          2|
+|          3|          4|
+|          5|          6|
++-----------+-----------+
+==

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3595bc1f/query_optimizer/tests/resolver/Insert.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/resolver/Insert.test b/query_optimizer/tests/resolver/Insert.test
index 88fff53..f21ce5c 100644
--- a/query_optimizer/tests/resolver/Insert.test
+++ b/query_optimizer/tests/resolver/Insert.test
@@ -153,3 +153,32 @@ insert into undefined_table values (1, 2)
 ERROR: Unrecognized relation undefined_table (1 : 13)
 insert into undefined_table values (1, 2)
             ^
+==
+
+insert into test values (null, 1, 2, 3, 'foo', 'foo'),(null, 4, 5, 6, 'foo', 'foo');
+--
+TopLevelPlan
++-plan=InsertTuple
+| +-input=TableReference[relation_name=Test,relation_alias=test]
+| | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
+| +-column_values=
+| | +-Literal[value=NULL,type=Int NULL]
+| | +-Literal[value=1,type=Long]
+| | +-Literal[value=2,type=Float]
+| | +-Literal[value=3,type=Double NULL]
+| | +-Literal[value=foo,type=Char(20)]
+| | +-Literal[value=foo,type=VarChar(20) NULL]
+| +-column_values=
+|   +-Literal[value=NULL,type=Int NULL]
+|   +-Literal[value=4,type=Long]
+|   +-Literal[value=5,type=Float]
+|   +-Literal[value=6,type=Double NULL]
+|   +-Literal[value=foo,type=Char(20)]
+|   +-Literal[value=foo,type=VarChar(20) NULL]
++-output_attributes=
+  +-[]

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3595bc1f/relational_operators/InsertOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/InsertOperator.cpp b/relational_operators/InsertOperator.cpp
index fbd3a07..b8c9f07 100644
--- a/relational_operators/InsertOperator.cpp
+++ b/relational_operators/InsertOperator.cpp
@@ -20,6 +20,7 @@
 #include "relational_operators/InsertOperator.hpp"
 
 #include <memory>
+#include <vector>
 
 #include "query_execution/QueryContext.hpp"
 #include "query_execution/WorkOrderProtosContainer.hpp"
@@ -43,12 +44,19 @@ bool InsertOperator::getAllWorkOrders(
     return true;
   }
 
+  std::vector<std::unique_ptr<Tuple>> tuples;
+
+  for (const QueryContext::tuple_id tuple_index : tuple_indexes_) {
+    std::unique_ptr<Tuple> newTuple(query_context->releaseTuple(tuple_index));
+    tuples.push_back(std::move(newTuple));
+  }
+
   DCHECK(query_context != nullptr);
   container->addNormalWorkOrder(
       new InsertWorkOrder(
           query_id_,
           query_context->getInsertDestination(output_destination_index_),
-          query_context->releaseTuple(tuple_index_)),
+          std::move(tuples)),
       op_index_);
 
   work_generated_ = true;
@@ -64,7 +72,9 @@ bool InsertOperator::getAllWorkOrderProtos(WorkOrderProtosContainer *container)
   proto->set_work_order_type(serialization::INSERT);
   proto->set_query_id(query_id_);
   proto->SetExtension(serialization::InsertWorkOrder::insert_destination_index, output_destination_index_);
-  proto->SetExtension(serialization::InsertWorkOrder::tuple_index, tuple_index_);
+  for (const QueryContext::tuple_id tuple_index : tuple_indexes_) {
+    proto->AddExtension(serialization::InsertWorkOrder::tuple_indexes, tuple_index);
+  }
 
   container->addWorkOrderProto(proto, op_index_);
 
@@ -74,7 +84,9 @@ bool InsertOperator::getAllWorkOrderProtos(WorkOrderProtosContainer *container)
 
 
 void InsertWorkOrder::execute() {
-  output_destination_->insertTuple(*tuple_);
+  for (const auto &tuple : tuples_) {
+    output_destination_->insertTuple(*tuple);
+  }
 }
 
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3595bc1f/relational_operators/InsertOperator.hpp
----------------------------------------------------------------------
diff --git a/relational_operators/InsertOperator.hpp b/relational_operators/InsertOperator.hpp
index b103538..3865a7f 100644
--- a/relational_operators/InsertOperator.hpp
+++ b/relational_operators/InsertOperator.hpp
@@ -23,6 +23,7 @@
 #include <cstddef>
 #include <string>
 #include <memory>
+#include <vector>
 
 #include "catalog/CatalogRelation.hpp"
 #include "catalog/CatalogTypedefs.hpp"
@@ -67,11 +68,11 @@ class InsertOperator : public RelationalOperator {
       const std::size_t query_id,
       const CatalogRelation &output_relation,
       const QueryContext::insert_destination_id output_destination_index,
-      const QueryContext::tuple_id tuple_index)
+      const std::vector<QueryContext::tuple_id> &tuple_indexes)
       : RelationalOperator(query_id, 1u, false, output_relation.getNumPartitions()),
         output_relation_(output_relation),
         output_destination_index_(output_destination_index),
-        tuple_index_(tuple_index),
+        tuple_indexes_(tuple_indexes),
         work_generated_(false) {}
 
   ~InsertOperator() override {}
@@ -103,7 +104,7 @@ class InsertOperator : public RelationalOperator {
  private:
   const CatalogRelation &output_relation_;
   const QueryContext::insert_destination_id output_destination_index_;
-  const QueryContext::tuple_id tuple_index_;
+  const std::vector<QueryContext::tuple_id> tuple_indexes_;
   bool work_generated_;
 
   DISALLOW_COPY_AND_ASSIGN(InsertOperator);
@@ -125,10 +126,10 @@ class InsertWorkOrder : public WorkOrder {
    **/
   InsertWorkOrder(const std::size_t query_id,
                   InsertDestination *output_destination,
-                  Tuple *tuple)
+                  std::vector<std::unique_ptr<Tuple>> &&tuples)
       : WorkOrder(query_id),
         output_destination_(DCHECK_NOTNULL(output_destination)),
-        tuple_(DCHECK_NOTNULL(tuple)) {}
+        tuples_(std::move(tuples)) {}
 
   ~InsertWorkOrder() override {}
 
@@ -140,7 +141,7 @@ class InsertWorkOrder : public WorkOrder {
 
  private:
   InsertDestination *output_destination_;
-  std::unique_ptr<Tuple> tuple_;
+  std::vector<std::unique_ptr<Tuple>> tuples_;
 
   DISALLOW_COPY_AND_ASSIGN(InsertWorkOrder);
 };

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3595bc1f/relational_operators/WorkOrder.proto
----------------------------------------------------------------------
diff --git a/relational_operators/WorkOrder.proto b/relational_operators/WorkOrder.proto
index aaf7929..b84e758 100644
--- a/relational_operators/WorkOrder.proto
+++ b/relational_operators/WorkOrder.proto
@@ -201,7 +201,7 @@ message InsertWorkOrder {
   extend WorkOrder {
     // All required.
     optional int32 insert_destination_index = 176;
-    optional uint32 tuple_index = 177;
+    repeated uint32 tuple_indexes = 177;
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/3595bc1f/relational_operators/WorkOrderFactory.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/WorkOrderFactory.cpp b/relational_operators/WorkOrderFactory.cpp
index 3a991bd..7f11e3e 100644
--- a/relational_operators/WorkOrderFactory.cpp
+++ b/relational_operators/WorkOrderFactory.cpp
@@ -395,12 +395,22 @@ WorkOrder* WorkOrderFactory::ReconstructFromProto(const serialization::WorkOrder
     }
     case serialization::INSERT: {
       LOG(INFO) << "Creating InsertWorkOrder for Query " << query_id << " in Shiftboss " << shiftboss_index;
+
+      const int tuple_count = proto.ExtensionSize(serialization::InsertWorkOrder::tuple_indexes);
+      std::vector<std::unique_ptr<Tuple>> tuple_indexes;
+
+      for (int specific_tuple_index = 0; specific_tuple_index < tuple_count; specific_tuple_index++) {
+        const int tuple_index =
+            proto.GetExtension(serialization::InsertWorkOrder::tuple_indexes, specific_tuple_index);
+        tuple_indexes.emplace_back(
+            std::unique_ptr<Tuple>(query_context->releaseTuple(tuple_index)));
+      }
+
       return new InsertWorkOrder(
           query_id,
           query_context->getInsertDestination(
               proto.GetExtension(serialization::InsertWorkOrder::insert_destination_index)),
-          query_context->releaseTuple(
-              proto.GetExtension(serialization::InsertWorkOrder::tuple_index)));
+              std::move(tuple_indexes));
     }
     case serialization::NESTED_LOOP_JOIN: {
       const partition_id part_id =
@@ -852,12 +862,20 @@ bool WorkOrderFactory::ProtoIsValid(const serialization::WorkOrder &proto,
              proto.HasExtension(serialization::InitializeAggregationWorkOrder::state_partition_id);
     }
     case serialization::INSERT: {
+      const int tuple_count = proto.ExtensionSize(serialization::InsertWorkOrder::tuple_indexes);
+      std::vector<QueryContext::tuple_id> tuple_indexes;
+
+      for (int specific_tuple_index = 0; specific_tuple_index < tuple_count; specific_tuple_index++) {
+        const int tuple_index =
+            proto.GetExtension(serialization::InsertWorkOrder::tuple_indexes, specific_tuple_index);
+        tuple_indexes.push_back(tuple_index);
+      }
+
       return proto.HasExtension(serialization::InsertWorkOrder::insert_destination_index) &&
              query_context.isValidInsertDestinationId(
                  proto.GetExtension(serialization::InsertWorkOrder::insert_destination_index)) &&
-             proto.HasExtension(serialization::InsertWorkOrder::tuple_index) &&
-             query_context.isValidTupleId(
-                 proto.GetExtension(serialization::InsertWorkOrder::tuple_index));
+             proto.HasExtension(serialization::InsertWorkOrder::tuple_indexes) &&
+             query_context.areValidTupleIds(tuple_indexes);
     }
     case serialization::NESTED_LOOP_JOIN: {
       if (!proto.HasExtension(serialization::NestedLoopsJoinWorkOrder::left_relation_id) ||


[42/46] incubator-quickstep git commit: IDE Documentation fixes

Posted by ji...@apache.org.
IDE Documentation fixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/4a945a6b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/4a945a6b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/4a945a6b

Branch: refs/heads/fix-iwyu
Commit: 4a945a6b9a64b9735f8cdf91556c6661e4731c43
Parents: 5d7aa5f
Author: Harshad Deshmukh <hb...@apache.org>
Authored: Wed Dec 27 10:47:00 2017 -0600
Committer: Harshad Deshmukh <hb...@apache.org>
Committed: Thu Jan 11 13:52:20 2018 -0600

----------------------------------------------------------------------
 WORKING_WITH_AN_IDE.md | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/4a945a6b/WORKING_WITH_AN_IDE.md
----------------------------------------------------------------------
diff --git a/WORKING_WITH_AN_IDE.md b/WORKING_WITH_AN_IDE.md
index 017a174..fca1217 100644
--- a/WORKING_WITH_AN_IDE.md
+++ b/WORKING_WITH_AN_IDE.md
@@ -1,17 +1,17 @@
-#Developing Quickstep with IDEs
+# Developing Quickstep with IDEs
 
-##Who should read this document?
+## Who should read this document?
 Any developer who prefers to work with IDEs instead of a terminal and
 vi, emacs, or the like. In other words, this document aims to make it easier
 for developers of Quickstep to work with IDEs. Over time, there will be
 information about working with other IDEs, but to start out, here are
 instructions for working with XCode on OSX.
 
-##Developing Quickstep with Xcode on OSX
+## Developing Quickstep with Xcode on OSX
 The instructions here were first written and verified on OSX El Capitan,
 v.10.11.2, using Xcode v.7.2.
 
-###1: Install Xcode and command line tools
+### 1: Install Xcode and command line tools
 First, you will need to download and install Xcode and the associated command
 line tools. There are multiple ways to do this, including going to
 https://developer.apple.com/xcode/ and downloading both Xcode and the command
@@ -25,7 +25,7 @@ cc
 This command should trigger a sequence of downloads to get you both Xcode
 and the assocaited command line tools.
 
-###2: Install cmake
+### 2: Install cmake
 Unfortunately, the command line tools do not package `cmake`, which is needed
 to build Quickstep. You can install cmake using brew as follows:
 
@@ -43,7 +43,7 @@ Terminal app by typing:
 brew install cmake
 ```
 
-###3: Build Quicktep
+### 3: Build Quicktep
 Checkout the Quickstep code from git, and also checkout the associated submodules.
 If you have not read it already, this would be good time to read the file
 [BUILDING.md](BUILDING.md), but do not run the cmake command mentioned there. Instead, go
@@ -103,7 +103,7 @@ these and other command line options by typing:
 ```
 
 
-###4: Debug Quickstep
+### 4: Debug Quickstep
 Now you can debug as you would any normal process in Xcode. Note the
 linenoise option in the cmake command above is important if you are going
 to run quickstep from Xcode (by hitting the "play" button). If you are
@@ -134,7 +134,7 @@ when it starts up. It you had set a breakpoint and the program executes that
 code, then Xcode (lldb) will stop at the breakpoint. Or, if there is a crash,
 you can examine the stack in Xcode.
 
-###5: Unit Tests
+### 5: Unit Tests
 Individual unit tests show up as target schemas, so you can simply select them
 and run the unit test of interest.
 
@@ -143,14 +143,14 @@ does not work. So, this is a known limitation at this point. You can, however,
 follow the instructions for a [BUILDING.md](command-line build) with cmake and
 then run `ctest` to run the full suite of unit tests.
 
-###6: Other known issues
+### 6: Other known issues
 
-####Modifying CMake Files
+#### Modifying CMake Files
 If you change any of the cmake files (such as any of the CMakeLists.txt
 files), then you will have to [redo step 3](#3-build-quicktep) above to
 create a new Xcode project file.
 
-####Running Python Validation Scripts
+#### Running Python Validation Scripts
 Quickstep developers have a few python scripts that are used to mechanically
 check code. These scripts are written in Python 2 and are not compatible with
 Python 3, so they use `python2` as the interpreter in their shebangs. While
@@ -167,7 +167,7 @@ sudo ln -s /usr/bin/python2.7 /usr/local/bin/python2
 2.X version is on your machine.)
 
 After putting the symlink in place, you should be able to run
-`./third_party/cpplint/lint_everything.py` (which applies a modified version of
+`./lint_everything.py` (which applies a modified version of
 Google cpplint to all C++ sources) and `./validate_cmakelists.py` (which checks
 that dependencies in CMakeLists.txt files exactly match included headers in C++
 sources) from the root quickstep source directory to check your code. There is


[20/46] incubator-quickstep git commit: Support Multiple Tuple Inserts

Posted by ji...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fe838df/parser/preprocessed/SqlParser_gen.hpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlParser_gen.hpp b/parser/preprocessed/SqlParser_gen.hpp
index f6b5247..142059d 100644
--- a/parser/preprocessed/SqlParser_gen.hpp
+++ b/parser/preprocessed/SqlParser_gen.hpp
@@ -198,6 +198,7 @@ union YYSTYPE
   quickstep::NumericParseLiteralValue *numeric_literal_value_;
   quickstep::ParseLiteralValue *literal_value_;
   quickstep::PtrList<quickstep::ParseScalarLiteral> *literal_value_list_;
+  quickstep::PtrList<quickstep::PtrList<quickstep::ParseScalarLiteral>> *literal_value_list_multiple_;
 
   quickstep::ParseExpression *expression_;
 
@@ -288,7 +289,7 @@ union YYSTYPE
 
   quickstep::ParsePriority *opt_priority_clause_;
 
-#line 292 "SqlParser_gen.hpp" /* yacc.c:1915  */
+#line 293 "SqlParser_gen.hpp" /* yacc.c:1915  */
 };
 
 typedef union YYSTYPE YYSTYPE;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fe838df/query_optimizer/ExecutionGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp
index 372d576..14d8949 100644
--- a/query_optimizer/ExecutionGenerator.cpp
+++ b/query_optimizer/ExecutionGenerator.cpp
@@ -1461,70 +1461,72 @@ void ExecutionGenerator::convertInsertTuple(
       *catalog_database_->getRelationById(
           input_relation_info->relation->getID());
 
-  // Construct the tuple proto to be inserted.
-  const QueryContext::tuple_id tuple_index = query_context_proto_->tuples_size();
+  for (const std::vector<expressions::ScalarLiteralPtr> &tuple : physical_plan->column_values()) {
+    // Construct the tuple proto to be inserted.
+    const QueryContext::tuple_id tuple_index = query_context_proto_->tuples_size();
 
-  S::Tuple *tuple_proto = query_context_proto_->add_tuples();
-  for (const E::ScalarLiteralPtr &literal : physical_plan->column_values()) {
-    tuple_proto->add_attribute_values()->CopyFrom(literal->value().getProto());
-  }
+    S::Tuple *tuple_proto = query_context_proto_->add_tuples();
+    for (const E::ScalarLiteralPtr &literal : tuple) {
+      tuple_proto->add_attribute_values()->CopyFrom(literal->value().getProto());
+    }
 
-  // FIXME(qzeng): A better way is using a traits struct to look up whether a storage
-  //               block supports ad-hoc insertion instead of hard-coding the block types.
-  const StorageBlockLayout &storage_block_layout =
-      input_relation.getDefaultStorageBlockLayout();
-  if (storage_block_layout.getDescription().tuple_store_description().sub_block_type() ==
-      TupleStorageSubBlockDescription::COMPRESSED_COLUMN_STORE ||
-      storage_block_layout.getDescription().tuple_store_description().sub_block_type() ==
-            TupleStorageSubBlockDescription::COMPRESSED_PACKED_ROW_STORE) {
-    THROW_SQL_ERROR() << "INSERT statement is not supported for the relation "
-                      << input_relation.getName()
-                      << ", because its storage blocks do not support ad-hoc insertion";
-  }
+    // FIXME(qzeng): A better way is using a traits struct to look up whether a storage
+    //               block supports ad-hoc insertion instead of hard-coding the block types.
+    const StorageBlockLayout &storage_block_layout =
+        input_relation.getDefaultStorageBlockLayout();
+    if (storage_block_layout.getDescription().tuple_store_description().sub_block_type() ==
+        TupleStorageSubBlockDescription::COMPRESSED_COLUMN_STORE ||
+        storage_block_layout.getDescription().tuple_store_description().sub_block_type() ==
+              TupleStorageSubBlockDescription::COMPRESSED_PACKED_ROW_STORE) {
+      THROW_SQL_ERROR() << "INSERT statement is not supported for the relation "
+                        << input_relation.getName()
+                        << ", because its storage blocks do not support ad-hoc insertion";
+    }
 
-  // Create InsertDestination proto.
-  const QueryContext::insert_destination_id insert_destination_index =
-      query_context_proto_->insert_destinations_size();
-  S::InsertDestination *insert_destination_proto = query_context_proto_->add_insert_destinations();
+    // Create InsertDestination proto.
+    const QueryContext::insert_destination_id insert_destination_index =
+        query_context_proto_->insert_destinations_size();
+    S::InsertDestination *insert_destination_proto = query_context_proto_->add_insert_destinations();
 
-  insert_destination_proto->set_relation_id(input_relation.getID());
-  insert_destination_proto->mutable_layout()->MergeFrom(
-      input_relation.getDefaultStorageBlockLayout().getDescription());
+    insert_destination_proto->set_relation_id(input_relation.getID());
+    insert_destination_proto->mutable_layout()->MergeFrom(
+        input_relation.getDefaultStorageBlockLayout().getDescription());
 
-  if (input_relation.hasPartitionScheme()) {
-    insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::PARTITION_AWARE);
-    insert_destination_proto->MutableExtension(S::PartitionAwareInsertDestination::partition_scheme)
-        ->MergeFrom(input_relation.getPartitionScheme()->getProto());
-  } else {
-    insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::BLOCK_POOL);
+    if (input_relation.hasPartitionScheme()) {
+      insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::PARTITION_AWARE);
+      insert_destination_proto->MutableExtension(S::PartitionAwareInsertDestination::partition_scheme)
+          ->MergeFrom(input_relation.getPartitionScheme()->getProto());
+    } else {
+      insert_destination_proto->set_insert_destination_type(S::InsertDestinationType::BLOCK_POOL);
 
-    const vector<block_id> blocks(input_relation.getBlocksSnapshot());
-    for (const block_id block : blocks) {
-      insert_destination_proto->AddExtension(S::BlockPoolInsertDestination::blocks, block);
+      const vector<block_id> blocks(input_relation.getBlocksSnapshot());
+      for (const block_id block : blocks) {
+        insert_destination_proto->AddExtension(S::BlockPoolInsertDestination::blocks, block);
+      }
     }
-  }
 
-  const QueryPlan::DAGNodeIndex insert_operator_index =
-      execution_plan_->addRelationalOperator(
-          new InsertOperator(query_handle_->query_id(),
-                             input_relation,
-                             insert_destination_index,
-                             tuple_index));
-  insert_destination_proto->set_relational_op_index(insert_operator_index);
+    const QueryPlan::DAGNodeIndex insert_operator_index =
+        execution_plan_->addRelationalOperator(
+            new InsertOperator(query_handle_->query_id(),
+                               input_relation,
+                               insert_destination_index,
+                               tuple_index));
+    insert_destination_proto->set_relational_op_index(insert_operator_index);
 
-  CatalogRelation *mutable_relation =
-      catalog_database_->getRelationByIdMutable(input_relation.getID());
-  const QueryPlan::DAGNodeIndex save_blocks_index =
-      execution_plan_->addRelationalOperator(
-          new SaveBlocksOperator(query_handle_->query_id(), mutable_relation));
-  if (!input_relation_info->isStoredRelation()) {
-    execution_plan_->addDirectDependency(insert_operator_index,
-                                         input_relation_info->producer_operator_index,
-                                         true /* is_pipeline_breaker */);
+    CatalogRelation *mutable_relation =
+        catalog_database_->getRelationByIdMutable(input_relation.getID());
+    const QueryPlan::DAGNodeIndex save_blocks_index =
+        execution_plan_->addRelationalOperator(
+            new SaveBlocksOperator(query_handle_->query_id(), mutable_relation));
+    if (!input_relation_info->isStoredRelation()) {
+      execution_plan_->addDirectDependency(insert_operator_index,
+                                           input_relation_info->producer_operator_index,
+                                           true /* is_pipeline_breaker */);
+    }
+    execution_plan_->addDirectDependency(save_blocks_index,
+                                         insert_operator_index,
+                                         false /* is_pipeline_breaker */);
   }
-  execution_plan_->addDirectDependency(save_blocks_index,
-                                       insert_operator_index,
-                                       false /* is_pipeline_breaker */);
 }
 
 void ExecutionGenerator::convertInsertSelection(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fe838df/query_optimizer/logical/InsertTuple.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/logical/InsertTuple.cpp b/query_optimizer/logical/InsertTuple.cpp
index e5ffa35..e2ce196 100644
--- a/query_optimizer/logical/InsertTuple.cpp
+++ b/query_optimizer/logical/InsertTuple.cpp
@@ -41,8 +41,10 @@ void InsertTuple::getFieldStringItems(
   non_container_child_field_names->push_back("input");
   non_container_child_fields->push_back(input_);
 
-  container_child_field_names->push_back("column_values");
-  container_child_fields->push_back(CastSharedPtrVector<OptimizerTreeBase>(column_values_));
+  for (const auto &column_values : column_values_) {
+    container_child_field_names->push_back("column_values");
+    container_child_fields->push_back(CastSharedPtrVector<OptimizerTreeBase>(column_values));
+  }
 }
 
 }  // namespace logical

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fe838df/query_optimizer/logical/InsertTuple.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/logical/InsertTuple.hpp b/query_optimizer/logical/InsertTuple.hpp
index fd0301e..dd35510 100644
--- a/query_optimizer/logical/InsertTuple.hpp
+++ b/query_optimizer/logical/InsertTuple.hpp
@@ -61,7 +61,7 @@ class InsertTuple : public Logical {
   /**
    * @return Column values to be used to compose a new tuple.
    */
-  const std::vector<expressions::ScalarLiteralPtr>& column_values() const {
+  const std::vector<std::vector<expressions::ScalarLiteralPtr>>& column_values() const {
     return column_values_;
   }
 
@@ -83,12 +83,12 @@ class InsertTuple : public Logical {
    * @brief Creates an InsertTuple logical node.
    *
    * @param input The input produces the relation to insert the tuple to.
-   * @param column_values The column values of the tuple to be inserted.
+   * @param column_values The column values of the tuples to be inserted.
    * @return An immutable InsertTuple node.
    */
   static InsertTuplePtr Create(
       const LogicalPtr &input,
-      const std::vector<expressions::ScalarLiteralPtr> &column_values) {
+      const std::vector<std::vector<expressions::ScalarLiteralPtr>> &column_values) {
     return InsertTuplePtr(new InsertTuple(input, column_values));
   }
 
@@ -103,13 +103,13 @@ class InsertTuple : public Logical {
 
  private:
   InsertTuple(const LogicalPtr &input,
-              const std::vector<expressions::ScalarLiteralPtr> &column_values)
+              const std::vector<std::vector<expressions::ScalarLiteralPtr>> &column_values)
       : input_(input), column_values_(column_values) {
     addChild(input_);
   }
 
   LogicalPtr input_;
-  std::vector<expressions::ScalarLiteralPtr> column_values_;
+  std::vector<std::vector<expressions::ScalarLiteralPtr>> column_values_;
 
   DISALLOW_COPY_AND_ASSIGN(InsertTuple);
 };

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fe838df/query_optimizer/physical/InsertTuple.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/InsertTuple.cpp b/query_optimizer/physical/InsertTuple.cpp
index 3085389..b209aa0 100644
--- a/query_optimizer/physical/InsertTuple.cpp
+++ b/query_optimizer/physical/InsertTuple.cpp
@@ -40,8 +40,10 @@ void InsertTuple::getFieldStringItems(
   non_container_child_field_names->push_back("input");
   non_container_child_fields->push_back(input_);
 
-  container_child_field_names->push_back("column_values");
-  container_child_fields->push_back(CastSharedPtrVector<OptimizerTreeBase>(column_values_));
+  for (const auto &column_values : column_values_) {
+    container_child_field_names->push_back("column_values");
+    container_child_fields->push_back(CastSharedPtrVector<OptimizerTreeBase>(column_values));
+  }
 }
 
 }  // namespace physical

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fe838df/query_optimizer/physical/InsertTuple.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/physical/InsertTuple.hpp b/query_optimizer/physical/InsertTuple.hpp
index 40f2582..10c7c5b 100644
--- a/query_optimizer/physical/InsertTuple.hpp
+++ b/query_optimizer/physical/InsertTuple.hpp
@@ -69,7 +69,7 @@ class InsertTuple : public Physical {
   /**
    * @return Column values to be used to compose a new tuple.
    */
-  const std::vector<expressions::ScalarLiteralPtr>& column_values() const {
+  const std::vector<std::vector<expressions::ScalarLiteralPtr>>& column_values() const {
     return column_values_;
   }
 
@@ -103,7 +103,7 @@ class InsertTuple : public Physical {
    */
   static InsertTuplePtr Create(
       const PhysicalPtr &input,
-      const std::vector<expressions::ScalarLiteralPtr> &column_values) {
+      const std::vector<std::vector<expressions::ScalarLiteralPtr>> &column_values) {
     return InsertTuplePtr(new InsertTuple(input, column_values));
   }
 
@@ -118,13 +118,13 @@ class InsertTuple : public Physical {
 
  private:
   InsertTuple(const PhysicalPtr &input,
-              const std::vector<expressions::ScalarLiteralPtr> &column_values)
+              const std::vector<std::vector<expressions::ScalarLiteralPtr>> &column_values)
       : input_(input), column_values_(column_values) {
     addChild(input_);
   }
 
   PhysicalPtr input_;
-  std::vector<expressions::ScalarLiteralPtr> column_values_;
+  std::vector<std::vector<expressions::ScalarLiteralPtr>> column_values_;
 
   DISALLOW_COPY_AND_ASSIGN(InsertTuple);
 };

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fe838df/query_optimizer/resolver/Resolver.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp
index 2991568..0b6dc22 100644
--- a/query_optimizer/resolver/Resolver.cpp
+++ b/query_optimizer/resolver/Resolver.cpp
@@ -1060,73 +1060,81 @@ L::LogicalPtr Resolver::resolveInsertTuple(
   // Resolve column values.
   const std::vector<E::AttributeReferencePtr> relation_attributes =
       input_logical->getOutputAttributes();
-  const PtrList<ParseScalarLiteral> &parse_column_values =
+  const PtrList<PtrList<ParseScalarLiteral>> &parse_column_values_list =
       insert_statement.getLiteralValues();
-  DCHECK_GT(parse_column_values.size(), 0u);
 
-  if (parse_column_values.size() > relation_attributes.size()) {
-    THROW_SQL_ERROR_AT(insert_statement.relation_name())
-        << "The relation " << insert_statement.relation_name()->value()
-        << " has " << std::to_string(relation_attributes.size())
-        << " columns, but " << std::to_string(parse_column_values.size())
-        << " values are provided";
-  }
+  std::vector<std::vector<E::ScalarLiteralPtr>> resolved_column_values_list;
+  DCHECK_GT(parse_column_values_list.size(), 0u);
 
-  std::vector<E::ScalarLiteralPtr> resolved_column_values;
-  std::vector<E::AttributeReferencePtr>::size_type aid = 0;
-  for (const ParseScalarLiteral &parse_literal_value : parse_column_values) {
-    E::ScalarLiteralPtr resolved_literal_value;
-    ExpressionResolutionInfo expr_resolution_info(
-        name_resolver,
-        "INSERT statement" /* clause_name */,
-        nullptr /* select_list_info */);
-    // When resolving the literal, use the attribute's Type as a hint.
-    CHECK(E::SomeScalarLiteral::MatchesWithConditionalCast(
-        resolveExpression(parse_literal_value,
-                          &(relation_attributes[aid]->getValueType()),
-                          &expr_resolution_info),
-        &resolved_literal_value));
-
-    // Check that the resolved Type is safely coercible to the attribute's
-    // Type.
-    if (!relation_attributes[aid]->getValueType().isSafelyCoercibleFrom(
-            resolved_literal_value->getValueType())) {
-      THROW_SQL_ERROR_AT(&parse_literal_value)
-          << "The assigned value for the column "
-          << relation_attributes[aid]->attribute_name() << " has the type "
-          << resolved_literal_value->getValueType().getName()
-          << ", which cannot be safely coerced to the column's type "
-          << relation_attributes[aid]->getValueType().getName();
-    }
+  for (const PtrList<ParseScalarLiteral> &parse_column_values : parse_column_values_list) {
+    DCHECK_GT(parse_column_values.size(), 0u);
 
-    // If the Type is not exactly right (but is safely coercible), coerce it.
-    if (!resolved_literal_value->getValueType().equals(
-            relation_attributes[aid]->getValueType())) {
-      resolved_literal_value = E::ScalarLiteral::Create(
-          relation_attributes[aid]->getValueType().coerceValue(
-              resolved_literal_value->value(),
-              resolved_literal_value->getValueType()),
-          relation_attributes[aid]->getValueType());
+    if (parse_column_values.size() > relation_attributes.size()) {
+      THROW_SQL_ERROR_AT(insert_statement.relation_name())
+          << "The relation " << insert_statement.relation_name()->value()
+          << " has " << std::to_string(relation_attributes.size())
+          << " columns, but " << std::to_string(parse_column_values.size())
+          << " values are provided";
     }
 
-    resolved_column_values.push_back(resolved_literal_value);
-    ++aid;
-  }
+    std::vector<E::ScalarLiteralPtr> resolved_column_values;
+    std::vector<E::AttributeReferencePtr>::size_type aid = 0;
+    for (const ParseScalarLiteral &parse_literal_value : parse_column_values) {
+      E::ScalarLiteralPtr resolved_literal_value;
+      ExpressionResolutionInfo expr_resolution_info(
+          name_resolver,
+          "INSERT statement" /* clause_name */,
+          nullptr /* select_list_info */);
+      // When resolving the literal, use the attribute's Type as a hint.
+      CHECK(E::SomeScalarLiteral::MatchesWithConditionalCast(
+          resolveExpression(parse_literal_value,
+                            &(relation_attributes[aid]->getValueType()),
+                            &expr_resolution_info),
+          &resolved_literal_value));
+
+      // Check that the resolved Type is safely coercible to the attribute's
+      // Type.
+      if (!relation_attributes[aid]->getValueType().isSafelyCoercibleFrom(
+              resolved_literal_value->getValueType())) {
+        THROW_SQL_ERROR_AT(&parse_literal_value)
+            << "The assigned value for the column "
+            << relation_attributes[aid]->attribute_name() << " has the type "
+            << resolved_literal_value->getValueType().getName()
+            << ", which cannot be safely coerced to the column's type "
+            << relation_attributes[aid]->getValueType().getName();
+      }
 
-  while (aid < relation_attributes.size()) {
-    if (!relation_attributes[aid]->getValueType().isNullable()) {
-      THROW_SQL_ERROR_AT(insert_statement.relation_name())
-          << "Must assign a non-NULL value to column "
-          << relation_attributes[aid]->attribute_name();
+      // If the Type is not exactly right (but is safely coercible), coerce it.
+      if (!resolved_literal_value->getValueType().equals(
+              relation_attributes[aid]->getValueType())) {
+        resolved_literal_value = E::ScalarLiteral::Create(
+            relation_attributes[aid]->getValueType().coerceValue(
+                resolved_literal_value->value(),
+                resolved_literal_value->getValueType()),
+            relation_attributes[aid]->getValueType());
+      }
+
+      resolved_column_values.push_back(resolved_literal_value);
+      ++aid;
+    }
+
+    while (aid < relation_attributes.size()) {
+      if (!relation_attributes[aid]->getValueType().isNullable()) {
+        THROW_SQL_ERROR_AT(insert_statement.relation_name())
+            << "Must assign a non-NULL value to column "
+            << relation_attributes[aid]->attribute_name();
+      }
+      // Create a NULL value.
+      resolved_column_values.push_back(E::ScalarLiteral::Create(
+          relation_attributes[aid]->getValueType().makeNullValue(),
+          relation_attributes[aid]->getValueType()));
+      ++aid;
     }
-    // Create a NULL value.
-    resolved_column_values.push_back(E::ScalarLiteral::Create(
-        relation_attributes[aid]->getValueType().makeNullValue(),
-        relation_attributes[aid]->getValueType()));
-    ++aid;
+
+    resolved_column_values_list.push_back(std::move(resolved_column_values));
   }
 
-  return L::InsertTuple::Create(input_logical, resolved_column_values);
+  return L::InsertTuple::Create(input_logical, resolved_column_values_list);
 }
 
 L::LogicalPtr Resolver::resolveUpdate(


[11/46] incubator-quickstep git commit: Removed the virtual function call in InvokeOnAnyValueAccessor.

Posted by ji...@apache.org.
Removed the virtual function call in InvokeOnAnyValueAccessor.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/79710ca6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/79710ca6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/79710ca6

Branch: refs/heads/fix-iwyu
Commit: 79710ca6c6b75410bf2c26b4646acbfc5d554d7c
Parents: 696a783
Author: Zuyu Zhang <zu...@cs.wisc.edu>
Authored: Fri Oct 6 14:34:21 2017 -0500
Committer: Zuyu Zhang <zu...@cs.wisc.edu>
Committed: Mon Oct 9 11:37:16 2017 -0500

----------------------------------------------------------------------
 storage/SplitRowStoreTupleStorageSubBlock.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/79710ca6/storage/SplitRowStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/SplitRowStoreTupleStorageSubBlock.cpp b/storage/SplitRowStoreTupleStorageSubBlock.cpp
index 5060208..9f5a839 100644
--- a/storage/SplitRowStoreTupleStorageSubBlock.cpp
+++ b/storage/SplitRowStoreTupleStorageSubBlock.cpp
@@ -343,7 +343,7 @@ tuple_id SplitRowStoreTupleStorageSubBlock::bulkInsertPartialTuplesImpl(
 
   InvokeOnAnyValueAccessor(
       accessor,
-      [&](auto *accessor) -> void {  // NOLINT(build/c++11
+      [&](auto *accessor) -> void {  // NOLINT(build/c++11)
     BitVector<true> tuple_null_bitmap(tuple_slot, num_null_attrs_);
     const std::size_t nullmap_size = BitVector<true>::BytesNeeded(num_null_attrs_);
 
@@ -410,7 +410,7 @@ tuple_id SplitRowStoreTupleStorageSubBlock::bulkInsertPartialTuplesImpl(
           max_num_tuples_to_insert += additional_tuples_insert;
         }
       }
-    } while (fill_to_capacity && !accessor->iterationFinishedVirtual() &&
+    } while (fill_to_capacity && !accessor->iterationFinished() &&
              num_tuples_inserted < max_num_tuples_to_insert);
   });
 


[46/46] incubator-quickstep git commit: Fix iwyu include path

Posted by ji...@apache.org.
Fix iwyu include path


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

Branch: refs/heads/fix-iwyu
Commit: c2ed5c69b6b8dad07d7410beb0c8292ea1a746e0
Parents: 023c43a
Author: Jianqiao Zhu <ji...@cs.wisc.edu>
Authored: Fri Sep 1 15:07:41 2017 -0500
Committer: Jianqiao Zhu <ji...@cs.wisc.edu>
Committed: Mon Feb 26 13:15:06 2018 -0600

----------------------------------------------------------------------
 third_party/src/iwyu/iwyu_helper.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c2ed5c69/third_party/src/iwyu/iwyu_helper.py
----------------------------------------------------------------------
diff --git a/third_party/src/iwyu/iwyu_helper.py b/third_party/src/iwyu/iwyu_helper.py
index dff4d55..42bf84c 100755
--- a/third_party/src/iwyu/iwyu_helper.py
+++ b/third_party/src/iwyu/iwyu_helper.py
@@ -22,12 +22,12 @@ QUICKSTEP_INCLUDES = [ '.',
                        './build/third_party/gflags/include',
                        './build/third_party/protobuf/include',
                        './build/third_party/tmb/include',
-                       './third_party/benchmark/include',
-                       './third_party/glog/src',
-                       './third_party/googletest/googletest/include',
-                       './third_party/protobuf/src',
-                       './third_party/re2',
-                       './third_party/tmb/include']
+                       './third_party/src/benchmark/include',
+                       './third_party/src/glog/src',
+                       './third_party/src/googletest/googletest/include',
+                       './third_party/src/protobuf/src',
+                       './third_party/src/re2',
+                       './third_party/src/tmb/include']
 QUICKSTEP_DEFINES = [ '-DQUICKSTEP_DEBUG',
                       '-DQUICKSTEP_ENABLE_VECTOR_COPY_ELISION_SELECTION', ]
 CLANG_FLAGS = [ '-std=c++14', '-x', 'c++', ]