From e942f367a3eaaa346bb4447ca8d22b1dfe99d57b Mon Sep 17 00:00:00 2001 From: Sudeep Sunthankar Date: Mon, 2 Jan 2017 16:50:55 +1100 Subject: [PATCH] 1) Sources for HBase Client Implementation. Consists of Client, Table and PB Request object builder. 2) We have included ResultScanner as an abstract class for Scan() method skeleton. 3) client-test fails with an error related to folly library. Work is in progress on the same. This is just a first cut so we get an idea of the client. 4) We ned to start hbase locally using ./bin/start-local-hbase.sh and create a table and insert some rows. Will be integrated in the unit-tests in the coming patches. diff --git a/hbase-native-client/core/BUCK b/hbase-native-client/core/BUCK index a5ea5c0..d4bc35c 100644 --- a/hbase-native-client/core/BUCK +++ b/hbase-native-client/core/BUCK @@ -33,6 +33,9 @@ cxx_library( "hbase_configuration_loader.h", "scan.h", "result.h", + "result_scanner.h", + "protobuf_request_builder.h", + "table.h", ], srcs=[ "cell.cc", @@ -45,6 +48,8 @@ cxx_library( "hbase_configuration_loader.cc", "scan.cc", "result.cc", + "protobuf_request_builder.cc", + "table.cc", ], deps=[ "//connection:connection", @@ -94,6 +99,24 @@ cxx_test( srcs=["result-test.cc",], deps=[":core",], run_test_separately=True,) +cxx_test( + name="protobuf_request_builder-test", + srcs=["protobuf_request_builder-test.cc",], + deps=[":core",], + run_test_separately=True,) +cxx_test( + name="client-test", + srcs=["client-test.cc",], + deps=[ + ":core", + "//connection:connection", + "//if:if", + "//serde:serde", + "//third-party:folly", + "//third-party:wangle", + "//third-party:zookeeper_mt", + ], + run_test_separately=True,) cxx_binary( name="simple-client", srcs=["simple-client.cc",], diff --git a/hbase-native-client/core/client-test.cc b/hbase-native-client/core/client-test.cc new file mode 100644 index 0000000..f0a6bbe --- /dev/null +++ b/hbase-native-client/core/client-test.cc @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include "core/client.h" +#include "core/configuration.h" +#include "core/get.h" +#include "core/hbase_configuration_loader.h" +#include "core/result.h" +#include "core/table.h" +#include "serde/table-name.h" + +TEST(Client, Get) { + auto tn = folly::to("t"); + auto row = "test2"; + + // Get to be performed on above HBase Table + hbase::Get get(row); + + // We are not using TestUtil as of now to start hbase, and put some rows as we + // ae getting some errors. We will have to do that going ahead. For now, we + // are creating test table and inserting rows. and starting hbase manually + // using ./bin/start-local-hbase.sh + + // Fetch zookeeper quorum + hbase::HBaseConfigurationLoader loader; + auto conf = loader.LoadDefaultResources(); + auto zk_quorum = conf->Get("hbase.zookeeper.quorum", "localhost:2181"); + + // Create a client + hbase::Client client(zk_quorum); + // Get connection to HBase Table + auto table = client.GetTable(tn); + ASSERT_TRUE(table != nullptr); + // Perform the Get + std::unique_ptr result = table->Get(get); + ASSERT_TRUE(result != nullptr); + + // Test the values, should be same as in put executed on hbase shell + EXPECT_EQ("test2", result->Row()); + EXPECT_EQ("value2", *(result->Value("d", "2"))); + EXPECT_EQ("value for extra", *(result->Value("d", "extra"))); +} diff --git a/hbase-native-client/core/client.cc b/hbase-native-client/core/client.cc index 0389b24..cd57fdc 100644 --- a/hbase-native-client/core/client.cc +++ b/hbase-native-client/core/client.cc @@ -1,5 +1,5 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one + w * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file @@ -19,28 +19,49 @@ #include "core/client.h" -#include - -#include -#include - -using namespace folly; -using namespace std; -using namespace hbase::pb; +#include namespace hbase { -Client::Client(std::string zk_quorum) +Client::Client(const std::string &zk_quorum) : cpu_executor_(std::make_shared(4)), io_executor_(std::make_shared( sysconf(_SC_NPROCESSORS_ONLN))), - location_cache_(zk_quorum, cpu_executor_, io_executor_) {} + location_cache_(std::make_shared( + zk_quorum, cpu_executor_, io_executor_)) {} // We can't have the threads continue running after everything is done // that leads to an error. Client::~Client() { cpu_executor_->stop(); io_executor_->stop(); + if (rpc_client_.get()) rpc_client_->Close(); +} + +std::unique_ptr Client::GetTable(const TableName &table_name) { + std::unique_ptr
table = std::make_unique
(table_name, *this); + return std::move(table); +} + +const std::shared_ptr &Client::LocationCache() const { + return location_cache_; +} + +const std::shared_ptr &Client::RpcClient() const { + return rpc_client_; +} + +const hbase::optional &Client::Configuration() const { + return conf_; +} + +void Client::Close() { + if (is_closed_) return; + + cpu_executor_->stop(); + io_executor_->stop(); + if (rpc_client_.get()) rpc_client_->Close(); + is_closed_ = true; } } // namespace hbase diff --git a/hbase-native-client/core/client.h b/hbase-native-client/core/client.h index 0ba1276..2ff7c6d 100644 --- a/hbase-native-client/core/client.h +++ b/hbase-native-client/core/client.h @@ -27,11 +27,18 @@ #include #include +#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" -namespace hbase { +using hbase::pb::TableName; +namespace hbase { +class Table; /** * Client. * @@ -42,16 +49,50 @@ namespace hbase { class Client { public: /** - * Create a new client. + * @brief Create a new client. * @param quorum_spec Where to connect to get Zookeeper bootstrap information. */ - explicit Client(std::string quorum_spec); + explicit Client(const std::string &quorum_spec); ~Client(); + /** + * @brief Retrieve a Table implementation for accessing a table. + * @param - table_name + */ + std::unique_ptr
GetTable(const TableName &table_name); + + /** + * @brief Returns a LocationCache instance for this Client. + */ + const std::shared_ptr &LocationCache() const; + + /** + * @brief Returns a RPC instance to perform Async calls by this Client + * instance. + */ + const std::shared_ptr &RpcClient() const; + + /** + * @brief Returns a Configuration instance being used by this Client instance. + */ + const hbase::optional &Configuration() const; + + /** + * @brief Close the Client connection. + */ + void Close(); + private: std::shared_ptr cpu_executor_; std::shared_ptr io_executor_; - LocationCache location_cache_; + std::shared_ptr location_cache_; + std::shared_ptr rpc_client_ = + std::make_shared(); + + HBaseConfigurationLoader loader; + hbase::optional conf_ = loader.LoadDefaultResources(); + + bool is_closed_ = false; }; } // namespace hbase diff --git a/hbase-native-client/core/protobuf_request_builder-test.cc b/hbase-native-client/core/protobuf_request_builder-test.cc new file mode 100644 index 0000000..2f0d63b --- /dev/null +++ b/hbase-native-client/core/protobuf_request_builder-test.cc @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "core/protobuf_request_builder.h" + +#include +#include +#include "connection/request.h" +#include "core/get.h" +#include "core/scan.h" + +using hbase::Get; +using hbase::Scan; + +using hbase::pb::GetRequest; +using hbase::pb::RegionSpecifier; +using hbase::pb::RegionSpecifier_RegionSpecifierType; +using hbase::pb::ScanRequest; + +TEST(ProtobufRequestBuilder, Get) { + std::string row_str = "row-test"; + Get get(row_str); + get.AddFamily("family-1"); + get.AddFamily("family-2"); + get.AddFamily("family-3"); + get.AddColumn("family-2", "qualifier-1"); + get.AddColumn("family-2", "qualifier-2"); + get.AddColumn("family-2", "qualifier-3"); + get.SetCacheBlocks(false); + get.SetConsistency(hbase::pb::Consistency::TIMELINE); + get.SetMaxVersions(2); + get.SetTimeRange(10000, 20000); + std::string region_name("RegionName"); + + auto req = hbase::ProtobufRequestBuilder::BuildGetRequest(get, region_name); + auto msg = std::static_pointer_cast(req->req_msg()); + + // Tests whether the PB object is properly set or not. + ASSERT_TRUE(msg->has_region()); + ASSERT_TRUE(msg->region().has_value()); + EXPECT_EQ(msg->region().value(), region_name); + + ASSERT_TRUE(msg->has_get()); + EXPECT_EQ(msg->get().row(), row_str); + EXPECT_FALSE(msg->get().cache_blocks()); + EXPECT_EQ(msg->get().consistency(), hbase::pb::Consistency::TIMELINE); + EXPECT_EQ(msg->get().max_versions(), 2); + EXPECT_EQ(msg->get().column_size(), 3); + for (int i = 0; i < msg->get().column_size(); ++i) { + EXPECT_EQ(msg->get().column(i).family(), "family-" + std::to_string(i + 1)); + for (int j = 0; j < msg->get().column(i).qualifier_size(); ++j) { + EXPECT_EQ(msg->get().column(i).qualifier(j), + "qualifier-" + std::to_string(j + 1)); + } + } +} + +TEST(ProtobufRequestBuilder, Scan) { + std::string start_row("start-row"); + std::string stop_row("stop-row"); + hbase::Scan scan; + scan.AddFamily("family-1"); + scan.AddFamily("family-2"); + scan.AddFamily("family-3"); + scan.AddColumn("family-2", "qualifier-1"); + scan.AddColumn("family-2", "qualifier-2"); + scan.AddColumn("family-2", "qualifier-3"); + scan.SetReversed(true); + scan.SetStartRow(start_row); + scan.SetStopRow(stop_row); + scan.SetSmall(true); + scan.SetCaching(3); + scan.SetConsistency(hbase::pb::Consistency::TIMELINE); + scan.SetCacheBlocks(true); + scan.SetAllowPartialResults(true); + scan.SetLoadColumnFamiliesOnDemand(true); + scan.SetMaxVersions(5); + scan.SetTimeRange(10000, 20000); + std::string region_name("RegionName"); + + auto req = hbase::ProtobufRequestBuilder::BuildScanRequest(scan, region_name); + auto msg = std::static_pointer_cast(req->req_msg()); + + // Tests whether the PB object is properly set or not. + ASSERT_TRUE(msg->has_region()); + ASSERT_TRUE(msg->region().has_value()); + EXPECT_EQ(msg->region().value(), region_name); + + ASSERT_TRUE(msg->has_scan()); + EXPECT_TRUE(msg->scan().reversed()); + EXPECT_EQ(msg->scan().start_row(), start_row); + EXPECT_EQ(msg->scan().stop_row(), stop_row); + EXPECT_TRUE(msg->scan().small()); + EXPECT_EQ(msg->scan().caching(), 3); + EXPECT_EQ(msg->scan().consistency(), hbase::pb::Consistency::TIMELINE); + EXPECT_TRUE(msg->scan().cache_blocks()); + EXPECT_TRUE(msg->scan().allow_partial_results()); + EXPECT_TRUE(msg->scan().load_column_families_on_demand()); + EXPECT_EQ(msg->scan().max_versions(), 5); + EXPECT_EQ(msg->scan().max_result_size(), + std::numeric_limits::max()); + + EXPECT_EQ(msg->scan().column_size(), 3); + for (int i = 0; i < msg->scan().column_size(); ++i) { + EXPECT_EQ(msg->scan().column(i).family(), + "family-" + std::to_string(i + 1)); + for (int j = 0; j < msg->scan().column(i).qualifier_size(); ++j) { + EXPECT_EQ(msg->scan().column(i).qualifier(j), + "qualifier-" + std::to_string(j + 1)); + } + } + ASSERT_TRUE(msg->client_handles_partials()); + ASSERT_TRUE(msg->client_handles_heartbeats()); + ASSERT_FALSE(msg->track_scan_metrics()); +} diff --git a/hbase-native-client/core/protobuf_request_builder.h b/hbase-native-client/core/protobuf_request_builder.h new file mode 100644 index 0000000..5026807 --- /dev/null +++ b/hbase-native-client/core/protobuf_request_builder.h @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#pragma once + +#include +#include + +#include "connection/request.h" +#include "core/get.h" +#include "core/scan.h" + +using hbase::pb::RegionSpecifier; + +namespace hbase { + +class ProtobufRequestBuilder { + public: + ~ProtobufRequestBuilder(); + + /** + * @brief Returns a Request object comprising of PB GetRequest created using + * passed 'get' + * @param get - Get object used for creating GetRequest + * @param region_name - table region + */ + static std::unique_ptr BuildGetRequest( + const Get &get, const std::string ®ion_name); + + /** + * @brief Returns a Request object comprising of PB ScanRequest created using + * passed 'scan' + * @param scan - Scan object used for creating ScanRequest + * @param region_name - table region + */ + static std::unique_ptr BuildScanRequest( + const Scan &scan, const std::string ®ion_name); + + private: + // Constructor not rquired. We will have all static methods to create PB + // requests + ProtobufRequestBuilder(); + + /** + * @brief fills region_specifier with region values. + * @param region_name - table region + * @param region_specifier - RegionSpecifier to be filled and passed in PB + * Request. + */ + static void SetRegion(const std::string ®ion_name, + RegionSpecifier *region_specifier); +}; + +} /* namespace hbase */ diff --git a/hbase-native-client/core/result_scanner.h b/hbase-native-client/core/result_scanner.h new file mode 100644 index 0000000..ed58d6d --- /dev/null +++ b/hbase-native-client/core/result_scanner.h @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#pragma once + +#include +#include + +#include "core/result.h" +namespace hbase { + +class ResultScanner { + public: + /** + * Constructors + */ + explicit ResultScanner(const std::vector > &results); + ResultScanner(const ResultScanner &res_scanner); + virtual ~ResultScanner(); + + /** + * @brief Grab the next row's worth of values. The scanner will return a + * Result. + */ + virtual std::unique_ptr Next() = 0; + + /** + * @brief Returns a vector of Results for the number of rows specified by + * num_rows. + * @param - num_rows number of rows to return + */ + virtual std::vector > Next(int num_rows) = 0; + + /** + * @brief Allow the client to renew the scanner's lease on the server. Returns + * true if + * the lease was successfully renewed, false otherwise. + */ + virtual bool RenewLease() const = 0; + + /** + * @brief Closes the scanner and releases any resources it has allocated + */ + virtual void Close() = 0; + + private: + bool close_scanner_ = false; + std::vector > results_; +}; + +} /* namespace hbase */ diff --git a/hbase-native-client/core/table.cc b/hbase-native-client/core/table.cc new file mode 100644 index 0000000..db85eb1 --- /dev/null +++ b/hbase-native-client/core/table.cc @@ -0,0 +1,185 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "core/table.h" + +#include +#include +#include +#include + +#include + +#include "connection/rpc-client.h" +#include "core/cell.h" +#include "core/configuration.h" +#include "core/location-cache.h" +#include "core/protobuf_request_builder.h" +#include "security/user.h" +#include "serde/server-name.h" + +using folly::Future; +using hbase::security::User; +using hbase::pb::GetResponse; +using std::chrono::milliseconds; + +namespace hbase { + +Table::Table(const TableName &table_name, const Client &client) + : table_name_(std::make_shared(table_name)), + client_(std::make_shared(client)) { + const int kHBaseClientScannerCaching = std::numeric_limits::max(); + const int64_t kHBaseClientMaxResultSize = 2 * 1024 * 1024; + client_retries_ = + (client.Configuration()) + ? (*(client.Configuration())).GetInt("hbase.client.retries", 5) + : 5; + scanner_caching_ = + (client.Configuration()) + ? (*(client.Configuration())).GetInt("hbase.client.scanner.caching", + kHBaseClientScannerCaching) + : kHBaseClientScannerCaching; + scanner_max_result_size_ = (client.Configuration()) + ? (*(client.Configuration())).GetLong( + "hbase.client.scanner.max.result.size", + kHBaseClientMaxResultSize) + : kHBaseClientMaxResultSize; +} + +Table::~Table() {} + +Table::Table(const Table &table) { + table_name_.reset(new TableName(*table.table_name_)); + client_.reset(new Client(*table.client_)); + cleanup_connection_on_close_ = table.cleanup_connection_on_close_; + is_closed_ = table.is_closed_; + client_retries_ = table.client_retries_; + scanner_caching_ = table.scanner_caching_; + scanner_max_result_size_ = table.scanner_max_result_size_; +} + +Table &Table::operator=(const Table &table) { + table_name_.reset(new TableName(*table.table_name_)); + cleanup_connection_on_close_ = table.cleanup_connection_on_close_; + is_closed_ = false; + client_retries_ = table.client_retries_; + scanner_caching_ = table.scanner_caching_; + scanner_max_result_size_ = table.scanner_max_result_size_; + return *this; +} + +// TODO check if consistency is STRONG or TIMELINE and fire Get() accordingly +std::unique_ptr Table::Get(const hbase::Get &get) { + try { + auto cache = client_->LocationCache(); + if (cache == nullptr) { + return nullptr; + } + + auto loc = + cache->LocateFromMeta(*table_name_, get.Row()).get(milliseconds(1000)); + if (loc == nullptr) { + return nullptr; + } + + auto req = + hbase::ProtobufRequestBuilder::BuildGetRequest(get, loc->region_name()); + auto user = + User::defaultUser(); // TODO: make User::current() similar to UserUtil + auto rpc_client = client_->RpcClient(); + if (rpc_client == nullptr) { + return nullptr; + } + + Future f = rpc_client->AsyncCall( + loc->server_name().host_name(), loc->server_name().port(), + std::move(req), user, "ClientService"); + Response resp = f.get(); + std::shared_ptr get_resp = + std::static_pointer_cast(resp.resp_msg()); + + std::vector > vcells; + for (auto cell : get_resp->result().cell()) { + std::shared_ptr pcell = std::make_shared( + cell.row(), cell.family(), cell.qualifier(), cell.timestamp(), + cell.value(), static_cast(cell.cell_type())); + vcells.push_back(pcell); + } + + std::unique_ptr result = std::make_unique( + vcells, get_resp->result().exists(), get_resp->result().stale(), + get_resp->result().partial()); + return std::move(result); + } + catch (const std::runtime_error &rex) { + return nullptr; + } +} + +std::unique_ptr Table::GetScanner(const hbase::Scan &scan) { + hbase::Scan htable_scan(scan); + if (htable_scan.Caching() <= 0) { + htable_scan.SetCaching(scanner_caching_); + } + if (htable_scan.MaxResultSize() <= 0) { + htable_scan.SetMaxResultSize(scanner_max_result_size_); + } + + // TODO Empty placeholders as of now. + if (htable_scan.IsReversed()) { + if (htable_scan.IsSmall()) { + } else { + } + } else { + if (htable_scan.IsSmall()) { + } else { + } + } + + auto cache = client_->LocationCache(); + auto loc = cache->LocateFromMeta(*table_name_, htable_scan.StartRow()) + .get(milliseconds(5000)); + auto req = hbase::ProtobufRequestBuilder::BuildScanRequest( + htable_scan, loc->region_name()); + std::unique_ptr result_scanner; + return std::move(result_scanner); +} + +std::unique_ptr Table::GetScanner(const std::string &family) { + hbase::Scan scan; + scan.AddFamily(family); + return GetScanner(scan); +} + +std::unique_ptr Table::GetScanner(const std::string &family, + const std::string &qualifier) { + hbase::Scan scan; + scan.AddColumn(family, qualifier); + return GetScanner(scan); +} + +void Table::Close() { + if (is_closed_) return; + if (cleanup_connection_on_close_) { + client_->Close(); + } + is_closed_ = true; +} + +} /* namespace hbase */ diff --git a/hbase-native-client/core/table.h b/hbase-native-client/core/table.h new file mode 100644 index 0000000..3930be8 --- /dev/null +++ b/hbase-native-client/core/table.h @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#pragma once + +#include +#include +#include + +#include "core/client.h" +#include "core/get.h" +#include "core/scan.h" +#include "core/result.h" +#include "core/result_scanner.h" +#include "serde/table-name.h" + +using hbase::pb::TableName; + +namespace hbase { +class Client; + +class Table { + public: + /** + * Constructors + */ + Table(const TableName &table_name, const Client &client); + Table(const Table &table); + Table &operator=(const Table &table); + ~Table(); + + /** + * @brief - Returns a Result object for the constructed Get. + * @param - get Get object to perform HBase Get operation. + */ + std::unique_ptr Get(const hbase::Get &get); + + /** + * @brief - Returns a list of Result objects for the coresponding Get object + * in gets. + * @param - gets vector consisting of the Get objects for fetching results. + * This is a multi-get operation. + */ + std::vector > Get( + const std::vector &gets); + + /** + * @brief - Returns ResultScanner for the constructed Scan. + * @param - scan Scan object to perform HBase Scan + */ + std::unique_ptr GetScanner(const hbase::Scan &scan); + + /** + * @brief - Returns ResultScanner for the constructed Scan using the passed + * family. + * @param - family Family string used to construct a Scan object to perform + * HBase Scan operation. + */ + std::unique_ptr GetScanner(const std::string &family); + + /** + * @brief - Returns ResultScanner for the constructed Scan using the passed + * family and qualifier. + * @param - family Family string used to construct a Scan object to perform + * HBase Scan operation. + * @param - qualifier Qualifier string used to construct a Scan objectto + * perform HBase Scan operation. + */ + std::unique_ptr GetScanner(const std::string &family, + const std::string &qualifier); + + /** + * @brief - Close the client connection. + */ + void Close(); + + private: + std::shared_ptr table_name_; + std::shared_ptr client_; + bool cleanup_connection_on_close_ = false; + bool is_closed_ = false; + // default 5 retries. over-ridden in constructor. + int client_retries_ = 5; + // If HBase Scan is to be performed, below values will be set by reading + // config if not present. + int scanner_caching_; + int64_t scanner_max_result_size_; +}; +} /* namespace hbase */ -- 1.8.3.1