This is an automated email from the ASF dual-hosted git repository. alexey 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 426d2ec [common] fix a bug in Schema::Reset(cols, ...) 426d2ec is described below commit 426d2ecb04d0f76ac50fe0868f40398ba6848582 Author: shenxingwuying <shenxingwuy...@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 <acelyc1112...@gmail.com> Reviewed-by: Alexey Serbin <aser...@cloudera.com> --- 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;