forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectCache.h
More file actions
70 lines (60 loc) · 2.05 KB
/
Copy pathObjectCache.h
File metadata and controls
70 lines (60 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#ifndef O2_FRAMEWORK_OBJECTCACHE_H_
#define O2_FRAMEWORK_OBJECTCACHE_H_
#include "Framework/DataRef.h"
#include <unordered_map>
#include <map>
#include <string>
namespace o2::framework
{
/// A cache for CCDB objects or objects in general
/// which have more than one timeframe of lifetime.
/// The cache is keyed *per path* rather than by a global id-derived hash.
struct ObjectCache {
struct Id {
int64_t value;
static Id fromRef(DataRef& ref)
{
return {reinterpret_cast<int64_t>(ref.payload)};
}
bool operator==(const Id& other) const
{
return value == other.value;
}
struct hash_fn {
std::size_t operator()(const Id& id) const
{
return id.value;
}
};
};
/// Per-path cache entry for a deserialised CCDB object.
struct Entry {
Id id{0};
void* obj{nullptr};
};
/// Per-path cache entry for the CCDB metadata map.
struct MetadataEntry {
Id id{0};
std::map<std::string, std::string> metadata;
};
/// A per-path cache for deserialised objects.
/// This keeps a mapping so that we can tell if a given
/// path was already received and it's blob stored in .second.obj
std::unordered_map<std::string, Entry> matcherToEntry;
/// A per-path cache to the deserialised metadata
/// We keep it separate because we want to avoid that looking up
/// the metadata also pollutes the object cache.
std::unordered_map<std::string, MetadataEntry> matcherToMetadata;
};
} // namespace o2::framework
#endif // O2_FRAMEWORK_OBJECTCACHE_H_