You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Alexey Serbin (Code Review)" <ge...@cloudera.org> on 2026/09/25 23:49:45 UTC

[kudu-CR] [util] optimize Status move assignment operator

Alexey Serbin has uploaded this change for review. ( http://gerrit.cloudera.org:8080/24962


Change subject: [util] optimize Status move assignment operator
......................................................................

[util] optimize Status move assignment operator

The C++ standard doesn't require a lot from source objects of
std::move().  At least, for STL objects the requirements are like
below [1]:

  Unless otherwise specified, all standard library objects that have been
  moved from are placed in a "valid but unspecified state", meaning the
  object's class invariants hold (so functions without preconditions,
  such as the assignment operator, can be safely used on the object
  after it was moved from).

Applying this to the Status class, it's possible to postpone
deallocating of the internal buffer to the time when the "moved from"
Status object goes out of scope, not calling 'delete' in the move
assignment operator itself.

I also snuck in a fix for KUDU_ATTR_NODISCARD macro's comment.

[1] https://cppreference.com/cpp/utility/move

Change-Id: Id98a4e4970e3dfc61c22e46ed8fa69393f56aaae
---
M src/kudu/util/status-test.cc
M src/kudu/util/status.h
2 files changed, 4 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/62/24962/1
-- 
To view, visit http://gerrit.cloudera.org:8080/24962
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id98a4e4970e3dfc61c22e46ed8fa69393f56aaae
Gerrit-Change-Number: 24962
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <al...@apache.org>

[kudu-CR] [util] optimize Status move assignment operator

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/24962 )

Change subject: [util] optimize Status move assignment operator
......................................................................

[util] optimize Status move assignment operator

The C++ standard doesn't require a lot from source objects of
std::move().  At least, for STL objects the requirements are like
below [1]:

  Unless otherwise specified, all standard library objects that have been
  moved from are placed in a "valid but unspecified state", meaning the
  object's class invariants hold (so functions without preconditions,
  such as the assignment operator, can be safely used on the object
  after it was moved from).

Applying this to the Status class, it's possible to postpone
deallocating of the internal buffer to the time when the "moved from"
Status object goes out of scope, not calling 'delete' in the move
assignment operator itself.

I also snuck in a fix for KUDU_ATTR_NODISCARD macro's comment.

[1] https://cppreference.com/cpp/utility/move

Change-Id: Id98a4e4970e3dfc61c22e46ed8fa69393f56aaae
Reviewed-on: http://gerrit.cloudera.org:8080/24962
Reviewed-by: Gabriella Lotz <lo...@gmail.com>
Reviewed-by: Marton Greber <gr...@gmail.com>
Tested-by: Marton Greber <gr...@gmail.com>
---
M src/kudu/util/status-test.cc
M src/kudu/util/status.h
2 files changed, 4 insertions(+), 8 deletions(-)

Approvals:
  Gabriella Lotz: Looks good to me, but someone else must approve
  Marton Greber: Looks good to me, approved; Verified

-- 
To view, visit http://gerrit.cloudera.org:8080/24962
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id98a4e4970e3dfc61c22e46ed8fa69393f56aaae
Gerrit-Change-Number: 24962
Gerrit-PatchSet: 2
Gerrit-Owner: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>

[kudu-CR] [util] optimize Status move assignment operator

Posted by "Zoltan Martonka (Code Review)" <ge...@cloudera.org>.
Zoltan Martonka has posted comments on this change. ( http://gerrit.cloudera.org:8080/24962 )

Change subject: [util] optimize Status move assignment operator
......................................................................


Patch Set 2:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24962/2/src/kudu/util/status-test.cc
File src/kudu/util/status-test.cc:

http://gerrit.cloudera.org:8080/#/c/24962/2/src/kudu/util/status-test.cc@70
PS2, Line 70:   // OK->Bad move should clear the source status and also make the
Fix comment. No longer "clear"



-- 
To view, visit http://gerrit.cloudera.org:8080/24962
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id98a4e4970e3dfc61c22e46ed8fa69393f56aaae
Gerrit-Change-Number: 24962
Gerrit-PatchSet: 2
Gerrit-Owner: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 29 Sep 2026 20:37:17 +0000
Gerrit-HasComments: Yes

[kudu-CR] [util] optimize Status move assignment operator

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has posted comments on this change. ( http://gerrit.cloudera.org:8080/24962 )

Change subject: [util] optimize Status move assignment operator
......................................................................


Patch Set 1: Verified+1 Code-Review+2

unrelated test failures:
debug: org.apache.kudu.spark.tools.DistributedDataGeneratorTest,
tsan: org.apache.kudu.client.TestSecurity


-- 
To view, visit http://gerrit.cloudera.org:8080/24962
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id98a4e4970e3dfc61c22e46ed8fa69393f56aaae
Gerrit-Change-Number: 24962
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Mon, 28 Sep 2026 12:56:47 +0000
Gerrit-HasComments: No

[kudu-CR] [util] optimize Status move assignment operator

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24962 )

Change subject: [util] optimize Status move assignment operator
......................................................................


Patch Set 1: Verified-1

Build Failed 

http://jenkins.kudu.apache.org/job/pre_commit/3049/ : FAILURE


-- 
To view, visit http://gerrit.cloudera.org:8080/24962
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id98a4e4970e3dfc61c22e46ed8fa69393f56aaae
Gerrit-Change-Number: 24962
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Sat, 26 Sep 2026 00:50:18 +0000
Gerrit-HasComments: No

[kudu-CR] [util] optimize Status move assignment operator

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( http://gerrit.cloudera.org:8080/24962 )

Change subject: [util] optimize Status move assignment operator
......................................................................


Patch Set 2:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24962/2/src/kudu/util/status-test.cc
File src/kudu/util/status-test.cc:

http://gerrit.cloudera.org:8080/#/c/24962/2/src/kudu/util/status-test.cc@70
PS2, Line 70:   // OK->Bad move should clear the source status and also make the
> Fix comment. No longer "clear"
Good catch!  I posted a follow-up update at  http://gerrit.cloudera.org:8080/24974



-- 
To view, visit http://gerrit.cloudera.org:8080/24962
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id98a4e4970e3dfc61c22e46ed8fa69393f56aaae
Gerrit-Change-Number: 24962
Gerrit-PatchSet: 2
Gerrit-Owner: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 29 Sep 2026 22:15:05 +0000
Gerrit-HasComments: Yes

[kudu-CR] [util] optimize Status move assignment operator

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24962 )

Change subject: [util] optimize Status move assignment operator
......................................................................


Patch Set 1:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3049/


-- 
To view, visit http://gerrit.cloudera.org:8080/24962
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id98a4e4970e3dfc61c22e46ed8fa69393f56aaae
Gerrit-Change-Number: 24962
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Comment-Date: Fri, 25 Sep 2026 23:49:52 +0000
Gerrit-HasComments: No

[kudu-CR] [util] optimize Status move assignment operator

Posted by "Gabriella Lotz (Code Review)" <ge...@cloudera.org>.
Gabriella Lotz has posted comments on this change. ( http://gerrit.cloudera.org:8080/24962 )

Change subject: [util] optimize Status move assignment operator
......................................................................


Patch Set 1: Code-Review+1


-- 
To view, visit http://gerrit.cloudera.org:8080/24962
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id98a4e4970e3dfc61c22e46ed8fa69393f56aaae
Gerrit-Change-Number: 24962
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Mon, 28 Sep 2026 10:58:35 +0000
Gerrit-HasComments: No

[kudu-CR] [util] optimize Status move assignment operator

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has removed a vote on this change.

Change subject: [util] optimize Status move assignment operator
......................................................................


Removed Verified-1 by Kudu Jenkins (120)
-- 
To view, visit http://gerrit.cloudera.org:8080/24962
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: deleteVote
Gerrit-Change-Id: Id98a4e4970e3dfc61c22e46ed8fa69393f56aaae
Gerrit-Change-Number: 24962
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>