You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2017/08/10 00:05:11 UTC
[5/6] kudu git commit: remove 'using std::...' and other from header
files
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/common/types.h
----------------------------------------------------------------------
diff --git a/src/kudu/common/types.h b/src/kudu/common/types.h
index 6e418dc..d1c9c79 100644
--- a/src/kudu/common/types.h
+++ b/src/kudu/common/types.h
@@ -37,7 +37,6 @@ namespace kudu {
// type we support.
const int kLargestTypeSize = sizeof(Slice);
-using std::string;
class TypeInfo;
// This is the important bit of this header:
@@ -52,9 +51,9 @@ class TypeInfo {
DataType type() const { return type_; }
// Returns the type used to actually store the data.
DataType physical_type() const { return physical_type_; }
- const string& name() const { return name_; }
+ const std::string& name() const { return name_; }
const size_t size() const { return size_; }
- void AppendDebugStringForValue(const void *ptr, string *str) const;
+ void AppendDebugStringForValue(const void *ptr, std::string *str) const;
int Compare(const void *lhs, const void *rhs) const;
// Returns true if increment(a) is equal to b.
bool AreConsecutive(const void* a, const void* b) const;
@@ -75,13 +74,13 @@ class TypeInfo {
const DataType type_;
const DataType physical_type_;
- const string name_;
+ const std::string name_;
const size_t size_;
const void* const min_value_;
// The maximum value of the type, or null if the type has no max value.
const void* const max_value_;
- typedef void (*AppendDebugFunc)(const void *, string *);
+ typedef void (*AppendDebugFunc)(const void *, std::string *);
const AppendDebugFunc append_func_;
typedef int (*CompareFunc)(const void *, const void *);
@@ -131,7 +130,7 @@ struct DataTypeTraits<UINT8> {
static const char *name() {
return "uint8";
}
- static void AppendDebugStringForValue(const void *val, string *str) {
+ static void AppendDebugStringForValue(const void *val, std::string *str) {
str->append(SimpleItoa(*reinterpret_cast<const uint8_t *>(val)));
}
static int Compare(const void *lhs, const void *rhs) {
@@ -155,7 +154,7 @@ struct DataTypeTraits<INT8> {
static const char *name() {
return "int8";
}
- static void AppendDebugStringForValue(const void *val, string *str) {
+ static void AppendDebugStringForValue(const void *val, std::string *str) {
str->append(SimpleItoa(*reinterpret_cast<const int8_t *>(val)));
}
static int Compare(const void *lhs, const void *rhs) {
@@ -179,7 +178,7 @@ struct DataTypeTraits<UINT16> {
static const char *name() {
return "uint16";
}
- static void AppendDebugStringForValue(const void *val, string *str) {
+ static void AppendDebugStringForValue(const void *val, std::string *str) {
str->append(SimpleItoa(*reinterpret_cast<const uint16_t *>(val)));
}
static int Compare(const void *lhs, const void *rhs) {
@@ -203,7 +202,7 @@ struct DataTypeTraits<INT16> {
static const char *name() {
return "int16";
}
- static void AppendDebugStringForValue(const void *val, string *str) {
+ static void AppendDebugStringForValue(const void *val, std::string *str) {
str->append(SimpleItoa(*reinterpret_cast<const int16_t *>(val)));
}
static int Compare(const void *lhs, const void *rhs) {
@@ -227,7 +226,7 @@ struct DataTypeTraits<UINT32> {
static const char *name() {
return "uint32";
}
- static void AppendDebugStringForValue(const void *val, string *str) {
+ static void AppendDebugStringForValue(const void *val, std::string *str) {
str->append(SimpleItoa(*reinterpret_cast<const uint32_t *>(val)));
}
static int Compare(const void *lhs, const void *rhs) {
@@ -251,7 +250,7 @@ struct DataTypeTraits<INT32> {
static const char *name() {
return "int32";
}
- static void AppendDebugStringForValue(const void *val, string *str) {
+ static void AppendDebugStringForValue(const void *val, std::string *str) {
str->append(SimpleItoa(*reinterpret_cast<const int32_t *>(val)));
}
static int Compare(const void *lhs, const void *rhs) {
@@ -275,7 +274,7 @@ struct DataTypeTraits<UINT64> {
static const char *name() {
return "uint64";
}
- static void AppendDebugStringForValue(const void *val, string *str) {
+ static void AppendDebugStringForValue(const void *val, std::string *str) {
str->append(SimpleItoa(*reinterpret_cast<const uint64_t *>(val)));
}
static int Compare(const void *lhs, const void *rhs) {
@@ -299,7 +298,7 @@ struct DataTypeTraits<INT64> {
static const char *name() {
return "int64";
}
- static void AppendDebugStringForValue(const void *val, string *str) {
+ static void AppendDebugStringForValue(const void *val, std::string *str) {
str->append(SimpleItoa(*reinterpret_cast<const int64_t *>(val)));
}
static int Compare(const void *lhs, const void *rhs) {
@@ -323,7 +322,7 @@ struct DataTypeTraits<FLOAT> {
static const char *name() {
return "float";
}
- static void AppendDebugStringForValue(const void *val, string *str) {
+ static void AppendDebugStringForValue(const void *val, std::string *str) {
str->append(SimpleFtoa(*reinterpret_cast<const float *>(val)));
}
static int Compare(const void *lhs, const void *rhs) {
@@ -347,7 +346,7 @@ struct DataTypeTraits<DOUBLE> {
static const char *name() {
return "double";
}
- static void AppendDebugStringForValue(const void *val, string *str) {
+ static void AppendDebugStringForValue(const void *val, std::string *str) {
str->append(SimpleDtoa(*reinterpret_cast<const double *>(val)));
}
static int Compare(const void *lhs, const void *rhs) {
@@ -371,7 +370,7 @@ struct DataTypeTraits<BINARY> {
static const char *name() {
return "binary";
}
- static void AppendDebugStringForValue(const void *val, string *str) {
+ static void AppendDebugStringForValue(const void *val, std::string *str) {
const Slice *s = reinterpret_cast<const Slice *>(val);
str->push_back('"');
str->append(strings::CHexEscape(s->ToString()));
@@ -411,7 +410,7 @@ struct DataTypeTraits<BOOL> {
static const char* name() {
return "bool";
}
- static void AppendDebugStringForValue(const void* val, string* str) {
+ static void AppendDebugStringForValue(const void* val, std::string* str) {
str->append(*reinterpret_cast<const bool *>(val) ? "true" : "false");
}
static int Compare(const void *lhs, const void *rhs) {
@@ -437,7 +436,7 @@ struct DerivedTypeTraits {
typedef typename DataTypeTraits<PhysicalType>::cpp_type cpp_type;
static const DataType physical_type = PhysicalType;
- static void AppendDebugStringForValue(const void *val, string *str) {
+ static void AppendDebugStringForValue(const void *val, std::string *str) {
DataTypeTraits<PhysicalType>::AppendDebugStringForValue(val, str);
}
@@ -463,7 +462,7 @@ struct DataTypeTraits<STRING> : public DerivedTypeTraits<BINARY>{
static const char* name() {
return "string";
}
- static void AppendDebugStringForValue(const void *val, string *str) {
+ static void AppendDebugStringForValue(const void *val, std::string *str) {
const Slice *s = reinterpret_cast<const Slice *>(val);
str->push_back('"');
str->append(strings::Utf8SafeCEscape(s->ToString()));
@@ -482,7 +481,7 @@ struct DataTypeTraits<UNIXTIME_MICROS> : public DerivedTypeTraits<INT64>{
return "unixtime_micros";
}
- static void AppendDebugStringForValue(const void* val, string* str) {
+ static void AppendDebugStringForValue(const void* val, std::string* str) {
int64_t timestamp_micros = *reinterpret_cast<const int64_t *>(val);
time_t secs_since_epoch = timestamp_micros / US_TO_S;
// If the time is negative we need to take into account that any microseconds
@@ -598,7 +597,7 @@ class Variant {
// Set the variant to a STRING type.
// The specified data block will be copied, and released by the variant
// on the next set/clear call.
- void Reset(const string& data) {
+ void Reset(const std::string& data) {
Slice slice(data);
Reset(STRING, &slice);
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/common/wire_protocol-test-util.h
----------------------------------------------------------------------
diff --git a/src/kudu/common/wire_protocol-test-util.h b/src/kudu/common/wire_protocol-test-util.h
index 8e47c96..a5a0412 100644
--- a/src/kudu/common/wire_protocol-test-util.h
+++ b/src/kudu/common/wire_protocol-test-util.h
@@ -56,7 +56,7 @@ inline void AddTestRowToPB(RowOperationsPB::Type op_type,
const Schema& schema,
int32_t key,
int32_t int_val,
- const string& string_val,
+ const std::string& string_val,
RowOperationsPB* ops) {
AddTestRowWithNullableStringToPB(op_type, schema, key, int_val, string_val.c_str(), ops);
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/common/wire_protocol-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/wire_protocol-test.cc b/src/kudu/common/wire_protocol-test.cc
index 83a966e..c5cc271 100644
--- a/src/kudu/common/wire_protocol-test.cc
+++ b/src/kudu/common/wire_protocol-test.cc
@@ -31,6 +31,7 @@
#include "kudu/util/test_macros.h"
#include "kudu/util/test_util.h"
+using std::string;
using std::vector;
namespace kudu {
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/common/wire_protocol.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/wire_protocol.cc b/src/kudu/common/wire_protocol.cc
index 33850a9..b1e06f2 100644
--- a/src/kudu/common/wire_protocol.cc
+++ b/src/kudu/common/wire_protocol.cc
@@ -37,6 +37,7 @@
#include "kudu/util/slice.h"
using google::protobuf::RepeatedPtrField;
+using std::string;
using std::vector;
namespace kudu {
@@ -452,7 +453,7 @@ void ColumnPredicateToPB(const ColumnPredicate& predicate,
Status ColumnPredicateFromPB(const Schema& schema,
Arena* arena,
const ColumnPredicatePB& pb,
- optional<ColumnPredicate>* predicate) {
+ boost::optional<ColumnPredicate>* predicate) {
if (!pb.has_column()) {
return Status::InvalidArgument("Column predicate must include a column", SecureDebugString(pb));
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/common/wire_protocol.h
----------------------------------------------------------------------
diff --git a/src/kudu/common/wire_protocol.h b/src/kudu/common/wire_protocol.h
index bd77171..a113053 100644
--- a/src/kudu/common/wire_protocol.h
+++ b/src/kudu/common/wire_protocol.h
@@ -25,8 +25,6 @@
#include "kudu/common/wire_protocol.pb.h"
#include "kudu/util/status.h"
-using boost::optional;
-
namespace kudu {
class Arena;
@@ -119,7 +117,7 @@ void ColumnPredicateToPB(const ColumnPredicate& predicate, ColumnPredicatePB* pb
Status ColumnPredicateFromPB(const Schema& schema,
Arena* arena,
const ColumnPredicatePB& pb,
- optional<ColumnPredicate>* predicate);
+ boost::optional<ColumnPredicate>* predicate);
// Encode the given row block into the provided protobuf and data buffers.
//
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/consensus-test-util.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus-test-util.h b/src/kudu/consensus/consensus-test-util.h
index de1b587..1075db4 100644
--- a/src/kudu/consensus/consensus-test-util.h
+++ b/src/kudu/consensus/consensus-test-util.h
@@ -49,16 +49,14 @@
#define ASSERT_OPID_EQ(left, right) \
OpId TOKENPASTE2(_left, __LINE__) = (left); \
OpId TOKENPASTE2(_right, __LINE__) = (right); \
- if (!consensus::OpIdEquals(TOKENPASTE2(_left, __LINE__), TOKENPASTE2(_right,__LINE__))) \
+ if (!consensus::OpIdEquals(TOKENPASTE2(_left, __LINE__), TOKENPASTE2(_right,__LINE__))) { \
FAIL() << "Expected: " << SecureShortDebugString(TOKENPASTE2(_right,__LINE__)) << "\n" \
- << "Value: " << SecureShortDebugString(TOKENPASTE2(_left,__LINE__)) << "\n"
+ << "Value: " << SecureShortDebugString(TOKENPASTE2(_left,__LINE__)) << "\n"; \
+ }
namespace kudu {
namespace consensus {
-using log::Log;
-using strings::Substitute;
-
inline gscoped_ptr<ReplicateMsg> CreateDummyReplicate(int64_t term,
int64_t index,
const Timestamp& timestamp,
@@ -78,7 +76,8 @@ inline gscoped_ptr<ReplicateMsg> CreateDummyReplicate(int64_t term,
inline RaftPeerPB FakeRaftPeerPB(const std::string& uuid) {
RaftPeerPB peer_pb;
peer_pb.set_permanent_uuid(uuid);
- peer_pb.mutable_last_known_addr()->set_host(Substitute("$0-fake-hostname", CURRENT_TEST_NAME()));
+ peer_pb.mutable_last_known_addr()->set_host(strings::Substitute(
+ "$0-fake-hostname", CURRENT_TEST_NAME()));
peer_pb.mutable_last_known_addr()->set_port(0);
return peer_pb;
}
@@ -109,9 +108,9 @@ inline RaftConfigPB BuildRaftConfigPBForTests(int num) {
for (int i = 0; i < num; i++) {
RaftPeerPB* peer_pb = raft_config.add_peers();
peer_pb->set_member_type(RaftPeerPB::VOTER);
- peer_pb->set_permanent_uuid(Substitute("peer-$0", i));
+ peer_pb->set_permanent_uuid(strings::Substitute("peer-$0", i));
HostPortPB* hp = peer_pb->mutable_last_known_addr();
- hp->set_host(Substitute("peer-$0.fake-domain-for-tests", i));
+ hp->set_host(strings::Substitute("peer-$0.fake-domain-for-tests", i));
hp->set_port(0);
}
return raft_config;
@@ -578,7 +577,7 @@ class LocalTestPeerProxyFactory : public PeerProxyFactory {
return Status::OK();
}
- const vector<LocalTestPeerProxy*>& GetProxies() {
+ const std::vector<LocalTestPeerProxy*>& GetProxies() {
return proxies_;
}
@@ -591,7 +590,7 @@ class LocalTestPeerProxyFactory : public PeerProxyFactory {
std::shared_ptr<rpc::Messenger> messenger_;
TestPeerMapManager* const peers_;
// NOTE: There is no need to delete this on the dctor because proxies are externally managed
- vector<LocalTestPeerProxy*> proxies_;
+ std::vector<LocalTestPeerProxy*> proxies_;
};
// A simple implementation of the transaction driver.
@@ -600,7 +599,7 @@ class LocalTestPeerProxyFactory : public PeerProxyFactory {
// work.
class TestDriver {
public:
- TestDriver(ThreadPool* pool, Log* log, const scoped_refptr<ConsensusRound>& round)
+ TestDriver(ThreadPool* pool, log::Log* log, const scoped_refptr<ConsensusRound>& round)
: round_(round),
pool_(pool),
log_(log) {
@@ -645,14 +644,15 @@ class TestDriver {
}
ThreadPool* pool_;
- Log* log_;
+ log::Log* log_;
};
// A transaction factory for tests, usually this is implemented by TabletReplica.
class TestTransactionFactory : public ReplicaTransactionFactory {
public:
- explicit TestTransactionFactory(Log* log) : consensus_(nullptr),
- log_(log) {
+ explicit TestTransactionFactory(log::Log* log)
+ : consensus_(nullptr),
+ log_(log) {
CHECK_OK(ThreadPoolBuilder("test-txn-factory").set_max_threads(1).Build(&pool_));
}
@@ -690,7 +690,7 @@ class TestTransactionFactory : public ReplicaTransactionFactory {
private:
gscoped_ptr<ThreadPool> pool_;
RaftConsensus* consensus_;
- Log* log_;
+ log::Log* log_;
};
} // namespace consensus
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/consensus_peers-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_peers-test.cc b/src/kudu/consensus/consensus_peers-test.cc
index e1b0ac3..97dc179 100644
--- a/src/kudu/consensus/consensus_peers-test.cc
+++ b/src/kudu/consensus/consensus_peers-test.cc
@@ -45,6 +45,7 @@ using log::LogOptions;
using rpc::Messenger;
using rpc::MessengerBuilder;
using std::shared_ptr;
+using std::string;
using std::unique_ptr;
const char* kTabletId = "test-peers-tablet";
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/consensus_peers.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_peers.cc b/src/kudu/consensus/consensus_peers.cc
index bbf48ce..1fce7c5 100644
--- a/src/kudu/consensus/consensus_peers.cc
+++ b/src/kudu/consensus/consensus_peers.cc
@@ -78,10 +78,12 @@ DECLARE_int32(raft_heartbeat_interval_ms);
namespace kudu {
namespace consensus {
-using std::shared_ptr;
-using std::weak_ptr;
using rpc::Messenger;
using rpc::RpcController;
+using std::shared_ptr;
+using std::string;
+using std::vector;
+using std::weak_ptr;
using strings::Substitute;
using tserver::TabletServerErrorPB;
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/consensus_queue-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_queue-test.cc b/src/kudu/consensus/consensus_queue-test.cc
index 0ce4419..69fdad8 100644
--- a/src/kudu/consensus/consensus_queue-test.cc
+++ b/src/kudu/consensus/consensus_queue-test.cc
@@ -42,6 +42,8 @@ DECLARE_int32(consensus_max_batch_size_bytes);
METRIC_DECLARE_entity(tablet);
+using std::vector;
+
namespace kudu {
namespace consensus {
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/consensus_queue.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_queue.cc b/src/kudu/consensus/consensus_queue.cc
index cf3d250..d7aa2f7 100644
--- a/src/kudu/consensus/consensus_queue.cc
+++ b/src/kudu/consensus/consensus_queue.cc
@@ -73,7 +73,9 @@ namespace kudu {
namespace consensus {
using log::Log;
+using std::string;
using std::unique_ptr;
+using std::vector;
using strings::Substitute;
METRIC_DEFINE_gauge_int64(tablet, majority_done_ops, "Leader Operations Acked by Majority",
@@ -228,7 +230,7 @@ void PeerMessageQueue::UntrackPeer(const string& uuid) {
void PeerMessageQueue::CheckPeersInActiveConfigIfLeaderUnlocked() const {
DCHECK(queue_lock_.is_locked());
if (queue_state_.mode != LEADER) return;
- unordered_set<string> config_peer_uuids;
+ std::unordered_set<string> config_peer_uuids;
for (const RaftPeerPB& peer_pb : queue_state_.active_config->peers()) {
InsertOrDie(&config_peer_uuids, peer_pb.permanent_uuid());
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/log-test-base.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log-test-base.h b/src/kudu/consensus/log-test-base.h
index a4ee663..6647617 100644
--- a/src/kudu/consensus/log-test-base.h
+++ b/src/kudu/consensus/log-test-base.h
@@ -53,20 +53,6 @@ METRIC_DECLARE_entity(tablet);
namespace kudu {
namespace log {
-using clock::Clock;
-
-using consensus::OpId;
-using consensus::CommitMsg;
-using consensus::ReplicateMsg;
-using consensus::WRITE_OP;
-using consensus::NO_OP;
-
-using tserver::WriteRequestPB;
-
-using tablet::TxResultPB;
-using tablet::OperationResultPB;
-using tablet::MemStoreTargetPB;
-
constexpr char kTestTable[] = "test-log-table";
constexpr char kTestTableId[] = "test-log-table-id";
constexpr char kTestTablet[] = "test-log-tablet";
@@ -76,19 +62,20 @@ constexpr bool APPEND_ASYNC = false;
// Append a single batch of 'count' NoOps to the log.
// If 'size' is not NULL, increments it by the expected increase in log size.
// Increments 'op_id''s index once for each operation logged.
-inline Status AppendNoOpsToLogSync(const scoped_refptr<Clock>& clock,
+inline Status AppendNoOpsToLogSync(const scoped_refptr<clock::Clock>& clock,
Log* log,
- OpId* op_id,
+ consensus::OpId* op_id,
int count,
int* size = NULL) {
- vector<consensus::ReplicateRefPtr> replicates;
+ std::vector<consensus::ReplicateRefPtr> replicates;
for (int i = 0; i < count; i++) {
- consensus::ReplicateRefPtr replicate = make_scoped_refptr_replicate(new ReplicateMsg());
- ReplicateMsg* repl = replicate->get();
+ consensus::ReplicateRefPtr replicate =
+ make_scoped_refptr_replicate(new consensus::ReplicateMsg());
+ consensus::ReplicateMsg* repl = replicate->get();
repl->mutable_id()->CopyFrom(*op_id);
- repl->set_op_type(NO_OP);
+ repl->set_op_type(consensus::NO_OP);
repl->set_timestamp(clock->Now().ToUint64());
// Increment op_id.
@@ -113,9 +100,9 @@ inline Status AppendNoOpsToLogSync(const scoped_refptr<Clock>& clock,
return s.Wait();
}
-inline Status AppendNoOpToLogSync(const scoped_refptr<Clock>& clock,
+inline Status AppendNoOpToLogSync(const scoped_refptr<clock::Clock>& clock,
Log* log,
- OpId* op_id,
+ consensus::OpId* op_id,
int* size = NULL) {
return AppendNoOpsToLogSync(clock, log, op_id, 1, size);
}
@@ -128,7 +115,7 @@ enum CorruptionType {
FLIP_BYTE
};
-inline Status CorruptLogFile(Env* env, const string& log_path,
+inline Status CorruptLogFile(Env* env, const std::string& log_path,
CorruptionType type, int corruption_offset) {
faststring buf;
RETURN_NOT_OK_PREPEND(ReadFileToString(env, log_path, &buf),
@@ -153,7 +140,7 @@ inline Status CorruptLogFile(Env* env, const string& log_path,
class LogTestBase : public KuduTest {
public:
- typedef pair<int, int> DeltaId;
+ typedef std::pair<int, int> DeltaId;
LogTestBase()
: schema_(GetSimpleTestSchema()),
@@ -192,13 +179,13 @@ class LogTestBase : public KuduTest {
void CheckRightNumberOfSegmentFiles(int expected) {
// Test that we actually have the expected number of files in the fs.
// We should have n segments plus '.' and '..'
- vector<string> files;
+ std::vector<std::string> files;
ASSERT_OK(env_->GetChildren(
JoinPathSegments(fs_manager_->GetWalsRootDir(),
kTestTablet),
&files));
int count = 0;
- for (const string& s : files) {
+ for (const std::string& s : files) {
if (HasPrefixString(s, FsManager::kWalFileNamePrefix)) {
count++;
}
@@ -206,7 +193,7 @@ class LogTestBase : public KuduTest {
ASSERT_EQ(expected, count);
}
- void EntriesToIdList(vector<uint32_t>* ids) {
+ void EntriesToIdList(std::vector<uint32_t>* ids) {
for (const LogEntryPB* entry : entries_) {
VLOG(2) << "Entry contents: " << SecureDebugString(*entry);
if (entry->type() == REPLICATE) {
@@ -220,12 +207,13 @@ class LogTestBase : public KuduTest {
}
// Appends a batch with size 2 (1 insert, 1 mutate) to the log.
- void AppendReplicateBatch(const OpId& opid, bool sync = APPEND_SYNC) {
- consensus::ReplicateRefPtr replicate = make_scoped_refptr_replicate(new ReplicateMsg());
- replicate->get()->set_op_type(WRITE_OP);
+ void AppendReplicateBatch(const consensus::OpId& opid, bool sync = APPEND_SYNC) {
+ consensus::ReplicateRefPtr replicate =
+ make_scoped_refptr_replicate(new consensus::ReplicateMsg());
+ replicate->get()->set_op_type(consensus::WRITE_OP);
replicate->get()->mutable_id()->CopyFrom(opid);
replicate->get()->set_timestamp(clock_->Now().ToUint64());
- WriteRequestPB* batch_request = replicate->get()->mutable_write_request();
+ tserver::WriteRequestPB* batch_request = replicate->get()->mutable_write_request();
ASSERT_OK(SchemaToPB(schema_, batch_request->mutable_schema()));
AddTestRowToPB(RowOperationsPB::INSERT, schema_,
opid.index(),
@@ -262,7 +250,7 @@ class LogTestBase : public KuduTest {
// Append a commit log entry containing one entry for the insert and one
// for the mutate.
- void AppendCommit(const OpId& original_opid,
+ void AppendCommit(const consensus::OpId& original_opid,
bool sync = APPEND_SYNC) {
// The mrs id for the insert.
const int kTargetMrsId = 1;
@@ -274,21 +262,21 @@ class LogTestBase : public KuduTest {
AppendCommit(original_opid, kTargetMrsId, kTargetRsId, kTargetDeltaId, sync);
}
- void AppendCommit(const OpId& original_opid,
+ void AppendCommit(const consensus::OpId& original_opid,
int mrs_id, int rs_id, int dms_id,
bool sync = APPEND_SYNC) {
- gscoped_ptr<CommitMsg> commit(new CommitMsg);
- commit->set_op_type(WRITE_OP);
+ gscoped_ptr<consensus::CommitMsg> commit(new consensus::CommitMsg);
+ commit->set_op_type(consensus::WRITE_OP);
commit->mutable_commited_op_id()->CopyFrom(original_opid);
- TxResultPB* result = commit->mutable_result();
+ tablet::TxResultPB* result = commit->mutable_result();
- OperationResultPB* insert = result->add_ops();
+ tablet::OperationResultPB* insert = result->add_ops();
insert->add_mutated_stores()->set_mrs_id(mrs_id);
- OperationResultPB* mutate = result->add_ops();
- MemStoreTargetPB* target = mutate->add_mutated_stores();
+ tablet::OperationResultPB* mutate = result->add_ops();
+ tablet::MemStoreTargetPB* target = mutate->add_mutated_stores();
target->set_dms_id(dms_id);
target->set_rs_id(rs_id);
AppendCommit(std::move(commit), sync);
@@ -297,23 +285,23 @@ class LogTestBase : public KuduTest {
// Append a COMMIT message for 'original_opid', but with results
// indicating that the associated writes failed due to
// "NotFound" errors.
- void AppendCommitWithNotFoundOpResults(const OpId& original_opid) {
- gscoped_ptr<CommitMsg> commit(new CommitMsg);
- commit->set_op_type(WRITE_OP);
+ void AppendCommitWithNotFoundOpResults(const consensus::OpId& original_opid) {
+ gscoped_ptr<consensus::CommitMsg> commit(new consensus::CommitMsg);
+ commit->set_op_type(consensus::WRITE_OP);
commit->mutable_commited_op_id()->CopyFrom(original_opid);
- TxResultPB* result = commit->mutable_result();
+ tablet::TxResultPB* result = commit->mutable_result();
- OperationResultPB* insert = result->add_ops();
+ tablet::OperationResultPB* insert = result->add_ops();
StatusToPB(Status::NotFound("fake failed write"), insert->mutable_failed_status());
- OperationResultPB* mutate = result->add_ops();
+ tablet::OperationResultPB* mutate = result->add_ops();
StatusToPB(Status::NotFound("fake failed write"), mutate->mutable_failed_status());
AppendCommit(std::move(commit));
}
- void AppendCommit(gscoped_ptr<CommitMsg> commit, bool sync = APPEND_SYNC) {
+ void AppendCommit(gscoped_ptr<consensus::CommitMsg> commit, bool sync = APPEND_SYNC) {
if (sync) {
Synchronizer s;
ASSERT_OK(log_->AsyncAppendCommit(std::move(commit), s.AsStatusCallback()));
@@ -327,7 +315,7 @@ class LogTestBase : public KuduTest {
// Appends 'count' ReplicateMsgs and the corresponding CommitMsgs to the log
void AppendReplicateBatchAndCommitEntryPairsToLog(int count, bool sync = true) {
for (int i = 0; i < count; i++) {
- OpId opid = consensus::MakeOpId(1, current_index_);
+ consensus::OpId opid = consensus::MakeOpId(1, current_index_);
AppendReplicateBatch(opid);
AppendCommit(opid, sync);
current_index_ += 1;
@@ -337,7 +325,7 @@ class LogTestBase : public KuduTest {
// Append a single NO_OP entry. Increments op_id by one.
// If non-NULL, and if the write is successful, 'size' is incremented
// by the size of the written operation.
- Status AppendNoOp(OpId* op_id, int* size = NULL) {
+ Status AppendNoOp(consensus::OpId* op_id, int* size = NULL) {
return AppendNoOpToLogSync(clock_, log_.get(), op_id, size);
}
@@ -345,7 +333,7 @@ class LogTestBase : public KuduTest {
// Increments op_id's index by the number of records written.
// If non-NULL, 'size' keeps track of the size of the operations
// successfully written.
- Status AppendNoOps(OpId* op_id, int num, int* size = NULL) {
+ Status AppendNoOps(consensus::OpId* op_id, int num, int* size = NULL) {
for (int i = 0; i < num; i++) {
RETURN_NOT_OK(AppendNoOp(op_id, size));
}
@@ -357,8 +345,8 @@ class LogTestBase : public KuduTest {
return log_->RollOver();
}
- string DumpSegmentsToString(const SegmentSequence& segments) {
- string dump;
+ std::string DumpSegmentsToString(const SegmentSequence& segments) {
+ std::string dump;
for (const scoped_refptr<ReadableLogSegment>& segment : segments) {
dump.append("------------\n");
strings::SubstituteAndAppend(&dump, "Segment: $0, Path: $1\n",
@@ -388,9 +376,9 @@ class LogTestBase : public KuduTest {
int64_t current_index_;
LogOptions options_;
// Reusable entries vector that deletes the entries on destruction.
- vector<LogEntryPB* > entries_;
+ std::vector<LogEntryPB* > entries_;
scoped_refptr<LogAnchorRegistry> log_anchor_registry_;
- scoped_refptr<Clock> clock_;
+ scoped_refptr<clock::Clock> clock_;
};
} // namespace log
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/log-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log-test.cc b/src/kudu/consensus/log-test.cc
index 7101af9..dd5c69b 100644
--- a/src/kudu/consensus/log-test.cc
+++ b/src/kudu/consensus/log-test.cc
@@ -51,7 +51,12 @@ using std::shared_ptr;
using std::string;
using std::unique_ptr;
using std::vector;
+using consensus::CommitMsg;
using consensus::MakeOpId;
+using consensus::NO_OP;
+using consensus::OpId;
+using consensus::ReplicateMsg;
+using consensus::WRITE_OP;
using strings::Substitute;
struct TestLogSequenceElem {
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/log.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log.h b/src/kudu/consensus/log.h
index 4027c8a..c4d16a3 100644
--- a/src/kudu/consensus/log.h
+++ b/src/kudu/consensus/log.h
@@ -93,7 +93,7 @@ class Log : public RefCountedThreadSafe<Log> {
// Append the given set of replicate messages, asynchronously.
// This requires that the replicates have already been assigned OpIds.
- Status AsyncAppendReplicates(const vector<consensus::ReplicateRefPtr>& replicates,
+ Status AsyncAppendReplicates(const std::vector<consensus::ReplicateRefPtr>& replicates,
const StatusCallback& callback);
// Append the given commit message, asynchronously.
@@ -489,7 +489,7 @@ class LogEntryBatch {
return entry_batch_pb_->entry(idx).replicate().id();
}
- void SetReplicates(const vector<consensus::ReplicateRefPtr>& replicates) {
+ void SetReplicates(const std::vector<consensus::ReplicateRefPtr>& replicates) {
replicates_ = replicates;
}
@@ -509,7 +509,7 @@ class LogEntryBatch {
// Used only when type is REPLICATE, this makes sure there's at
// least a reference to each replicate message until we're finished
// appending.
- vector<consensus::ReplicateRefPtr> replicates_;
+ std::vector<consensus::ReplicateRefPtr> replicates_;
// Callback to be invoked upon the entries being written and
// synced to disk.
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/log_anchor_registry-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_anchor_registry-test.cc b/src/kudu/consensus/log_anchor_registry-test.cc
index 817fe0b..f6d255c 100644
--- a/src/kudu/consensus/log_anchor_registry-test.cc
+++ b/src/kudu/consensus/log_anchor_registry-test.cc
@@ -23,6 +23,7 @@
#include "kudu/gutil/strings/substitute.h"
#include "kudu/util/test_util.h"
+using std::string;
using strings::Substitute;
namespace kudu {
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/log_cache-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_cache-test.cc b/src/kudu/consensus/log_cache-test.cc
index 12910fe..3ac9dcd 100644
--- a/src/kudu/consensus/log_cache-test.cc
+++ b/src/kudu/consensus/log_cache-test.cc
@@ -32,6 +32,8 @@
#include "kudu/util/test_util.h"
using std::shared_ptr;
+using std::vector;
+using strings::Substitute;
DECLARE_int32(log_cache_size_limit_mb);
DECLARE_int32(global_log_cache_size_limit_mb);
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/log_cache.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_cache.cc b/src/kudu/consensus/log_cache.cc
index a7088c9..285d7e7 100644
--- a/src/kudu/consensus/log_cache.cc
+++ b/src/kudu/consensus/log_cache.cc
@@ -53,6 +53,8 @@ DEFINE_int32(global_log_cache_size_limit_mb, 1024,
"caching log entries across all tablets is kept under this threshold.");
TAG_FLAG(global_log_cache_size_limit_mb, advanced);
+using std::string;
+using std::vector;
using strings::Substitute;
namespace kudu {
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/log_index.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_index.cc b/src/kudu/consensus/log_index.cc
index 9cd0ce3..e3d743f 100644
--- a/src/kudu/consensus/log_index.cc
+++ b/src/kudu/consensus/log_index.cc
@@ -45,6 +45,7 @@
#include "kudu/util/locks.h"
using std::string;
+using std::vector;
using strings::Substitute;
#define RETRY_ON_EINTR(ret, expr) do { \
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/log_reader.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_reader.cc b/src/kudu/consensus/log_reader.cc
index e8262d4..3c676ef 100644
--- a/src/kudu/consensus/log_reader.cc
+++ b/src/kudu/consensus/log_reader.cc
@@ -61,6 +61,8 @@ struct LogSegmentSeqnoComparator {
using consensus::OpId;
using consensus::ReplicateMsg;
using std::shared_ptr;
+using std::string;
+using std::vector;
using strings::Substitute;
const int64_t LogReader::kNoSizeLimit = -1;
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/log_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_util.cc b/src/kudu/consensus/log_util.cc
index bf20545..497e22e 100644
--- a/src/kudu/consensus/log_util.cc
+++ b/src/kudu/consensus/log_util.cc
@@ -69,8 +69,9 @@ namespace kudu {
namespace log {
using consensus::OpId;
-using std::vector;
+using std::string;
using std::shared_ptr;
+using std::vector;
using std::unique_ptr;
using strings::Substitute;
using strings::SubstituteAndAppend;
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/mt-log-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/mt-log-test.cc b/src/kudu/consensus/mt-log-test.cc
index d925fb4..133a895 100644
--- a/src/kudu/consensus/mt-log-test.cc
+++ b/src/kudu/consensus/mt-log-test.cc
@@ -46,7 +46,10 @@ namespace log {
using std::shared_ptr;
using std::vector;
+using consensus::OpId;
using consensus::ReplicateRefPtr;
+using consensus::ReplicateMsg;
+using consensus::WRITE_OP;
using consensus::make_scoped_refptr_replicate;
namespace {
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/quorum_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/quorum_util.cc b/src/kudu/consensus/quorum_util.cc
index d4b39f4..d462082 100644
--- a/src/kudu/consensus/quorum_util.cc
+++ b/src/kudu/consensus/quorum_util.cc
@@ -28,15 +28,16 @@
#include "kudu/util/pb_util.h"
#include "kudu/util/status.h"
-namespace kudu {
-namespace consensus {
-
using google::protobuf::RepeatedPtrField;
using std::map;
using std::pair;
using std::string;
+using std::vector;
using strings::Substitute;
+namespace kudu {
+namespace consensus {
+
bool IsRaftConfigMember(const std::string& uuid, const RaftConfigPB& config) {
for (const RaftPeerPB& peer : config.peers()) {
if (peer.permanent_uuid() == uuid) {
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/raft_consensus.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus.cc b/src/kudu/consensus/raft_consensus.cc
index cefe569..66339bf 100644
--- a/src/kudu/consensus/raft_consensus.cc
+++ b/src/kudu/consensus/raft_consensus.cc
@@ -125,6 +125,8 @@ METRIC_DEFINE_gauge_int64(tablet, raft_term,
"Current Term of the Raft Consensus algorithm. This number increments "
"each time a leader election is started.");
+using std::string;
+
namespace {
// Return the mean interval at which to check for failures of the
@@ -1665,7 +1667,7 @@ Status RaftConsensus::UnsafeChangeConfig(const UnsafeChangeConfigRequestPB& req,
// addresses of each server (since we can get the address information from
// the committed config). Additionally, only a subset of the committed config
// is required for typical cluster repair scenarios.
- unordered_set<string> retained_peer_uuids;
+ std::unordered_set<string> retained_peer_uuids;
const RaftConfigPB& config = req.new_config();
for (const RaftPeerPB& new_peer : config.peers()) {
const string& peer_uuid = new_peer.permanent_uuid();
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/raft_consensus_quorum-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus_quorum-test.cc b/src/kudu/consensus/raft_consensus_quorum-test.cc
index 6bddb5e..0350b94 100644
--- a/src/kudu/consensus/raft_consensus_quorum-test.cc
+++ b/src/kudu/consensus/raft_consensus_quorum-test.cc
@@ -55,7 +55,9 @@ METRIC_DECLARE_entity(tablet);
ASSERT_NO_FATAL_FAILURE(ReplicateSequenceOfMessages(a, b, c, d, e, f, g))
using std::shared_ptr;
+using std::string;
using std::unique_ptr;
+using std::vector;
namespace kudu {
@@ -479,9 +481,7 @@ class RaftConsensusQuorumTest : public KuduTest {
}
void VerifyNoCommitsBeforeReplicates(const vector<LogEntryPB*>& entries) {
- unordered_set<OpId,
- OpIdHashFunctor,
- OpIdEqualsFunctor> replication_ops;
+ std::unordered_set<OpId, OpIdHashFunctor, OpIdEqualsFunctor> replication_ops;
for (const LogEntryPB* entry : entries) {
if (entry->has_replicate()) {
@@ -567,7 +567,7 @@ class RaftConsensusQuorumTest : public KuduTest {
MetricRegistry metric_registry_;
scoped_refptr<MetricEntity> metric_entity_;
const Schema schema_;
- unordered_map<ConsensusRound*, Synchronizer*> syncs_;
+ std::unordered_map<ConsensusRound*, Synchronizer*> syncs_;
};
// Tests Replicate/Commit a single message through the leader.
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/time_manager-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/time_manager-test.cc b/src/kudu/consensus/time_manager-test.cc
index 2aeb212..5bed655 100644
--- a/src/kudu/consensus/time_manager-test.cc
+++ b/src/kudu/consensus/time_manager-test.cc
@@ -65,8 +65,8 @@ class TimeManagerTest : public KuduTest {
scoped_refptr<clock::HybridClock> clock_;
scoped_refptr<TimeManager> time_manager_;
- vector<unique_ptr<CountDownLatch>> latches_;
- vector<std::thread> threads_;
+ std::vector<unique_ptr<CountDownLatch>> latches_;
+ std::vector<std::thread> threads_;
};
// Tests TimeManager's functionality in non-leader mode and the transition to leader mode.
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/consensus/time_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/time_manager.cc b/src/kudu/consensus/time_manager.cc
index b1f1482..c9444cb 100644
--- a/src/kudu/consensus/time_manager.cc
+++ b/src/kudu/consensus/time_manager.cc
@@ -42,12 +42,13 @@ TAG_FLAG(safe_time_max_lag_ms, experimental);
DECLARE_int32(raft_heartbeat_interval_ms);
DECLARE_int32(scanner_max_wait_ms);
+using kudu::clock::Clock;
+using std::string;
+using strings::Substitute;
+
namespace kudu {
namespace consensus {
-using clock::Clock;
-using strings::Substitute;
-
typedef std::lock_guard<simple_spinlock> Lock;
ExternalConsistencyMode TimeManager::GetMessageConsistencyMode(const ReplicateMsg& message) {
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/fs/block_manager.h
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager.h b/src/kudu/fs/block_manager.h
index c3bfc89..1e9ed47 100644
--- a/src/kudu/fs/block_manager.h
+++ b/src/kudu/fs/block_manager.h
@@ -160,7 +160,7 @@ class ReadableBlock : public Block {
// beginning from 'offset' in the block, returning an error if fewer bytes exist.
// Sets each "result" to the data that was read.
// If an error was encountered, returns a non-OK status.
- virtual Status ReadV(uint64_t offset, vector<Slice>* results) const = 0;
+ virtual Status ReadV(uint64_t offset, std::vector<Slice>* results) const = 0;
// Returns the memory usage of this object including the object itself.
virtual size_t memory_footprint() const = 0;
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/fs/data_dirs.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/data_dirs.cc b/src/kudu/fs/data_dirs.cc
index 5596b22..2fbec20 100644
--- a/src/kudu/fs/data_dirs.cc
+++ b/src/kudu/fs/data_dirs.cc
@@ -102,6 +102,7 @@ using internal::DataDirGroup;
using std::default_random_engine;
using std::deque;
using std::iota;
+using std::set;
using std::shuffle;
using std::string;
using std::unique_ptr;
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/fs/data_dirs.h
----------------------------------------------------------------------
diff --git a/src/kudu/fs/data_dirs.h b/src/kudu/fs/data_dirs.h
index 817f1a0..5cb17cc 100644
--- a/src/kudu/fs/data_dirs.h
+++ b/src/kudu/fs/data_dirs.h
@@ -286,7 +286,7 @@ class DataDirManager {
// Adds 'uuid_idx' to the set of failed data directories. This directory will
// no longer be used. Logs an error message prefixed with 'error_message'
// describing what directories are affected.
- void MarkDataDirFailed(uint16_t uuid_idx, const string& error_message = "");
+ void MarkDataDirFailed(uint16_t uuid_idx, const std::string& error_message = "");
// Returns whether or not the 'uuid_idx' refers to a failed directory.
bool IsDataDirFailed(uint16_t uuid_idx) const;
@@ -315,12 +315,12 @@ class DataDirManager {
// added. Although this function does not itself change DataDirManager state,
// its expected usage warrants that it is called within the scope of a
// lock_guard of dir_group_lock_.
- Status GetDirsForGroupUnlocked(int target_size, vector<uint16_t>* group_indices);
+ Status GetDirsForGroupUnlocked(int target_size, std::vector<uint16_t>* group_indices);
// Goes through the data dirs in 'uuid_indices' and populates
// 'healthy_indices' with those that haven't failed.
- void RemoveUnhealthyDataDirsUnlocked(const vector<uint16_t>& uuid_indices,
- vector<uint16_t>* healthy_indices) const;
+ void RemoveUnhealthyDataDirsUnlocked(const std::vector<uint16_t>& uuid_indices,
+ std::vector<uint16_t>* healthy_indices) const;
Env* env_;
const std::string block_manager_type_;
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/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 7f741af..1391698 100644
--- a/src/kudu/fs/fs-test-util.h
+++ b/src/kudu/fs/fs-test-util.h
@@ -64,7 +64,7 @@ class CountingReadableBlock : public ReadableBlock {
}
virtual Status Read(uint64_t offset, Slice* result) const OVERRIDE {
- vector<Slice> results = { *result };
+ std::vector<Slice> results = { *result };
return ReadV(offset, &results);
}
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/fs/fs_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/fs_manager.cc b/src/kudu/fs/fs_manager.cc
index 0c43706..ac3e15a 100644
--- a/src/kudu/fs/fs_manager.cc
+++ b/src/kudu/fs/fs_manager.cc
@@ -90,6 +90,8 @@ using kudu::fs::LogBlockManager;
using kudu::fs::ReadableBlock;
using kudu::fs::WritableBlock;
using std::map;
+using std::ostream;
+using std::set;
using std::stack;
using std::string;
using std::unique_ptr;
@@ -305,7 +307,7 @@ Status FsManager::CreateInitialFileSystemLayout(boost::optional<string> uuid) {
// subdirectories.
//
// In the event of failure, delete everything we created.
- deque<ScopedFileDeleter*> delete_on_failure;
+ std::deque<ScopedFileDeleter*> delete_on_failure;
ElementDeleter d(&delete_on_failure);
InstanceMetadataPB metadata;
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/gutil/int128.h
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/int128.h b/src/kudu/gutil/int128.h
index 2a19cca..4512672 100644
--- a/src/kudu/gutil/int128.h
+++ b/src/kudu/gutil/int128.h
@@ -6,7 +6,6 @@
#define BASE_INT128_H_
#include <iosfwd>
-using std::ostream;
#include "kudu/gutil/integral_types.h"
struct uint128_pod;
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/gutil/map-util.h
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/map-util.h b/src/kudu/gutil/map-util.h
index 6fffedf..9883c1d 100644
--- a/src/kudu/gutil/map-util.h
+++ b/src/kudu/gutil/map-util.h
@@ -63,13 +63,8 @@
#define UTIL_GTL_MAP_UTIL_H_
#include <stddef.h>
-#include <string>
-using std::string;
#include <utility>
-using std::make_pair;
-using std::pair;
#include <vector>
-using std::vector;
#include <glog/logging.h>
@@ -305,7 +300,7 @@ bool ContainsKeyValuePair(const Collection& collection,
const Key& key,
const Value& value) {
typedef typename Collection::const_iterator const_iterator;
- pair<const_iterator, const_iterator> range = collection.equal_range(key);
+ std::pair<const_iterator, const_iterator> range = collection.equal_range(key);
for (const_iterator it = range.first; it != range.second; ++it) {
if (it->second == value) {
return true;
@@ -324,7 +319,7 @@ bool ContainsKeyValuePair(const Collection& collection,
template <class Collection>
bool InsertOrUpdate(Collection* const collection,
const typename Collection::value_type& vt) {
- pair<typename Collection::iterator, bool> ret = collection->insert(vt);
+ std::pair<typename Collection::iterator, bool> ret = collection->insert(vt);
if (!ret.second) {
// update
ret.first->second = vt.second;
@@ -361,7 +356,7 @@ bool InsertAndDeleteExisting(
Collection* const collection,
const typename Collection::key_type& key,
const typename Collection::mapped_type& value) {
- pair<typename Collection::iterator, bool> ret =
+ std::pair<typename Collection::iterator, bool> ret =
collection->insert(typename Collection::value_type(key, value));
if (!ret.second) {
delete ret.first->second;
@@ -435,7 +430,7 @@ typename Collection::mapped_type& InsertKeyOrDie(
Collection* const collection,
const typename Collection::key_type& key) {
typedef typename Collection::value_type value_type;
- pair<typename Collection::iterator, bool> res =
+ std::pair<typename Collection::iterator, bool> res =
collection->insert(value_type(key, typename Collection::mapped_type()));
CHECK(res.second) << "duplicate key: " << key;
return res.first->second;
@@ -511,7 +506,7 @@ template <class Collection>
typename Collection::mapped_type&
LookupOrInsertNew(Collection* const collection,
const typename Collection::key_type& key) {
- pair<typename Collection::iterator, bool> ret =
+ std::pair<typename Collection::iterator, bool> ret =
collection->insert(
typename Collection::value_type(key,
static_cast<typename Collection::mapped_type>(NULL)));
@@ -530,7 +525,7 @@ typename Collection::mapped_type&
LookupOrInsertNew(Collection* const collection,
const typename Collection::key_type& key,
const Arg& arg) {
- pair<typename Collection::iterator, bool> ret =
+ std::pair<typename Collection::iterator, bool> ret =
collection->insert(
typename Collection::value_type(
key,
@@ -563,7 +558,7 @@ LookupOrInsertNewSharedPtr(
const typename Collection::key_type& key) {
typedef typename Collection::mapped_type SharedPtr;
typedef typename Collection::mapped_type::element_type Element;
- pair<typename Collection::iterator, bool> ret =
+ std::pair<typename Collection::iterator, bool> ret =
collection->insert(typename Collection::value_type(key, SharedPtr()));
if (ret.second) {
ret.first->second.reset(new Element());
@@ -584,7 +579,7 @@ LookupOrInsertNewSharedPtr(
const Arg& arg) {
typedef typename Collection::mapped_type SharedPtr;
typedef typename Collection::mapped_type::element_type Element;
- pair<typename Collection::iterator, bool> ret =
+ std::pair<typename Collection::iterator, bool> ret =
collection->insert(typename Collection::value_type(key, SharedPtr()));
if (ret.second) {
ret.first->second.reset(new Element(arg));
@@ -608,7 +603,7 @@ bool UpdateReturnCopy(Collection* const collection,
const typename Collection::key_type& key,
const typename Collection::mapped_type& value,
typename Collection::mapped_type* previous) {
- pair<typename Collection::iterator, bool> ret =
+ std::pair<typename Collection::iterator, bool> ret =
collection->insert(typename Collection::value_type(key, value));
if (!ret.second) {
// update
@@ -626,7 +621,7 @@ template <class Collection>
bool UpdateReturnCopy(Collection* const collection,
const typename Collection::value_type& vt,
typename Collection::mapped_type* previous) {
- pair<typename Collection::iterator, bool> ret =
+ std::pair<typename Collection::iterator, bool> ret =
collection->insert(vt);
if (!ret.second) {
// update
@@ -650,7 +645,7 @@ template <class Collection>
typename Collection::mapped_type* const
InsertOrReturnExisting(Collection* const collection,
const typename Collection::value_type& vt) {
- pair<typename Collection::iterator, bool> ret = collection->insert(vt);
+ std::pair<typename Collection::iterator, bool> ret = collection->insert(vt);
if (ret.second) {
return NULL; // Inserted, no existing previous value.
} else {
@@ -750,7 +745,7 @@ void AppendKeysFromMap(const MapContainer& map_container,
// without the complexity of a SFINAE-based solution.)
template <class MapContainer, class KeyType>
void AppendKeysFromMap(const MapContainer& map_container,
- vector<KeyType>* key_container) {
+ std::vector<KeyType>* key_container) {
CHECK(key_container != NULL);
// We now have the opportunity to call reserve(). Calling reserve() every
// time is a bad idea for some use cases: libstdc++'s implementation of
@@ -794,7 +789,7 @@ void AppendValuesFromMap(const MapContainer& map_container,
// without the complexity of a SFINAE-based solution.)
template <class MapContainer, class ValueType>
void AppendValuesFromMap(const MapContainer& map_container,
- vector<ValueType>* value_container) {
+ std::vector<ValueType>* value_container) {
CHECK(value_container != NULL);
// See AppendKeysFromMap for why this is done.
if (value_container->empty()) {
@@ -826,18 +821,19 @@ void AppendValuesFromMap(const MapContainer& map_container,
// if (result.second) ....
//
template <class MapContainer, typename Function>
-pair<typename MapContainer::mapped_type* const, bool>
+std::pair<typename MapContainer::mapped_type* const, bool>
ComputeIfAbsentReturnAbsense(MapContainer* container,
const typename MapContainer::key_type& key,
Function compute_func) {
typename MapContainer::iterator iter = container->find(key);
bool new_value = iter == container->end();
if (new_value) {
- pair<typename MapContainer::iterator, bool> result = container->emplace(key, compute_func());
+ std::pair<typename MapContainer::iterator, bool> result =
+ container->emplace(key, compute_func());
DCHECK(result.second) << "duplicate key: " << key;
iter = result.first;
}
- return make_pair(&iter->second, new_value);
+ return std::make_pair(&iter->second, new_value);
};
// Like the above but doesn't return a pair, just returns a pointer to the value.
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/gutil/stl_util.h
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/stl_util.h b/src/kudu/gutil/stl_util.h
index 60cb587..9e7cfb3 100644
--- a/src/kudu/gutil/stl_util.h
+++ b/src/kudu/gutil/stl_util.h
@@ -31,26 +31,13 @@
#include <stddef.h>
#include <string.h> // for memcpy
#include <algorithm>
-using std::copy;
-using std::max;
-using std::min;
-using std::reverse;
-using std::sort;
-using std::swap;
#include <cassert>
#include <deque>
-using std::deque;
#include <functional>
-using std::binary_function;
-using std::less;
#include <iterator>
-using std::back_insert_iterator;
-using std::iterator_traits;
#include <memory>
#include <string>
-using std::string;
#include <vector>
-using std::vector;
#include "kudu/gutil/integral_types.h"
#include "kudu/gutil/macros.h"
@@ -59,7 +46,7 @@ using std::vector;
// Sort and remove duplicates of an STL vector or deque.
template<class T>
void STLSortAndRemoveDuplicates(T *v) {
- sort(v->begin(), v->end());
+ std::sort(v->begin(), v->end());
v->erase(unique(v->begin(), v->end()), v->end());
}
@@ -77,8 +64,8 @@ template<class T> void STLClearObject(T* obj) {
// Specialization for deque. Same as STLClearObject but doesn't call reserve
// since deque doesn't have reserve.
template <class T, class A>
-void STLClearObject(deque<T, A>* obj) {
- deque<T, A> tmp;
+void STLClearObject(std::deque<T, A>* obj) {
+ std::deque<T, A> tmp;
tmp.swap(*obj);
}
@@ -94,7 +81,7 @@ template <class T> inline void STLClearIfBig(T* obj, size_t limit = 1<<20) {
// Specialization for deque, which doesn't implement capacity().
template <class T, class A>
-inline void STLClearIfBig(deque<T, A>* obj, size_t limit = 1<<20) {
+inline void STLClearIfBig(std::deque<T, A>* obj, size_t limit = 1<<20) {
if (obj->size() >= limit) {
STLClearObject(obj);
} else {
@@ -214,7 +201,7 @@ void STLDeleteContainerPairSecondPointers(ForwardIterator begin,
}
template<typename T>
-inline void STLAssignToVector(vector<T>* vec,
+inline void STLAssignToVector(std::vector<T>* vec,
const T* ptr,
size_t n) {
vec->resize(n);
@@ -225,7 +212,7 @@ inline void STLAssignToVector(vector<T>* vec,
// Not faster; but we need the specialization so the function works at all
// on the vector<bool> specialization.
template<>
-inline void STLAssignToVector(vector<bool>* vec,
+inline void STLAssignToVector(std::vector<bool>* vec,
const bool* ptr,
size_t n) {
vec->clear();
@@ -242,7 +229,7 @@ inline void STLAssignToVector(vector<bool>* vec,
// STLAssignToVectorChar(&vec, ptr, size);
// STLAssignToString(&str, ptr, size);
-inline void STLAssignToVectorChar(vector<char>* vec,
+inline void STLAssignToVectorChar(std::vector<char>* vec,
const char* ptr,
size_t n) {
STLAssignToVector(vec, ptr, n);
@@ -266,7 +253,7 @@ struct InternalStringRepGCC4 {
// "*str" as a result of resizing may be left uninitialized, rather
// than being filled with '0' bytes. Typically used when code is then
// going to overwrite the backing store of the string with known data.
-inline void STLStringResizeUninitialized(string* s, size_t new_size) {
+inline void STLStringResizeUninitialized(std::string* s, size_t new_size) {
if (sizeof(*s) == sizeof(InternalStringRepGCC4)) {
if (new_size > s->capacity()) {
s->reserve(new_size);
@@ -291,17 +278,17 @@ inline void STLStringResizeUninitialized(string* s, size_t new_size) {
// Returns true if the string implementation supports a resize where
// the new characters added to the string are left untouched.
-inline bool STLStringSupportsNontrashingResize(const string& s) {
+inline bool STLStringSupportsNontrashingResize(const std::string& s) {
return (sizeof(s) == sizeof(InternalStringRepGCC4));
}
-inline void STLAssignToString(string* str, const char* ptr, size_t n) {
+inline void STLAssignToString(std::string* str, const char* ptr, size_t n) {
STLStringResizeUninitialized(str, n);
if (n == 0) return;
memcpy(&*str->begin(), ptr, n);
}
-inline void STLAppendToString(string* str, const char* ptr, size_t n) {
+inline void STLAppendToString(std::string* str, const char* ptr, size_t n) {
if (n == 0) return;
size_t old_size = str->size();
STLStringResizeUninitialized(str, old_size + n);
@@ -318,7 +305,7 @@ inline void STLAppendToString(string* str, const char* ptr, size_t n) {
// change this as well.
template<typename T, typename Allocator>
-inline T* vector_as_array(vector<T, Allocator>* v) {
+inline T* vector_as_array(std::vector<T, Allocator>* v) {
# ifdef NDEBUG
return &*v->begin();
# else
@@ -327,7 +314,7 @@ inline T* vector_as_array(vector<T, Allocator>* v) {
}
template<typename T, typename Allocator>
-inline const T* vector_as_array(const vector<T, Allocator>* v) {
+inline const T* vector_as_array(const std::vector<T, Allocator>* v) {
# ifdef NDEBUG
return &*v->begin();
# else
@@ -347,7 +334,7 @@ inline const T* vector_as_array(const vector<T, Allocator>* v) {
// contiguous is officially part of the C++11 standard [string.require]/5.
// According to Matt Austern, this should already work on all current C++98
// implementations.
-inline char* string_as_array(string* str) {
+inline char* string_as_array(std::string* str) {
// DO NOT USE const_cast<char*>(str->data())! See the unittest for why.
return str->empty() ? NULL : &*str->begin();
}
@@ -804,9 +791,9 @@ BinaryOperateOnSecond<Pair, BinaryOp> BinaryOperate2nd(const BinaryOp& f) {
// F has to be a model of AdaptableBinaryFunction.
// G1 and G2 have to be models of AdabtableUnaryFunction.
template<typename F, typename G1, typename G2>
-class BinaryComposeBinary : public binary_function<typename G1::argument_type,
- typename G2::argument_type,
- typename F::result_type> {
+class BinaryComposeBinary : public std::binary_function<typename G1::argument_type,
+ typename G2::argument_type,
+ typename F::result_type> {
public:
BinaryComposeBinary(F f, G1 g1, G2 g2) : f_(f), g1_(g1), g2_(g2) { }
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/gutil/stringprintf.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/stringprintf.cc b/src/kudu/gutil/stringprintf.cc
index 112605c..45a0cde 100644
--- a/src/kudu/gutil/stringprintf.cc
+++ b/src/kudu/gutil/stringprintf.cc
@@ -6,11 +6,13 @@
#include <stdarg.h> // For va_list and related operations
#include <stdio.h> // MSVC requires this for _vsnprintf
#include <vector>
-using std::vector;
#include <glog/logging.h>
#include "kudu/gutil/logging-inl.h"
#include "kudu/gutil/macros.h"
+using std::string;
+using std::vector;
+
#ifdef _MSC_VER
enum { IS__MSC_VER = 1 };
#else
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/gutil/stringprintf.h
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/stringprintf.h b/src/kudu/gutil/stringprintf.h
index 2083574..0343834 100644
--- a/src/kudu/gutil/stringprintf.h
+++ b/src/kudu/gutil/stringprintf.h
@@ -12,30 +12,28 @@
#include <stdarg.h>
#include <string>
-using std::string;
#include <vector>
-using std::vector;
#include "kudu/gutil/port.h"
// Return a C++ string
-extern string StringPrintf(const char* format, ...)
+extern std::string StringPrintf(const char* format, ...)
// Tell the compiler to do printf format string checking.
PRINTF_ATTRIBUTE(1,2);
// Store result into a supplied string and return it
-extern const string& SStringPrintf(string* dst, const char* format, ...)
+extern const std::string& SStringPrintf(std::string* dst, const char* format, ...)
// Tell the compiler to do printf format string checking.
PRINTF_ATTRIBUTE(2,3);
// Append result to a supplied string
-extern void StringAppendF(string* dst, const char* format, ...)
+extern void StringAppendF(std::string* dst, const char* format, ...)
// Tell the compiler to do printf format string checking.
PRINTF_ATTRIBUTE(2,3);
// Lower-level routine that takes a va_list and appends to a specified
// string. All other routines are just convenience wrappers around it.
-extern void StringAppendV(string* dst, const char* format, va_list ap);
+extern void StringAppendV(std::string* dst, const char* format, va_list ap);
// The max arguments supported by StringPrintfVector
extern const int kStringPrintfVectorMaxArgs;
@@ -43,6 +41,6 @@ extern const int kStringPrintfVectorMaxArgs;
// You can use this version when all your arguments are strings, but
// you don't know how many arguments you'll have at compile time.
// StringPrintfVector will LOG(FATAL) if v.size() > kStringPrintfVectorMaxArgs
-extern string StringPrintfVector(const char* format, const vector<string>& v);
+extern std::string StringPrintfVector(const char* format, const std::vector<std::string>& v);
#endif /* _BASE_STRINGPRINTF_H */
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/gutil/strings/escaping.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/escaping.cc b/src/kudu/gutil/strings/escaping.cc
index 7b03335..4128b92 100644
--- a/src/kudu/gutil/strings/escaping.cc
+++ b/src/kudu/gutil/strings/escaping.cc
@@ -8,9 +8,7 @@
#include <string.h>
#include <limits>
-using std::numeric_limits;
#include <vector>
-using std::vector;
#include "kudu/gutil/integral_types.h"
#include "kudu/gutil/port.h"
@@ -20,6 +18,10 @@ using std::vector;
#include "kudu/gutil/charmap.h"
#include "kudu/gutil/stl_util.h"
+using std::numeric_limits;
+using std::string;
+using std::vector;
+
namespace strings {
// These are used for the leave_nulls_escaped argument to CUnescapeInternal().
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/gutil/strings/escaping.h
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/escaping.h b/src/kudu/gutil/strings/escaping.h
index 19e0860..b94001b 100644
--- a/src/kudu/gutil/strings/escaping.h
+++ b/src/kudu/gutil/strings/escaping.h
@@ -23,9 +23,7 @@
#include <stddef.h>
#include <string>
-using std::string;
#include <vector>
-using std::vector;
#include <glog/logging.h>
@@ -85,7 +83,7 @@ int EscapeStrForCSV(const char* src, char* dest, int dest_len);
// ----------------------------------------------------------------------
int UnescapeCEscapeSequences(const char* source, char* dest);
int UnescapeCEscapeSequences(const char* source, char* dest,
- vector<string>* errors);
+ std::vector<std::string>* errors);
// ----------------------------------------------------------------------
// UnescapeCEscapeString()
@@ -103,10 +101,10 @@ int UnescapeCEscapeSequences(const char* source, char* dest,
//
// *** DEPRECATED: Use CUnescape() in new code ***
// ----------------------------------------------------------------------
-int UnescapeCEscapeString(const string& src, string* dest);
-int UnescapeCEscapeString(const string& src, string* dest,
- vector<string>* errors);
-string UnescapeCEscapeString(const string& src);
+int UnescapeCEscapeString(const std::string& src, std::string* dest);
+int UnescapeCEscapeString(const std::string& src, std::string* dest,
+ std::vector<std::string>* errors);
+std::string UnescapeCEscapeString(const std::string& src);
// ----------------------------------------------------------------------
// CUnescape()
@@ -139,12 +137,12 @@ string UnescapeCEscapeString(const string& src);
// 'error'. To disable error reporting, set 'error' to NULL.
// ----------------------------------------------------------------------
bool CUnescape(const StringPiece& source, char* dest, int* dest_len,
- string* error);
+ std::string* error);
-bool CUnescape(const StringPiece& source, string* dest, string* error);
+bool CUnescape(const StringPiece& source, std::string* dest, std::string* error);
// A version with no error reporting.
-inline bool CUnescape(const StringPiece& source, string* dest) {
+inline bool CUnescape(const StringPiece& source, std::string* dest) {
return CUnescape(source, dest, NULL);
}
@@ -163,15 +161,15 @@ inline bool CUnescape(const StringPiece& source, string* dest) {
bool CUnescapeForNullTerminatedString(const StringPiece& source,
char* dest,
int* dest_len,
- string* error);
+ std::string* error);
bool CUnescapeForNullTerminatedString(const StringPiece& source,
- string* dest,
- string* error);
+ std::string* dest,
+ std::string* error);
// A version with no error reporting.
inline bool CUnescapeForNullTerminatedString(const StringPiece& source,
- string* dest) {
+ std::string* dest) {
return CUnescapeForNullTerminatedString(source, dest, NULL);
}
@@ -207,10 +205,10 @@ int Utf8SafeCHexEscapeString(const char* src, int src_len, char* dest,
// allocation. However, it is much more convenient to use in
// non-speed-critical code like logging messages etc.
// ----------------------------------------------------------------------
-string CEscape(const StringPiece& src);
-string CHexEscape(const StringPiece& src);
-string Utf8SafeCEscape(const StringPiece& src);
-string Utf8SafeCHexEscape(const StringPiece& src);
+std::string CEscape(const StringPiece& src);
+std::string CHexEscape(const StringPiece& src);
+std::string Utf8SafeCEscape(const StringPiece& src);
+std::string Utf8SafeCHexEscape(const StringPiece& src);
// ----------------------------------------------------------------------
// BackslashEscape()
@@ -233,21 +231,21 @@ string Utf8SafeCHexEscape(const StringPiece& src);
// ----------------------------------------------------------------------
void BackslashEscape(const StringPiece& src,
const strings::CharSet& to_escape,
- string* dest);
+ std::string* dest);
void BackslashUnescape(const StringPiece& src,
const strings::CharSet& to_unescape,
- string* dest);
+ std::string* dest);
-inline string BackslashEscape(const StringPiece& src,
+inline std::string BackslashEscape(const StringPiece& src,
const strings::CharSet& to_escape) {
- string s;
+ std::string s;
BackslashEscape(src, to_escape, &s);
return s;
}
-inline string BackslashUnescape(const StringPiece& src,
+inline std::string BackslashUnescape(const StringPiece& src,
const strings::CharSet& to_unescape) {
- string s;
+ std::string s;
BackslashUnescape(src, to_unescape, &s);
return s;
}
@@ -311,14 +309,14 @@ int QEncodingUnescape(const char* src, int slen, char* dest, int szdest);
// these versions src and dest must be different strings.
// ----------------------------------------------------------------------
int Base64Unescape(const char* src, int slen, char* dest, int szdest);
-bool Base64Unescape(const char* src, int slen, string* dest);
-inline bool Base64Unescape(const string& src, string* dest) {
+bool Base64Unescape(const char* src, int slen, std::string* dest);
+inline bool Base64Unescape(const std::string& src, std::string* dest) {
return Base64Unescape(src.data(), src.size(), dest);
}
int WebSafeBase64Unescape(const char* src, int slen, char* dest, int szdest);
-bool WebSafeBase64Unescape(const char* src, int slen, string* dest);
-inline bool WebSafeBase64Unescape(const string& src, string* dest) {
+bool WebSafeBase64Unescape(const char* src, int slen, std::string* dest);
+inline bool WebSafeBase64Unescape(const std::string& src, std::string* dest) {
return WebSafeBase64Unescape(src.data(), src.size(), dest);
}
@@ -346,16 +344,16 @@ int Base64Escape(const unsigned char* src, int slen, char* dest, int szdest);
int WebSafeBase64Escape(const unsigned char* src, int slen, char* dest,
int szdest, bool do_padding);
// Encode src into dest with padding.
-void Base64Escape(const string& src, string* dest);
+void Base64Escape(const std::string& src, std::string* dest);
// Encode src into dest web-safely without padding.
-void WebSafeBase64Escape(const string& src, string* dest);
+void WebSafeBase64Escape(const std::string& src, std::string* dest);
// Encode src into dest web-safely with padding.
-void WebSafeBase64EscapeWithPadding(const string& src, string* dest);
+void WebSafeBase64EscapeWithPadding(const std::string& src, std::string* dest);
void Base64Escape(const unsigned char* src, int szsrc,
- string* dest, bool do_padding);
+ std::string* dest, bool do_padding);
void WebSafeBase64Escape(const unsigned char* src, int szsrc,
- string* dest, bool do_padding);
+ std::string* dest, bool do_padding);
// ----------------------------------------------------------------------
// Base32Unescape()
@@ -364,8 +362,8 @@ void WebSafeBase64Escape(const unsigned char* src, int szsrc,
// RETURNS the length of dest, or -1 if src contains invalid chars.
// ----------------------------------------------------------------------
int Base32Unescape(const char* src, int slen, char* dest, int szdest);
-bool Base32Unescape(const char* src, int slen, string* dest);
-inline bool Base32Unescape(const string& src, string* dest) {
+bool Base32Unescape(const char* src, int slen, std::string* dest);
+inline bool Base32Unescape(const std::string& src, std::string* dest) {
return Base32Unescape(src.data(), src.size(), dest);
}
@@ -381,7 +379,7 @@ inline bool Base32Unescape(const string& src, string* dest) {
// ----------------------------------------------------------------------
int Base32Escape(const unsigned char* src, size_t szsrc,
char* dest, size_t szdest);
-bool Base32Escape(const string& src, string* dest);
+bool Base32Escape(const std::string& src, std::string* dest);
// ----------------------------------------------------------------------
// Base32HexEscape()
@@ -396,7 +394,7 @@ bool Base32Escape(const string& src, string* dest);
// ----------------------------------------------------------------------
int Base32HexEscape(const unsigned char* src, size_t szsrc,
char* dest, size_t szdest);
-bool Base32HexEscape(const string& src, string* dest);
+bool Base32HexEscape(const std::string& src, std::string* dest);
// Return the length to use for the output buffer given to the base32 escape
// routines. This function may return incorrect results if given input_len
@@ -464,15 +462,15 @@ void FiveBytesToEightBase32Digits(const unsigned char* in_bytes, char* out);
//
// The versions that receive a string for the output will append to it.
// ----------------------------------------------------------------------
-void EscapeFileName(const StringPiece& src, string* dst);
-void UnescapeFileName(const StringPiece& src, string* dst);
-inline string EscapeFileName(const StringPiece& src) {
- string r;
+void EscapeFileName(const StringPiece& src, std::string* dst);
+void UnescapeFileName(const StringPiece& src, std::string* dst);
+inline std::string EscapeFileName(const StringPiece& src) {
+ std::string r;
EscapeFileName(src, &r);
return r;
}
-inline string UnescapeFileName(const StringPiece& src) {
- string r;
+inline std::string UnescapeFileName(const StringPiece& src) {
+ std::string r;
UnescapeFileName(src, &r);
return r;
}
@@ -510,8 +508,8 @@ inline int hex_digit_to_int(char c) {
// ----------------------------------------------------------------------
void a2b_hex(const char* from, unsigned char* to, int num);
void a2b_hex(const char* from, char* to, int num);
-void a2b_hex(const char* from, string* to, int num);
-string a2b_hex(const string& a);
+void a2b_hex(const char* from, std::string* to, int num);
+std::string a2b_hex(const std::string& a);
// ----------------------------------------------------------------------
// a2b_bin()
@@ -523,7 +521,7 @@ string a2b_hex(const string& a);
// multiple of 8.
// Return value: ceil(a.size()/8) bytes of binary data
// ----------------------------------------------------------------------
-string a2b_bin(const string& a, bool byte_order_msb);
+std::string a2b_bin(const std::string& a, bool byte_order_msb);
// ----------------------------------------------------------------------
// b2a_hex()
@@ -532,7 +530,7 @@ string a2b_bin(const string& a, bool byte_order_msb);
// Return value: 2*'num' characters of ascii text (via the 'to' argument)
// ----------------------------------------------------------------------
void b2a_hex(const unsigned char* from, char* to, int num);
-void b2a_hex(const unsigned char* from, string* to, int num);
+void b2a_hex(const unsigned char* from, std::string* to, int num);
// ----------------------------------------------------------------------
// b2a_hex()
@@ -540,8 +538,8 @@ void b2a_hex(const unsigned char* from, string* to, int num);
// 'num' bytes of binary to a 2*'num'-character hexadecimal representation
// Return value: 2*'num' characters of ascii string
// ----------------------------------------------------------------------
-string b2a_hex(const char* from, int num);
-string b2a_hex(const StringPiece& b);
+std::string b2a_hex(const char* from, int num);
+std::string b2a_hex(const StringPiece& b);
// ----------------------------------------------------------------------
// b2a_bin()
@@ -551,7 +549,7 @@ string b2a_hex(const StringPiece& b);
// first in the string if byte_order_msb is set.
// Return value: 8*b.size() characters of ascii text
// ----------------------------------------------------------------------
-string b2a_bin(const string& b, bool byte_order_msb);
+std::string b2a_bin(const std::string& b, bool byte_order_msb);
// ----------------------------------------------------------------------
// ShellEscape
@@ -563,13 +561,13 @@ string b2a_bin(const string& b, bool byte_order_msb);
// safe for Bourne shell syntax (i.e. sh, bash), but mileage may vary
// with other shells.
// ----------------------------------------------------------------------
-string ShellEscape(StringPiece src);
+std::string ShellEscape(StringPiece src);
// Runs ShellEscape() on the arguments, concatenates them with a space, and
// returns the resulting string.
template <class InputIterator>
-string ShellEscapeCommandLine(InputIterator begin, const InputIterator& end) {
- string result;
+std::string ShellEscapeCommandLine(InputIterator begin, const InputIterator& end) {
+ std::string result;
for (; begin != end; ++begin) {
if (!result.empty()) result.append(" ");
result.append(ShellEscape(*begin));
@@ -579,12 +577,12 @@ string ShellEscapeCommandLine(InputIterator begin, const InputIterator& end) {
// Reads at most bytes_to_read from binary_string and writes it to
// ascii_string in lower case hex.
-void ByteStringToAscii(const string& binary_string, int bytes_to_read,
- string* ascii_string);
+void ByteStringToAscii(const std::string& binary_string, int bytes_to_read,
+ std::string* ascii_string);
-inline string ByteStringToAscii(const string& binary_string,
+inline std::string ByteStringToAscii(const std::string& binary_string,
int bytes_to_read) {
- string result;
+ std::string result;
ByteStringToAscii(binary_string, bytes_to_read, &result);
return result;
}
@@ -594,7 +592,7 @@ inline string ByteStringToAscii(const string& binary_string,
// Empty input successfully converts to empty output.
// Returns false and may modify output if it is
// unable to parse the hex string.
-bool ByteStringFromAscii(const string& ascii_string, string* binary_string);
+bool ByteStringFromAscii(const std::string& ascii_string, std::string* binary_string);
// Clean up a multi-line string to conform to Unix line endings.
// Reads from src and appends to dst, so usually dst should be empty.
@@ -621,11 +619,11 @@ bool ByteStringFromAscii(const string& ascii_string, string* binary_string);
// This does not do the right thing for CRCRLF files created by
// broken programs that do another Unix->DOS conversion on files
// that are already in CRLF format.
-void CleanStringLineEndings(const string& src, string* dst,
+void CleanStringLineEndings(const std::string& src, std::string* dst,
bool auto_end_last_line);
// Same as above, but transforms the argument in place.
-void CleanStringLineEndings(string* str, bool auto_end_last_line);
+void CleanStringLineEndings(std::string* str, bool auto_end_last_line);
} // namespace strings
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/gutil/strings/human_readable.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/human_readable.cc b/src/kudu/gutil/strings/human_readable.cc
index fb3419a..2af0a35 100644
--- a/src/kudu/gutil/strings/human_readable.cc
+++ b/src/kudu/gutil/strings/human_readable.cc
@@ -11,6 +11,8 @@
#include "kudu/gutil/stringprintf.h"
#include "kudu/gutil/strings/strip.h"
+using std::string;
+
namespace {
template <typename T>
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/gutil/strings/human_readable.h
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/human_readable.h b/src/kudu/gutil/strings/human_readable.h
index e05b169..53207f6 100644
--- a/src/kudu/gutil/strings/human_readable.h
+++ b/src/kudu/gutil/strings/human_readable.h
@@ -7,10 +7,7 @@
#define STRINGS_HUMAN_READABLE_H__
#include <functional>
-using std::binary_function;
-using std::less;
#include <string>
-using std::string;
#include "kudu/gutil/basictypes.h"
#include "kudu/gutil/integral_types.h"
@@ -41,16 +38,16 @@ class HumanReadableNumBytes {
// e.g. 1000000 -> "976.6K".
// Note that calling these two functions in succession isn't a
// noop, since ToString() may round.
- static bool ToInt64(const string &str, int64 *num_bytes);
- static string ToString(int64 num_bytes);
+ static bool ToInt64(const std::string &str, int64 *num_bytes);
+ static std::string ToString(int64 num_bytes);
// Like ToString but without rounding. For example 1025 would return
// "1025B" rather than "1.0K". Uses the largest common denominator.
- static string ToStringWithoutRounding(int64 num_bytes);
+ static std::string ToStringWithoutRounding(int64 num_bytes);
- static bool ToDouble(const string &str, double *num_bytes);
+ static bool ToDouble(const std::string &str, double *num_bytes);
// Function overloading this with a function that takes an int64 is just
// asking for trouble.
- static string DoubleToString(double num_bytes);
+ static std::string DoubleToString(double num_bytes);
// TODO(user): Maybe change this class to use SIPrefix?
@@ -71,7 +68,7 @@ class HumanReadableNumBytes {
// 3.02P
// 0.007E
// ----------------------------------------------------------------------
- static bool LessThan(const string &a, const string &b);
+ static bool LessThan(const std::string &a, const std::string &b);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(HumanReadableNumBytes);
@@ -80,16 +77,16 @@ class HumanReadableNumBytes {
// See documentation at HumanReadableNumBytes::LessThan().
struct humanreadablebytes_less
- : public binary_function<const string&, const string&, bool> {
- bool operator()(const string& a, const string &b) const {
+ : public std::binary_function<const std::string&, const std::string&, bool> {
+ bool operator()(const std::string& a, const std::string &b) const {
return HumanReadableNumBytes::LessThan(a, b);
}
};
// See documentation at HumanReadableNumBytes::LessThan().
struct humanreadablebytes_greater
- : public binary_function<const string&, const string&, bool> {
- bool operator()(const string& a, const string &b) const {
+ : public std::binary_function<const std::string&, const std::string&, bool> {
+ bool operator()(const std::string& a, const std::string &b) const {
return HumanReadableNumBytes::LessThan(b, a);
}
};
@@ -99,11 +96,11 @@ class HumanReadableInt {
// Similar to HumanReadableNumBytes::ToInt64(), but uses decimal
// rather than binary expansions - so M = 1 million, B = 1 billion,
// etc. Numbers beyond 1T are expressed as "3E14" etc.
- static string ToString(int64 value);
+ static std::string ToString(int64 value);
// Reverses ToString(). Note that calling these two functions in
// succession isn't a noop, since ToString() may round.
- static bool ToInt64(const string &str, int64 *value);
+ static bool ToInt64(const std::string &str, int64 *value);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(HumanReadableInt);
@@ -112,16 +109,16 @@ class HumanReadableInt {
class HumanReadableNum {
public:
// Same as HumanReadableInt::ToString().
- static string ToString(int64 value);
+ static std::string ToString(int64 value);
// Similar to HumanReadableInt::ToString(), but prints 2 decimal
// places for numbers with absolute value < 10.0 and 1 decimal place
// for numbers >= 10.0 and < 100.0.
- static string DoubleToString(double value);
+ static std::string DoubleToString(double value);
// Reverses DoubleToString(). Note that calling these two functions in
// succession isn't a noop, since there may be rounding errors.
- static bool ToDouble(const string &str, double *value);
+ static bool ToDouble(const std::string &str, double *value);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(HumanReadableNum);
@@ -136,7 +133,7 @@ class HumanReadableElapsedTime {
// 933120.0 -> "10.8 days"
// 39420000.0 -> "1.25 years"
// -10 -> "-10 s"
- static string ToShortString(double seconds);
+ static std::string ToShortString(double seconds);
// Reverses ToShortString(). Note that calling these two functions in
// succession isn't a noop, since ToShortString() may round.
@@ -153,7 +150,7 @@ class HumanReadableElapsedTime {
// "-10 sec" -> -10
// "18.3" -> 18.3
// "1M" -> 2592000 (1 month = 30 days)
- static bool ToDouble(const string& str, double* value);
+ static bool ToDouble(const std::string& str, double* value);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(HumanReadableElapsedTime);
http://git-wip-us.apache.org/repos/asf/kudu/blob/154b07de/src/kudu/gutil/strings/join.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/strings/join.cc b/src/kudu/gutil/strings/join.cc
index 4c289f2..645e612 100644
--- a/src/kudu/gutil/strings/join.cc
+++ b/src/kudu/gutil/strings/join.cc
@@ -8,6 +8,11 @@
#include "kudu/gutil/strings/ascii_ctype.h"
#include "kudu/gutil/strings/escaping.h"
+using std::map;
+using std::pair;
+using std::string;
+using std::vector;
+
// ----------------------------------------------------------------------
// JoinUsing()
// This merges a vector of string components with delim inserted