13 std::ostream &operator<<(std::ostream &os,
const RConcurrentHashColl::HashValue &h)
15 auto digest = h.Get();
16 os << digest[0] <<
"-" << digest[1] <<
"-" << digest[2] <<
"-" << digest[3];
20 RConcurrentHashColl::HashValue::HashValue(
const char *data,
int len)
23 Sha256(reinterpret_cast<const unsigned char *>(data), len, fDigest);
27 std::set<ROOT::Internal::RConcurrentHashColl::HashValue> fSet;
30 RConcurrentHashColl::RConcurrentHashColl()
31 : fHashSet(std::make_unique<RHashSet>()), fRWLock(std::make_unique<ROOT::TRWSpinLock>()){};
33 RConcurrentHashColl::~RConcurrentHashColl() =
default;
36 bool RConcurrentHashColl::Find(
const HashValue &hash)
const
38 ROOT::TRWSpinLockReadGuard rg(*fRWLock);
39 return (fHashSet->fSet.end() != fHashSet->fSet.find(hash));
43 RConcurrentHashColl::HashValue RConcurrentHashColl::Hash(
char *buffer,
int len)
45 return HashValue(buffer, len);
49 bool RConcurrentHashColl::Insert(
char *buffer,
int len)
const
51 HashValue hash(buffer, len);
54 ROOT::TRWSpinLockReadGuard rg(*fRWLock);
55 if (fHashSet->fSet.end() != fHashSet->fSet.find(hash))
59 ROOT::TRWSpinLockWriteGuard wg(*fRWLock);
60 fHashSet->fSet.insert(hash);
66 bool RConcurrentHashColl::Insert(
const HashValue &hash)
const
68 ROOT::TRWSpinLockWriteGuard wg(*fRWLock);
69 auto ret = fHashSet->fSet.insert(hash);