[server] clean-up: stringstream --> ostringstream Replaced std::stringstream with std::ostringstream in places where only output stream functionality is required from the stream buffer class.
Include iosfwd instead of stream headers for forward declarations. Minor clean-up on header files include order to be in line with the styling guide. There are not any functional changes in this changelist. Change-Id: I059c19bb287ee37f96e5ad42f4886015a1697d19 Reviewed-on: http://gerrit.cloudera.org:8080/4303 Reviewed-by: Adar Dembo <[email protected]> Tested-by: Kudu Jenkins Reviewed-by: Will Berkeley <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/d807034d Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/d807034d Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/d807034d Branch: refs/heads/master Commit: d807034dd22d47dbbaec002391ffef79ca5ea4c3 Parents: c0f3727 Author: Alexey Serbin <[email protected]> Authored: Thu Sep 1 18:14:55 2016 -0700 Committer: Adar Dembo <[email protected]> Committed: Thu Sep 8 16:30:03 2016 +0000 ---------------------------------------------------------------------- src/kudu/client/samples/sample.cc | 6 ++-- src/kudu/codegen/code_generator.cc | 2 +- src/kudu/codegen/module_builder.cc | 6 ++-- src/kudu/master/master-path-handlers.cc | 24 ++++++++-------- src/kudu/master/master-path-handlers.h | 14 +++++----- src/kudu/server/default-path-handlers.cc | 20 ++++++++------ src/kudu/server/pprof-path-handlers.cc | 22 ++++++++------- src/kudu/server/rpcz-path-handler.cc | 9 +++--- src/kudu/server/server_base.cc | 10 ++++--- src/kudu/server/tracing-path-handlers.cc | 18 ++++++------ src/kudu/server/tracing-path-handlers.h | 2 -- src/kudu/server/webserver-test.cc | 3 +- src/kudu/server/webserver.cc | 31 +++++++++++---------- src/kudu/server/webserver.h | 7 +++-- src/kudu/server/webui_util.cc | 7 +++-- src/kudu/server/webui_util.h | 8 +++--- src/kudu/tablet/tablet-test.cc | 5 ++-- src/kudu/tools/fs_dump-tool.cc | 2 +- src/kudu/tools/fs_list-tool.cc | 2 +- src/kudu/tools/ksck-test.cc | 8 ++++-- src/kudu/tools/ksck_remote-test.cc | 4 ++- src/kudu/tserver/tablet_server-stress-test.cc | 2 +- src/kudu/tserver/tablet_server-test.cc | 6 ++-- src/kudu/tserver/tserver-path-handlers.cc | 32 +++++++++++----------- src/kudu/tserver/tserver-path-handlers.h | 25 +++++++++-------- src/kudu/util/jsonwriter.cc | 18 ++++++------ src/kudu/util/jsonwriter.h | 6 ++-- src/kudu/util/logging.cc | 6 ++-- src/kudu/util/mem_tracker.cc | 14 ++++++---- src/kudu/util/metrics-test.cc | 4 +-- src/kudu/util/metrics.cc | 3 +- src/kudu/util/os-util.cc | 4 +-- src/kudu/util/pb_util.cc | 3 +- src/kudu/util/spinlock_profiling-test.cc | 2 +- src/kudu/util/spinlock_profiling.cc | 8 ++++-- src/kudu/util/spinlock_profiling.h | 2 +- src/kudu/util/thread.cc | 20 ++++++++------ src/kudu/util/thread.h | 8 ++++-- src/kudu/util/trace.cc | 6 ++-- src/kudu/util/url-coding-test.cc | 2 +- src/kudu/util/url-coding.cc | 24 ++++++++-------- src/kudu/util/url-coding.h | 7 +++-- src/kudu/util/web_callback_registry.h | 6 ++-- 43 files changed, 227 insertions(+), 191 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/client/samples/sample.cc ---------------------------------------------------------------------- diff --git a/src/kudu/client/samples/sample.cc b/src/kudu/client/samples/sample.cc index 94084e6..b021fce 100644 --- a/src/kudu/client/samples/sample.cc +++ b/src/kudu/client/samples/sample.cc @@ -47,8 +47,8 @@ using kudu::KuduPartialRow; using kudu::MonoDelta; using kudu::Status; +using std::ostringstream; using std::string; -using std::stringstream; using std::vector; static Status CreateClient(const string& addr, @@ -197,7 +197,7 @@ static Status ScanRows(const shared_ptr<KuduTable>& table) { int32_t val; KUDU_RETURN_NOT_OK(result.GetInt32("key", &val)); if (val != next_row) { - stringstream out; + ostringstream out; out << "Scan returned the wrong results. Expected key " << next_row << " but got " << val; return Status::IOError(out.str()); @@ -210,7 +210,7 @@ static Status ScanRows(const shared_ptr<KuduTable>& table) { int last_row_seen = next_row - 1; if (last_row_seen != kUpperBound) { - stringstream out; + ostringstream out; out << "Scan returned the wrong results. Expected last row to be " << kUpperBound << " rows but got " << last_row_seen; return Status::IOError(out.str()); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/codegen/code_generator.cc ---------------------------------------------------------------------- diff --git a/src/kudu/codegen/code_generator.cc b/src/kudu/codegen/code_generator.cc index 923752a..6d3eba1 100644 --- a/src/kudu/codegen/code_generator.cc +++ b/src/kudu/codegen/code_generator.cc @@ -219,7 +219,7 @@ Status CodeGenerator::CompileRowProjector(const Schema& base, const Schema& proj if (FLAGS_codegen_dump_mc) { static const int kInstrMax = 500; - std::stringstream sstr; + std::ostringstream sstr; sstr << "Printing read projection function:\n"; int instrs = DumpAsm((*out)->read(), *tm, &sstr, kInstrMax); sstr << "Printed " << instrs << " instructions."; http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/codegen/module_builder.cc ---------------------------------------------------------------------- diff --git a/src/kudu/codegen/module_builder.cc b/src/kudu/codegen/module_builder.cc index 0bd3305..7d446c3 100644 --- a/src/kudu/codegen/module_builder.cc +++ b/src/kudu/codegen/module_builder.cc @@ -75,8 +75,8 @@ using llvm::Type; using llvm::Value; using std::move; using std::ostream; +using std::ostringstream; using std::string; -using std::stringstream; using std::unique_ptr; using std::vector; using strings::Substitute; @@ -87,7 +87,7 @@ namespace codegen { namespace { string ToString(const SMDiagnostic& err) { - stringstream sstr; + ostringstream sstr; raw_os_ostream os(sstr); err.print("precompiled.ll", os); os.flush(); @@ -97,7 +97,7 @@ string ToString(const SMDiagnostic& err) { } string ToString(const Module& m) { - stringstream sstr; + ostringstream sstr; raw_os_ostream os(sstr); os << m; return sstr.str(); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/master/master-path-handlers.cc ---------------------------------------------------------------------- diff --git a/src/kudu/master/master-path-handlers.cc b/src/kudu/master/master-path-handlers.cc index 2eb6120..87f854e 100644 --- a/src/kudu/master/master-path-handlers.cc +++ b/src/kudu/master/master-path-handlers.cc @@ -19,14 +19,16 @@ #include <array> #include <algorithm> -#include <boost/bind.hpp> #include <map> #include <memory> #include <set> +#include <sstream> #include <string> #include <utility> #include <vector> +#include <boost/bind.hpp> + #include "kudu/common/partition.h" #include "kudu/common/schema.h" #include "kudu/common/wire_protocol.h" @@ -47,14 +49,14 @@ namespace kudu { -using std::array; using consensus::ConsensusStatePB; using consensus::RaftPeerPB; +using std::array; using std::map; +using std::ostringstream; using std::pair; using std::shared_ptr; using std::string; -using std::stringstream; using std::vector; using strings::Substitute; @@ -64,7 +66,7 @@ MasterPathHandlers::~MasterPathHandlers() { } void MasterPathHandlers::HandleTabletServers(const Webserver::WebRequest& req, - stringstream* output) { + ostringstream* output) { vector<std::shared_ptr<TSDescriptor> > descs; master_->ts_manager()->GetAllDescriptors(&descs); @@ -107,7 +109,7 @@ void MasterPathHandlers::HandleTabletServers(const Webserver::WebRequest& req, } void MasterPathHandlers::HandleCatalogManager(const Webserver::WebRequest& req, - stringstream* output) { + ostringstream* output) { CatalogManager::ScopedLeaderSharedLock l(master_->catalog_manager()); if (!l.first_failed_status().ok()) { *output << "Master is not ready: " << l.first_failed_status().ToString(); @@ -163,7 +165,7 @@ bool CompareByRole(const pair<string, RaftPeerPB::Role>& a, void MasterPathHandlers::HandleTablePage(const Webserver::WebRequest& req, - stringstream *output) { + ostringstream* output) { // Parse argument. string table_id; if (!FindCopy(req.parsed_args, "id", &table_id)) { @@ -226,7 +228,7 @@ void MasterPathHandlers::HandleTablePage(const Webserver::WebRequest& req, // Prepare the tablets table first because the tablet partition information is // also used to make the range bounds. std::set<std::pair<string, string>> range_bounds; - std::stringstream tablets_output; + std::ostringstream tablets_output; tablets_output << "<h3>Tablets</h3>"; tablets_output << "<table class='table table-striped'>\n"; tablets_output << " <tr><th>Tablet ID</th><th>Partition</th><th>State</th>" @@ -258,7 +260,7 @@ void MasterPathHandlers::HandleTablePage(const Webserver::WebRequest& req, std::sort(sorted_replicas.begin(), sorted_replicas.end(), &CompareByRole); // Generate the RaftConfig table cell. - stringstream raft_config_html; + ostringstream raft_config_html; raft_config_html << "<ul>\n"; for (const auto& e : sorted_replicas) { raft_config_html << e.first; @@ -327,7 +329,7 @@ void MasterPathHandlers::HandleTablePage(const Webserver::WebRequest& req, } void MasterPathHandlers::HandleMasters(const Webserver::WebRequest& req, - stringstream* output) { + ostringstream* output) { vector<ServerEntryPB> masters; Status s = master_->ListMasters(&masters); if (!s.ok()) { @@ -457,7 +459,7 @@ class JsonDumper : public TableVisitor, public TabletVisitor { JsonWriter* jw_; }; -void JsonError(const Status& s, stringstream* out) { +void JsonError(const Status& s, ostringstream* out) { out->str(""); JsonWriter jw(out, JsonWriter::COMPACT); jw.StartObject(); @@ -468,7 +470,7 @@ void JsonError(const Status& s, stringstream* out) { } // anonymous namespace void MasterPathHandlers::HandleDumpEntities(const Webserver::WebRequest& req, - stringstream* output) { + ostringstream* output) { JsonWriter jw(output, JsonWriter::COMPACT); JsonDumper d(&jw); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/master/master-path-handlers.h ---------------------------------------------------------------------- diff --git a/src/kudu/master/master-path-handlers.h b/src/kudu/master/master-path-handlers.h index bcda0a3..0850edb 100644 --- a/src/kudu/master/master-path-handlers.h +++ b/src/kudu/master/master-path-handlers.h @@ -17,8 +17,8 @@ #ifndef KUDU_MASTER_MASTER_PATH_HANDLERS_H #define KUDU_MASTER_MASTER_PATH_HANDLERS_H +#include <iosfwd> #include <string> -#include <sstream> #include <vector> #include "kudu/gutil/macros.h" @@ -47,15 +47,15 @@ class MasterPathHandlers { private: void HandleTabletServers(const Webserver::WebRequest& req, - std::stringstream* output); + std::ostringstream* output); void HandleCatalogManager(const Webserver::WebRequest& req, - std::stringstream* output); + std::ostringstream* output); void HandleTablePage(const Webserver::WebRequest& req, - std::stringstream *output); + std::ostringstream *output); void HandleMasters(const Webserver::WebRequest& req, - std::stringstream* output); + std::ostringstream* output); void HandleDumpEntities(const Webserver::WebRequest& req, - std::stringstream* output); + std::ostringstream* output); // Convert the specified TSDescriptor to HTML, adding a link to the // tablet server's own webserver if specified in 'desc'. @@ -72,7 +72,7 @@ class MasterPathHandlers { DISALLOW_COPY_AND_ASSIGN(MasterPathHandlers); }; -void HandleTabletServersPage(const Webserver::WebRequest& req, std::stringstream* output); +void HandleTabletServersPage(const Webserver::WebRequest& req, std::ostringstream* output); } // namespace master } // namespace kudu http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/server/default-path-handlers.cc ---------------------------------------------------------------------- diff --git a/src/kudu/server/default-path-handlers.cc b/src/kudu/server/default-path-handlers.cc index 61134f1..32989cc 100644 --- a/src/kudu/server/default-path-handlers.cc +++ b/src/kudu/server/default-path-handlers.cc @@ -17,16 +17,18 @@ #include "kudu/server/default-path-handlers.h" -#include <boost/algorithm/string.hpp> -#include <boost/bind.hpp> +#include <sys/stat.h> + #include <fstream> -#include <gperftools/malloc_extension.h> #include <memory> #include <sstream> #include <string> -#include <sys/stat.h> #include <vector> +#include <boost/algorithm/string.hpp> +#include <boost/bind.hpp> +#include <gperftools/malloc_extension.h> + #include "kudu/gutil/map-util.h" #include "kudu/gutil/strings/human_readable.h" #include "kudu/gutil/strings/split.h" @@ -82,7 +84,7 @@ struct Tags { // Writes the last FLAGS_web_log_bytes of the INFO logfile to a webpage // Note to get best performance, set GLOG_logbuflevel=-1 to prevent log buffering -static void LogsHandler(const Webserver::WebRequest& req, std::stringstream* output) { +static void LogsHandler(const Webserver::WebRequest& req, std::ostringstream* output) { bool as_text = (req.parsed_args.find("raw") != req.parsed_args.end()); Tags tags(as_text); string logfile; @@ -110,7 +112,7 @@ static void LogsHandler(const Webserver::WebRequest& req, std::stringstream* out } // Registered to handle "/flags", and prints out all command-line flags and their values -static void FlagsHandler(const Webserver::WebRequest& req, std::stringstream* output) { +static void FlagsHandler(const Webserver::WebRequest& req, std::ostringstream* output) { bool as_text = (req.parsed_args.find("raw") != req.parsed_args.end()); Tags tags(as_text); (*output) << tags.header << "Command-line Flags" << tags.end_header; @@ -118,7 +120,7 @@ static void FlagsHandler(const Webserver::WebRequest& req, std::stringstream* ou } // Registered to handle "/memz", and prints out memory allocation statistics. -static void MemUsageHandler(const Webserver::WebRequest& req, std::stringstream* output) { +static void MemUsageHandler(const Webserver::WebRequest& req, std::ostringstream* output) { bool as_text = (req.parsed_args.find("raw") != req.parsed_args.end()); Tags tags(as_text); @@ -136,7 +138,7 @@ static void MemUsageHandler(const Webserver::WebRequest& req, std::stringstream* } // Registered to handle "/mem-trackers", and prints out to handle memory tracker information. -static void MemTrackersHandler(const Webserver::WebRequest& req, std::stringstream* output) { +static void MemTrackersHandler(const Webserver::WebRequest& req, std::ostringstream* output) { *output << "<h1>Memory usage by subsystem</h1>\n"; *output << "<table class='table table-striped'>\n"; *output << " <tr><th>Id</th><th>Parent</th><th>Limit</th><th>Current Consumption</th>" @@ -169,7 +171,7 @@ void AddDefaultPathHandlers(Webserver* webserver) { static void WriteMetricsAsJson(const MetricRegistry* const metrics, - const Webserver::WebRequest& req, std::stringstream* output) { + const Webserver::WebRequest& req, std::ostringstream* output) { const string* requested_metrics_param = FindOrNull(req.parsed_args, "metrics"); vector<string> requested_metrics; MetricJsonOptions opts; http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/server/pprof-path-handlers.cc ---------------------------------------------------------------------- diff --git a/src/kudu/server/pprof-path-handlers.cc b/src/kudu/server/pprof-path-handlers.cc index 1537a31..ade01da 100644 --- a/src/kudu/server/pprof-path-handlers.cc +++ b/src/kudu/server/pprof-path-handlers.cc @@ -14,16 +14,19 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. + #include "kudu/server/pprof-path-handlers.h" +#include <sys/stat.h> + #include <fstream> +#include <string> +#include <vector> + #include <glog/logging.h> #include <gperftools/heap-profiler.h> #include <gperftools/malloc_extension.h> #include <gperftools/profiler.h> -#include <string> -#include <sys/stat.h> -#include <vector> #include "kudu/gutil/map-util.h" #include "kudu/gutil/strings/numbers.h" @@ -46,7 +49,6 @@ using std::endl; using std::ifstream; using std::ostringstream; using std::string; -using std::stringstream; // GLog already implements symbolization. Just import their hidden symbol. namespace google { @@ -63,7 +65,7 @@ const int PPROF_DEFAULT_SAMPLE_SECS = 30; // pprof default sample time in second // pprof asks for the url /pprof/cmdline to figure out what application it's profiling. // The server should respond by sending the executable path. -static void PprofCmdLineHandler(const Webserver::WebRequest& req, stringstream* output) { +static void PprofCmdLineHandler(const Webserver::WebRequest& req, ostringstream* output) { string executable_path; Env* env = Env::Default(); WARN_NOT_OK(env->GetExecutablePath(&executable_path), "Failed to get executable path"); @@ -73,7 +75,7 @@ static void PprofCmdLineHandler(const Webserver::WebRequest& req, stringstream* // pprof asks for the url /pprof/heap to get heap information. This should be implemented // by calling HeapProfileStart(filename), continue to do work, and then, some number of // seconds later, call GetHeapProfile() followed by HeapProfilerStop(). -static void PprofHeapHandler(const Webserver::WebRequest& req, stringstream* output) { +static void PprofHeapHandler(const Webserver::WebRequest& req, ostringstream* output) { #ifndef TCMALLOC_ENABLED (*output) << "Heap profiling is not available without tcmalloc."; #else @@ -102,7 +104,7 @@ static void PprofHeapHandler(const Webserver::WebRequest& req, stringstream* out // pprof asks for the url /pprof/profile?seconds=XX to get cpu-profiling information. // The server should respond by calling ProfilerStart(), continuing to do its work, // and then, XX seconds later, calling ProfilerStop(). -static void PprofCpuProfileHandler(const Webserver::WebRequest& req, stringstream* output) { +static void PprofCpuProfileHandler(const Webserver::WebRequest& req, ostringstream* output) { #ifndef TCMALLOC_ENABLED (*output) << "CPU profiling is not available without tcmalloc."; #else @@ -129,7 +131,7 @@ static void PprofCpuProfileHandler(const Webserver::WebRequest& req, stringstrea // pprof asks for the url /pprof/growth to get heap-profiling delta (growth) information. // The server should respond by calling: // MallocExtension::instance()->GetHeapGrowthStacks(&output); -static void PprofGrowthHandler(const Webserver::WebRequest& req, stringstream* output) { +static void PprofGrowthHandler(const Webserver::WebRequest& req, ostringstream* output) { #ifndef TCMALLOC_ENABLED (*output) << "Growth profiling is not available without tcmalloc."; #else @@ -140,7 +142,7 @@ static void PprofGrowthHandler(const Webserver::WebRequest& req, stringstream* o } // Lock contention profiling -static void PprofContentionHandler(const Webserver::WebRequest& req, stringstream* output) { +static void PprofContentionHandler(const Webserver::WebRequest& req, ostringstream* output) { string secs_str = FindWithDefault(req.parsed_args, "seconds", ""); int32_t seconds = ParseLeadingInt32Value(secs_str.c_str(), PPROF_DEFAULT_SAMPLE_SECS); int64_t discarded_samples = 0; @@ -187,7 +189,7 @@ static void PprofContentionHandler(const Webserver::WebRequest& req, stringstrea // <hex address><tab><function name> // For instance: // 0x08b2dabd _Update -static void PprofSymbolHandler(const Webserver::WebRequest& req, stringstream* output) { +static void PprofSymbolHandler(const Webserver::WebRequest& req, ostringstream* output) { if (req.request_method == "GET") { // Per the above comment, pprof doesn't expect to know the actual number of symbols. // Any non-zero value indicates that we support symbol lookup. http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/server/rpcz-path-handler.cc ---------------------------------------------------------------------- diff --git a/src/kudu/server/rpcz-path-handler.cc b/src/kudu/server/rpcz-path-handler.cc index 57c599c..c349d6f 100644 --- a/src/kudu/server/rpcz-path-handler.cc +++ b/src/kudu/server/rpcz-path-handler.cc @@ -17,11 +17,12 @@ #include "kudu/server/rpcz-path-handler.h" -#include <boost/bind.hpp> -#include <fstream> #include <memory> +#include <sstream> #include <string> +#include <boost/bind.hpp> + #include "kudu/gutil/map-util.h" #include "kudu/gutil/strings/numbers.h" #include "kudu/rpc/messenger.h" @@ -34,15 +35,15 @@ using kudu::rpc::DumpRunningRpcsResponsePB; using kudu::rpc::DumpRpczStoreRequestPB; using kudu::rpc::DumpRpczStoreResponsePB; using kudu::rpc::Messenger; +using std::ostringstream; using std::shared_ptr; -using std::stringstream; namespace kudu { namespace { void RpczPathHandler(const shared_ptr<Messenger>& messenger, - const Webserver::WebRequest& req, stringstream* output) { + const Webserver::WebRequest& req, ostringstream* output) { DumpRunningRpcsResponsePB running_rpcs; { DumpRunningRpcsRequestPB dump_req; http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/server/server_base.cc ---------------------------------------------------------------------- diff --git a/src/kudu/server/server_base.cc b/src/kudu/server/server_base.cc index aa7d111..c05d8a9 100644 --- a/src/kudu/server/server_base.cc +++ b/src/kudu/server/server_base.cc @@ -16,11 +16,13 @@ // under the License. #include "kudu/server/server_base.h" -#include <boost/algorithm/string/predicate.hpp> -#include <gflags/gflags.h> +#include <sstream> #include <string> #include <vector> +#include <boost/algorithm/string/predicate.hpp> +#include <gflags/gflags.h> + #include "kudu/codegen/compilation_manager.h" #include "kudu/common/wire_protocol.pb.h" #include "kudu/fs/fs_manager.h" @@ -59,9 +61,9 @@ TAG_FLAG(num_reactor_threads, advanced); DECLARE_bool(use_hybrid_clock); +using std::ostringstream; using std::shared_ptr; using std::string; -using std::stringstream; using std::vector; using strings::Substitute; @@ -265,7 +267,7 @@ void ServerBase::MetricsLoggingThread() { next_log = MonoTime::Now() + MonoDelta::FromMilliseconds(options_.metrics_log_interval_ms); - std::stringstream buf; + std::ostringstream buf; buf << "metrics " << GetCurrentTimeMicros() << " "; // Collect the metrics JSON string. http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/server/tracing-path-handlers.cc ---------------------------------------------------------------------- diff --git a/src/kudu/server/tracing-path-handlers.cc b/src/kudu/server/tracing-path-handlers.cc index bef31e3..de1ebe0 100644 --- a/src/kudu/server/tracing-path-handlers.cc +++ b/src/kudu/server/tracing-path-handlers.cc @@ -35,8 +35,8 @@ #include "kudu/util/zlib.h" using std::map; +using std::ostringstream; using std::string; -using std::stringstream; using std::unique_ptr; using std::vector; @@ -124,7 +124,7 @@ Status BeginRecording(const Webserver::WebRequest& req, Status EndRecording(const Webserver::WebRequest& req, bool compressed, - stringstream* out) { + ostringstream* out) { TraceLog* tl = TraceLog::GetInstance(); tl->SetDisabled(); string json = TraceResultBuffer::FlushTraceLogToString(); @@ -139,7 +139,7 @@ Status EndRecording(const Webserver::WebRequest& req, return Status::OK(); } -Status CaptureMonitoring(stringstream* out) { +Status CaptureMonitoring(ostringstream* out) { TraceLog* tl = TraceLog::GetInstance(); if (!tl->IsEnabled()) { return Status::IllegalState("monitoring not enabled"); @@ -148,7 +148,7 @@ Status CaptureMonitoring(stringstream* out) { return Status::OK(); } -void GetCategories(stringstream* out) { +void GetCategories(ostringstream* out) { vector<string> groups; kudu::debug::TraceLog::GetInstance()->GetKnownCategoryGroups(&groups); JsonWriter j(out, JsonWriter::COMPACT); @@ -159,13 +159,13 @@ void GetCategories(stringstream* out) { j.EndArray(); } -void GetMonitoringStatus(stringstream* out) { +void GetMonitoringStatus(ostringstream* out) { TraceLog* tl = TraceLog::GetInstance(); bool is_monitoring = tl->IsEnabled(); std::string category_filter = tl->GetCurrentCategoryFilter().ToString(); int options = static_cast<int>(tl->trace_options()); - stringstream json_out; + ostringstream json_out; JsonWriter j(&json_out, JsonWriter::COMPACT); j.StartObject(); @@ -189,7 +189,7 @@ void GetMonitoringStatus(stringstream* out) { } void HandleTraceJsonPage(const Webserver::ArgumentMap &args, - std::stringstream* output) { + std::ostringstream* output) { TraceLog* tl = TraceLog::GetInstance(); tl->SetEnabled(CategoryFilter(CategoryFilter::kDefaultCategoryFilterString), TraceLog::RECORDING_MODE, @@ -202,7 +202,7 @@ void HandleTraceJsonPage(const Webserver::ArgumentMap &args, Status DoHandleRequest(Handler handler, const Webserver::WebRequest& req, - std::stringstream* output) { + std::ostringstream* output) { VLOG(2) << "Tracing request type=" << handler << ": " << req.query_string; switch (handler) { @@ -242,7 +242,7 @@ Status DoHandleRequest(Handler handler, void HandleRequest(Handler handler, const Webserver::WebRequest& req, - std::stringstream* output) { + std::ostringstream* output) { Status s = DoHandleRequest(handler, req, output); if (!s.ok()) { LOG(WARNING) << "Tracing error for handler " << handler << ": " http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/server/tracing-path-handlers.h ---------------------------------------------------------------------- diff --git a/src/kudu/server/tracing-path-handlers.h b/src/kudu/server/tracing-path-handlers.h index 7936c60..402b77e 100644 --- a/src/kudu/server/tracing-path-handlers.h +++ b/src/kudu/server/tracing-path-handlers.h @@ -21,8 +21,6 @@ #include "kudu/server/webserver.h" #include "kudu/util/status.h" -#include <sstream> - namespace kudu { namespace server { http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/server/webserver-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/server/webserver-test.cc b/src/kudu/server/webserver-test.cc index 6fc9e94..9357434 100644 --- a/src/kudu/server/webserver-test.cc +++ b/src/kudu/server/webserver-test.cc @@ -15,9 +15,10 @@ // specific language governing permissions and limitations // under the License. +#include <string> + #include <gflags/gflags.h> #include <gtest/gtest.h> -#include <string> #include "kudu/gutil/strings/substitute.h" #include "kudu/gutil/strings/util.h" http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/server/webserver.cc ---------------------------------------------------------------------- diff --git a/src/kudu/server/webserver.cc b/src/kudu/server/webserver.cc index 1121ccb..c658ea2 100644 --- a/src/kudu/server/webserver.cc +++ b/src/kudu/server/webserver.cc @@ -16,19 +16,22 @@ // under the License. #include "kudu/server/webserver.h" +#include <cstdio> +#include <signal.h> + #include <algorithm> -#include <boost/algorithm/string.hpp> #include <functional> -#include <gflags/gflags.h> -#include <glog/logging.h> #include <map> #include <mutex> -#include <signal.h> -#include <squeasel.h> -#include <stdio.h> +#include <sstream> #include <string> #include <vector> +#include <boost/algorithm/string.hpp> +#include <glog/logging.h> +#include <gflags/gflags.h> +#include <squeasel.h> + #include "kudu/gutil/map-util.h" #include "kudu/gutil/stl_util.h" #include "kudu/gutil/stringprintf.h" @@ -47,10 +50,10 @@ typedef sig_t sighandler_t; #endif +using std::make_pair; +using std::ostringstream; using std::string; -using std::stringstream; using std::vector; -using std::make_pair; DEFINE_int32(webserver_max_post_length_bytes, 1024 * 1024, "The maximum length of a POST request that will be accepted by " @@ -72,7 +75,7 @@ Webserver::~Webserver() { STLDeleteValues(&path_handlers_); } -void Webserver::RootHandler(const Webserver::WebRequest& args, stringstream* output) { +void Webserver::RootHandler(const Webserver::WebRequest& args, ostringstream* output) { (*output) << "<h2>Status Pages</h2>"; for (const PathHandlerMap::value_type& handler : path_handlers_) { if (handler.second->is_on_nav_bar()) { @@ -148,7 +151,7 @@ Status Webserver::Start() { // Mongoose doesn't log anything if it can't stat the password file (but will if it // can't open it, which it tries to do during a request) if (!Env::Default()->FileExists(opts_.password_file)) { - stringstream ss; + ostringstream ss; ss << "Webserver: Password file does not exist: " << opts_.password_file; return Status::InvalidArgument(ss.str()); } @@ -190,7 +193,7 @@ Status Webserver::Start() { signal(SIGCHLD, sig_chld); if (context_ == nullptr) { - stringstream error_msg; + ostringstream error_msg; error_msg << "Webserver: Could not start on address " << http_address_; Sockaddr addr; addr.set_port(opts_.port); @@ -338,7 +341,7 @@ int Webserver::RunPathHandler(const PathHandler& handler, use_style = false; } - stringstream output; + ostringstream output; if (use_style) BootstrapPageHeader(&output); for (const PathHandlerCallback& callback_ : handler.callbacks()) { callback_(req, &output); @@ -402,7 +405,7 @@ static const char* const NAVIGATION_BAR_SUFFIX = " </div>" " <div class='container-fluid'>"; -void Webserver::BootstrapPageHeader(stringstream* output) { +void Webserver::BootstrapPageHeader(ostringstream* output) { (*output) << PAGE_HEADER; (*output) << NAVIGATION_BAR_PREFIX; for (const PathHandlerMap::value_type& handler : path_handlers_) { @@ -429,7 +432,7 @@ void Webserver::set_footer_html(const std::string& html) { footer_html_ = html; } -void Webserver::BootstrapPageFooter(stringstream* output) { +void Webserver::BootstrapPageFooter(ostringstream* output) { shared_lock<RWMutex> l(lock_); *output << "</div>\n"; // end bootstrap 'container' div if (!footer_html_.empty()) { http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/server/webserver.h ---------------------------------------------------------------------- diff --git a/src/kudu/server/webserver.h b/src/kudu/server/webserver.h index ec50568..2ef4646 100644 --- a/src/kudu/server/webserver.h +++ b/src/kudu/server/webserver.h @@ -17,6 +17,7 @@ #ifndef KUDU_UTIL_WEBSERVER_H #define KUDU_UTIL_WEBSERVER_H +#include <iosfwd> #include <map> #include <string> #include <vector> @@ -101,11 +102,11 @@ class Webserver : public WebCallbackRegistry { Status BuildListenSpec(std::string* spec) const; // Renders a common Bootstrap-styled header - void BootstrapPageHeader(std::stringstream* output); + void BootstrapPageHeader(std::ostringstream* output); // Renders a common Bootstrap-styled footer. Must be used in conjunction with // BootstrapPageHeader. - void BootstrapPageFooter(std::stringstream* output); + void BootstrapPageFooter(std::ostringstream* output); // Dispatch point for all incoming requests. // Static so that it can act as a function pointer, and then call the next method @@ -122,7 +123,7 @@ class Webserver : public WebCallbackRegistry { const char* message); // Registered to handle "/", and prints a list of available URIs - void RootHandler(const WebRequest& args, std::stringstream* output); + void RootHandler(const WebRequest& args, std::ostringstream* output); // Builds a map of argument name to argument value from a typical URL argument // string (that is, "key1=value1&key2=value2.."). If no value is given for a http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/server/webui_util.cc ---------------------------------------------------------------------- diff --git a/src/kudu/server/webui_util.cc b/src/kudu/server/webui_util.cc index 05047ce..b7aaefb 100644 --- a/src/kudu/server/webui_util.cc +++ b/src/kudu/server/webui_util.cc @@ -17,6 +17,7 @@ #include "kudu/server/webui_util.h" +#include <sstream> #include <string> #include "kudu/gutil/strings/join.h" @@ -31,7 +32,7 @@ using strings::Substitute; namespace kudu { void HtmlOutputSchemaTable(const Schema& schema, - std::stringstream* output) { + std::ostringstream* output) { *output << "<table class='table table-striped'>\n"; *output << " <tr>" << "<th>Column</th><th>ID</th><th>Type</th>" @@ -68,7 +69,7 @@ void HtmlOutputSchemaTable(const Schema& schema, void HtmlOutputImpalaSchema(const std::string& table_name, const Schema& schema, const string& master_addresses, - std::stringstream* output) { + std::ostringstream* output) { *output << "<pre><code>\n"; // Escape table and column names with ` to avoid conflicts with Impala reserved words. @@ -144,7 +145,7 @@ void HtmlOutputImpalaSchema(const std::string& table_name, } void HtmlOutputTaskList(const std::vector<scoped_refptr<MonitoredTask> >& tasks, - std::stringstream* output) { + std::ostringstream* output) { *output << "<table class='table table-striped'>\n"; *output << " <tr><th>Task Name</th><th>State</th><th>Time</th><th>Description</th></tr>\n"; for (const scoped_refptr<MonitoredTask>& task : tasks) { http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/server/webui_util.h ---------------------------------------------------------------------- diff --git a/src/kudu/server/webui_util.h b/src/kudu/server/webui_util.h index 52a9119..8bfbd27 100644 --- a/src/kudu/server/webui_util.h +++ b/src/kudu/server/webui_util.h @@ -17,8 +17,8 @@ #ifndef KUDU_SERVER_WEBUI_UTIL_H #define KUDU_SERVER_WEBUI_UTIL_H +#include <iosfwd> #include <string> -#include <sstream> #include <vector> #include "kudu/common/schema.h" @@ -30,13 +30,13 @@ class Schema; class MonitoredTask; void HtmlOutputSchemaTable(const Schema& schema, - std::stringstream* output); + std::ostringstream* output); void HtmlOutputImpalaSchema(const std::string& table_name, const Schema& schema, const std::string& master_address, - std::stringstream* output); + std::ostringstream* output); void HtmlOutputTaskList(const std::vector<scoped_refptr<MonitoredTask> >& tasks, - std::stringstream* output); + std::ostringstream* output); } // namespace kudu #endif // KUDU_SERVER_WEBUI_UTIL_H http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/tablet/tablet-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tablet/tablet-test.cc b/src/kudu/tablet/tablet-test.cc index cb53ccb..a8f97bc 100644 --- a/src/kudu/tablet/tablet-test.cc +++ b/src/kudu/tablet/tablet-test.cc @@ -15,8 +15,9 @@ // specific language governing permissions and limitations // under the License. +#include <ctime> + #include <glog/logging.h> -#include <time.h> #include "kudu/common/iterator.h" #include "kudu/common/row.h" @@ -938,7 +939,7 @@ TYPED_TEST(TestTablet, TestMetricsInit) { // Create a tablet, but do not open it this->CreateTestTablet(); MetricRegistry* registry = this->harness()->metrics_registry(); - std::stringstream out; + std::ostringstream out; JsonWriter writer(&out, JsonWriter::PRETTY); ASSERT_OK(registry->WriteAsJson(&writer, { "*" }, MetricJsonOptions())); // Open tablet, should still work http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/tools/fs_dump-tool.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tools/fs_dump-tool.cc b/src/kudu/tools/fs_dump-tool.cc index fe45614..92bdb8a 100644 --- a/src/kudu/tools/fs_dump-tool.cc +++ b/src/kudu/tools/fs_dump-tool.cc @@ -120,7 +120,7 @@ bool ValidateCommand(int argc, char** argv, CommandType* out) { static int FsDumpToolMain(int argc, char** argv) { FLAGS_logtostderr = 1; - std::stringstream usage_str; + std::ostringstream usage_str; PrintUsageToStream(argv[0], &usage_str); google::SetUsageMessage(usage_str.str()); ParseCommandLineFlags(&argc, &argv, true); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/tools/fs_list-tool.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tools/fs_list-tool.cc b/src/kudu/tools/fs_list-tool.cc index 228967c..5f3836f 100644 --- a/src/kudu/tools/fs_list-tool.cc +++ b/src/kudu/tools/fs_list-tool.cc @@ -102,7 +102,7 @@ bool ValidateCommand(int argc, char** argv, CommandType* out) { static int FsListToolMain(int argc, char** argv) { FLAGS_logtostderr = 1; - std::stringstream usage_str; + std::ostringstream usage_str; PrintUsageToStream(argv[0], &usage_str); google::SetUsageMessage(usage_str.str()); ParseCommandLineFlags(&argc, &argv, true); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/tools/ksck-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tools/ksck-test.cc b/src/kudu/tools/ksck-test.cc index cc2d4c7..5e9624a 100644 --- a/src/kudu/tools/ksck-test.cc +++ b/src/kudu/tools/ksck-test.cc @@ -15,11 +15,13 @@ // specific language governing permissions and limitations // under the License. -#include <gflags/gflags.h> -#include <gtest/gtest.h> +#include <iosfwd> #include <memory> #include <unordered_map> +#include <gflags/gflags.h> +#include <gtest/gtest.h> + #include "kudu/gutil/map-util.h" #include "kudu/gutil/strings/substitute.h" #include "kudu/tools/ksck.h" @@ -255,7 +257,7 @@ class KsckTest : public KuduTest { // are assigned first, end up on ts1 and ts3. vector<string> assignment_plan_; - std::stringstream err_stream_; + std::ostringstream err_stream_; }; TEST_F(KsckTest, TestMasterOk) { http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/tools/ksck_remote-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tools/ksck_remote-test.cc b/src/kudu/tools/ksck_remote-test.cc index b8857ce..5a38945 100644 --- a/src/kudu/tools/ksck_remote-test.cc +++ b/src/kudu/tools/ksck_remote-test.cc @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#include <sstream> + #include <gtest/gtest.h> #include "kudu/client/client.h" @@ -191,7 +193,7 @@ class RemoteKsckTest : public KuduTest { shared_ptr<client::KuduClient> client_; // Captures logged messages from ksck. - std::stringstream err_stream_; + std::ostringstream err_stream_; private: client::KuduSchema schema_; http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/tserver/tablet_server-stress-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tserver/tablet_server-stress-test.cc b/src/kudu/tserver/tablet_server-stress-test.cc index 87d24fd..b303cdc 100644 --- a/src/kudu/tserver/tablet_server-stress-test.cc +++ b/src/kudu/tserver/tablet_server-stress-test.cc @@ -129,7 +129,7 @@ TEST_F(TSStressTest, TestMTInserts) { LOG(INFO) << "CPU efficiency: " << (num_rows / s.elapsed().user_cpu_seconds()) << " rows/cpusec"; // Generate the JSON. - std::stringstream out; + std::ostringstream out; JsonWriter writer(&out, JsonWriter::PRETTY); ASSERT_OK(histogram_->WriteAsJson(&writer, MetricJsonOptions())); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/tserver/tablet_server-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tserver/tablet_server-test.cc b/src/kudu/tserver/tablet_server-test.cc index 24cc182..6d99c24 100644 --- a/src/kudu/tserver/tablet_server-test.cc +++ b/src/kudu/tserver/tablet_server-test.cc @@ -17,6 +17,8 @@ #include "kudu/tserver/tablet_server-test-base.h" #include <memory> +#include <sstream> + #include <zlib.h> #include "kudu/consensus/log-test-base.h" @@ -233,7 +235,7 @@ TEST_F(TabletServerTest, TestWebPages) { &buf)); string json; if (compressed) { - std::stringstream ss; + std::ostringstream ss; ASSERT_OK(zlib::Uncompress(buf, &ss)); json = ss.str(); } else { @@ -2059,7 +2061,7 @@ TEST_F(TabletServerTest, TestInsertLatencyMicroBenchmark) { double throughput = ((max_rows - warmup) * 1.0) / (end - start).ToSeconds(); // Generate the JSON. - std::stringstream out; + std::ostringstream out; JsonWriter writer(&out, JsonWriter::PRETTY); ASSERT_OK(histogram->WriteAsJson(&writer, MetricJsonOptions())); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/tserver/tserver-path-handlers.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tserver/tserver-path-handlers.cc b/src/kudu/tserver/tserver-path-handlers.cc index df6f6bf..b88ece2 100644 --- a/src/kudu/tserver/tserver-path-handlers.cc +++ b/src/kudu/tserver/tserver-path-handlers.cc @@ -106,7 +106,7 @@ Status TabletServerPathHandlers::Register(Webserver* server) { } void TabletServerPathHandlers::HandleTransactionsPage(const Webserver::WebRequest& req, - std::stringstream* output) { + std::ostringstream* output) { bool as_text = ContainsKey(req.parsed_args, "raw"); vector<scoped_refptr<TabletPeer> > peers; @@ -176,7 +176,7 @@ string TabletLink(const string& id) { } // anonymous namespace void TabletServerPathHandlers::HandleTabletsPage(const Webserver::WebRequest& req, - std::stringstream *output) { + std::ostringstream *output) { vector<scoped_refptr<TabletPeer> > peers; tserver_->tablet_manager()->GetTabletPeers(&peers); @@ -242,7 +242,7 @@ bool CompareByMemberType(const RaftPeerPB& a, const RaftPeerPB& b) { } // anonymous namespace string TabletServerPathHandlers::ConsensusStatePBToHtml(const ConsensusStatePB& cstate) const { - std::stringstream html; + std::ostringstream html; html << "<ul>\n"; std::vector<RaftPeerPB> sorted_peers; @@ -270,7 +270,7 @@ string TabletServerPathHandlers::ConsensusStatePBToHtml(const ConsensusStatePB& namespace { -bool GetTabletID(const Webserver::WebRequest& req, string* id, std::stringstream *out) { +bool GetTabletID(const Webserver::WebRequest& req, string* id, std::ostringstream* out) { if (!FindCopy(req.parsed_args, "id", id)) { // TODO: webserver should give a way to return a non-200 response code (*out) << "Tablet missing 'id' argument"; @@ -281,7 +281,7 @@ bool GetTabletID(const Webserver::WebRequest& req, string* id, std::stringstream bool GetTabletPeer(TabletServer* tserver, const Webserver::WebRequest& req, scoped_refptr<TabletPeer>* peer, const string& tablet_id, - std::stringstream *out) { + std::ostringstream* out) { if (!tserver->tablet_manager()->LookupTablet(tablet_id, peer)) { (*out) << "Tablet " << EscapeForHtmlToString(tablet_id) << " not found"; return false; @@ -290,7 +290,7 @@ bool GetTabletPeer(TabletServer* tserver, const Webserver::WebRequest& req, } bool TabletBootstrapping(const scoped_refptr<TabletPeer>& peer, const string& tablet_id, - std::stringstream* out) { + std::ostringstream* out) { if (peer->state() == tablet::BOOTSTRAPPING) { (*out) << "Tablet " << EscapeForHtmlToString(tablet_id) << " is still bootstrapping"; return false; @@ -303,7 +303,7 @@ bool TabletBootstrapping(const scoped_refptr<TabletPeer>& peer, const string& ta bool LoadTablet(TabletServer* tserver, const Webserver::WebRequest& req, string* tablet_id, scoped_refptr<TabletPeer>* peer, - std::stringstream* out) { + std::ostringstream* out) { if (!GetTabletID(req, tablet_id, out)) return false; if (!GetTabletPeer(tserver, req, peer, *tablet_id, out)) return false; if (!TabletBootstrapping(*peer, *tablet_id, out)) return false; @@ -313,7 +313,7 @@ bool LoadTablet(TabletServer* tserver, } // anonymous namespace void TabletServerPathHandlers::HandleTabletPage(const Webserver::WebRequest& req, - std::stringstream *output) { + std::ostringstream *output) { string tablet_id; scoped_refptr<TabletPeer> peer; if (!LoadTablet(tserver_, req, &tablet_id, &peer, output)) return; @@ -358,7 +358,7 @@ void TabletServerPathHandlers::HandleTabletPage(const Webserver::WebRequest& req } void TabletServerPathHandlers::HandleTabletSVGPage(const Webserver::WebRequest& req, - std::stringstream* output) { + std::ostringstream* output) { string id; scoped_refptr<TabletPeer> peer; if (!LoadTablet(tserver_, req, &id, &peer, output)) return; @@ -375,7 +375,7 @@ void TabletServerPathHandlers::HandleTabletSVGPage(const Webserver::WebRequest& } void TabletServerPathHandlers::HandleLogAnchorsPage(const Webserver::WebRequest& req, - std::stringstream* output) { + std::ostringstream* output) { string tablet_id; scoped_refptr<TabletPeer> peer; if (!LoadTablet(tserver_, req, &tablet_id, &peer, output)) return; @@ -388,7 +388,7 @@ void TabletServerPathHandlers::HandleLogAnchorsPage(const Webserver::WebRequest& } void TabletServerPathHandlers::HandleConsensusStatusPage(const Webserver::WebRequest& req, - std::stringstream* output) { + std::ostringstream* output) { string id; scoped_refptr<TabletPeer> peer; if (!LoadTablet(tserver_, req, &id, &peer, output)) return; @@ -401,7 +401,7 @@ void TabletServerPathHandlers::HandleConsensusStatusPage(const Webserver::WebReq } void TabletServerPathHandlers::HandleScansPage(const Webserver::WebRequest& req, - std::stringstream* output) { + std::ostringstream* output) { *output << "<h1>Scans</h1>\n"; *output << "<table class='table table-striped'>\n"; *output << "<tr><th>Tablet id</th><th>Scanner id</th><th>Total time in-flight</th>" @@ -417,7 +417,7 @@ void TabletServerPathHandlers::HandleScansPage(const Webserver::WebRequest& req, } string TabletServerPathHandlers::ScannerToHtml(const Scanner& scanner) const { - std::stringstream html; + std::ostringstream html; uint64_t time_in_flight_us = (MonoTime::Now() - scanner.start_time()).ToMicroseconds(); uint64_t time_since_last_access_us = @@ -471,7 +471,7 @@ string TabletServerPathHandlers::ScannerToHtml(const Scanner& scanner) const { string TabletServerPathHandlers::IteratorStatsToHtml(const Schema& projection, const vector<IteratorStats>& stats) const { - std::stringstream html; + std::ostringstream html; html << "<table>\n"; html << "<tr><th>Column</th>" << "<th>Blocks read from disk</th>" @@ -500,7 +500,7 @@ string TabletServerPathHandlers::IteratorStatsToHtml(const Schema& projection, } void TabletServerPathHandlers::HandleDashboardsPage(const Webserver::WebRequest& req, - std::stringstream* output) { + std::ostringstream* output) { *output << "<h3>Dashboards</h3>\n"; *output << "<table class='table table-striped'>\n"; @@ -523,7 +523,7 @@ string TabletServerPathHandlers::GetDashboardLine(const std::string& link, } void TabletServerPathHandlers::HandleMaintenanceManagerPage(const Webserver::WebRequest& req, - std::stringstream* output) { + std::ostringstream* output) { MaintenanceManager* manager = tserver_->maintenance_manager(); MaintenanceManagerStatusPB pb; manager->GetMaintenanceManagerStatusDump(&pb); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/tserver/tserver-path-handlers.h ---------------------------------------------------------------------- diff --git a/src/kudu/tserver/tserver-path-handlers.h b/src/kudu/tserver/tserver-path-handlers.h index 6cd1f2a..9b2b038 100644 --- a/src/kudu/tserver/tserver-path-handlers.h +++ b/src/kudu/tserver/tserver-path-handlers.h @@ -17,12 +17,13 @@ #ifndef KUDU_TSERVER_TSERVER_PATH_HANDLERS_H #define KUDU_TSERVER_TSERVER_PATH_HANDLERS_H -#include "kudu/gutil/macros.h" -#include "kudu/server/webserver.h" +#include <iosfwd> #include <string> -#include <sstream> #include <vector> +#include "kudu/gutil/macros.h" +#include "kudu/server/webserver.h" + namespace kudu { class Schema; @@ -49,23 +50,23 @@ class TabletServerPathHandlers { private: void HandleScansPage(const Webserver::WebRequest& req, - std::stringstream* output); + std::ostringstream* output); void HandleTabletsPage(const Webserver::WebRequest& req, - std::stringstream* output); + std::ostringstream* output); void HandleTabletPage(const Webserver::WebRequest& req, - std::stringstream* output); + std::ostringstream* output); void HandleTransactionsPage(const Webserver::WebRequest& req, - std::stringstream* output); + std::ostringstream* output); void HandleTabletSVGPage(const Webserver::WebRequest& req, - std::stringstream* output); + std::ostringstream* output); void HandleLogAnchorsPage(const Webserver::WebRequest& req, - std::stringstream* output); + std::ostringstream* output); void HandleConsensusStatusPage(const Webserver::WebRequest& req, - std::stringstream* output); + std::ostringstream* output); void HandleDashboardsPage(const Webserver::WebRequest& req, - std::stringstream* output); + std::ostringstream* output); void HandleMaintenanceManagerPage(const Webserver::WebRequest& req, - std::stringstream* output); + std::ostringstream* output); std::string ConsensusStatePBToHtml(const consensus::ConsensusStatePB& cstate) const; std::string ScannerToHtml(const Scanner& scanner) const; std::string IteratorStatsToHtml(const Schema& projection, http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/jsonwriter.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/jsonwriter.cc b/src/kudu/util/jsonwriter.cc index bc11264..64f8706 100644 --- a/src/kudu/util/jsonwriter.cc +++ b/src/kudu/util/jsonwriter.cc @@ -16,6 +16,7 @@ // under the License. #include "kudu/util/jsonwriter.h" +#include <sstream> #include <string> #include <vector> @@ -29,8 +30,8 @@ using google::protobuf::FieldDescriptor; using google::protobuf::Message; using google::protobuf::Reflection; +using std::ostringstream; using std::string; -using std::stringstream; using std::vector; namespace kudu { @@ -39,10 +40,10 @@ namespace kudu { // Since Squeasel exposes a stringstream as its interface, this is needed to avoid overcopying. class UTF8StringStreamBuffer { public: - explicit UTF8StringStreamBuffer(std::stringstream* out); + explicit UTF8StringStreamBuffer(std::ostringstream* out); void Put(rapidjson::UTF8<>::Ch c); private: - std::stringstream* out_; + std::ostringstream* out_; }; // rapidjson doesn't provide any common interface between the PrettyWriter and @@ -75,7 +76,7 @@ class JsonWriterIf { template<class T> class JsonWriterImpl : public JsonWriterIf { public: - explicit JsonWriterImpl(stringstream* out); + explicit JsonWriterImpl(ostringstream* out); virtual void Null() OVERRIDE; virtual void Bool(bool b) OVERRIDE; @@ -106,7 +107,7 @@ class JsonWriterImpl : public JsonWriterIf { typedef rapidjson::PrettyWriter<UTF8StringStreamBuffer> PrettyWriterClass; typedef rapidjson::Writer<UTF8StringStreamBuffer> CompactWriterClass; -JsonWriter::JsonWriter(stringstream* out, Mode m) { +JsonWriter::JsonWriter(ostringstream* out, Mode m) { switch (m) { case PRETTY: impl_.reset(new JsonWriterImpl<PrettyWriterClass>(DCHECK_NOTNULL(out))); @@ -118,6 +119,7 @@ JsonWriter::JsonWriter(stringstream* out, Mode m) { } JsonWriter::~JsonWriter() { } + void JsonWriter::Null() { impl_->Null(); } void JsonWriter::Bool(bool b) { impl_->Bool(b); } void JsonWriter::Int(int i) { impl_->Int(i); } @@ -260,7 +262,7 @@ void JsonWriter::ProtobufRepeatedField(const Message& pb, const FieldDescriptor* } string JsonWriter::ToJson(const Message& pb, Mode mode) { - stringstream stream; + ostringstream stream; JsonWriter writer(&stream, mode); writer.Protobuf(pb); return stream.str(); @@ -270,7 +272,7 @@ string JsonWriter::ToJson(const Message& pb, Mode mode) { // UTF8StringStreamBuffer // -UTF8StringStreamBuffer::UTF8StringStreamBuffer(std::stringstream* out) +UTF8StringStreamBuffer::UTF8StringStreamBuffer(std::ostringstream* out) : out_(DCHECK_NOTNULL(out)) { } @@ -283,7 +285,7 @@ void UTF8StringStreamBuffer::Put(rapidjson::UTF8<>::Ch c) { // template<class T> -JsonWriterImpl<T>::JsonWriterImpl(stringstream* out) +JsonWriterImpl<T>::JsonWriterImpl(ostringstream* out) : stream_(DCHECK_NOTNULL(out)), writer_(stream_) { } http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/jsonwriter.h ---------------------------------------------------------------------- diff --git a/src/kudu/util/jsonwriter.h b/src/kudu/util/jsonwriter.h index 4e1c9fd..1909bc0 100644 --- a/src/kudu/util/jsonwriter.h +++ b/src/kudu/util/jsonwriter.h @@ -19,9 +19,9 @@ #include <inttypes.h> +#include <memory> #include <string> -#include "kudu/gutil/gscoped_ptr.h" #include "kudu/gutil/macros.h" namespace google { @@ -52,7 +52,7 @@ class JsonWriter { COMPACT }; - JsonWriter(std::stringstream* out, Mode mode); + JsonWriter(std::ostringstream* out, Mode mode); ~JsonWriter(); void Null(); @@ -87,7 +87,7 @@ class JsonWriter { const google::protobuf::FieldDescriptor* field, int index); - gscoped_ptr<JsonWriterIf> impl_; + std::unique_ptr<JsonWriterIf> impl_; DISALLOW_COPY_AND_ASSIGN(JsonWriter); }; http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/logging.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/logging.cc b/src/kudu/util/logging.cc index a5ff0cd..1032f97 100644 --- a/src/kudu/util/logging.cc +++ b/src/kudu/util/logging.cc @@ -179,13 +179,13 @@ void InitGoogleLoggingSafe(const char* arg) { if (!FLAGS_logtostderr) { // Verify that a log file can be created in log_dir by creating a tmp file. - stringstream ss; + ostringstream ss; random_generator uuid_generator; ss << FLAGS_log_dir << "/" << PROJ_NAME "_test_log." << uuid_generator(); const string file_name = ss.str(); ofstream test_file(file_name.c_str()); if (!test_file.is_open()) { - stringstream error_msg; + ostringstream error_msg; error_msg << "Could not open file in log_dir " << FLAGS_log_dir; perror(error_msg.str().c_str()); // Unlock the mutex before exiting the program to avoid mutex d'tor assert. @@ -278,7 +278,7 @@ void UnregisterLoggingCallback() { } void GetFullLogFilename(google::LogSeverity severity, string* filename) { - stringstream ss; + ostringstream ss; ss << FLAGS_log_dir << "/" << FLAGS_log_filename << "." << google::GetLogSeverityName(severity); *filename = ss.str(); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/mem_tracker.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/mem_tracker.cc b/src/kudu/util/mem_tracker.cc index 1727780..f5d7adc 100644 --- a/src/kudu/util/mem_tracker.cc +++ b/src/kudu/util/mem_tracker.cc @@ -19,11 +19,13 @@ #include <algorithm> #include <deque> -#include <gperftools/malloc_extension.h> #include <limits> #include <list> #include <memory> #include <mutex> +#include <sstream> + +#include <gperftools/malloc_extension.h> #include "kudu/gutil/map-util.h" #include "kudu/gutil/once.h" @@ -71,9 +73,9 @@ namespace kudu { using std::deque; using std::list; -using std::string; -using std::stringstream; +using std::ostringstream; using std::shared_ptr; +using std::string; using std::vector; using std::weak_ptr; @@ -515,7 +517,7 @@ void MemTracker::GcTcmalloc() { } string MemTracker::LogUsage(const string& prefix) const { - stringstream ss; + ostringstream ss; ss << prefix << id_ << ":"; if (CheckLimitExceeded()) { ss << " memory limit exceeded."; @@ -525,7 +527,7 @@ string MemTracker::LogUsage(const string& prefix) const { } ss << " Consumption=" << HumanReadableNumBytes::ToString(consumption()); - stringstream prefix_ss; + ostringstream prefix_ss; prefix_ss << prefix << " "; string new_prefix = prefix_ss.str(); MutexLock l(child_trackers_lock_); @@ -559,7 +561,7 @@ void MemTracker::AddChildTrackerUnlocked(const shared_ptr<MemTracker>& tracker) } void MemTracker::LogUpdate(bool is_consume, int64_t bytes) const { - stringstream ss; + ostringstream ss; ss << this << " " << (is_consume ? "Consume: " : "Release: ") << bytes << " Consumption: " << consumption() << " Limit: " << limit_; if (log_stack_) { http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/metrics-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/metrics-test.cc b/src/kudu/util/metrics-test.cc index 867ea6a..7493056 100644 --- a/src/kudu/util/metrics-test.cc +++ b/src/kudu/util/metrics-test.cc @@ -171,7 +171,7 @@ TEST_F(MetricsTest, JsonPrintTest) { entity_->SetAttribute("test_attr", "attr_val"); // Generate the JSON. - std::stringstream out; + std::ostringstream out; JsonWriter writer(&out, JsonWriter::PRETTY); ASSERT_OK(entity_->WriteAsJson(&writer, { "*" }, MetricJsonOptions())); @@ -268,7 +268,7 @@ TEST_F(MetricsTest, TestInstantiatingDifferentEntities) { TEST_F(MetricsTest, TestDumpJsonPrototypes) { // Dump the prototype info. - std::stringstream out; + std::ostringstream out; JsonWriter w(&out, JsonWriter::PRETTY); MetricPrototypeRegistry::get()->WriteAsJson(&w); string json = out.str(); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/metrics.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/metrics.cc b/src/kudu/util/metrics.cc index 50ccdcf..6450e8c 100644 --- a/src/kudu/util/metrics.cc +++ b/src/kudu/util/metrics.cc @@ -17,6 +17,7 @@ #include "kudu/util/metrics.h" #include <iostream> +#include <sstream> #include <map> #include <set> @@ -414,7 +415,7 @@ void MetricPrototypeRegistry::WriteAsJson(JsonWriter* writer) const { } void MetricPrototypeRegistry::WriteAsJsonAndExit() const { - std::stringstream s; + std::ostringstream s; JsonWriter w(&s, JsonWriter::PRETTY); WriteAsJson(&w); std::cout << s.str() << std::endl; http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/os-util.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/os-util.cc b/src/kudu/util/os-util.cc index a7d279f..8874bd8 100644 --- a/src/kudu/util/os-util.cc +++ b/src/kudu/util/os-util.cc @@ -39,7 +39,7 @@ using std::ifstream; using std::istreambuf_iterator; -using std::stringstream; +using std::ostringstream; using strings::Split; using strings::Substitute; @@ -107,7 +107,7 @@ Status GetThreadStats(int64_t tid, ThreadStats* stats) { return Status::NotSupported("ThreadStats not supported"); } - stringstream proc_path; + ostringstream proc_path; proc_path << "/proc/self/task/" << tid << "/stat"; ifstream proc_file(proc_path.str().c_str()); if (!proc_file.is_open()) { http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/pb_util.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/pb_util.cc b/src/kudu/util/pb_util.cc index 6df4c84..5180153 100644 --- a/src/kudu/util/pb_util.cc +++ b/src/kudu/util/pb_util.cc @@ -27,6 +27,7 @@ #include <initializer_list> #include <memory> #include <ostream> +#include <sstream> #include <string> #include <unordered_set> #include <vector> @@ -888,7 +889,7 @@ PbTracer::PbTracer(const Message& msg) : msg_(msg.New()) { void PbTracer::AppendAsTraceFormat(std::string* out) const { pb_util::TruncateFields(msg_.get(), kMaxFieldLengthToTrace); - std::stringstream ss; + std::ostringstream ss; JsonWriter jw(&ss, JsonWriter::COMPACT); jw.Protobuf(*msg_); out->append(ss.str()); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/spinlock_profiling-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/spinlock_profiling-test.cc b/src/kudu/util/spinlock_profiling-test.cc index cc430f1..4960c0f 100644 --- a/src/kudu/util/spinlock_profiling-test.cc +++ b/src/kudu/util/spinlock_profiling-test.cc @@ -68,7 +68,7 @@ TEST_F(SpinLockProfilingTest, TestStackCollection) { base::SpinLock lock; gutil::SubmitSpinLockProfileData(&lock, 12345); StopSynchronizationProfiling(); - std::stringstream str; + std::ostringstream str; int64_t dropped = 0; FlushSynchronizationProfile(&str, &dropped); string s = str.str(); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/spinlock_profiling.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/spinlock_profiling.cc b/src/kudu/util/spinlock_profiling.cc index 3f9e5eb..001f8d5 100644 --- a/src/kudu/util/spinlock_profiling.cc +++ b/src/kudu/util/spinlock_profiling.cc @@ -17,6 +17,8 @@ #include "kudu/util/spinlock_profiling.h" +#include <sstream> + #include <glog/logging.h> #include <gflags/gflags.h> @@ -100,7 +102,7 @@ class ContentionStacks { // // On return, guarantees that any stack traces that were present at the beginning of // the call have been flushed. However, new stacks can be added concurrently with this call. - void Flush(std::stringstream* out, int64_t* dropped); + void Flush(std::ostringstream* out, int64_t* dropped); private: @@ -187,7 +189,7 @@ void ContentionStacks::AddStack(const StackTrace& s, int64_t cycles) { dropped_samples_.Increment(); } -void ContentionStacks::Flush(std::stringstream* out, int64_t* dropped) { +void ContentionStacks::Flush(std::ostringstream* out, int64_t* dropped) { uint64_t iterator = 0; StackTrace t; int64_t cycles; @@ -308,7 +310,7 @@ void StartSynchronizationProfiling() { base::subtle::Barrier_AtomicIncrement(&g_profiling_enabled, 1); } -void FlushSynchronizationProfile(std::stringstream* out, +void FlushSynchronizationProfile(std::ostringstream* out, int64_t* drop_count) { CHECK_NOTNULL(g_contention_stacks)->Flush(out, drop_count); } http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/spinlock_profiling.h ---------------------------------------------------------------------- diff --git a/src/kudu/util/spinlock_profiling.h b/src/kudu/util/spinlock_profiling.h index ddd21d0..d5b5f15 100644 --- a/src/kudu/util/spinlock_profiling.h +++ b/src/kudu/util/spinlock_profiling.h @@ -67,7 +67,7 @@ void StartSynchronizationProfiling(); // due to the contention buffer overflowing. If profiling is enabled during this // call, then the 'drop_count' may be slightly out-of-date with respect to the // returned samples. -void FlushSynchronizationProfile(std::stringstream* out, int64_t* drop_count); +void FlushSynchronizationProfile(std::ostringstream* out, int64_t* drop_count); // Stop collecting contention profiles. void StopSynchronizationProfiling(); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/thread.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/thread.cc b/src/kudu/util/thread.cc index ffaa2ce..971568e 100644 --- a/src/kudu/util/thread.cc +++ b/src/kudu/util/thread.cc @@ -19,15 +19,17 @@ #include "kudu/util/thread.h" -#include <algorithm> -#include <map> -#include <memory> -#include <set> #include <sys/resource.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> + +#include <algorithm> +#include <map> +#include <memory> +#include <set> +#include <sstream> #include <vector> #if defined(__linux__) @@ -55,8 +57,8 @@ using boost::bind; using boost::mem_fn; using std::endl; using std::map; +using std::ostringstream; using std::shared_ptr; -using std::stringstream; using strings::Substitute; METRIC_DEFINE_gauge_uint64(server, threads_started, @@ -211,8 +213,8 @@ class ThreadMgr { uint64_t ReadThreadsRunning(); // Webpage callback; prints all threads by category - void ThreadPathHandler(const WebCallbackRegistry::WebRequest& args, stringstream* output); - void PrintThreadCategoryRows(const ThreadCategory& category, stringstream* output); + void ThreadPathHandler(const WebCallbackRegistry::WebRequest& args, ostringstream* output); + void PrintThreadCategoryRows(const ThreadCategory& category, ostringstream* output); }; void ThreadMgr::SetThreadName(const string& name, int64 tid) { @@ -327,7 +329,7 @@ void ThreadMgr::RemoveThread(const pthread_t& pthread_id, const string& category } void ThreadMgr::PrintThreadCategoryRows(const ThreadCategory& category, - stringstream* output) { + ostringstream* output) { for (const ThreadCategory::value_type& thread : category) { ThreadStats stats; Status status = GetThreadStats(thread.second.thread_id(), &stats); @@ -343,7 +345,7 @@ void ThreadMgr::PrintThreadCategoryRows(const ThreadCategory& category, } void ThreadMgr::ThreadPathHandler(const WebCallbackRegistry::WebRequest& req, - stringstream* output) { + ostringstream* output) { MutexLock l(lock_); vector<const ThreadCategory*> categories_to_print; auto category_name = req.parsed_args.find("group"); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/thread.h ---------------------------------------------------------------------- diff --git a/src/kudu/util/thread.h b/src/kudu/util/thread.h index 77c40e5..5aa7620 100644 --- a/src/kudu/util/thread.h +++ b/src/kudu/util/thread.h @@ -20,14 +20,16 @@ #ifndef KUDU_UTIL_THREAD_H #define KUDU_UTIL_THREAD_H -#include <boost/bind.hpp> -#include <boost/function.hpp> #include <pthread.h> -#include <string> #include <sys/syscall.h> #include <sys/types.h> + +#include <string> #include <vector> +#include <boost/bind.hpp> +#include <boost/function.hpp> + #include "kudu/gutil/atomicops.h" #include "kudu/gutil/ref_counted.h" #include "kudu/util/async_util.h" http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/trace.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/trace.cc b/src/kudu/util/trace.cc index f5793cb..177ba38 100644 --- a/src/kudu/util/trace.cc +++ b/src/kudu/util/trace.cc @@ -23,7 +23,7 @@ #include <map> #include <mutex> #include <string> -#include <strstream> +#include <sstream> #include <utility> #include <vector> @@ -190,13 +190,13 @@ void Trace::Dump(std::ostream* out, int flags) const { } string Trace::DumpToString(int flags) const { - std::stringstream s; + std::ostringstream s; Dump(&s, flags); return s.str(); } string Trace::MetricsAsJSON() const { - std::stringstream s; + std::ostringstream s; JsonWriter jw(&s, JsonWriter::COMPACT); MetricsToJSON(&jw); return s.str(); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/url-coding-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/url-coding-test.cc b/src/kudu/util/url-coding-test.cc index 1e06cce..e83de64 100644 --- a/src/kudu/util/url-coding-test.cc +++ b/src/kudu/util/url-coding-test.cc @@ -99,7 +99,7 @@ TEST(Base64Test, Basic) { TEST(HtmlEscapingTest, Basic) { string before = "<html><body>&"; - stringstream after; + ostringstream after; EscapeForHtml(before, &after); EXPECT_EQ(after.str(), "<html><body>&amp"); } http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/url-coding.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/url-coding.cc b/src/kudu/util/url-coding.cc index 6c3f26c..afbaa44 100644 --- a/src/kudu/util/url-coding.cc +++ b/src/kudu/util/url-coding.cc @@ -19,13 +19,13 @@ #include "kudu/util/url-coding.h" #include <algorithm> +#include <exception> +#include <sstream> + #include <boost/algorithm/string.hpp> #include <boost/archive/iterators/base64_from_binary.hpp> #include <boost/archive/iterators/binary_from_base64.hpp> #include <boost/archive/iterators/transform_width.hpp> -#include <exception> -#include <sstream> - #include <glog/logging.h> using std::string; @@ -46,7 +46,7 @@ static boost::function<bool (char)> ShouldNotEscape = boost::is_any_of("-_.~"); static inline void UrlEncode(const char* in, int in_len, string* out, bool hive_compat) { (*out).reserve(in_len); - std::stringstream ss; + std::ostringstream ss; for (int i = 0; i < in_len; ++i) { const char ch = in[i]; // Escape the character iff a) we are in Hive-compat mode and the @@ -112,10 +112,10 @@ bool UrlDecode(const string& in, string* out, bool hive_compat) { return true; } -static inline void Base64Encode(const char* in, int in_len, std::stringstream* out) { +static inline void Base64Encode(const char* in, int in_len, std::ostringstream* out) { typedef base64_from_binary<transform_width<const char*, 6, 8> > base64_encode; // Base64 encodes 8 byte chars as 6 bit values. - std::stringstream::pos_type len_before = out->tellp(); + std::ostringstream::pos_type len_before = out->tellp(); copy(base64_encode(in), base64_encode(in + in_len), std::ostream_iterator<char>(*out)); int bytes_written = out->tellp() - len_before; // Pad with = to make it valid base64 encoded string @@ -133,13 +133,13 @@ void Base64Encode(const vector<uint8_t>& in, string* out) { if (in.empty()) { *out = ""; } else { - std::stringstream ss; + std::ostringstream ss; Base64Encode(in, &ss); *out = ss.str(); } } -void Base64Encode(const vector<uint8_t>& in, std::stringstream* out) { +void Base64Encode(const vector<uint8_t>& in, std::ostringstream* out) { if (!in.empty()) { // Boost does not like non-null terminated strings string tmp(reinterpret_cast<const char*>(&in[0]), in.size()); @@ -148,12 +148,12 @@ void Base64Encode(const vector<uint8_t>& in, std::stringstream* out) { } void Base64Encode(const string& in, string* out) { - std::stringstream ss; + std::ostringstream ss; Base64Encode(in.c_str(), in.size(), &ss); *out = ss.str(); } -void Base64Encode(const string& in, std::stringstream* out) { +void Base64Encode(const string& in, std::ostringstream* out) { Base64Encode(in.c_str(), in.size(), out); } @@ -179,7 +179,7 @@ bool Base64Decode(const string& in, string* out) { return true; } -void EscapeForHtml(const string& in, std::stringstream* out) { +void EscapeForHtml(const string& in, std::ostringstream* out) { DCHECK(out != nullptr); for (const char& c : in) { switch (c) { @@ -195,7 +195,7 @@ void EscapeForHtml(const string& in, std::stringstream* out) { } std::string EscapeForHtmlToString(const std::string& in) { - std::stringstream str; + std::ostringstream str; EscapeForHtml(in, &str); return str.str(); } http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/url-coding.h ---------------------------------------------------------------------- diff --git a/src/kudu/util/url-coding.h b/src/kudu/util/url-coding.h index 0a003b9..179aecb 100644 --- a/src/kudu/util/url-coding.h +++ b/src/kudu/util/url-coding.h @@ -19,6 +19,7 @@ #include <stdint.h> +#include <iosfwd> #include <string> #include <vector> @@ -45,9 +46,9 @@ bool UrlDecode(const std::string& in, std::string* out, bool hive_compat = false // very performant (multiple string copies) and should not be used // in a hot path. void Base64Encode(const std::vector<uint8_t>& in, std::string* out); -void Base64Encode(const std::vector<uint8_t>& in, std::stringstream* out); +void Base64Encode(const std::vector<uint8_t>& in, std::ostringstream* out); void Base64Encode(const std::string& in, std::string* out); -void Base64Encode(const std::string& in, std::stringstream* out); +void Base64Encode(const std::string& in, std::ostringstream* out); // Utility method to decode base64 encoded strings. Also not extremely // performant. @@ -59,7 +60,7 @@ bool Base64Decode(const std::string& in, std::string* out); // added to on a case-by-case basis. Slow, since it necessarily // inspects each character in turn, and copies them all to *out; use // judiciously. -void EscapeForHtml(const std::string& in, std::stringstream* out); +void EscapeForHtml(const std::string& in, std::ostringstream* out); // Same as above, but returns a string. std::string EscapeForHtmlToString(const std::string& in); http://git-wip-us.apache.org/repos/asf/kudu/blob/d807034d/src/kudu/util/web_callback_registry.h ---------------------------------------------------------------------- diff --git a/src/kudu/util/web_callback_registry.h b/src/kudu/util/web_callback_registry.h index 0c143f4..ce90d79 100644 --- a/src/kudu/util/web_callback_registry.h +++ b/src/kudu/util/web_callback_registry.h @@ -17,10 +17,12 @@ #ifndef KUDU_UTIL_WEB_CALLBACK_REGISTRY_H #define KUDU_UTIL_WEB_CALLBACK_REGISTRY_H -#include <boost/function.hpp> +#include <iosfwd> #include <map> #include <string> +#include <boost/function.hpp> + namespace kudu { // Interface for registering webserver callbacks. @@ -42,7 +44,7 @@ class WebCallbackRegistry { std::string post_data; }; - typedef boost::function<void (const WebRequest& args, std::stringstream* output)> + typedef boost::function<void (const WebRequest& args, std::ostringstream* output)> PathHandlerCallback; virtual ~WebCallbackRegistry() {}
