You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2019/10/17 22:45:13 UTC

[kudu] branch branch-1.11.x updated: [common] Use EncodeKeyImpl() to handle different RowType

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

alexey pushed a commit to branch branch-1.11.x
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/branch-1.11.x by this push:
     new 6afb57d  [common] Use EncodeKeyImpl() to handle different RowType
6afb57d is described below

commit 6afb57d04e1e29de74682cb5492cc721670c82d8
Author: lingbin <li...@gmail.com>
AuthorDate: Wed Oct 16 15:38:25 2019 +0800

    [common] Use EncodeKeyImpl() to handle different RowType
    
    For different RowType, the processing logic in two overloaded
    EncodeRow() is duplicated.
    
    Change-Id: I5daf09a09c8916da1307b598be708588aa842803
    Reviewed-on: http://gerrit.cloudera.org:8080/14461
    Reviewed-by: Adar Dembo <ad...@cloudera.com>
    Tested-by: Adar Dembo <ad...@cloudera.com>
    (cherry picked from commit eedcbb1bffa32ee25573673ae55db27118d1d732)
    Reviewed-on: http://gerrit.cloudera.org:8080/14492
    Reviewed-by: Grant Henke <gr...@apache.org>
    Tested-by: Kudu Jenkins
---
 src/kudu/common/partition.cc | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/kudu/common/partition.cc b/src/kudu/common/partition.cc
index f406965..7bcfd34 100644
--- a/src/kudu/common/partition.cc
+++ b/src/kudu/common/partition.cc
@@ -198,7 +198,8 @@ void PartitionSchema::ToPB(PartitionSchemaPB* pb) const {
   SetColumnIdentifiers(range_schema_.column_ids, pb->mutable_range_schema()->mutable_columns());
 }
 
-Status PartitionSchema::EncodeKey(const KuduPartialRow& row, string* buf) const {
+template<typename Row>
+Status PartitionSchema::EncodeKeyImpl(const Row& row, string* buf) const {
   const KeyEncoder<string>& hash_encoder = GetKeyEncoder<string>(GetTypeInfo(UINT32));
 
   for (const HashBucketSchema& hash_bucket_schema : hash_bucket_schemas_) {
@@ -210,16 +211,12 @@ Status PartitionSchema::EncodeKey(const KuduPartialRow& row, string* buf) const
   return EncodeColumns(row, range_schema_.column_ids, buf);
 }
 
-Status PartitionSchema::EncodeKey(const ConstContiguousRow& row, string* buf) const {
-  const KeyEncoder<string>& hash_encoder = GetKeyEncoder<string>(GetTypeInfo(UINT32));
-
-  for (const HashBucketSchema& hash_bucket_schema : hash_bucket_schemas_) {
-    int32_t bucket;
-    RETURN_NOT_OK(BucketForRow(row, hash_bucket_schema, &bucket));
-    hash_encoder.Encode(&bucket, buf);
-  }
+Status PartitionSchema::EncodeKey(const KuduPartialRow& row, string* buf) const {
+  return EncodeKeyImpl(row, buf);
+}
 
-  return EncodeColumns(row, range_schema_.column_ids, buf);
+Status PartitionSchema::EncodeKey(const ConstContiguousRow& row, string* buf) const {
+  return EncodeKeyImpl(row, buf);
 }
 
 Status PartitionSchema::EncodeRangeKey(const KuduPartialRow& row,