You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by to...@apache.org on 2017/03/24 19:04:04 UTC
[2/2] kudu git commit: Use unique_ptr instead of gscoped_ptr for
blocks, CFileReader
Use unique_ptr instead of gscoped_ptr for blocks, CFileReader
Adar asked me to change this in one place in a review. It leaked out to
40+ files.
204 down, 1214 more to go!
Change-Id: Ia5c8da82806404ce3c10463c86c7279ee6d37e69
Reviewed-on: http://gerrit.cloudera.org:8080/6467
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/cf25ec5c
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/cf25ec5c
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/cf25ec5c
Branch: refs/heads/master
Commit: cf25ec5c4436907ac03a16903c37506591cf272c
Parents: 02cbf88
Author: Todd Lipcon <to...@apache.org>
Authored: Thu Mar 23 22:09:35 2017 -0700
Committer: Todd Lipcon <to...@apache.org>
Committed: Fri Mar 24 18:47:14 2017 +0000
----------------------------------------------------------------------
src/kudu/cfile/bloomfile-test-base.h | 4 +-
src/kudu/cfile/bloomfile-test.cc | 5 +-
src/kudu/cfile/bloomfile.cc | 12 +--
src/kudu/cfile/bloomfile.h | 10 +--
src/kudu/cfile/cfile-test-base.h | 7 +-
src/kudu/cfile/cfile-test.cc | 37 ++++-----
src/kudu/cfile/cfile_reader.cc | 20 ++---
src/kudu/cfile/cfile_reader.h | 13 ++--
src/kudu/cfile/cfile_writer.cc | 13 ++--
src/kudu/cfile/cfile_writer.h | 8 +-
src/kudu/fs/block_manager-stress-test.cc | 5 +-
src/kudu/fs/block_manager-test.cc | 80 ++++++++++----------
src/kudu/fs/block_manager.h | 9 +--
src/kudu/fs/file_block_manager.cc | 7 +-
src/kudu/fs/file_block_manager.h | 22 +++---
src/kudu/fs/fs-test-util.h | 10 ++-
src/kudu/fs/fs_manager-test.cc | 4 +-
src/kudu/fs/fs_manager.cc | 8 +-
src/kudu/fs/fs_manager.h | 9 +--
src/kudu/fs/log_block_manager.cc | 6 +-
src/kudu/fs/log_block_manager.h | 23 +++---
src/kudu/tablet/cfile_set.cc | 10 +--
src/kudu/tablet/cfile_set.h | 2 +-
src/kudu/tablet/delta_compaction-test.cc | 4 +-
src/kudu/tablet/delta_compaction.cc | 4 +-
src/kudu/tablet/delta_tracker.cc | 10 +--
src/kudu/tablet/delta_tracker.h | 4 +-
src/kudu/tablet/deltafile-test.cc | 15 ++--
src/kudu/tablet/deltafile.cc | 12 +--
src/kudu/tablet/deltafile.h | 10 +--
src/kudu/tablet/deltamemstore-test.cc | 3 +-
src/kudu/tablet/diskrowset.cc | 8 +-
src/kudu/tablet/multi_column_writer.cc | 3 +-
src/kudu/tablet/tablet-test.cc | 3 +-
src/kudu/tools/kudu-tool-test.cc | 2 +-
src/kudu/tools/tool_action_fs.cc | 4 +-
src/kudu/tools/tool_action_local_replica.cc | 6 +-
src/kudu/tserver/tablet_copy-test-base.h | 2 +-
src/kudu/tserver/tablet_copy_client-test.cc | 5 +-
src/kudu/tserver/tablet_copy_client.cc | 2 +-
.../tserver/tablet_copy_source_session-test.cc | 2 +-
src/kudu/tserver/tablet_copy_source_session.cc | 3 +-
src/kudu/tserver/tablet_copy_source_session.h | 2 +-
43 files changed, 224 insertions(+), 204 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/cfile/bloomfile-test-base.h
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/bloomfile-test-base.h b/src/kudu/cfile/bloomfile-test-base.h
index 68ce025..aceb536 100644
--- a/src/kudu/cfile/bloomfile-test-base.h
+++ b/src/kudu/cfile/bloomfile-test-base.h
@@ -70,7 +70,7 @@ class BloomFileTestBase : public KuduTest {
}
void WriteTestBloomFile() {
- gscoped_ptr<WritableBlock> sink;
+ std::unique_ptr<WritableBlock> sink;
ASSERT_OK(fs_manager_->CreateNewBlock(&sink));
block_id_ = sink->id();
@@ -90,7 +90,7 @@ class BloomFileTestBase : public KuduTest {
}
Status OpenBloomFile() {
- gscoped_ptr<ReadableBlock> source;
+ std::unique_ptr<ReadableBlock> source;
RETURN_NOT_OK(fs_manager_->OpenBlock(block_id_, &source));
return BloomFileReader::Open(std::move(source), ReaderOptions(), &bfr_);
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/cfile/bloomfile-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/bloomfile-test.cc b/src/kudu/cfile/bloomfile-test.cc
index 693a875..6c89249 100644
--- a/src/kudu/cfile/bloomfile-test.cc
+++ b/src/kudu/cfile/bloomfile-test.cc
@@ -24,6 +24,7 @@ namespace kudu {
namespace cfile {
using fs::CountingReadableBlock;
+using std::unique_ptr;
class BloomFileTest : public BloomFileTestBase {
@@ -94,10 +95,10 @@ TEST_F(BloomFileTest, TestLazyInit) {
int64_t initial_mem_usage = tracker->consumption();
// Open the bloom file using a "counting" readable block.
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
ASSERT_OK(fs_manager_->OpenBlock(block_id_, &block));
size_t bytes_read = 0;
- gscoped_ptr<ReadableBlock> count_block(
+ unique_ptr<ReadableBlock> count_block(
new CountingReadableBlock(std::move(block), &bytes_read));
// Lazily opening the bloom file should not trigger any reads.
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/cfile/bloomfile.cc
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/bloomfile.cc b/src/kudu/cfile/bloomfile.cc
index 7d23863..061ad78 100644
--- a/src/kudu/cfile/bloomfile.cc
+++ b/src/kudu/cfile/bloomfile.cc
@@ -31,6 +31,8 @@
DECLARE_bool(cfile_lazy_open);
+using std::unique_ptr;
+
namespace kudu {
namespace cfile {
@@ -42,7 +44,7 @@ using fs::WritableBlock;
// Writer
////////////////////////////////////////////////////////////
-BloomFileWriter::BloomFileWriter(gscoped_ptr<WritableBlock> block,
+BloomFileWriter::BloomFileWriter(unique_ptr<WritableBlock> block,
const BloomFilterSizing &sizing)
: bloom_builder_(sizing) {
cfile::WriterOptions opts;
@@ -139,7 +141,7 @@ Status BloomFileWriter::FinishCurrentBloomBlock() {
// Reader
////////////////////////////////////////////////////////////
-Status BloomFileReader::Open(gscoped_ptr<ReadableBlock> block,
+Status BloomFileReader::Open(unique_ptr<ReadableBlock> block,
ReaderOptions options,
gscoped_ptr<BloomFileReader> *reader) {
gscoped_ptr<BloomFileReader> bf_reader;
@@ -151,10 +153,10 @@ Status BloomFileReader::Open(gscoped_ptr<ReadableBlock> block,
return Status::OK();
}
-Status BloomFileReader::OpenNoInit(gscoped_ptr<ReadableBlock> block,
+Status BloomFileReader::OpenNoInit(unique_ptr<ReadableBlock> block,
ReaderOptions options,
gscoped_ptr<BloomFileReader> *reader) {
- gscoped_ptr<CFileReader> cf_reader;
+ unique_ptr<CFileReader> cf_reader;
RETURN_NOT_OK(CFileReader::OpenNoInit(std::move(block),
options, &cf_reader));
gscoped_ptr<BloomFileReader> bf_reader(new BloomFileReader(
@@ -167,7 +169,7 @@ Status BloomFileReader::OpenNoInit(gscoped_ptr<ReadableBlock> block,
return Status::OK();
}
-BloomFileReader::BloomFileReader(gscoped_ptr<CFileReader> reader,
+BloomFileReader::BloomFileReader(unique_ptr<CFileReader> reader,
ReaderOptions options)
: reader_(std::move(reader)),
mem_consumption_(std::move(options.parent_mem_tracker),
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/cfile/bloomfile.h
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/bloomfile.h b/src/kudu/cfile/bloomfile.h
index 1394ced..d01942c 100644
--- a/src/kudu/cfile/bloomfile.h
+++ b/src/kudu/cfile/bloomfile.h
@@ -35,7 +35,7 @@ namespace cfile {
class BloomFileWriter {
public:
- BloomFileWriter(gscoped_ptr<fs::WritableBlock> block,
+ BloomFileWriter(std::unique_ptr<fs::WritableBlock> block,
const BloomFilterSizing &sizing);
Status Start();
@@ -77,7 +77,7 @@ class BloomFileReader {
// Fully open a bloom file using a previously opened block.
//
// After this call, the bloom reader is safe for use.
- static Status Open(gscoped_ptr<fs::ReadableBlock> block,
+ static Status Open(std::unique_ptr<fs::ReadableBlock> block,
ReaderOptions options,
gscoped_ptr<BloomFileReader> *reader);
@@ -86,7 +86,7 @@ class BloomFileReader {
// the bloom file.
//
// Init() must be called before using CheckKeyPresent().
- static Status OpenNoInit(gscoped_ptr<fs::ReadableBlock> block,
+ static Status OpenNoInit(std::unique_ptr<fs::ReadableBlock> block,
ReaderOptions options,
gscoped_ptr<BloomFileReader> *reader);
@@ -106,7 +106,7 @@ class BloomFileReader {
private:
DISALLOW_COPY_AND_ASSIGN(BloomFileReader);
- BloomFileReader(gscoped_ptr<CFileReader> reader, ReaderOptions options);
+ BloomFileReader(std::unique_ptr<CFileReader> reader, ReaderOptions options);
// Parse the header present in the given block.
//
@@ -124,7 +124,7 @@ class BloomFileReader {
// excluding the CFileReader, which is tracked independently.
size_t memory_footprint_excluding_reader() const;
- gscoped_ptr<CFileReader> reader_;
+ std::unique_ptr<CFileReader> reader_;
// TODO: temporary workaround for the fact that
// the index tree iterator is a member of the Reader object.
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/cfile/cfile-test-base.h
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/cfile-test-base.h b/src/kudu/cfile/cfile-test-base.h
index 9fbb238..695cd99 100644
--- a/src/kudu/cfile/cfile-test-base.h
+++ b/src/kudu/cfile/cfile-test-base.h
@@ -44,6 +44,7 @@ DEFINE_int32(cfile_test_block_size, 1024,
using kudu::fs::ReadableBlock;
using kudu::fs::WritableBlock;
+using std::unique_ptr;
namespace kudu {
namespace cfile {
@@ -348,7 +349,7 @@ class CFileTestBase : public KuduTest {
int num_entries,
uint32_t flags,
BlockId* block_id) {
- gscoped_ptr<WritableBlock> sink;
+ unique_ptr<WritableBlock> sink;
ASSERT_OK(fs_manager_->CreateNewBlock(&sink));
*block_id = sink->id();
WriterOptions opts;
@@ -460,9 +461,9 @@ void ReadBinaryFile(CFileIterator* iter, int* count) {
void TimeReadFile(FsManager* fs_manager, const BlockId& block_id, size_t *count_ret) {
Status s;
- gscoped_ptr<fs::ReadableBlock> source;
+ unique_ptr<fs::ReadableBlock> source;
ASSERT_OK(fs_manager->OpenBlock(block_id, &source));
- gscoped_ptr<CFileReader> reader;
+ unique_ptr<CFileReader> reader;
ASSERT_OK(CFileReader::Open(std::move(source), ReaderOptions(), &reader));
gscoped_ptr<CFileIterator> iter;
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/cfile/cfile-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/cfile-test.cc b/src/kudu/cfile/cfile-test.cc
index 794ee9e..34b5125 100644
--- a/src/kudu/cfile/cfile-test.cc
+++ b/src/kudu/cfile/cfile-test.cc
@@ -47,6 +47,7 @@ METRIC_DECLARE_counter(block_cache_hits_caching);
METRIC_DECLARE_entity(server);
using std::shared_ptr;
+using std::unique_ptr;
namespace kudu {
namespace cfile {
@@ -64,9 +65,9 @@ class TestCFile : public CFileTestBase {
WriteTestFile(&generator, encoding, NO_COMPRESSION, 10000, SMALL_BLOCKSIZE, &block_id);
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
ASSERT_OK(fs_manager_->OpenBlock(block_id, &block));
- gscoped_ptr<CFileReader> reader;
+ unique_ptr<CFileReader> reader;
ASSERT_OK(CFileReader::Open(std::move(block), ReaderOptions(), &reader));
BlockPointer ptr;
@@ -147,9 +148,9 @@ class TestCFile : public CFileTestBase {
template <class DataGeneratorType>
void TimeSeekAndReadFileWithNulls(DataGeneratorType* generator,
const BlockId& block_id, size_t num_entries) {
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
ASSERT_OK(fs_manager_->OpenBlock(block_id, &block));
- gscoped_ptr<CFileReader> reader;
+ unique_ptr<CFileReader> reader;
ASSERT_OK(CFileReader::Open(std::move(block), ReaderOptions(), &reader));
ASSERT_EQ(DataGeneratorType::kDataType, reader->type_info()->type());
@@ -209,7 +210,7 @@ class TestCFile : public CFileTestBase {
void TestReadWriteRawBlocks(CompressionType compression, int num_entries) {
// Test Write
- gscoped_ptr<WritableBlock> sink;
+ unique_ptr<WritableBlock> sink;
ASSERT_OK(fs_manager_->CreateNewBlock(&sink));
BlockId id = sink->id();
WriterOptions opts;
@@ -230,9 +231,9 @@ class TestCFile : public CFileTestBase {
ASSERT_OK(w.Finish());
// Test Read
- gscoped_ptr<ReadableBlock> source;
+ unique_ptr<ReadableBlock> source;
ASSERT_OK(fs_manager_->OpenBlock(id, &source));
- gscoped_ptr<CFileReader> reader;
+ unique_ptr<CFileReader> reader;
ASSERT_OK(CFileReader::Open(std::move(source), ReaderOptions(), &reader));
gscoped_ptr<IndexTreeIterator> iter;
@@ -511,9 +512,9 @@ void TestCFile::TestReadWriteStrings(EncodingType encoding,
WriteTestFile(&generator, encoding, NO_COMPRESSION, nrows,
SMALL_BLOCKSIZE | WRITE_VALIDX, &block_id);
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
ASSERT_OK(fs_manager_->OpenBlock(block_id, &block));
- gscoped_ptr<CFileReader> reader;
+ unique_ptr<CFileReader> reader;
ASSERT_OK(CFileReader::Open(std::move(block), ReaderOptions(), &reader));
rowid_t reader_nrows;
@@ -658,7 +659,7 @@ TEST_P(TestCFileBothCacheTypes, TestMetadata) {
// Write the file.
{
- gscoped_ptr<WritableBlock> sink;
+ unique_ptr<WritableBlock> sink;
ASSERT_OK(fs_manager_->CreateNewBlock(&sink));
block_id = sink->id();
WriterOptions opts;
@@ -676,9 +677,9 @@ TEST_P(TestCFileBothCacheTypes, TestMetadata) {
// Read the file and ensure metadata is present.
{
- gscoped_ptr<ReadableBlock> source;
+ unique_ptr<ReadableBlock> source;
ASSERT_OK(fs_manager_->OpenBlock(block_id, &source));
- gscoped_ptr<CFileReader> reader;
+ unique_ptr<CFileReader> reader;
ASSERT_OK(CFileReader::Open(std::move(source), ReaderOptions(), &reader));
string val;
ASSERT_TRUE(reader->GetMetadataEntry("key_in_header", &val));
@@ -783,7 +784,7 @@ TEST_P(TestCFileBothCacheTypes, TestNullDictStrings) {
}
TEST_P(TestCFileBothCacheTypes, TestReleaseBlock) {
- gscoped_ptr<WritableBlock> sink;
+ unique_ptr<WritableBlock> sink;
ASSERT_OK(fs_manager_->CreateNewBlock(&sink));
ASSERT_EQ(WritableBlock::CLEAN, sink->state());
WriterOptions opts;
@@ -821,17 +822,17 @@ TEST_P(TestCFileBothCacheTypes, TestLazyInit) {
int64_t initial_mem_usage = tracker->consumption();
// Open it using a "counting" readable block.
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
ASSERT_OK(fs_manager_->OpenBlock(block_id, &block));
size_t bytes_read = 0;
- gscoped_ptr<ReadableBlock> count_block(
+ unique_ptr<ReadableBlock> count_block(
new CountingReadableBlock(std::move(block), &bytes_read));
ASSERT_EQ(initial_mem_usage, tracker->consumption());
// Lazily opening the cfile should not trigger any reads.
ReaderOptions opts;
opts.parent_mem_tracker = tracker;
- gscoped_ptr<CFileReader> reader;
+ unique_ptr<CFileReader> reader;
ASSERT_OK(CFileReader::OpenNoInit(std::move(count_block), opts, &reader));
ASSERT_EQ(0, bytes_read);
int64_t lazy_mem_usage = tracker->consumption();
@@ -876,9 +877,9 @@ TEST_P(TestCFileBothCacheTypes, TestCacheKeysAreStable) {
// Open and read from it twice, checking the block cache statistics.
for (int i = 0; i < 2; i++) {
- gscoped_ptr<ReadableBlock> source;
+ unique_ptr<ReadableBlock> source;
ASSERT_OK(fs_manager_->OpenBlock(block_id, &source));
- gscoped_ptr<CFileReader> reader;
+ unique_ptr<CFileReader> reader;
ASSERT_OK(CFileReader::Open(std::move(source), ReaderOptions(), &reader));
gscoped_ptr<IndexTreeIterator> iter;
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/cfile/cfile_reader.cc
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/cfile_reader.cc b/src/kudu/cfile/cfile_reader.cc
index 0b1bfff..8e814f8 100644
--- a/src/kudu/cfile/cfile_reader.cc
+++ b/src/kudu/cfile/cfile_reader.cc
@@ -20,6 +20,7 @@
#include <glog/logging.h>
#include <algorithm>
+#include <memory>
#include "kudu/cfile/binary_plain_block.h"
#include "kudu/cfile/block_cache.h"
@@ -51,6 +52,7 @@ TAG_FLAG(cfile_lazy_open, hidden);
using kudu::fs::ReadableBlock;
using strings::Substitute;
+using std::unique_ptr;
namespace kudu {
namespace cfile {
@@ -91,7 +93,7 @@ static Status ParseMagicAndLength(const Slice &data,
CFileReader::CFileReader(ReaderOptions options,
uint64_t file_size,
- gscoped_ptr<ReadableBlock> block) :
+ unique_ptr<ReadableBlock> block) :
block_(std::move(block)),
file_size_(file_size),
codec_(nullptr),
@@ -99,31 +101,31 @@ CFileReader::CFileReader(ReaderOptions options,
memory_footprint()) {
}
-Status CFileReader::Open(gscoped_ptr<ReadableBlock> block,
+Status CFileReader::Open(unique_ptr<ReadableBlock> block,
ReaderOptions options,
- gscoped_ptr<CFileReader> *reader) {
- gscoped_ptr<CFileReader> reader_local;
+ unique_ptr<CFileReader>* reader) {
+ unique_ptr<CFileReader> reader_local;
RETURN_NOT_OK(OpenNoInit(std::move(block),
std::move(options),
&reader_local));
RETURN_NOT_OK(reader_local->Init());
- reader->reset(reader_local.release());
+ *reader = std::move(reader_local);
return Status::OK();
}
-Status CFileReader::OpenNoInit(gscoped_ptr<ReadableBlock> block,
+Status CFileReader::OpenNoInit(unique_ptr<ReadableBlock> block,
ReaderOptions options,
- gscoped_ptr<CFileReader> *reader) {
+ unique_ptr<CFileReader>* reader) {
uint64_t block_size;
RETURN_NOT_OK(block->Size(&block_size));
- gscoped_ptr<CFileReader> reader_local(
+ unique_ptr<CFileReader> reader_local(
new CFileReader(std::move(options), block_size, std::move(block)));
if (!FLAGS_cfile_lazy_open) {
RETURN_NOT_OK(reader_local->Init());
}
- reader->reset(reader_local.release());
+ *reader = std::move(reader_local);
return Status::OK();
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/cfile/cfile_reader.h
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/cfile_reader.h b/src/kudu/cfile/cfile_reader.h
index 581d3c1..a1b9956 100644
--- a/src/kudu/cfile/cfile_reader.h
+++ b/src/kudu/cfile/cfile_reader.h
@@ -18,6 +18,7 @@
#ifndef KUDU_CFILE_CFILE_READER_H
#define KUDU_CFILE_CFILE_READER_H
+#include <memory>
#include <string>
#include <vector>
@@ -59,9 +60,9 @@ class CFileReader {
// Fully open a cfile using a previously opened block.
//
// After this call, the reader is safe for use.
- static Status Open(gscoped_ptr<fs::ReadableBlock> block,
+ static Status Open(std::unique_ptr<fs::ReadableBlock> block,
ReaderOptions options,
- gscoped_ptr<CFileReader>* reader);
+ std::unique_ptr<CFileReader>* reader);
// Lazily open a cfile using a previously opened block. A lazy open does
// not incur additional I/O, nor does it validate the contents of the
@@ -69,9 +70,9 @@ class CFileReader {
//
// Init() must be called before most methods; the exceptions are documented
// below.
- static Status OpenNoInit(gscoped_ptr<fs::ReadableBlock> block,
+ static Status OpenNoInit(std::unique_ptr<fs::ReadableBlock> block,
ReaderOptions options,
- gscoped_ptr<CFileReader>* reader);
+ std::unique_ptr<CFileReader>* reader);
// Fully opens a previously lazily opened cfile, parsing and validating
// its contents.
@@ -175,7 +176,7 @@ class CFileReader {
CFileReader(ReaderOptions options,
uint64_t file_size,
- gscoped_ptr<fs::ReadableBlock> block);
+ std::unique_ptr<fs::ReadableBlock> block);
// Callback used in 'init_once_' to initialize this cfile.
Status InitOnce();
@@ -190,7 +191,7 @@ class CFileReader {
#ifdef __clang__
__attribute__((__unused__))
#endif
- const gscoped_ptr<fs::ReadableBlock> block_;
+ const std::unique_ptr<fs::ReadableBlock> block_;
const uint64_t file_size_;
uint8_t cfile_version_;
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/cfile/cfile_writer.cc
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/cfile_writer.cc b/src/kudu/cfile/cfile_writer.cc
index 4c0e352..6724d45 100644
--- a/src/kudu/cfile/cfile_writer.cc
+++ b/src/kudu/cfile/cfile_writer.cc
@@ -36,11 +36,6 @@
#include "kudu/util/logging.h"
#include "kudu/util/pb_util.h"
-using google::protobuf::RepeatedPtrField;
-using kudu::fs::ScopedWritableBlockCloser;
-using kudu::fs::WritableBlock;
-using std::string;
-
DEFINE_int32(cfile_default_block_size, 256*1024, "The default block size to use in cfiles");
TAG_FLAG(cfile_default_block_size, advanced);
@@ -66,6 +61,12 @@ DEFINE_string(cfile_do_on_finish, "flush",
"Possible values are 'close', 'flush', or 'nothing'.");
TAG_FLAG(cfile_do_on_finish, experimental);
+using google::protobuf::RepeatedPtrField;
+using kudu::fs::ScopedWritableBlockCloser;
+using kudu::fs::WritableBlock;
+using std::string;
+using std::unique_ptr;
+
namespace kudu {
namespace cfile {
@@ -99,7 +100,7 @@ WriterOptions::WriterOptions()
CFileWriter::CFileWriter(const WriterOptions &options,
const TypeInfo* typeinfo,
bool is_nullable,
- gscoped_ptr<WritableBlock> block)
+ unique_ptr<WritableBlock> block)
: block_(std::move(block)),
off_(0),
value_count_(0),
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/cfile/cfile_writer.h
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/cfile_writer.h b/src/kudu/cfile/cfile_writer.h
index 37816c9..22895c2 100644
--- a/src/kudu/cfile/cfile_writer.h
+++ b/src/kudu/cfile/cfile_writer.h
@@ -18,9 +18,11 @@
#ifndef KUDU_CFILE_CFILE_WRITER_H
#define KUDU_CFILE_CFILE_WRITER_H
-#include <unordered_map>
#include <stdint.h>
+
+#include <memory>
#include <string>
+#include <unordered_map>
#include <utility>
#include <vector>
@@ -95,7 +97,7 @@ class CFileWriter {
explicit CFileWriter(const WriterOptions &options,
const TypeInfo* typeinfo,
bool is_nullable,
- gscoped_ptr<fs::WritableBlock> block);
+ std::unique_ptr<fs::WritableBlock> block);
~CFileWriter();
Status Start();
@@ -191,7 +193,7 @@ class CFileWriter {
void FlushMetadataToPB(google::protobuf::RepeatedPtrField<FileMetadataPairPB> *field);
// Block being written.
- gscoped_ptr<fs::WritableBlock> block_;
+ std::unique_ptr<fs::WritableBlock> block_;
// Current file offset.
uint64_t off_;
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/fs/block_manager-stress-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager-stress-test.cc b/src/kudu/fs/block_manager-stress-test.cc
index 70827e5..bca0b2d 100644
--- a/src/kudu/fs/block_manager-stress-test.cc
+++ b/src/kudu/fs/block_manager-stress-test.cc
@@ -53,6 +53,7 @@ DEFINE_string(block_manager_paths, "", "Comma-separated list of paths to "
"test path");
using std::string;
+using std::unique_ptr;
using std::unordered_map;
using std::vector;
using strings::Substitute;
@@ -226,7 +227,7 @@ void BlockManagerStressTest<T>::WriterThread() {
// Create the blocks and write out the PRNG seeds.
for (int i = 0; i < FLAGS_block_group_size; i++) {
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
CHECK_OK(bm_->CreateBlock(&block));
const uint32_t seed = rand.Next() + 1;
@@ -300,7 +301,7 @@ void BlockManagerStressTest<T>::ReaderThread() {
it->second++;
}
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
CHECK_OK(bm_->OpenBlock(block_id, &block));
// Done opening the block, make it available for deleting.
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/fs/block_manager-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager-test.cc b/src/kudu/fs/block_manager-test.cc
index c726127..c086067 100644
--- a/src/kudu/fs/block_manager-test.cc
+++ b/src/kudu/fs/block_manager-test.cc
@@ -192,7 +192,7 @@ void BlockManagerTest<FileBlockManager>::RunMultipathTest(const vector<string>&
// Write ten blocks.
const char* kTestData = "test data";
for (int i = 0; i < 10; i++) {
- gscoped_ptr<WritableBlock> written_block;
+ unique_ptr<WritableBlock> written_block;
ASSERT_OK(bm_->CreateBlock(&written_block));
ASSERT_OK(written_block->Append(kTestData));
ASSERT_OK(written_block->Close());
@@ -216,7 +216,7 @@ void BlockManagerTest<LogBlockManager>::RunMultipathTest(const vector<string>& p
for (int i = 0; i < 3; i++) {
ScopedWritableBlockCloser closer;
for (int j = 0; j < paths.size() * 2; j++) {
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
ASSERT_OK(bm_->CreateBlock(&block));
ASSERT_OK(block->Append(kTestData));
closer.AddBlock(std::move(block));
@@ -270,7 +270,7 @@ void BlockManagerTest<LogBlockManager>::RunLogMetricsTest() {
FLAGS_log_container_max_size = 1024;
// One block --> one container.
- gscoped_ptr<WritableBlock> writer;
+ unique_ptr<WritableBlock> writer;
ASSERT_OK(bm_->CreateBlock(&writer));
ASSERT_NO_FATAL_FAILURE(CheckLogMetrics(entity, 0, 0, 1, 0));
@@ -285,7 +285,7 @@ void BlockManagerTest<LogBlockManager>::RunLogMetricsTest() {
Random rand(SeedRandom());
ScopedWritableBlockCloser closer;
for (int i = 0; i < 10; i++) {
- gscoped_ptr<WritableBlock> b;
+ unique_ptr<WritableBlock> b;
ASSERT_OK(bm_->CreateBlock(&b));
if (saved_id.IsNull()) {
saved_id = b->id();
@@ -334,7 +334,7 @@ void BlockManagerTest<LogBlockManager>::RunLogContainerPreallocationTest() {
// Create a block with some test data. This should also trigger
// preallocation of the container, provided it's supported by the kernel.
- gscoped_ptr<WritableBlock> written_block;
+ unique_ptr<WritableBlock> written_block;
ASSERT_OK(bm_->CreateBlock(&written_block));
ASSERT_OK(written_block->Append(kTestData));
ASSERT_OK(written_block->Close());
@@ -381,7 +381,7 @@ void BlockManagerTest<FileBlockManager>::RunMemTrackerTest() {
// The file block manager does not allocate memory for persistent data.
int64_t initial_mem = tracker->consumption();
ASSERT_EQ(initial_mem, 0);
- gscoped_ptr<WritableBlock> writer;
+ unique_ptr<WritableBlock> writer;
ASSERT_OK(bm_->CreateBlock(&writer));
ASSERT_OK(writer->Close());
ASSERT_EQ(tracker->consumption(), initial_mem);
@@ -400,7 +400,7 @@ void BlockManagerTest<LogBlockManager>::RunMemTrackerTest() {
ASSERT_GT(initial_mem, 0);
// Allocating a persistent block should increase the consumption.
- gscoped_ptr<WritableBlock> writer;
+ unique_ptr<WritableBlock> writer;
ASSERT_OK(bm_->CreateBlock(&writer));
ASSERT_OK(writer->Close());
ASSERT_GT(tracker->consumption(), initial_mem);
@@ -417,7 +417,7 @@ TYPED_TEST_CASE(BlockManagerTest, BlockManagers);
// Test the entire lifecycle of a block.
TYPED_TEST(BlockManagerTest, EndToEndTest) {
// Create a block.
- gscoped_ptr<WritableBlock> written_block;
+ unique_ptr<WritableBlock> written_block;
ASSERT_OK(this->bm_->CreateBlock(&written_block));
// Write some data to it.
@@ -426,7 +426,7 @@ TYPED_TEST(BlockManagerTest, EndToEndTest) {
ASSERT_OK(written_block->Close());
// Read the data back.
- gscoped_ptr<ReadableBlock> read_block;
+ unique_ptr<ReadableBlock> read_block;
ASSERT_OK(this->bm_->OpenBlock(written_block->id(), &read_block));
uint64_t sz;
ASSERT_OK(read_block->Size(&sz));
@@ -450,14 +450,14 @@ TYPED_TEST(BlockManagerTest, EndToEndTest) {
// (even if we can't open it again).
TYPED_TEST(BlockManagerTest, ReadAfterDeleteTest) {
// Write a new block.
- gscoped_ptr<WritableBlock> written_block;
+ unique_ptr<WritableBlock> written_block;
ASSERT_OK(this->bm_->CreateBlock(&written_block));
string test_data = "test data";
ASSERT_OK(written_block->Append(test_data));
ASSERT_OK(written_block->Close());
// Open it for reading, then delete it. Subsequent opens should fail.
- gscoped_ptr<ReadableBlock> read_block;
+ unique_ptr<ReadableBlock> read_block;
ASSERT_OK(this->bm_->OpenBlock(written_block->id(), &read_block));
ASSERT_OK(this->bm_->DeleteBlock(written_block->id()));
ASSERT_TRUE(this->bm_->OpenBlock(written_block->id(), nullptr)
@@ -472,13 +472,13 @@ TYPED_TEST(BlockManagerTest, ReadAfterDeleteTest) {
TYPED_TEST(BlockManagerTest, CloseTwiceTest) {
// Create a new block and close it repeatedly.
- gscoped_ptr<WritableBlock> written_block;
+ unique_ptr<WritableBlock> written_block;
ASSERT_OK(this->bm_->CreateBlock(&written_block));
ASSERT_OK(written_block->Close());
ASSERT_OK(written_block->Close());
// Open it for reading and close it repeatedly.
- gscoped_ptr<ReadableBlock> read_block;
+ unique_ptr<ReadableBlock> read_block;
ASSERT_OK(this->bm_->OpenBlock(written_block->id(), &read_block));
ASSERT_OK(read_block->Close());
ASSERT_OK(read_block->Close());
@@ -501,7 +501,7 @@ TYPED_TEST(BlockManagerTest, CloseManyBlocksTest) {
LOG_TIMING(INFO, Substitute("creating $0 blocks", kNumBlocks)) {
for (int i = 0; i < kNumBlocks; i++) {
// Create a block.
- gscoped_ptr<WritableBlock> written_block;
+ unique_ptr<WritableBlock> written_block;
ASSERT_OK(this->bm_->CreateBlock(&written_block));
// Write 64k bytes of random data into it.
@@ -523,7 +523,7 @@ TYPED_TEST(BlockManagerTest, CloseManyBlocksTest) {
// We can't really test that FlushDataAsync() "works", but we can test that
// it doesn't break anything.
TYPED_TEST(BlockManagerTest, FlushDataAsyncTest) {
- gscoped_ptr<WritableBlock> written_block;
+ unique_ptr<WritableBlock> written_block;
ASSERT_OK(this->bm_->CreateBlock(&written_block));
string test_data = "test data";
ASSERT_OK(written_block->Append(test_data));
@@ -531,7 +531,7 @@ TYPED_TEST(BlockManagerTest, FlushDataAsyncTest) {
}
TYPED_TEST(BlockManagerTest, WritableBlockStateTest) {
- gscoped_ptr<WritableBlock> written_block;
+ unique_ptr<WritableBlock> written_block;
// Common flow: CLEAN->DIRTY->CLOSED.
ASSERT_OK(this->bm_->CreateBlock(&written_block));
@@ -595,7 +595,7 @@ TYPED_TEST(BlockManagerTest, AbortTest) {
{ this->test_dir_ },
false));
- gscoped_ptr<WritableBlock> written_block;
+ unique_ptr<WritableBlock> written_block;
ASSERT_OK(this->bm_->CreateBlock(&written_block));
string test_data = "test data";
ASSERT_OK(written_block->Append(test_data));
@@ -620,9 +620,9 @@ TYPED_TEST(BlockManagerTest, PersistenceTest) {
// 1. Empty.
// 2. Non-empty.
// 3. Deleted.
- gscoped_ptr<WritableBlock> written_block1;
- gscoped_ptr<WritableBlock> written_block2;
- gscoped_ptr<WritableBlock> written_block3;
+ unique_ptr<WritableBlock> written_block1;
+ unique_ptr<WritableBlock> written_block2;
+ unique_ptr<WritableBlock> written_block3;
ASSERT_OK(this->bm_->CreateBlock(&written_block1));
ASSERT_OK(written_block1->Close());
ASSERT_OK(this->bm_->CreateBlock(&written_block2));
@@ -646,7 +646,7 @@ TYPED_TEST(BlockManagerTest, PersistenceTest) {
ASSERT_OK(new_bm->Open());
// Test that the state of all three blocks is properly reflected.
- gscoped_ptr<ReadableBlock> read_block;
+ unique_ptr<ReadableBlock> read_block;
ASSERT_OK(new_bm->OpenBlock(written_block1->id(), &read_block));
uint64_t sz;
ASSERT_OK(read_block->Size(&sz));
@@ -684,11 +684,11 @@ static void CloseHelper(ReadableBlock* block) {
// Tests that ReadableBlock::Close() is thread-safe and idempotent.
TYPED_TEST(BlockManagerTest, ConcurrentCloseReadableBlockTest) {
- gscoped_ptr<WritableBlock> writer;
+ unique_ptr<WritableBlock> writer;
ASSERT_OK(this->bm_->CreateBlock(&writer));
ASSERT_OK(writer->Close());
- gscoped_ptr<ReadableBlock> reader;
+ unique_ptr<ReadableBlock> reader;
ASSERT_OK(this->bm_->OpenBlock(writer->id(), &reader));
vector<scoped_refptr<Thread> > threads;
@@ -714,8 +714,8 @@ TYPED_TEST(BlockManagerTest, MetricsTest) {
ASSERT_NO_FATAL_FAILURE(CheckMetrics(entity, 0, 0, 0, 0, 0, 0));
for (int i = 0; i < 3; i++) {
- gscoped_ptr<WritableBlock> writer;
- gscoped_ptr<ReadableBlock> reader;
+ unique_ptr<WritableBlock> writer;
+ unique_ptr<ReadableBlock> reader;
// An open writer. Also reflected in total_writable_blocks.
ASSERT_OK(this->bm_->CreateBlock(&writer));
@@ -784,7 +784,7 @@ TEST_F(LogBlockManagerTest, TestReuseBlockIds) {
{
ScopedWritableBlockCloser closer;
for (int i = 0; i < 4; i++) {
- gscoped_ptr<WritableBlock> writer;
+ unique_ptr<WritableBlock> writer;
ASSERT_OK(bm_->CreateBlock(&writer));
block_ids.push_back(writer->id());
closer.AddBlock(std::move(writer));
@@ -794,7 +794,7 @@ TEST_F(LogBlockManagerTest, TestReuseBlockIds) {
// Create one more block, which should reuse the first container.
{
- gscoped_ptr<WritableBlock> writer;
+ unique_ptr<WritableBlock> writer;
ASSERT_OK(bm_->CreateBlock(&writer));
ASSERT_OK(writer->Close());
}
@@ -811,7 +811,7 @@ TEST_F(LogBlockManagerTest, TestReuseBlockIds) {
// could produce this situation, and we still need to handle it on startup.
bm_->next_block_id_.Store(1);
for (int i = 0; i < 4; i++) {
- gscoped_ptr<WritableBlock> writer;
+ unique_ptr<WritableBlock> writer;
ASSERT_OK(bm_->CreateBlock(&writer));
ASSERT_EQ(writer->id(), block_ids[i]);
ASSERT_OK(writer->Close());
@@ -851,7 +851,7 @@ TEST_F(LogBlockManagerTest, TestMetadataTruncation) {
vector<BlockId> created_blocks;
BlockId last_block_id;
for (int i = 0; i < 4; i++) {
- gscoped_ptr<WritableBlock> writer;
+ unique_ptr<WritableBlock> writer;
ASSERT_OK(bm_->CreateBlock(&writer));
last_block_id = writer->id();
created_blocks.push_back(last_block_id);
@@ -860,7 +860,7 @@ TEST_F(LogBlockManagerTest, TestMetadataTruncation) {
vector<BlockId> block_ids;
ASSERT_OK(bm_->GetAllBlockIds(&block_ids));
ASSERT_EQ(4, block_ids.size());
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
ASSERT_OK(bm_->OpenBlock(last_block_id, &block));
ASSERT_OK(block->Close());
@@ -916,7 +916,7 @@ TEST_F(LogBlockManagerTest, TestMetadataTruncation) {
// Add a new block, increasing the size of the container metadata file.
{
- gscoped_ptr<WritableBlock> writer;
+ unique_ptr<WritableBlock> writer;
ASSERT_OK(bm_->CreateBlock(&writer));
last_block_id = writer->id();
created_blocks.push_back(last_block_id);
@@ -961,7 +961,7 @@ TEST_F(LogBlockManagerTest, TestMetadataTruncation) {
// Add a new block, increasing the size of the container metadata file.
{
- gscoped_ptr<WritableBlock> writer;
+ unique_ptr<WritableBlock> writer;
ASSERT_OK(bm_->CreateBlock(&writer));
last_block_id = writer->id();
created_blocks.push_back(last_block_id);
@@ -1038,7 +1038,7 @@ TEST_F(LogBlockManagerTest, TestAppendExceedsPreallocation) {
FLAGS_log_container_preallocate_bytes = 1;
// Create a container, preallocate it by one byte, and append more than one.
- gscoped_ptr<WritableBlock> writer;
+ unique_ptr<WritableBlock> writer;
ASSERT_OK(bm_->CreateBlock(&writer));
ASSERT_OK(writer->Append("hello world"));
ASSERT_OK(writer->Close());
@@ -1057,7 +1057,7 @@ TEST_F(LogBlockManagerTest, TestPreallocationAndTruncation) {
FLAGS_log_container_preallocate_bytes = 32 * 1024 * 1024;
// Fill up one container.
- gscoped_ptr<WritableBlock> writer;
+ unique_ptr<WritableBlock> writer;
ASSERT_OK(bm_->CreateBlock(&writer));
unique_ptr<uint8_t[]> data(new uint8_t[FLAGS_log_container_max_size]);
memset(data.get(), 0, FLAGS_log_container_max_size);
@@ -1141,7 +1141,7 @@ TYPED_TEST(BlockManagerTest, TestDiskSpaceCheck) {
FLAGS_disk_reserved_bytes_free_for_testing = free_space;
for (int attempt = 0; attempt < 3; attempt++) {
- gscoped_ptr<WritableBlock> writer;
+ unique_ptr<WritableBlock> writer;
LOG(INFO) << "Attempt #" << ++i;
Status s = this->bm_->CreateBlock(&writer);
if (FLAGS_disk_reserved_bytes_free_for_testing < FLAGS_fs_data_dirs_reserved_bytes) {
@@ -1193,7 +1193,7 @@ TYPED_TEST(BlockManagerTest, TestMetadataOkayDespiteFailedWrites) {
// Creates a block, writing the result to 'out' on success.
auto create_a_block = [&](BlockId* out) -> Status {
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
RETURN_NOT_OK(this->bm_->CreateBlock(&block));
for (int i = 0; i < kNumAppends; i++) {
RETURN_NOT_OK(block->Append(kTestData));
@@ -1205,7 +1205,7 @@ TYPED_TEST(BlockManagerTest, TestMetadataOkayDespiteFailedWrites) {
// Reads a block given by 'id', comparing its contents to kTestData.
auto read_a_block = [&](const BlockId& id) -> Status {
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
RETURN_NOT_OK(this->bm_->OpenBlock(id, &block));
uint64_t size;
RETURN_NOT_OK(block->Size(&size));
@@ -1274,7 +1274,7 @@ TYPED_TEST(BlockManagerTest, TestMetadataOkayDespiteFailedWrites) {
TYPED_TEST(BlockManagerTest, TestGetAllBlockIds) {
vector<BlockId> ids;
for (int i = 0; i < 100; i++) {
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
ASSERT_OK(this->bm_->CreateBlock(&block));
ASSERT_OK(block->Close());
ids.push_back(block->id());
@@ -1332,7 +1332,7 @@ TEST_F(LogBlockManagerTest, TestContainerWithManyHoles) {
LOG(INFO) << Substitute("Creating $0 blocks", kNumBlocks);
vector<BlockId> ids;
for (int i = 0; i < kNumBlocks; i++) {
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
ASSERT_OK(bm_->CreateBlock(&block));
ASSERT_OK(block->Append("aaaa"));
ASSERT_OK(block->Close());
@@ -1420,7 +1420,7 @@ TEST_F(LogBlockManagerTest, TestContainerBlockLimiting) {
// Creates 'kNumBlocks' blocks with minimal data.
auto create_some_blocks = [&]() -> Status {
for (int i = 0; i < kNumBlocks; i++) {
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
RETURN_NOT_OK(bm_->CreateBlock(&block));
RETURN_NOT_OK(block->Append("aaaa"));
RETURN_NOT_OK(block->Close());
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/fs/block_manager.h
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager.h b/src/kudu/fs/block_manager.h
index b2cf1c5..e6b483d 100644
--- a/src/kudu/fs/block_manager.h
+++ b/src/kudu/fs/block_manager.h
@@ -25,7 +25,6 @@
#include <vector>
#include "kudu/fs/block_id.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/gutil/stl_util.h"
#include "kudu/gutil/strings/substitute.h"
@@ -208,10 +207,10 @@ class BlockManager {
//
// Does not modify 'block' on error.
virtual Status CreateBlock(const CreateBlockOptions& opts,
- gscoped_ptr<WritableBlock>* block) = 0;
+ std::unique_ptr<WritableBlock>* block) = 0;
// Like the above but uses default options.
- virtual Status CreateBlock(gscoped_ptr<WritableBlock>* block) = 0;
+ virtual Status CreateBlock(std::unique_ptr<WritableBlock>* block) = 0;
// Opens an existing block for reading.
//
@@ -223,7 +222,7 @@ class BlockManager {
//
// Does not modify 'block' on error.
virtual Status OpenBlock(const BlockId& block_id,
- gscoped_ptr<ReadableBlock>* block) = 0;
+ std::unique_ptr<ReadableBlock>* block) = 0;
// Deletes an existing block, allowing its space to be reclaimed by the
// filesystem. The change is immediately made durable.
@@ -265,7 +264,7 @@ class ScopedWritableBlockCloser {
STLDeleteElements(&blocks_);
}
- void AddBlock(gscoped_ptr<WritableBlock> block) {
+ void AddBlock(std::unique_ptr<WritableBlock> block) {
blocks_.push_back(block.release());
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/fs/file_block_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/file_block_manager.cc b/src/kudu/fs/file_block_manager.cc
index 33086ce..0dd18c2 100644
--- a/src/kudu/fs/file_block_manager.cc
+++ b/src/kudu/fs/file_block_manager.cc
@@ -38,6 +38,7 @@
using std::shared_ptr;
using std::string;
+using std::unique_ptr;
using std::vector;
using strings::Substitute;
@@ -552,7 +553,7 @@ Status FileBlockManager::Open() {
}
Status FileBlockManager::CreateBlock(const CreateBlockOptions& opts,
- gscoped_ptr<WritableBlock>* block) {
+ unique_ptr<WritableBlock>* block) {
CHECK(!read_only_);
DataDir* dir;
@@ -608,12 +609,12 @@ Status FileBlockManager::CreateBlock(const CreateBlockOptions& opts,
return s;
}
-Status FileBlockManager::CreateBlock(gscoped_ptr<WritableBlock>* block) {
+Status FileBlockManager::CreateBlock(unique_ptr<WritableBlock>* block) {
return CreateBlock(CreateBlockOptions(), block);
}
Status FileBlockManager::OpenBlock(const BlockId& block_id,
- gscoped_ptr<ReadableBlock>* block) {
+ unique_ptr<ReadableBlock>* block) {
string path;
if (!FindBlockPath(block_id, &path)) {
return Status::NotFound(
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/fs/file_block_manager.h
----------------------------------------------------------------------
diff --git a/src/kudu/fs/file_block_manager.h b/src/kudu/fs/file_block_manager.h
index f4581c2..93f3929 100644
--- a/src/kudu/fs/file_block_manager.h
+++ b/src/kudu/fs/file_block_manager.h
@@ -78,23 +78,23 @@ class FileBlockManager : public BlockManager {
virtual ~FileBlockManager();
- virtual Status Create() OVERRIDE;
+ Status Create() override;
- virtual Status Open() OVERRIDE;
+ Status Open() override;
- virtual Status CreateBlock(const CreateBlockOptions& opts,
- gscoped_ptr<WritableBlock>* block) OVERRIDE;
+ Status CreateBlock(const CreateBlockOptions& opts,
+ std::unique_ptr<WritableBlock>* block) override;
- virtual Status CreateBlock(gscoped_ptr<WritableBlock>* block) OVERRIDE;
+ Status CreateBlock(std::unique_ptr<WritableBlock>* block) override;
- virtual Status OpenBlock(const BlockId& block_id,
- gscoped_ptr<ReadableBlock>* block) OVERRIDE;
+ Status OpenBlock(const BlockId& block_id,
+ std::unique_ptr<ReadableBlock>* block) override;
- virtual Status DeleteBlock(const BlockId& block_id) OVERRIDE;
+ Status DeleteBlock(const BlockId& block_id) override;
- virtual Status CloseBlocks(const std::vector<WritableBlock*>& blocks) OVERRIDE;
+ Status CloseBlocks(const std::vector<WritableBlock*>& blocks) override;
- virtual Status GetAllBlockIds(std::vector<BlockId>* block_ids) OVERRIDE;
+ Status GetAllBlockIds(std::vector<BlockId>* block_ids) override;
private:
friend class internal::FileBlockLocation;
@@ -136,7 +136,7 @@ class FileBlockManager : public BlockManager {
// Metric container for the block manager.
// May be null if instantiated without metrics.
- gscoped_ptr<internal::BlockManagerMetrics> metrics_;
+ std::unique_ptr<internal::BlockManagerMetrics> metrics_;
// Tracks memory consumption of any allocations numerous enough to be
// interesting.
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/fs/fs-test-util.h
----------------------------------------------------------------------
diff --git a/src/kudu/fs/fs-test-util.h b/src/kudu/fs/fs-test-util.h
index e3bf626..b99f7ad 100644
--- a/src/kudu/fs/fs-test-util.h
+++ b/src/kudu/fs/fs-test-util.h
@@ -18,6 +18,8 @@
#ifndef KUDU_FS_FS_TEST_UTIL_H
#define KUDU_FS_FS_TEST_UTIL_H
+#include <memory>
+
#include "kudu/fs/block_manager.h"
#include "kudu/util/malloc.h"
@@ -32,17 +34,17 @@ namespace fs {
//
// Sample usage:
//
-// gscoped_ptr<ReadableBlock> block;
+// unique_ptr<ReadableBlock> block;
// fs_manager->OpenBlock("some block id", &block);
// size_t bytes_read = 0;
-// gscoped_ptr<ReadableBlock> tr_block(new CountingReadableBlock(std::move(block), &bytes_read));
+// unique_ptr<ReadableBlock> tr_block(new CountingReadableBlock(std::move(block), &bytes_read));
// tr_block->Read(0, 100, ...);
// tr_block->Read(0, 200, ...);
// ASSERT_EQ(300, bytes_read);
//
class CountingReadableBlock : public ReadableBlock {
public:
- CountingReadableBlock(gscoped_ptr<ReadableBlock> block, size_t* bytes_read)
+ CountingReadableBlock(std::unique_ptr<ReadableBlock> block, size_t* bytes_read)
: block_(std::move(block)),
bytes_read_(bytes_read) {
}
@@ -71,7 +73,7 @@ class CountingReadableBlock : public ReadableBlock {
}
private:
- gscoped_ptr<ReadableBlock> block_;
+ std::unique_ptr<ReadableBlock> block_;
size_t* bytes_read_;
};
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/fs/fs_manager-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/fs_manager-test.cc b/src/kudu/fs/fs_manager-test.cc
index 0c99e53..1338547 100644
--- a/src/kudu/fs/fs_manager-test.cc
+++ b/src/kudu/fs/fs_manager-test.cc
@@ -75,14 +75,14 @@ class FsManagerTestBase : public KuduTest {
DCHECK_LT(data.size(), sizeof(buffer));
// Test Write
- gscoped_ptr<fs::WritableBlock> writer;
+ unique_ptr<fs::WritableBlock> writer;
ASSERT_OK(fs_manager()->CreateNewBlock(&writer));
ASSERT_OK(writer->Append(data));
ASSERT_OK(writer->Close());
// Test Read
Slice result;
- gscoped_ptr<fs::ReadableBlock> reader;
+ unique_ptr<fs::ReadableBlock> reader;
ASSERT_OK(fs_manager()->OpenBlock(writer->id(), &reader));
ASSERT_OK(reader->Read(0, data.size(), &result, buffer));
ASSERT_EQ(data.size(), result.size());
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/fs/fs_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/fs_manager.cc b/src/kudu/fs/fs_manager.cc
index c3d1a55..5cbf3d4 100644
--- a/src/kudu/fs/fs_manager.cc
+++ b/src/kudu/fs/fs_manager.cc
@@ -32,6 +32,7 @@
#include "kudu/fs/file_block_manager.h"
#include "kudu/fs/fs.pb.h"
#include "kudu/fs/log_block_manager.h"
+#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/map-util.h"
#include "kudu/gutil/stringprintf.h"
#include "kudu/gutil/strings/join.h"
@@ -89,6 +90,7 @@ using kudu::fs::WritableBlock;
using std::map;
using std::stack;
using std::string;
+using std::unique_ptr;
using std::unordered_set;
using std::vector;
using strings::Substitute;
@@ -568,13 +570,13 @@ void FsManager::DumpFileSystemTree(ostream& out, const string& prefix,
// Data read/write interfaces
// ==========================================================================
-Status FsManager::CreateNewBlock(gscoped_ptr<WritableBlock>* block) {
+Status FsManager::CreateNewBlock(unique_ptr<WritableBlock>* block) {
CHECK(!read_only_);
return block_manager_->CreateBlock(block);
}
-Status FsManager::OpenBlock(const BlockId& block_id, gscoped_ptr<ReadableBlock>* block) {
+Status FsManager::OpenBlock(const BlockId& block_id, unique_ptr<ReadableBlock>* block) {
return block_manager_->OpenBlock(block_id, block);
}
@@ -585,7 +587,7 @@ Status FsManager::DeleteBlock(const BlockId& block_id) {
}
bool FsManager::BlockExists(const BlockId& block_id) const {
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
return block_manager_->OpenBlock(block_id, &block).ok();
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/fs/fs_manager.h
----------------------------------------------------------------------
diff --git a/src/kudu/fs/fs_manager.h b/src/kudu/fs/fs_manager.h
index 438832e..10435c7 100644
--- a/src/kudu/fs/fs_manager.h
+++ b/src/kudu/fs/fs_manager.h
@@ -27,7 +27,6 @@
#include <string>
#include <vector>
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/util/env.h"
#include "kudu/util/path_util.h"
@@ -129,10 +128,10 @@ class FsManager {
// Creates a new anonymous block.
//
// Block will be synced on close.
- Status CreateNewBlock(gscoped_ptr<fs::WritableBlock>* block);
+ Status CreateNewBlock(std::unique_ptr<fs::WritableBlock>* block);
Status OpenBlock(const BlockId& block_id,
- gscoped_ptr<fs::ReadableBlock>* block);
+ std::unique_ptr<fs::ReadableBlock>* block);
Status DeleteBlock(const BlockId& block_id);
@@ -279,9 +278,9 @@ class FsManager {
std::set<std::string> canonicalized_data_fs_roots_;
std::set<std::string> canonicalized_all_fs_roots_;
- gscoped_ptr<InstanceMetadataPB> metadata_;
+ std::unique_ptr<InstanceMetadataPB> metadata_;
- gscoped_ptr<fs::BlockManager> block_manager_;
+ std::unique_ptr<fs::BlockManager> block_manager_;
bool initted_;
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/fs/log_block_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/log_block_manager.cc b/src/kudu/fs/log_block_manager.cc
index 30da40b..6792226 100644
--- a/src/kudu/fs/log_block_manager.cc
+++ b/src/kudu/fs/log_block_manager.cc
@@ -1385,7 +1385,7 @@ Status LogBlockManager::Open() {
}
Status LogBlockManager::CreateBlock(const CreateBlockOptions& opts,
- gscoped_ptr<WritableBlock>* block) {
+ unique_ptr<WritableBlock>* block) {
CHECK(!read_only_);
// Find a free container. If one cannot be found, create a new one.
@@ -1411,12 +1411,12 @@ Status LogBlockManager::CreateBlock(const CreateBlockOptions& opts,
return Status::OK();
}
-Status LogBlockManager::CreateBlock(gscoped_ptr<WritableBlock>* block) {
+Status LogBlockManager::CreateBlock(unique_ptr<WritableBlock>* block) {
return CreateBlock(CreateBlockOptions(), block);
}
Status LogBlockManager::OpenBlock(const BlockId& block_id,
- gscoped_ptr<ReadableBlock>* block) {
+ unique_ptr<ReadableBlock>* block) {
scoped_refptr<LogBlock> lb;
{
std::lock_guard<simple_spinlock> l(lock_);
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/fs/log_block_manager.h
----------------------------------------------------------------------
diff --git a/src/kudu/fs/log_block_manager.h b/src/kudu/fs/log_block_manager.h
index 1295871..32249af 100644
--- a/src/kudu/fs/log_block_manager.h
+++ b/src/kudu/fs/log_block_manager.h
@@ -34,7 +34,6 @@
#include "kudu/fs/block_manager.h"
#include "kudu/fs/data_dirs.h"
#include "kudu/fs/fs.pb.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/util/atomic.h"
#include "kudu/util/mem_tracker.h"
@@ -164,23 +163,23 @@ class LogBlockManager : public BlockManager {
virtual ~LogBlockManager();
- virtual Status Create() OVERRIDE;
+ Status Create() override;
- virtual Status Open() OVERRIDE;
+ Status Open() override;
- virtual Status CreateBlock(const CreateBlockOptions& opts,
- gscoped_ptr<WritableBlock>* block) OVERRIDE;
+ Status CreateBlock(const CreateBlockOptions& opts,
+ std::unique_ptr<WritableBlock>* block) override;
- virtual Status CreateBlock(gscoped_ptr<WritableBlock>* block) OVERRIDE;
+ Status CreateBlock(std::unique_ptr<WritableBlock>* block) override;
- virtual Status OpenBlock(const BlockId& block_id,
- gscoped_ptr<ReadableBlock>* block) OVERRIDE;
+ Status OpenBlock(const BlockId& block_id,
+ std::unique_ptr<ReadableBlock>* block) override;
- virtual Status DeleteBlock(const BlockId& block_id) OVERRIDE;
+ Status DeleteBlock(const BlockId& block_id) override;
- virtual Status CloseBlocks(const std::vector<WritableBlock*>& blocks) OVERRIDE;
+ Status CloseBlocks(const std::vector<WritableBlock*>& blocks) override;
- virtual Status GetAllBlockIds(std::vector<BlockId>* block_ids) OVERRIDE;
+ Status GetAllBlockIds(std::vector<BlockId>* block_ids) override;
private:
FRIEND_TEST(LogBlockManagerTest, TestLookupBlockLimit);
@@ -351,7 +350,7 @@ class LogBlockManager : public BlockManager {
// Metrics for the block manager.
//
// May be null if instantiated without metrics.
- gscoped_ptr<internal::LogBlockManagerMetrics> metrics_;
+ std::unique_ptr<internal::LogBlockManagerMetrics> metrics_;
DISALLOW_COPY_AND_ASSIGN(LogBlockManager);
};
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tablet/cfile_set.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/cfile_set.cc b/src/kudu/tablet/cfile_set.cc
index 9b70c92..059c0a0 100644
--- a/src/kudu/tablet/cfile_set.cc
+++ b/src/kudu/tablet/cfile_set.cc
@@ -55,8 +55,8 @@ using strings::Substitute;
static Status OpenReader(FsManager* fs,
shared_ptr<MemTracker> parent_mem_tracker,
const BlockId& block_id,
- gscoped_ptr<CFileReader> *new_reader) {
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<CFileReader>* new_reader) {
+ unique_ptr<ReadableBlock> block;
RETURN_NOT_OK(fs->OpenBlock(block_id, &block));
ReaderOptions opts;
@@ -100,12 +100,12 @@ Status CFileSet::DoOpen() {
ColumnId col_id = e.first;
DCHECK(!ContainsKey(readers_by_col_id_, col_id)) << "already open";
- gscoped_ptr<CFileReader> reader;
+ unique_ptr<CFileReader> reader;
RETURN_NOT_OK(OpenReader(rowset_metadata_->fs_manager(),
parent_mem_tracker_,
rowset_metadata_->column_data_block_for_col_id(col_id),
&reader));
- readers_by_col_id_[col_id] = unique_ptr<CFileReader>(reader.release());
+ readers_by_col_id_[col_id] = std::move(reader);
VLOG(1) << "Successfully opened cfile for column id " << col_id
<< " in " << rowset_metadata_->ToString();
}
@@ -130,7 +130,7 @@ Status CFileSet::DoOpen() {
Status CFileSet::OpenBloomReader() {
FsManager* fs = rowset_metadata_->fs_manager();
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
RETURN_NOT_OK(fs->OpenBlock(rowset_metadata_->bloom_block(), &block));
ReaderOptions opts;
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tablet/cfile_set.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/cfile_set.h b/src/kudu/tablet/cfile_set.h
index 7cfcfa6..36489d8 100644
--- a/src/kudu/tablet/cfile_set.h
+++ b/src/kudu/tablet/cfile_set.h
@@ -127,7 +127,7 @@ class CFileSet : public std::enable_shared_from_this<CFileSet> {
// A file reader for an ad-hoc index, i.e. an index that sits in its own file
// and is not embedded with the column's data blocks. This is used when the
// index pertains to more than one column, as in the case of composite keys.
- gscoped_ptr<CFileReader> ad_hoc_idx_reader_;
+ std::unique_ptr<CFileReader> ad_hoc_idx_reader_;
gscoped_ptr<BloomFileReader> bloom_reader_;
};
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tablet/delta_compaction-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_compaction-test.cc b/src/kudu/tablet/delta_compaction-test.cc
index 7504f88..053b672 100644
--- a/src/kudu/tablet/delta_compaction-test.cc
+++ b/src/kudu/tablet/delta_compaction-test.cc
@@ -68,7 +68,7 @@ class TestDeltaCompaction : public KuduTest {
Status GetDeltaFileWriter(gscoped_ptr<DeltaFileWriter>* dfw,
BlockId* block_id) const {
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
RETURN_NOT_OK(fs_manager_->CreateNewBlock(&block));
*block_id = block->id();
dfw->reset(new DeltaFileWriter(std::move(block)));
@@ -78,7 +78,7 @@ class TestDeltaCompaction : public KuduTest {
Status GetDeltaFileReader(const BlockId& block_id,
shared_ptr<DeltaFileReader>* dfr) const {
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
RETURN_NOT_OK(fs_manager_->OpenBlock(block_id, &block));
shared_ptr<DeltaFileReader> delta_reader;
return DeltaFileReader::Open(std::move(block), REDO, ReaderOptions(), dfr);
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tablet/delta_compaction.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_compaction.cc b/src/kudu/tablet/delta_compaction.cc
index d2b69b9..a2b1700 100644
--- a/src/kudu/tablet/delta_compaction.cc
+++ b/src/kudu/tablet/delta_compaction.cc
@@ -247,7 +247,7 @@ Status MajorDeltaCompaction::OpenBaseDataWriter() {
}
Status MajorDeltaCompaction::OpenRedoDeltaFileWriter() {
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
RETURN_NOT_OK_PREPEND(fs_manager_->CreateNewBlock(&block),
"Unable to create REDO delta output block");
new_redo_delta_block_ = block->id();
@@ -256,7 +256,7 @@ Status MajorDeltaCompaction::OpenRedoDeltaFileWriter() {
}
Status MajorDeltaCompaction::OpenUndoDeltaFileWriter() {
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
RETURN_NOT_OK_PREPEND(fs_manager_->CreateNewBlock(&block),
"Unable to create UNDO delta output block");
new_undo_delta_block_ = block->id();
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tablet/delta_tracker.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_tracker.cc b/src/kudu/tablet/delta_tracker.cc
index a4b4d66..c4e3f07 100644
--- a/src/kudu/tablet/delta_tracker.cc
+++ b/src/kudu/tablet/delta_tracker.cc
@@ -76,7 +76,7 @@ Status DeltaTracker::OpenDeltaReaders(const vector<BlockId>& blocks,
DeltaType type) {
FsManager* fs = rowset_metadata_->fs_manager();
for (const BlockId& block_id : blocks) {
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
Status s = fs->OpenBlock(block_id, &block);
if (!s.ok()) {
LOG_WITH_PREFIX(ERROR) << "Failed to open " << DeltaType_Name(type)
@@ -346,7 +346,7 @@ Status DeltaTracker::CompactStores(int start_idx, int end_idx) {
// Open a writer for the new destination delta block
FsManager* fs = rowset_metadata_->fs_manager();
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
RETURN_NOT_OK_PREPEND(fs->CreateNewBlock(&block),
"Could not allocate delta block");
BlockId new_block_id(block->id());
@@ -478,7 +478,7 @@ Status DeltaTracker::DeleteAncientUndoDeltas(Timestamp ancient_history_mark,
}
Status DeltaTracker::DoCompactStores(size_t start_idx, size_t end_idx,
- gscoped_ptr<WritableBlock> block,
+ unique_ptr<WritableBlock> block,
vector<shared_ptr<DeltaStore> > *compacted_stores,
vector<BlockId> *compacted_blocks) {
unique_ptr<DeltaIterator> inputs_merge;
@@ -612,7 +612,7 @@ Status DeltaTracker::FlushDMS(DeltaMemStore* dms,
MetadataFlushType flush_type) {
// Open file for write.
FsManager* fs = rowset_metadata_->fs_manager();
- gscoped_ptr<WritableBlock> writable_block;
+ unique_ptr<WritableBlock> writable_block;
RETURN_NOT_OK_PREPEND(fs->CreateNewBlock(&writable_block),
"Unable to allocate new delta data writable_block");
BlockId block_id(writable_block->id());
@@ -630,7 +630,7 @@ Status DeltaTracker::FlushDMS(DeltaMemStore* dms,
<< ", " << stats->max_timestamp() << "]";
// Now re-open for read
- gscoped_ptr<ReadableBlock> readable_block;
+ unique_ptr<ReadableBlock> readable_block;
RETURN_NOT_OK(fs->OpenBlock(block_id, &readable_block));
ReaderOptions options;
options.parent_mem_tracker = mem_trackers_.tablet_tracker;
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tablet/delta_tracker.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_tracker.h b/src/kudu/tablet/delta_tracker.h
index 0a43dc9..50b5505 100644
--- a/src/kudu/tablet/delta_tracker.h
+++ b/src/kudu/tablet/delta_tracker.h
@@ -261,8 +261,8 @@ class DeltaTracker {
// exclusive lock on 'compact_flush_lock_' before calling this
// method in order to protect 'redo_delta_stores_'.
Status DoCompactStores(size_t start_idx, size_t end_idx,
- gscoped_ptr<fs::WritableBlock> block,
- vector<std::shared_ptr<DeltaStore> > *compacted_stores,
+ std::unique_ptr<fs::WritableBlock> block,
+ std::vector<std::shared_ptr<DeltaStore>>* compacted_stores,
std::vector<BlockId>* compacted_blocks);
// Creates a merge delta iterator and captures the delta stores and
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tablet/deltafile-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/deltafile-test.cc b/src/kudu/tablet/deltafile-test.cc
index a550bbe..e151c21 100644
--- a/src/kudu/tablet/deltafile-test.cc
+++ b/src/kudu/tablet/deltafile-test.cc
@@ -37,6 +37,7 @@ DEFINE_int32(n_verify, 1, "number of times to verify the updates"
using std::is_sorted;
using std::shared_ptr;
+using std::unique_ptr;
namespace kudu {
namespace tablet {
@@ -67,7 +68,7 @@ class TestDeltaFile : public KuduTest {
}
void WriteTestFile(int min_timestamp = 0, int max_timestamp = 0) {
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
ASSERT_OK(fs_manager_->CreateNewBlock(&block));
test_block_ = block->id();
DeltaFileWriter dfw(std::move(block));
@@ -105,7 +106,7 @@ class TestDeltaFile : public KuduTest {
}
Status OpenDeltaFileReader(const BlockId& block_id, shared_ptr<DeltaFileReader>* out) {
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
RETURN_NOT_OK(fs_manager_->OpenBlock(block_id, &block));
return DeltaFileReader::Open(std::move(block), REDO, ReaderOptions(), out);
}
@@ -217,7 +218,7 @@ TEST_F(TestDeltaFile, TestWriteDeltaFileIteratorToFile) {
}
ASSERT_OK(s);
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
ASSERT_OK(fs_manager_->CreateNewBlock(&block));
BlockId block_id(block->id());
DeltaFileWriter dfw(std::move(block));
@@ -332,10 +333,10 @@ TEST_F(TestDeltaFile, TestLazyInit) {
WriteTestFile();
// Open it using a "counting" readable block.
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
ASSERT_OK(fs_manager_->OpenBlock(test_block_, &block));
size_t bytes_read = 0;
- gscoped_ptr<ReadableBlock> count_block(
+ unique_ptr<ReadableBlock> count_block(
new CountingReadableBlock(std::move(block), &bytes_read));
// Lazily opening the delta file should not trigger any reads.
@@ -364,7 +365,7 @@ TEST_F(TestDeltaFile, TestLazyInit) {
// Check that, if a delta file is opened but no deltas are written,
// Finish() will return Status::Aborted().
TEST_F(TestDeltaFile, TestEmptyFileIsAborted) {
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
ASSERT_OK(fs_manager_->CreateNewBlock(&block));
test_block_ = block->id();
{
@@ -377,7 +378,7 @@ TEST_F(TestDeltaFile, TestEmptyFileIsAborted) {
}
// The block should have been deleted as well.
- gscoped_ptr<ReadableBlock> rb;
+ unique_ptr<ReadableBlock> rb;
Status s = fs_manager_->OpenBlock(test_block_, &rb);
ASSERT_TRUE(s.IsNotFound()) << s.ToString();
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tablet/deltafile.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/deltafile.cc b/src/kudu/tablet/deltafile.cc
index 7a9e55f..0572ccf 100644
--- a/src/kudu/tablet/deltafile.cc
+++ b/src/kudu/tablet/deltafile.cc
@@ -70,7 +70,7 @@ namespace {
} // namespace
-DeltaFileWriter::DeltaFileWriter(gscoped_ptr<WritableBlock> block)
+DeltaFileWriter::DeltaFileWriter(unique_ptr<WritableBlock> block)
#ifndef NDEBUG
: has_appended_(false)
#endif
@@ -170,7 +170,7 @@ void DeltaFileWriter::WriteDeltaStats(const DeltaStats& stats) {
// Reader
////////////////////////////////////////////////////////////
-Status DeltaFileReader::Open(gscoped_ptr<ReadableBlock> block,
+Status DeltaFileReader::Open(unique_ptr<ReadableBlock> block,
DeltaType delta_type,
ReaderOptions options,
shared_ptr<DeltaFileReader>* reader_out) {
@@ -185,11 +185,11 @@ Status DeltaFileReader::Open(gscoped_ptr<ReadableBlock> block,
return Status::OK();
}
-Status DeltaFileReader::OpenNoInit(gscoped_ptr<ReadableBlock> block,
+Status DeltaFileReader::OpenNoInit(unique_ptr<ReadableBlock> block,
DeltaType delta_type,
ReaderOptions options,
shared_ptr<DeltaFileReader>* reader_out) {
- gscoped_ptr<CFileReader> cf_reader;
+ unique_ptr<CFileReader> cf_reader;
RETURN_NOT_OK(CFileReader::OpenNoInit(std::move(block),
std::move(options),
&cf_reader));
@@ -204,7 +204,7 @@ Status DeltaFileReader::OpenNoInit(gscoped_ptr<ReadableBlock> block,
return Status::OK();
}
-DeltaFileReader::DeltaFileReader(gscoped_ptr<CFileReader> cf_reader,
+DeltaFileReader::DeltaFileReader(unique_ptr<CFileReader> cf_reader,
DeltaType delta_type)
: reader_(cf_reader.release()),
delta_type_(delta_type) {}
@@ -263,7 +263,7 @@ bool DeltaFileReader::IsRelevantForSnapshot(const MvccSnapshot& snap) const {
Status DeltaFileReader::CloneForDebugging(FsManager* fs_manager,
const shared_ptr<MemTracker>& parent_mem_tracker,
shared_ptr<DeltaFileReader>* out) const {
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
RETURN_NOT_OK(fs_manager->OpenBlock(reader_->block_id(), &block));
ReaderOptions options;
options.parent_mem_tracker = parent_mem_tracker;
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tablet/deltafile.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/deltafile.h b/src/kudu/tablet/deltafile.h
index 78bea23..f0db2d5 100644
--- a/src/kudu/tablet/deltafile.h
+++ b/src/kudu/tablet/deltafile.h
@@ -60,7 +60,7 @@ class DeltaFileWriter {
// Construct a new delta file writer.
//
// The writer takes ownership of the block and will Close it in Finish().
- explicit DeltaFileWriter(gscoped_ptr<fs::WritableBlock> block);
+ explicit DeltaFileWriter(std::unique_ptr<fs::WritableBlock> block);
Status Start();
@@ -85,7 +85,7 @@ class DeltaFileWriter {
private:
Status DoAppendDelta(const DeltaKey &key, const RowChangeList &delta);
- gscoped_ptr<cfile::CFileWriter> writer_;
+ std::unique_ptr<cfile::CFileWriter> writer_;
// Buffer used as a temporary for storing the serialized form
// of the deltas
@@ -110,7 +110,7 @@ class DeltaFileReader : public DeltaStore,
// Fully open a delta file using a previously opened block.
//
// After this call, the delta reader is safe for use.
- static Status Open(gscoped_ptr<fs::ReadableBlock> block,
+ static Status Open(std::unique_ptr<fs::ReadableBlock> block,
DeltaType delta_type,
cfile::ReaderOptions options,
std::shared_ptr<DeltaFileReader>* reader_out);
@@ -120,7 +120,7 @@ class DeltaFileReader : public DeltaStore,
// the delta file.
//
// Init() must be called before using the file's stats.
- static Status OpenNoInit(gscoped_ptr<fs::ReadableBlock> block,
+ static Status OpenNoInit(std::unique_ptr<fs::ReadableBlock> block,
DeltaType delta_type,
cfile::ReaderOptions options,
std::shared_ptr<DeltaFileReader>* reader_out);
@@ -173,7 +173,7 @@ class DeltaFileReader : public DeltaStore,
return reader_;
}
- DeltaFileReader(gscoped_ptr<cfile::CFileReader> cf_reader,
+ DeltaFileReader(std::unique_ptr<cfile::CFileReader> cf_reader,
DeltaType delta_type);
// Callback used in 'init_once_' to initialize this delta file.
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tablet/deltamemstore-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/deltamemstore-test.cc b/src/kudu/tablet/deltamemstore-test.cc
index 60712f7..e0c59f0 100644
--- a/src/kudu/tablet/deltamemstore-test.cc
+++ b/src/kudu/tablet/deltamemstore-test.cc
@@ -37,6 +37,7 @@
DEFINE_int32(benchmark_num_passes, 100, "Number of passes to apply deltas in the benchmark");
using std::shared_ptr;
+using std::unique_ptr;
using std::unordered_set;
namespace kudu {
@@ -166,7 +167,7 @@ TEST_F(TestDeltaMemStore, TestUpdateCount) {
// Flush the delta file so that the stats get updated.
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
ASSERT_OK(fs_manager_->CreateNewBlock(&block));
DeltaFileWriter dfw(std::move(block));
ASSERT_OK(dfw.Start());
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tablet/diskrowset.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/diskrowset.cc b/src/kudu/tablet/diskrowset.cc
index eb32832..69708f6 100644
--- a/src/kudu/tablet/diskrowset.cc
+++ b/src/kudu/tablet/diskrowset.cc
@@ -101,7 +101,7 @@ Status DiskRowSetWriter::Open() {
Status DiskRowSetWriter::InitBloomFileWriter() {
TRACE_EVENT0("tablet", "DiskRowSetWriter::InitBloomFileWriter");
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
FsManager* fs = rowset_metadata_->fs_manager();
RETURN_NOT_OK_PREPEND(fs->CreateNewBlock(&block),
"Couldn't allocate a block for bloom filter");
@@ -114,7 +114,7 @@ Status DiskRowSetWriter::InitBloomFileWriter() {
Status DiskRowSetWriter::InitAdHocIndexWriter() {
TRACE_EVENT0("tablet", "DiskRowSetWriter::InitAdHocIndexWriter");
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
FsManager* fs = rowset_metadata_->fs_manager();
RETURN_NOT_OK_PREPEND(fs->CreateNewBlock(&block),
"Couldn't allocate a block for compoound index");
@@ -311,8 +311,8 @@ Status RollingDiskRowSetWriter::RollWriter() {
RETURN_NOT_OK(cur_writer_->Open());
FsManager* fs = tablet_metadata_->fs_manager();
- gscoped_ptr<WritableBlock> undo_data_block;
- gscoped_ptr<WritableBlock> redo_data_block;
+ unique_ptr<WritableBlock> undo_data_block;
+ unique_ptr<WritableBlock> redo_data_block;
RETURN_NOT_OK(fs->CreateNewBlock(&undo_data_block));
RETURN_NOT_OK(fs->CreateNewBlock(&redo_data_block));
cur_undo_ds_block_id_ = undo_data_block->id();
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tablet/multi_column_writer.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/multi_column_writer.cc b/src/kudu/tablet/multi_column_writer.cc
index 39bd584..51d6c29 100644
--- a/src/kudu/tablet/multi_column_writer.cc
+++ b/src/kudu/tablet/multi_column_writer.cc
@@ -29,6 +29,7 @@ namespace tablet {
using cfile::CFileWriter;
using fs::ScopedWritableBlockCloser;
using fs::WritableBlock;
+using std::unique_ptr;
MultiColumnWriter::MultiColumnWriter(FsManager* fs,
const Schema* schema)
@@ -68,7 +69,7 @@ Status MultiColumnWriter::Open() {
}
// Open file for write.
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
RETURN_NOT_OK_PREPEND(fs_->CreateNewBlock(&block),
"Unable to open output file for column " + col.ToString());
BlockId block_id(block->id());
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tablet/tablet-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet-test.cc b/src/kudu/tablet/tablet-test.cc
index 1de12bd..564ca3e 100644
--- a/src/kudu/tablet/tablet-test.cc
+++ b/src/kudu/tablet/tablet-test.cc
@@ -40,6 +40,7 @@ DEFINE_int32(testcompaction_num_rows, 1000,
"Number of rows per rowset in TestCompaction");
using std::shared_ptr;
+using std::unique_ptr;
namespace kudu {
namespace tablet {
@@ -83,7 +84,7 @@ TYPED_TEST(TestTablet, TestFlush) {
ASSERT_EQ(1, undo_blocks.size());
// Read the undo delta, we should get one undo mutation (delete) for each row.
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
ASSERT_OK(this->fs_manager()->OpenBlock(undo_blocks[0], &block));
shared_ptr<DeltaFileReader> dfr;
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tools/kudu-tool-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/kudu-tool-test.cc b/src/kudu/tools/kudu-tool-test.cc
index e7052a3..e6c241a 100644
--- a/src/kudu/tools/kudu-tool-test.cc
+++ b/src/kudu/tools/kudu-tool-test.cc
@@ -610,7 +610,7 @@ TEST_F(ToolTest, TestFsDumpCFile) {
ASSERT_OK(fs.CreateInitialFileSystemLayout());
ASSERT_OK(fs.Open());
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
ASSERT_OK(fs.CreateNewBlock(&block));
BlockId block_id = block->id();
StringDataGenerator<false> generator("hello %04d");
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tools/tool_action_fs.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/tool_action_fs.cc b/src/kudu/tools/tool_action_fs.cc
index 59a4c21..3149e52 100644
--- a/src/kudu/tools/tool_action_fs.cc
+++ b/src/kudu/tools/tool_action_fs.cc
@@ -172,10 +172,10 @@ Status DumpCFile(const RunnerContext& context) {
FsManager fs_manager(Env::Default(), fs_opts);
RETURN_NOT_OK(fs_manager.Open());
- gscoped_ptr<fs::ReadableBlock> block;
+ unique_ptr<fs::ReadableBlock> block;
RETURN_NOT_OK(fs_manager.OpenBlock(block_id, &block));
- gscoped_ptr<CFileReader> reader;
+ unique_ptr<CFileReader> reader;
RETURN_NOT_OK(CFileReader::Open(std::move(block), ReaderOptions(), &reader));
if (FLAGS_print_meta) {
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tools/tool_action_local_replica.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/tool_action_local_replica.cc b/src/kudu/tools/tool_action_local_replica.cc
index ad728b5..0736a66 100644
--- a/src/kudu/tools/tool_action_local_replica.cc
+++ b/src/kudu/tools/tool_action_local_replica.cc
@@ -451,9 +451,9 @@ Status ListLocalReplicas(const RunnerContext& context) {
Status DumpCFileBlockInternal(FsManager* fs_manager,
const BlockId& block_id,
int indent) {
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
RETURN_NOT_OK(fs_manager->OpenBlock(block_id, &block));
- gscoped_ptr<CFileReader> reader;
+ unique_ptr<CFileReader> reader;
RETURN_NOT_OK(CFileReader::Open(std::move(block), ReaderOptions(), &reader));
cout << Indent(indent) << "CFile Header: "
@@ -477,7 +477,7 @@ Status DumpDeltaCFileBlockInternal(FsManager* fs_manager,
DeltaType delta_type,
int indent) {
// Open the delta reader
- gscoped_ptr<ReadableBlock> readable_block;
+ unique_ptr<ReadableBlock> readable_block;
RETURN_NOT_OK(fs_manager->OpenBlock(block_id, &readable_block));
shared_ptr<DeltaFileReader> delta_reader;
RETURN_NOT_OK(DeltaFileReader::Open(std::move(readable_block),
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tserver/tablet_copy-test-base.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy-test-base.h b/src/kudu/tserver/tablet_copy-test-base.h
index 0a634f6..35c3b71 100644
--- a/src/kudu/tserver/tablet_copy-test-base.h
+++ b/src/kudu/tserver/tablet_copy-test-base.h
@@ -107,7 +107,7 @@ class TabletCopyTest : public TabletServerTestBase {
// Slice pointing to it.
Status ReadLocalBlockFile(FsManager* fs_manager, const BlockId& block_id,
faststring* scratch, Slice* slice) {
- gscoped_ptr<fs::ReadableBlock> block;
+ std::unique_ptr<fs::ReadableBlock> block;
RETURN_NOT_OK(fs_manager->OpenBlock(block_id, &block));
uint64_t size = 0;
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tserver/tablet_copy_client-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_client-test.cc b/src/kudu/tserver/tablet_copy_client-test.cc
index 213e754..cb92c21 100644
--- a/src/kudu/tserver/tablet_copy_client-test.cc
+++ b/src/kudu/tserver/tablet_copy_client-test.cc
@@ -29,6 +29,7 @@ namespace tserver {
using consensus::GetRaftConfigLeader;
using consensus::RaftPeerPB;
+using std::unique_ptr;
using tablet::TabletMetadata;
class TabletCopyClientTest : public TabletCopyTest {
@@ -223,13 +224,13 @@ TEST_F(TabletCopyClientTest, TestDownloadAllBlocks) {
// FsManager than 'tablet_peer', so the only way an old block could end
// up in ours is due to a tablet copy client bug.
for (const BlockId& block_id : old_data_blocks) {
- gscoped_ptr<fs::ReadableBlock> block;
+ unique_ptr<fs::ReadableBlock> block;
Status s = fs_manager_->OpenBlock(block_id, &block);
ASSERT_TRUE(s.IsNotFound()) << "Expected block not found: " << s.ToString();
}
// And the new blocks are all present.
for (const BlockId& block_id : new_data_blocks) {
- gscoped_ptr<fs::ReadableBlock> block;
+ unique_ptr<fs::ReadableBlock> block;
ASSERT_OK(fs_manager_->OpenBlock(block_id, &block));
}
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tserver/tablet_copy_client.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_client.cc b/src/kudu/tserver/tablet_copy_client.cc
index 3d759e3..0c918de 100644
--- a/src/kudu/tserver/tablet_copy_client.cc
+++ b/src/kudu/tserver/tablet_copy_client.cc
@@ -514,7 +514,7 @@ Status TabletCopyClient::DownloadBlock(const BlockId& old_block_id,
BlockId* new_block_id) {
VLOG_WITH_PREFIX(1) << "Downloading block with block_id " << old_block_id.ToString();
- gscoped_ptr<WritableBlock> block;
+ unique_ptr<WritableBlock> block;
RETURN_NOT_OK_PREPEND(fs_manager_->CreateNewBlock(&block),
"Unable to create new block");
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tserver/tablet_copy_source_session-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_source_session-test.cc b/src/kudu/tserver/tablet_copy_source_session-test.cc
index c39c098..2d9ec1d 100644
--- a/src/kudu/tserver/tablet_copy_source_session-test.cc
+++ b/src/kudu/tserver/tablet_copy_source_session-test.cc
@@ -272,7 +272,7 @@ TEST_F(TabletCopyTest, TestBlocksEqual) {
LOG(INFO) << "session block file has size of " << session_block_size
<< " and CRC32C of " << session_crc << ": " << path;
- gscoped_ptr<ReadableBlock> tablet_block;
+ unique_ptr<ReadableBlock> tablet_block;
ASSERT_OK(fs_manager()->OpenBlock(block_id, &tablet_block));
uint64_t tablet_block_size = 0;
ASSERT_OK(tablet_block->Size(&tablet_block_size));
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tserver/tablet_copy_source_session.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_source_session.cc b/src/kudu/tserver/tablet_copy_source_session.cc
index 9976f39..c357673 100644
--- a/src/kudu/tserver/tablet_copy_source_session.cc
+++ b/src/kudu/tserver/tablet_copy_source_session.cc
@@ -47,6 +47,7 @@ using consensus::OpId;
using fs::ReadableBlock;
using log::ReadableLogSegment;
using std::shared_ptr;
+using std::unique_ptr;
using strings::Substitute;
using tablet::TabletMetadata;
using tablet::TabletPeer;
@@ -300,7 +301,7 @@ static Status AddImmutableFileToMap(Collection* const cache,
Status TabletCopySourceSession::OpenBlockUnlocked(const BlockId& block_id) {
session_lock_.AssertAcquired();
- gscoped_ptr<ReadableBlock> block;
+ unique_ptr<ReadableBlock> block;
Status s = fs_manager_->OpenBlock(block_id, &block);
if (PREDICT_FALSE(!s.ok())) {
LOG(WARNING) << "Unable to open requested (existing) block file: "
http://git-wip-us.apache.org/repos/asf/kudu/blob/cf25ec5c/src/kudu/tserver/tablet_copy_source_session.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_copy_source_session.h b/src/kudu/tserver/tablet_copy_source_session.h
index d51a024..7c6ba44 100644
--- a/src/kudu/tserver/tablet_copy_source_session.h
+++ b/src/kudu/tserver/tablet_copy_source_session.h
@@ -66,7 +66,7 @@ struct ImmutableRandomAccessFileInfo {
// Caches block size and holds an exclusive reference to a ReadableBlock.
// Assumes that the block underlying the ReadableBlock is immutable.
struct ImmutableReadableBlockInfo {
- gscoped_ptr<fs::ReadableBlock> readable;
+ std::unique_ptr<fs::ReadableBlock> readable;
int64_t size;
ImmutableReadableBlockInfo(fs::ReadableBlock* readable,