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 2022/02/16 15:56:21 UTC
[kudu] branch branch-1.16.x updated: [common] fix a bug in Schema::Reset(cols, ...)
This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch branch-1.16.x
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/branch-1.16.x by this push:
new f52a5cc [common] fix a bug in Schema::Reset(cols, ...)
f52a5cc is described below
commit f52a5cc804136d52846daca870e9987c5b775c0f
Author: shenxingwuying <sh...@gmail.com>
AuthorDate: Tue Feb 8 16:21:44 2022 +0800
[common] fix a bug in Schema::Reset(cols, ...)
Prior to this patch, Schema::col_offsets_ was not cleared
upon calling Schema::Reset(). This patch addresses the issue.
A new test scenario is added to cover the corresponding regressions in future.
Change-Id: I7a197638cbfb568d5df605ed88f0bb95926ac722
Reviewed-on: http://gerrit.cloudera.org:8080/18213
Tested-by: Kudu Jenkins
Reviewed-by: Yingchun Lai <ac...@gmail.com>
Reviewed-by: Alexey Serbin <as...@cloudera.com>
(cherry picked from commit 426d2ecb04d0f76ac50fe0868f40398ba6848582)
Reviewed-on: http://gerrit.cloudera.org:8080/18236
Reviewed-by: Attila Bukor <ab...@apache.org>
---
src/kudu/common/schema-test.cc | 12 ++++++++++++
src/kudu/common/schema.cc | 1 +
2 files changed, 13 insertions(+)
diff --git a/src/kudu/common/schema-test.cc b/src/kudu/common/schema-test.cc
index 79fad9b..251402b 100644
--- a/src/kudu/common/schema-test.cc
+++ b/src/kudu/common/schema-test.cc
@@ -314,6 +314,18 @@ TEST_F(TestSchema, TestReset) {
1));
ASSERT_TRUE(schema.initialized());
+ Schema schema1;
+ ASSERT_OK(schema1.Reset({ ColumnSchema("col3", UINT64),
+ ColumnSchema("col4", STRING),
+ ColumnSchema("col5", UINT32),
+ ColumnSchema("col6", STRING) }, 2));
+ ASSERT_OK(schema.Reset(schema1.columns(), 2));
+ ASSERT_TRUE(schema == schema1);
+ for (int i = 0; i < schema1.num_columns(); i++) {
+ ASSERT_EQ(schema.column_offset(i), schema1.column_offset(i));
+ }
+ ASSERT_EQ(schema.key_byte_size(), schema1.key_byte_size());
+
// Move an uninitialized schema into the initialized schema.
Schema schema2;
schema = std::move(schema2);
diff --git a/src/kudu/common/schema.cc b/src/kudu/common/schema.cc
index a8df9f6..c46c653 100644
--- a/src/kudu/common/schema.cc
+++ b/src/kudu/common/schema.cc
@@ -281,6 +281,7 @@ Status Schema::Reset(vector<ColumnSchema> cols,
}
// Calculate the offset of each column in the row format.
+ col_offsets_.clear();
col_offsets_.reserve(cols_.size() + 1); // Include space for total byte size at the end.
size_t off = 0;
size_t i = 0;