From 37a5bb6b78e344d16bf4efed5453debcafe6aad6 Mon Sep 17 00:00:00 2001
From: scott snyder <snyder@bnl.gov>
Date: Tue, 25 Aug 2020 22:31:20 +0200
Subject: [PATCH] AthViews: Use transient keys within views.

Change the mapping of keys to the parent store such that we use
transient-only keys (starting with an underscore).
Should help with avoiding hash collisions.
---
 Control/AthViews/CMakeLists.txt                    |  2 +-
 Control/AthViews/src/SimpleView.cxx                |  3 ++-
 Control/AthViews/test/ViewCollectionMerge_test.cxx | 10 +++++-----
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/Control/AthViews/CMakeLists.txt b/Control/AthViews/CMakeLists.txt
index 8cfbffaab5b..594026fe12e 100644
--- a/Control/AthViews/CMakeLists.txt
+++ b/Control/AthViews/CMakeLists.txt
@@ -12,7 +12,7 @@ atlas_add_library( AthViews
                    src/*.cxx
                    PUBLIC_HEADERS AthViews
                    INCLUDE_DIRS ${TBB_INCLUDE_DIRS}
-                   LINK_LIBRARIES ${TBB_LIBRARIES} AthContainers AthLinks AthenaBaseComps AthenaKernel GaudiKernel StoreGateLib TrigSteeringEvent )
+                   LINK_LIBRARIES ${TBB_LIBRARIES} AthContainers AthLinks AthenaBaseComps AthenaKernel GaudiKernel StoreGateLib TrigSteeringEvent SGTools )
 
 atlas_add_component( AthViewsAlgs
                      src/components/*.cxx
diff --git a/Control/AthViews/src/SimpleView.cxx b/Control/AthViews/src/SimpleView.cxx
index 5b2821f7055..9c232b98026 100644
--- a/Control/AthViews/src/SimpleView.cxx
+++ b/Control/AthViews/src/SimpleView.cxx
@@ -5,6 +5,7 @@
 #include <stdexcept>
 #include "AthViews/SimpleView.h"
 #include "AthViews/View.h"
+#include "SGTools/transientKey.h"
 
 SimpleView::SimpleView( std::string Name, bool AllowFallThrough, std::string const& storeName ) :
   m_store( storeName, Name ),
@@ -25,7 +26,7 @@ SimpleView::~SimpleView()
  */
 std::string SimpleView::viewKey (const std::string& key) const
 {
-  return m_name + "_" + key;
+  return SG::transientKey (m_name + "_" + key);
 }
 
 
diff --git a/Control/AthViews/test/ViewCollectionMerge_test.cxx b/Control/AthViews/test/ViewCollectionMerge_test.cxx
index 87b69137572..cb23953eff9 100644
--- a/Control/AthViews/test/ViewCollectionMerge_test.cxx
+++ b/Control/AthViews/test/ViewCollectionMerge_test.cxx
@@ -477,7 +477,7 @@ TEST_F( ViewCollectionMerge_test, elementLinkViewRemapTest ) {
   ASSERT_TRUE( outputDataHandle2.isValid() );
 
   // Declare remapping - pretty hacky, have to specify view object names explicitly
-  evtStore()->remap( ClassID_traits< DataVector< int > >::ID(), "testView_" + DATA_NAME, "testView_" + DATA_NAME + "2", 0 );
+  evtStore()->remap( ClassID_traits< DataVector< int > >::ID(), "_testView_" + DATA_NAME, "_testView_" + DATA_NAME + "2", 0 );
 
   // Test the link again - should not have changed
   ASSERT_TRUE( dataLink.isValid() );
@@ -566,8 +566,8 @@ TEST_F( ViewCollectionMerge_test, elementLinkMergeRemapTest ) {
   ASSERT_TRUE( outputDataHandle.isValid() );
 
   // Declare remapping - pretty hacky, have to specify view object names explicitly
-  evtStore()->remap( ClassID_traits< DataVector< int > >::ID(), "testView_1_" + DATA_NAME, DATA_NAME, 0 );
-  evtStore()->remap( ClassID_traits< DataVector< int > >::ID(), "testView_2_" + DATA_NAME, DATA_NAME, 1 );
+  evtStore()->remap( ClassID_traits< DataVector< int > >::ID(), "_testView_1_" + DATA_NAME, DATA_NAME, 0 );
+  evtStore()->remap( ClassID_traits< DataVector< int > >::ID(), "_testView_2_" + DATA_NAME, DATA_NAME, 1 );
 
   // Element link should still be pointing to view container
   ASSERT_TRUE( dataLink.isValid() );
@@ -665,8 +665,8 @@ TEST_F( ViewCollectionMerge_test, elementLinkMergeRemapBookkeepTest ) {
   ASSERT_TRUE( auxHandle.isValid() );
 
   // Declare remapping - pretty hacky, have to specify view object names explicitly
-  evtStore()->remap( ClassID_traits< DataVector< DummyData > >::ID(), "testView_1_" + DATA_NAME, DATA_NAME, 0 );
-  evtStore()->remap( ClassID_traits< DataVector< DummyData > >::ID(), "testView_2_" + DATA_NAME, DATA_NAME, 1 );
+  evtStore()->remap( ClassID_traits< DataVector< DummyData > >::ID(), "_testView_1_" + DATA_NAME, DATA_NAME, 0 );
+  evtStore()->remap( ClassID_traits< DataVector< DummyData > >::ID(), "_testView_2_" + DATA_NAME, DATA_NAME, 1 );
 
   // Element link should still be pointing to view container
   ASSERT_TRUE( dataLink.isValid() );
-- 
GitLab