This is an automated email from the ASF dual-hosted git repository. adar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 49d3438f0a5ac21d8875916ad437da71752f8ddd Author: Adar Dembo <[email protected]> AuthorDate: Mon Apr 1 15:31:20 2019 -0700 remove schema copies from RowBlock and RowBuilder AFAICT the schemas in these two always outlive the classes themselves, so there's no reason to make schema copies. This is especially painful for the MergeIterator where each sub-iterator has a RowBlock (and thus a full copy of the schema). Change-Id: Ie4d60640b2bac4f2b3077ddd696966e1f6658740 Reviewed-on: http://gerrit.cloudera.org:8080/12907 Tested-by: Kudu Jenkins Reviewed-by: Mike Percy <[email protected]> --- src/kudu/codegen/codegen-test.cc | 14 ++--- src/kudu/common/generic_iterators-test.cc | 6 +-- src/kudu/common/generic_iterators.cc | 6 +-- src/kudu/common/row.h | 38 ++++++++----- src/kudu/common/row_changelist-test.cc | 6 +-- src/kudu/common/rowblock.cc | 14 ++--- src/kudu/common/rowblock.h | 62 +++++++++++++--------- src/kudu/common/schema-test.cc | 6 +-- src/kudu/common/wire_protocol-test.cc | 8 +-- src/kudu/common/wire_protocol.cc | 6 +-- src/kudu/integration-tests/linked_list-test-util.h | 2 +- src/kudu/master/sys_catalog.cc | 2 +- src/kudu/tablet/cfile_set-test.cc | 8 +-- src/kudu/tablet/compaction-test.cc | 14 ++--- src/kudu/tablet/compaction.cc | 8 +-- src/kudu/tablet/delta_compaction.cc | 2 +- src/kudu/tablet/deltafile-test.cc | 2 +- src/kudu/tablet/diskrowset-test-base.h | 12 +++-- src/kudu/tablet/diskrowset-test.cc | 28 ++++++---- src/kudu/tablet/diskrowset.cc | 2 +- src/kudu/tablet/memrowset-test.cc | 16 +++--- src/kudu/tablet/mt-rowset_delta_compaction-test.cc | 2 +- src/kudu/tablet/mt-tablet-test.cc | 6 +-- src/kudu/tablet/tablet-decoder-eval-test.cc | 21 ++++---- src/kudu/tablet/tablet-pushdown-test.cc | 4 +- src/kudu/tablet/tablet-test-base.h | 2 +- src/kudu/tablet/tablet-test-util.h | 8 +-- src/kudu/tablet/tablet-test.cc | 6 +-- src/kudu/tablet/tablet_random_access-test.cc | 2 +- src/kudu/tserver/tablet_server-test-base.cc | 4 +- src/kudu/tserver/tablet_service.cc | 4 +- 31 files changed, 178 insertions(+), 143 deletions(-) diff --git a/src/kudu/codegen/codegen-test.cc b/src/kudu/codegen/codegen-test.cc index 2aace58..0db310b 100644 --- a/src/kudu/codegen/codegen-test.cc +++ b/src/kudu/codegen/codegen-test.cc @@ -86,7 +86,7 @@ class CodegenTest : public KuduTest { defaults_ = SchemaBuilder(defaults_).Build(); // add IDs test_rows_arena_.reset(new Arena(2 * 1024)); - RowBuilder rb(base_); + RowBuilder rb(&base_); for (int i = 0; i < kNumTestRows; ++i) { rb.AddUint64(i); rb.AddInt32(random_.Next32()); @@ -168,14 +168,14 @@ const Slice kStrWValue = "WWWWW STRING DEFAULT WRITE"; void CheckRowBlocksEqual(const RowBlock* rb1, const RowBlock* rb2, const string& name1, const string& name2) { CHECK_EQ(rb1->nrows(), rb2->nrows()); - const Schema& schema = rb1->schema(); + const Schema* schema = rb1->schema(); for (int i = 0; i < rb1->nrows(); ++i) { RowBlockRow row1 = rb1->row(i); RowBlockRow row2 = rb2->row(i); - CHECK_EQ(schema.Compare(row1, row2), 0) + CHECK_EQ(schema->Compare(row1, row2), 0) << "Rows unequal (failed at row " << i << "):\n" - << "\t(" << name1 << ") = " << schema.DebugRow(row1) << "\n" - << "\t(" << name2 << ") = " << schema.DebugRow(row2); + << "\t(" << name1 << ") = " << schema->DebugRow(row1) << "\n" + << "\t(" << name2 << ") = " << schema->DebugRow(row2); } } @@ -219,8 +219,8 @@ void CodegenTest::TestProjection(const Schema* proj) { CHECK_EQ(with->base_schema(), &base_); CHECK_EQ(with->projection(), proj); - RowBlock rb_with(*proj, kNumTestRows, &projections_arena_); - RowBlock rb_without(*proj, kNumTestRows, &projections_arena_); + RowBlock rb_with(proj, kNumTestRows, &projections_arena_); + RowBlock rb_without(proj, kNumTestRows, &projections_arena_); projections_arena_.Reset(); ProjectTestRows<READ>(with.get(), &rb_with); diff --git a/src/kudu/common/generic_iterators-test.cc b/src/kudu/common/generic_iterators-test.cc index d002e83..10592d2 100644 --- a/src/kudu/common/generic_iterators-test.cc +++ b/src/kudu/common/generic_iterators-test.cc @@ -364,7 +364,7 @@ void TestMerge(const Schema& schema, const TestIntRangePredicate &predicate, std::move(to_merge))); ASSERT_OK(merger->Init(&spec)); - RowBlock dst(schema, 100, nullptr); + RowBlock dst(&schema, 100, nullptr); size_t total_idx = 0; auto expected_iter = expected.cbegin(); while (merger->HasNext()) { @@ -452,7 +452,7 @@ TEST(TestMaterializingIterator, TestMaterializingPredicatePushdown) { ASSERT_EQ(0, spec.predicates().size()) << "Iterator should have pushed down predicate"; Arena arena(1024); - RowBlock dst(kIntSchema, 100, &arena); + RowBlock dst(&kIntSchema, 100, &arena); ASSERT_OK(materializing->NextBlock(&dst)); ASSERT_EQ(dst.nrows(), 100); @@ -499,7 +499,7 @@ TEST(TestPredicateEvaluatingIterator, TestPredicateEvaluation) { << "Predicate should be evaluated by the outer iterator"; Arena arena(1024); - RowBlock dst(kIntSchema, 100, &arena); + RowBlock dst(&kIntSchema, 100, &arena); ASSERT_OK(outer_iter->NextBlock(&dst)); ASSERT_EQ(dst.nrows(), 100); diff --git a/src/kudu/common/generic_iterators.cc b/src/kudu/common/generic_iterators.cc index 682c2e1..0230fc4 100644 --- a/src/kudu/common/generic_iterators.cc +++ b/src/kudu/common/generic_iterators.cc @@ -103,7 +103,7 @@ class MergeIterState { explicit MergeIterState(unique_ptr<RowwiseIterator> iter) : iter_(std::move(iter)), arena_(1024), - read_block_(iter_->schema(), kMergeRowBuffer, &arena_), + read_block_(&iter_->schema(), kMergeRowBuffer, &arena_), next_row_idx_(0), rows_advanced_(0), rows_valid_(0) @@ -387,7 +387,7 @@ Status MergeIterator::InitSubIterators(ScanSpec *spec) { Status MergeIterator::NextBlock(RowBlock* dst) { CHECK(initted_); - DCHECK_SCHEMA_EQ(dst->schema(), schema()); + DCHECK_SCHEMA_EQ(*dst->schema(), schema()); PrepareBatch(dst); RETURN_NOT_OK(MaterializeBlock(dst)); @@ -1015,7 +1015,7 @@ Status PredicateEvaluatingIterator::NextBlock(RowBlock *dst) { RETURN_NOT_OK(base_iter_->NextBlock(dst)); for (const auto& predicate : col_predicates_) { - int32_t col_idx = dst->schema().find_column(predicate.column().name()); + int32_t col_idx = dst->schema()->find_column(predicate.column().name()); if (col_idx == Schema::kColumnNotFound) { return Status::InvalidArgument("Unknown column in predicate", predicate.ToString()); } diff --git a/src/kudu/common/row.h b/src/kudu/common/row.h index 8015cdd..45090fc 100644 --- a/src/kudu/common/row.h +++ b/src/kudu/common/row.h @@ -429,6 +429,9 @@ class ContiguousRowHelper { template<class ContiguousRowType> class ContiguousRowCell { public: + // Constructs a new ContiguousRowCell. + // + // The 'row' object must outlive this ContiguousRowCell. ContiguousRowCell(const ContiguousRowType* row, int idx) : row_(row), col_idx_(idx) { } @@ -455,6 +458,9 @@ class ContiguousRow { public: typedef ContiguousRowCell<ContiguousRow> Cell; + // Constructs a new ContiguousRow. + // + // The 'schema' and 'row_data' objects must outlive this ContiguousRow. explicit ContiguousRow(const Schema* schema, uint8_t *row_data = NULL) : schema_(schema), row_data_(row_data) { } @@ -504,6 +510,9 @@ class ConstContiguousRow { public: typedef ContiguousRowCell<ConstContiguousRow> Cell; + // Constructs a new ConstContiguousRow. + // + // The 'row' object's schema and data must outlive this ConstContiguousRow. explicit ConstContiguousRow(const ContiguousRow &row) : schema_(row.schema_), row_data_(row.row_data_) { @@ -560,13 +569,16 @@ void ContiguousRowCell<ConstContiguousRow>::set_null(bool null) const; // Utility class for building rows corresponding to a given schema. // This is used only by tests. -// TODO: move it into a test utility. +// TODO(todd): move it into a test utility. class RowBuilder { public: - explicit RowBuilder(const Schema& schema) + // Constructs a new RowBuilder. + // + // The 'schema' object must outlive this RowBuilder. + explicit RowBuilder(const Schema* schema) : schema_(schema), arena_(1024), - bitmap_size_(ContiguousRowHelper::null_bitmap_size(schema)) { + bitmap_size_(ContiguousRowHelper::null_bitmap_size(*schema)) { Reset(); } @@ -579,12 +591,12 @@ class RowBuilder { // (eg using CopyRowToArena()). void Reset() { arena_.Reset(); - size_t row_size = schema_.byte_size() + bitmap_size_; + size_t row_size = schema_->byte_size() + bitmap_size_; buf_ = reinterpret_cast<uint8_t *>(arena_.AllocateBytes(row_size)); CHECK(buf_) << "could not allocate " << row_size << " bytes for row builder"; col_idx_ = 0; byte_idx_ = 0; - ContiguousRowHelper::InitNullsBitmap(schema_, buf_, bitmap_size_); + ContiguousRowHelper::InitNullsBitmap(*schema_, buf_, bitmap_size_); } void AddString(const Slice &slice) { @@ -674,8 +686,8 @@ class RowBuilder { } void AddNull() { - CHECK(schema_.column(col_idx_).is_nullable()); - BitmapSet(buf_ + schema_.byte_size(), col_idx_); + CHECK(schema_->column(col_idx_).is_nullable()); + BitmapSet(buf_ + schema_->byte_size(), col_idx_); Advance(); } @@ -691,16 +703,16 @@ class RowBuilder { // data is copied, it is not safe to Reset() before also calling // CopyRowIndirectDataToArena. const Slice data() const { - CHECK_EQ(byte_idx_, schema_.byte_size()); + CHECK_EQ(byte_idx_, schema_->byte_size()); return Slice(buf_, byte_idx_ + bitmap_size_); } - const Schema& schema() const { + const Schema* schema() const { return schema_; } ConstContiguousRow row() const { - return ConstContiguousRow(&schema_, data()); + return ConstContiguousRow(schema_, data()); } private: @@ -724,17 +736,17 @@ class RowBuilder { } void CheckNextType(DataType type) { - CHECK_EQ(schema_.column(col_idx_).type_info()->type(), + CHECK_EQ(schema_->column(col_idx_).type_info()->type(), type); } void Advance() { - int size = schema_.column(col_idx_).type_info()->size(); + int size = schema_->column(col_idx_).type_info()->size(); byte_idx_ += size; col_idx_++; } - const Schema schema_; + const Schema* schema_; Arena arena_; uint8_t *buf_; diff --git a/src/kudu/common/row_changelist-test.cc b/src/kudu/common/row_changelist-test.cc index 1797c89..c21ff7c 100644 --- a/src/kudu/common/row_changelist-test.cc +++ b/src/kudu/common/row_changelist-test.cc @@ -145,7 +145,7 @@ TEST_F(TestRowChangeList, TestReinserts) { { // Reinserts include indirect data, so it should be ok to make the RowBuilder a scoped var. - RowBuilder rb(schema_); + RowBuilder rb(&schema_); rb.AddString(Slice("hello")); rb.AddString(Slice("world")); rb.AddUint32(12345); @@ -168,9 +168,9 @@ TEST_F(TestRowChangeList, TestReinserts) { faststring buf2; RowChangeListEncoder reinsert_2_enc(&buf2); { - RowBlock block(schema_, 1, nullptr); + RowBlock block(&schema_, 1, nullptr); RowBlockRow dst_row = block.row(0); - RowBuilder rb(schema_); + RowBuilder rb(&schema_); rb.AddString(Slice("hello")); rb.AddString(Slice("mundo")); rb.AddUint32(54321); diff --git a/src/kudu/common/rowblock.cc b/src/kudu/common/rowblock.cc index df43eda..32cce4b 100644 --- a/src/kudu/common/rowblock.cc +++ b/src/kudu/common/rowblock.cc @@ -110,12 +110,12 @@ bool operator!=(const SelectionVector& a, const SelectionVector& b) { ////////////////////////////// // RowBlock ////////////////////////////// -RowBlock::RowBlock(const Schema &schema, +RowBlock::RowBlock(const Schema* schema, size_t nrows, Arena *arena) : schema_(schema), - columns_data_(schema.num_columns()), - column_null_bitmaps_(schema.num_columns()), + columns_data_(schema->num_columns()), + column_null_bitmaps_(schema->num_columns()), row_capacity_(nrows), nrows_(nrows), arena_(arena), @@ -123,8 +123,8 @@ RowBlock::RowBlock(const Schema &schema, CHECK_GT(row_capacity_, 0); size_t bitmap_size = BitmapSize(row_capacity_); - for (size_t i = 0; i < schema.num_columns(); ++i) { - const ColumnSchema& col_schema = schema.column(i); + for (size_t i = 0; i < schema->num_columns(); ++i) { + const ColumnSchema& col_schema = schema->column(i); size_t col_size = row_capacity_ * col_schema.type_info()->size(); columns_data_[i] = new uint8_t[col_size]; @@ -135,10 +135,10 @@ RowBlock::RowBlock(const Schema &schema, } RowBlock::~RowBlock() { - for (uint8_t *column_data : columns_data_) { + for (uint8_t* column_data : columns_data_) { delete[] column_data; } - for (uint8_t *bitmap_data : column_null_bitmaps_) { + for (uint8_t* bitmap_data : column_null_bitmaps_) { delete[] bitmap_data; } } diff --git a/src/kudu/common/rowblock.h b/src/kudu/common/rowblock.h index 2afd212..d2cfc82 100644 --- a/src/kudu/common/rowblock.h +++ b/src/kudu/common/rowblock.h @@ -149,6 +149,9 @@ bool operator!=(const SelectionVector& a, const SelectionVector& b); // underlying selection vector can easily be updated batch-by-batch. class SelectionVectorView { public: + // Constructs a new SelectionVectorView. + // + // The 'sel_vec' object must outlive this SelectionVectorView. explicit SelectionVectorView(SelectionVector *sel_vec) : sel_vec_(sel_vec), row_offset_(0) { } @@ -192,9 +195,12 @@ class SelectionVectorView { // of the latter doesn't mean you _should_. class RowBlock { public: - RowBlock(const Schema &schema, + // Constructs a new RowBlock. + // + // The 'schema' and 'arena' objects must outlive this RowBlock. + RowBlock(const Schema* schema, size_t nrows, - Arena *arena); + Arena* arena); ~RowBlock(); // Resize the block to the given number of rows. @@ -209,8 +215,8 @@ class RowBlock { RowBlockRow row(size_t idx) const; - const Schema &schema() const { return schema_; } - Arena *arena() const { return arena_; } + const Schema* schema() const { return schema_; } + Arena* arena() const { return arena_; } ColumnBlock column_block(size_t col_idx) const { return column_block(col_idx, nrows_); @@ -219,9 +225,9 @@ class RowBlock { ColumnBlock column_block(size_t col_idx, size_t nrows) const { DCHECK_LE(nrows, nrows_); - const ColumnSchema& col_schema = schema_.column(col_idx); - uint8_t *col_data = columns_data_[col_idx]; - uint8_t *nulls_bitmap = column_null_bitmaps_[col_idx]; + const ColumnSchema& col_schema = schema_->column(col_idx); + uint8_t* col_data = columns_data_[col_idx]; + uint8_t* nulls_bitmap = column_null_bitmaps_[col_idx]; return ColumnBlock(col_schema.type_info(), nulls_bitmap, col_data, nrows, arena_); } @@ -245,8 +251,8 @@ class RowBlock { // from unit tests. void ZeroMemory() { size_t bitmap_size = BitmapSize(row_capacity_); - for (size_t i = 0; i < schema_.num_columns(); ++i) { - const ColumnSchema& col_schema = schema_.column(i); + for (size_t i = 0; i < schema_->num_columns(); ++i) { + const ColumnSchema& col_schema = schema_->column(i); size_t col_size = col_schema.type_info()->size() * row_capacity_; memset(columns_data_[i], '\0', col_size); @@ -263,11 +269,11 @@ class RowBlock { // as predicates or deletions make rows invalid, they are set to 0s. // After a batch has completed, only those rows with associated true // bits in the selection vector are valid results for the scan. - SelectionVector *selection_vector() { + SelectionVector* selection_vector() { return &sel_vec_; } - const SelectionVector *selection_vector() const { + const SelectionVector* selection_vector() const { return &sel_vec_; } @@ -286,9 +292,9 @@ class RowBlock { return block_size; } - Schema schema_; - std::vector<uint8_t *> columns_data_; - std::vector<uint8_t *> column_null_bitmaps_; + const Schema* schema_; + std::vector<uint8_t*> columns_data_; + std::vector<uint8_t*> column_null_bitmaps_; // The maximum number of rows that can be stored in our allocated buffer. size_t row_capacity_; @@ -297,7 +303,7 @@ class RowBlock { // nrows_ <= row_capacity_ size_t nrows_; - Arena *arena_; + Arena* arena_; // The bitmap indicating which rows are valid in this block. // Deleted rows or rows which have failed to pass predicates will be zeroed @@ -315,11 +321,15 @@ class RowBlockRow { public: typedef ColumnBlock::Cell Cell; - explicit RowBlockRow(const RowBlock *row_block = NULL, size_t row_index = 0) + // Constructs a new RowBlockRow. + // + // The 'row_block' object must outlive this RowBlockRow. + explicit RowBlockRow(const RowBlock* row_block = nullptr, + size_t row_index = 0) : row_block_(row_block), row_index_(row_index) { } - RowBlockRow *Reset(const RowBlock *row_block, size_t row_index) { + RowBlockRow* Reset(const RowBlock* row_block, size_t row_index) { row_block_ = row_block; row_index_ = row_index; return this; @@ -334,22 +344,22 @@ class RowBlockRow { } const Schema* schema() const { - return &row_block_->schema(); + return row_block_->schema(); } bool is_null(size_t col_idx) const { return column_block(col_idx).is_null(row_index_); } - uint8_t *mutable_cell_ptr(size_t col_idx) const { + uint8_t* mutable_cell_ptr(size_t col_idx) const { return const_cast<uint8_t*>(cell_ptr(col_idx)); } - const uint8_t *cell_ptr(size_t col_idx) const { + const uint8_t* cell_ptr(size_t col_idx) const { return column_block(col_idx).cell_ptr(row_index_); } - const uint8_t *nullable_cell_ptr(size_t col_idx) const { + const uint8_t* nullable_cell_ptr(size_t col_idx) const { return column_block(col_idx).nullable_cell_ptr(row_index_); } @@ -363,23 +373,23 @@ class RowBlockRow { // Mark this row as unselected in the selection vector. void SetRowUnselected() { - // TODO: const-ness issues since this class holds a const RowBlock *. + // TODO(todd): const-ness issues since this class holds a const RowBlock*. // hack around this for now - SelectionVector *vec = const_cast<SelectionVector *>(row_block_->selection_vector()); + SelectionVector* vec = const_cast<SelectionVector*>(row_block_->selection_vector()); vec->SetRowUnselected(row_index_); } #ifndef NDEBUG void OverwriteWithPattern(StringPiece pattern) { - const Schema& schema = row_block_->schema(); - for (size_t col = 0; col < schema.num_columns(); col++) { + const Schema* schema = row_block_->schema(); + for (size_t col = 0; col < schema->num_columns(); col++) { row_block_->column_block(col).OverwriteWithPattern(row_index_, pattern); } } #endif private: - const RowBlock *row_block_; + const RowBlock* row_block_; size_t row_index_; }; diff --git a/src/kudu/common/schema-test.cc b/src/kudu/common/schema-test.cc index 1c5e8c6..0d26bbb 100644 --- a/src/kudu/common/schema-test.cc +++ b/src/kudu/common/schema-test.cc @@ -504,7 +504,7 @@ TEST_F(TestSchema, TestRowOperations) { Arena arena(1024); - RowBuilder rb(schema); + RowBuilder rb(&schema); rb.AddString(string("row_a_1")); rb.AddString(string("row_a_2")); rb.AddUint32(3); @@ -662,9 +662,9 @@ TEST(TestKeyEncoder, BenchmarkSimpleKey) { faststring fs; Schema schema({ ColumnSchema("col1", STRING) }, 1); - RowBuilder rb(schema); + RowBuilder rb(&schema); rb.AddString(Slice("hello world")); - ConstContiguousRow row(&rb.schema(), rb.data()); + ConstContiguousRow row(rb.schema(), rb.data()); LOG_TIMING(INFO, "Encoding") { for (int i = 0; i < 10000000; i++) { diff --git a/src/kudu/common/wire_protocol-test.cc b/src/kudu/common/wire_protocol-test.cc index 35aa7ea..4885b96 100644 --- a/src/kudu/common/wire_protocol-test.cc +++ b/src/kudu/common/wire_protocol-test.cc @@ -221,7 +221,7 @@ TEST_F(WireProtocolTest, TestBadSchema_DuplicateColumnName) { // converted to and from protobuf. TEST_F(WireProtocolTest, TestColumnarRowBlockToPB) { Arena arena(1024); - RowBlock block(schema_, 10, &arena); + RowBlock block(&schema_, 10, &arena); FillRowBlockWithTestRows(&block); // Convert to PB. @@ -258,7 +258,7 @@ TEST_F(WireProtocolTest, TestColumnarRowBlockToPBWithPadding) { ColumnSchema("col2", UNIXTIME_MICROS), ColumnSchema("col3", INT32, true /* nullable */), ColumnSchema("col4", UNIXTIME_MICROS, true /* nullable */)}, 1); - RowBlock block(tablet_schema, kNumRows, &arena); + RowBlock block(&tablet_schema, kNumRows, &arena); block.selection_vector()->SetAllTrue(); for (int i = 0; i < block.nrows(); i++) { @@ -342,7 +342,7 @@ TEST_F(WireProtocolTest, TestColumnarRowBlockToPBWithPadding) { TEST_F(WireProtocolTest, TestColumnarRowBlockToPBBenchmark) { Arena arena(1024); const int kNumTrials = AllowSlowTests() ? 100 : 10; - RowBlock block(schema_, 10000 * kNumTrials, &arena); + RowBlock block(&schema_, 10000 * kNumTrials, &arena); FillRowBlockWithTestRows(&block); RowwiseRowBlockPB pb; @@ -386,7 +386,7 @@ TEST_F(WireProtocolTest, TestInvalidRowBlock) { TEST_F(WireProtocolTest, TestBlockWithNoColumns) { Schema empty(std::vector<ColumnSchema>(), 0); Arena arena(1024); - RowBlock block(empty, 1000, &arena); + RowBlock block(&empty, 1000, &arena); block.selection_vector()->SetAllTrue(); // Unselect 100 rows for (int i = 0; i < 100; i++) { diff --git a/src/kudu/common/wire_protocol.cc b/src/kudu/common/wire_protocol.cc index ce2cf0b..e7781b7 100644 --- a/src/kudu/common/wire_protocol.cc +++ b/src/kudu/common/wire_protocol.cc @@ -891,10 +891,10 @@ void SerializeRowBlock(const RowBlock& block, faststring* indirect_data, bool pad_unixtime_micros_to_16_bytes) { DCHECK_GT(block.nrows(), 0); - const Schema& tablet_schema = block.schema(); + const Schema* tablet_schema = block.schema(); if (projection_schema == nullptr) { - projection_schema = &tablet_schema; + projection_schema = tablet_schema; } // Check whether we need to pad or if there are nullable columns, this will dictate whether @@ -932,7 +932,7 @@ void SerializeRowBlock(const RowBlock& block, size_t padding_so_far = 0; for (int p_schema_idx = 0; p_schema_idx < projection_schema->num_columns(); p_schema_idx++) { const ColumnSchema& col = projection_schema->column(p_schema_idx); - t_schema_idx = tablet_schema.find_column(col.name()); + t_schema_idx = tablet_schema->find_column(col.name()); DCHECK_NE(t_schema_idx, -1); size_t column_offset = projection_schema->column_offset(p_schema_idx) + padding_so_far; diff --git a/src/kudu/integration-tests/linked_list-test-util.h b/src/kudu/integration-tests/linked_list-test-util.h index e51fc27..46a509f 100644 --- a/src/kudu/integration-tests/linked_list-test-util.h +++ b/src/kudu/integration-tests/linked_list-test-util.h @@ -685,7 +685,7 @@ Status LinkedListTester::VerifyLinkedListLocal(const tablet::Tablet* tablet, RETURN_NOT_OK_PREPEND(iter->Init(nullptr), "Cannot initialize row iterator"); Arena arena(1024); - RowBlock block(projection, 100, &arena); + RowBlock block(&projection, 100, &arena); while (iter->HasNext()) { RETURN_NOT_OK(iter->NextBlock(&block)); for (int i = 0; i < block.nrows(); i++) { diff --git a/src/kudu/master/sys_catalog.cc b/src/kudu/master/sys_catalog.cc index c9bc5ad..4918f11 100644 --- a/src/kudu/master/sys_catalog.cc +++ b/src/kudu/master/sys_catalog.cc @@ -627,7 +627,7 @@ Status SysCatalogTable::ProcessRows( RETURN_NOT_OK(iter->Init(&spec)); Arena arena(32 * 1024); - RowBlock block(iter->schema(), 512, &arena); + RowBlock block(&iter->schema(), 512, &arena); while (iter->HasNext()) { RETURN_NOT_OK(iter->NextBlock(&block)); const size_t nrows = block.nrows(); diff --git a/src/kudu/tablet/cfile_set-test.cc b/src/kudu/tablet/cfile_set-test.cc index 20b9f22..33f21d3 100644 --- a/src/kudu/tablet/cfile_set-test.cc +++ b/src/kudu/tablet/cfile_set-test.cc @@ -94,7 +94,7 @@ class TestCFileSet : public KuduRowSetTest { ASSERT_OK(rsw.Open()); - RowBuilder rb(schema_); + RowBuilder rb(&schema_); for (int i = 0; i < nrows; i++) { rb.Reset(); rb.AddInt32(i * 2); @@ -193,7 +193,7 @@ class TestCFileSet : public KuduRowSetTest { // Check that the range was respected on all the results. Arena arena(1024); - RowBlock block(schema_, 100, &arena); + RowBlock block(&schema_, 100, &arena); while (iter->HasNext()) { ASSERT_OK_FAST(iter->NextBlock(&block)); for (size_t i = 0; i < block.nrows(); i++) { @@ -227,7 +227,7 @@ class TestCFileSet : public KuduRowSetTest { ASSERT_OK(iter->Init(&spec)); // Check that the range was respected on all the results. Arena arena(1024); - RowBlock block(schema_, 100, &arena); + RowBlock block(&schema_, 100, &arena); while (iter->HasNext()) { ASSERT_OK_FAST(iter->NextBlock(&block)); for (size_t i = 0; i < block.nrows(); i++) { @@ -284,7 +284,7 @@ TEST_F(TestCFileSet, TestPartiallyMaterialize) { ASSERT_OK(iter->Init(nullptr)); Arena arena(4096); - RowBlock block(schema_, 100, &arena); + RowBlock block(&schema_, 100, &arena); rowid_t row_idx = 0; while (iter->HasNext()) { arena.Reset(); diff --git a/src/kudu/tablet/compaction-test.cc b/src/kudu/tablet/compaction-test.cc index 6c83169..e5bafea 100644 --- a/src/kudu/tablet/compaction-test.cc +++ b/src/kudu/tablet/compaction-test.cc @@ -111,7 +111,7 @@ class TestCompaction : public KuduRowSetTest { TestCompaction() : KuduRowSetTest(CreateSchema()), op_id_(consensus::MaximumOpId()), - row_builder_(schema_), + row_builder_(&schema_), arena_(32*1024), clock_(clock::LogicalClock::CreateStartingAt(Timestamp::kInitialTimestamp)), log_anchor_registry_(new log::LogAnchorRegistry()) { @@ -160,9 +160,9 @@ class TestCompaction : public KuduRowSetTest { int row_key, int32_t val) { BuildRow(row_key, val); - if (!mrs->schema().Equals(row_builder_.schema())) { + if (!mrs->schema().Equals(*row_builder_.schema())) { // The MemRowSet is not projecting the row, so must be done by the caller - RowProjector projector(&row_builder_.schema(), &mrs->schema()); + RowProjector projector(row_builder_.schema(), &mrs->schema()); uint8_t rowbuf[ContiguousRowHelper::row_size(mrs->schema())]; ContiguousRow dst_row(&mrs->schema(), rowbuf); ASSERT_OK_FAST(projector.Init()); @@ -216,7 +216,8 @@ class TestCompaction : public KuduRowSetTest { nullable_col_id, &new_val); } - RowBuilder rb(schema_.CreateKeyProjection()); + Schema proj_key = schema_.CreateKeyProjection(); + RowBuilder rb(&proj_key); rb.AddString(Slice(keybuf)); RowSetKeyProbe probe(rb.row()); ProbeStats stats; @@ -253,7 +254,8 @@ class TestCompaction : public KuduRowSetTest { RowChangeListEncoder update(&update_buf); update.SetToDelete(); - RowBuilder rb(schema_.CreateKeyProjection()); + Schema proj_key = schema_.CreateKeyProjection(); + RowBuilder rb(&proj_key); rb.AddString(Slice(keybuf)); RowSetKeyProbe probe(rb.row()); ProbeStats stats; @@ -775,7 +777,7 @@ TEST_F(TestCompaction, TestDuplicatedRowsRandomCompaction) { } - RowBlock block(schema_, kBaseNumRowSets * kNumRowsPerRowSet, &arena_); + RowBlock block(&schema_, kBaseNumRowSets * kNumRowsPerRowSet, &arena_); // Go through the expected compaction input rows, flip the last undo into a redo and // build the base. This will give us the final version that we'll expect the result // of the real compaction to match. diff --git a/src/kudu/tablet/compaction.cc b/src/kudu/tablet/compaction.cc index 5f4510d..a076302 100644 --- a/src/kudu/tablet/compaction.cc +++ b/src/kudu/tablet/compaction.cc @@ -115,7 +115,7 @@ class MemRowSetCompactionInput : public CompactionInput { // Realloc the internal block storage if we don't have enough space to // copy the whole leaf node's worth of data into it. if (PREDICT_FALSE(!row_block_ || num_in_block > row_block_->nrows())) { - row_block_.reset(new RowBlock(iter_->schema(), num_in_block, nullptr)); + row_block_.reset(new RowBlock(&iter_->schema(), num_in_block, nullptr)); } arena_.Reset(); @@ -202,7 +202,7 @@ class DiskRowSetCompactionInput : public CompactionInput { redo_delta_iter_(std::move(redo_delta_iter)), undo_delta_iter_(std::move(undo_delta_iter)), arena_(32 * 1024), - block_(base_iter_->schema(), kRowsPerBlock, &arena_), + block_(&base_iter_->schema(), kRowsPerBlock, &arena_), redo_mutation_block_(kRowsPerBlock, static_cast<Mutation *>(nullptr)), undo_mutation_block_(kRowsPerBlock, static_cast<Mutation *>(nullptr)) {} @@ -689,7 +689,7 @@ class MergeCompactionInput : public CompactionInput { num_dup_rows_++; if (row_idx == 0) { duplicated_rows_.push_back(std::unique_ptr<RowBlock>( - new RowBlock(*schema_, kDuplicatedRowsPerBlock, static_cast<Arena*>(nullptr)))); + new RowBlock(schema_, kDuplicatedRowsPerBlock, static_cast<Arena*>(nullptr)))); } return duplicated_rows_.back()->row(row_idx); } @@ -1101,7 +1101,7 @@ Status FlushCompactionInput(CompactionInput* input, DCHECK(out->schema().has_column_ids()); - RowBlock block(out->schema(), kCompactionOutputBlockNumRows, nullptr); + RowBlock block(&out->schema(), kCompactionOutputBlockNumRows, nullptr); while (input->HasMoreBlocks()) { RETURN_NOT_OK(input->PrepareBlock(&rows)); diff --git a/src/kudu/tablet/delta_compaction.cc b/src/kudu/tablet/delta_compaction.cc index dd208b0..d6dbb9e 100644 --- a/src/kudu/tablet/delta_compaction.cc +++ b/src/kudu/tablet/delta_compaction.cc @@ -132,7 +132,7 @@ Status MajorDeltaCompaction::FlushRowSetAndDeltas(const IOContext* io_context) { RETURN_NOT_OK(delta_iter_->SeekToOrdinal(0)); Arena arena(32 * 1024); - RowBlock block(partial_schema_, kRowsPerBlock, &arena); + RowBlock block(&partial_schema_, kRowsPerBlock, &arena); DVLOG(1) << "Applying deltas and rewriting columns (" << partial_schema_.ToString() << ")"; DeltaStats redo_stats; diff --git a/src/kudu/tablet/deltafile-test.cc b/src/kudu/tablet/deltafile-test.cc index 65aefa7..02a72dc 100644 --- a/src/kudu/tablet/deltafile-test.cc +++ b/src/kudu/tablet/deltafile-test.cc @@ -176,7 +176,7 @@ class TestDeltaFile : public KuduTest { ASSERT_OK(s); ASSERT_OK(it->Init(nullptr)); - RowBlock block(schema_, 100, &arena_); + RowBlock block(&schema_, 100, &arena_); // Iterate through the faked table, starting with batches that // come before all of the updates, and extending a bit further diff --git a/src/kudu/tablet/diskrowset-test-base.h b/src/kudu/tablet/diskrowset-test-base.h index d26ee03..3c11c7c 100644 --- a/src/kudu/tablet/diskrowset-test-base.h +++ b/src/kudu/tablet/diskrowset-test-base.h @@ -114,7 +114,7 @@ class TestRowSet : public KuduRowSetTest { CHECK_OK(writer->Open()); char buf[256]; - RowBuilder rb(schema_); + RowBuilder rb(&schema_); for (int i = 0; i < n_rows; i++) { CHECK_OK(writer->RollIfNecessary()); rb.Reset(); @@ -179,7 +179,8 @@ class TestRowSet : public KuduRowSetTest { uint32_t row_idx, const RowChangeList &mutation, OperationResultPB* result) { - RowBuilder rb(schema_.CreateKeyProjection()); + Schema proj_key = schema_.CreateKeyProjection(); + RowBuilder rb(&proj_key); BuildRowKey(&rb, row_idx); RowSetKeyProbe probe(rb.row()); @@ -192,7 +193,8 @@ class TestRowSet : public KuduRowSetTest { } Status CheckRowPresent(const DiskRowSet &rs, uint32_t row_idx, bool *present) { - RowBuilder rb(schema_.CreateKeyProjection()); + Schema proj_key = schema_.CreateKeyProjection(); + RowBuilder rb(&proj_key); BuildRowKey(&rb, row_idx); RowSetKeyProbe probe(rb.row()); ProbeStats stats; @@ -219,7 +221,7 @@ class TestRowSet : public KuduRowSetTest { CHECK_OK(row_iter->Init(nullptr)); Arena arena(1024); int batch_size = 10000; - RowBlock dst(proj_val, batch_size, &arena); + RowBlock dst(&proj_val, batch_size, &arena); int i = 0; while (row_iter->HasNext()) { @@ -283,7 +285,7 @@ class TestRowSet : public KuduRowSetTest { int batch_size = 1000; Arena arena(1024); - RowBlock dst(schema, batch_size, &arena); + RowBlock dst(&schema, batch_size, &arena); int i = 0; int log_interval = expected_rows/20 / batch_size; diff --git a/src/kudu/tablet/diskrowset-test.cc b/src/kudu/tablet/diskrowset-test.cc index 01549cd..8f98be4 100644 --- a/src/kudu/tablet/diskrowset-test.cc +++ b/src/kudu/tablet/diskrowset-test.cc @@ -133,7 +133,8 @@ TEST_F(TestRowSet, TestRowSetRoundTrip) { // 1. Check a key which comes before all keys in rowset { - RowBuilder rb(schema_.CreateKeyProjection()); + Schema pk = schema_.CreateKeyProjection(); + RowBuilder rb(&pk); rb.AddString(Slice("h")); RowSetKeyProbe probe(rb.row()); bool present; @@ -143,7 +144,8 @@ TEST_F(TestRowSet, TestRowSetRoundTrip) { // 2. Check a key which comes after all keys in rowset { - RowBuilder rb(schema_.CreateKeyProjection()); + Schema pk = schema_.CreateKeyProjection(); + RowBuilder rb(&pk); rb.AddString(Slice("z")); RowSetKeyProbe probe(rb.row()); bool present; @@ -154,7 +156,8 @@ TEST_F(TestRowSet, TestRowSetRoundTrip) { // 3. Check a key which is not present, but comes between present // keys { - RowBuilder rb(schema_.CreateKeyProjection()); + Schema pk = schema_.CreateKeyProjection(); + RowBuilder rb(&pk); rb.AddString(Slice("hello 00000000000049x")); RowSetKeyProbe probe(rb.row()); bool present; @@ -165,8 +168,9 @@ TEST_F(TestRowSet, TestRowSetRoundTrip) { // 4. Check a key which is present { char buf[256]; - RowBuilder rb(schema_.CreateKeyProjection()); FormatKey(49, buf, sizeof(buf)); + Schema pk = schema_.CreateKeyProjection(); + RowBuilder rb(&pk); rb.AddString(Slice(buf)); RowSetKeyProbe probe(rb.row()); bool present; @@ -198,7 +202,8 @@ TEST_F(TestRowSet, TestRowSetUpdate) { enc.SetToDelete(); Timestamp timestamp(0); - RowBuilder rb(schema_.CreateKeyProjection()); + Schema proj_key = schema_.CreateKeyProjection(); + RowBuilder rb(&proj_key); rb.AddString(Slice("hello 00000000000049x")); RowSetKeyProbe probe(rb.row()); @@ -224,7 +229,8 @@ TEST_F(TestRowSet, TestErrorDuringUpdate) { // Get a row that we expect to be in the rowset. Timestamp timestamp(0); - RowBuilder rb(schema_.CreateKeyProjection()); + Schema proj_key = schema_.CreateKeyProjection(); + RowBuilder rb(&proj_key); rb.AddString(Slice("hello 000000000000050")); RowSetKeyProbe probe(rb.row()); @@ -383,7 +389,7 @@ TEST_F(TestRowSet, TestFlushedUpdatesRespectMVCC) { ASSERT_OK(drsw.Open()); - RowBuilder rb(schema_); + RowBuilder rb(&schema_); rb.AddString(key_slice); rb.AddUint32(1); ASSERT_OK_FAST(WriteRow(rb.data(), &drsw)); @@ -410,7 +416,8 @@ TEST_F(TestRowSet, TestFlushedUpdatesRespectMVCC) { tx.StartApplying(); update.Reset(); update.AddColumnUpdate(schema_.column(1), schema_.column_id(1), &i); - RowBuilder rb(schema_.CreateKeyProjection()); + Schema proj_key = schema_.CreateKeyProjection(); + RowBuilder rb(&proj_key); rb.AddString(key_slice); RowSetKeyProbe probe(rb.row()); OperationResultPB result; @@ -737,7 +744,7 @@ TEST_P(DiffScanRowSetTest, TestFuzz) { BloomFilterSizing::BySizeAndFPRate(32 * 1024, 0.01f)); ASSERT_OK(drsw.Open()); - RowBuilder rb(schema_); + RowBuilder rb(&schema_); for (int i = 0; i < 4; i++) { rb.Reset(); rb.AddUint32(i); @@ -833,7 +840,8 @@ TEST_P(DiffScanRowSetTest, TestFuzz) { } // Build the row key. - RowBuilder rb(schema_.CreateKeyProjection()); + Schema proj_key = schema_.CreateKeyProjection(); + RowBuilder rb(&proj_key); rb.AddUint32(row_idx); RowSetKeyProbe probe(rb.row()); diff --git a/src/kudu/tablet/diskrowset.cc b/src/kudu/tablet/diskrowset.cc index 5725e53..d6972cc 100644 --- a/src/kudu/tablet/diskrowset.cc +++ b/src/kudu/tablet/diskrowset.cc @@ -184,7 +184,7 @@ Status DiskRowSetWriter::InitAdHocIndexWriter() { } Status DiskRowSetWriter::AppendBlock(const RowBlock &block) { - DCHECK_EQ(block.schema().num_columns(), schema_->num_columns()); + DCHECK_EQ(block.schema()->num_columns(), schema_->num_columns()); CHECK(!finished_); // If this is the very first block, encode the first key and save it as metadata diff --git a/src/kudu/tablet/memrowset-test.cc b/src/kudu/tablet/memrowset-test.cc index 4cd3b25..ff8ba4b 100644 --- a/src/kudu/tablet/memrowset-test.cc +++ b/src/kudu/tablet/memrowset-test.cc @@ -116,7 +116,7 @@ class TestMemRowSet : public KuduTest { Status CheckRowPresent(const MemRowSet &mrs, const string &key, bool *present) { - RowBuilder rb(key_schema_); + RowBuilder rb(&key_schema_); rb.AddString(Slice(key)); RowSetKeyProbe probe(rb.row()); ProbeStats stats; @@ -125,7 +125,7 @@ class TestMemRowSet : public KuduTest { } Status InsertRows(MemRowSet *mrs, int num_rows) { - RowBuilder rb(schema_); + RowBuilder rb(&schema_); char keybuf[256]; for (uint32_t i = 0; i < num_rows; i++) { rb.Reset(); @@ -140,7 +140,7 @@ class TestMemRowSet : public KuduTest { Status InsertRow(MemRowSet *mrs, const string &key, uint32_t val) { ScopedTransaction tx(&mvcc_, clock_->Now()); - RowBuilder rb(schema_); + RowBuilder rb(&schema_); rb.AddString(key); rb.AddUint32(val); tx.StartApplying(); @@ -160,7 +160,7 @@ class TestMemRowSet : public KuduTest { RowChangeListEncoder update(&mutation_buf_); update.AddColumnUpdate(schema_.column(1), schema_.column_id(1), &new_val); - RowBuilder rb(key_schema_); + RowBuilder rb(&key_schema_); rb.AddString(Slice(key)); RowSetKeyProbe probe(rb.row()); ProbeStats stats; @@ -183,7 +183,7 @@ class TestMemRowSet : public KuduTest { RowChangeListEncoder update(&mutation_buf_); update.SetToDelete(); - RowBuilder rb(key_schema_); + RowBuilder rb(&key_schema_); rb.AddString(Slice(key)); RowSetKeyProbe probe(rb.row()); ProbeStats stats; @@ -203,7 +203,7 @@ class TestMemRowSet : public KuduTest { CHECK_OK(iter->Init(nullptr)); Arena arena(1024); - RowBlock block(schema_, 100, &arena); + RowBlock block(&schema_, 100, &arena); int fetched = 0; while (iter->HasNext()) { CHECK_OK(iter->NextBlock(&block)); @@ -298,7 +298,7 @@ TEST_F(TestMemRowSet, TestInsertAndIterateCompoundKey) { ASSERT_OK(MemRowSet::Create(0, compound_key_schema, log_anchor_registry_.get(), MemTracker::GetRootTracker(), &mrs)); - RowBuilder rb(compound_key_schema); + RowBuilder rb(&compound_key_schema); { ScopedTransaction tx(&mvcc_, clock_->Now()); tx.StartApplying(); @@ -542,7 +542,7 @@ TEST_F(TestMemRowSet, TestInsertionMVCC) { { ScopedTransaction tx(&mvcc_, clock_->Now()); tx.StartApplying(); - RowBuilder rb(schema_); + RowBuilder rb(&schema_); char keybuf[256]; rb.Reset(); snprintf(keybuf, sizeof(keybuf), "tx%d", i); diff --git a/src/kudu/tablet/mt-rowset_delta_compaction-test.cc b/src/kudu/tablet/mt-rowset_delta_compaction-test.cc index a1501db..6af4d12 100644 --- a/src/kudu/tablet/mt-rowset_delta_compaction-test.cc +++ b/src/kudu/tablet/mt-rowset_delta_compaction-test.cc @@ -109,7 +109,7 @@ class TestMultiThreadedRowSetDeltaCompaction : public TestRowSet { void ReadVerify(DiskRowSet *rs) { Arena arena(1024); - RowBlock dst(schema_, 1000, &arena); + RowBlock dst(&schema_, 1000, &arena); RowIteratorOptions opts; opts.projection = &schema_; unique_ptr<RowwiseIterator> iter; diff --git a/src/kudu/tablet/mt-tablet-test.cc b/src/kudu/tablet/mt-tablet-test.cc index f5a15e9..2e3afaa 100644 --- a/src/kudu/tablet/mt-tablet-test.cc +++ b/src/kudu/tablet/mt-tablet-test.cc @@ -143,7 +143,7 @@ class MultiThreadedTabletTest : public TabletTestBase<SETUP> { LocalTabletWriter writer(this->tablet().get(), &this->client_schema_); Arena tmp_arena(1024); - RowBlock block(schema_, 1, &tmp_arena); + RowBlock block(&schema_, 1, &tmp_arena); faststring update_buf; uint64_t updates_since_last_report = 0; @@ -213,7 +213,7 @@ class MultiThreadedTabletTest : public TabletTestBase<SETUP> { // trying to reference already-freed memrowset memory. void SlowReaderThread(int /*tid*/) { Arena arena(32*1024); - RowBlock block(schema_, 1, &arena); + RowBlock block(&schema_, 1, &arena); uint64_t max_rows = this->ClampRowCount(FLAGS_inserts_per_thread * FLAGS_num_insert_threads) / FLAGS_num_insert_threads; @@ -248,7 +248,7 @@ class MultiThreadedTabletTest : public TabletTestBase<SETUP> { Arena arena(1024); // unused, just scanning ints static const int kBufInts = 1024*1024 / 8; - RowBlock block(valcol_projection_, kBufInts, &arena); + RowBlock block(&valcol_projection_, kBufInts, &arena); ColumnBlock column = block.column_block(0); uint64_t count_since_report = 0; diff --git a/src/kudu/tablet/tablet-decoder-eval-test.cc b/src/kudu/tablet/tablet-decoder-eval-test.cc index eb4ff7c..3c5f43c 100644 --- a/src/kudu/tablet/tablet-decoder-eval-test.cc +++ b/src/kudu/tablet/tablet-decoder-eval-test.cc @@ -55,6 +55,7 @@ DEFINE_int32(decoder_eval_test_lower, 0, "Lower bound on the predicate [lower, u DEFINE_int32(decoder_eval_test_upper, 50, "Upper bound on the predicate [lower, upper)"); DEFINE_int32(decoder_eval_test_strlen, 10, "Number of strings per cell"); +using std::string; using std::unique_ptr; using strings::Substitute; @@ -136,7 +137,7 @@ public: } void FillTestTablet(size_t nrows, size_t cardinality, size_t strlen, int null_upper) { - RowBuilder rb(client_schema_); + RowBuilder rb(&client_schema_); LocalTabletWriter writer(tablet().get(), &client_schema_); KuduPartialRow row(&client_schema_); for (int64_t i = 0; i < nrows; i++) { @@ -163,8 +164,8 @@ public: ScanSpec spec; // Generate the predicate. - const std::string lower_string = LeftZeroPadded(lower_val, strlen); - const std::string upper_string = LeftZeroPadded(upper_val, strlen); + const string lower_string = LeftZeroPadded(lower_val, strlen); + const string upper_string = LeftZeroPadded(upper_val, strlen); Slice lower(lower_string); Slice upper(upper_string); auto string_pred = ColumnPredicate::Range(schema_.column(2), &lower, &upper); @@ -211,7 +212,7 @@ public: return (nrows / cardinality) * (upper - lower) + last_chunk_count; } - std::string LeftZeroPadded(size_t n, size_t strlen) { + string LeftZeroPadded(size_t n, size_t strlen) { // Assumes the string representation of n is under strlen characters. return StringPrintf(Substitute("%0$0$1", strlen, PRId64).c_str(), static_cast<int64_t>(n)); } @@ -231,12 +232,12 @@ public: ScanSpec spec; // Generate the predicates [0, upper) AND [lower, cardinality). - const std::string lower_string_a(LeftZeroPadded(0, strlen)); - const std::string upper_string_a(LeftZeroPadded(upper, strlen)); + const string lower_string_a(LeftZeroPadded(0, strlen)); + const string upper_string_a(LeftZeroPadded(upper, strlen)); Slice lower_a(lower_string_a); Slice upper_a(upper_string_a); - const std::string lower_string_b = LeftZeroPadded(lower, strlen); - const std::string upper_string_b = LeftZeroPadded(cardinality, strlen); + const string lower_string_b = LeftZeroPadded(lower, strlen); + const string upper_string_b = LeftZeroPadded(cardinality, strlen); Slice lower_b(lower_string_b); Slice upper_b(upper_string_b); @@ -260,9 +261,9 @@ public: Arena ret_arena(1024); size_t expected_count = ExpectedCount(nrows, cardinality, lower, upper); Schema schema = iter->schema(); - RowBlock block(schema, 100, &ret_arena); + RowBlock block(&schema, 100, &ret_arena); int fetched = 0; - std::string column_str_a, column_str_b; + string column_str_a, column_str_b; while (iter->HasNext()) { ASSERT_OK(iter->NextBlock(&block)); for (size_t i = 0; i < block.nrows(); i++) { diff --git a/src/kudu/tablet/tablet-pushdown-test.cc b/src/kudu/tablet/tablet-pushdown-test.cc index c9bee93..caeb227 100644 --- a/src/kudu/tablet/tablet-pushdown-test.cc +++ b/src/kudu/tablet/tablet-pushdown-test.cc @@ -74,7 +74,7 @@ class TabletPushdownTest : public KuduTabletTest, } void FillTestTablet() { - RowBuilder rb(client_schema_); + RowBuilder rb(&client_schema_); nrows_ = 2100; if (AllowSlowTests()) { @@ -236,7 +236,7 @@ class TabletSparsePushdownTest : public KuduTabletTest { void SetUp() override { KuduTabletTest::SetUp(); - RowBuilder rb(client_schema_); + RowBuilder rb(&client_schema_); LocalTabletWriter writer(tablet().get(), &client_schema_); KuduPartialRow row(&client_schema_); diff --git a/src/kudu/tablet/tablet-test-base.h b/src/kudu/tablet/tablet-test-base.h index ef98ef1..4a86a2b 100644 --- a/src/kudu/tablet/tablet-test-base.h +++ b/src/kudu/tablet/tablet-test-base.h @@ -435,7 +435,7 @@ class TabletTestBase : public KuduTabletTest { int batch_size = std::max<size_t>(1, std::min<size_t>(expected_row_count / 10, 4L * 1024 * 1024 / schema_.byte_size())); Arena arena(32*1024); - RowBlock block(schema_, batch_size, &arena); + RowBlock block(&schema_, batch_size, &arena); bool check_for_dups = true; if (expected_row_count > INT_MAX) { diff --git a/src/kudu/tablet/tablet-test-util.h b/src/kudu/tablet/tablet-test-util.h index 9571d4b..267a18c 100644 --- a/src/kudu/tablet/tablet-test-util.h +++ b/src/kudu/tablet/tablet-test-util.h @@ -199,7 +199,7 @@ static inline Status SilentIterateToStringList(RowwiseIterator* iter, int* fetched) { const Schema& schema = iter->schema(); Arena arena(1024); - RowBlock block(schema, 100, &arena); + RowBlock block(&schema, 100, &arena); *fetched = 0; while (iter->HasNext()) { RETURN_NOT_OK(iter->NextBlock(&block)); @@ -218,7 +218,7 @@ static inline Status IterateToStringList(RowwiseIterator* iter, out->clear(); Schema schema = iter->schema(); Arena arena(1024); - RowBlock block(schema, 100, &arena); + RowBlock block(&schema, 100, &arena); int fetched = 0; while (iter->HasNext() && fetched < limit) { RETURN_NOT_OK(iter->NextBlock(&block)); @@ -331,7 +331,7 @@ static Status WriteRow(const Slice &row_slice, RowSetWriterClass *writer) { const Schema &schema = writer->schema(); DCHECK_EQ(row_slice.size(), schema.byte_size()); - RowBlock block(schema, 1, nullptr); + RowBlock block(&schema, 1, nullptr); ConstContiguousRow row(&schema, row_slice.data()); RowBlockRow dst_row = block.row(0); RETURN_NOT_OK(CopyRow(row, &dst_row, static_cast<Arena*>(nullptr))); @@ -672,7 +672,7 @@ void CreateRandomDeltas(const Schema& schema, if (is_deleted) { // The row is deleted; we must REINSERT it. DCHECK(allow_reinserts); - RowBuilder rb(schema); + RowBuilder rb(&schema); for (int i = 0; i < schema.num_columns(); i++) { rb.AddUint32(prng->Next()); } diff --git a/src/kudu/tablet/tablet-test.cc b/src/kudu/tablet/tablet-test.cc index 3ceb6c1..895a185 100644 --- a/src/kudu/tablet/tablet-test.cc +++ b/src/kudu/tablet/tablet-test.cc @@ -491,7 +491,7 @@ TYPED_TEST(TestTablet, TestRowIteratorSimple) { ASSERT_TRUE(iter->HasNext()); - RowBlock block(this->schema_, 100, &this->arena_); + RowBlock block(&this->schema_, 100, &this->arena_); // First call to CopyNextRows should fetch the whole memrowset. ASSERT_OK_FAST(iter->NextBlock(&block)); @@ -564,7 +564,7 @@ TYPED_TEST(TestTablet, TestRowIteratorOrdered) { // Iterate the tablet collecting rows. vector<shared_ptr<faststring> > rows; for (int i = 0; i < numBlocks; i++) { - RowBlock block(this->schema_, rowsPerBlock, &this->arena_); + RowBlock block(&this->schema_, rowsPerBlock, &this->arena_); ASSERT_TRUE(iter->HasNext()); ASSERT_OK(iter->NextBlock(&block)); ASSERT_EQ(rowsPerBlock, block.nrows()) << "unexpected number of rows returned"; @@ -667,7 +667,7 @@ TYPED_TEST(TestTablet, TestRowIteratorComplex) { vector<bool> seen(max_rows, false); int seen_count = 0; - RowBlock block(schema, 100, &this->arena_); + RowBlock block(&schema, 100, &this->arena_); while (iter->HasNext()) { this->arena_.Reset(); ASSERT_OK(iter->NextBlock(&block)); diff --git a/src/kudu/tablet/tablet_random_access-test.cc b/src/kudu/tablet/tablet_random_access-test.cc index d8fc442..0c87894 100644 --- a/src/kudu/tablet/tablet_random_access-test.cc +++ b/src/kudu/tablet/tablet_random_access-test.cc @@ -281,7 +281,7 @@ class TestRandomAccess : public KuduTabletTest { int n_results = 0; Arena arena(1024); - RowBlock block(schema, 100, &arena); + RowBlock block(&schema, 100, &arena); while (iter->HasNext()) { arena.Reset(); CHECK_OK(iter->NextBlock(&block)); diff --git a/src/kudu/tserver/tablet_server-test-base.cc b/src/kudu/tserver/tablet_server-test-base.cc index 524a11a..1bfd976 100644 --- a/src/kudu/tserver/tablet_server-test-base.cc +++ b/src/kudu/tserver/tablet_server-test-base.cc @@ -102,7 +102,7 @@ void TabletServerTestBase::SetUp() { KuduTest::SetUp(); key_schema_ = schema_.CreateKeyProjection(); - rb_.reset(new RowBuilder(schema_)); + rb_.reset(new RowBuilder(&schema_)); rpc::MessengerBuilder bld("Client"); ASSERT_OK(bld.Build(&client_messenger_)); @@ -411,7 +411,7 @@ void TabletServerTestBase::VerifyRows(const Schema& schema, 4*1024*1024 / schema.byte_size())); Arena arena(32*1024); - RowBlock block(schema, batch_size, &arena); + RowBlock block(&schema, batch_size, &arena); int count = 0; while (iter->HasNext()) { diff --git a/src/kudu/tserver/tablet_service.cc b/src/kudu/tserver/tablet_service.cc index d240b68..1335b5d 100644 --- a/src/kudu/tserver/tablet_service.cc +++ b/src/kudu/tserver/tablet_service.cc @@ -783,7 +783,7 @@ class ScanResultChecksummer : public ScanResultCollector { const Schema* client_projection_schema = scanner->client_projection_schema(); if (!client_projection_schema) { - client_projection_schema = &row_block.schema(); + client_projection_schema = row_block.schema(); } size_t nrows = row_block.nrows(); @@ -2543,7 +2543,7 @@ Status TabletServiceImpl::HandleContinueScanRequest(const ScanRequestPB* req, // If people had really large indirect objects, we would currently overshoot // their requested batch size by a lot. Arena arena(32 * 1024); - RowBlock block(scanner->iter()->schema(), + RowBlock block(&scanner->iter()->schema(), FLAGS_scanner_batch_size_rows, &arena); // TODO(todd): in the future, use the client timeout to set a budget. For now,
