Grant Henke has posted comments on this change. ( 
http://gerrit.cloudera.org:8080/17129 )

Change subject: KUDU-3248: Match C++ replica selection behavior of Java client
......................................................................


Patch Set 1:

(2 comments)

http://gerrit.cloudera.org:8080/#/c/17129/1/src/kudu/client/client-internal.cc
File src/kudu/client/client-internal.cc:

http://gerrit.cloudera.org:8080/#/c/17129/1/src/kudu/client/client-internal.cc@124
PS1, Line 124: GoogleOnceType once;
             : // This random integer is used when making any random choice for 
replica
             : // selection. It is static to provide a deterministic selection 
for any given
             : // process and therefore also providing better cache affinity 
while ensuring
             : // that we can still benefit from spreading the load across 
replicas for
             : // other processes and applications.
             : int random_selection_int;
             :
             : void InitRandomSelectionInt() {
             :   std::random_device rdev;
             :   std::mt19937 gen(rdev());
             :   random_selection_int = gen();
             : }
             :
             : }
> Since this is client-internal.cc, C++11 and above is permitted so can use s
I will use static initialization as mentioned below.


http://gerrit.cloudera.org:8080/#/c/17129/1/src/kudu/client/client-internal.cc@270
PS1, Line 270:       if (!local.empty()) {
             :         ret = local[random_selection_int % local.size()];
             :       } else if (!same_location.empty()) {
             :         ret = same_location[random_selection_int % 
same_location.size()];
             :       } else if (!filtered.empty()) {
             :         ret = filtered[random_selection_int % filtered.size()];
             :       }
> Considering random_selection_int is used only in this function, std::once i
Awesome! I wasn't totally clear on that behavior given my lack of C++ expertise 
and wen't with what I saw other locations in the code base using. I am glad I 
can switch to something more straight forward.



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Iaa55e88b4a222fabfaa7fa521c24482cc6816b04
Gerrit-Change-Number: 17129
Gerrit-PatchSet: 1
Gerrit-Owner: Grant Henke <[email protected]>
Gerrit-Reviewer: Andrew Wong <[email protected]>
Gerrit-Reviewer: Bankim Bhavsar <[email protected]>
Gerrit-Reviewer: Grant Henke <[email protected]>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Comment-Date: Fri, 26 Feb 2021 18:53:30 +0000
Gerrit-HasComments: Yes

Reply via email to