You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by gr...@apache.org on 2020/07/30 00:16:56 UTC
[kudu] branch master updated: KUDU-1802: Add
KuduScanner.GetKuduTable
This is an automated email from the ASF dual-hosted git repository.
granthenke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 5ad5d3d KUDU-1802: Add KuduScanner.GetKuduTable
5ad5d3d is described below
commit 5ad5d3d6606bbca33fc5909f7a96c7fefd0299e0
Author: Grant Henke <gr...@apache.org>
AuthorDate: Tue Jul 28 08:39:33 2020 -0500
KUDU-1802: Add KuduScanner.GetKuduTable
This patch adds the ability to get the KuduTable instance from the
KuduScanner. This allows the user to use the KuduTable instance
populated by the scan token instead of making a GetTableSchema
call to the master.
The complete KuduTable is passed to the KuduScanner in the
constructor, this patch allows it to be re-used by the consumer of the
scanner. It's literally a passthrough, but it helps when the KuduTable
was constructed internally (e.g via a ScanToken).
Change-Id: I09a80c6d499987553aef1338db93397a1de2491e
Reviewed-on: http://gerrit.cloudera.org:8080/16251
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <as...@cloudera.com>
---
src/kudu/client/client-test.cc | 8 ++++++++
src/kudu/client/client.cc | 4 ++++
src/kudu/client/client.h | 3 +++
3 files changed, 15 insertions(+)
diff --git a/src/kudu/client/client-test.cc b/src/kudu/client/client-test.cc
index 9d1dd86..b9cf55f 100644
--- a/src/kudu/client/client-test.cc
+++ b/src/kudu/client/client-test.cc
@@ -1345,6 +1345,14 @@ TEST_F(ClientTest, TestScanPredicateNonKeyColNotProjected) {
ASSERT_EQ(nrows, 6);
}
+TEST_F(ClientTest, TestGetKuduTable) {
+ KuduScanner scanner(client_table_.get());
+ shared_ptr<KuduTable> table = scanner.GetKuduTable();
+ ASSERT_EQ(table->name(), client_table_->name());
+ ASSERT_EQ(table->id(), client_table_->id());
+ ASSERT_EQ(table->schema().ToString(), client_table_->schema().ToString());
+}
+
// Test adding various sorts of invalid binary predicates.
TEST_F(ClientTest, TestInvalidPredicates) {
KuduScanner scanner(client_table_.get());
diff --git a/src/kudu/client/client.cc b/src/kudu/client/client.cc
index f748763..2d62546 100644
--- a/src/kudu/client/client.cc
+++ b/src/kudu/client/client.cc
@@ -1574,6 +1574,10 @@ KuduSchema KuduScanner::GetProjectionSchema() const {
return KuduSchema::FromSchema(*data_->configuration().projection());
}
+shared_ptr<KuduTable> KuduScanner::GetKuduTable() {
+ return data_->table_;
+}
+
Status KuduScanner::SetRowFormatFlags(uint64_t flags) {
switch (flags) {
case NO_FLAGS:
diff --git a/src/kudu/client/client.h b/src/kudu/client/client.h
index c1cde39..e665937 100644
--- a/src/kudu/client/client.h
+++ b/src/kudu/client/client.h
@@ -2426,6 +2426,9 @@ class KUDU_EXPORT KuduScanner {
/// @return Schema of the projection being scanned.
KuduSchema GetProjectionSchema() const;
+ /// @return KuduTable being scanned.
+ sp::shared_ptr<KuduTable> GetKuduTable();
+
/// @name Advanced/Unstable API
//
///@{