This is an automated email from the ASF dual-hosted git repository.

laszlog pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 31e48c3cdfe0e43cbaa64a32ee8d2f956af22626
Author: Surya Hebbar <[email protected]>
AuthorDate: Wed Mar 12 02:01:32 2025 +0530

    IMPALA-13843: Support usage of strings directly in rapidjson
    
    The RapidJSON library recalculates length of a StringRef each time
    when using char*, until null character.
    
    Within the codebase, many times we convert from string to char* for
    RapidJSON.
    
    Instead with RAPIDJSON_HAS_STDSTRING, we can use strings directly,
    which inherently contain the size, instead of recalculating each time.
    
    This is a major convenience and a bit more efficient during both
    JSON generation and parsing.
    
    This simplifies many methods(i.e. AddMember, HasMember, etc) and
    the creation of Document::Value.
    
    This does not remove compatibility for existing char* and still remains
    as a stable feature within RapidJSON.
    
    Change-Id: I84c6f17690f7a2e958a6dfbb3637832f5ab6ee53
    Reviewed-on: http://gerrit.cloudera.org:8080/22613
    Reviewed-by: Impala Public Jenkins <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
---
 be/CMakeLists.txt                           |   2 +
 be/src/catalog/catalog-server.cc            |  77 ++++++-----
 be/src/exprs/string-functions.cc            |   5 +-
 be/src/runtime/coordinator-backend-state.cc |  12 +-
 be/src/service/impala-http-handler.cc       | 193 ++++++++++++++--------------
 be/src/util/json-util.cc                    |  12 +-
 be/src/util/json-util.h                     |   2 +-
 be/src/util/jwt-util.cc                     |   6 +-
 be/src/util/lineage-util.h                  |  18 +--
 be/src/util/logging-support.cc              |   2 +-
 be/src/util/metrics.cc                      |  20 +--
 be/src/util/redactor.cc                     |   2 +-
 be/src/util/runtime-profile.cc              |  29 ++---
 be/src/util/webserver.cc                    |  10 +-
 14 files changed, 192 insertions(+), 198 deletions(-)

diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index 1a94b321f..541f2ae77 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -65,6 +65,8 @@ SET(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} 
-DBOOST_ALLOW_DEPRECATED_HEADERS")
 #      built at OS where getrandom(2) is available at OSes where getrandom(2)
 #      isn't supported (e.g., that might happen in containerized deployments).
 SET(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} 
-DBOOST_UUID_RANDOM_PROVIDER_FORCE_POSIX")
+# Support using strings directly in rapidjson
+SET(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DRAPIDJSON_HAS_STDSTRING=1")
 IF($ENV{IMPALA_LINKER} STREQUAL "mold")
   # Only very recent GCC 12+ has support for -fuse-ld=mold, so we override 
"ld" by
   # putting Mold's libexec/mold directory (which has a "ld" symlink) on the 
path.
diff --git a/be/src/catalog/catalog-server.cc b/be/src/catalog/catalog-server.cc
index 41615005a..55b169c8f 100644
--- a/be/src/catalog/catalog-server.cc
+++ b/be/src/catalog/catalog-server.cc
@@ -838,7 +838,7 @@ void CatalogServer::CatalogUrlCallback(const 
Webserver::WebRequest& req,
   TGetDbsResult get_dbs_result;
   Status status = catalog_->GetDbs(NULL, &get_dbs_result);
   if (!status.ok()) {
-    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    Value error(status.GetDetail(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
     return;
   }
@@ -849,19 +849,19 @@ void CatalogServer::CatalogUrlCallback(const 
Webserver::WebRequest& req,
     version_value.SetInt(current_catalog_version);
     document->AddMember("version", version_value, document->GetAllocator());
   } else {
-    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    Value error(status.GetDetail(), document->GetAllocator());
     document->AddMember("versionError", error, document->GetAllocator());
   }
   Value databases(kArrayType);
   for (const TDatabase& db: get_dbs_result.dbs) {
     Value database(kObjectType);
-    Value str(db.db_name.c_str(), document->GetAllocator());
+    Value str(db.db_name, document->GetAllocator());
     database.AddMember("name", str, document->GetAllocator());
 
     TGetTablesResult get_table_results;
     Status status = catalog_->GetTableNames(db.db_name, NULL, 
&get_table_results);
     if (!status.ok()) {
-      Value error(status.GetDetail().c_str(), document->GetAllocator());
+      Value error(status.GetDetail(), document->GetAllocator());
       database.AddMember("error", error, document->GetAllocator());
       continue;
     }
@@ -869,10 +869,10 @@ void CatalogServer::CatalogUrlCallback(const 
Webserver::WebRequest& req,
     Value table_array(kArrayType);
     for (const string& table: get_table_results.tables) {
       Value table_obj(kObjectType);
-      Value fq_name(Substitute("$0.$1", db.db_name, table).c_str(),
+      Value fq_name(Substitute("$0.$1", db.db_name, table),
           document->GetAllocator());
       table_obj.AddMember("fqtn", fq_name, document->GetAllocator());
-      Value table_name(table.c_str(), document->GetAllocator());
+      Value table_name(table, document->GetAllocator());
       table_obj.AddMember("name", table_name, document->GetAllocator());
       Value has_metrics;
       has_metrics.SetBool(true);
@@ -893,7 +893,7 @@ void CatalogServer::GetCatalogUsage(Document* document) {
   TGetCatalogUsageResponse catalog_usage_result;
   Status status = catalog_->GetCatalogUsage(&catalog_usage_result);
   if (!status.ok()) {
-    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    Value error(status.GetDetail(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
     return;
   }
@@ -902,7 +902,7 @@ void CatalogServer::GetCatalogUsage(Document* document) {
   for (const auto & large_table : catalog_usage_result.large_tables) {
     Value tbl_obj(kObjectType);
     Value tbl_name(Substitute("$0.$1", large_table.table_name.db_name,
-        large_table.table_name.table_name).c_str(), document->GetAllocator());
+        large_table.table_name.table_name), document->GetAllocator());
     tbl_obj.AddMember("name", tbl_name, document->GetAllocator());
     DCHECK(large_table.__isset.memory_estimate_bytes);
     tbl_obj.AddMember("mem_estimate", large_table.memory_estimate_bytes,
@@ -922,7 +922,7 @@ void CatalogServer::GetCatalogUsage(Document* document) {
   for (const auto & frequent_table : 
catalog_usage_result.frequently_accessed_tables) {
     Value tbl_obj(kObjectType);
     Value tbl_name(Substitute("$0.$1", frequent_table.table_name.db_name,
-        frequent_table.table_name.table_name).c_str(), 
document->GetAllocator());
+        frequent_table.table_name.table_name), document->GetAllocator());
     tbl_obj.AddMember("name", tbl_name, document->GetAllocator());
     Value num_metadata_operations;
     DCHECK(frequent_table.__isset.num_metadata_operations);
@@ -946,7 +946,7 @@ void CatalogServer::GetCatalogUsage(Document* document) {
   for (const auto & high_filecount_tbl : 
catalog_usage_result.high_file_count_tables) {
     Value tbl_obj(kObjectType);
     Value tbl_name(Substitute("$0.$1", high_filecount_tbl.table_name.db_name,
-        high_filecount_tbl.table_name.table_name).c_str(), 
document->GetAllocator());
+        high_filecount_tbl.table_name.table_name), document->GetAllocator());
     tbl_obj.AddMember("name", tbl_name, document->GetAllocator());
     Value num_files;
     DCHECK(high_filecount_tbl.__isset.num_files);
@@ -971,7 +971,7 @@ void CatalogServer::GetCatalogUsage(Document* document) {
   for (const auto & longest_table : 
catalog_usage_result.long_metadata_loading_tables) {
     Value tbl_obj(kObjectType);
     Value tbl_name(Substitute("$0.$1", longest_table.table_name.db_name,
-        longest_table.table_name.table_name).c_str(), 
document->GetAllocator());
+        longest_table.table_name.table_name), document->GetAllocator());
     tbl_obj.AddMember("name", tbl_name, document->GetAllocator());
     Value median_loading_time;
     Value max_loading_time;
@@ -1024,16 +1024,16 @@ void CatalogServer::EventMetricsUrlCallback(
   TEventProcessorMetricsSummaryResponse event_processor_summary_response;
   Status status = 
catalog_->GetEventProcessorSummary(&event_processor_summary_response);
   if (!status.ok()) {
-    Value error(status.GetDetail().c_str(), allocator);
+    Value error(status.GetDetail(), allocator);
     document->AddMember("error", error, allocator);
     return;
   }
 
   Value event_processor_summary(
-      event_processor_summary_response.summary.c_str(), allocator);
+      event_processor_summary_response.summary, allocator);
   document->AddMember("event_processor_metrics", event_processor_summary, 
allocator);
   if (event_processor_summary_response.__isset.error_msg) {
-    Value error_msg(event_processor_summary_response.error_msg.c_str(), 
allocator);
+    Value error_msg(event_processor_summary_response.error_msg, allocator);
     document->AddMember("event_processor_error_msg", error_msg, allocator);
   }
   const TEventBatchProgressInfo& progress_info =
@@ -1123,7 +1123,7 @@ void CatalogServer::CatalogObjectsUrlCallback(const 
Webserver::WebRequest& req,
       string json_str;
       if (status.ok()) status = catalog_->GetJsonCatalogObject(request, 
&json_str);
       if (status.ok()) {
-        Value debug_string(json_str.c_str(), document->GetAllocator());
+        Value debug_string(json_str, document->GetAllocator());
         document->AddMember("json_string", debug_string, 
document->GetAllocator());
       }
     } else {
@@ -1132,12 +1132,12 @@ void CatalogServer::CatalogObjectsUrlCallback(const 
Webserver::WebRequest& req,
       if (status.ok()) status = catalog_->GetCatalogObject(request, &result);
       if(status.ok()) {
         Value debug_string(
-            ThriftDebugStringNoThrow(result).c_str(), 
document->GetAllocator());
+            ThriftDebugStringNoThrow(result), document->GetAllocator());
         document->AddMember("thrift_string", debug_string, 
document->GetAllocator());
       }
     }
     if (!status.ok()) {
-      Value error(status.GetDetail().c_str(), document->GetAllocator());
+      Value error(status.GetDetail(), document->GetAllocator());
       document->AddMember("error", error, document->GetAllocator());
     }
   } else {
@@ -1152,7 +1152,7 @@ void CatalogServer::OperationUsageUrlCallback(
   TGetOperationUsageResponse operation_usage;
   Status status = catalog_->GetOperationUsage(&operation_usage);
   if (!status.ok()) {
-    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    Value error(status.GetDetail(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
     return;
   }
@@ -1166,12 +1166,12 @@ void CatalogServer::GetCatalogOpSummary(const 
TGetOperationUsageResponse& operat
   Value catalog_op_list(kArrayType);
   for (const auto& catalog_op : operation_usage.catalog_op_counters) {
     Value catalog_op_obj(kObjectType);
-    Value op_name(catalog_op.catalog_op_name.c_str(), 
document->GetAllocator());
+    Value op_name(catalog_op.catalog_op_name, document->GetAllocator());
     catalog_op_obj.AddMember("catalog_op_name", op_name, 
document->GetAllocator());
     Value op_counter;
     op_counter.SetInt64(catalog_op.op_counter);
     catalog_op_obj.AddMember("op_counter", op_counter, 
document->GetAllocator());
-    Value table_name(catalog_op.table_name.c_str(), document->GetAllocator());
+    Value table_name(catalog_op.table_name, document->GetAllocator());
     catalog_op_obj.AddMember("table_name", table_name, 
document->GetAllocator());
     catalog_op_list.PushBack(catalog_op_obj, document->GetAllocator());
   }
@@ -1185,7 +1185,7 @@ void CatalogServer::GetCatalogOpSummary(const 
TGetOperationUsageResponse& operat
   Value catalog_op_summary(kArrayType);
   for (const auto& catalog_op : aggregated_operations) {
     Value catalog_op_obj(kObjectType);
-    Value op_name(catalog_op.first.c_str(), document->GetAllocator());
+    Value op_name(catalog_op.first, document->GetAllocator());
     catalog_op_obj.AddMember("catalog_op_name", op_name, 
document->GetAllocator());
     Value op_counter;
     op_counter.SetInt64(catalog_op.second);
@@ -1199,37 +1199,37 @@ static void CatalogOpListToJson(const 
vector<TCatalogOpRecord>& catalog_ops,
     Value* catalog_op_list, Document* document) {
   for (const auto& catalog_op : catalog_ops) {
     Value obj(kObjectType);
-    Value op_name(catalog_op.catalog_op_name.c_str(), 
document->GetAllocator());
+    Value op_name(catalog_op.catalog_op_name, document->GetAllocator());
     obj.AddMember("catalog_op_name", op_name, document->GetAllocator());
 
     Value thread_id;
     thread_id.SetInt64(catalog_op.thread_id);
     obj.AddMember("thread_id", thread_id, document->GetAllocator());
 
-    Value query_id(PrintId(catalog_op.query_id).c_str(), 
document->GetAllocator());
+    Value query_id(PrintId(catalog_op.query_id), document->GetAllocator());
     obj.AddMember("query_id", query_id, document->GetAllocator());
 
-    Value client_ip(catalog_op.client_ip.c_str(), document->GetAllocator());
+    Value client_ip(catalog_op.client_ip, document->GetAllocator());
     obj.AddMember("client_ip", client_ip, document->GetAllocator());
 
-    Value coordinator(catalog_op.coordinator_hostname.c_str(), 
document->GetAllocator());
+    Value coordinator(catalog_op.coordinator_hostname, 
document->GetAllocator());
     obj.AddMember("coordinator", coordinator, document->GetAllocator());
 
-    Value user(catalog_op.user.c_str(), document->GetAllocator());
+    Value user(catalog_op.user, document->GetAllocator());
     obj.AddMember("user", user, document->GetAllocator());
 
-    Value target_name(catalog_op.target_name.c_str(), 
document->GetAllocator());
+    Value target_name(catalog_op.target_name, document->GetAllocator());
     obj.AddMember("target_name", target_name, document->GetAllocator());
 
     Value start_time(ToStringFromUnixMillis(catalog_op.start_time_ms,
-        TimePrecision::Millisecond).c_str(), document->GetAllocator());
+        TimePrecision::Millisecond), document->GetAllocator());
     obj.AddMember("start_time", start_time, document->GetAllocator());
 
     int64_t end_time_ms;
     if (catalog_op.finish_time_ms > 0) {
       end_time_ms = catalog_op.finish_time_ms;
       Value finish_time(ToStringFromUnixMillis(catalog_op.finish_time_ms,
-          TimePrecision::Millisecond).c_str(), document->GetAllocator());
+          TimePrecision::Millisecond), document->GetAllocator());
       obj.AddMember("finish_time", finish_time, document->GetAllocator());
     } else {
       end_time_ms = UnixMillis();
@@ -1237,13 +1237,13 @@ static void CatalogOpListToJson(const 
vector<TCatalogOpRecord>& catalog_ops,
 
     int64_t duration_ms = end_time_ms - catalog_op.start_time_ms;
     const string& printed_duration = PrettyPrinter::Print(duration_ms, 
TUnit::TIME_MS);
-    Value duration(printed_duration.c_str(), document->GetAllocator());
+    Value duration(printed_duration, document->GetAllocator());
     obj.AddMember("duration", duration, document->GetAllocator());
 
-    Value status(catalog_op.status.c_str(), document->GetAllocator());
+    Value status(catalog_op.status, document->GetAllocator());
     obj.AddMember("status", status, document->GetAllocator());
 
-    Value details(catalog_op.details.c_str(), document->GetAllocator());
+    Value details(catalog_op.details, document->GetAllocator());
     obj.AddMember("details", details, document->GetAllocator());
 
     catalog_op_list->PushBack(obj, document->GetAllocator());
@@ -1278,18 +1278,17 @@ void CatalogServer::TableMetricsUrlCallback(const 
Webserver::WebRequest& req,
     if (pos == string::npos || pos >= full_tbl_name.size() - 1) {
       stringstream error_msg;
       error_msg << "Invalid table name: " << full_tbl_name;
-      Value error(error_msg.str().c_str(), document->GetAllocator());
-      document->AddMember("error", error, document->GetAllocator());
+      document->AddMember("error", error_msg.str(), document->GetAllocator());
       return;
     }
     string metrics;
     Status status = catalog_->GetTableMetrics(
         full_tbl_name.substr(0, pos), full_tbl_name.substr(pos + 1), &metrics);
     if (status.ok()) {
-      Value metrics_str(metrics.c_str(), document->GetAllocator());
+      Value metrics_str(metrics, document->GetAllocator());
       document->AddMember("table_metrics", metrics_str, 
document->GetAllocator());
     } else {
-      Value error(status.GetDetail().c_str(), document->GetAllocator());
+      Value error(status.GetDetail(), document->GetAllocator());
       document->AddMember("error", error, document->GetAllocator());
     }
   } else {
@@ -1345,7 +1344,7 @@ void CatalogServer::HadoopVarzHandler(const 
Webserver::WebRequest& req,
   if (!status.ok()) {
     LOG(ERROR) << "Error getting cluster configuration for hadoop-varz: "
                << status.GetDetail();
-    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    Value error(status.GetDetail(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
     return;
   }
@@ -1353,8 +1352,8 @@ void CatalogServer::HadoopVarzHandler(const 
Webserver::WebRequest& req,
   Value configs(kArrayType);
   typedef map<string, string> ConfigMap;
   for (const auto& config: response.configs) {
-    Value key(config.first.c_str(), document->GetAllocator());
-    Value value(config.second.c_str(), document->GetAllocator());
+    Value key(config.first, document->GetAllocator());
+    Value value(config.second, document->GetAllocator());
     Value config_json(kObjectType);
     config_json.AddMember("key", key, document->GetAllocator());
     config_json.AddMember("value", value, document->GetAllocator());
diff --git a/be/src/exprs/string-functions.cc b/be/src/exprs/string-functions.cc
index 12630087a..1d9999911 100644
--- a/be/src/exprs/string-functions.cc
+++ b/be/src/exprs/string-functions.cc
@@ -160,12 +160,11 @@ static StringVal ToStringVal(FunctionContext* ctx, const 
JsonUdfValue& values,
 static void SelectByKey(const string& key, JsonUdfValue* queue,
     JsonUdfAllocator* allocator) {
   SizeType old_items = queue->Size();  // RapidJson uses SizeType instead of 
size_t
-  const char* key_ptr = key.c_str();
   JsonUdfValue item;
   for (SizeType i = 0; i < old_items; ++i) {
     item = (*queue)[i];
-    if (!item.IsObject() || !item.HasMember(key_ptr)) continue;
-    queue->PushBack(item[key_ptr], *allocator);
+    if (!item.IsObject() || !item.HasMember(key)) continue;
+    queue->PushBack(item[key], *allocator);
   }
   queue->Erase(queue->Begin(), queue->Begin() + old_items);
 }
diff --git a/be/src/runtime/coordinator-backend-state.cc 
b/be/src/runtime/coordinator-backend-state.cc
index 2ad027d15..6be1cb52f 100644
--- a/be/src/runtime/coordinator-backend-state.cc
+++ b/be/src/runtime/coordinator-backend-state.cc
@@ -896,18 +896,18 @@ void 
Coordinator::BackendState::InstanceStats::UpdateExecStats(
 
 void Coordinator::BackendState::InstanceStats::ToJson(Value* value, Document* 
document) {
   Value instance_id_val(
-      PrintId(exec_params_.instance_id()).c_str(), document->GetAllocator());
+      PrintId(exec_params_.instance_id()), document->GetAllocator());
   value->AddMember("instance_id", instance_id_val, document->GetAllocator());
 
   // We send 'done' explicitly so we don't have to infer it by comparison with 
a string
   // constant in the debug page JS code.
   value->AddMember("done", done_, document->GetAllocator());
 
-  Value 
state_val(FragmentInstanceState::ExecStateToString(current_state_).c_str(),
+  Value state_val(FragmentInstanceState::ExecStateToString(current_state_),
       document->GetAllocator());
   value->AddMember("current_state", state_val, document->GetAllocator());
 
-  Value fragment_name_val(fragment_->display_name.c_str(), 
document->GetAllocator());
+  Value fragment_name_val(fragment_->display_name, document->GetAllocator());
   value->AddMember("fragment_name", fragment_name_val, 
document->GetAllocator());
 
   value->AddMember("first_status_update_received", last_report_time_ms_ > 0,
@@ -987,7 +987,7 @@ void Coordinator::BackendState::ToJson(Value* value, 
Document* document) {
       document->GetAllocator());
 
   string host = NetworkAddressPBToString(impalad_address());
-  Value val(host.c_str(), document->GetAllocator());
+  Value val(host, document->GetAllocator());
   value->AddMember("host", val, document->GetAllocator());
 
   value->AddMember("rpc_latency", rpc_latency(), document->GetAllocator());
@@ -995,7 +995,7 @@ void Coordinator::BackendState::ToJson(Value* value, 
Document* document) {
       document->GetAllocator());
 
   string status_str = status_.ok() ? "OK" : status_.GetDetail();
-  Value status_val(status_str.c_str(), document->GetAllocator());
+  Value status_val(status_str, document->GetAllocator());
   value->AddMember("status", status_val, document->GetAllocator());
 
   value->AddMember(
@@ -1018,7 +1018,7 @@ void 
Coordinator::BackendState::InstanceStatsToJson(Value* value, Document* docu
   // impalad_address is not protected by lock_. The lifetime of the backend 
state is
   // protected by Coordinator::lock_.
   Value val(
-      NetworkAddressPBToString(impalad_address()).c_str(), 
document->GetAllocator());
+      NetworkAddressPBToString(impalad_address()), document->GetAllocator());
   value->AddMember("host", val, document->GetAllocator());
 }
 
diff --git a/be/src/service/impala-http-handler.cc 
b/be/src/service/impala-http-handler.cc
index d7b7bcd85..cacfa0e89 100644
--- a/be/src/service/impala-http-handler.cc
+++ b/be/src/service/impala-http-handler.cc
@@ -233,7 +233,7 @@ void ImpalaHttpHandler::HadoopVarzHandler(const 
Webserver::WebRequest& req,
   if (!status.ok()) {
     LOG(ERROR) << "Error getting cluster configuration for hadoop-varz: "
                << status.GetDetail();
-    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    Value error(status.GetDetail(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
     return;
   }
@@ -241,8 +241,8 @@ void ImpalaHttpHandler::HadoopVarzHandler(const 
Webserver::WebRequest& req,
   Value configs(kArrayType);
   typedef map<string, string> ConfigMap;
   for (const auto& config: response.configs) {
-    Value key(config.first.c_str(), document->GetAllocator());
-    Value value(config.second.c_str(), document->GetAllocator());
+    Value key(config.first, document->GetAllocator());
+    Value value(config.second, document->GetAllocator());
     Value config_json(kObjectType);
     config_json.AddMember("key", key, document->GetAllocator());
     config_json.AddMember("value", value, document->GetAllocator());
@@ -256,7 +256,7 @@ void ImpalaHttpHandler::CancelQueryHandler(const 
Webserver::WebRequest& req,
   TUniqueId unique_id;
   Status status = ParseIdFromRequest(req, &unique_id, "query_id");
   if (!status.ok()) {
-    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    Value error(status.GetDetail(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
     return;
   }
@@ -266,7 +266,7 @@ void ImpalaHttpHandler::CancelQueryHandler(const 
Webserver::WebRequest& req,
   // web UI is allowed to close queries.
   status = server_->UnregisterQuery(unique_id, true, &cause);
   if (!status.ok()) {
-    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    Value error(status.GetDetail(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
     return;
   }
@@ -279,7 +279,7 @@ void ImpalaHttpHandler::CloseSessionHandler(const 
Webserver::WebRequest& req,
   TUniqueId unique_id;
   Status status = ParseIdFromRequest(req, &unique_id, "session_id");
   if (!status.ok()) {
-    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    Value error(status.GetDetail(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
     return;
   }
@@ -290,13 +290,13 @@ void ImpalaHttpHandler::CloseSessionHandler(const 
Webserver::WebRequest& req,
   status = server_->CloseSessionInternal(unique_id,
       ImpalaServer::SecretArg::SkipSecretCheck(), /* ignore_if_absent= */ 
false);
   if (!status.ok()) {
-    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    Value error(status.GetDetail(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
     return;
   }
   stringstream ss;
   ss << "Session " << PrintId(unique_id) << " closed successfully";
-  Value message(ss.str().c_str(), document->GetAllocator());
+  Value message(ss.str(), document->GetAllocator());
   document->AddMember("contents", message, document->GetAllocator());
 }
 
@@ -305,12 +305,12 @@ void ImpalaHttpHandler::QueryProfileHandler(const 
Webserver::WebRequest& req,
   TUniqueId unique_id;
   Status parse_status = ParseIdFromRequest(req, &unique_id, "query_id");
   if (!parse_status.ok()) {
-    Value error(parse_status.GetDetail().c_str(), document->GetAllocator());
+    Value error(parse_status.GetDetail(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
     return;
   }
 
-  Value query_id_val(PrintId(unique_id).c_str(), document->GetAllocator());
+  Value query_id_val(PrintId(unique_id), document->GetAllocator());
   document->AddMember("query_id", query_id_val, document->GetAllocator());
 
   ImpalaServer::RuntimeProfileOutput runtime_profile;
@@ -319,12 +319,12 @@ void ImpalaHttpHandler::QueryProfileHandler(const 
Webserver::WebRequest& req,
   Status status = server_->GetRuntimeProfileOutput(
       unique_id, "", TRuntimeProfileFormat::STRING, &runtime_profile);
   if (!status.ok()) {
-    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    Value error(status.GetDetail(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
     return;
   }
 
-  Value profile(ss.str().c_str(), document->GetAllocator());
+  Value profile(ss.str(), document->GetAllocator());
   document->AddMember("profile", profile, document->GetAllocator());
 }
 
@@ -338,7 +338,7 @@ void ImpalaHttpHandler::QueryProfileHelper(const 
Webserver::WebRequest& req,
   } else {
     ImpalaServer::RuntimeProfileOutput runtime_profile;
     if (internal_profile) {
-      Value query_id_val(PrintId(unique_id).c_str(), document->GetAllocator());
+      Value query_id_val(PrintId(unique_id), document->GetAllocator());
       document->AddMember("query_id", query_id_val, document->GetAllocator());
       document->AddMember("internal_profile", true, document->GetAllocator());
     }
@@ -353,11 +353,11 @@ void ImpalaHttpHandler::QueryProfileHelper(const 
Webserver::WebRequest& req,
   }
   // JSON format contents already been added inside document in 
GetRuntimeProfileOutput()
   if (format != TRuntimeProfileFormat::JSON){
-    Value profile(ss.str().c_str(), document->GetAllocator());
+    Value profile(ss.str(), document->GetAllocator());
     document->AddMember("contents", profile, document->GetAllocator());
   } else if (internal_profile) {
     if (!status.ok()) {
-      Value error(ss.str().c_str(), document->GetAllocator());
+      Value error(ss.str(), document->GetAllocator());
       document->AddMember("error", error, document->GetAllocator());
       return;
     }
@@ -398,7 +398,7 @@ void ImpalaHttpHandler::InflightQueryIdsHandler(const 
Webserver::WebRequest& req
       });
   document->AddMember(rapidjson::StringRef(Webserver::ENABLE_RAW_HTML_KEY), 
true,
       document->GetAllocator());
-  Value query_ids(ss.str().c_str(), document->GetAllocator());
+  Value query_ids(ss.str(), document->GetAllocator());
   document->AddMember("contents", query_ids, document->GetAllocator());
 }
 
@@ -407,7 +407,7 @@ void ImpalaHttpHandler::QueryMemoryHandler(const 
Webserver::WebRequest& req,
   TUniqueId unique_id;
   Status parse_status = ParseIdFromRequest(req, &unique_id, "query_id");
   if (!parse_status.ok()) {
-    Value error(parse_status.GetDetail().c_str(), document->GetAllocator());
+    Value error(parse_status.GetDetail(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
     return;
   }
@@ -421,10 +421,10 @@ void ImpalaHttpHandler::QueryMemoryHandler(const 
Webserver::WebRequest& req,
                      "current memory consumption is not available.";
   }
 
-  Value mem_usage(mem_usage_text.c_str(), document->GetAllocator());
+  Value mem_usage(mem_usage_text, document->GetAllocator());
   document->AddMember("mem_usage", mem_usage, document->GetAllocator());
   const auto& args = req.parsed_args;
-  Value query_id(args.find("query_id")->second.c_str(), 
document->GetAllocator());
+  Value query_id(args.find("query_id")->second, document->GetAllocator());
   document->AddMember("query_id", query_id, document->GetAllocator());
 }
 
@@ -528,10 +528,10 @@ std::string ImpalaHttpHandler::ProgressToString(int64_t 
num_completed, int64_t t
 
 void ImpalaHttpHandler::QueryStateToJson(const QueryStateRecord& record,
     Value* value, Document* document, bool inflight) {
-  Value user(record.effective_user.c_str(), document->GetAllocator());
+  Value user(record.effective_user, document->GetAllocator());
   value->AddMember("effective_user", user, document->GetAllocator());
 
-  Value default_db(record.default_db.c_str(), document->GetAllocator());
+  Value default_db(record.default_db, document->GetAllocator());
   value->AddMember("default_db", default_db, document->GetAllocator());
 
   // Redact the query string
@@ -539,7 +539,7 @@ void ImpalaHttpHandler::QueryStateToJson(const 
QueryStateRecord& record,
   if(FLAGS_query_stmt_size && tmp_stmt.length() > FLAGS_query_stmt_size) {
     tmp_stmt = tmp_stmt.substr(0, FLAGS_query_stmt_size).append("...");
   }
-  Value stmt(tmp_stmt.c_str(), document->GetAllocator());
+  Value stmt(tmp_stmt, document->GetAllocator());
   value->AddMember("stmt", stmt, document->GetAllocator());
 
   Value stmt_type(_TStmtType_VALUES_TO_NAMES.find(record.stmt_type)->second,
@@ -547,11 +547,11 @@ void ImpalaHttpHandler::QueryStateToJson(const 
QueryStateRecord& record,
   value->AddMember("stmt_type", stmt_type, document->GetAllocator());
 
   Value start_time(ToStringFromUnixMicros(record.start_time_us,
-      TimePrecision::Millisecond).c_str(), document->GetAllocator());
+      TimePrecision::Millisecond), document->GetAllocator());
   value->AddMember("start_time", start_time, document->GetAllocator());
 
   Value end_time(ToStringFromUnixMicros(record.end_time_us,
-      TimePrecision::Millisecond).c_str(), document->GetAllocator());
+      TimePrecision::Millisecond), document->GetAllocator());
   value->AddMember("end_time", end_time, document->GetAllocator());
 
   vector<string>::const_iterator it = 
std::find(record.event_sequence.labels.begin(),
@@ -564,12 +564,12 @@ void ImpalaHttpHandler::QueryStateToJson(const 
QueryStateRecord& record,
   }
   const string& printed_first_fetch = PrettyPrinter::Print(first_fetch_ns,
       TUnit::TIME_NS);
-  Value val_first_fetch(printed_first_fetch.c_str(), document->GetAllocator());
+  Value val_first_fetch(printed_first_fetch, document->GetAllocator());
   value->AddMember("first_fetch", val_first_fetch, document->GetAllocator());
 
   const string& printed_client_fetch_duration = PrettyPrinter::Print(
       record.client_fetch_wait_time_ns, TUnit::TIME_NS);
-  Value val_client_fetch_duration(printed_client_fetch_duration.c_str(),
+  Value val_client_fetch_duration(printed_client_fetch_duration,
       document->GetAllocator());
   value->AddMember("client_fetch_duration", val_client_fetch_duration,
       document->GetAllocator());
@@ -581,22 +581,22 @@ void ImpalaHttpHandler::QueryStateToJson(const 
QueryStateRecord& record,
   int64_t duration_us = end_time_us - record.start_time_us;
   const string& printed_duration = PrettyPrinter::Print(duration_us * 
NANOS_PER_MICRO,
       TUnit::TIME_NS);
-  Value val_duration(printed_duration.c_str(), document->GetAllocator());
+  Value val_duration(printed_duration, document->GetAllocator());
   value->AddMember("duration", val_duration, document->GetAllocator());
 
   const string& printed_queued_duration = 
PrettyPrinter::Print(record.wait_time_ms,
       TUnit::TIME_MS);
-  Value queued_duration(printed_queued_duration.c_str(), 
document->GetAllocator());
+  Value queued_duration(printed_queued_duration, document->GetAllocator());
   value->AddMember("queued_duration", queued_duration, 
document->GetAllocator());
 
   const string& printed_mem_usage = 
PrettyPrinter::Print(record.total_peak_mem_usage,
       TUnit::BYTES);
-  Value mem_usage(printed_mem_usage.c_str(), document->GetAllocator());
+  Value mem_usage(printed_mem_usage, document->GetAllocator());
   value->AddMember("mem_usage", mem_usage, document->GetAllocator());
 
   const string& printed_mem_est = PrettyPrinter::Print(record.cluster_mem_est,
       TUnit::BYTES);
-  Value mem_est(printed_mem_est.c_str(), document->GetAllocator());
+  Value mem_est(printed_mem_est, document->GetAllocator());
   value->AddMember("mem_est", mem_est, document->GetAllocator());
 
   string progress = "N/A";
@@ -607,32 +607,32 @@ void ImpalaHttpHandler::QueryStateToJson(const 
QueryStateRecord& record,
     query_progress = ProgressToString(record.num_completed_fragment_instances,
         record.total_fragment_instances);
   }
-  Value progress_json(progress.c_str(), document->GetAllocator());
+  Value progress_json(progress, document->GetAllocator());
   value->AddMember("progress", progress_json, document->GetAllocator());
 
-  Value query_progress_json(query_progress.c_str(), document->GetAllocator());
+  Value query_progress_json(query_progress, document->GetAllocator());
   value->AddMember("query_progress", query_progress_json, 
document->GetAllocator());
 
   const string& printed_bytes_read = PrettyPrinter::Print(record.bytes_read,
       TUnit::BYTES);
-  Value bytes_read(printed_bytes_read.c_str(), document->GetAllocator());
+  Value bytes_read(printed_bytes_read, document->GetAllocator());
   value->AddMember("bytes_read", bytes_read, document->GetAllocator());
 
   const string& printed_bytes_sent = PrettyPrinter::Print(record.bytes_sent,
       TUnit::BYTES);
-  Value bytes_sent(printed_bytes_sent.c_str(), document->GetAllocator());
+  Value bytes_sent(printed_bytes_sent, document->GetAllocator());
   value->AddMember("bytes_sent", bytes_sent, document->GetAllocator());
 
-  Value state(record.query_state.c_str(), document->GetAllocator());
+  Value state(record.query_state, document->GetAllocator());
   value->AddMember("state", state, document->GetAllocator());
 
   value->AddMember("rows_fetched", record.num_rows_fetched, 
document->GetAllocator());
 
-  Value query_id(PrintId(record.id).c_str(), document->GetAllocator());
+  Value query_id(PrintId(record.id), document->GetAllocator());
   value->AddMember("query_id", query_id, document->GetAllocator());
 
   if (record.event_sequence.labels.size() > 0) {
-    Value last_event(record.event_sequence.labels.back().c_str(),
+    Value last_event(record.event_sequence.labels.back(),
         document->GetAllocator());
     value->AddMember("last_event", last_event, document->GetAllocator());
   }
@@ -648,11 +648,10 @@ void ImpalaHttpHandler::QueryStateToJson(const 
QueryStateRecord& record,
   if (waiting_time > 0) {
     waiting_time_str = PrettyPrinter::Print(waiting_time, TUnit::TIME_MS);
   }
-  Value val_waiting_time(waiting_time_str.c_str(), document->GetAllocator());
+  Value val_waiting_time(waiting_time_str, document->GetAllocator());
   value->AddMember("waiting_time", val_waiting_time, document->GetAllocator());
 
-  Value resource_pool(record.resource_pool.c_str(), document->GetAllocator());
-  value->AddMember("resource_pool", resource_pool, document->GetAllocator());
+  value->AddMember("resource_pool", record.resource_pool, 
document->GetAllocator());
 
   value->AddMember(
       "coordinator_slots", record.coordinator_slots, document->GetAllocator());
@@ -723,10 +722,10 @@ void ImpalaHttpHandler::QueryStateHandler(const 
Webserver::WebRequest& req,
     for (const ImpalaServer::QueryLocations::value_type& location :
         server_->query_locations_) {
       Value location_json(kObjectType);
-      Value 
location_name(NetworkAddressPBToString(location.second.address).c_str(),
+      Value location_name(NetworkAddressPBToString(location.second.address),
           document->GetAllocator());
       location_json.AddMember("location", location_name, 
document->GetAllocator());
-      Value backend_id_str(PrintId(location.first).c_str(), 
document->GetAllocator());
+      Value backend_id_str(PrintId(location.first), document->GetAllocator());
       location_json.AddMember("backend_id", backend_id_str, 
document->GetAllocator());
       location_json.AddMember("count",
           static_cast<uint64_t>(location.second.query_ids.size()),
@@ -762,7 +761,7 @@ void ImpalaHttpHandler::FillSessionsInfo(Document* 
document) {
       server_->session_state_map_) {
     shared_ptr<ImpalaServer::SessionState> state = session.second;
     Value session_json(kObjectType);
-    Value type(PrintValue(state->session_type).c_str(), 
document->GetAllocator());
+    Value type(PrintValue(state->session_type), document->GetAllocator());
     session_json.AddMember("type", type, document->GetAllocator());
 
     session_json.AddMember("inflight_queries",
@@ -771,30 +770,30 @@ void ImpalaHttpHandler::FillSessionsInfo(Document* 
document) {
     session_json.AddMember("total_queries", state->total_queries,
         document->GetAllocator());
 
-    Value user(state->connected_user.c_str(), document->GetAllocator());
+    Value user(state->connected_user, document->GetAllocator());
     session_json.AddMember("user", user, document->GetAllocator());
 
-    Value delegated_user(state->do_as_user.c_str(), document->GetAllocator());
+    Value delegated_user(state->do_as_user, document->GetAllocator());
     session_json.AddMember("delegated_user", delegated_user, 
document->GetAllocator());
 
-    Value session_id(PrintId(session.first).c_str(), document->GetAllocator());
+    Value session_id(PrintId(session.first), document->GetAllocator());
     session_json.AddMember("session_id", session_id, document->GetAllocator());
 
-    Value connection_ids(PrintIdSet(state->connections, "\n").c_str(),
+    Value connection_ids(PrintIdSet(state->connections, "\n"),
         document->GetAllocator());
     session_json.AddMember("connection_ids", connection_ids, 
document->GetAllocator());
 
-    Value default_db(state->database.c_str(), document->GetAllocator());
+    Value default_db(state->database, document->GetAllocator());
     session_json.AddMember("default_database", default_db, 
document->GetAllocator());
 
     Value start_time(ToStringFromUnixMillis(session.second->start_time_ms,
-        TimePrecision::Second).c_str(), document->GetAllocator());
+        TimePrecision::Second), document->GetAllocator());
     session_json.AddMember("start_time", start_time, document->GetAllocator());
     session_json.AddMember(
         "start_time_sort", session.second->start_time_ms, 
document->GetAllocator());
 
     Value 
last_accessed(ToStringFromUnixMillis(session.second->last_accessed_ms,
-        TimePrecision::Second).c_str(), document->GetAllocator());
+        TimePrecision::Second), document->GetAllocator());
     session_json.AddMember("last_accessed", last_accessed, 
document->GetAllocator());
     session_json.AddMember(
         "last_accessed_sort", session.second->last_accessed_ms, 
document->GetAllocator());
@@ -830,7 +829,7 @@ void ImpalaHttpHandler::FillUsersInfo(Document* document) {
       const string& name = it.first;
       const int64& session_count = it.second;
       Value users_json(kObjectType);
-      Value user_name(name.c_str(), document->GetAllocator());
+      Value user_name(name, document->GetAllocator());
       users_json.AddMember("user", user_name, document->GetAllocator());
       users_json.AddMember("session_count", session_count, 
document->GetAllocator());
       users.PushBack(users_json, document->GetAllocator());
@@ -864,7 +863,7 @@ void ImpalaHttpHandler::FillClientHostsInfo(
     int64_t total_queries = 0;
     std::set<TUniqueId> connection_ids = pair.second;
     total_connections += connection_ids.size();
-    Value hostname(pair.first.c_str(), document->GetAllocator());
+    Value hostname(pair.first, document->GetAllocator());
     client_host_json.AddMember("hostname", hostname, document->GetAllocator());
     for (const TUniqueId& connection_id : connection_ids) {
       ImpalaServer::ConnectionToSessionMap::iterator it =
@@ -932,26 +931,26 @@ void ImpalaHttpHandler::FillConnectionsInfo(
         ++num_external_frontend_connections;
       }
       Value connection_json(kObjectType);
-      Value connection_id(PrintId(connection_context->connection_id).c_str(),
+      Value connection_id(PrintId(connection_context->connection_id),
           document->GetAllocator());
       connection_json.AddMember("connection_id", connection_id, 
document->GetAllocator());
 
-      Value user(connection_context->username.c_str(), 
document->GetAllocator());
+      Value user(connection_context->username, document->GetAllocator());
       connection_json.AddMember("user", user, document->GetAllocator());
 
       Value delegated_user(
-          connection_context->do_as_user.c_str(), document->GetAllocator());
+          connection_context->do_as_user, document->GetAllocator());
       connection_json.AddMember(
           "delegated_user", delegated_user, document->GetAllocator());
 
       Value network_address(
-          TNetworkAddressToString(connection_context->network_address).c_str(),
+          TNetworkAddressToString(connection_context->network_address),
           document->GetAllocator());
       connection_json.AddMember(
           "network_address", network_address, document->GetAllocator());
 
       Value server_name(
-          connection_context->server_name.c_str(), document->GetAllocator());
+          connection_context->server_name, document->GetAllocator());
       connection_json.AddMember("server_name", server_name, 
document->GetAllocator());
 
       std::set<TUniqueId> valid_session_ids;
@@ -965,7 +964,7 @@ void ImpalaHttpHandler::FillConnectionsInfo(
             valid_session_ids.insert(session_id);
         }
       }
-      Value session_ids_str(PrintIdSet(valid_session_ids, "\n").c_str(),
+      Value session_ids_str(PrintIdSet(valid_session_ids, "\n"),
           document->GetAllocator());
       connection_json.AddMember("session_ids", session_ids_str, 
document->GetAllocator());
       connections.PushBack(connection_json, document->GetAllocator());
@@ -989,7 +988,7 @@ void ImpalaHttpHandler::CatalogHandler(const 
Webserver::WebRequest& req,
   TGetDbsResult get_dbs_result;
   Status status = server_->exec_env_->frontend()->GetDbs(NULL, NULL, 
&get_dbs_result);
   if (!status.ok()) {
-    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    Value error(status.GetDetail(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
     return;
   }
@@ -997,14 +996,14 @@ void ImpalaHttpHandler::CatalogHandler(const 
Webserver::WebRequest& req,
   Value databases(kArrayType);
   for (const TDatabase& db: get_dbs_result.dbs) {
     Value database(kObjectType);
-    Value str(db.db_name.c_str(), document->GetAllocator());
+    Value str(db.db_name, document->GetAllocator());
     database.AddMember("name", str, document->GetAllocator());
 
     TGetTablesResult get_table_results;
     status = server_->exec_env_->frontend()->GetTableNames(
         db.db_name, nullptr, nullptr, &get_table_results);
     if (!status.ok()) {
-      Value error(status.GetDetail().c_str(), document->GetAllocator());
+      Value error(status.GetDetail(), document->GetAllocator());
       database.AddMember("error", error, document->GetAllocator());
       continue;
     }
@@ -1014,11 +1013,11 @@ void ImpalaHttpHandler::CatalogHandler(const 
Webserver::WebRequest& req,
       Value table_obj(kObjectType);
       if(!FLAGS_use_local_catalog){
         // Creates hyperlinks for /catalog_object. This is disabled in local 
catalog mode
-        Value fq_name(Substitute("$0.$1", db.db_name, table).c_str(),
+        Value fq_name(Substitute("$0.$1", db.db_name, table),
             document->GetAllocator());
         table_obj.AddMember("fqtn", fq_name, document->GetAllocator());
       }
-      Value table_name(table.c_str(), document->GetAllocator());
+      Value table_name(table, document->GetAllocator());
       table_obj.AddMember("name", table_name, document->GetAllocator());
       table_array.PushBack(table_obj, document->GetAllocator());
     }
@@ -1051,10 +1050,10 @@ void ImpalaHttpHandler::CatalogObjectsHandler(const 
Webserver::WebRequest& req,
       status = server_->exec_env_->frontend()->GetCatalogObject(request, 
&result);
     }
     if (status.ok()) {
-      Value debug_string(ThriftDebugString(result).c_str(), 
document->GetAllocator());
+      Value debug_string(ThriftDebugString(result), document->GetAllocator());
       document->AddMember("thrift_string", debug_string, 
document->GetAllocator());
     } else {
-      Value error(status.GetDetail().c_str(), document->GetAllocator());
+      Value error(status.GetDetail(), document->GetAllocator());
       document->AddMember("error", error, document->GetAllocator());
     }
   } else {
@@ -1074,10 +1073,10 @@ void PlanToJsonHelper(const map<TPlanNodeId, 
TPlanNodeExecSummary>& summaries,
     const vector<TPlanNode>& nodes,
     vector<TPlanNode>::const_iterator* it, rapidjson::Document* document, 
Value* value) {
   Value children(kArrayType);
-  Value label((*it)->label.c_str(), document->GetAllocator());
+  Value label((*it)->label, document->GetAllocator());
   value->AddMember("label", label, document->GetAllocator());
   // Node "details" may contain exprs which should be redacted.
-  Value label_detail(RedactCopy((*it)->label_detail).c_str(), 
document->GetAllocator());
+  Value label_detail(RedactCopy((*it)->label_detail), 
document->GetAllocator());
   value->AddMember("label_detail", label_detail, document->GetAllocator());
 
   TPlanNodeId id = (*it)->node_id;
@@ -1105,7 +1104,7 @@ void PlanToJsonHelper(const map<TPlanNodeId, 
TPlanNodeExecSummary>& summaries,
     }
 
     const string& max_time_str = PrettyPrinter::Print(max_time, 
TUnit::TIME_NS);
-    Value max_time_str_json(max_time_str.c_str(), document->GetAllocator());
+    Value max_time_str_json(max_time_str, document->GetAllocator());
     value->AddMember("max_time", max_time_str_json, document->GetAllocator());
     value->AddMember("max_time_val", max_time, document->GetAllocator());
 
@@ -1115,7 +1114,7 @@ void PlanToJsonHelper(const map<TPlanNodeId, 
TPlanNodeExecSummary>& summaries,
         // A bug may occasionally cause 1-instance nodes to appear to have 0 
instances.
         total_time / 
::max(static_cast<int>(summary->second.exec_stats.size()), 1),
         TUnit::TIME_NS);
-    Value avg_time_str_json(avg_time_str.c_str(), document->GetAllocator());
+    Value avg_time_str_json(avg_time_str, document->GetAllocator());
     value->AddMember("avg_time", avg_time_str_json, document->GetAllocator());
   }
 
@@ -1178,11 +1177,11 @@ void PlanToJson(const vector<TPlanFragment>& fragments, 
const TExecSummary& summ
     if (fragment.__isset.output_sink) {
       const TDataSink& sink = fragment.output_sink;
       if (sink.__isset.stream_sink) {
-        Value target(label_map[sink.stream_sink.dest_node_id].c_str(),
+        Value target(label_map[sink.stream_sink.dest_node_id],
             document->GetAllocator());
         plan_fragment.AddMember("data_stream_target", target, 
document->GetAllocator());
       } else if (sink.__isset.join_build_sink) {
-        Value target(label_map[sink.join_build_sink.dest_node_id].c_str(),
+        Value target(label_map[sink.join_build_sink.dest_node_id],
             document->GetAllocator());
         plan_fragment.AddMember("join_build_target", target, 
document->GetAllocator());
       }
@@ -1198,11 +1197,11 @@ void ImpalaHttpHandler::QueryBackendsHandler(
     const Webserver::WebRequest& req, Document* document) {
   TUniqueId query_id;
   Status status = ParseIdFromRequest(req, &query_id, "query_id");
-  Value query_id_val(PrintId(query_id).c_str(), document->GetAllocator());
+  Value query_id_val(PrintId(query_id), document->GetAllocator());
   document->AddMember("query_id", query_id_val, document->GetAllocator());
   if (!status.ok()) {
     // Redact the error message, it may contain part or all of the query.
-    Value json_error(RedactCopy(status.GetDetail()).c_str(), 
document->GetAllocator());
+    Value json_error(RedactCopy(status.GetDetail()), document->GetAllocator());
     document->AddMember("error", json_error, document->GetAllocator());
     return;
   }
@@ -1223,11 +1222,11 @@ void ImpalaHttpHandler::QueryFInstancesHandler(
     const Webserver::WebRequest& req, Document* document) {
   TUniqueId query_id;
   Status status = ParseIdFromRequest(req, &query_id, "query_id");
-  Value query_id_val(PrintId(query_id).c_str(), document->GetAllocator());
+  Value query_id_val(PrintId(query_id), document->GetAllocator());
   document->AddMember("query_id", query_id_val, document->GetAllocator());
   if (!status.ok()) {
     // Redact the error message, it may contain part or all of the query.
-    Value json_error(RedactCopy(status.GetDetail()).c_str(), 
document->GetAllocator());
+    Value json_error(RedactCopy(status.GetDetail()), document->GetAllocator());
     document->AddMember("error", json_error, document->GetAllocator());
     return;
   }
@@ -1248,11 +1247,11 @@ void ImpalaHttpHandler::QuerySummaryHandler(bool 
include_json_plan, bool include
     const Webserver::WebRequest& req, Document* document) {
   TUniqueId query_id;
   Status status = ParseIdFromRequest(req, &query_id, "query_id");
-  Value query_id_val(PrintId(query_id).c_str(), document->GetAllocator());
+  Value query_id_val(PrintId(query_id), document->GetAllocator());
   document->AddMember("query_id", query_id_val, document->GetAllocator());
   if (!status.ok()) {
     // Redact the error message, it may contain part or all of the query.
-    Value json_error(RedactCopy(status.GetDetail()).c_str(), 
document->GetAllocator());
+    Value json_error(RedactCopy(status.GetDetail()), document->GetAllocator());
     document->AddMember("error", json_error, document->GetAllocator());
     return;
   }
@@ -1304,7 +1303,7 @@ void ImpalaHttpHandler::QuerySummaryHandler(bool 
include_json_plan, bool include
   if (!inflight) {
     if (!server_->GetQueryRecord(query_id, &query_record).ok()) {
       const string& err = Substitute("Unknown query id: $0", 
PrintId(query_id));
-      Value json_error(err.c_str(), document->GetAllocator());
+      Value json_error(err, document->GetAllocator());
       document->AddMember("error", json_error, document->GetAllocator());
       return;
     }
@@ -1326,14 +1325,14 @@ void ImpalaHttpHandler::QuerySummaryHandler(bool 
include_json_plan, bool include
   }
   if (include_summary) {
     const string& printed_summary = PrintExecSummary(summary);
-    Value json_summary(printed_summary.c_str(), document->GetAllocator());
+    Value json_summary(printed_summary, document->GetAllocator());
     document->AddMember("summary", json_summary, document->GetAllocator());
-    Value json_timeline(query_record->timeline.c_str(), 
document->GetAllocator());
+    Value json_timeline(query_record->timeline, document->GetAllocator());
     document->AddMember("timeline", json_timeline, document->GetAllocator());
   }
-  Value json_stmt(RedactCopy(stmt).c_str(), document->GetAllocator());
+  Value json_stmt(RedactCopy(stmt), document->GetAllocator());
   document->AddMember("stmt", json_stmt, document->GetAllocator());
-  Value json_plan_text(RedactCopy(plan).c_str(), document->GetAllocator());
+  Value json_plan_text(RedactCopy(plan), document->GetAllocator());
   document->AddMember("plan", json_plan_text, document->GetAllocator());
   Value json_inflight(inflight);
   document->AddMember("inflight", json_inflight, document->GetAllocator());
@@ -1342,7 +1341,7 @@ void ImpalaHttpHandler::QuerySummaryHandler(bool 
include_json_plan, bool include
 
   // Redact the error in case the query is contained in the error message.
   Value json_status(query_status.ok() ? "OK" :
-      RedactCopy(query_status.GetDetail()).c_str(), document->GetAllocator());
+      RedactCopy(query_status.GetDetail()), document->GetAllocator());
   document->AddMember("status", json_status, document->GetAllocator());
 
   AddQueryRecordTips(document);
@@ -1369,17 +1368,17 @@ void ImpalaHttpHandler::BackendsHandler(const 
Webserver::WebRequest& req,
     BackendDescriptorPB backend = entry.second;
     Value backend_obj(kObjectType);
     string address = NetworkAddressPBToString(backend.address());
-    Value str(address.c_str(), document->GetAllocator());
-    Value 
krpc_address(NetworkAddressPBToString(backend.krpc_address()).c_str(),
+    Value str(address, document->GetAllocator());
+    Value krpc_address(NetworkAddressPBToString(backend.krpc_address()),
         document->GetAllocator());
     backend_obj.AddMember("address", str, document->GetAllocator());
     backend_obj.AddMember("krpc_address", krpc_address, 
document->GetAllocator());
-    Value backend_id_str(PrintId(backend.backend_id()).c_str(), 
document->GetAllocator());
+    Value backend_id_str(PrintId(backend.backend_id()), 
document->GetAllocator());
     backend_obj.AddMember("backend_id", backend_id_str, 
document->GetAllocator());
     string webserver_url =
         Substitute("$0://$1", backend.secure_webserver() ? "https" : "http",
             NetworkAddressPBToString(backend.debug_http_address()));
-    Value webserver_url_val(webserver_url.c_str(), document->GetAllocator());
+    Value webserver_url_val(webserver_url, document->GetAllocator());
     backend_obj.AddMember("webserver_url", webserver_url_val, 
document->GetAllocator());
     backend_obj.AddMember(
         "is_coordinator", backend.is_coordinator(), document->GetAllocator());
@@ -1399,11 +1398,11 @@ void ImpalaHttpHandler::BackendsHandler(const 
Webserver::WebRequest& req,
       ++num_quiescing_backends;
     } else if (is_blacklisted) {
       Value blacklist_cause_value(
-          blacklist_cause.GetDetail().c_str(), document->GetAllocator());
+          blacklist_cause.GetDetail(), document->GetAllocator());
       backend_obj.AddMember(
           "blacklist_cause", blacklist_cause_value, document->GetAllocator());
       Value blacklist_time_remaining_str(
-          Substitute("$0 s", (blacklist_time_remaining_ms / 1000)).c_str(),
+          Substitute("$0 s", (blacklist_time_remaining_ms / 1000)),
           document->GetAllocator());
       backend_obj.AddMember("blacklist_time_remaining", 
blacklist_time_remaining_str,
           document->GetAllocator());
@@ -1411,16 +1410,16 @@ void ImpalaHttpHandler::BackendsHandler(const 
Webserver::WebRequest& req,
     } else {
       ++num_active_backends;
     }
-    Value 
admit_mem_limit(PrettyPrinter::PrintBytes(backend.admit_mem_limit()).c_str(),
+    Value admit_mem_limit(PrettyPrinter::PrintBytes(backend.admit_mem_limit()),
         document->GetAllocator());
     backend_obj.AddMember("admit_mem_limit", admit_mem_limit, 
document->GetAllocator());
     // If the host address does not exist in the 'host_stats', this would 
ensure that a
     // value of zero is used for those addresses.
     Value mem_reserved(PrettyPrinter::PrintBytes(
-        host_stats[address].mem_reserved).c_str(), document->GetAllocator());
+        host_stats[address].mem_reserved), document->GetAllocator());
     backend_obj.AddMember("mem_reserved", mem_reserved, 
document->GetAllocator());
     Value mem_admitted(PrettyPrinter::PrintBytes(
-        host_stats[address].mem_admitted).c_str(), document->GetAllocator());
+        host_stats[address].mem_admitted), document->GetAllocator());
     backend_obj.AddMember("mem_admitted", mem_admitted, 
document->GetAllocator());
     backend_obj.AddMember(
         "admission_slots", backend.admission_slots(), 
document->GetAllocator());
@@ -1432,12 +1431,12 @@ void ImpalaHttpHandler::BackendsHandler(const 
Webserver::WebRequest& req,
     for (const auto& group : backend.executor_groups()) {
       group_names.push_back(group.name());
     }
-    Value executor_groups(JoinStrings(group_names, ", ").c_str(),
+    Value executor_groups(JoinStrings(group_names, ", "),
         document->GetAllocator());
     backend_obj.AddMember("executor_groups", executor_groups, 
document->GetAllocator());
-    Value start_time_val(backend.process_start_time().c_str(), 
document->GetAllocator());
+    Value start_time_val(backend.process_start_time(), 
document->GetAllocator());
     backend_obj.AddMember("process_start_time", start_time_val, 
document->GetAllocator());
-    Value version_val(backend.version().c_str(), document->GetAllocator());
+    Value version_val(backend.version(), document->GetAllocator());
     backend_obj.AddMember("version", version_val, document->GetAllocator());
     backends_list.PushBack(backend_obj, document->GetAllocator());
   }
@@ -1532,7 +1531,7 @@ void ImpalaHttpHandler::AdmissionStateHandler(
     Value queries_in_pool(rapidjson::kArrayType);
     for (QueryInfo info : info_array) {
       Value query_info(rapidjson::kObjectType);
-      Value query_id(PrintId(info.query_id).c_str(), document->GetAllocator());
+      Value query_id(PrintId(info.query_id), document->GetAllocator());
       query_info.AddMember("query_id", query_id, document->GetAllocator());
       query_info.AddMember(
           "mem_limit", info.executor_mem_limit, document->GetAllocator());
@@ -1565,7 +1564,7 @@ void ImpalaHttpHandler::AdmissionStateHandler(
   document->AddMember("statestore_admission_control_time_since_last_update_ms",
       ms_since_last_statestore_update, document->GetAllocator());
   if (!staleness_detail.empty()) {
-    Value staleness_detail_json(staleness_detail.c_str(), 
document->GetAllocator());
+    Value staleness_detail_json(staleness_detail, document->GetAllocator());
     document->AddMember("statestore_update_staleness_detail", 
staleness_detail_json,
         document->GetAllocator());
   }
diff --git a/be/src/util/json-util.cc b/be/src/util/json-util.cc
index eae1dae57..23783ab37 100644
--- a/be/src/util/json-util.cc
+++ b/be/src/util/json-util.cc
@@ -71,7 +71,7 @@ static void RepeatedFieldToJson(const 
google::protobuf::Message& pb,
         arr.PushBack(reflection->GetRepeatedBool(pb, field, i), 
document->GetAllocator());
         break;
       case google::protobuf::FieldDescriptor::CPPTYPE_ENUM: {
-        Value enum_str(reflection->GetRepeatedEnum(pb, field, 
i)->name().c_str(),
+        Value enum_str(reflection->GetRepeatedEnum(pb, field, i)->name(),
             document->GetAllocator());
         arr.PushBack(enum_str, document->GetAllocator());
         break;
@@ -79,7 +79,7 @@ static void RepeatedFieldToJson(const 
google::protobuf::Message& pb,
       case google::protobuf::FieldDescriptor::CPPTYPE_STRING: {
         string str = reflection->GetRepeatedString(pb, field, i);
         Redact(&str, nullptr);
-        Value val_str(str.c_str(), document->GetAllocator());
+        Value val_str(str, document->GetAllocator());
         arr.PushBack(val_str, document->GetAllocator());
         break;
       }
@@ -94,7 +94,7 @@ static void RepeatedFieldToJson(const 
google::protobuf::Message& pb,
         DCHECK(false) << "Type NYI: " << field->cpp_type() << " " << 
field->name();
     }
   }
-  Value field_name(field->name().c_str(), document->GetAllocator());
+  Value field_name(field->name(), document->GetAllocator());
   obj->AddMember(field_name, arr, document->GetAllocator());
 }
 
@@ -107,7 +107,7 @@ void ProtobufToJson(const google::protobuf::Message& pb, 
Document* document, Val
       RepeatedFieldToJson(pb, reflection, field, document, obj);
       continue;
     }
-    Value field_name(field->name().c_str(), document->GetAllocator());
+    Value field_name(field->name(), document->GetAllocator());
     switch (field->cpp_type()) {
       case google::protobuf::FieldDescriptor::CPPTYPE_INT32:
         obj->AddMember(
@@ -139,14 +139,14 @@ void ProtobufToJson(const google::protobuf::Message& pb, 
Document* document, Val
         break;
       case google::protobuf::FieldDescriptor::CPPTYPE_ENUM: {
         Value enum_str(
-            reflection->GetEnum(pb, field)->name().c_str(), 
document->GetAllocator());
+            reflection->GetEnum(pb, field)->name(), document->GetAllocator());
         obj->AddMember(field_name, enum_str, document->GetAllocator());
         break;
       }
       case google::protobuf::FieldDescriptor::CPPTYPE_STRING: {
         string str = reflection->GetString(pb, field);
         Redact(&str, nullptr);
-        Value val_str(str.c_str(), document->GetAllocator());
+        Value val_str(str, document->GetAllocator());
         obj->AddMember(field_name, val_str, document->GetAllocator());
         break;
       }
diff --git a/be/src/util/json-util.h b/be/src/util/json-util.h
index cbccb7b04..d53473249 100644
--- a/be/src/util/json-util.h
+++ b/be/src/util/json-util.h
@@ -91,7 +91,7 @@ struct JsonObjWrapper {
 
 template<>
 inline void JsonObjWrapper::AddMember(const char* name, const std::string& 
val) {
-  rapidjson::Value field(val.c_str(), allocator);
+  rapidjson::Value field(val, allocator);
   value.AddMember(rapidjson::StringRef(name), field, allocator);
 }
 
diff --git a/be/src/util/jwt-util.cc b/be/src/util/jwt-util.cc
index 8843790de..fd2f25cd3 100644
--- a/be/src/util/jwt-util.cc
+++ b/be/src/util/jwt-util.cc
@@ -149,7 +149,7 @@ class JWKSetParser {
          member != json_key.MemberEnd(); ++member) {
       string k, v, values[MAX_X5C_CERTIFICATES];
       k = string(member->name.GetString());
-      const Value& json_value = json_key[k.c_str()];
+      const Value& json_value = json_key[k];
       if (NameOfTypeOfJsonValue(json_value) == ARRAY_TYPE) {
         RETURN_IF_ERROR(ReadKeyArrayProperty(k.c_str(), json_key, values,
             /*required*/ false));
@@ -203,7 +203,7 @@ class JWKSetParser {
   template <typename T>
   Status ReadKeyProperty(
       const string& name, const Value& json_key, T* value, bool required = 
true) {
-    const Value& json_value = json_key[name.c_str()];
+    const Value& json_value = json_key[name];
     if (json_value.IsNull()) {
       if (required) {
         return Status(Substitute("'$0' property is required and cannot be 
null", name));
@@ -219,7 +219,7 @@ class JWKSetParser {
   template <typename T>
   Status ReadKeyArrayProperty(
       const string& name, const Value& json_key, T* value, bool required = 
true) {
-    const Value& json_value = json_key[name.c_str()];
+    const Value& json_value = json_key[name];
     if (json_value.IsNull()) {
       if (required) {
         return Status(Substitute("'$0' property is required and cannot be 
null", name));
diff --git a/be/src/util/lineage-util.h b/be/src/util/lineage-util.h
index 3382d0340..80a77af5f 100644
--- a/be/src/util/lineage-util.h
+++ b/be/src/util/lineage-util.h
@@ -41,14 +41,14 @@ class LineageUtil {
       writer->String("vertexType");
       writer->String("COLUMN");
       writer->String("vertexId");
-      writer->String(vertex.label.c_str());
+      writer->String(vertex.label);
       if (vertex.__isset.metadata) {
         writer->String("metadata");
         writer->StartObject();
         writer->String("tableName");
-        writer->String(vertex.metadata.table_name.c_str());
+        writer->String(vertex.metadata.table_name);
         writer->String("tableType");
-        writer->String(vertex.metadata.table_type.c_str());
+        writer->String(vertex.metadata.table_type);
         writer->String("tableCreateTime");
         writer->Int64(vertex.metadata.table_create_time);
         writer->EndObject();
@@ -78,7 +78,7 @@ class LineageUtil {
       writer->String("edgeType");
       string edge_type =
           (obj.edgetype == TEdgeType::PROJECTION) ? "PROJECTION" : "PREDICATE";
-      writer->String(edge_type.c_str());
+      writer->String(edge_type);
       writer->EndObject();
     }
 
@@ -89,13 +89,13 @@ class LineageUtil {
       rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
       writer.StartObject();
       writer.String("queryText");
-      writer.String(lineage.query_text.c_str());
+      writer.String(lineage.query_text);
       writer.String("queryId");
-      writer.String(PrintId(lineage.query_id).c_str());
+      writer.String(PrintId(lineage.query_id));
       writer.String("hash");
-      writer.String(lineage.hash.c_str());
+      writer.String(lineage.hash);
       writer.String("user");
-      writer.String(lineage.user.c_str());
+      writer.String(lineage.user);
       // write query start time
       writer.String("timestamp");
       writer.Int64(lineage.started);
@@ -120,7 +120,7 @@ class LineageUtil {
       // Write location if it is available.
       if (lineage.__isset.table_location) {
         writer.String("tableLocation");
-        writer.String(lineage.table_location.c_str());
+        writer.String(lineage.table_location);
       }
       writer.EndObject();
       *out = buffer.GetString();
diff --git a/be/src/util/logging-support.cc b/be/src/util/logging-support.cc
index c10e1ded2..e0ef057ba 100644
--- a/be/src/util/logging-support.cc
+++ b/be/src/util/logging-support.cc
@@ -94,7 +94,7 @@ static jmethodID reset_log_levels_method; // 
GlogAppender.resetLogLevels()
 void AddDocumentMember(const string& message, const char* member,
     Document* document) {
   Value key(member, document->GetAllocator());
-  Value output(message.c_str(), document->GetAllocator());
+  Value output(message, document->GetAllocator());
   document->AddMember(key, output, document->GetAllocator());
 }
 
diff --git a/be/src/util/metrics.cc b/be/src/util/metrics.cc
index 13e836d82..10fa83da6 100644
--- a/be/src/util/metrics.cc
+++ b/be/src/util/metrics.cc
@@ -45,16 +45,16 @@ namespace impala {
 template <>
 void ToJsonValue<string>(const string& value, const TUnit::type unit,
     Document* document, Value* out_val) {
-  Value val(value.c_str(), document->GetAllocator());
+  Value val(value, document->GetAllocator());
   *out_val = val;
 }
 
 void Metric::AddStandardFields(Document* document, Value* val) {
-  Value name(key_.c_str(), document->GetAllocator());
+  Value name(key_, document->GetAllocator());
   val->AddMember("name", name, document->GetAllocator());
-  Value desc(description_.c_str(), document->GetAllocator());
+  Value desc(description_, document->GetAllocator());
   val->AddMember("description", desc, document->GetAllocator());
-  Value metric_value(ToHumanReadable().c_str(), document->GetAllocator());
+  Value metric_value(ToHumanReadable(), document->GetAllocator());
   val->AddMember("human_readable", metric_value, document->GetAllocator());
 }
 
@@ -67,9 +67,9 @@ void ScalarMetric<T, metric_kind_t>::ToJson(Document* 
document, Value* val) {
   ToJsonValue(GetValue(), TUnit::NONE, document, &metric_value);
   container.AddMember("value", metric_value, document->GetAllocator());
 
-  Value type_value(PrintValue(kind()).c_str(), document->GetAllocator());
+  Value type_value(PrintValue(kind()), document->GetAllocator());
   container.AddMember("kind", type_value, document->GetAllocator());
-  Value units(PrintValue(unit()).c_str(), document->GetAllocator());
+  Value units(PrintValue(unit()), document->GetAllocator());
   container.AddMember("units", units, document->GetAllocator());
   *val = container;
 }
@@ -78,14 +78,14 @@ template <typename T, TMetricKind::type metric_kind_t>
 void ScalarMetric<T, metric_kind_t>::ToLegacyJson(Document* document) {
   Value val;
   ToJsonValue(GetValue(), TUnit::NONE, document, &val);
-  Value key(key_.c_str(), document->GetAllocator());
+  Value key(key_, document->GetAllocator());
   document->AddMember(key, val, document->GetAllocator());
 }
 
 template <typename T, TMetricKind::type metric_kind_t>
 TMetricKind::type ScalarMetric<T, metric_kind_t>::ToPrometheus(
     string name, stringstream* val, stringstream* metric_kind) {
-  string metric_type = PrintValue(kind()).c_str();
+  string metric_type = PrintValue(kind());
   // prometheus doesn't support 'property', so ignore it
   if (!metric_type.compare("property")) {
     return TMetricKind::PROPERTY;
@@ -240,7 +240,7 @@ void MetricGroup::TemplateCallback(const 
Webserver::WebRequest& req,
     found_group->ToJson(false, document, &container);
     document->AddMember("metric_group", container, document->GetAllocator());
   } else {
-    Value error(Substitute("Metric group $0 not found", 
metric_group->second).c_str(),
+    Value error(Substitute("Metric group $0 not found", metric_group->second),
         document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
   }
@@ -270,7 +270,7 @@ void MetricGroup::ToJson(bool include_children, Document* 
document, Value* out_v
 
   Value container(kObjectType);
   container.AddMember("metrics", metric_list, document->GetAllocator());
-  Value name(name_.c_str(), document->GetAllocator());
+  Value name(name_, document->GetAllocator());
   container.AddMember("name", name, document->GetAllocator());
   if (include_children) {
     Value child_groups(kArrayType);
diff --git a/be/src/util/redactor.cc b/be/src/util/redactor.cc
index cbdff4400..866c5c64f 100644
--- a/be/src/util/redactor.cc
+++ b/be/src/util/redactor.cc
@@ -172,7 +172,7 @@ class RulesParser {
   template<typename T>
   bool ReadRuleProperty(const string& name, const Value& rule, T* value,
       bool required = true) {
-    const Value& json_value = rule[name.c_str()];
+    const Value& json_value = rule[name];
     if (json_value.IsNull()) {
       if (required) {
         AddRuleParseError() << name << " property is required and cannot be 
null";
diff --git a/be/src/util/runtime-profile.cc b/be/src/util/runtime-profile.cc
index f36c7a42e..ca9b511c3 100644
--- a/be/src/util/runtime-profile.cc
+++ b/be/src/util/runtime-profile.cc
@@ -1303,8 +1303,7 @@ void RuntimeProfileBase::ToJsonCounters(Verbosity 
verbosity, Value* parent, Docu
 
       Value counter(kObjectType);
       iter->second->ToJson(verbosity, *d, &counter);
-      Value child_counter_json(child_counter.c_str(), child_counter.size(), 
allocator);
-      counter.AddMember("counter_name", child_counter_json, allocator);
+      counter.AddMember("counter_name", child_counter, allocator);
 
       Value child_counters_json(kArrayType);
       ToJsonCounters(verbosity, &child_counters_json, d, child_counter, 
counter_map,
@@ -1331,8 +1330,7 @@ void RuntimeProfileBase::ToJsonHelper(
   }
 
   // 1. Name
-  Value name(name_.c_str(), allocator);
-  parent->AddMember("profile_name", name, allocator);
+  parent->AddMember("profile_name", name_, allocator);
 
   // 2. Num_children
   parent->AddMember("num_children", children_.size(), allocator);
@@ -1357,12 +1355,10 @@ void RuntimeProfileBase::ToJsonHelper(
       Value info_strings_json(kArrayType);
       for (const string& key : info_strings_display_order_) {
         Value info_string_json(kObjectType);
-        Value key_json(key.c_str(), allocator);
         auto value_itr = info_strings_.find(key);
         DCHECK(value_itr != info_strings_.end());
-        Value value_json(value_itr->second.c_str(), allocator);
-        info_string_json.AddMember("key", key_json, allocator);
-        info_string_json.AddMember("value", value_json, allocator);
+        info_string_json.AddMember("key", key, allocator);
+        info_string_json.AddMember("value", value_itr->second, allocator);
         info_strings_json.PushBack(info_string_json, allocator);
       }
       parent->AddMember("info_strings", info_strings_json, allocator);
@@ -1443,7 +1439,7 @@ void RuntimeProfile::ToJsonSubclass(
       Value summary_stats_counters_json(kArrayType);
       for (const SummaryStatsCounterMap::value_type& v : summary_stats_map_) {
         Value summary_stats_counter(kObjectType);
-        Value summary_name_json(v.first.c_str(), v.first.size(), allocator);
+        Value summary_name_json(v.first, allocator);
         v.second->ToJson(verbosity, *d, &summary_stats_counter);
         summary_stats_counter.AddMember("counter_name", summary_name_json, 
allocator);
         summary_stats_counters_json.PushBack(summary_stats_counter, allocator);
@@ -2607,7 +2603,7 @@ void RuntimeProfile::TimeSeriesCounter::ToJson(
   lock_guard<SpinLock> lock(lock_);
   Value counter_json(kObjectType);
 
-  Value counter_name_json(name_.c_str(), name_.size(), 
document.GetAllocator());
+  Value counter_name_json(name_, document.GetAllocator());
   counter_json.AddMember("counter_name", counter_name_json, 
document.GetAllocator());
   auto unit_itr = _TUnit_VALUES_TO_NAMES.find(unit_);
   DCHECK(unit_itr != _TUnit_VALUES_TO_NAMES.end());
@@ -2630,7 +2626,7 @@ void RuntimeProfile::TimeSeriesCounter::ToJson(
     if (i + step < num) stream << ",";
   }
 
-  Value samples_data_json(stream.str().c_str(), document.GetAllocator());
+  Value samples_data_json(stream.str(), document.GetAllocator());
   counter_json.AddMember("data", samples_data_json, document.GetAllocator());
   *val = counter_json;
 }
@@ -2647,7 +2643,7 @@ void RuntimeProfile::EventSequence::ToJson(
 
   for (const Event& ev: events_) {
     Value event_json(kObjectType);
-    Value label_json(ev.first.c_str(), ev.first.size(), 
document.GetAllocator());
+    Value label_json(ev.first, document.GetAllocator());
     event_json.AddMember("label", label_json, document.GetAllocator());
     event_json.AddMember("timestamp", ev.second, document.GetAllocator());
     events_json.PushBack(event_json, document.GetAllocator());
@@ -2944,7 +2940,7 @@ void AggregatedRuntimeProfile::ToJsonSubclass(
         SummaryStatsCounter aggregated_stats(v.second.first);
         AggregateSummaryStats(v.second.second, &aggregated_stats);
         Value summary_stats_counter(kObjectType);
-        Value summary_name_json(v.first.c_str(), v.first.size(), allocator);
+        Value summary_name_json(v.first, allocator);
         aggregated_stats.ToJson(verbosity, *d, &summary_stats_counter);
         summary_stats_counter.AddMember("counter_name", summary_name_json, 
allocator);
         summary_stats_counters_json.PushBack(summary_stats_counter, allocator);
@@ -3009,7 +3005,7 @@ void 
AggregatedRuntimeProfile::AggEventSequence::ToJson(Value& event_sequence_js
   vector<Value> label_vals(events_count);
   // Index event labels with their associated value
   for (const auto& label_item : labels) {
-    label_vals[label_item.second] = Value(label_item.first.c_str(), allocator);
+    label_vals[label_item.second] = Value(label_item.first, allocator);
     // Note: The value part of 'labels' map is being used to order events 
initially.
   }
 
@@ -3174,18 +3170,17 @@ void 
AggregatedRuntimeProfile::CollectInfoStringIntoJson(const string& info_stri
   AggInfoStrings::const_iterator it = agg_info_strings_.find(info_string_name);
   if (it != agg_info_strings_.end()) {
     Value info_string_json(kObjectType);
-    Value info_string_key((info_string_name).c_str(), allocator);
     Value info_values_json(kArrayType);
 
     // Group info string values into "values" field
     map<string, vector<int32_t>> distinct_values = GroupDistinctInfoStrings(
         it->second);
     for (auto& info_value : distinct_values) {
-      info_values_json.PushBack(Value(info_value.first.c_str(), allocator),
+      info_values_json.PushBack(Value(info_value.first, allocator),
           allocator);
     }
 
-    info_string_json.AddMember("key", info_string_key, allocator);
+    info_string_json.AddMember("key", info_string_name, allocator);
     info_string_json.AddMember("values", info_values_json, allocator);
     parent->PushBack(info_string_json, allocator);
   }
diff --git a/be/src/util/webserver.cc b/be/src/util/webserver.cc
index 6c9e4abf8..13923a103 100644
--- a/be/src/util/webserver.cc
+++ b/be/src/util/webserver.cc
@@ -378,7 +378,7 @@ void Webserver::ErrorHandler(const WebRequest& req, 
Document* document) {
   ArgumentMap::const_iterator it = req.parsed_args.find(ERROR_KEY);
   if (it == req.parsed_args.end()) return;
 
-  Value error(it->second.c_str(), document->GetAllocator());
+  Value error(it->second, document->GetAllocator());
   document->AddMember("error", error, document->GetAllocator());
 }
 
@@ -602,14 +602,14 @@ void Webserver::GetCommonJson(Document* document, const 
struct sq_connection* co
     // absolute, which allows Knox to rewrite the links to point to the Knox 
host while
     // including 'scheme', 'host', and 'port' parameters which tell Knox where 
do forward
     // the request to.
-    Value url_value(url().c_str(), document->GetAllocator());
+    Value url_value(url(), document->GetAllocator());
     obj.AddMember("host-url", url_value, document->GetAllocator());
 
     // These are used to add hidden form fields when Knox is being used to add 
the 'host'
     // and related parameters to the form's request.
     Value scheme_value(IsSecure() ? "https" : "http", 
document->GetAllocator());
     obj.AddMember("scheme", scheme_value, document->GetAllocator());
-    Value hostname_value(hostname_.c_str(), document->GetAllocator());
+    Value hostname_value(hostname_, document->GetAllocator());
     obj.AddMember("hostname", hostname_value, document->GetAllocator());
     Value port_value;
     port_value.SetInt(http_address_.port);
@@ -624,8 +624,8 @@ void Webserver::GetCommonJson(Document* document, const 
struct sq_connection* co
         Value hdl(kObjectType);
         // Though we set link and title the same value, be careful with 
RapidJSON's MOVE
         // semantic. We create the values by deep-copy here.
-        Value link(handler.first.c_str(), document->GetAllocator());
-        Value title(handler.first.c_str(), document->GetAllocator());
+        Value link(handler.first, document->GetAllocator());
+        Value title(handler.first, document->GetAllocator());
         hdl.AddMember("link", link, document->GetAllocator());
         hdl.AddMember("title", title, document->GetAllocator());
         lst.PushBack(hdl, document->GetAllocator());

Reply via email to