kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aw...@apache.org
Subject [kudu] 01/03: tserver: correct usage of col idx in SplitKeyRange
Date Mon, 11 Mar 2019 21:09:13 GMT
This is an automated email from the ASF dual-hosted git repository.

awong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 9d4ed7add75b20fa46fa38cfe246fa40ba2a3cba
Author: Andrew Wong <awong@apache.org>
AuthorDate: Fri Mar 8 18:23:16 2019 -0800

    tserver: correct usage of col idx in SplitKeyRange
    
    Added a basic tserver-level test to use the SplitKeyRange endpoint that
    would fail without this patch.
    
    Change-Id: If444ffa408b3827425ab07ef06ffd6ccc10e926e
    Reviewed-on: http://gerrit.cloudera.org:8080/12707
    Reviewed-by: Adar Dembo <adar@cloudera.com>
    Tested-by: Kudu Jenkins
    Reviewed-by: Yao Xu <oclarms.ant@gmail.com>
    Reviewed-by: Grant Henke <granthenke@apache.org>
---
 src/kudu/tserver/tablet_server-test.cc | 26 ++++++++++++++++++++++++++
 src/kudu/tserver/tablet_service.cc     |  6 +++---
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/src/kudu/tserver/tablet_server-test.cc b/src/kudu/tserver/tablet_server-test.cc
index dd60bd1..82aed13 100644
--- a/src/kudu/tserver/tablet_server-test.cc
+++ b/src/kudu/tserver/tablet_server-test.cc
@@ -2650,6 +2650,32 @@ TEST_F(TabletServerTest, TestOrderedScan_ProjectionWithKeyColumnsOutOfOrder)
{
                     R"((string string_val="hello $0", int32 int_val=$1, int32 key=$0))");
 }
 
+TEST_F(TabletServerTest, TestSplitKeyRange) {
+  int kNumRowsets = 10;
+  int kRowsetSize = 10;
+  scoped_refptr<TabletReplica> replica;
+  ASSERT_TRUE(mini_server_->server()->tablet_manager()->LookupTablet(kTabletId,
&replica));
+  for (int i = 0; i < kNumRowsets; i++) {
+    InsertTestRowsDirect(kRowsetSize * i, kRowsetSize);
+    ASSERT_OK(replica->tablet()->Flush());
+  }
+
+  {
+    SplitKeyRangeRequestPB req;
+    SplitKeyRangeResponsePB resp;
+    RpcController rpc;
+    req.set_tablet_id(kTabletId);
+    // Request the smallest possible chunk size, expecting we get back a range
+    // for every rowset.
+    req.set_target_chunk_size_bytes(1);
+    ColumnSchemaToPB(ColumnSchema("key", INT32), req.add_columns());
+    ASSERT_OK(proxy_->SplitKeyRange(req, &resp, &rpc));
+    SCOPED_TRACE(SecureDebugString(resp));
+    ASSERT_FALSE(resp.has_error());
+    ASSERT_EQ(kNumRowsets, resp.ranges_size());
+  }
+}
+
 TEST_F(TabletServerTest, TestAlterSchema) {
   AlterSchemaRequestPB req;
   AlterSchemaResponsePB resp;
diff --git a/src/kudu/tserver/tablet_service.cc b/src/kudu/tserver/tablet_service.cc
index eb6ecda..5d89ea1 100644
--- a/src/kudu/tserver/tablet_service.cc
+++ b/src/kudu/tserver/tablet_service.cc
@@ -1646,8 +1646,8 @@ void TabletServiceImpl::SplitKeyRange(const SplitKeyRangeRequestPB*
req,
 
   vector<ColumnId> column_ids;
   for (const ColumnSchema& column : schema.columns()) {
-    int column_id = tablet_schema.find_column(column.name());
-    if (PREDICT_FALSE(column_id == Schema::kColumnNotFound)) {
+    int column_idx = tablet_schema.find_column(column.name());
+    if (PREDICT_FALSE(column_idx == Schema::kColumnNotFound)) {
       SetupErrorAndRespond(resp->mutable_error(),
                            Status::InvalidArgument(
                                "Invalid SplitKeyRange column name", column.name()),
@@ -1655,7 +1655,7 @@ void TabletServiceImpl::SplitKeyRange(const SplitKeyRangeRequestPB*
req,
                            context);
       return;
     }
-    column_ids.emplace_back(column_id);
+    column_ids.emplace_back(tablet_schema.column_id(column_idx));
   }
 
   // Validate the target chunk size are valid


Mime
View raw message