You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bh...@apache.org on 2020/05/27 21:14:11 UTC

[hbase] branch branch-2.3 updated: HBASE-24434 Fix building cpp-example DemoClient

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

bharathv pushed a commit to branch branch-2.3
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.3 by this push:
     new b28ba1c  HBASE-24434 Fix building cpp-example DemoClient
b28ba1c is described below

commit b28ba1c02445b0b4d13574f1e9734deeb59153fd
Author: Alexander Myasnikov <my...@gmail.com>
AuthorDate: Wed May 27 14:02:30 2020 -0700

    HBASE-24434 Fix building cpp-example DemoClient
    
    Changed boost::shared_ptr to std::shared_ptr for compatibility with apache thrift v0.13.
    
    Signed-off-by: Bharath Vissapragada <bh...@apache.org>
---
 hbase-examples/README.txt                          |  7 ++---
 hbase-examples/src/main/cpp/DemoClient.cpp         | 15 +++++-----
 hbase-examples/src/main/cpp/gen-cpp/Hbase.cpp      |  6 ++--
 hbase-examples/src/main/cpp/gen-cpp/Hbase.h        | 32 +++++++++++-----------
 .../src/main/cpp/gen-cpp/Hbase_server.skeleton.cpp | 12 ++++----
 5 files changed, 34 insertions(+), 38 deletions(-)

diff --git a/hbase-examples/README.txt b/hbase-examples/README.txt
index bf28180..599ccd4 100644
--- a/hbase-examples/README.txt
+++ b/hbase-examples/README.txt
@@ -57,11 +57,10 @@ Example code.
       3. Execute {perl DemoClient.pl}.
 
     * CPP: hbase-examples/src/main/cpp/DemoClient.cpp
-      1. Make sure you have boost and Thrift C++ libraries; modify Makefile if necessary.
-        The recent (0.9.0 as of this writing) version of Thrift can be downloaded from http://thrift.apache.org/download/.
-        Boost can be found at http://www.boost.org/users/download/.
+      1. Make sure you have Thrift C++ libraries; modify Makefile if necessary.
+        The recent (0.13.0 as of this writing) version of Thrift can be downloaded from http://thrift.apache.org/download/.
       2. Execute {make}.
-      3. Execute {./DemoClient}.
+      3. Execute {./DemoClient <host> <port>}.
 
 ON PROTOBUFS
 This maven module has core protobuf definition files ('.protos') used by hbase
diff --git a/hbase-examples/src/main/cpp/DemoClient.cpp b/hbase-examples/src/main/cpp/DemoClient.cpp
index 05f0a94..452387b 100644
--- a/hbase-examples/src/main/cpp/DemoClient.cpp
+++ b/hbase-examples/src/main/cpp/DemoClient.cpp
@@ -23,7 +23,6 @@
 
 #include <iostream>
 
-#include <boost/lexical_cast.hpp>
 #include <protocol/TBinaryProtocol.h>
 #include <transport/TSocket.h>
 #include <transport/TTransportUtils.h>
@@ -79,15 +78,15 @@ main(int argc, char** argv)
     return -1;
   }
   bool isFramed = false;
-  boost::shared_ptr<TTransport> socket(new TSocket(argv[1], boost::lexical_cast<int>(argv[2])));
-  boost::shared_ptr<TTransport> transport;
+  std::shared_ptr<TTransport> socket = std::make_shared<TSocket>(argv[1], std::stoi(argv[2]));
+  std::shared_ptr<TTransport> transport;
 
   if (isFramed) {
-    transport.reset(new TFramedTransport(socket));
+    transport = std::make_shared<TFramedTransport>(socket);
   } else {
-    transport.reset(new TBufferedTransport(socket));
+    transport = std::make_shared<TBufferedTransport>(socket);
   }
-  boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
+  std::shared_ptr<TProtocol> protocol = std::make_shared<TBinaryProtocol>(transport);
 
   const std::map<Text, Text>  dummyAttributes; // see HBASE-6806 HBASE-4658
   HbaseClient client(protocol);
@@ -240,10 +239,10 @@ main(int argc, char** argv)
       mutations.clear();
       mutations.push_back(Mutation());
       mutations.back().column = "entry:num";
-      mutations.back().value = boost::lexical_cast<std::string>(i);
+      mutations.back().value = std::to_string(i);
       mutations.push_back(Mutation());
       mutations.back().column = "entry:sqr";
-      mutations.back().value = boost::lexical_cast<std::string>(i*i);
+      mutations.back().value = std::to_string(i * i);
       client.mutateRow(t, row, mutations, dummyAttributes);
       client.getRow(rowResult, t, row, dummyAttributes);
       printRow(rowResult);
diff --git a/hbase-examples/src/main/cpp/gen-cpp/Hbase.cpp b/hbase-examples/src/main/cpp/gen-cpp/Hbase.cpp
index 43a7867..936fe58 100644
--- a/hbase-examples/src/main/cpp/gen-cpp/Hbase.cpp
+++ b/hbase-examples/src/main/cpp/gen-cpp/Hbase.cpp
@@ -16127,10 +16127,10 @@ void HbaseProcessor::process_getRegionInfo(int32_t seqid, ::apache::thrift::prot
   }
 }
 
-::boost::shared_ptr< ::apache::thrift::TProcessor > HbaseProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) {
+std::shared_ptr< ::apache::thrift::TProcessor > HbaseProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) {
   ::apache::thrift::ReleaseHandler< HbaseIfFactory > cleanup(handlerFactory_);
-  ::boost::shared_ptr< HbaseIf > handler(handlerFactory_->getHandler(connInfo), cleanup);
-  ::boost::shared_ptr< ::apache::thrift::TProcessor > processor(new HbaseProcessor(handler));
+  std::shared_ptr< HbaseIf > handler(handlerFactory_->getHandler(connInfo), cleanup);
+  std::shared_ptr< ::apache::thrift::TProcessor > processor(new HbaseProcessor(handler));
   return processor;
 }
 }}}} // namespace
diff --git a/hbase-examples/src/main/cpp/gen-cpp/Hbase.h b/hbase-examples/src/main/cpp/gen-cpp/Hbase.h
index 2e6ac1a..53f7ca3 100644
--- a/hbase-examples/src/main/cpp/gen-cpp/Hbase.h
+++ b/hbase-examples/src/main/cpp/gen-cpp/Hbase.h
@@ -72,7 +72,7 @@ class HbaseIfFactory {
 
 class HbaseIfSingletonFactory : virtual public HbaseIfFactory {
  public:
-  HbaseIfSingletonFactory(const boost::shared_ptr<HbaseIf>& iface) : iface_(iface) {}
+  HbaseIfSingletonFactory(const std::shared_ptr<HbaseIf>& iface) : iface_(iface) {}
   virtual ~HbaseIfSingletonFactory() {}
 
   virtual HbaseIf* getHandler(const ::apache::thrift::TConnectionInfo&) {
@@ -81,7 +81,7 @@ class HbaseIfSingletonFactory : virtual public HbaseIfFactory {
   virtual void releaseHandler(HbaseIf* /* handler */) {}
 
  protected:
-  boost::shared_ptr<HbaseIf> iface_;
+  std::shared_ptr<HbaseIf> iface_;
 };
 
 class HbaseNull : virtual public HbaseIf {
@@ -6010,22 +6010,22 @@ class Hbase_getRegionInfo_presult {
 
 class HbaseClient : virtual public HbaseIf {
  public:
-  HbaseClient(boost::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) :
+  HbaseClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) :
     piprot_(prot),
     poprot_(prot) {
     iprot_ = prot.get();
     oprot_ = prot.get();
   }
-  HbaseClient(boost::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, boost::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) :
+  HbaseClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) :
     piprot_(iprot),
     poprot_(oprot) {
     iprot_ = iprot.get();
     oprot_ = oprot.get();
   }
-  boost::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() {
+  std::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() {
     return piprot_;
   }
-  boost::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() {
+  std::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() {
     return poprot_;
   }
   void enableTable(const Bytes& tableName);
@@ -6158,15 +6158,15 @@ class HbaseClient : virtual public HbaseIf {
   void send_getRegionInfo(const Text& row);
   void recv_getRegionInfo(TRegionInfo& _return);
  protected:
-  boost::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_;
-  boost::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_;
+  std::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_;
+  std::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_;
   ::apache::thrift::protocol::TProtocol* iprot_;
   ::apache::thrift::protocol::TProtocol* oprot_;
 };
 
 class HbaseProcessor : public ::apache::thrift::TDispatchProcessor {
  protected:
-  boost::shared_ptr<HbaseIf> iface_;
+  std::shared_ptr<HbaseIf> iface_;
   virtual bool dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext);
  private:
   typedef  void (HbaseProcessor::*ProcessFunction)(int32_t, ::apache::thrift::protocol::TProtocol*, ::apache::thrift::protocol::TProtocol*, void*);
@@ -6216,7 +6216,7 @@ class HbaseProcessor : public ::apache::thrift::TDispatchProcessor {
   void process_getRowOrBefore(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext);
   void process_getRegionInfo(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext);
  public:
-  HbaseProcessor(boost::shared_ptr<HbaseIf> iface) :
+  HbaseProcessor(std::shared_ptr<HbaseIf> iface) :
     iface_(iface) {
     processMap_["enableTable"] = &HbaseProcessor::process_enableTable;
     processMap_["disableTable"] = &HbaseProcessor::process_disableTable;
@@ -6268,24 +6268,24 @@ class HbaseProcessor : public ::apache::thrift::TDispatchProcessor {
 
 class HbaseProcessorFactory : public ::apache::thrift::TProcessorFactory {
  public:
-  HbaseProcessorFactory(const ::boost::shared_ptr< HbaseIfFactory >& handlerFactory) :
+  HbaseProcessorFactory(const std::shared_ptr< HbaseIfFactory >& handlerFactory) :
       handlerFactory_(handlerFactory) {}
 
-  ::boost::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo);
+  std::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo);
 
  protected:
-  ::boost::shared_ptr< HbaseIfFactory > handlerFactory_;
+  std::shared_ptr< HbaseIfFactory > handlerFactory_;
 };
 
 class HbaseMultiface : virtual public HbaseIf {
  public:
-  HbaseMultiface(std::vector<boost::shared_ptr<HbaseIf> >& ifaces) : ifaces_(ifaces) {
+  HbaseMultiface(std::vector<std::shared_ptr<HbaseIf> >& ifaces) : ifaces_(ifaces) {
   }
   virtual ~HbaseMultiface() {}
  protected:
-  std::vector<boost::shared_ptr<HbaseIf> > ifaces_;
+  std::vector<std::shared_ptr<HbaseIf> > ifaces_;
   HbaseMultiface() {}
-  void add(boost::shared_ptr<HbaseIf> iface) {
+  void add(std::shared_ptr<HbaseIf> iface) {
     ifaces_.push_back(iface);
   }
  public:
diff --git a/hbase-examples/src/main/cpp/gen-cpp/Hbase_server.skeleton.cpp b/hbase-examples/src/main/cpp/gen-cpp/Hbase_server.skeleton.cpp
index 6a08d63..f2e1488 100644
--- a/hbase-examples/src/main/cpp/gen-cpp/Hbase_server.skeleton.cpp
+++ b/hbase-examples/src/main/cpp/gen-cpp/Hbase_server.skeleton.cpp
@@ -12,8 +12,6 @@ using namespace ::apache::thrift::protocol;
 using namespace ::apache::thrift::transport;
 using namespace ::apache::thrift::server;
 
-using boost::shared_ptr;
-
 using namespace  ::apache::hadoop::hbase::thrift;
 
 class HbaseHandler : virtual public HbaseIf {
@@ -241,11 +239,11 @@ class HbaseHandler : virtual public HbaseIf {
 
 int main(int argc, char **argv) {
   int port = 9090;
-  shared_ptr<HbaseHandler> handler(new HbaseHandler());
-  shared_ptr<TProcessor> processor(new HbaseProcessor(handler));
-  shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
-  shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
-  shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
+  std::shared_ptr<HbaseHandler> handler(new HbaseHandler());
+  std::shared_ptr<TProcessor> processor(new HbaseProcessor(handler));
+  std::shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
+  std::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
+  std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
   TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory);
   server.serve();