You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/10/01 13:00:42 UTC

[GitHub] [arrow] bkietz commented on a change in pull request #8023: ARROW-9318: [C++] Parquet encryption key management

bkietz commented on a change in pull request #8023:
URL: https://github.com/apache/arrow/pull/8023#discussion_r497661719



##########
File path: cpp/src/arrow/util/concurrent_map.h
##########
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <functional>
+#include <unordered_map>
+#include <utility>
+
+#include "arrow/util/mutex.h"
+
+namespace arrow {
+namespace util {
+
+template <typename V>
+class ConcurrentMap {

Review comment:
       In all, I think this doesn't add sufficient value over an inlined `container, mutex` pair. I think this class should be removed, maybe extracting a helper for single lookup insertion:
   ```c++
   template <typename K, typename V, typename Hash, typename Eq, typename Gen>
   auto GetOrInsert(std::unordered_map<K, V, Hash, Eq>* map, const K& key, Gen&& gen, V placeholder = V{})
     -> decltype(map->begin()) {
     auto it_success = map->emplace(key, placeholder);
     if (!it_success.second) {
       // insertion of placeholder was blocked by an existing entry, return that
       return it_success.first;
     }
     // overwrite placeholder with computed value
     it_success.first->second = gen();
     return it_success.first;
   }
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org