29#include <unordered_map>
38 auto seed = std::hash<uint64_t>{}(oid.
lo);
39 seed ^= std::hash<uint64_t>{}(oid.
hi) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
59class RDaosFakeObject {
61 std::mutex fMutexStorage;
62 std::unordered_map<std::string, std::string> fStorage;
68 reinterpret_cast<char *
>(
akey->iov_buf),
akey->iov_buf_len);
72 RDaosFakeObject() =
default;
83 std::lock_guard<std::mutex> lock(fMutexStorage);
85 for (
unsigned i = 0; i <
nr; i++) {
87 auto data = fStorage.find(GetKey(dkey, &
iods[i].iod_name));
88 if (
data == fStorage.end())
96 if (
sgls[i].sg_nr != 1)
100 std::copy_n(std::begin(
data->second), std::min(
iov.iov_buf_len,
data->second.size()),
101 reinterpret_cast<char *
>(
iov.iov_buf));
110 std::lock_guard<std::mutex> lock(fMutexStorage);
112 for (
unsigned i = 0; i <
nr; i++) {
113 auto &
data = fStorage[GetKey(dkey, &
iods[i].iod_name)];
120 for (
unsigned j = 0;
j <
sgls[i].sg_nr;
j++) {
122 data.append(
reinterpret_cast<const char *
>(
iov.iov_buf),
iov.iov_buf_len);
134class RDaosFakeContainer {
136 std::mutex fMutexObjects;
137 std::unordered_map<daos_obj_id_t, std::unique_ptr<RDaosFakeObject>> fObjects;
140 RDaosFakeContainer() =
default;
145 std::lock_guard<std::mutex> lock(fMutexObjects);
146 auto &obj = fObjects[oid];
148 obj = std::make_unique<RDaosFakeObject>();
161 static std::mutex fMutexPools;
162 static std::unordered_map<label_t, std::unique_ptr<RDaosFakePool>> fPools;
164 std::mutex fMutexContainers;
165 std::unordered_map<label_t, std::unique_ptr<RDaosFakeContainer>> fContainers;
172 std::lock_guard<std::mutex> lock(fMutexPools);
173 auto &
pool = fPools[label];
175 pool = std::make_unique<RDaosFakePool>();
179 RDaosFakePool() =
default;
184 std::lock_guard<std::mutex> lock(fMutexContainers);
185 fContainers.emplace(label, std::make_unique<RDaosFakeContainer>());
188 RDaosFakeContainer *GetContainer(
const label_t &label)
190 std::lock_guard<std::mutex> lock(fMutexContainers);
191 auto it = fContainers.find(label);
192 return (it != fContainers.end()) ? it->second.get() :
nullptr;
196std::mutex RDaosFakePool::fMutexPools;
197std::unordered_map<label_t, std::unique_ptr<RDaosFakePool>> RDaosFakePool::fPools;
214 Cookie(
void *
p) : fPointer(
p) {}
215 ~Cookie() { fPointer =
nullptr; }
216 void *GetPointer() {
return fPointer; }
222 template <
typename T>
228 template <
typename T>
231 return reinterpret_cast<typename std::add_pointer<T>::type
>(
reinterpret_cast<Cookie *
>(
h.cookie)->GetPointer());
234 static inline void Invalidate(
daos_handle_t h) {
delete reinterpret_cast<Cookie *
>(
h.cookie); }
253 return rc ?
"DER_INVAL" :
"Success";
283 auto pool = RDaosHandle::ToPointer<RDaosFakePool>(
poh);
297 auto pool = RDaosHandle::ToPointer<RDaosFakePool>(
poh);
307 *
coh = RDaosHandle::ToHandle(
cont);
313 RDaosHandle::Invalidate(
coh);
361 auto cont = RDaosHandle::ToPointer<RDaosFakeContainer>(
coh);
364 auto obj =
cont->GetObject(oid,
mode);
365 *
oh = RDaosHandle::ToHandle(obj);
371 RDaosHandle::Invalidate(
oh);
401 auto obj = RDaosHandle::ToPointer<RDaosFakeObject>(
oh);
410 auto obj = RDaosHandle::ToPointer<RDaosFakeObject>(
oh);
422 *
poh = RDaosHandle::ToHandle(RDaosFakePool::GetPool(
label_t(label)));
428 RDaosHandle::Invalidate(
poh);
#define R__LOG_WARNING(...)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
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 mode
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 type
TRObject operator()(const T1 &t1) const
This file is a reduced version of daos_xxx.h headers that provides (simplified) declarations for use ...
int daos_oclass_id2name(daos_oclass_id_t oc_id, char *name)
const char * d_errstr(int rc)
int daos_pool_disconnect(daos_handle_t poh, daos_event_t *ev)
daos_otype_t
DAOS object type.
int daos_oclass_name2id(const char *name)
int daos_obj_fetch(daos_handle_t oh, daos_handle_t th, uint64_t flags, daos_key_t *dkey, unsigned int nr, daos_iod_t *iods, d_sg_list_t *sgls, daos_iom_t *ioms, daos_event_t *ev)
int daos_obj_open(daos_handle_t coh, daos_obj_id_t oid, unsigned int mode, daos_handle_t *oh, daos_event_t *ev)
uint16_t daos_oclass_hints_t
int daos_pool_connect(const char *pool, const char *grp, unsigned int flags, daos_handle_t *poh, daos_pool_info_t *info, daos_event_t *ev)
int daos_event_fini(daos_event_t *ev)
@ OC_RP_XSF
Replicated object class which is extremely scalable for fetch.
int daos_obj_generate_oid(daos_handle_t coh, daos_obj_id_t *oid, enum daos_otype_t type, daos_oclass_id_t cid, daos_oclass_hints_t hints, uint32_t args)
int daos_obj_update(daos_handle_t oh, daos_handle_t th, uint64_t flags, daos_key_t *dkey, unsigned int nr, daos_iod_t *iods, d_sg_list_t *sgls, daos_event_t *ev)
#define OID_FMT_META_SHIFT
int daos_cont_close(daos_handle_t coh, daos_event_t *ev)
static bool daos_label_is_valid(const char *)
uint16_t daos_oclass_id_t
#define OID_FMT_INTR_BITS
int daos_event_init(daos_event_t *ev, daos_handle_t eqh, daos_event_t *parent)
int daos_event_test(daos_event_t *ev, int64_t timeout, bool *flag)
static bool daos_otype_t_is_valid(enum daos_otype_t type)
int daos_eq_create(daos_handle_t *eqh)
int daos_obj_close(daos_handle_t oh, daos_event_t *ev)
int daos_cont_create_with_label(daos_handle_t poh, const char *label, daos_prop_t *cont_prop, uuid_t *uuid, daos_event_t *ev)
int daos_eq_destroy(daos_handle_t eqh, int flags)
int daos_eq_poll(daos_handle_t eqh, int wait_running, int64_t timeout, unsigned int nevents, daos_event_t **events)
int daos_cont_open(daos_handle_t poh, const char *uuid, unsigned int flags, daos_handle_t *coh, daos_cont_info_t *info, daos_event_t *ev)
#define OID_FMT_CLASS_SHIFT
int daos_event_parent_barrier(daos_event_t *ev)
#define OID_FMT_TYPE_SHIFT
bool operator==(const daos_obj_id_t &lhs, const daos_obj_id_t &rhs)
RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.
Scatter/gather list for memory buffers.
Generic handle for various DAOS components like container, object, etc.
daos properties, for pool or container