You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zg...@apache.org on 2019/03/12 12:45:44 UTC
[hbase] 56/133: HBASE-17219 [C++] Reformat the code according to
the style guidelines - ADDENDUM after HBASE-17395
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 9017e0aa081f1509109b0eb209c76358bf29ef8f
Author: Enis Soztutar <en...@apache.org>
AuthorDate: Fri Jan 13 17:42:10 2017 -0800
HBASE-17219 [C++] Reformat the code according to the style guidelines - ADDENDUM after HBASE-17395
---
.../connection/client-dispatcher.cc | 4 +-
hbase-native-client/connection/client-dispatcher.h | 3 +-
hbase-native-client/connection/client-handler.cc | 10 ++--
hbase-native-client/connection/client-handler.h | 12 ++--
.../connection/connection-factory.cc | 13 ++---
.../connection/connection-factory.h | 6 +-
hbase-native-client/connection/connection-id.h | 15 ++---
.../connection/connection-pool-test.cc | 28 +++------
hbase-native-client/connection/connection-pool.cc | 9 +--
hbase-native-client/connection/connection-pool.h | 23 +++-----
hbase-native-client/connection/pipeline.h | 6 +-
hbase-native-client/connection/request.cc | 14 ++---
hbase-native-client/connection/response.h | 4 +-
hbase-native-client/connection/rpc-client.cc | 67 ++++++++--------------
hbase-native-client/connection/rpc-client.h | 29 ++++------
hbase-native-client/connection/rpc-connection.h | 8 +--
hbase-native-client/core/cell-test.cc | 21 +++----
hbase-native-client/core/cell.cc | 14 ++---
hbase-native-client/core/cell.h | 5 +-
hbase-native-client/core/client-test.cc | 6 +-
hbase-native-client/core/client.h | 4 +-
hbase-native-client/core/configuration.cc | 33 ++++-------
hbase-native-client/core/configuration.h | 9 +--
hbase-native-client/core/get-test.cc | 9 +--
hbase-native-client/core/get.cc | 15 ++---
.../core/hbase_configuration-test.cc | 45 +++++----------
.../core/hbase_configuration_loader.cc | 27 ++++-----
.../core/hbase_configuration_loader.h | 8 +--
hbase-native-client/core/location-cache.cc | 36 +++++-------
hbase-native-client/core/location-cache.h | 4 +-
hbase-native-client/core/meta-utils.cc | 10 ++--
hbase-native-client/core/meta-utils.h | 6 +-
hbase-native-client/core/region-location.h | 3 +-
hbase-native-client/core/response_converter.h | 2 +-
hbase-native-client/core/result-test.cc | 54 ++++++++---------
hbase-native-client/core/result.cc | 28 ++++-----
hbase-native-client/core/result.h | 20 +++----
hbase-native-client/core/scan-test.cc | 6 +-
hbase-native-client/core/scan.cc | 21 ++-----
hbase-native-client/core/simple-client.cc | 28 ++++-----
hbase-native-client/core/time_range.cc | 7 +--
hbase-native-client/security/BUCK | 12 ++--
hbase-native-client/security/user.h | 13 ++---
.../serde/client-deserializer-test.cc | 3 +-
hbase-native-client/serde/rpc.cc | 13 ++---
hbase-native-client/serde/rpc.h | 12 ++--
hbase-native-client/serde/server-name-test.cc | 4 +-
hbase-native-client/serde/zk.cc | 3 +-
48 files changed, 270 insertions(+), 462 deletions(-)
diff --git a/hbase-native-client/connection/client-dispatcher.cc b/hbase-native-client/connection/client-dispatcher.cc
index 0a03396..1ace99c 100644
--- a/hbase-native-client/connection/client-dispatcher.cc
+++ b/hbase-native-client/connection/client-dispatcher.cc
@@ -57,6 +57,4 @@ Future<Response> ClientDispatcher::operator()(std::unique_ptr<Request> arg) {
Future<Unit> ClientDispatcher::close() { return ClientDispatcherBase::close(); }
-Future<Unit> ClientDispatcher::close(Context *ctx) {
- return ClientDispatcherBase::close(ctx);
-}
+Future<Unit> ClientDispatcher::close(Context *ctx) { return ClientDispatcherBase::close(ctx); }
diff --git a/hbase-native-client/connection/client-dispatcher.h b/hbase-native-client/connection/client-dispatcher.h
index 67e604e..0489717 100644
--- a/hbase-native-client/connection/client-dispatcher.h
+++ b/hbase-native-client/connection/client-dispatcher.h
@@ -36,8 +36,7 @@ namespace hbase {
* future.
*/
class ClientDispatcher
- : public wangle::ClientDispatcherBase<SerializePipeline,
- std::unique_ptr<Request>, Response> {
+ : public wangle::ClientDispatcherBase<SerializePipeline, std::unique_ptr<Request>, Response> {
public:
/** Create a new ClientDispatcher */
ClientDispatcher();
diff --git a/hbase-native-client/connection/client-handler.cc b/hbase-native-client/connection/client-handler.cc
index e445444..5a6dce2 100644
--- a/hbase-native-client/connection/client-handler.cc
+++ b/hbase-native-client/connection/client-handler.cc
@@ -41,8 +41,8 @@ ClientHandler::ClientHandler(std::string user_name)
serde_(),
once_flag_(std::make_unique<std::once_flag>()),
resp_msgs_(
- make_unique<folly::AtomicHashMap<
- uint32_t, std::shared_ptr<google::protobuf::Message>>>(5000)) {}
+ make_unique<folly::AtomicHashMap<uint32_t, std::shared_ptr<google::protobuf::Message>>>(
+ 5000)) {}
void ClientHandler::read(Context *ctx, std::unique_ptr<IOBuf> buf) {
if (LIKELY(buf != nullptr)) {
@@ -51,8 +51,7 @@ void ClientHandler::read(Context *ctx, std::unique_ptr<IOBuf> buf) {
ResponseHeader header;
int used_bytes = serde_.ParseDelimited(buf.get(), &header);
- LOG(INFO) << "Read ResponseHeader size=" << used_bytes
- << " call_id=" << header.call_id()
+ LOG(INFO) << "Read ResponseHeader size=" << used_bytes << " call_id=" << header.call_id()
<< " has_exception=" << header.has_exception();
// Get the response protobuf from the map
@@ -96,6 +95,5 @@ Future<Unit> ClientHandler::write(Context *ctx, std::unique_ptr<Request> r) {
// Now store the call id to response.
resp_msgs_->insert(r->call_id(), r->resp_msg());
// Send the data down the pipeline.
- return ctx->fireWrite(
- serde_.Request(r->call_id(), r->method(), r->req_msg().get()));
+ return ctx->fireWrite(serde_.Request(r->call_id(), r->method(), r->req_msg().get()));
}
diff --git a/hbase-native-client/connection/client-handler.h b/hbase-native-client/connection/client-handler.h
index 7306c9a..d860cc1 100644
--- a/hbase-native-client/connection/client-handler.h
+++ b/hbase-native-client/connection/client-handler.h
@@ -50,9 +50,9 @@ namespace hbase {
* This class deals with sending the connection header and preamble
* on first request.
*/
-class ClientHandler : public wangle::Handler<std::unique_ptr<folly::IOBuf>,
- Response, std::unique_ptr<Request>,
- std::unique_ptr<folly::IOBuf>> {
+class ClientHandler
+ : public wangle::Handler<std::unique_ptr<folly::IOBuf>, Response, std::unique_ptr<Request>,
+ std::unique_ptr<folly::IOBuf>> {
public:
/**
* Create the handler
@@ -70,8 +70,7 @@ class ClientHandler : public wangle::Handler<std::unique_ptr<folly::IOBuf>,
/**
* Write the data down the wire.
*/
- folly::Future<folly::Unit> write(Context *ctx,
- std::unique_ptr<Request> r) override;
+ folly::Future<folly::Unit> write(Context *ctx, std::unique_ptr<Request> r) override;
private:
std::unique_ptr<std::once_flag> once_flag_;
@@ -79,8 +78,7 @@ class ClientHandler : public wangle::Handler<std::unique_ptr<folly::IOBuf>,
RpcSerde serde_;
// in flight requests
- std::unique_ptr<folly::AtomicHashMap<
- uint32_t, std::shared_ptr<google::protobuf::Message>>>
+ std::unique_ptr<folly::AtomicHashMap<uint32_t, std::shared_ptr<google::protobuf::Message>>>
resp_msgs_;
};
} // namespace hbase
diff --git a/hbase-native-client/connection/connection-factory.cc b/hbase-native-client/connection/connection-factory.cc
index beec6d56..ff83212 100644
--- a/hbase-native-client/connection/connection-factory.cc
+++ b/hbase-native-client/connection/connection-factory.cc
@@ -26,13 +26,10 @@
using namespace folly;
using namespace hbase;
-ConnectionFactory::ConnectionFactory(
- std::shared_ptr<wangle::IOThreadPoolExecutor> io_pool)
- : io_pool_(io_pool),
- pipeline_factory_(std::make_shared<RpcPipelineFactory>()) {}
+ConnectionFactory::ConnectionFactory(std::shared_ptr<wangle::IOThreadPoolExecutor> io_pool)
+ : io_pool_(io_pool), pipeline_factory_(std::make_shared<RpcPipelineFactory>()) {}
-std::shared_ptr<wangle::ClientBootstrap<SerializePipeline>>
-ConnectionFactory::MakeBootstrap() {
+std::shared_ptr<wangle::ClientBootstrap<SerializePipeline>> ConnectionFactory::MakeBootstrap() {
auto client = std::make_shared<wangle::ClientBootstrap<SerializePipeline>>();
client->group(io_pool_);
client->pipelineFactory(pipeline_factory_);
@@ -40,8 +37,8 @@ ConnectionFactory::MakeBootstrap() {
return client;
}
std::shared_ptr<HBaseService> ConnectionFactory::Connect(
- std::shared_ptr<wangle::ClientBootstrap<SerializePipeline>> client,
- const std::string &hostname, int port) {
+ std::shared_ptr<wangle::ClientBootstrap<SerializePipeline>> client, const std::string &hostname,
+ int port) {
// Yes this will block however it makes dealing with connection pool soooooo
// much nicer.
// TODO see about using shared promise for this.
diff --git a/hbase-native-client/connection/connection-factory.h b/hbase-native-client/connection/connection-factory.h
index 17d9941..da44c35 100644
--- a/hbase-native-client/connection/connection-factory.h
+++ b/hbase-native-client/connection/connection-factory.h
@@ -40,16 +40,14 @@ class ConnectionFactory {
* Constructor.
* There should only be one ConnectionFactory per client.
*/
- explicit ConnectionFactory(
- std::shared_ptr<wangle::IOThreadPoolExecutor> io_pool);
+ explicit ConnectionFactory(std::shared_ptr<wangle::IOThreadPoolExecutor> io_pool);
/** Default Desctructor */
virtual ~ConnectionFactory() = default;
/**
* Create a BootStrap from which a connection can be made.
*/
- virtual std::shared_ptr<wangle::ClientBootstrap<SerializePipeline>>
- MakeBootstrap();
+ virtual std::shared_ptr<wangle::ClientBootstrap<SerializePipeline>> MakeBootstrap();
/**
* Connect a ClientBootstrap to a server and return the pipeline.
diff --git a/hbase-native-client/connection/connection-id.h b/hbase-native-client/connection/connection-id.h
index 62fe222..78b9780 100644
--- a/hbase-native-client/connection/connection-id.h
+++ b/hbase-native-client/connection/connection-id.h
@@ -21,9 +21,9 @@
#include "if/HBase.pb.h"
#include "security/user.h"
+#include <boost/functional/hash.hpp>
#include <memory>
#include <utility>
-#include <boost/functional/hash.hpp>
using hbase::pb::ServerName;
using hbase::security::User;
@@ -34,12 +34,11 @@ class ConnectionId {
ConnectionId(const std::string &host, uint16_t port)
: ConnectionId(host, port, User::defaultUser(), "") {}
- ConnectionId(const std::string &host, uint16_t port,
- std::shared_ptr<User> user)
+ ConnectionId(const std::string &host, uint16_t port, std::shared_ptr<User> user)
: ConnectionId(host, port, user, "") {}
- ConnectionId(const std::string &host, uint16_t port,
- std::shared_ptr<User> user, const std::string &service_name)
+ ConnectionId(const std::string &host, uint16_t port, std::shared_ptr<User> user,
+ const std::string &service_name)
: user_(user), service_name_(service_name), host_(host), port_(port) {}
virtual ~ConnectionId() = default;
@@ -66,11 +65,9 @@ struct ConnectionIdEquals {
}
private:
- bool userEquals(const std::shared_ptr<User> &lhs,
- const std::shared_ptr<User> &rhs) const {
+ bool userEquals(const std::shared_ptr<User> &lhs, const std::shared_ptr<User> &rhs) const {
return lhs == nullptr ? rhs == nullptr
- : (rhs == nullptr ? false : lhs->user_name() ==
- rhs->user_name());
+ : (rhs == nullptr ? false : lhs->user_name() == rhs->user_name());
}
};
diff --git a/hbase-native-client/connection/connection-pool-test.cc b/hbase-native-client/connection/connection-pool-test.cc
index 4547b30..0930095 100644
--- a/hbase-native-client/connection/connection-pool-test.cc
+++ b/hbase-native-client/connection/connection-pool-test.cc
@@ -17,9 +17,9 @@
*
*/
-#include "connection/connection-id.h"
#include "connection/connection-pool.h"
#include "connection/connection-factory.h"
+#include "connection/connection-id.h"
#include "if/HBase.pb.h"
#include "serde/server-name.h"
@@ -37,12 +37,10 @@ using hbase::ConnectionId;
class MockConnectionFactory : public ConnectionFactory {
public:
MockConnectionFactory() : ConnectionFactory(nullptr) {}
- MOCK_METHOD0(MakeBootstrap,
- std::shared_ptr<wangle::ClientBootstrap<SerializePipeline>>());
- MOCK_METHOD3(Connect,
- std::shared_ptr<HBaseService>(
- std::shared_ptr<wangle::ClientBootstrap<SerializePipeline>>,
- const std::string &hostname, int port));
+ MOCK_METHOD0(MakeBootstrap, std::shared_ptr<wangle::ClientBootstrap<SerializePipeline>>());
+ MOCK_METHOD3(Connect, std::shared_ptr<HBaseService>(
+ std::shared_ptr<wangle::ClientBootstrap<SerializePipeline>>,
+ const std::string &hostname, int port));
};
class MockBootstrap : public wangle::ClientBootstrap<SerializePipeline> {};
@@ -69,12 +67,8 @@ TEST(TestConnectionPool, TestOnlyCreateOnce) {
auto mock_cf = std::make_shared<MockConnectionFactory>();
uint32_t port{999};
- EXPECT_CALL((*mock_cf), Connect(_, _, _))
- .Times(1)
- .WillRepeatedly(Return(mock_service));
- EXPECT_CALL((*mock_cf), MakeBootstrap())
- .Times(1)
- .WillRepeatedly(Return(mock_boot));
+ EXPECT_CALL((*mock_cf), Connect(_, _, _)).Times(1).WillRepeatedly(Return(mock_service));
+ EXPECT_CALL((*mock_cf), MakeBootstrap()).Times(1).WillRepeatedly(Return(mock_boot));
ConnectionPool cp{mock_cf};
auto remote_id = std::make_shared<ConnectionId>(hostname, port);
@@ -92,12 +86,8 @@ TEST(TestConnectionPool, TestOnlyCreateMultipleDispose) {
auto mock_service = std::make_shared<MockService>();
auto mock_cf = std::make_shared<MockConnectionFactory>();
- EXPECT_CALL((*mock_cf), Connect(_, _, _))
- .Times(2)
- .WillRepeatedly(Return(mock_service));
- EXPECT_CALL((*mock_cf), MakeBootstrap())
- .Times(2)
- .WillRepeatedly(Return(mock_boot));
+ EXPECT_CALL((*mock_cf), Connect(_, _, _)).Times(2).WillRepeatedly(Return(mock_service));
+ EXPECT_CALL((*mock_cf), MakeBootstrap()).Times(2).WillRepeatedly(Return(mock_boot));
ConnectionPool cp{mock_cf};
{
diff --git a/hbase-native-client/connection/connection-pool.cc b/hbase-native-client/connection/connection-pool.cc
index ee14c9d..07518c5 100644
--- a/hbase-native-client/connection/connection-pool.cc
+++ b/hbase-native-client/connection/connection-pool.cc
@@ -33,8 +33,7 @@ using hbase::HBaseService;
using folly::SharedMutexWritePriority;
using folly::SocketAddress;
-ConnectionPool::ConnectionPool(
- std::shared_ptr<wangle::IOThreadPoolExecutor> io_executor)
+ConnectionPool::ConnectionPool(std::shared_ptr<wangle::IOThreadPoolExecutor> io_executor)
: cf_(std::make_shared<ConnectionFactory>(io_executor)),
clients_(),
connections_(),
@@ -95,8 +94,7 @@ std::shared_ptr<RpcConnection> ConnectionPool::GetNewConnection(
/* create new connection */
auto clientBootstrap = cf_->MakeBootstrap();
- auto dispatcher =
- cf_->Connect(clientBootstrap, remote_id->host(), remote_id->port());
+ auto dispatcher = cf_->Connect(clientBootstrap, remote_id->host(), remote_id->port());
auto conneciton = std::make_shared<RpcConnection>(remote_id, dispatcher);
@@ -118,5 +116,4 @@ void ConnectionPool::Close(std::shared_ptr<ConnectionId> remote_id) {
connections_.erase(found);
}
-void ConnectionPool::Close() {
-}
+void ConnectionPool::Close() {}
diff --git a/hbase-native-client/connection/connection-pool.h b/hbase-native-client/connection/connection-pool.h
index 5101c68..1f2a182 100644
--- a/hbase-native-client/connection/connection-pool.h
+++ b/hbase-native-client/connection/connection-pool.h
@@ -30,7 +30,6 @@
#include "connection/service.h"
#include "if/HBase.pb.h"
-
using hbase::ConnectionId;
using hbase::ConnectionIdEquals;
using hbase::ConnectionIdHash;
@@ -47,8 +46,7 @@ namespace hbase {
class ConnectionPool {
public:
/** Create connection pool wit default connection factory */
- explicit ConnectionPool(
- std::shared_ptr<wangle::IOThreadPoolExecutor> io_executor);
+ explicit ConnectionPool(std::shared_ptr<wangle::IOThreadPoolExecutor> io_executor);
/**
* Desctructor.
@@ -67,8 +65,7 @@ class ConnectionPool {
* Get a connection to the server name. Start time is ignored.
* This can be a blocking operation for a short time.
*/
- std::shared_ptr<RpcConnection> GetConnection(
- std::shared_ptr<ConnectionId> remote_id);
+ std::shared_ptr<RpcConnection> GetConnection(std::shared_ptr<ConnectionId> remote_id);
/**
* Close/remove a connection.
@@ -81,18 +78,14 @@ class ConnectionPool {
void Close();
private:
- std::shared_ptr<RpcConnection> GetCachedConnection(
- std::shared_ptr<ConnectionId> remote_id);
- std::shared_ptr<RpcConnection> GetNewConnection(
- std::shared_ptr<ConnectionId> remote_id);
+ std::shared_ptr<RpcConnection> GetCachedConnection(std::shared_ptr<ConnectionId> remote_id);
+ std::shared_ptr<RpcConnection> GetNewConnection(std::shared_ptr<ConnectionId> remote_id);
+ std::unordered_map<std::shared_ptr<ConnectionId>, std::shared_ptr<RpcConnection>,
+ ConnectionIdHash, ConnectionIdEquals>
+ connections_;
std::unordered_map<std::shared_ptr<ConnectionId>,
- std::shared_ptr<RpcConnection>, ConnectionIdHash,
+ std::shared_ptr<wangle::ClientBootstrap<SerializePipeline>>, ConnectionIdHash,
ConnectionIdEquals>
- connections_;
- std::unordered_map<
- std::shared_ptr<ConnectionId>,
- std::shared_ptr<wangle::ClientBootstrap<SerializePipeline>>,
- ConnectionIdHash, ConnectionIdEquals>
clients_;
folly::SharedMutexWritePriority map_mutex_;
std::shared_ptr<ConnectionFactory> cf_;
diff --git a/hbase-native-client/connection/pipeline.h b/hbase-native-client/connection/pipeline.h
index c4f3bbb..343219d 100644
--- a/hbase-native-client/connection/pipeline.h
+++ b/hbase-native-client/connection/pipeline.h
@@ -30,8 +30,7 @@
namespace hbase {
/** Pipeline to turn IOBuf into requests */
-using SerializePipeline =
- wangle::Pipeline<folly::IOBufQueue &, std::unique_ptr<Request>>;
+using SerializePipeline = wangle::Pipeline<folly::IOBufQueue &, std::unique_ptr<Request>>;
/**
* Factory to create new pipelines for HBase RPC's.
@@ -52,8 +51,7 @@ class RpcPipelineFactory : public wangle::PipelineFactory<SerializePipeline> {
* - Length Field Based Frame Decoder
* - Client Handler
*/
- SerializePipeline::Ptr newPipeline(
- std::shared_ptr<folly::AsyncTransportWrapper> sock) override;
+ SerializePipeline::Ptr newPipeline(std::shared_ptr<folly::AsyncTransportWrapper> sock) override;
private:
UserUtil user_util_;
diff --git a/hbase-native-client/connection/request.cc b/hbase-native-client/connection/request.cc
index d4a4603..189130e 100644
--- a/hbase-native-client/connection/request.cc
+++ b/hbase-native-client/connection/request.cc
@@ -24,22 +24,18 @@
using namespace hbase;
Request::Request(std::shared_ptr<google::protobuf::Message> req,
- std::shared_ptr<google::protobuf::Message> resp,
- std::string method)
+ std::shared_ptr<google::protobuf::Message> resp, std::string method)
: req_msg_(req), resp_msg_(resp), method_(method), call_id_(0) {}
std::unique_ptr<Request> Request::get() {
return std::make_unique<Request>(std::make_shared<hbase::pb::GetRequest>(),
- std::make_shared<hbase::pb::GetResponse>(),
- "Get");
+ std::make_shared<hbase::pb::GetResponse>(), "Get");
}
std::unique_ptr<Request> Request::mutate() {
- return std::make_unique<Request>(
- std::make_shared<hbase::pb::MutateRequest>(),
- std::make_shared<hbase::pb::MutateResponse>(), "Mutate");
+ return std::make_unique<Request>(std::make_shared<hbase::pb::MutateRequest>(),
+ std::make_shared<hbase::pb::MutateResponse>(), "Mutate");
}
std::unique_ptr<Request> Request::scan() {
return std::make_unique<Request>(std::make_shared<hbase::pb::ScanRequest>(),
- std::make_shared<hbase::pb::ScanResponse>(),
- "Scan");
+ std::make_shared<hbase::pb::ScanResponse>(), "Scan");
}
diff --git a/hbase-native-client/connection/response.h b/hbase-native-client/connection/response.h
index f032d09..560387c 100644
--- a/hbase-native-client/connection/response.h
+++ b/hbase-native-client/connection/response.h
@@ -55,9 +55,7 @@ class Response {
* The caller is reponsible for knowing the type. In practice the call id is
* used to figure out the type.
*/
- std::shared_ptr<google::protobuf::Message> resp_msg() const {
- return resp_msg_;
- }
+ std::shared_ptr<google::protobuf::Message> resp_msg() const { return resp_msg_; }
/** Set the response message. */
void set_resp_msg(std::shared_ptr<google::protobuf::Message> response) {
diff --git a/hbase-native-client/connection/rpc-client.cc b/hbase-native-client/connection/rpc-client.cc
index 3f0cfaf..9cfefb8 100644
--- a/hbase-native-client/connection/rpc-client.cc
+++ b/hbase-native-client/connection/rpc-client.cc
@@ -28,41 +28,32 @@ namespace hbase {
class RpcChannelImplementation : public AbstractRpcChannel {
public:
- RpcChannelImplementation(std::shared_ptr<RpcClient> rpc_client,
- const std::string& host, uint16_t port,
- std::shared_ptr<User> ticket, int rpc_timeout)
+ RpcChannelImplementation(std::shared_ptr<RpcClient> rpc_client, const std::string& host,
+ uint16_t port, std::shared_ptr<User> ticket, int rpc_timeout)
: AbstractRpcChannel(rpc_client, host, port, ticket, rpc_timeout) {}
- void CallMethod(const MethodDescriptor* method, RpcController* controller,
- const Message* request, Message* response,
- Closure* done) override {
- rpc_client_->CallMethod(method, controller, request, response, done, host_,
- port_, ticket_);
+ void CallMethod(const MethodDescriptor* method, RpcController* controller, const Message* request,
+ Message* response, Closure* done) override {
+ rpc_client_->CallMethod(method, controller, request, response, done, host_, port_, ticket_);
}
};
} // namespace hbase
RpcClient::RpcClient() {
- io_executor_ = std::make_shared<wangle::IOThreadPoolExecutor>(
- sysconf(_SC_NPROCESSORS_ONLN));
+ io_executor_ = std::make_shared<wangle::IOThreadPoolExecutor>(sysconf(_SC_NPROCESSORS_ONLN));
cp_ = std::make_shared<ConnectionPool>(io_executor_);
}
-void RpcClient::Close() {
- io_executor_->stop();
-}
+void RpcClient::Close() { io_executor_->stop(); }
-std::shared_ptr<Response> RpcClient::SyncCall(const std::string& host,
- uint16_t port,
+std::shared_ptr<Response> RpcClient::SyncCall(const std::string& host, uint16_t port,
std::unique_ptr<Request> req,
std::shared_ptr<User> ticket) {
- return std::make_shared<Response>(
- AsyncCall(host, port, std::move(req), ticket).get());
+ return std::make_shared<Response>(AsyncCall(host, port, std::move(req), ticket).get());
}
-std::shared_ptr<Response> RpcClient::SyncCall(const std::string& host,
- uint16_t port,
+std::shared_ptr<Response> RpcClient::SyncCall(const std::string& host, uint16_t port,
std::unique_ptr<Request> req,
std::shared_ptr<User> ticket,
const std::string& service_name) {
@@ -70,54 +61,44 @@ std::shared_ptr<Response> RpcClient::SyncCall(const std::string& host,
AsyncCall(host, port, std::move(req), ticket, service_name).get());
}
-folly::Future<Response> RpcClient::AsyncCall(const std::string& host,
- uint16_t port,
+folly::Future<Response> RpcClient::AsyncCall(const std::string& host, uint16_t port,
std::unique_ptr<Request> req,
std::shared_ptr<User> ticket) {
auto remote_id = std::make_shared<ConnectionId>(host, port, ticket);
return GetConnection(remote_id)->SendRequest(std::move(req));
}
-folly::Future<Response> RpcClient::AsyncCall(const std::string& host,
- uint16_t port,
+folly::Future<Response> RpcClient::AsyncCall(const std::string& host, uint16_t port,
std::unique_ptr<Request> req,
std::shared_ptr<User> ticket,
const std::string& service_name) {
- auto remote_id =
- std::make_shared<ConnectionId>(host, port, ticket, service_name);
+ auto remote_id = std::make_shared<ConnectionId>(host, port, ticket, service_name);
return GetConnection(remote_id)->SendRequest(std::move(req));
}
-std::shared_ptr<RpcConnection> RpcClient::GetConnection(
- std::shared_ptr<ConnectionId> remote_id) {
+std::shared_ptr<RpcConnection> RpcClient::GetConnection(std::shared_ptr<ConnectionId> remote_id) {
return cp_->GetConnection(remote_id);
}
-std::shared_ptr<RpcChannel> RpcClient::CreateRpcChannel(
- const std::string& host, uint16_t port, std::shared_ptr<User> ticket,
- int rpc_timeout) {
- std::shared_ptr<RpcChannelImplementation> channel =
- std::make_shared<RpcChannelImplementation>(shared_from_this(), host, port,
- ticket, rpc_timeout);
+std::shared_ptr<RpcChannel> RpcClient::CreateRpcChannel(const std::string& host, uint16_t port,
+ std::shared_ptr<User> ticket,
+ int rpc_timeout) {
+ std::shared_ptr<RpcChannelImplementation> channel = std::make_shared<RpcChannelImplementation>(
+ shared_from_this(), host, port, ticket, rpc_timeout);
/* static_pointer_cast is safe since RpcChannelImplementation derives
* from RpcChannel, otherwise, dynamic_pointer_cast should be used. */
return std::static_pointer_cast<RpcChannel>(channel);
}
-void RpcClient::CallMethod(const MethodDescriptor* method,
- RpcController* controller, const Message* req_msg,
- Message* resp_msg, Closure* done,
- const std::string& host, uint16_t port,
- std::shared_ptr<User> ticket) {
+void RpcClient::CallMethod(const MethodDescriptor* method, RpcController* controller,
+ const Message* req_msg, Message* resp_msg, Closure* done,
+ const std::string& host, uint16_t port, std::shared_ptr<User> ticket) {
std::shared_ptr<Message> shared_req(const_cast<Message*>(req_msg));
std::shared_ptr<Message> shared_resp(resp_msg);
- std::unique_ptr<Request> req =
- std::make_unique<Request>(shared_req, shared_resp, method->name());
+ std::unique_ptr<Request> req = std::make_unique<Request>(shared_req, shared_resp, method->name());
AsyncCall(host, port, std::move(req), ticket, method->service()->name())
- .then([done, this](Response resp) {
- done->Run();
- });
+ .then([done, this](Response resp) { done->Run(); });
}
diff --git a/hbase-native-client/connection/rpc-client.h b/hbase-native-client/connection/rpc-client.h
index dbf857d..407d588 100644
--- a/hbase-native-client/connection/rpc-client.h
+++ b/hbase-native-client/connection/rpc-client.h
@@ -53,41 +53,35 @@ class RpcClient : public std::enable_shared_from_this<RpcClient> {
virtual ~RpcClient() { Close(); }
- virtual std::shared_ptr<Response> SyncCall(const std::string &host,
- uint16_t port,
+ virtual std::shared_ptr<Response> SyncCall(const std::string &host, uint16_t port,
std::unique_ptr<Request> req,
std::shared_ptr<User> ticket);
- virtual std::shared_ptr<Response> SyncCall(const std::string &host,
- uint16_t port,
+ virtual std::shared_ptr<Response> SyncCall(const std::string &host, uint16_t port,
std::unique_ptr<Request> req,
std::shared_ptr<User> ticket,
const std::string &service_name);
- virtual folly::Future<Response> AsyncCall(const std::string &host,
- uint16_t port,
+ virtual folly::Future<Response> AsyncCall(const std::string &host, uint16_t port,
std::unique_ptr<Request> req,
std::shared_ptr<User> ticket);
- virtual folly::Future<Response> AsyncCall(const std::string &host,
- uint16_t port,
+ virtual folly::Future<Response> AsyncCall(const std::string &host, uint16_t port,
std::unique_ptr<Request> req,
std::shared_ptr<User> ticket,
const std::string &service_name);
virtual void Close();
- virtual std::shared_ptr<RpcChannel> CreateRpcChannel(
- const std::string &host, uint16_t port, std::shared_ptr<User> ticket,
- int rpc_timeout);
+ virtual std::shared_ptr<RpcChannel> CreateRpcChannel(const std::string &host, uint16_t port,
+ std::shared_ptr<User> ticket,
+ int rpc_timeout);
private:
- void CallMethod(const MethodDescriptor *method, RpcController *controller,
- const Message *req_msg, Message *resp_msg, Closure *done,
- const std::string &host, uint16_t port,
+ void CallMethod(const MethodDescriptor *method, RpcController *controller, const Message *req_msg,
+ Message *resp_msg, Closure *done, const std::string &host, uint16_t port,
std::shared_ptr<User> ticket);
- std::shared_ptr<RpcConnection> GetConnection(
- std::shared_ptr<ConnectionId> remote_id);
+ std::shared_ptr<RpcConnection> GetConnection(std::shared_ptr<ConnectionId> remote_id);
private:
std::shared_ptr<ConnectionPool> cp_;
@@ -96,8 +90,7 @@ class RpcClient : public std::enable_shared_from_this<RpcClient> {
class AbstractRpcChannel : public RpcChannel {
public:
- AbstractRpcChannel(std::shared_ptr<RpcClient> rpc_client,
- const std::string &host, uint16_t port,
+ AbstractRpcChannel(std::shared_ptr<RpcClient> rpc_client, const std::string &host, uint16_t port,
std::shared_ptr<User> ticket, int rpc_timeout)
: rpc_client_(rpc_client),
host_(host),
diff --git a/hbase-native-client/connection/rpc-connection.h b/hbase-native-client/connection/rpc-connection.h
index 2e06ec3..e2500b2 100644
--- a/hbase-native-client/connection/rpc-connection.h
+++ b/hbase-native-client/connection/rpc-connection.h
@@ -37,13 +37,9 @@ class RpcConnection {
virtual ~RpcConnection() { Close(); }
- virtual std::shared_ptr<ConnectionId> remote_id() const {
- return connection_id_;
- }
+ virtual std::shared_ptr<ConnectionId> remote_id() const { return connection_id_; }
- virtual std::shared_ptr<HBaseService> get_service() const {
- return hbase_service_;
- }
+ virtual std::shared_ptr<HBaseService> get_service() const { return hbase_service_; }
virtual folly::Future<Response> SendRequest(std::unique_ptr<Request> req) {
return (*hbase_service_)(std::move(req));
diff --git a/hbase-native-client/core/cell-test.cc b/hbase-native-client/core/cell-test.cc
index 53574e8..fb4d033 100644
--- a/hbase-native-client/core/cell-test.cc
+++ b/hbase-native-client/core/cell-test.cc
@@ -32,8 +32,7 @@ TEST(CellTest, CellFailureTest) {
std::string value = "value";
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));
+ std::unique_ptr<Cell> cell(new Cell(row, family, column, timestamp, value, cell_type));
if (cell.get()) {
EXPECT_NE("row-value", cell.get()->Row());
EXPECT_NE("family-value", cell.get()->Family());
@@ -51,8 +50,7 @@ TEST(CellTest, CellSuceessTest) {
std::string value = "value-value";
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));
+ const std::unique_ptr<Cell> cell(new Cell(row, family, column, timestamp, value, cell_type));
if (cell.get()) {
EXPECT_EQ(row, cell.get()->Row());
EXPECT_EQ(family, cell.get()->Family());
@@ -74,8 +72,7 @@ TEST(CellTest, MultipleCellsTest) {
row += std::to_string(i);
value += std::to_string(i);
CellType cell_type = CellType::PUT;
- const Cell *cell =
- new Cell(row, family, column, timestamp, value, cell_type);
+ const Cell *cell = new Cell(row, family, column, timestamp, value, cell_type);
cells.push_back(cell);
}
int i = 0;
@@ -105,8 +102,7 @@ TEST(CellTest, CellRowTest) {
std::string value = "";
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));
+ std::unique_ptr<Cell> cell(new Cell(row, family, column, timestamp, value, cell_type));
if (cell.get()) {
EXPECT_EQ(row, cell.get()->Row());
EXPECT_EQ(family, cell.get()->Family());
@@ -124,8 +120,7 @@ TEST(CellTest, CellRowFamilyTest) {
std::string value = "";
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));
+ const std::unique_ptr<Cell> cell(new Cell(row, family, column, timestamp, value, cell_type));
if (cell.get()) {
EXPECT_EQ(row, cell.get()->Row());
EXPECT_EQ(family, cell.get()->Family());
@@ -143,8 +138,7 @@ TEST(CellTest, CellRowFamilyValueTest) {
std::string value = "only-value";
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));
+ const std::unique_ptr<Cell> cell(new Cell(row, family, column, timestamp, value, cell_type));
if (cell.get()) {
EXPECT_EQ(row, cell.get()->Row());
EXPECT_EQ(family, cell.get()->Family());
@@ -162,8 +156,7 @@ TEST(CellTest, CellRowFamilyColumnValueTest) {
std::string value = "only-value";
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));
+ std::unique_ptr<Cell> cell(new Cell(row, family, column, timestamp, value, cell_type));
if (cell.get()) {
EXPECT_EQ(row, cell.get()->Row());
EXPECT_EQ(family, cell.get()->Family());
diff --git a/hbase-native-client/core/cell.cc b/hbase-native-client/core/cell.cc
index 3102e53..4982406 100644
--- a/hbase-native-client/core/cell.cc
+++ b/hbase-native-client/core/cell.cc
@@ -22,9 +22,8 @@
namespace hbase {
-Cell::Cell(const std::string &row, const std::string &family,
- const std::string &qualifier, const int64_t timestamp,
- const std::string &value, const hbase::CellType &cell_type)
+Cell::Cell(const std::string &row, const std::string &family, const std::string &qualifier,
+ const int64_t timestamp, const std::string &value, const hbase::CellType &cell_type)
: row_(row),
family_(family),
qualifier_(qualifier),
@@ -32,14 +31,11 @@ Cell::Cell(const std::string &row, const std::string &family,
cell_type_(cell_type),
value_(value),
sequence_id_(0) {
- if (0 == row.size())
- throw std::runtime_error("Row size should be greater than 0");
+ if (0 == row.size()) throw std::runtime_error("Row size should be greater than 0");
- if (0 == family.size())
- throw std::runtime_error("Column family size should be greater than 0");
+ if (0 == family.size()) throw std::runtime_error("Column family size should be greater than 0");
- if (0 >= timestamp)
- throw std::runtime_error("Timestamp should be greater than 0");
+ if (0 >= timestamp) throw std::runtime_error("Timestamp should be greater than 0");
}
Cell::~Cell() {}
diff --git a/hbase-native-client/core/cell.h b/hbase-native-client/core/cell.h
index f55655c..5a39dc3 100644
--- a/hbase-native-client/core/cell.h
+++ b/hbase-native-client/core/cell.h
@@ -36,9 +36,8 @@ enum CellType {
class Cell {
public:
- Cell(const std::string &row, const std::string &family,
- const std::string &qualifier, const int64_t timestamp,
- const std::string &value, const hbase::CellType &cell_type);
+ Cell(const std::string &row, const std::string &family, 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;
diff --git a/hbase-native-client/core/client-test.cc b/hbase-native-client/core/client-test.cc
index 0fe0225..28eec6f 100644
--- a/hbase-native-client/core/client-test.cc
+++ b/hbase-native-client/core/client-test.cc
@@ -17,8 +17,8 @@
*
*/
-#include <gtest/gtest.h>
#include "core/client.h"
+#include <gtest/gtest.h>
#include "core/configuration.h"
#include "core/get.h"
#include "core/hbase_configuration_loader.h"
@@ -84,9 +84,7 @@ const std::string ClientTest::kHBaseXmlData(
"the License.\n "
"*/\n-->\n<configuration>\n\n</configuration>");
-TEST(Client, EmptyConfigurationPassedToClient) {
- ASSERT_ANY_THROW(hbase::Client client);
-}
+TEST(Client, EmptyConfigurationPassedToClient) { ASSERT_ANY_THROW(hbase::Client client); }
TEST(Client, ConfigurationPassedToClient) {
// Remove already configured env if present.
diff --git a/hbase-native-client/core/client.h b/hbase-native-client/core/client.h
index 2bb506b..da71624 100644
--- a/hbase-native-client/core/client.h
+++ b/hbase-native-client/core/client.h
@@ -27,13 +27,13 @@
#include <memory>
#include <string>
+#include "connection/rpc-client.h"
#include "core/configuration.h"
#include "core/hbase_configuration_loader.h"
#include "core/location-cache.h"
-#include "connection/rpc-client.h"
#include "core/table.h"
-#include "serde/table-name.h"
#include "if/Cell.pb.h"
+#include "serde/table-name.h"
using hbase::pb::TableName;
diff --git a/hbase-native-client/core/configuration.cc b/hbase-native-client/core/configuration.cc
index 134f05f..bd582d8 100644
--- a/hbase-native-client/core/configuration.cc
+++ b/hbase-native-client/core/configuration.cc
@@ -28,13 +28,11 @@
namespace hbase {
-Configuration::Configuration(ConfigMap &config_map)
- : hb_property_(std::move(config_map)) {}
+Configuration::Configuration(ConfigMap &config_map) : hb_property_(std::move(config_map)) {}
Configuration::~Configuration() {}
-size_t Configuration::IsSubVariable(const std::string &expr,
- std::string &sub_variable) const {
+size_t Configuration::IsSubVariable(const std::string &expr, std::string &sub_variable) const {
size_t start_pos = expr.find("${");
if (std::string::npos != start_pos) {
size_t pos_next = expr.find("}", start_pos + 1);
@@ -57,8 +55,7 @@ std::string Configuration::SubstituteVars(const std::string &expr) const {
if (start_pos != std::string::npos) {
// We are blindly checking for environment property at first.
// If we don't get any value from GetEnv, check in hbase-site.xml.
- value_to_be_replaced =
- GetEnv(var).value_or(GetProperty(var).value_or(""));
+ value_to_be_replaced = GetEnv(var).value_or(GetProperty(var).value_or(""));
// we haven't found any value yet so we are returning eval
if (0 == value_to_be_replaced.size()) {
@@ -148,8 +145,7 @@ optional<std::string> Configuration::Get(const std::string &key) const {
}
}
-std::string Configuration::Get(const std::string &key,
- const std::string &default_value) const {
+std::string Configuration::Get(const std::string &key, const std::string &default_value) const {
return Get(key).value_or(default_value);
}
@@ -157,8 +153,7 @@ optional<int32_t> Configuration::GetInt(const std::string &key) const {
optional<std::string> raw = Get(key);
if (raw) {
try {
- return std::experimental::make_optional(
- boost::lexical_cast<int32_t>(*raw));
+ return std::experimental::make_optional(boost::lexical_cast<int32_t>(*raw));
} catch (const boost::bad_lexical_cast &blex) {
throw std::runtime_error(blex.what());
}
@@ -166,8 +161,7 @@ optional<int32_t> Configuration::GetInt(const std::string &key) const {
return optional<int32_t>();
}
-int32_t Configuration::GetInt(const std::string &key,
- int32_t default_value) const {
+int32_t Configuration::GetInt(const std::string &key, int32_t default_value) const {
return GetInt(key).value_or(default_value);
}
@@ -175,8 +169,7 @@ optional<int64_t> Configuration::GetLong(const std::string &key) const {
optional<std::string> raw = Get(key);
if (raw) {
try {
- return std::experimental::make_optional(
- boost::lexical_cast<int64_t>(*raw));
+ return std::experimental::make_optional(boost::lexical_cast<int64_t>(*raw));
} catch (const boost::bad_lexical_cast &blex) {
throw std::runtime_error(blex.what());
}
@@ -184,8 +177,7 @@ optional<int64_t> Configuration::GetLong(const std::string &key) const {
return optional<int64_t>();
}
-int64_t Configuration::GetLong(const std::string &key,
- int64_t default_value) const {
+int64_t Configuration::GetLong(const std::string &key, int64_t default_value) const {
return GetLong(key).value_or(default_value);
}
@@ -193,8 +185,7 @@ optional<double> Configuration::GetDouble(const std::string &key) const {
optional<std::string> raw = Get(key);
if (raw) {
try {
- return std::experimental::make_optional(
- boost::lexical_cast<double>(*raw));
+ return std::experimental::make_optional(boost::lexical_cast<double>(*raw));
} catch (const boost::bad_lexical_cast &blex) {
throw std::runtime_error(blex.what());
}
@@ -202,8 +193,7 @@ optional<double> Configuration::GetDouble(const std::string &key) const {
return optional<double>();
}
-double Configuration::GetDouble(const std::string &key,
- double default_value) const {
+double Configuration::GetDouble(const std::string &key, double default_value) const {
return GetDouble(key).value_or(default_value);
}
@@ -215,8 +205,7 @@ optional<bool> Configuration::GetBool(const std::string &key) const {
} else if (!strcasecmp((*raw).c_str(), "false")) {
return std::experimental::make_optional(false);
} else {
- throw std::runtime_error(
- "Unexpected value found while conversion to bool.");
+ throw std::runtime_error("Unexpected value found while conversion to bool.");
}
}
return optional<bool>();
diff --git a/hbase-native-client/core/configuration.h b/hbase-native-client/core/configuration.h
index f09bbac..69bef75 100644
--- a/hbase-native-client/core/configuration.h
+++ b/hbase-native-client/core/configuration.h
@@ -41,8 +41,7 @@ class Configuration {
* @param key Property whose value is to be fetched. SubstituteVars will be
* called for any variable expansion.
*/
- std::string Get(const std::string &key,
- const std::string &default_value) const;
+ std::string Get(const std::string &key, const std::string &default_value) const;
/**
* @brief Returns int32_t identified by key in ConfigMap else default value if
@@ -89,8 +88,7 @@ class Configuration {
std::string value;
bool final;
ConfigData() : final(false) {}
- explicit ConfigData(const std::string &value)
- : value(value), final(false) {}
+ explicit ConfigData(const std::string &value) : value(value), final(false) {}
void operator=(const std::string &new_value) {
value = new_value;
final = false;
@@ -174,8 +172,7 @@ class Configuration {
* @param sub_variable Extracted variable from expr which will be checked
* against environment value or ConfigMap values.
*/
- size_t IsSubVariable(const std::string &expr,
- std::string &sub_variable) const;
+ size_t IsSubVariable(const std::string &expr, std::string &sub_variable) const;
/**
* @brief This method will fetch value for key from environment if present.
diff --git a/hbase-native-client/core/get-test.cc b/hbase-native-client/core/get-test.cc
index cef99b9..07d0003 100644
--- a/hbase-native-client/core/get-test.cc
+++ b/hbase-native-client/core/get-test.cc
@@ -121,8 +121,7 @@ void GetMethods(Get &get, const std::string &row) {
// Test initial values
EXPECT_EQ(0, get.Timerange().MinTimeStamp());
- EXPECT_EQ(std::numeric_limits<int64_t>::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);
@@ -136,13 +135,11 @@ 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<int64_t>::max()),
- std::runtime_error);
+ 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<uint32_t>::max() + 1),
- std::runtime_error);
+ ASSERT_THROW(get.SetMaxVersions(std::numeric_limits<uint32_t>::max() + 1), std::runtime_error);
}
TEST(Get, SingleGet) {
diff --git a/hbase-native-client/core/get.cc b/hbase-native-client/core/get.cc
index 6ba4e86..5c5f446 100644
--- a/hbase-native-client/core/get.cc
+++ b/hbase-native-client/core/get.cc
@@ -34,8 +34,7 @@ Get::Get(const Get &get) {
cache_blocks_ = get.cache_blocks_;
check_existence_only_ = get.check_existence_only_;
consistency_ = get.consistency_;
- tr_.reset(new TimeRange(get.Timerange().MinTimeStamp(),
- get.Timerange().MaxTimeStamp()));
+ tr_.reset(new TimeRange(get.Timerange().MinTimeStamp(), get.Timerange().MaxTimeStamp()));
family_map_.insert(get.family_map_.begin(), get.family_map_.end());
}
@@ -45,8 +44,7 @@ Get &Get::operator=(const Get &get) {
cache_blocks_ = get.cache_blocks_;
check_existence_only_ = get.check_existence_only_;
consistency_ = get.consistency_;
- tr_.reset(new TimeRange(get.Timerange().MinTimeStamp(),
- get.Timerange().MaxTimeStamp()));
+ tr_.reset(new TimeRange(get.Timerange().MinTimeStamp(), get.Timerange().MaxTimeStamp()));
family_map_.insert(get.family_map_.begin(), get.family_map_.end());
return *this;
}
@@ -68,8 +66,7 @@ Get &Get::AddFamily(const std::string &family) {
}
Get &Get::AddColumn(const std::string &family, const std::string &qualifier) {
- const auto &it = std::find(family_map_[family].begin(),
- family_map_[family].end(), qualifier);
+ const auto &it = std::find(family_map_[family].begin(), family_map_[family].end(), qualifier);
/**
* Check if any qualifiers are already present or not.
@@ -97,8 +94,7 @@ const FamilyMap &Get::Family() const { return family_map_; }
int Get::MaxVersions() const { return max_versions_; }
Get &Get::SetMaxVersions(int32_t max_versions) {
- if (0 == max_versions)
- throw std::runtime_error("max_versions must be positive");
+ if (0 == max_versions) throw std::runtime_error("max_versions must be positive");
max_versions_ = max_versions;
return *this;
@@ -130,8 +126,7 @@ void Get::CheckRow(const std::string &row) {
throw std::runtime_error("Row length can't be 0");
}
if (row_length > kMaxRowLength) {
- throw std::runtime_error("Length of " + row +
- " is greater than max row size: " +
+ throw std::runtime_error("Length of " + row + " is greater than max row size: " +
std::to_string(kMaxRowLength));
}
}
diff --git a/hbase-native-client/core/hbase_configuration-test.cc b/hbase-native-client/core/hbase_configuration-test.cc
index eec500e..07a6358 100644
--- a/hbase-native-client/core/hbase_configuration-test.cc
+++ b/hbase-native-client/core/hbase_configuration-test.cc
@@ -28,10 +28,8 @@
using namespace hbase;
-const std::string kDefHBaseConfPath(
- "./build/test-data/hbase-configuration-test/conf/");
-const std::string kHBaseConfPath(
- "./build/test-data/hbase-configuration-test/custom-conf/");
+const std::string kDefHBaseConfPath("./build/test-data/hbase-configuration-test/conf/");
+const std::string kHBaseConfPath("./build/test-data/hbase-configuration-test/custom-conf/");
const std::string kHBaseDefaultXml("hbase-default.xml");
const std::string kHBaseSiteXml("hbase-site.xml");
@@ -121,8 +119,7 @@ void WriteDataToFile(const std::string &file, const std::string &xml_data) {
hbase_conf.close();
}
-void CreateHBaseConf(const std::string &dir, const std::string &file,
- const std::string xml_data) {
+void CreateHBaseConf(const std::string &dir, const std::string &file, const std::string xml_data) {
// Directory will be created if not present
if (!boost::filesystem::exists(dir)) {
boost::filesystem::create_directories(dir);
@@ -153,10 +150,8 @@ TEST(Configuration, LoadConfFromDefaultLocation) {
HBaseConfigurationLoader loader;
hbase::optional<Configuration> conf = loader.LoadDefaultResources();
ASSERT_TRUE(conf) << "No configuration object present.";
- EXPECT_STREQ((*conf).Get("custom-prop", "Set this value").c_str(),
- "custom-value");
- EXPECT_STREQ((*conf).Get("default-prop", "Set this value").c_str(),
- "default-value");
+ EXPECT_STREQ((*conf).Get("custom-prop", "Set this value").c_str(), "custom-value");
+ EXPECT_STREQ((*conf).Get("default-prop", "Set this value").c_str(), "default-value");
}
/*
@@ -170,8 +165,7 @@ TEST(Configuration, LoadConfFromCustomLocation) {
HBaseConfigurationLoader loader;
std::vector<std::string> resources{kHBaseSiteXml};
- hbase::optional<Configuration> conf =
- loader.LoadResources(kHBaseConfPath, resources);
+ hbase::optional<Configuration> conf = loader.LoadResources(kHBaseConfPath, resources);
ASSERT_TRUE(conf) << "No configuration object present.";
EXPECT_STREQ((*conf).Get("custom-prop", "").c_str(), "custom-value");
EXPECT_STRNE((*conf).Get("custom-prop", "").c_str(), "some-value");
@@ -192,11 +186,9 @@ TEST(Configuration, LoadConfFromMultipleLocatons) {
HBaseConfigurationLoader loader;
std::string conf_paths = kDefHBaseConfPath + ":" + kHBaseConfPath;
std::vector<std::string> resources{kHBaseDefaultXml, kHBaseSiteXml};
- hbase::optional<Configuration> conf =
- loader.LoadResources(conf_paths, resources);
+ hbase::optional<Configuration> conf = loader.LoadResources(conf_paths, resources);
ASSERT_TRUE(conf) << "No configuration object present.";
- EXPECT_STREQ((*conf).Get("default-prop", "From hbase-default.xml").c_str(),
- "default-value");
+ EXPECT_STREQ((*conf).Get("default-prop", "From hbase-default.xml").c_str(), "default-value");
EXPECT_STREQ((*conf).Get("custom-prop", "").c_str(), "custom-value");
EXPECT_STRNE((*conf).Get("custom-prop", "").c_str(), "some-value");
}
@@ -215,10 +207,8 @@ TEST(Configuration, DefaultValues) {
HBaseConfigurationLoader loader;
hbase::optional<Configuration> conf = loader.LoadDefaultResources();
ASSERT_TRUE(conf) << "No configuration object present.";
- EXPECT_STREQ((*conf).Get("default-prop", "Set this value.").c_str(),
- "default-value");
- EXPECT_STREQ((*conf).Get("custom-prop", "Set this value.").c_str(),
- "custom-value");
+ EXPECT_STREQ((*conf).Get("default-prop", "Set this value.").c_str(), "default-value");
+ EXPECT_STREQ((*conf).Get("custom-prop", "Set this value.").c_str(), "custom-value");
}
TEST(Configuration, FinalValues) {
@@ -229,12 +219,10 @@ TEST(Configuration, FinalValues) {
HBaseConfigurationLoader loader;
hbase::optional<Configuration> conf = loader.LoadDefaultResources();
ASSERT_TRUE(conf) << "No configuration object present.";
- EXPECT_STREQ((*conf).Get("hbase.rootdir", "").c_str(),
- "/root/hbase-docker/apps/hbase/data");
+ EXPECT_STREQ((*conf).Get("hbase.rootdir", "").c_str(), "/root/hbase-docker/apps/hbase/data");
EXPECT_STREQ((*conf).Get("hbase.zookeeper.property.datadir", "").c_str(),
"/root/hbase-docker/zookeeper");
- EXPECT_STRNE((*conf).Get("hbase.rootdir", "").c_str(),
- "This value will not be be overwritten");
+ EXPECT_STRNE((*conf).Get("hbase.rootdir", "").c_str(), "This value will not be be overwritten");
EXPECT_STRNE((*conf).Get("hbase.zookeeper.property.datadir", "").c_str(),
"This value will be overwritten");
}
@@ -253,10 +241,8 @@ TEST(Configuration, EnvVars) {
HBaseConfigurationLoader loader;
hbase::optional<Configuration> conf = loader.LoadDefaultResources();
ASSERT_TRUE(conf) << "No configuration object present.";
- EXPECT_STREQ((*conf).Get("hbase-client.user.name", "").c_str(),
- "${user.name}");
- EXPECT_STRNE((*conf).Get("hbase-client.user.name", "root").c_str(),
- "test-user");
+ EXPECT_STREQ((*conf).Get("hbase-client.user.name", "").c_str(), "${user.name}");
+ EXPECT_STRNE((*conf).Get("hbase-client.user.name", "root").c_str(), "test-user");
}
TEST(Configuration, SelfRef) {
@@ -292,8 +278,7 @@ TEST(Configuration, VarExpansionException) {
HBaseConfigurationLoader loader;
hbase::optional<Configuration> conf = loader.LoadDefaultResources();
ASSERT_TRUE(conf) << "No configuration object present.";
- ASSERT_THROW((*conf).Get("foo.substs.exception", "foo-value").c_str(),
- std::runtime_error);
+ ASSERT_THROW((*conf).Get("foo.substs.exception", "foo-value").c_str(), std::runtime_error);
}
TEST(Configuration, GetInt) {
diff --git a/hbase-native-client/core/hbase_configuration_loader.cc b/hbase-native-client/core/hbase_configuration_loader.cc
index 20d0449..38a617b 100644
--- a/hbase-native-client/core/hbase_configuration_loader.cc
+++ b/hbase-native-client/core/hbase_configuration_loader.cc
@@ -94,8 +94,7 @@ void HBaseConfigurationLoader::AddToSearchPath(const std::string &search_path) {
if (search_path.back() != kFileSeparator) {
path_to_add += kFileSeparator;
}
- if (std::find(search_paths_.begin(), search_paths_.end(), path_to_add) ==
- search_paths_.end())
+ if (std::find(search_paths_.begin(), search_paths_.end(), path_to_add) == search_paths_.end())
search_paths_.push_back(path_to_add);
}
@@ -105,8 +104,7 @@ void HBaseConfigurationLoader::AddDefaultResources() {
}
void HBaseConfigurationLoader::AddResources(const std::string &filename) {
- if (std::find(resources_.begin(), resources_.end(), filename) ==
- resources_.end())
+ if (std::find(resources_.begin(), resources_.end(), filename) == resources_.end())
resources_.push_back(filename);
}
@@ -127,8 +125,7 @@ optional<Configuration> HBaseConfigurationLoader::LoadDefaultResources() {
}
}
if (success) {
- return std::experimental::make_optional<Configuration>(
- Configuration(conf_property));
+ return std::experimental::make_optional<Configuration>(Configuration(conf_property));
} else {
return optional<Configuration>();
}
@@ -152,15 +149,13 @@ optional<Configuration> HBaseConfigurationLoader::LoadResources(
}
}
if (success) {
- return std::experimental::make_optional<Configuration>(
- Configuration(conf_property));
+ return std::experimental::make_optional<Configuration>(Configuration(conf_property));
} else {
return optional<Configuration>();
}
}
-bool HBaseConfigurationLoader::LoadProperties(const std::string &file,
- ConfigMap &property_map) {
+bool HBaseConfigurationLoader::LoadProperties(const std::string &file, ConfigMap &property_map) {
// Create empty property tree object
using boost::property_tree::ptree;
ptree pt;
@@ -179,23 +174,21 @@ bool HBaseConfigurationLoader::LoadProperties(const std::string &file,
std::string name_node = v.second.get<std::string>("name");
std::string value_node = v.second.get<std::string>("value");
if ((name_node.size() > 0) && (value_node.size() > 0)) {
- boost::optional<std::string> final_node =
- v.second.get_optional<std::string>("final");
+ boost::optional<std::string> final_node = v.second.get_optional<std::string>("final");
UpdateMapWithValue(property_map, name_node, value_node, final_node);
}
}
}
} catch (std::exception &ex) {
- DLOG(WARNING) << "Exception in parsing file [" << file << "]:[" << ex.what()
- << "]";
+ DLOG(WARNING) << "Exception in parsing file [" << file << "]:[" << ex.what() << "]";
return false;
}
return true;
}
-bool HBaseConfigurationLoader::UpdateMapWithValue(
- ConfigMap &map, const std::string &key, const std::string &value,
- boost::optional<std::string> final_text) {
+bool HBaseConfigurationLoader::UpdateMapWithValue(ConfigMap &map, const std::string &key,
+ const std::string &value,
+ boost::optional<std::string> final_text) {
auto map_value = map.find(key);
if (map_value != map.end() && map_value->second.final) {
return false;
diff --git a/hbase-native-client/core/hbase_configuration_loader.h b/hbase-native-client/core/hbase_configuration_loader.h
index 49dc2b9..a1c1d3f 100644
--- a/hbase-native-client/core/hbase_configuration_loader.h
+++ b/hbase-native-client/core/hbase_configuration_loader.h
@@ -58,9 +58,8 @@ class HBaseConfigurationLoader {
* @param search_path - ':' search paths to load resources.
* @param resources - list of resources used to load configuration properties.
*/
- optional<Configuration> LoadResources(
- const std::string &search_path,
- const std::vector<std::string> &resources);
+ optional<Configuration> LoadResources(const std::string &search_path,
+ const std::vector<std::string> &resources);
private:
using ConfigMap = Configuration::ConfigMap;
@@ -137,8 +136,7 @@ class HBaseConfigurationLoader {
* @param value value of value node.
* @param final_text value of final node true or false if present
*/
- bool UpdateMapWithValue(ConfigMap &map, const std::string &key,
- const std::string &value,
+ bool UpdateMapWithValue(ConfigMap &map, const std::string &key, const std::string &value,
boost::optional<std::string> final_text);
};
diff --git a/hbase-native-client/core/location-cache.cc b/hbase-native-client/core/location-cache.cc
index 4c29a61..6c2a790 100644
--- a/hbase-native-client/core/location-cache.cc
+++ b/hbase-native-client/core/location-cache.cc
@@ -53,10 +53,9 @@ using hbase::pb::RegionInfo;
// TODO(eclark): make this configurable on client creation
static const char META_ZNODE_NAME[] = "/hbase/meta-region-server";
-LocationCache::LocationCache(
- std::string quorum_spec,
- std::shared_ptr<wangle::CPUThreadPoolExecutor> cpu_executor,
- std::shared_ptr<wangle::IOThreadPoolExecutor> io_executor)
+LocationCache::LocationCache(std::string quorum_spec,
+ std::shared_ptr<wangle::CPUThreadPoolExecutor> cpu_executor,
+ std::shared_ptr<wangle::IOThreadPoolExecutor> io_executor)
: quorum_spec_(quorum_spec),
cpu_executor_(cpu_executor),
meta_promise_(nullptr),
@@ -91,9 +90,7 @@ void LocationCache::InvalidateMeta() {
/// MUST hold the meta_lock_
void LocationCache::RefreshMetaLocation() {
meta_promise_ = make_unique<SharedPromise<ServerName>>();
- cpu_executor_->add([&] {
- meta_promise_->setWith([&] { return this->ReadMetaLocation(); });
- });
+ cpu_executor_->add([&] { meta_promise_->setWith([&] { return this->ReadMetaLocation(); }); });
}
ServerName LocationCache::ReadMetaLocation() {
@@ -103,9 +100,8 @@ ServerName LocationCache::ReadMetaLocation() {
// This needs to be int rather than size_t as that's what ZK expects.
int len = buf->capacity();
// TODO(elliott): handle disconnects/reconntion as needed.
- int zk_result =
- zoo_get(this->zk_, META_ZNODE_NAME, 0,
- reinterpret_cast<char *>(buf->writableData()), &len, nullptr);
+ int zk_result = zoo_get(this->zk_, META_ZNODE_NAME, 0,
+ reinterpret_cast<char *>(buf->writableData()), &len, nullptr);
if (zk_result != ZOK || len < 9) {
LOG(ERROR) << "Error getting meta location.";
throw runtime_error("Error getting meta location");
@@ -119,18 +115,16 @@ ServerName LocationCache::ReadMetaLocation() {
return mrs.server();
}
-Future<std::shared_ptr<RegionLocation>> LocationCache::LocateFromMeta(
- const TableName &tn, const string &row) {
+Future<std::shared_ptr<RegionLocation>> LocationCache::LocateFromMeta(const TableName &tn,
+ const string &row) {
return this->LocateMeta()
.via(cpu_executor_.get())
.then([this](ServerName sn) {
- auto remote_id =
- std::make_shared<ConnectionId>(sn.host_name(), sn.port());
+ auto remote_id = std::make_shared<ConnectionId>(sn.host_name(), sn.port());
return this->cp_.GetConnection(remote_id);
})
.then([tn, row, this](std::shared_ptr<RpcConnection> rpc_connection) {
- return (*rpc_connection->get_service())(
- std::move(meta_util_.MetaRequest(tn, row)));
+ return (*rpc_connection->get_service())(std::move(meta_util_.MetaRequest(tn, row)));
})
.then([this](Response resp) {
// take the protobuf response and make it into
@@ -146,16 +140,15 @@ Future<std::shared_ptr<RegionLocation>> LocationCache::LocateFromMeta(
return rl;
})
.then([this](std::shared_ptr<RegionLocation> rl) {
- auto remote_id = std::make_shared<ConnectionId>(
- rl->server_name().host_name(), rl->server_name().port());
+ auto remote_id =
+ std::make_shared<ConnectionId>(rl->server_name().host_name(), rl->server_name().port());
// Now fill out the connection.
rl->set_service(cp_.GetConnection(remote_id)->get_service());
return rl;
});
}
-std::shared_ptr<RegionLocation> LocationCache::CreateLocation(
- const Response &resp) {
+std::shared_ptr<RegionLocation> LocationCache::CreateLocation(const Response &resp) {
auto resp_msg = static_pointer_cast<ScanResponse>(resp.resp_msg());
auto &results = resp_msg->results().Get(0);
auto &cells = results.cell();
@@ -168,6 +161,5 @@ std::shared_ptr<RegionLocation> LocationCache::CreateLocation(
auto region_info = folly::to<RegionInfo>(cell_zero);
auto server_name = folly::to<ServerName>(cell_one);
- return std::make_shared<RegionLocation>(row, std::move(region_info),
- server_name, nullptr);
+ return std::make_shared<RegionLocation>(row, std::move(region_info), server_name, nullptr);
}
diff --git a/hbase-native-client/core/location-cache.h b/hbase-native-client/core/location-cache.h
index 53e41ab..b290a1f 100644
--- a/hbase-native-client/core/location-cache.h
+++ b/hbase-native-client/core/location-cache.h
@@ -79,8 +79,8 @@ class LocationCache {
* @param row of the table to look up. This object must live until after the
* future is returned
*/
- folly::Future<std::shared_ptr<RegionLocation>> LocateFromMeta(
- const hbase::pb::TableName &tn, const std::string &row);
+ folly::Future<std::shared_ptr<RegionLocation>> LocateFromMeta(const hbase::pb::TableName &tn,
+ const std::string &row);
/**
* Remove the cached location of meta.
diff --git a/hbase-native-client/core/meta-utils.cc b/hbase-native-client/core/meta-utils.cc
index e1946d6..f92300c 100644
--- a/hbase-native-client/core/meta-utils.cc
+++ b/hbase-native-client/core/meta-utils.cc
@@ -37,13 +37,11 @@ using hbase::pb::RegionSpecifier_RegionSpecifierType;
static const std::string META_REGION = "1588230740";
-std::string MetaUtil::RegionLookupRowkey(const TableName &tn,
- const std::string &row) const {
+std::string MetaUtil::RegionLookupRowkey(const TableName &tn, const std::string &row) const {
return folly::to<std::string>(tn, ",", row, ",", "999999999999999999");
}
-std::unique_ptr<Request> MetaUtil::MetaRequest(const TableName tn,
- const std::string &row) const {
+std::unique_ptr<Request> MetaUtil::MetaRequest(const TableName tn, const std::string &row) const {
auto request = Request::scan();
auto msg = std::static_pointer_cast<ScanRequest>(request->req_msg());
@@ -53,8 +51,8 @@ std::unique_ptr<Request> MetaUtil::MetaRequest(const TableName tn,
// Set the region this scan goes to
auto region = msg->mutable_region();
region->set_value(META_REGION);
- region->set_type(RegionSpecifier_RegionSpecifierType::
- RegionSpecifier_RegionSpecifierType_ENCODED_REGION_NAME);
+ region->set_type(
+ RegionSpecifier_RegionSpecifierType::RegionSpecifier_RegionSpecifierType_ENCODED_REGION_NAME);
auto scan = msg->mutable_scan();
// We don't care about before, just now.
diff --git a/hbase-native-client/core/meta-utils.h b/hbase-native-client/core/meta-utils.h
index 33da1a8..075215e 100644
--- a/hbase-native-client/core/meta-utils.h
+++ b/hbase-native-client/core/meta-utils.h
@@ -36,14 +36,12 @@ class MetaUtil {
* Given a table and a row give the row key from which to start a scan to find
* region locations.
*/
- std::string RegionLookupRowkey(const hbase::pb::TableName &tn,
- const std::string &row) const;
+ std::string RegionLookupRowkey(const hbase::pb::TableName &tn, const std::string &row) const;
/**
* Given a row we're trying to access create a request to look up the
* location.
*/
- std::unique_ptr<Request> MetaRequest(const hbase::pb::TableName tn,
- const std::string &row) const;
+ std::unique_ptr<Request> MetaRequest(const hbase::pb::TableName tn, const std::string &row) const;
};
} // namespace hbase
diff --git a/hbase-native-client/core/region-location.h b/hbase-native-client/core/region-location.h
index f0295b1..e7b76d3 100644
--- a/hbase-native-client/core/region-location.h
+++ b/hbase-native-client/core/region-location.h
@@ -42,8 +42,7 @@ class RegionLocation {
* this region.
* @param service the connected service to the regionserver.
*/
- RegionLocation(std::string region_name, hbase::pb::RegionInfo ri,
- hbase::pb::ServerName sn,
+ RegionLocation(std::string region_name, hbase::pb::RegionInfo ri, hbase::pb::ServerName sn,
std::shared_ptr<HBaseService> service)
: region_name_(region_name), ri_(ri), sn_(sn), service_(service) {}
diff --git a/hbase-native-client/core/response_converter.h b/hbase-native-client/core/response_converter.h
index 7cbde81..86fb632 100644
--- a/hbase-native-client/core/response_converter.h
+++ b/hbase-native-client/core/response_converter.h
@@ -20,8 +20,8 @@
#pragma once
#include <memory>
-#include "core/result.h"
#include "connection/response.h"
+#include "core/result.h"
namespace hbase {
diff --git a/hbase-native-client/core/result-test.cc b/hbase-native-client/core/result-test.cc
index 134e80f..09d4e15 100644
--- a/hbase-native-client/core/result-test.cc
+++ b/hbase-native-client/core/result-test.cc
@@ -19,11 +19,11 @@
#include "core/result.h"
+#include <gtest/gtest.h>
#include <limits>
#include <memory>
-#include <vector>
#include <string>
-#include <gtest/gtest.h>
+#include <vector>
#include "core/cell.h"
using namespace hbase;
@@ -41,36 +41,35 @@ void PopulateCells(std::vector<std::shared_ptr<Cell> > &cells) {
switch (i) {
case 5: {
- cells.push_back(std::make_shared<Cell>(
- row, family, column, 1482113040506, "value-5", CellType::PUT));
- cells.push_back(std::make_shared<Cell>(
- row, family, column, 1482111803856, "value-X", CellType::PUT));
+ cells.push_back(
+ std::make_shared<Cell>(row, family, column, 1482113040506, "value-5", CellType::PUT));
+ cells.push_back(
+ std::make_shared<Cell>(row, family, column, 1482111803856, "value-X", CellType::PUT));
break;
}
case 8: {
- cells.push_back(std::make_shared<Cell>(
- row, family, column, 1482113040506, "value-8", CellType::PUT));
- cells.push_back(std::make_shared<Cell>(
- row, family, column, 1482111803856, "value-X", CellType::PUT));
- cells.push_back(std::make_shared<Cell>(
- row, family, column, 1482110969958, "value-Y", CellType::PUT));
+ cells.push_back(
+ std::make_shared<Cell>(row, family, column, 1482113040506, "value-8", CellType::PUT));
+ cells.push_back(
+ std::make_shared<Cell>(row, family, column, 1482111803856, "value-X", CellType::PUT));
+ cells.push_back(
+ std::make_shared<Cell>(row, family, column, 1482110969958, "value-Y", CellType::PUT));
break;
}
case 9: {
- cells.push_back(std::make_shared<Cell>(
- row, family, column, 1482113040506, "value-9", CellType::PUT));
- cells.push_back(std::make_shared<Cell>(
- row, family, column, 1482111803856, "value-X", CellType::PUT));
- cells.push_back(std::make_shared<Cell>(
- row, family, column, 1482110969958, "value-Y", CellType::PUT));
- cells.push_back(std::make_shared<Cell>(
- row, family, column, 1482110876075, "value-Z", CellType::PUT));
+ cells.push_back(
+ std::make_shared<Cell>(row, family, column, 1482113040506, "value-9", CellType::PUT));
+ cells.push_back(
+ std::make_shared<Cell>(row, family, column, 1482111803856, "value-X", CellType::PUT));
+ cells.push_back(
+ std::make_shared<Cell>(row, family, column, 1482110969958, "value-Y", CellType::PUT));
+ cells.push_back(
+ std::make_shared<Cell>(row, family, column, 1482110876075, "value-Z", CellType::PUT));
break;
}
default: {
- cells.push_back(std::make_shared<Cell>(row, family, column,
- std::numeric_limits<long>::max(),
- value, CellType::PUT));
+ cells.push_back(std::make_shared<Cell>(
+ row, family, column, std::numeric_limits<long>::max(), value, CellType::PUT));
}
}
}
@@ -111,12 +110,9 @@ TEST(Result, FilledResult) {
// Value will be present as family and qualifier is present
ASSERT_TRUE(result.Value("family-4", "column-4"));
// Value should be present and match.
- EXPECT_EQ(latest_cell->Value(),
- (*result.ColumnLatestCell("family-4", "column-4")).Value());
- EXPECT_EQ("value-5",
- (*result.ColumnLatestCell("family-5", "column-5")).Value());
- EXPECT_EQ("value-8",
- (*result.ColumnLatestCell("family-8", "column-8")).Value());
+ EXPECT_EQ(latest_cell->Value(), (*result.ColumnLatestCell("family-4", "column-4")).Value());
+ EXPECT_EQ("value-5", (*result.ColumnLatestCell("family-5", "column-5")).Value());
+ EXPECT_EQ("value-8", (*result.ColumnLatestCell("family-8", "column-8")).Value());
EXPECT_EQ("value-7", *result.Value("family-7", "column-7"));
// Get cells for the given family and qualifier
diff --git a/hbase-native-client/core/result.cc b/hbase-native-client/core/result.cc
index 9842915..d73a5b2 100644
--- a/hbase-native-client/core/result.cc
+++ b/hbase-native-client/core/result.cc
@@ -23,15 +23,14 @@ namespace hbase {
Result::~Result() {}
-Result::Result(const std::vector<std::shared_ptr<Cell> > &cells, bool exists,
- bool stale, bool partial)
+Result::Result(const std::vector<std::shared_ptr<Cell> > &cells, bool exists, bool stale,
+ bool partial)
: exists_(exists), stale_(stale), partial_(partial) {
for (const auto &cell : cells) {
cells_.push_back(cell);
// We create the map when cells are added. unlike java where map is created
// when result.getMap() is called
- result_map_[cell->Family()][cell->Qualifier()][cell->Timestamp()] =
- cell->Value();
+ result_map_[cell->Family()][cell->Qualifier()][cell->Timestamp()] = cell->Value();
}
row_ = (cells_.size() == 0 ? "" : cells_[0]->Row());
}
@@ -44,17 +43,14 @@ Result::Result(const Result &result) {
if (!result.cells_.empty()) {
for (const auto &cell : result.cells_) {
cells_.push_back(cell);
- result_map_[cell->Family()][cell->Qualifier()][cell->Timestamp()] =
- cell->Value();
+ result_map_[cell->Family()][cell->Qualifier()][cell->Timestamp()] = cell->Value();
}
}
}
-const std::vector<std::shared_ptr<Cell> > &Result::Cells() const {
- return cells_;
-}
+const std::vector<std::shared_ptr<Cell> > &Result::Cells() const { return cells_; }
-std::vector<std::shared_ptr<Cell> > Result::ColumnCells(
- const std::string &family, const std::string &qualifier) const {
+std::vector<std::shared_ptr<Cell> > Result::ColumnCells(const std::string &family,
+ const std::string &qualifier) const {
std::vector<std::shared_ptr<Cell> > column_cells;
// TODO implement a BinarySearch here ?
for (const auto &cell : cells_) {
@@ -65,8 +61,8 @@ std::vector<std::shared_ptr<Cell> > Result::ColumnCells(
return column_cells;
}
-const std::shared_ptr<Cell> Result::ColumnLatestCell(
- const std::string &family, const std::string &qualifier) const {
+const std::shared_ptr<Cell> Result::ColumnLatestCell(const std::string &family,
+ const std::string &qualifier) const {
// TODO implement a BinarySearch here ?
for (const auto &cell : cells_) {
// We find the latest(first) occurrence of the Cell for a given column and
@@ -100,10 +96,8 @@ const ResultFamilyMap Result::FamilyMap(const std::string &family) const {
if (!IsEmpty()) {
for (auto itr = result_map_.begin(); itr != result_map_.end(); ++itr) {
if (family == itr->first) {
- for (auto qitr = itr->second.begin(); qitr != itr->second.end();
- ++qitr) {
- for (auto vitr = qitr->second.begin(); vitr != qitr->second.end();
- ++vitr) {
+ for (auto qitr = itr->second.begin(); qitr != itr->second.end(); ++qitr) {
+ for (auto vitr = qitr->second.begin(); vitr != qitr->second.end(); ++vitr) {
// We break after inserting the first value. Result.java takes only
// the first value
family_map[qitr->first] = vitr->second;
diff --git a/hbase-native-client/core/result.h b/hbase-native-client/core/result.h
index ecfdd55..cd41cf0 100644
--- a/hbase-native-client/core/result.h
+++ b/hbase-native-client/core/result.h
@@ -34,9 +34,9 @@ namespace hbase {
* We need to have a reverse ordered map, when storing TS -> value, so that the
* most recent value is stored first
*/
-using ResultMap = std::map<
- std::string, std::map<std::string, std::map<int64_t, std::string,
- std::greater<int64_t> > > >;
+using ResultMap =
+ std::map<std::string,
+ std::map<std::string, std::map<int64_t, std::string, std::greater<int64_t> > > >;
/**
* @brief Map of qualifiers to values.
@@ -48,8 +48,7 @@ class Result {
/**
* Constructors
*/
- Result(const std::vector<std::shared_ptr<Cell> > &cells, bool exists,
- bool stale, bool partial);
+ Result(const std::vector<std::shared_ptr<Cell> > &cells, bool exists, bool stale, bool partial);
Result(const Result &result);
~Result();
@@ -67,8 +66,8 @@ class Result {
* @param family - column family
* @param qualifier - column qualifier
*/
- std::vector<std::shared_ptr<Cell> > ColumnCells(
- const std::string &family, const std::string &qualifier) const;
+ std::vector<std::shared_ptr<Cell> > ColumnCells(const std::string &family,
+ const std::string &qualifier) const;
/**
* @brief Returns the Cell for the most recent timestamp for a given family
@@ -77,16 +76,15 @@ class Result {
* @param family - column family.
* @param qualifier - column qualifier
*/
- const std::shared_ptr<Cell> ColumnLatestCell(
- const std::string &family, const std::string &qualifier) const;
+ const std::shared_ptr<Cell> ColumnLatestCell(const std::string &family,
+ const std::string &qualifier) const;
/**
* @brief Get the latest version of the specified family and qualifier.
* @param family - column family
* @param qualifier - column qualifier
*/
- std::shared_ptr<std::string> Value(const std::string &family,
- const std::string &qualifier) const;
+ std::shared_ptr<std::string> Value(const std::string &family, const std::string &qualifier) const;
/**
* @brief Returns if the underlying Cell vector is empty or not
diff --git a/hbase-native-client/core/scan-test.cc b/hbase-native-client/core/scan-test.cc
index 0a4001a..9a26407 100644
--- a/hbase-native-client/core/scan-test.cc
+++ b/hbase-native-client/core/scan-test.cc
@@ -154,8 +154,7 @@ void ScanMethods(Scan &scan) {
// Test initial values
EXPECT_EQ(0, scan.Timerange().MinTimeStamp());
- EXPECT_EQ(std::numeric_limits<int64_t>::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);
@@ -169,8 +168,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<int64_t>::max()),
- std::runtime_error);
+ ASSERT_THROW(scan.SetTimeStamp(std::numeric_limits<int64_t>::max()), std::runtime_error);
}
TEST(Scan, Object) {
diff --git a/hbase-native-client/core/scan.cc b/hbase-native-client/core/scan.cc
index 036acfb..5335abd 100644
--- a/hbase-native-client/core/scan.cc
+++ b/hbase-native-client/core/scan.cc
@@ -30,9 +30,7 @@ Scan::Scan() {}
Scan::~Scan() {}
-Scan::Scan(const std::string &start_row) : start_row_(start_row) {
- CheckRow(start_row_);
-}
+Scan::Scan(const std::string &start_row) : start_row_(start_row) { CheckRow(start_row_); }
Scan::Scan(const std::string &start_row, const std::string &stop_row)
: start_row_(start_row), stop_row_(stop_row) {
@@ -76,8 +74,7 @@ Scan &Scan::operator=(const Scan &scan) {
Scan::Scan(const Get &get) {
cache_blocks_ = get.CacheBlocks();
max_versions_ = get.MaxVersions();
- tr_.reset(new TimeRange(get.Timerange().MinTimeStamp(),
- get.Timerange().MaxTimeStamp()));
+ tr_.reset(new TimeRange(get.Timerange().MinTimeStamp(), get.Timerange().MaxTimeStamp()));
family_map_.insert(get.Family().begin(), get.Family().end());
}
@@ -97,8 +94,7 @@ Scan &Scan::AddFamily(const std::string &family) {
}
Scan &Scan::AddColumn(const std::string &family, const std::string &qualifier) {
- const auto &it = std::find(family_map_[family].begin(),
- family_map_[family].end(), qualifier);
+ const auto &it = std::find(family_map_[family].begin(), family_map_[family].end(), qualifier);
/**
* Check if any qualifiers are already present or not.
* Add only if qualifiers for a given family are not present
@@ -156,9 +152,7 @@ void Scan::SetLoadColumnFamiliesOnDemand(bool load_column_families_on_demand) {
load_column_families_on_demand_ = load_column_families_on_demand;
}
-bool Scan::LoadColumnFamiliesOnDemand() const {
- return load_column_families_on_demand_;
-}
+bool Scan::LoadColumnFamiliesOnDemand() const { return load_column_families_on_demand_; }
Scan &Scan::SetMaxVersions(uint32_t max_versions) {
max_versions_ = max_versions;
@@ -167,9 +161,7 @@ Scan &Scan::SetMaxVersions(uint32_t max_versions) {
int Scan::MaxVersions() const { return max_versions_; }
-void Scan::SetMaxResultSize(int64_t max_result_size) {
- max_result_size_ = max_result_size;
-}
+void Scan::SetMaxResultSize(int64_t max_result_size) { max_result_size_ = max_result_size; }
int64_t Scan::MaxResultSize() const { return max_result_size_; }
@@ -192,8 +184,7 @@ void Scan::CheckRow(const std::string &row) {
throw std::runtime_error("Row length can't be 0");
}
if (row_length > kMaxRowLength) {
- throw std::runtime_error("Length of " + row +
- " is greater than max row size: " +
+ throw std::runtime_error("Length of " + row + " is greater than max row size: " +
std::to_string(kMaxRowLength));
}
}
diff --git a/hbase-native-client/core/simple-client.cc b/hbase-native-client/core/simple-client.cc
index f3f6c42..90e7cd4 100644
--- a/hbase-native-client/core/simple-client.cc
+++ b/hbase-native-client/core/simple-client.cc
@@ -65,12 +65,11 @@ std::unique_ptr<Request> MakeRequest(uint64_t col, std::string region_name) {
auto suf = folly::to<std::string>(col);
region->set_value(region_name);
- region->set_type(RegionSpecifier_RegionSpecifierType::
- RegionSpecifier_RegionSpecifierType_REGION_NAME);
+ region->set_type(
+ RegionSpecifier_RegionSpecifierType::RegionSpecifier_RegionSpecifierType_REGION_NAME);
auto mutation = msg->mutable_mutation();
mutation->set_row(FLAGS_row + suf);
- mutation->set_mutate_type(
- MutationProto_MutationType::MutationProto_MutationType_PUT);
+ mutation->set_mutate_type(MutationProto_MutationType::MutationProto_MutationType_PUT);
auto column = mutation->add_column_value();
column->set_family("d");
auto qual = column->add_qualifier_value();
@@ -81,14 +80,12 @@ std::unique_ptr<Request> MakeRequest(uint64_t col, std::string region_name) {
}
int main(int argc, char *argv[]) {
- google::SetUsageMessage(
- "Simple client to get a single row from HBase on the comamnd line");
+ google::SetUsageMessage("Simple client to get a single row from HBase on the comamnd line");
google::ParseCommandLineFlags(&argc, &argv, true);
google::InitGoogleLogging(argv[0]);
// Set up thread pools.
- auto cpu_pool =
- std::make_shared<wangle::CPUThreadPoolExecutor>(FLAGS_threads);
+ auto cpu_pool = std::make_shared<wangle::CPUThreadPoolExecutor>(FLAGS_threads);
auto io_pool = std::make_shared<wangle::IOThreadPoolExecutor>(5);
// Create the cache.
@@ -105,14 +102,13 @@ int main(int argc, char *argv[]) {
auto results = std::vector<Future<Response>>{};
auto col = uint64_t{0};
for (; col < num_puts; col++) {
- results.push_back(folly::makeFuture(col)
- .via(cpu_pool.get())
- .then([loc](uint64_t col) {
- return MakeRequest(col, loc->region_name());
- })
- .then([connection](std::unique_ptr<Request> req) {
- return (*connection)(std::move(req));
- }));
+ results.push_back(
+ folly::makeFuture(col)
+ .via(cpu_pool.get())
+ .then([loc](uint64_t col) { return MakeRequest(col, loc->region_name()); })
+ .then([connection](std::unique_ptr<Request> req) {
+ return (*connection)(std::move(req));
+ }));
}
auto allf = folly::collect(results).get();
diff --git a/hbase-native-client/core/time_range.cc b/hbase-native-client/core/time_range.cc
index 8c37b29..04b70ec 100644
--- a/hbase-native-client/core/time_range.cc
+++ b/hbase-native-client/core/time_range.cc
@@ -25,9 +25,7 @@
namespace hbase {
TimeRange::TimeRange()
- : min_timestamp_(0L),
- max_timestamp_(std::numeric_limits<int64_t>::max()),
- all_time_(true) {}
+ : min_timestamp_(0L), max_timestamp_(std::numeric_limits<int64_t>::max()), all_time_(true) {}
TimeRange::TimeRange(const TimeRange &tr) {
this->all_time_ = tr.all_time_;
@@ -53,8 +51,7 @@ TimeRange::TimeRange(int64_t min_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) +
- ", max_timestamp:" +
+ std::to_string(min_timestamp) + ", max_timestamp:" +
std::to_string(max_timestamp));
}
if (max_timestamp < min_timestamp) {
diff --git a/hbase-native-client/security/BUCK b/hbase-native-client/security/BUCK
index 5b935d3..e176c90 100644
--- a/hbase-native-client/security/BUCK
+++ b/hbase-native-client/security/BUCK
@@ -19,12 +19,8 @@
# to a single server.
cxx_library(
name="security",
- exported_headers=[
- "user.h",
- ],
- srcs=[
- ],
- deps=[
- ],
+ exported_headers=["user.h",],
+ srcs=[],
+ deps=[],
compiler_flags=['-Weffc++'],
- visibility=['//core/...','//connection/...'],)
+ visibility=['//core/...', '//connection/...'],)
diff --git a/hbase-native-client/security/user.h b/hbase-native-client/security/user.h
index 795f5ac..8a15891 100644
--- a/hbase-native-client/security/user.h
+++ b/hbase-native-client/security/user.h
@@ -23,16 +23,15 @@
namespace hbase {
namespace security {
class User {
-public:
+ public:
explicit User(const std::string& user_name) : user_name_(user_name) {}
- virtual ~User() = default;
+ virtual ~User() = default;
- std::string user_name() {return user_name_;}
+ std::string user_name() { return user_name_; }
- static std::shared_ptr<User> defaultUser() {
- return std::make_shared<User>("__drwho");
- }
-private:
+ static std::shared_ptr<User> defaultUser() { return std::make_shared<User>("__drwho"); }
+
+ private:
std::string user_name_;
};
}
diff --git a/hbase-native-client/serde/client-deserializer-test.cc b/hbase-native-client/serde/client-deserializer-test.cc
index 8c571b1..a30f904 100644
--- a/hbase-native-client/serde/client-deserializer-test.cc
+++ b/hbase-native-client/serde/client-deserializer-test.cc
@@ -50,8 +50,7 @@ TEST(TestRpcSerde, TestGoodGetRequestFullRoundTrip) {
// fill up the GetRequest.
in.mutable_region()->set_value("test_region_id");
in.mutable_region()->set_type(
- RegionSpecifier_RegionSpecifierType::
- RegionSpecifier_RegionSpecifierType_ENCODED_REGION_NAME);
+ RegionSpecifier_RegionSpecifierType::RegionSpecifier_RegionSpecifierType_ENCODED_REGION_NAME);
in.mutable_get()->set_row("test_row");
// Create the buffer
diff --git a/hbase-native-client/serde/rpc.cc b/hbase-native-client/serde/rpc.cc
index e4ade22..3bdb489 100644
--- a/hbase-native-client/serde/rpc.cc
+++ b/hbase-native-client/serde/rpc.cc
@@ -70,15 +70,13 @@ int RpcSerde::ParseDelimited(const IOBuf *buf, Message *msg) {
coded_stream.PushLimit(msg_size);
// Parse the message.
if (msg->MergeFromCodedStream(&coded_stream) == false) {
- FB_LOG_EVERY_MS(ERROR, 1000)
- << "Unable to read a protobuf message from data.";
+ FB_LOG_EVERY_MS(ERROR, 1000) << "Unable to read a protobuf message from data.";
return -4;
}
// Make sure all the data was consumed.
if (coded_stream.ConsumedEntireMessage() == false) {
- FB_LOG_EVERY_MS(ERROR, 1000)
- << "Orphaned data left after reading protobuf message";
+ FB_LOG_EVERY_MS(ERROR, 1000) << "Orphaned data left after reading protobuf message";
return -5;
}
@@ -115,8 +113,8 @@ unique_ptr<IOBuf> RpcSerde::Header(const string &user) {
return PrependLength(SerializeMessage(h));
}
-unique_ptr<IOBuf> RpcSerde::Request(const uint32_t call_id,
- const string &method, const Message *msg) {
+unique_ptr<IOBuf> RpcSerde::Request(const uint32_t call_id, const string &method,
+ const Message *msg) {
pb::RequestHeader rq;
rq.set_method_name(method);
rq.set_call_id(call_id);
@@ -169,8 +167,7 @@ unique_ptr<IOBuf> RpcSerde::SerializeDelimited(const Message &msg) {
// Now write the rest out.
// We're using the protobuf output streams here to keep track
// of where in the output array we are rather than IOBuf.
- msg.SerializeWithCachedSizesToArray(
- cos.GetDirectBufferForNBytesAndAdvance(msg_size));
+ msg.SerializeWithCachedSizesToArray(cos.GetDirectBufferForNBytesAndAdvance(msg_size));
// Return the buffer.
return buf;
diff --git a/hbase-native-client/serde/rpc.h b/hbase-native-client/serde/rpc.h
index 05ceee9..7d060c7 100644
--- a/hbase-native-client/serde/rpc.h
+++ b/hbase-native-client/serde/rpc.h
@@ -83,8 +83,7 @@ class RpcSerde {
* - RequestHeader object
* - The passed in Message object
*/
- std::unique_ptr<folly::IOBuf> Request(const uint32_t call_id,
- const std::string &method,
+ std::unique_ptr<folly::IOBuf> Request(const uint32_t call_id, const std::string &method,
const google::protobuf::Message *msg);
/**
@@ -94,21 +93,18 @@ class RpcSerde {
* - A protobuf var int32
* - The message object seriailized after that.
*/
- std::unique_ptr<folly::IOBuf> SerializeDelimited(
- const google::protobuf::Message &msg);
+ std::unique_ptr<folly::IOBuf> SerializeDelimited(const google::protobuf::Message &msg);
/**
* Serilalize a message. This does not add any length prepend.
*/
- std::unique_ptr<folly::IOBuf> SerializeMessage(
- const google::protobuf::Message &msg);
+ std::unique_ptr<folly::IOBuf> SerializeMessage(const google::protobuf::Message &msg);
/**
* Prepend a length IOBuf to the given IOBuf chain.
* This involves no copies or moves of the passed in data.
*/
- std::unique_ptr<folly::IOBuf> PrependLength(
- std::unique_ptr<folly::IOBuf> msg);
+ std::unique_ptr<folly::IOBuf> PrependLength(std::unique_ptr<folly::IOBuf> msg);
private:
/* data */
diff --git a/hbase-native-client/serde/server-name-test.cc b/hbase-native-client/serde/server-name-test.cc
index 73a68d6..87c493a 100644
--- a/hbase-native-client/serde/server-name-test.cc
+++ b/hbase-native-client/serde/server-name-test.cc
@@ -37,9 +37,7 @@ TEST(TestServerName, TestIps) {
ASSERT_EQ(999, sn.port());
}
-TEST(TestServerName, TestThrow) {
- ASSERT_ANY_THROW(folly::to<ServerName>("Ther's no colon here"));
-}
+TEST(TestServerName, TestThrow) { ASSERT_ANY_THROW(folly::to<ServerName>("Ther's no colon here")); }
TEST(TestServerName, TestIPV6) {
auto sn = folly::to<ServerName>("[::::1]:123");
diff --git a/hbase-native-client/serde/zk.cc b/hbase-native-client/serde/zk.cc
index 69b55fa..bf68400 100644
--- a/hbase-native-client/serde/zk.cc
+++ b/hbase-native-client/serde/zk.cc
@@ -46,8 +46,7 @@ bool ZkDeserializer::Parse(IOBuf *buf, Message *out) {
// There should be a magic number for recoverable zk
uint8_t magic_num = c.read<uint8_t>();
if (magic_num != 255) {
- LOG(ERROR) << "Magic number not in ZK znode data expected 255 got ="
- << unsigned(magic_num);
+ LOG(ERROR) << "Magic number not in ZK znode data expected 255 got =" << unsigned(magic_num);
throw runtime_error("Magic number not in znode data");
}
// How long is the id?