You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2020/03/08 22:06:30 UTC
[kudu] branch master updated: common/tserver: replace gscoped_ptr
with unique_ptr
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
The following commit(s) were added to refs/heads/master by this push:
new f4bab12 common/tserver: replace gscoped_ptr with unique_ptr
f4bab12 is described below
commit f4bab12093a527ea6d6ba71cedc6c86ae37db561
Author: Adar Dembo <ad...@cloudera.com>
AuthorDate: Thu Mar 5 22:05:57 2020 -0800
common/tserver: replace gscoped_ptr with unique_ptr
There was a little bit of spillover into other modules. I'll get to them in
subsequent patches.
Change-Id: I369ba6a7d27eb7a68f928cef37b9d81fc1ca1ef0
Reviewed-on: http://gerrit.cloudera.org:8080/15379
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <as...@cloudera.com>
---
src/kudu/client/scan_configuration.cc | 5 ++--
src/kudu/common/columnblock.h | 8 +++---
src/kudu/common/encoded_key-test.cc | 15 +++++------
src/kudu/common/encoded_key.cc | 13 +++++-----
src/kudu/common/encoded_key.h | 14 +++++------
src/kudu/common/partition_pruner-test.cc | 13 +++++-----
src/kudu/common/rowblock.h | 9 ++-----
src/kudu/common/scan_spec-test.cc | 7 +++---
src/kudu/common/scan_spec.cc | 2 +-
src/kudu/master/sys_catalog.cc | 5 +---
src/kudu/tablet/rowset.h | 7 ++----
src/kudu/tablet/tablet-test.cc | 5 ++--
src/kudu/tablet/tablet_replica-test.cc | 6 ++---
src/kudu/tablet/transactions/transaction.h | 13 ++++------
src/kudu/tablet/transactions/transaction_driver.cc | 29 +++++++++++-----------
src/kudu/tools/tool_action_fs.cc | 4 +--
src/kudu/tserver/heartbeater.cc | 14 ++++++-----
src/kudu/tserver/scanners-test.cc | 1 -
src/kudu/tserver/scanners.h | 3 +--
src/kudu/tserver/tablet_copy_service-test.cc | 4 +--
.../tserver/tablet_copy_source_session-test.cc | 3 +--
src/kudu/tserver/tablet_server-test.cc | 5 ++--
src/kudu/tserver/tablet_server.h | 11 ++++----
src/kudu/tserver/tablet_service.cc | 11 ++++----
src/kudu/tserver/ts_tablet_manager-test.cc | 22 ++++++++--------
25 files changed, 105 insertions(+), 124 deletions(-)
diff --git a/src/kudu/client/scan_configuration.cc b/src/kudu/client/scan_configuration.cc
index 3e74b0f..ea4ef02 100644
--- a/src/kudu/client/scan_configuration.cc
+++ b/src/kudu/client/scan_configuration.cc
@@ -31,7 +31,6 @@
#include "kudu/common/encoded_key.h"
#include "kudu/common/partial_row.h"
#include "kudu/common/schema.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/strings/substitute.h"
using std::unique_ptr;
@@ -115,7 +114,7 @@ Status ScanConfiguration::AddUpperBound(const KuduPartialRow& key) {
Status ScanConfiguration::AddLowerBoundRaw(const Slice& key) {
// Make a copy of the key.
- gscoped_ptr<EncodedKey> enc_key;
+ unique_ptr<EncodedKey> enc_key;
RETURN_NOT_OK(EncodedKey::DecodeEncodedString(
*table_->schema().schema_, &arena_, key, &enc_key));
spec_.SetLowerBoundKey(enc_key.get());
@@ -125,7 +124,7 @@ Status ScanConfiguration::AddLowerBoundRaw(const Slice& key) {
Status ScanConfiguration::AddUpperBoundRaw(const Slice& key) {
// Make a copy of the key.
- gscoped_ptr<EncodedKey> enc_key;
+ unique_ptr<EncodedKey> enc_key;
RETURN_NOT_OK(EncodedKey::DecodeEncodedString(
*table_->schema().schema_, &arena_, key, &enc_key));
spec_.SetExclusiveUpperBoundKey(enc_key.get());
diff --git a/src/kudu/common/columnblock.h b/src/kudu/common/columnblock.h
index 45d0d2a..0915cd6 100644
--- a/src/kudu/common/columnblock.h
+++ b/src/kudu/common/columnblock.h
@@ -14,7 +14,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-
#pragma once
#include <cstddef>
@@ -26,7 +25,6 @@
#include "kudu/common/common.pb.h"
#include "kudu/common/types.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/strings/fastmem.h"
#include "kudu/gutil/strings/stringpiece.h"
#include "kudu/util/bitmap.h"
@@ -312,9 +310,9 @@ class ScopedColumnBlock : public ColumnBlock {
}
private:
- gscoped_array<uint8_t> null_bitmap_;
- gscoped_array<cpp_type> data_;
- gscoped_ptr<Arena> arena_;
+ std::unique_ptr<uint8_t[]> null_bitmap_;
+ std::unique_ptr<cpp_type[]> data_;
+ std::unique_ptr<Arena> arena_;
};
diff --git a/src/kudu/common/encoded_key-test.cc b/src/kudu/common/encoded_key-test.cc
index 077b2f0..7ef10f4 100644
--- a/src/kudu/common/encoded_key-test.cc
+++ b/src/kudu/common/encoded_key-test.cc
@@ -18,6 +18,7 @@
#include "kudu/common/encoded_key.h"
#include <cstdint>
+#include <memory>
#include <string>
#include <gtest/gtest.h>
@@ -25,7 +26,6 @@
#include "kudu/common/schema.h"
#include "kudu/common/common.pb.h"
#include "kudu/common/key_encoder.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/strings/substitute.h" // IWYU pragma: keep
#include "kudu/util/faststring.h"
#include "kudu/util/int128.h"
@@ -38,6 +38,7 @@
#include "kudu/util/test_macros.h"
using std::string;
+using std::unique_ptr;
namespace kudu {
@@ -73,9 +74,9 @@ class EncodedKeyTest : public KuduTest {
// Test whether target lies within the numerical key ranges given by
// start and end. If -1, an empty slice is used instead.
bool InRange(int start, int end, int target) {
- gscoped_ptr<EncodedKey> start_key(BuildEncodedKey(&key_builder_, start));
- gscoped_ptr<EncodedKey> end_key(BuildEncodedKey(&key_builder_, end));
- gscoped_ptr<EncodedKey> target_key(BuildEncodedKey(&key_builder_, target));
+ unique_ptr<EncodedKey> start_key(BuildEncodedKey(&key_builder_, start));
+ unique_ptr<EncodedKey> end_key(BuildEncodedKey(&key_builder_, end));
+ unique_ptr<EncodedKey> target_key(BuildEncodedKey(&key_builder_, target));
return target_key->InRange(start != -1 ? start_key->encoded_key() : Slice(),
end != -1 ? end_key->encoded_key() : Slice());
}
@@ -93,7 +94,7 @@ class EncodedKeyTest : public KuduTest {
Schema schema({ ColumnSchema("key", Type) }, 1);
EncodedKeyBuilder builder(&schema);
builder.AddColumnKey(val);
- gscoped_ptr<EncodedKey> key(builder.BuildEncodedKey());
+ unique_ptr<EncodedKey> key(builder.BuildEncodedKey());
EXPECT_ROWKEY_EQ(schema, expected, *key);
EXPECT_EQ(encoded_form, key->encoded_key());
}
@@ -192,7 +193,7 @@ TEST_F(EncodedKeyTest, TestDecodeSimpleKeys) {
}
TEST_F(EncodedKeyTest, TestDecodeCompoundKeys) {
- gscoped_ptr<EncodedKey> key;
+ unique_ptr<EncodedKey> key;
{
// Integer type compound key.
Schema schema({ ColumnSchema("key0", UINT16),
@@ -246,7 +247,7 @@ TEST_F(EncodedKeyTest, TestDecodeCompoundKeys) {
}
TEST_F(EncodedKeyTest, TestConstructFromEncodedString) {
- gscoped_ptr<EncodedKey> key;
+ unique_ptr<EncodedKey> key;
Arena arena(1024);
{
diff --git a/src/kudu/common/encoded_key.cc b/src/kudu/common/encoded_key.cc
index 48232cb..af68e36 100644
--- a/src/kudu/common/encoded_key.cc
+++ b/src/kudu/common/encoded_key.cc
@@ -16,6 +16,7 @@
// under the License.
#include <cstring>
+#include <memory>
#include <ostream>
#include <vector>
@@ -31,11 +32,11 @@
#include "kudu/util/logging.h"
#include "kudu/util/memory/arena.h"
-namespace kudu {
-
using std::string;
+using std::unique_ptr;
using std::vector;
+namespace kudu {
EncodedKey::EncodedKey(faststring* data,
vector<const void *> *raw_keys,
@@ -50,19 +51,19 @@ EncodedKey::EncodedKey(faststring* data,
raw_keys_.swap(*raw_keys);
}
-gscoped_ptr<EncodedKey> EncodedKey::FromContiguousRow(const ConstContiguousRow& row) {
+unique_ptr<EncodedKey> EncodedKey::FromContiguousRow(const ConstContiguousRow& row) {
EncodedKeyBuilder kb(row.schema());
for (int i = 0; i < row.schema()->num_key_columns(); i++) {
kb.AddColumnKey(row.cell_ptr(i));
}
- return make_gscoped_ptr(kb.BuildEncodedKey());
+ return unique_ptr<EncodedKey>(kb.BuildEncodedKey());
}
Status EncodedKey::DecodeEncodedString(const Schema& schema,
Arena* arena,
const Slice& encoded,
- gscoped_ptr<EncodedKey>* result) {
+ unique_ptr<EncodedKey>* result) {
uint8_t* raw_key_buf = static_cast<uint8_t*>(arena->AllocateBytes(schema.key_byte_size()));
if (PREDICT_FALSE(!raw_key_buf)) {
return Status::RuntimeError("OOM");
@@ -84,7 +85,7 @@ Status EncodedKey::DecodeEncodedString(const Schema& schema,
}
Status EncodedKey::IncrementEncodedKey(const Schema& tablet_schema,
- gscoped_ptr<EncodedKey> *key,
+ unique_ptr<EncodedKey> *key,
Arena* arena) {
// Copy the row itself to the Arena.
uint8_t* new_row_key = static_cast<uint8_t*>(
diff --git a/src/kudu/common/encoded_key.h b/src/kudu/common/encoded_key.h
index 28b8f50..3dc5519 100644
--- a/src/kudu/common/encoded_key.h
+++ b/src/kudu/common/encoded_key.h
@@ -14,15 +14,14 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-#ifndef KUDU_COMMON_ENCODED_KEY_H
-#define KUDU_COMMON_ENCODED_KEY_H
+#pragma once
#include <cstddef>
#include <cstdint>
+#include <memory>
#include <string>
#include <vector>
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/macros.h"
#include "kudu/util/faststring.h"
#include "kudu/util/slice.h"
@@ -46,7 +45,7 @@ class EncodedKey {
std::vector<const void *> *raw_keys,
size_t num_key_cols);
- static gscoped_ptr<EncodedKey> FromContiguousRow(const ConstContiguousRow& row);
+ static std::unique_ptr<EncodedKey> FromContiguousRow(const ConstContiguousRow& row);
// Decode the encoded key specified in 'encoded', which must correspond to the
// provided schema.
@@ -55,11 +54,11 @@ class EncodedKey {
static Status DecodeEncodedString(const Schema& schema,
Arena* arena,
const Slice& encoded,
- gscoped_ptr<EncodedKey> *result);
+ std::unique_ptr<EncodedKey> *result);
// Given an EncodedKey, increment it to the next lexicographically greater EncodedKey.
static Status IncrementEncodedKey(const Schema& tablet_schema,
- gscoped_ptr<EncodedKey>* key,
+ std::unique_ptr<EncodedKey>* key,
Arena* arena);
const Slice &encoded_key() const { return encoded_key_; }
@@ -91,7 +90,7 @@ class EncodedKey {
private:
const int num_key_cols_;
Slice encoded_key_;
- gscoped_ptr<uint8_t[]> data_;
+ std::unique_ptr<uint8_t[]> data_;
std::vector<const void *> raw_keys_;
};
@@ -121,4 +120,3 @@ class EncodedKeyBuilder {
};
} // namespace kudu
-#endif
diff --git a/src/kudu/common/partition_pruner-test.cc b/src/kudu/common/partition_pruner-test.cc
index 19690a5..2a0d78f 100644
--- a/src/kudu/common/partition_pruner-test.cc
+++ b/src/kudu/common/partition_pruner-test.cc
@@ -37,7 +37,6 @@
#include "kudu/common/row.h"
#include "kudu/common/scan_spec.h"
#include "kudu/common/schema.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/strings/substitute.h"
#include "kudu/util/auto_release_pool.h"
#include "kudu/util/memory/arena.h"
@@ -126,8 +125,8 @@ TEST_F(PartitionPrunerTest, TestPrimaryKeyRangePruning) {
ScanSpec spec;
KuduPartialRow lower_bound(&schema);
KuduPartialRow upper_bound(&schema);
- gscoped_ptr<EncodedKey> enc_lower_bound;
- gscoped_ptr<EncodedKey> enc_upper_bound;
+ unique_ptr<EncodedKey> enc_lower_bound;
+ unique_ptr<EncodedKey> enc_upper_bound;
if (lower) {
CHECK_OK(lower_bound.SetInt8("a", get<0>(*lower)));
@@ -247,8 +246,8 @@ TEST_F(PartitionPrunerTest, TestPartialPrimaryKeyRangePruning) {
ScanSpec spec;
KuduPartialRow lower_bound(&schema);
KuduPartialRow upper_bound(&schema);
- gscoped_ptr<EncodedKey> enc_lower_bound;
- gscoped_ptr<EncodedKey> enc_upper_bound;
+ unique_ptr<EncodedKey> enc_lower_bound;
+ unique_ptr<EncodedKey> enc_upper_bound;
if (lower) {
CHECK_OK(lower_bound.SetInt8("a", get<0>(*lower)));
@@ -359,8 +358,8 @@ TEST_F(PartitionPrunerTest, TestIntPartialPrimaryKeyRangePruning) {
ScanSpec spec;
KuduPartialRow lower_bound(&schema);
KuduPartialRow upper_bound(&schema);
- gscoped_ptr<EncodedKey> enc_lower_bound;
- gscoped_ptr<EncodedKey> enc_upper_bound;
+ unique_ptr<EncodedKey> enc_lower_bound;
+ unique_ptr<EncodedKey> enc_upper_bound;
if (lower) {
CHECK_OK(lower_bound.SetInt8("a", get<0>(*lower)));
diff --git a/src/kudu/common/rowblock.h b/src/kudu/common/rowblock.h
index 98e2283..52804b9 100644
--- a/src/kudu/common/rowblock.h
+++ b/src/kudu/common/rowblock.h
@@ -14,9 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-
-#ifndef KUDU_COMMON_ROWBLOCK_H
-#define KUDU_COMMON_ROWBLOCK_H
+#pragma once
#include <cstdint>
#include <cstring>
@@ -28,7 +26,6 @@
#include "kudu/common/columnblock.h"
#include "kudu/common/schema.h"
#include "kudu/common/types.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/macros.h"
#include "kudu/gutil/strings/stringpiece.h"
#include "kudu/util/bitmap.h"
@@ -178,7 +175,7 @@ class SelectionVector {
size_t n_rows_;
size_t n_bytes_;
- gscoped_array<uint8_t> bitmap_;
+ std::unique_ptr<uint8_t[]> bitmap_;
DISALLOW_COPY_AND_ASSIGN(SelectionVector);
};
@@ -471,5 +468,3 @@ inline RowBlockRow RowBlock::row(size_t idx) const {
}
} // namespace kudu
-
-#endif
diff --git a/src/kudu/common/scan_spec-test.cc b/src/kudu/common/scan_spec-test.cc
index fbbd3ca..123d1de 100644
--- a/src/kudu/common/scan_spec-test.cc
+++ b/src/kudu/common/scan_spec-test.cc
@@ -19,6 +19,7 @@
#include <cstdint>
#include <cstring>
+#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
@@ -34,7 +35,6 @@
#include "kudu/common/partial_row.h"
#include "kudu/common/row.h"
#include "kudu/common/schema.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/map-util.h"
#include "kudu/gutil/strings/stringpiece.h"
#include "kudu/util/auto_release_pool.h"
@@ -44,6 +44,7 @@
#include "kudu/util/test_macros.h"
#include "kudu/util/test_util.h"
+using std::unique_ptr;
using std::vector;
namespace kudu {
@@ -117,7 +118,7 @@ class TestScanSpec : public KuduTest {
void SetLowerBound(ScanSpec* spec, const KuduPartialRow& row) {
CHECK(row.IsKeySet());
ConstContiguousRow cont_row(row.schema(), row.row_data_);
- gscoped_ptr<EncodedKey> enc_key(EncodedKey::FromContiguousRow(cont_row));
+ unique_ptr<EncodedKey> enc_key(EncodedKey::FromContiguousRow(cont_row));
spec->SetLowerBoundKey(enc_key.get());
pool_.Add(enc_key.release());
}
@@ -127,7 +128,7 @@ class TestScanSpec : public KuduTest {
void SetExclusiveUpperBound(ScanSpec* spec, const KuduPartialRow& row) {
CHECK(row.IsKeySet());
ConstContiguousRow cont_row(row.schema(), row.row_data_);
- gscoped_ptr<EncodedKey> enc_key(EncodedKey::FromContiguousRow(cont_row));
+ unique_ptr<EncodedKey> enc_key(EncodedKey::FromContiguousRow(cont_row));
spec->SetExclusiveUpperBoundKey(enc_key.get());
pool_.Add(enc_key.release());
}
diff --git a/src/kudu/common/scan_spec.cc b/src/kudu/common/scan_spec.cc
index d20826d..b336409 100644
--- a/src/kudu/common/scan_spec.cc
+++ b/src/kudu/common/scan_spec.cc
@@ -19,6 +19,7 @@
#include <algorithm>
#include <iterator>
+#include <memory>
#include <ostream>
#include <string>
#include <unordered_set>
@@ -34,7 +35,6 @@
#include "kudu/common/row.h"
#include "kudu/common/schema.h"
#include "kudu/common/types.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/map-util.h"
#include "kudu/gutil/strings/join.h"
#include "kudu/gutil/strings/substitute.h"
diff --git a/src/kudu/master/sys_catalog.cc b/src/kudu/master/sys_catalog.cc
index c095096..164b278 100644
--- a/src/kudu/master/sys_catalog.cc
+++ b/src/kudu/master/sys_catalog.cc
@@ -23,9 +23,7 @@
#include <iterator>
#include <memory>
#include <ostream>
-#include <set>
#include <string>
-#include <type_traits>
#include <utility>
#include <vector>
@@ -58,7 +56,6 @@
#include "kudu/fs/fs_manager.h"
#include "kudu/gutil/bind.h"
#include "kudu/gutil/bind_helpers.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/port.h"
#include "kudu/gutil/strings/join.h"
#include "kudu/gutil/strings/substitute.h"
@@ -491,7 +488,7 @@ Status SysCatalogTable::SyncWrite(const WriteRequestPB& req) {
}
CountDownLatch latch(1);
WriteResponsePB resp;
- gscoped_ptr<tablet::TransactionCompletionCallback> txn_callback(
+ unique_ptr<tablet::TransactionCompletionCallback> txn_callback(
new LatchTransactionCompletionCallback<WriteResponsePB>(&latch, &resp));
unique_ptr<tablet::WriteTransactionState> tx_state(
new tablet::WriteTransactionState(tablet_replica_.get(),
diff --git a/src/kudu/tablet/rowset.h b/src/kudu/tablet/rowset.h
index e08b515..9e96e2c 100644
--- a/src/kudu/tablet/rowset.h
+++ b/src/kudu/tablet/rowset.h
@@ -14,8 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-#ifndef KUDU_TABLET_ROWSET_H
-#define KUDU_TABLET_ROWSET_H
+#pragma once
#include <cstddef>
#include <cstdint>
@@ -346,7 +345,7 @@ class RowSetKeyProbe {
private:
const ConstContiguousRow row_key_;
- gscoped_ptr<EncodedKey> encoded_key_;
+ std::unique_ptr<EncodedKey> encoded_key_;
BloomKeyProbe bloom_probe_;
};
@@ -509,5 +508,3 @@ class DuplicatingRowSet : public RowSet {
} // namespace tablet
} // namespace kudu
-
-#endif
diff --git a/src/kudu/tablet/tablet-test.cc b/src/kudu/tablet/tablet-test.cc
index 3f83998..0482ac4 100644
--- a/src/kudu/tablet/tablet-test.cc
+++ b/src/kudu/tablet/tablet-test.cc
@@ -44,7 +44,6 @@
#include "kudu/common/wire_protocol.pb.h"
#include "kudu/fs/block_id.h"
#include "kudu/fs/block_manager.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/port.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/gutil/stl_util.h"
@@ -1320,8 +1319,8 @@ TEST_F(TestTabletStringKey, TestSplitKeyRange) {
}
// test split key range with bound
{
- gscoped_ptr<EncodedKey> l_enc_key;
- gscoped_ptr<EncodedKey> u_enc_key;
+ unique_ptr<EncodedKey> l_enc_key;
+ unique_ptr<EncodedKey> u_enc_key;
Arena arena(256);
KuduPartialRow lower_bound(&this->schema_);
CHECK_OK(lower_bound.SetString("key", "1"));
diff --git a/src/kudu/tablet/tablet_replica-test.cc b/src/kudu/tablet/tablet_replica-test.cc
index 3d60c47..7cba80d 100644
--- a/src/kudu/tablet/tablet_replica-test.cc
+++ b/src/kudu/tablet/tablet_replica-test.cc
@@ -290,7 +290,7 @@ class TabletReplicaTest : public KuduTabletTest {
resp.get()));
CountDownLatch rpc_latch(1);
- tx_state->set_completion_callback(gscoped_ptr<TransactionCompletionCallback>(
+ tx_state->set_completion_callback(unique_ptr<TransactionCompletionCallback>(
new LatchTransactionCompletionCallback<WriteResponsePB>(&rpc_latch, resp.get())));
RETURN_NOT_OK(replica->SubmitWrite(std::move(tx_state)));
@@ -314,7 +314,7 @@ class TabletReplicaTest : public KuduTabletTest {
unique_ptr<AlterSchemaTransactionState> tx_state(
new AlterSchemaTransactionState(replica, &req, resp.get()));
CountDownLatch rpc_latch(1);
- tx_state->set_completion_callback(gscoped_ptr<TransactionCompletionCallback>(
+ tx_state->set_completion_callback(unique_ptr<TransactionCompletionCallback>(
new LatchTransactionCompletionCallback<AlterSchemaResponsePB>(&rpc_latch, resp.get())));
RETURN_NOT_OK(replica->SubmitAlterSchema(std::move(tx_state)));
rpc_latch.Wait();
@@ -589,7 +589,7 @@ TEST_F(TabletReplicaTest, TestActiveTransactionPreventsLogGC) {
nullptr, // No RequestIdPB
resp.get()));
- tx_state->set_completion_callback(gscoped_ptr<TransactionCompletionCallback>(
+ tx_state->set_completion_callback(unique_ptr<TransactionCompletionCallback>(
new LatchTransactionCompletionCallback<WriteResponsePB>(&rpc_latch, resp.get())));
gscoped_ptr<DelayedApplyTransaction> transaction(
diff --git a/src/kudu/tablet/transactions/transaction.h b/src/kudu/tablet/transactions/transaction.h
index 01d3122..ba4b64d 100644
--- a/src/kudu/tablet/transactions/transaction.h
+++ b/src/kudu/tablet/transactions/transaction.h
@@ -14,9 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-
-#ifndef KUDU_TABLET_TRANSACTION_H_
-#define KUDU_TABLET_TRANSACTION_H_
+#pragma once
#include <cstddef>
#include <cstdint>
@@ -194,8 +192,9 @@ class TransactionState {
return &tx_metrics_;
}
- void set_completion_callback(gscoped_ptr<TransactionCompletionCallback> completion_clbk) {
- completion_clbk_.reset(completion_clbk.release());
+ void set_completion_callback(
+ std::unique_ptr<TransactionCompletionCallback> completion_clbk) {
+ completion_clbk_ = std::move(completion_clbk);
}
// Returns the completion callback.
@@ -281,7 +280,7 @@ class TransactionState {
scoped_refptr<rpc::ResultTracker> result_tracker_;
// Optional callback to be called once the transaction completes.
- gscoped_ptr<TransactionCompletionCallback> completion_clbk_;
+ std::unique_ptr<TransactionCompletionCallback> completion_clbk_;
AutoReleasePool pool_;
@@ -372,5 +371,3 @@ class LatchTransactionCompletionCallback : public TransactionCompletionCallback
} // namespace tablet
} // namespace kudu
-
-#endif /* KUDU_TABLET_TRANSACTION_H_ */
diff --git a/src/kudu/tablet/transactions/transaction_driver.cc b/src/kudu/tablet/transactions/transaction_driver.cc
index d6e1375..2f4d9c0 100644
--- a/src/kudu/tablet/transactions/transaction_driver.cc
+++ b/src/kudu/tablet/transactions/transaction_driver.cc
@@ -53,20 +53,21 @@
#include "kudu/util/threadpool.h"
#include "kudu/util/trace.h"
-namespace kudu {
-namespace tablet {
-
-using consensus::CommitMsg;
-using consensus::DriverType;
-using consensus::RaftConsensus;
-using consensus::ReplicateMsg;
-using log::Log;
-using pb_util::SecureShortDebugString;
-using rpc::RequestIdPB;
-using rpc::ResultTracker;
+using kudu::consensus::CommitMsg;
+using kudu::consensus::DriverType;
+using kudu::consensus::RaftConsensus;
+using kudu::consensus::ReplicateMsg;
+using kudu::log::Log;
+using kudu::pb_util::SecureShortDebugString;
+using kudu::rpc::RequestIdPB;
+using kudu::rpc::ResultTracker;
using std::string;
+using std::unique_ptr;
using strings::Substitute;
+namespace kudu {
+namespace tablet {
+
static const char* kTimestampFieldName = "timestamp";
class FollowerTransactionCompletionCallback : public TransactionCompletionCallback {
@@ -156,11 +157,11 @@ Status TransactionDriver::Init(gscoped_ptr<Transaction> transaction,
// before the transaction has a chance to fail.
const rpc::RequestIdPB& request_id = state()->request_id();
const google::protobuf::Message* response = state()->response();
- gscoped_ptr<TransactionCompletionCallback> callback(
+ unique_ptr<TransactionCompletionCallback> callback(
new FollowerTransactionCompletionCallback(request_id,
response,
state()->result_tracker()));
- mutable_state()->set_completion_callback(callback.Pass());
+ mutable_state()->set_completion_callback(std::move(callback));
}
} else {
DCHECK_EQ(type, consensus::LEADER);
@@ -263,7 +264,7 @@ void TransactionDriver::RegisterFollowerTransactionOnResultTracker() {
case ResultTracker::RpcState::STALE:
case ResultTracker::RpcState::COMPLETED: {
mutable_state()->set_completion_callback(
- gscoped_ptr<TransactionCompletionCallback>(new TransactionCompletionCallback()));
+ unique_ptr<TransactionCompletionCallback>(new TransactionCompletionCallback()));
VLOG(2) << state()->result_tracker() << " Follower Rpc was already COMPLETED or STALE: "
<< rpc_state << " OpId: " << SecureShortDebugString(state()->op_id())
<< " RequestId: " << SecureShortDebugString(state()->request_id());
diff --git a/src/kudu/tools/tool_action_fs.cc b/src/kudu/tools/tool_action_fs.cc
index 1f0c6c4..2a1e903 100644
--- a/src/kudu/tools/tool_action_fs.cc
+++ b/src/kudu/tools/tool_action_fs.cc
@@ -43,10 +43,10 @@
#include "kudu/fs/block_id.h"
#include "kudu/fs/block_manager.h"
#include "kudu/fs/data_dirs.h"
+#include "kudu/fs/dir_manager.h"
#include "kudu/fs/fs.pb.h"
#include "kudu/fs/fs_manager.h"
#include "kudu/fs/fs_report.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/map-util.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/gutil/strings/human_readable.h"
@@ -595,7 +595,7 @@ string FormatCFileKeyMetadata(const TabletMetadata& tablet,
}
Arena arena(1024);
- gscoped_ptr<EncodedKey> key;
+ unique_ptr<EncodedKey> key;
CHECK_OK(EncodedKey::DecodeEncodedString(tablet.schema(), &arena, value, &key));
return key->Stringify(tablet.schema());
}
diff --git a/src/kudu/tserver/heartbeater.cc b/src/kudu/tserver/heartbeater.cc
index 3216ffd..d88ebf5 100644
--- a/src/kudu/tserver/heartbeater.cc
+++ b/src/kudu/tserver/heartbeater.cc
@@ -17,6 +17,7 @@
#include "kudu/tserver/heartbeater.h"
+#include <algorithm>
#include <atomic>
#include <cstdint>
#include <memory>
@@ -29,13 +30,13 @@
#include <boost/optional/optional.hpp>
#include <gflags/gflags.h>
-#include <gflags/gflags_declare.h>
#include <glog/logging.h>
+#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/port.h>
#include "kudu/common/wire_protocol.h"
#include "kudu/common/wire_protocol.pb.h"
#include "kudu/consensus/replica_management.pb.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/map-util.h"
#include "kudu/gutil/port.h"
#include "kudu/gutil/ref_counted.h"
@@ -111,6 +112,7 @@ using kudu::pb_util::SecureDebugString;
using kudu::rpc::ErrorStatusPB;
using kudu::rpc::RpcController;
using std::string;
+using std::unique_ptr;
using std::vector;
using strings::Substitute;
@@ -148,7 +150,7 @@ class Heartbeater::Thread {
void SetupCommonField(master::TSToMasterCommonPB* common);
bool IsCurrentThread() const;
// Creates a proxy to 'hostport'.
- Status MasterServiceProxyForHostPort(gscoped_ptr<MasterServiceProxy>* proxy);
+ Status MasterServiceProxyForHostPort(unique_ptr<MasterServiceProxy>* proxy);
// The host and port of the master that this thread will heartbeat to.
//
@@ -164,7 +166,7 @@ class Heartbeater::Thread {
scoped_refptr<kudu::Thread> thread_;
// Current RPC proxy to the leader master.
- gscoped_ptr<MasterServiceProxy> proxy_;
+ unique_ptr<MasterServiceProxy> proxy_;
// The most recent response from a heartbeat.
master::TSHeartbeatResponsePB last_hb_response_;
@@ -310,7 +312,7 @@ Heartbeater::Thread::Thread(HostPort master_address, TabletServer* server)
}
Status Heartbeater::Thread::ConnectToMaster() {
- gscoped_ptr<MasterServiceProxy> new_proxy;
+ unique_ptr<MasterServiceProxy> new_proxy;
RETURN_NOT_OK(MasterServiceProxyForHostPort(&new_proxy));
// Ping the master to verify that it's alive.
master::PingRequestPB req;
@@ -715,7 +717,7 @@ void Heartbeater::Thread::GenerateFullTabletReport(TabletReportPB* report) {
}
Status Heartbeater::Thread::MasterServiceProxyForHostPort(
- gscoped_ptr<MasterServiceProxy>* proxy) {
+ unique_ptr<MasterServiceProxy>* proxy) {
vector<Sockaddr> addrs;
RETURN_NOT_OK(server_->dns_resolver()->ResolveAddresses(master_address_,
&addrs));
diff --git a/src/kudu/tserver/scanners-test.cc b/src/kudu/tserver/scanners-test.cc
index e2456c4..a3d4c11 100644
--- a/src/kudu/tserver/scanners-test.cc
+++ b/src/kudu/tserver/scanners-test.cc
@@ -22,7 +22,6 @@
#include <gflags/gflags_declare.h>
#include <gtest/gtest.h>
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/rpc/remote_user.h"
#include "kudu/tablet/tablet_replica.h"
diff --git a/src/kudu/tserver/scanners.h b/src/kudu/tserver/scanners.h
index 15eb86c..b30bcb9 100644
--- a/src/kudu/tserver/scanners.h
+++ b/src/kudu/tserver/scanners.h
@@ -31,7 +31,6 @@
#include "kudu/common/iterator_stats.h"
#include "kudu/common/scan_spec.h"
#include "kudu/common/schema.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/macros.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/rpc/remote_user.h"
@@ -142,7 +141,7 @@ class ScannerManager {
void RecordCompletedScanUnlocked(ScanDescriptor descriptor);
// (Optional) scanner metrics for this instance.
- gscoped_ptr<ScannerMetrics> metrics_;
+ std::unique_ptr<ScannerMetrics> metrics_;
// If true, removal thread should shut itself down. Protected
// by 'shutdown_lock_' and 'shutdown_cv_'.
diff --git a/src/kudu/tserver/tablet_copy_service-test.cc b/src/kudu/tserver/tablet_copy_service-test.cc
index 9f8afb5..38ebd2a 100644
--- a/src/kudu/tserver/tablet_copy_service-test.cc
+++ b/src/kudu/tserver/tablet_copy_service-test.cc
@@ -38,7 +38,6 @@
#include "kudu/fs/data_dirs.h"
#include "kudu/fs/fs.pb.h"
#include "kudu/fs/fs_manager.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/port.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/rpc/rpc_controller.h"
@@ -72,6 +71,7 @@ using kudu::rpc::RpcController;
using std::atomic;
using std::string;
using std::thread;
+using std::unique_ptr;
using std::vector;
namespace kudu {
@@ -208,7 +208,7 @@ class TabletCopyServiceTest : public TabletCopyTest {
return data_id;
}
- gscoped_ptr<TabletCopyServiceProxy> tablet_copy_proxy_;
+ unique_ptr<TabletCopyServiceProxy> tablet_copy_proxy_;
};
// Test beginning and ending a tablet copy session.
diff --git a/src/kudu/tserver/tablet_copy_source_session-test.cc b/src/kudu/tserver/tablet_copy_source_session-test.cc
index 1041d9b..ff94519 100644
--- a/src/kudu/tserver/tablet_copy_source_session-test.cc
+++ b/src/kudu/tserver/tablet_copy_source_session-test.cc
@@ -45,7 +45,6 @@
#include "kudu/fs/fs_manager.h"
#include "kudu/gutil/bind.h"
#include "kudu/gutil/bind_helpers.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/gutil/strings/fastmem.h"
#include "kudu/gutil/strings/substitute.h"
@@ -216,7 +215,7 @@ class TabletCopyTest : public KuduTabletTest {
&req,
nullptr, // No RequestIdPB
&resp));
- state->set_completion_callback(gscoped_ptr<tablet::TransactionCompletionCallback>(
+ state->set_completion_callback(unique_ptr<tablet::TransactionCompletionCallback>(
new tablet::LatchTransactionCompletionCallback<WriteResponsePB>(&latch, &resp)));
ASSERT_OK(tablet_replica_->SubmitWrite(std::move(state)));
latch.Wait();
diff --git a/src/kudu/tserver/tablet_server-test.cc b/src/kudu/tserver/tablet_server-test.cc
index 8f5c64b..30dfb43 100644
--- a/src/kudu/tserver/tablet_server-test.cc
+++ b/src/kudu/tserver/tablet_server-test.cc
@@ -66,7 +66,6 @@
#include "kudu/gutil/basictypes.h"
#include "kudu/gutil/callback.h"
#include "kudu/gutil/casts.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/map-util.h"
#include "kudu/gutil/port.h"
#include "kudu/gutil/ref_counted.h"
@@ -2666,11 +2665,11 @@ TEST_F(TabletServerTest, TestScanWithEncodedPredicates) {
int32_t stop_key_int = 60;
EncodedKeyBuilder ekb(&schema_);
ekb.AddColumnKey(&start_key_int);
- gscoped_ptr<EncodedKey> start_encoded(ekb.BuildEncodedKey());
+ unique_ptr<EncodedKey> start_encoded(ekb.BuildEncodedKey());
ekb.Reset();
ekb.AddColumnKey(&stop_key_int);
- gscoped_ptr<EncodedKey> stop_encoded(ekb.BuildEncodedKey());
+ unique_ptr<EncodedKey> stop_encoded(ekb.BuildEncodedKey());
scan->mutable_start_primary_key()->assign(
reinterpret_cast<const char*>(start_encoded->encoded_key().data()),
diff --git a/src/kudu/tserver/tablet_server.h b/src/kudu/tserver/tablet_server.h
index 2382f92..71d0923 100644
--- a/src/kudu/tserver/tablet_server.h
+++ b/src/kudu/tserver/tablet_server.h
@@ -22,7 +22,6 @@
#include <string>
#include "kudu/gutil/atomicops.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/macros.h"
#include "kudu/kserver/kserver.h"
#include "kudu/tserver/tablet_server_options.h"
@@ -118,18 +117,18 @@ class TabletServer : public kserver::KuduServer {
const TabletServerOptions opts_;
// Manager for tablets which are available on this server.
- gscoped_ptr<TSTabletManager> tablet_manager_;
+ std::unique_ptr<TSTabletManager> tablet_manager_;
// Manager for open scanners from clients.
// This is always non-NULL. It is scoped only to minimize header
// dependencies.
- gscoped_ptr<ScannerManager> scanner_manager_;
+ std::unique_ptr<ScannerManager> scanner_manager_;
// Thread responsible for heartbeating to the master.
- gscoped_ptr<Heartbeater> heartbeater_;
+ std::unique_ptr<Heartbeater> heartbeater_;
- // Webserver path handlers
- gscoped_ptr<TabletServerPathHandlers> path_handlers_;
+ // Webserver path handlers.
+ std::unique_ptr<TabletServerPathHandlers> path_handlers_;
// The maintenance manager for this tablet server
std::shared_ptr<MaintenanceManager> maintenance_manager_;
diff --git a/src/kudu/tserver/tablet_service.cc b/src/kudu/tserver/tablet_service.cc
index b10eeff..b120661 100644
--- a/src/kudu/tserver/tablet_service.cc
+++ b/src/kudu/tserver/tablet_service.cc
@@ -58,7 +58,6 @@
#include "kudu/fs/fs_manager.h"
#include "kudu/gutil/basictypes.h"
#include "kudu/gutil/casts.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/macros.h"
#include "kudu/gutil/map-util.h"
#include "kudu/gutil/ref_counted.h"
@@ -999,7 +998,7 @@ void TabletServiceAdminImpl::AlterSchema(const AlterSchemaRequestPB* req,
unique_ptr<AlterSchemaTransactionState> tx_state(
new AlterSchemaTransactionState(replica.get(), req, resp));
- tx_state->set_completion_callback(gscoped_ptr<TransactionCompletionCallback>(
+ tx_state->set_completion_callback(unique_ptr<TransactionCompletionCallback>(
new RpcTransactionCompletionCallback<AlterSchemaResponsePB>(context,
resp)));
@@ -1253,7 +1252,7 @@ void TabletServiceImpl::Write(const WriteRequestPB* req,
return;
}
- tx_state->set_completion_callback(gscoped_ptr<TransactionCompletionCallback>(
+ tx_state->set_completion_callback(unique_ptr<TransactionCompletionCallback>(
new RpcTransactionCompletionCallback<WriteResponsePB>(context,
resp)));
@@ -1913,7 +1912,8 @@ void TabletServiceImpl::SplitKeyRange(const SplitKeyRangeRequestPB* req,
// Decode encoded key
Arena arena(256);
Schema tablet_schema = replica->tablet_metadata()->schema();
- gscoped_ptr<EncodedKey> start, stop;
+ unique_ptr<EncodedKey> start;
+ unique_ptr<EncodedKey> stop;
if (req->has_start_primary_key()) {
s = EncodedKey::DecodeEncodedString(tablet_schema, &arena, req->start_primary_key(), &start);
if (PREDICT_FALSE(!s.ok())) {
@@ -2154,7 +2154,8 @@ static Status DecodeEncodedKeyRange(const NewScanRequestPB& scan_pb,
const Schema& tablet_schema,
const SharedScanner& scanner,
ScanSpec* spec) {
- gscoped_ptr<EncodedKey> start, stop;
+ unique_ptr<EncodedKey> start;
+ unique_ptr<EncodedKey> stop;
if (scan_pb.has_start_primary_key()) {
RETURN_NOT_OK_PREPEND(EncodedKey::DecodeEncodedString(
tablet_schema, scanner->arena(),
diff --git a/src/kudu/tserver/ts_tablet_manager-test.cc b/src/kudu/tserver/ts_tablet_manager-test.cc
index a346089..9a0b9e9 100644
--- a/src/kudu/tserver/ts_tablet_manager-test.cc
+++ b/src/kudu/tserver/ts_tablet_manager-test.cc
@@ -18,6 +18,7 @@
#include "kudu/tserver/ts_tablet_manager.h"
#include <cstdint>
+#include <memory>
#include <ostream>
#include <string>
#include <utility>
@@ -35,7 +36,6 @@
#include "kudu/consensus/metadata.pb.h"
#include "kudu/consensus/opid_util.h"
#include "kudu/consensus/raft_consensus.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/port.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/master/master.pb.h"
@@ -63,7 +63,16 @@ DECLARE_int32(update_tablet_metrics_interval_ms);
#define ASSERT_MONOTONIC_REPORT_SEQNO(report_seqno, tablet_report) \
NO_FATALS(AssertMonotonicReportSeqno(report_seqno, tablet_report))
+using kudu::consensus::kInvalidOpIdIndex;
+using kudu::consensus::RaftConfigPB;
+using kudu::master::ReportedTabletPB;
+using kudu::master::TabletReportPB;
+using kudu::pb_util::SecureShortDebugString;
+using kudu::tablet::LocalTabletWriter;
+using kudu::tablet::Tablet;
+using kudu::tablet::TabletReplica;
using std::string;
+using std::unique_ptr;
using std::vector;
namespace kudu {
@@ -72,15 +81,6 @@ class FsManager;
namespace tserver {
-using consensus::kInvalidOpIdIndex;
-using consensus::RaftConfigPB;
-using master::ReportedTabletPB;
-using master::TabletReportPB;
-using pb_util::SecureShortDebugString;
-using tablet::LocalTabletWriter;
-using tablet::Tablet;
-using tablet::TabletReplica;
-
class TsTabletManagerTest : public KuduTest {
public:
TsTabletManagerTest()
@@ -157,7 +157,7 @@ class TsTabletManagerTest : public KuduTest {
}
protected:
- gscoped_ptr<MiniTabletServer> mini_server_;
+ unique_ptr<MiniTabletServer> mini_server_;
FsManager* fs_manager_;
TSTabletManager* tablet_manager_;
Heartbeater* heartbeater_;