Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RConcurrentHashColl.cxx
Go to the documentation of this file.
3#include <ROOT/TSeq.hxx>
4#include <ROOT/RSha256.hxx>
5
6#include <memory>
7#include <set>
8#include <unordered_map>
9
10namespace std
11{
12template <> struct hash<ROOT::Internal::RConcurrentHashColl::HashValue>
13{
14 std::size_t operator()(const ROOT::Internal::RConcurrentHashColl::HashValue& key) const noexcept
15 {
16 return key.Hash();
17 }
18};
19}
20namespace ROOT {
21namespace Internal {
22
23
24std::ostream &operator<<(std::ostream &os, const RConcurrentHashColl::HashValue &h)
25{
26 auto digest = h.Get();
27 os << digest[0] << "-" << digest[1] << "-" << digest[2] << "-" << digest[3];
28 return os;
29}
30
32{
33 // The cast here is because in the TBuffer ecosystem, the type used is char*
34 Sha256(reinterpret_cast<const unsigned char *>(data), len, fDigest);
35}
36
37struct RHashMap {
38 std::unordered_map<ROOT::Internal::RConcurrentHashColl::HashValue, RUidColl> fHashMap;
39};
40
42 : fHashMap(std::make_unique<RHashMap>()), fRWLock(std::make_unique<ROOT::TRWSpinLock>()){};
43
45
47{
49 auto iter = fHashMap->fHashMap.find(hash);
50 if (iter != fHashMap->fHashMap.end())
51 return &(iter->second);
52 else
53 return nullptr;
54}
55
57{
58 return HashValue(buffer, len);
59}
60
61bool RConcurrentHashColl::Insert(const HashValue &hash, RUidColl &&values) const
62{
64 auto ret = fHashMap->fHashMap.insert({hash, std::move(values)});
65 return ret.second;
66}
67
68} // End NS Internal
69} // End NS ROOT
#define h(i)
Definition RSha256.hxx:106
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Definition TBuffer.h:397
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
TRObject operator()(const T1 &t1) const
bool Insert(const HashValue &hash, RUidColl &&coll) const
If the hash is there, return false.
static HashValue Hash(char *buf, int len)
Return the hash object corresponding to the buffer.
std::unique_ptr< ROOT::TRWSpinLock > fRWLock
const RUidColl * Find(const HashValue &hash) const
Return the collection of UID corresponding to the hash if the hash has already been seen or nullptr o...
std::vector< Int_t > RUidColl
void Sha256(const unsigned char *data, int len, ULong64_t *fDigest)
Definition RSha256.hxx:267
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
std::unordered_map< ROOT::Internal::RConcurrentHashColl::HashValue, RUidColl > fHashMap