kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danburk...@apache.org
Subject [2/3] kudu git commit: [sys_catalog] no copying into intermediate KuduPartialRow
Date Thu, 09 Mar 2017 00:00:53 GMT
[sys_catalog] no copying into intermediate KuduPartialRow

Use KuduPartialRow::SetStringNoCopy() instead of
KuduPartialRow::SetString() while setting fields for the system catalog
table.  Copying the data into the intermediate KuduPartialRow object is
not necessary: the intermediate object is not used once the data is
encoded into the result WriteRequestPB via RowOperationsPBEncoder.

Change-Id: I0dbcb822d8f85e1101846409e90e2e5af0afc4f3
Reviewed-on: http://gerrit.cloudera.org:8080/6315
Tested-by: Alexey Serbin <aserbin@cloudera.com>
Reviewed-by: David Ribeiro Alves <dralves@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/5a24fe67
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/5a24fe67
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/5a24fe67

Branch: refs/heads/master
Commit: 5a24fe6742611c71fe272b37a1fd6afcc089c998
Parents: 62553e0
Author: Alexey Serbin <aserbin@cloudera.com>
Authored: Wed Mar 8 08:09:40 2017 -0800
Committer: Alexey Serbin <aserbin@cloudera.com>
Committed: Wed Mar 8 23:16:15 2017 +0000

----------------------------------------------------------------------
 src/kudu/master/sys_catalog.cc | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/5a24fe67/src/kudu/master/sys_catalog.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/sys_catalog.cc b/src/kudu/master/sys_catalog.cc
index 1d698ff..2d54fcc 100644
--- a/src/kudu/master/sys_catalog.cc
+++ b/src/kudu/master/sys_catalog.cc
@@ -590,13 +590,12 @@ Status SysCatalogTable::AddCertAuthorityEntry(
 
   KuduPartialRow row(&schema_);
   CHECK_OK(row.SetInt8(kSysCatalogTableColType, CERT_AUTHORITY_INFO));
-  CHECK_OK(row.SetString(kSysCatalogTableColId, kSysCertAuthorityEntryId));
-  CHECK_OK(row.SetString(kSysCatalogTableColMetadata, metadata_buf));
+  CHECK_OK(row.SetStringNoCopy(kSysCatalogTableColId, kSysCertAuthorityEntryId));
+  CHECK_OK(row.SetStringNoCopy(kSysCatalogTableColMetadata, metadata_buf));
   RowOperationsPBEncoder enc(req.mutable_row_operations());
   enc.Add(RowOperationsPB::INSERT, row);
-  RETURN_NOT_OK(SyncWrite(&req, &resp));
 
-  return Status::OK();
+  return SyncWrite(&req, &resp);
 }
 
 Status SysCatalogTable::AddTskEntry(const SysTskEntryPB& entry) {
@@ -613,11 +612,14 @@ Status SysCatalogTable::AddTskEntry(const SysTskEntryPB& entry)
{
   faststring metadata_buf;
   pb_util::SerializeToString(entry, &metadata_buf);
 
+  // This is crucial to keep entry_id alive until its put into the
+  // WriteRequestPB object by RowOperationsPBEncoder.
+  const string entry_id = TskSeqNumberToEntryId(entry.tsk().key_seq_num());
+
   KuduPartialRow row(&schema_);
   CHECK_OK(row.SetInt8(kSysCatalogTableColType, TSK_ENTRY));
-  CHECK_OK(row.SetString(kSysCatalogTableColId,
-                         TskSeqNumberToEntryId(entry.tsk().key_seq_num())));
-  CHECK_OK(row.SetString(kSysCatalogTableColMetadata, metadata_buf));
+  CHECK_OK(row.SetStringNoCopy(kSysCatalogTableColId, entry_id));
+  CHECK_OK(row.SetStringNoCopy(kSysCatalogTableColMetadata, metadata_buf));
   RowOperationsPBEncoder enc(req.mutable_row_operations());
   enc.Add(RowOperationsPB::INSERT, row);
 
@@ -633,7 +635,7 @@ Status SysCatalogTable::RemoveTskEntries(const set<string>&
entry_ids) {
   for (const auto& id : entry_ids) {
     KuduPartialRow row(&schema_);
     CHECK_OK(row.SetInt8(kSysCatalogTableColType, TSK_ENTRY));
-    CHECK_OK(row.SetString(kSysCatalogTableColId, id));
+    CHECK_OK(row.SetStringNoCopy(kSysCatalogTableColId, id));
     RowOperationsPBEncoder enc(req.mutable_row_operations());
     enc.Add(RowOperationsPB::DELETE, row);
   }


Mime
View raw message