David Ribeiro Alves has submitted this change and it was merged.

Change subject: Add ComputeIfAbsent methods to map-util
......................................................................


Add ComputeIfAbsent methods to map-util

This adds two new ComputeIfAbsent methods to map-util, inspired by java's 
implementation,
which can be found here:

https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html#computeIfAbsent-K-java.util.function.Function-

The first one, ComputeIfAbsent, is a simple c++ implementation of the exact same
concept: Retreive a value from a map; if it doesn't exist compute it using a 
lambda
function and insert it first.

The second one is a slight variation that returns a pair instead of a pointer 
to the
value. The pair includes the pointer to the value, but also a bool indicating 
whether
the value was initially absent.

Change-Id: Iba9fa8038e699e66d34ce541cd02c77f46691315
Reviewed-on: http://gerrit.cloudera.org:8080/3593
Reviewed-by: Todd Lipcon <t...@apache.org>
Tested-by: Kudu Jenkins
---
M src/kudu/gutil/map-util.h
M src/kudu/util/map-util-test.cc
2 files changed, 70 insertions(+), 0 deletions(-)

Approvals:
  Todd Lipcon: Looks good to me, approved
  Kudu Jenkins: Verified



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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iba9fa8038e699e66d34ce541cd02c77f46691315
Gerrit-PatchSet: 10
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: David Ribeiro Alves <dral...@apache.org>
Gerrit-Reviewer: Alexey Serbin <aser...@cloudera.com>
Gerrit-Reviewer: David Ribeiro Alves <dral...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Todd Lipcon <t...@apache.org>

Reply via email to