This is an automated email from the ASF dual-hosted git repository.

zghao pushed a commit to branch HBASE-14850
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 777258763540bf1df233600bd622a8ac20a26bda
Author: Enis Soztutar <[email protected]>
AuthorDate: Fri Dec 16 16:28:34 2016 -0800

    HBASE-17220 [C++] Address major issues from cpplint
---
 .gitignore                                          |  1 +
 hbase-native-client/bin/cpplint.sh                  |  4 +++-
 hbase-native-client/connection/client-dispatcher.cc |  2 ++
 hbase-native-client/connection/client-dispatcher.h  |  1 +
 hbase-native-client/connection/client-handler.h     |  4 +++-
 hbase-native-client/connection/connection-factory.h |  4 +++-
 hbase-native-client/connection/connection-pool.cc   |  3 +++
 hbase-native-client/connection/connection-pool.h    |  4 +++-
 hbase-native-client/connection/pipeline.h           |  2 ++
 hbase-native-client/connection/response.h           |  2 ++
 hbase-native-client/connection/service.h            |  2 ++
 hbase-native-client/core/cell-test.cc               | 16 ++++++++--------
 hbase-native-client/core/cell.cc                    |  6 +++---
 hbase-native-client/core/cell.h                     | 16 ++++++++++------
 hbase-native-client/core/client.h                   |  1 +
 hbase-native-client/core/configuration.cc           |  4 +++-
 hbase-native-client/core/configuration.h            |  7 ++++---
 hbase-native-client/core/get-test.cc                |  9 +++++----
 hbase-native-client/core/get.cc                     | 10 +++++-----
 hbase-native-client/core/get.h                      | 13 +++++++------
 .../core/hbase_configuration_loader.cc              |  6 ++++--
 hbase-native-client/core/location-cache.cc          |  2 ++
 hbase-native-client/core/meta-utils.cc              |  1 +
 hbase-native-client/core/meta-utils.h               |  1 +
 hbase-native-client/core/region-location.h          |  1 +
 hbase-native-client/core/scan-test.cc               |  9 +++++----
 hbase-native-client/core/scan.cc                    | 17 ++++++++---------
 hbase-native-client/core/scan.h                     | 19 ++++++++++---------
 hbase-native-client/core/time_range-test.cc         |  2 +-
 hbase-native-client/core/time_range.cc              | 14 +++++++-------
 hbase-native-client/core/time_range.h               | 21 ++++++++++++---------
 hbase-native-client/serde/region-info.h             |  2 ++
 hbase-native-client/serde/rpc.cc                    |  3 ++-
 hbase-native-client/serde/rpc.h                     |  2 +-
 hbase-native-client/serde/server-name.h             |  8 ++++++--
 hbase-native-client/serde/table-name.h              |  1 +
 hbase-native-client/serde/zk.cc                     |  2 ++
 hbase-native-client/test-util/test-util.cc          |  6 +++---
 38 files changed, 140 insertions(+), 88 deletions(-)

diff --git a/.gitignore b/.gitignore
index f4cfbb7..1cd1a0d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 /.externalToolBuilders
 .project
+.cproject
 *.settings/
 .DS_Store
 .classpath
diff --git a/hbase-native-client/bin/cpplint.sh 
b/hbase-native-client/bin/cpplint.sh
index 52ca581..169c382 100755
--- a/hbase-native-client/bin/cpplint.sh
+++ b/hbase-native-client/bin/cpplint.sh
@@ -24,4 +24,6 @@ OUTPUT=build/cpplint.py
 wget -nc $CPPLINT_LOC -O $OUTPUT
 
 # Execute the script
-find core connection serde utils test-util -name "*.h" -or -name "*.cc" | 
xargs -P8 python $OUTPUT
+# Exclude the following rules: build/header_guard (We use #pragma once instead)
+#                              readability/todo (TODOs are generic)
+find core connection serde utils test-util -name "*.h" -or -name "*.cc"| xargs 
-P8 python $OUTPUT --filter=-build/header_guard,-readability/todo
diff --git a/hbase-native-client/connection/client-dispatcher.cc 
b/hbase-native-client/connection/client-dispatcher.cc
index 655d765..0a03396 100644
--- a/hbase-native-client/connection/client-dispatcher.cc
+++ b/hbase-native-client/connection/client-dispatcher.cc
@@ -18,6 +18,8 @@
  */
 #include "connection/client-dispatcher.h"
 
+#include <utility>
+
 using namespace folly;
 using namespace hbase;
 using namespace wangle;
diff --git a/hbase-native-client/connection/client-dispatcher.h 
b/hbase-native-client/connection/client-dispatcher.h
index 5528a44..67e604e 100644
--- a/hbase-native-client/connection/client-dispatcher.h
+++ b/hbase-native-client/connection/client-dispatcher.h
@@ -24,6 +24,7 @@
 #include <wangle/service/ClientDispatcher.h>
 
 #include <atomic>
+#include <memory>
 
 #include "connection/pipeline.h"
 #include "connection/request.h"
diff --git a/hbase-native-client/connection/client-handler.h 
b/hbase-native-client/connection/client-handler.h
index 269b737..7306c9a 100644
--- a/hbase-native-client/connection/client-handler.h
+++ b/hbase-native-client/connection/client-handler.h
@@ -22,8 +22,10 @@
 #include <wangle/channel/Handler.h>
 
 #include <atomic>
+#include <memory>
 #include <mutex>
 #include <string>
+#include <utility>
 
 #include "serde/rpc.h"
 
@@ -56,7 +58,7 @@ class ClientHandler : public 
wangle::Handler<std::unique_ptr<folly::IOBuf>,
    * Create the handler
    * @param user_name the user name of the user running this process.
    */
-  ClientHandler(std::string user_name);
+  explicit ClientHandler(std::string user_name);
 
   /**
    * Get bytes from the wire.
diff --git a/hbase-native-client/connection/connection-factory.h 
b/hbase-native-client/connection/connection-factory.h
index 4627952..17d9941 100644
--- a/hbase-native-client/connection/connection-factory.h
+++ b/hbase-native-client/connection/connection-factory.h
@@ -20,6 +20,7 @@
 
 #include <wangle/service/Service.h>
 
+#include <memory>
 #include <string>
 
 #include "connection/pipeline.h"
@@ -39,7 +40,8 @@ class ConnectionFactory {
    * Constructor.
    * There should only be one ConnectionFactory per client.
    */
-  ConnectionFactory(std::shared_ptr<wangle::IOThreadPoolExecutor> io_pool);
+  explicit ConnectionFactory(
+      std::shared_ptr<wangle::IOThreadPoolExecutor> io_pool);
   /** Default Desctructor */
   virtual ~ConnectionFactory() = default;
 
diff --git a/hbase-native-client/connection/connection-pool.cc 
b/hbase-native-client/connection/connection-pool.cc
index 2cb8e81..c216d0b 100644
--- a/hbase-native-client/connection/connection-pool.cc
+++ b/hbase-native-client/connection/connection-pool.cc
@@ -22,6 +22,9 @@
 #include <folly/SocketAddress.h>
 #include <wangle/service/Service.h>
 
+#include <memory>
+#include <utility>
+
 using std::mutex;
 using std::unique_ptr;
 using std::shared_ptr;
diff --git a/hbase-native-client/connection/connection-pool.h 
b/hbase-native-client/connection/connection-pool.h
index c89744e..2624336 100644
--- a/hbase-native-client/connection/connection-pool.h
+++ b/hbase-native-client/connection/connection-pool.h
@@ -20,6 +20,7 @@
 
 #include <folly/SharedMutex.h>
 #include <boost/functional/hash.hpp>
+#include <memory>
 #include <mutex>
 #include <unordered_map>
 
@@ -60,7 +61,8 @@ struct ServerNameHash {
 class ConnectionPool {
  public:
   /** Create connection pool wit default connection factory */
-  ConnectionPool(std::shared_ptr<wangle::IOThreadPoolExecutor> io_executor);
+  explicit ConnectionPool(
+      std::shared_ptr<wangle::IOThreadPoolExecutor> io_executor);
 
   /**
    * Desctructor.
diff --git a/hbase-native-client/connection/pipeline.h 
b/hbase-native-client/connection/pipeline.h
index b969e2b..c4f3bbb 100644
--- a/hbase-native-client/connection/pipeline.h
+++ b/hbase-native-client/connection/pipeline.h
@@ -21,6 +21,8 @@
 #include <folly/io/IOBufQueue.h>
 #include <wangle/service/Service.h>
 
+#include <memory>
+
 #include "connection/request.h"
 #include "connection/response.h"
 #include "utils/user-util.h"
diff --git a/hbase-native-client/connection/response.h 
b/hbase-native-client/connection/response.h
index 6458c6b..f032d09 100644
--- a/hbase-native-client/connection/response.h
+++ b/hbase-native-client/connection/response.h
@@ -19,6 +19,8 @@
 #pragma once
 
 #include <cstdint>
+#include <memory>
+#include <utility>
 
 // Forward
 namespace google {
diff --git a/hbase-native-client/connection/service.h 
b/hbase-native-client/connection/service.h
index 226f936..0d2e258 100644
--- a/hbase-native-client/connection/service.h
+++ b/hbase-native-client/connection/service.h
@@ -20,6 +20,8 @@
 
 #include <wangle/service/Service.h>
 
+#include <memory>
+
 #include "connection/request.h"
 #include "connection/response.h"
 
diff --git a/hbase-native-client/core/cell-test.cc 
b/hbase-native-client/core/cell-test.cc
index 1d5c0eb..53574e8 100644
--- a/hbase-native-client/core/cell-test.cc
+++ b/hbase-native-client/core/cell-test.cc
@@ -30,7 +30,7 @@ TEST(CellTest, CellFailureTest) {
   std::string family = "family";
   std::string column = "column";
   std::string value = "value";
-  long timestamp = std::numeric_limits<long>::max();
+  int64_t timestamp = std::numeric_limits<int64_t>::max();
   std::string tags = "";
   std::unique_ptr<Cell> cell(
       new Cell(row, family, column, timestamp, value, cell_type));
@@ -49,7 +49,7 @@ TEST(CellTest, CellSuceessTest) {
   std::string family = "family-value";
   std::string column = "column-value";
   std::string value = "value-value";
-  long timestamp = std::numeric_limits<long>::max();
+  int64_t timestamp = std::numeric_limits<int64_t>::max();
   CellType cell_type = CellType::PUT;
   const std::unique_ptr<Cell> cell(
       new Cell(row, family, column, timestamp, value, cell_type));
@@ -70,7 +70,7 @@ TEST(CellTest, MultipleCellsTest) {
     std::string family = "family-value";
     std::string column = "column-value";
     std::string value = "value-value";
-    long timestamp = std::numeric_limits<long>::max();
+    int64_t timestamp = std::numeric_limits<int64_t>::max();
     row += std::to_string(i);
     value += std::to_string(i);
     CellType cell_type = CellType::PUT;
@@ -88,7 +88,7 @@ TEST(CellTest, MultipleCellsTest) {
     EXPECT_EQ("family-value", cell->Family());
     EXPECT_EQ("column-value", cell->Qualifier());
     EXPECT_EQ(value, cell->Value());
-    EXPECT_EQ(std::numeric_limits<long>::max(), cell->Timestamp());
+    EXPECT_EQ(std::numeric_limits<int64_t>::max(), cell->Timestamp());
     EXPECT_EQ(CellType::PUT, cell->Type());
     i += 1;
   }
@@ -103,7 +103,7 @@ TEST(CellTest, CellRowTest) {
   std::string family = "D";
   std::string column = "";
   std::string value = "";
-  long timestamp = std::numeric_limits<long>::max();
+  int64_t timestamp = std::numeric_limits<int64_t>::max();
   CellType cell_type = CellType::PUT;
   std::unique_ptr<Cell> cell(
       new Cell(row, family, column, timestamp, value, cell_type));
@@ -122,7 +122,7 @@ TEST(CellTest, CellRowFamilyTest) {
   std::string family = "only-family";
   std::string column = "";
   std::string value = "";
-  long timestamp = std::numeric_limits<long>::max();
+  int64_t timestamp = std::numeric_limits<int64_t>::max();
   CellType cell_type = CellType::PUT;
   const std::unique_ptr<Cell> cell(
       new Cell(row, family, column, timestamp, value, cell_type));
@@ -141,7 +141,7 @@ TEST(CellTest, CellRowFamilyValueTest) {
   std::string family = "only-family";
   std::string column = "";
   std::string value = "only-value";
-  long timestamp = std::numeric_limits<long>::max();
+  int64_t timestamp = std::numeric_limits<int64_t>::max();
   CellType cell_type = CellType::PUT;
   const std::unique_ptr<Cell> cell(
       new Cell(row, family, column, timestamp, value, cell_type));
@@ -160,7 +160,7 @@ TEST(CellTest, CellRowFamilyColumnValueTest) {
   std::string family = "only-family";
   std::string column = "only-column";
   std::string value = "only-value";
-  long timestamp = std::numeric_limits<long>::max();
+  int64_t timestamp = std::numeric_limits<int64_t>::max();
   CellType cell_type = CellType::PUT;
   std::unique_ptr<Cell> cell(
       new Cell(row, family, column, timestamp, value, cell_type));
diff --git a/hbase-native-client/core/cell.cc b/hbase-native-client/core/cell.cc
index 37ebd13..3102e53 100644
--- a/hbase-native-client/core/cell.cc
+++ b/hbase-native-client/core/cell.cc
@@ -23,7 +23,7 @@
 namespace hbase {
 
 Cell::Cell(const std::string &row, const std::string &family,
-           const std::string &qualifier, const long &timestamp,
+           const std::string &qualifier, const int64_t timestamp,
            const std::string &value, const hbase::CellType &cell_type)
     : row_(row),
       family_(family),
@@ -50,12 +50,12 @@ const std::string &Cell::Family() const { return family_; }
 
 const std::string &Cell::Qualifier() const { return qualifier_; }
 
-unsigned long Cell::Timestamp() const { return timestamp_; }
+int64_t Cell::Timestamp() const { return timestamp_; }
 
 const std::string &Cell::Value() const { return value_; }
 
 hbase::CellType Cell::Type() const { return cell_type_; }
 
-long Cell::SequenceId() const { return sequence_id_; }
+int64_t Cell::SequenceId() const { return sequence_id_; }
 
 } /* namespace hbase */
diff --git a/hbase-native-client/core/cell.h b/hbase-native-client/core/cell.h
index 16ed280..f55655c 100644
--- a/hbase-native-client/core/cell.h
+++ b/hbase-native-client/core/cell.h
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include <cstdint>
 #include <string>
 
 namespace hbase {
@@ -36,25 +37,28 @@ enum CellType {
 class Cell {
  public:
   Cell(const std::string &row, const std::string &family,
-       const std::string &qualifier, const long &timestamp,
+       const std::string &qualifier, const int64_t timestamp,
        const std::string &value, const hbase::CellType &cell_type);
   virtual ~Cell();
   const std::string &Row() const;
   const std::string &Family() const;
   const std::string &Qualifier() const;
-  unsigned long Timestamp() const;
+  int64_t Timestamp() const;
   const std::string &Value() const;
   CellType Type() const;
-  long SequenceId() const;
+  int64_t SequenceId() const;
 
  private:
   std::string row_;
   std::string family_;
   std::string qualifier_;
-  unsigned long timestamp_;
+  // Since java does not have unsigned, we are also using signed numerics here
+  // so that we won't have surprises when large uint64's are treated as
+  // negative values in the java server side
+  int64_t timestamp_;
   hbase::CellType cell_type_;
   std::string value_;
-  long sequence_id_;
+  int64_t sequence_id_;
 };
 
-} /* namespace hbase */
+}  // namespace hbase
diff --git a/hbase-native-client/core/client.h 
b/hbase-native-client/core/client.h
index 296a8a0..0ba1276 100644
--- a/hbase-native-client/core/client.h
+++ b/hbase-native-client/core/client.h
@@ -24,6 +24,7 @@
 #include <wangle/concurrent/CPUThreadPoolExecutor.h>
 #include <wangle/concurrent/IOThreadPoolExecutor.h>
 
+#include <memory>
 #include <string>
 
 #include "core/location-cache.h"
diff --git a/hbase-native-client/core/configuration.cc 
b/hbase-native-client/core/configuration.cc
index c074cf6..134f05f 100644
--- a/hbase-native-client/core/configuration.cc
+++ b/hbase-native-client/core/configuration.cc
@@ -17,9 +17,11 @@
  *
  */
 
-#include "configuration.h"
+#include "core/configuration.h"
 
+#include <memory>
 #include <stdexcept>
+#include <utility>
 
 #include <glog/logging.h>
 #include <boost/lexical_cast.hpp>
diff --git a/hbase-native-client/core/configuration.h 
b/hbase-native-client/core/configuration.h
index d313cf6..f09bbac 100644
--- a/hbase-native-client/core/configuration.h
+++ b/hbase-native-client/core/configuration.h
@@ -88,8 +88,9 @@ class Configuration {
   struct ConfigData {
     std::string value;
     bool final;
-    ConfigData() : final(false){};
-    ConfigData(const std::string &value) : value(value), final(false) {}
+    ConfigData() : final(false) {}
+    explicit ConfigData(const std::string &value)
+        : value(value), final(false) {}
     void operator=(const std::string &new_value) {
       value = new_value;
       final = false;
@@ -105,7 +106,7 @@ class Configuration {
    * @brief Create Configuration object using config_map;
    * @param config_map - Map consisting of properties.
    */
-  Configuration(ConfigMap &config_map);
+  explicit Configuration(ConfigMap &config_map);
 
   // Property map filled all the properties loaded by ConfigurationLoader
   ConfigMap hb_property_;
diff --git a/hbase-native-client/core/get-test.cc 
b/hbase-native-client/core/get-test.cc
index 53c14e3..cef99b9 100644
--- a/hbase-native-client/core/get-test.cc
+++ b/hbase-native-client/core/get-test.cc
@@ -121,7 +121,8 @@ void GetMethods(Get &get, const std::string &row) {
 
   // Test initial values
   EXPECT_EQ(0, get.Timerange().MinTimeStamp());
-  EXPECT_EQ(std::numeric_limits<long>::max(), get.Timerange().MaxTimeStamp());
+  EXPECT_EQ(std::numeric_limits<int64_t>::max(),
+            get.Timerange().MaxTimeStamp());
 
   // Set & Test new values using TimeRange and TimeStamp
   get.SetTimeRange(1000, 2000);
@@ -135,12 +136,12 @@ void GetMethods(Get &get, const std::string &row) {
   ASSERT_THROW(get.SetTimeRange(-1000, 2000), std::runtime_error);
   ASSERT_THROW(get.SetTimeRange(1000, -2000), std::runtime_error);
   ASSERT_THROW(get.SetTimeRange(1000, 200), std::runtime_error);
-  ASSERT_THROW(get.SetTimeStamp(std::numeric_limits<long>::max()),
+  ASSERT_THROW(get.SetTimeStamp(std::numeric_limits<int64_t>::max()),
                std::runtime_error);
 
   // Test some exceptions
   ASSERT_THROW(get.SetMaxVersions(0), std::runtime_error);
-  ASSERT_THROW(get.SetMaxVersions(std::numeric_limits<unsigned int>::max() + 
1),
+  ASSERT_THROW(get.SetMaxVersions(std::numeric_limits<uint32_t>::max() + 1),
                std::runtime_error);
 }
 
@@ -218,7 +219,7 @@ TEST(Get, MultiGet) {
 }
 
 TEST(Get, Exception) {
-  std::string row(std::numeric_limits<short>::max() + 1, 'X');
+  std::string row(std::numeric_limits<int16_t>::max() + 1, 'X');
   ASSERT_THROW(Get tmp = Get(row), std::runtime_error);
   ASSERT_THROW(Get tmp = Get(""), std::runtime_error);
 }
diff --git a/hbase-native-client/core/get.cc b/hbase-native-client/core/get.cc
index a70da37..6ba4e86 100644
--- a/hbase-native-client/core/get.cc
+++ b/hbase-native-client/core/get.cc
@@ -96,7 +96,7 @@ const FamilyMap &Get::Family() const { return family_map_; }
 
 int Get::MaxVersions() const { return max_versions_; }
 
-Get &Get::SetMaxVersions(uint32_t max_versions) {
+Get &Get::SetMaxVersions(int32_t max_versions) {
   if (0 == max_versions)
     throw std::runtime_error("max_versions must be positive");
 
@@ -111,12 +111,12 @@ Get &Get::SetCacheBlocks(bool cache_blocks) {
   return *this;
 }
 
-Get &Get::SetTimeRange(long min_timestamp, long max_timestamp) {
+Get &Get::SetTimeRange(int64_t min_timestamp, int64_t max_timestamp) {
   tr_.reset(new TimeRange(min_timestamp, max_timestamp));
   return *this;
 }
 
-Get &Get::SetTimeStamp(long timestamp) {
+Get &Get::SetTimeStamp(int64_t timestamp) {
   tr_.reset(new TimeRange(timestamp, timestamp + 1));
   return *this;
 }
@@ -124,7 +124,7 @@ Get &Get::SetTimeStamp(long timestamp) {
 const TimeRange &Get::Timerange() const { return *tr_; }
 
 void Get::CheckRow(const std::string &row) {
-  const int kMaxRowLength = std::numeric_limits<short>::max();
+  const int kMaxRowLength = std::numeric_limits<int16_t>::max();
   int row_length = row.size();
   if (0 == row_length) {
     throw std::runtime_error("Row length can't be 0");
@@ -135,4 +135,4 @@ void Get::CheckRow(const std::string &row) {
                              std::to_string(kMaxRowLength));
   }
 }
-}
+}  // namespace hbase
diff --git a/hbase-native-client/core/get.h b/hbase-native-client/core/get.h
index 90c42ee..f79c633 100644
--- a/hbase-native-client/core/get.h
+++ b/hbase-native-client/core/get.h
@@ -40,7 +40,7 @@ class Get {
   /**
    * Constructors
    */
-  Get(const std::string& row);
+  explicit Get(const std::string& row);
   Get(const Get& cget);
   Get& operator=(const Get& cget);
 
@@ -56,7 +56,7 @@ class Get {
    * is 1.
    * @param max_versions max_versons to set
    */
-  Get& SetMaxVersions(uint32_t max_versions = 1);
+  Get& SetMaxVersions(int32_t max_versions = 1);
 
   /**
    * @brief Returns whether blocks should be cached for this Get operation.
@@ -86,13 +86,13 @@ class Get {
    * @param minStamp the minimum timestamp, inclusive
    * @param maxStamp the maximum timestamp, exclusive
    */
-  Get& SetTimeRange(long min_timestamp, long max_timestamp);
+  Get& SetTimeRange(int64_t min_timestamp, int64_t max_timestamp);
 
   /**
    * @brief Get versions of columns with the specified timestamp.
    * @param The timestamp to be set
    */
-  Get& SetTimeStamp(long timestamp);
+  Get& SetTimeStamp(int64_t timestamp);
 
   /**
    * @brief Get all columns from the specified family.
@@ -131,7 +131,7 @@ class Get {
 
  private:
   std::string row_ = "";
-  uint32_t max_versions_ = 1;
+  int32_t max_versions_ = 1;
   bool cache_blocks_ = true;
   bool check_existence_only_ = false;
   FamilyMap family_map_;
@@ -146,4 +146,5 @@ class Get {
    */
   void CheckRow(const std::string& row);
 };
-}
+
+}  // namespace hbase
diff --git a/hbase-native-client/core/hbase_configuration_loader.cc 
b/hbase-native-client/core/hbase_configuration_loader.cc
index d3aff8c..20d0449 100644
--- a/hbase-native-client/core/hbase_configuration_loader.cc
+++ b/hbase-native-client/core/hbase_configuration_loader.cc
@@ -127,7 +127,8 @@ optional<Configuration> 
HBaseConfigurationLoader::LoadDefaultResources() {
     }
   }
   if (success) {
-    return std::experimental::make_optional<Configuration>(conf_property);
+    return std::experimental::make_optional<Configuration>(
+               Configuration(conf_property));
   } else {
     return optional<Configuration>();
   }
@@ -151,7 +152,8 @@ optional<Configuration> 
HBaseConfigurationLoader::LoadResources(
     }
   }
   if (success) {
-    return std::experimental::make_optional<Configuration>(conf_property);
+    return std::experimental::make_optional<Configuration>(
+               Configuration(conf_property));
   } else {
     return optional<Configuration>();
   }
diff --git a/hbase-native-client/core/location-cache.cc 
b/hbase-native-client/core/location-cache.cc
index 4359795..a0ca5ca 100644
--- a/hbase-native-client/core/location-cache.cc
+++ b/hbase-native-client/core/location-cache.cc
@@ -23,6 +23,8 @@
 #include <wangle/concurrent/CPUThreadPoolExecutor.h>
 #include <wangle/concurrent/IOThreadPoolExecutor.h>
 
+#include <utility>
+
 #include "connection/response.h"
 #include "if/Client.pb.h"
 #include "if/ZooKeeper.pb.h"
diff --git a/hbase-native-client/core/meta-utils.cc 
b/hbase-native-client/core/meta-utils.cc
index 23d2041..e1946d6 100644
--- a/hbase-native-client/core/meta-utils.cc
+++ b/hbase-native-client/core/meta-utils.cc
@@ -20,6 +20,7 @@
 #include "core/meta-utils.h"
 
 #include <folly/Conv.h>
+#include <memory>
 
 #include "connection/request.h"
 #include "connection/response.h"
diff --git a/hbase-native-client/core/meta-utils.h 
b/hbase-native-client/core/meta-utils.h
index 303a273..33da1a8 100644
--- a/hbase-native-client/core/meta-utils.h
+++ b/hbase-native-client/core/meta-utils.h
@@ -18,6 +18,7 @@
  */
 #pragma once
 
+#include <memory>
 #include <string>
 
 #include "connection/request.h"
diff --git a/hbase-native-client/core/region-location.h 
b/hbase-native-client/core/region-location.h
index b3c124d..f0295b1 100644
--- a/hbase-native-client/core/region-location.h
+++ b/hbase-native-client/core/region-location.h
@@ -19,6 +19,7 @@
 #pragma once
 
 #include <memory>
+#include <string>
 
 #include "connection/service.h"
 #include "if/HBase.pb.h"
diff --git a/hbase-native-client/core/scan-test.cc 
b/hbase-native-client/core/scan-test.cc
index b6a6f3e..0a4001a 100644
--- a/hbase-native-client/core/scan-test.cc
+++ b/hbase-native-client/core/scan-test.cc
@@ -154,7 +154,8 @@ void ScanMethods(Scan &scan) {
 
   // Test initial values
   EXPECT_EQ(0, scan.Timerange().MinTimeStamp());
-  EXPECT_EQ(std::numeric_limits<long>::max(), scan.Timerange().MaxTimeStamp());
+  EXPECT_EQ(std::numeric_limits<int64_t>::max(),
+            scan.Timerange().MaxTimeStamp());
 
   // Set & Test new values using TimeRange and TimeStamp
   scan.SetTimeRange(1000, 2000);
@@ -168,7 +169,7 @@ void ScanMethods(Scan &scan) {
   ASSERT_THROW(scan.SetTimeRange(-1000, 2000), std::runtime_error);
   ASSERT_THROW(scan.SetTimeRange(1000, -2000), std::runtime_error);
   ASSERT_THROW(scan.SetTimeRange(1000, 200), std::runtime_error);
-  ASSERT_THROW(scan.SetTimeStamp(std::numeric_limits<long>::max()),
+  ASSERT_THROW(scan.SetTimeStamp(std::numeric_limits<int64_t>::max()),
                std::runtime_error);
 }
 
@@ -179,7 +180,7 @@ TEST(Scan, Object) {
 
   // Resetting TimeRange values so that the copy construction and assignment
   // operator tests pass.
-  scan.SetTimeRange(0, std::numeric_limits<long>::max());
+  scan.SetTimeRange(0, std::numeric_limits<int64_t>::max());
   Scan scancp(scan);
   ScanMethods(scancp);
   CheckFamiliesAfterCopy(scancp);
@@ -228,7 +229,7 @@ TEST(Scan, FromGet) {
 }
 
 TEST(Scan, Exception) {
-  std::string row(std::numeric_limits<short>::max() + 1, 'X');
+  std::string row(std::numeric_limits<int16_t>::max() + 1, 'X');
   ASSERT_THROW(Scan tmp(row), std::runtime_error);
   ASSERT_THROW(Scan tmp(""), std::runtime_error);
 }
diff --git a/hbase-native-client/core/scan.cc b/hbase-native-client/core/scan.cc
index 2dd8ef2..036acfb 100644
--- a/hbase-native-client/core/scan.cc
+++ b/hbase-native-client/core/scan.cc
@@ -113,14 +113,14 @@ void Scan::SetReversed(bool reversed) { reversed_ = 
reversed; }
 
 bool Scan::IsReversed() const { return reversed_; }
 
-void Scan::SetStartRow(std::string &start_row) {
+void Scan::SetStartRow(const std::string &start_row) {
   CheckRow(start_row);
   start_row_ = start_row;
 }
 
 const std::string &Scan::StartRow() const { return start_row_; }
 
-void Scan::SetStopRow(std::string &stop_row) {
+void Scan::SetStopRow(const std::string &stop_row) {
   CheckRow(stop_row);
   stop_row_ = stop_row;
 }
@@ -167,18 +167,18 @@ Scan &Scan::SetMaxVersions(uint32_t max_versions) {
 
 int Scan::MaxVersions() const { return max_versions_; }
 
-void Scan::SetMaxResultSize(long max_result_size) {
+void Scan::SetMaxResultSize(int64_t max_result_size) {
   max_result_size_ = max_result_size;
 }
 
-long Scan::MaxResultSize() const { return max_result_size_; }
+int64_t Scan::MaxResultSize() const { return max_result_size_; }
 
-Scan &Scan::SetTimeRange(long min_stamp, long max_stamp) {
+Scan &Scan::SetTimeRange(int64_t min_stamp, int64_t max_stamp) {
   tr_.reset(new TimeRange(min_stamp, max_stamp));
   return *this;
 }
 
-Scan &Scan::SetTimeStamp(long timestamp) {
+Scan &Scan::SetTimeStamp(int64_t timestamp) {
   tr_.reset(new TimeRange(timestamp, timestamp + 1));
   return *this;
 }
@@ -186,7 +186,7 @@ Scan &Scan::SetTimeStamp(long timestamp) {
 const TimeRange &Scan::Timerange() const { return *tr_; }
 
 void Scan::CheckRow(const std::string &row) {
-  const int kMaxRowLength = std::numeric_limits<short>::max();
+  const int32_t kMaxRowLength = std::numeric_limits<int16_t>::max();
   int row_length = row.size();
   if (0 == row_length) {
     throw std::runtime_error("Row length can't be 0");
@@ -201,5 +201,4 @@ void Scan::CheckRow(const std::string &row) {
 bool Scan::HasFamilies() const { return !family_map_.empty(); }
 
 const FamilyMap &Scan::Family() const { return family_map_; }
-}
-/* namespace hbase */
+}  // namespace hbase
diff --git a/hbase-native-client/core/scan.h b/hbase-native-client/core/scan.h
index 99ed26a..e2e7f1a 100644
--- a/hbase-native-client/core/scan.h
+++ b/hbase-native-client/core/scan.h
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include <cstdint>
 #include <map>
 #include <memory>
 #include <string>
@@ -52,7 +53,7 @@ class Scan {
    * the Scanner will start from the next closest row after the specified row.
    * @param start_row - row to start scanner at or after
    */
-  Scan(const std::string &start_row);
+  explicit Scan(const std::string &start_row);
 
   /**
    * @brief Create a Scan operation for the range of rows specified.
@@ -65,7 +66,7 @@ class Scan {
    * @brief Builds a scan object with the same specs as get.
    * @param get - get to model scan after
    */
-  Scan(const Get &get);
+  explicit Scan(const Get &get);
 
   /**
    * @brief Get all columns from the specified family.Overrides previous calls
@@ -102,7 +103,7 @@ class Scan {
    * @throws std::runtime_error if start_row length is 0 or greater than
    * MAX_ROW_LENGTH
    */
-  void SetStartRow(std::string &start_row);
+  void SetStartRow(const std::string &start_row);
 
   /**
    * @brief returns start_row of the Scan.
@@ -116,7 +117,7 @@ class Scan {
    * @throws std::runtime_error if stop_row length is 0 or greater than
    * MAX_ROW_LENGTH
    */
-  void SetStopRow(std::string &stop_row);
+  void SetStopRow(const std::string &stop_row);
 
   /**
    * @brief returns stop_row of the Scan.
@@ -218,12 +219,12 @@ class Scan {
    * configured value will be used instead. (Defaults to unlimited).
    * @param The maximum result size in bytes.
    */
-  void SetMaxResultSize(long max_result_size);
+  void SetMaxResultSize(int64_t max_result_size);
 
   /**
    * @brief the maximum result size in bytes.
    */
-  long MaxResultSize() const;
+  int64_t MaxResultSize() const;
 
   /**
    * @brief Get versions of columns only within the specified timestamp range,
@@ -233,7 +234,7 @@ class Scan {
    * @param min_stamp - minimum timestamp value, inclusive.
    * @param max_stamp - maximum timestamp value, exclusive.
    */
-  Scan &SetTimeRange(long min_stamp, long max_stamp);
+  Scan &SetTimeRange(int64_t min_stamp, int64_t max_stamp);
 
   /**
    * @brief Get versions of columns with the specified timestamp. Note, default
@@ -242,7 +243,7 @@ class Scan {
    * beyond the defaut.
    * @param timestamp - version timestamp
    */
-  Scan &SetTimeStamp(long timestamp);
+  Scan &SetTimeStamp(int64_t timestamp);
 
   /**
    * @brief Return Timerange
@@ -264,7 +265,7 @@ class Scan {
   std::string stop_row_ = "";
   uint32_t max_versions_ = 1;
   int caching_ = -1;
-  long max_result_size_ = -1;
+  int64_t max_result_size_ = -1;
   bool cache_blocks_ = true;
   bool load_column_families_on_demand_ = false;
   bool reversed_ = false;
diff --git a/hbase-native-client/core/time_range-test.cc 
b/hbase-native-client/core/time_range-test.cc
index e066c57..49cb359 100644
--- a/hbase-native-client/core/time_range-test.cc
+++ b/hbase-native-client/core/time_range-test.cc
@@ -29,7 +29,7 @@ TEST(TimeRange, DefaultObject) {
   ASSERT_NO_THROW(timerange_def = new TimeRange());
 
   EXPECT_EQ(0, timerange_def->MinTimeStamp());
-  EXPECT_EQ(std::numeric_limits<long>::max(), timerange_def->MaxTimeStamp());
+  EXPECT_EQ(std::numeric_limits<int64_t>::max(), 
timerange_def->MaxTimeStamp());
   EXPECT_NE(1000, timerange_def->MinTimeStamp());
   EXPECT_NE(2000, timerange_def->MaxTimeStamp());
   delete timerange_def;
diff --git a/hbase-native-client/core/time_range.cc 
b/hbase-native-client/core/time_range.cc
index 2accc9a..8c37b29 100644
--- a/hbase-native-client/core/time_range.cc
+++ b/hbase-native-client/core/time_range.cc
@@ -26,7 +26,7 @@ namespace hbase {
 
 TimeRange::TimeRange()
     : min_timestamp_(0L),
-      max_timestamp_(std::numeric_limits<long>::max()),
+      max_timestamp_(std::numeric_limits<int64_t>::max()),
       all_time_(true) {}
 
 TimeRange::TimeRange(const TimeRange &tr) {
@@ -44,13 +44,13 @@ TimeRange &TimeRange::operator=(const TimeRange &tr) {
 
 TimeRange::~TimeRange() {}
 
-TimeRange::TimeRange(long min_timestamp) {
+TimeRange::TimeRange(int64_t min_timestamp) {
   this->min_timestamp_ = min_timestamp;
-  this->max_timestamp_ = std::numeric_limits<long>::max();
+  this->max_timestamp_ = std::numeric_limits<int64_t>::max();
   this->all_time_ = false;
 }
 
-TimeRange::TimeRange(long min_timestamp, long max_timestamp) {
+TimeRange::TimeRange(int64_t min_timestamp, int64_t max_timestamp) {
   if (min_timestamp < 0 || max_timestamp < 0) {
     throw std::runtime_error("Timestamp cannot be negative. min_timestamp: " +
                              std::to_string(min_timestamp) +
@@ -68,9 +68,9 @@ TimeRange::TimeRange(long min_timestamp, long max_timestamp) {
   this->all_time_ = false;
 }
 
-long TimeRange::MinTimeStamp() const { return this->min_timestamp_; }
+int64_t TimeRange::MinTimeStamp() const { return this->min_timestamp_; }
 
-long TimeRange::MaxTimeStamp() const { return this->max_timestamp_; }
+int64_t TimeRange::MaxTimeStamp() const { return this->max_timestamp_; }
 
 bool TimeRange::IsAllTime() const { return this->all_time_; }
-}
+}  // namespace hbase
diff --git a/hbase-native-client/core/time_range.h 
b/hbase-native-client/core/time_range.h
index 171f3ed..d645ecd 100644
--- a/hbase-native-client/core/time_range.h
+++ b/hbase-native-client/core/time_range.h
@@ -19,21 +19,24 @@
 
 #pragma once
 
+#include <cstdint>
+
 namespace hbase {
 class TimeRange {
  public:
   /**
-   * @brief  Default constructor. Represents interval [0, Long.MAX_VALUE)
+   * @brief  Default constructor. Represents interval [0,
+   * std::numeric_limits<int64_t>::max())
    * (allTime)
    */
   TimeRange();
   TimeRange(const TimeRange &tr);
   TimeRange &operator=(const TimeRange &tr);
   /**
-   * @brief Represents interval [minStamp, Long.MAX_VALUE)
+   * @brief Represents interval [minStamp, std::numeric_limits<int64_t>::max())
    * @param minStamp the minimum timestamp value, inclusive
    */
-  TimeRange(long min_timestamp);
+  explicit TimeRange(int64_t min_timestamp);
   /**
    * @brief Represents interval [minStamp, maxStamp)
    * @param minStamp the minimum timestamp, inclusive
@@ -41,15 +44,15 @@ class TimeRange {
    * @throws std::runtime_error if min_timestamp < 0 or max_timestamp < 0 or
    * max_timestamp < min_timestamp
    */
-  TimeRange(long min_timestamp, long max_timestamp);
-  long MinTimeStamp() const;
-  long MaxTimeStamp() const;
+  TimeRange(int64_t min_timestamp, int64_t max_timestamp);
+  int64_t MinTimeStamp() const;
+  int64_t MaxTimeStamp() const;
   bool IsAllTime() const;
   ~TimeRange();
 
  private:
-  long min_timestamp_;
-  long max_timestamp_;
+  int64_t min_timestamp_;
+  int64_t max_timestamp_;
   bool all_time_;
 };
-}
+}  // namespace hbase
diff --git a/hbase-native-client/serde/region-info.h 
b/hbase-native-client/serde/region-info.h
index 1b0a3fb..1f08298 100644
--- a/hbase-native-client/serde/region-info.h
+++ b/hbase-native-client/serde/region-info.h
@@ -24,6 +24,8 @@
 #include <folly/Conv.h>
 #include <boost/algorithm/string/predicate.hpp>
 
+#include <string>
+
 namespace hbase {
 namespace pb {
 template <class String>
diff --git a/hbase-native-client/serde/rpc.cc b/hbase-native-client/serde/rpc.cc
index b573738..d863d50 100644
--- a/hbase-native-client/serde/rpc.cc
+++ b/hbase-native-client/serde/rpc.cc
@@ -20,12 +20,13 @@
 #include "serde/rpc.h"
 
 #include <folly/Logging.h>
-#include <folly/Logging.h>
 #include <folly/io/Cursor.h>
 #include <google/protobuf/io/coded_stream.h>
 #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
 #include <google/protobuf/message.h>
 
+#include <utility>
+
 #include "if/HBase.pb.h"
 #include "if/RPC.pb.h"
 
diff --git a/hbase-native-client/serde/rpc.h b/hbase-native-client/serde/rpc.h
index 873d01c..05ceee9 100644
--- a/hbase-native-client/serde/rpc.h
+++ b/hbase-native-client/serde/rpc.h
@@ -114,4 +114,4 @@ class RpcSerde {
   /* data */
   uint8_t auth_type_;
 };
-}
+}  // namespace hbase
diff --git a/hbase-native-client/serde/server-name.h 
b/hbase-native-client/serde/server-name.h
index dda9bf2..41e3c77 100644
--- a/hbase-native-client/serde/server-name.h
+++ b/hbase-native-client/serde/server-name.h
@@ -21,6 +21,9 @@
 
 #include <folly/Conv.h>
 #include <folly/String.h>
+
+#include <string>
+
 #include "if/HBase.pb.h"
 
 namespace hbase {
@@ -39,5 +42,6 @@ void parseTo(String in, ServerName &out) {
   // Now keep everything after the : (delim + 1) to the end.
   out.set_port(folly::to<int>(s.substr(delim + 1)));
 }
-}
-}
+
+}  // namespace pb
+}  // namespace hbase
diff --git a/hbase-native-client/serde/table-name.h 
b/hbase-native-client/serde/table-name.h
index 707ba44..b8b7776 100644
--- a/hbase-native-client/serde/table-name.h
+++ b/hbase-native-client/serde/table-name.h
@@ -20,6 +20,7 @@
 
 #include <memory>
 #include <string>
+#include <vector>
 
 #include <folly/Conv.h>
 #include <folly/String.h>
diff --git a/hbase-native-client/serde/zk.cc b/hbase-native-client/serde/zk.cc
index 63c96ed..69b55fa 100644
--- a/hbase-native-client/serde/zk.cc
+++ b/hbase-native-client/serde/zk.cc
@@ -23,6 +23,8 @@
 #include <folly/io/IOBuf.h>
 #include <google/protobuf/message.h>
 
+#include <string>
+
 using hbase::ZkDeserializer;
 using std::runtime_error;
 using folly::IOBuf;
diff --git a/hbase-native-client/test-util/test-util.cc 
b/hbase-native-client/test-util/test-util.cc
index 88ce7c8..e355bdf 100644
--- a/hbase-native-client/test-util/test-util.cc
+++ b/hbase-native-client/test-util/test-util.cc
@@ -45,16 +45,16 @@ TestUtil::TestUtil() : temp_dir_(TestUtil::RandString()) {
   auto p = temp_dir_.path().string();
   auto cmd = std::string{"bin/start-local-hbase.sh " + p};
   auto res_code = std::system(cmd.c_str());
-  CHECK(res_code == 0);
+  CHECK_EQ(res_code, 0);
 }
 
 TestUtil::~TestUtil() {
   auto res_code = std::system("bin/stop-local-hbase.sh");
-  CHECK(res_code == 0);
+  CHECK_EQ(res_code, 0);
 }
 
 void TestUtil::RunShellCmd(const std::string &command) {
   auto cmd_string = folly::sformat("echo \"{}\" | ../bin/hbase shell", 
command);
   auto res_code = std::system(cmd_string.c_str());
-  CHECK(res_code == 0);
+  CHECK_EQ(res_code, 0);
 }

Reply via email to