@@ -57,28 +57,12 @@ public:
5757 \class RDaosObject
5858 \brief Provides low-level access to DAOS objects in a container.
5959 */
60- template <typename DKeyT, typename AKeyT>
6160class RDaosObject {
6261private:
6362 daos_handle_t fObjectHandle ;
64-
65- // Provide support for UINT64 dkey/akey.
66- template <typename T, typename std::enable_if<!ROOT::TypeTraits::HasDataAndSize<T>::value, int >::type = 0 >
67- static size_t key_size (T& x) { return sizeof (x); }
68-
69- template <typename T, typename std::enable_if<!ROOT::TypeTraits::HasDataAndSize<T>::value, int >::type = 0 >
70- static typename std::add_pointer<T>::type key_data (T& x) { return &x; }
71-
72- // Provide support for std::string/std::vector dkey/akey.
73- template <typename T, typename std::enable_if<ROOT::TypeTraits::HasDataAndSize<T>::value, int >::type = 0 >
74- static size_t key_size (T& x) { return x.size (); }
75-
76- template <typename T, typename std::enable_if<ROOT::TypeTraits::HasDataAndSize<T>::value, int >::type = 0 >
77- static typename T::pointer key_data (T& x) { return const_cast <typename T::pointer>(x.data ()); }
78-
7963public:
80- using DistributionKey_t = DKeyT ;
81- using AttributeKey_t = AKeyT ;
64+ using DistributionKey_t = std:: uint64_t ;
65+ using AttributeKey_t = std:: uint64_t ;
8266
8367 // / \brief Contains required information for a single fetch/update operation.
8468 struct FetchUpdateArgs {
@@ -115,18 +99,19 @@ public:
11599 \brief A RDaosContainer provides read/write access to objects in a given container.
116100 */
117101class RDaosContainer {
118- template <typename DKeyT, typename AKeyT>
119102 friend class RDaosObject ;
120103public:
104+ using DistributionKey_t = std::uint64_t ;
105+ using AttributeKey_t = std::uint64_t ;
106+
121107 // / \brief Describes a read/write operation on multiple objects; see the `ReadV`/`WriteV` functions.
122- template <typename DKeyT, typename AKeyT>
123108 struct RWOperation {
124109 RWOperation () = default ;
125- RWOperation (daos_obj_id_t o, DKeyT d, AKeyT a, std::vector<d_iov_t > &v)
110+ RWOperation (daos_obj_id_t o, DistributionKey_t d, AttributeKey_t a, std::vector<d_iov_t > &v)
126111 : fOid (o), fDistributionKey (d), fAttributeKey (a), fIovs (v) {};
127112 daos_obj_id_t fOid {};
128- DKeyT fDistributionKey {};
129- AKeyT fAttributeKey {};
113+ DistributionKey_t fDistributionKey {};
114+ AttributeKey_t fAttributeKey {};
130115 std::vector<d_iov_t > fIovs {};
131116 };
132117
@@ -147,7 +132,7 @@ private:
147132 daos_handle_t fContainerHandle {};
148133 uuid_t fContainerUuid {};
149134 std::shared_ptr<RDaosPool> fPool ;
150- // / OID that will be used by the next call to `WriteObject(const void *, std::size_t, DKeyT, AKeyT )`.
135+ // / OID that will be used by the next call to `WriteObject(const void *, std::size_t, DistributionKey_t, AttributeKey_t )`.
151136 daos_obj_id_t fSequentialWrOid {};
152137
153138 /* *
@@ -156,17 +141,16 @@ private:
156141 \param fn Either `std::mem_fn<&RDaosObject::Fetch>` (read) or `std::mem_fn<&RDaosObject::Update>` (write).
157142 \return Number of requests that did not complete; this should be 0 after a successful call.
158143 */
159- template <typename Fn, typename DKeyT, typename AKeyT>
160- int VectorReadWrite (std::vector<RWOperation<DKeyT, AKeyT>> &vec, Fn fn) {
161- using _RDaosObject = RDaosObject<DKeyT, AKeyT>;
144+ template <typename Fn>
145+ int VectorReadWrite (std::vector<RWOperation> &vec, Fn fn) {
162146 int ret;
163147 DaosEventQueue eventQueue (vec.size ());
164148 {
165- std::vector<std::tuple<std::unique_ptr<_RDaosObject >, typename _RDaosObject ::FetchUpdateArgs>> requests{};
149+ std::vector<std::tuple<std::unique_ptr<RDaosObject >, RDaosObject ::FetchUpdateArgs>> requests{};
166150 requests.reserve (vec.size ());
167151 for (size_t i = 0 ; i < vec.size (); ++i) {
168- requests.push_back (std::make_tuple (std::unique_ptr<_RDaosObject >(new _RDaosObject (*this , vec[i].fOid )),
169- typename _RDaosObject ::FetchUpdateArgs{
152+ requests.push_back (std::make_tuple (std::unique_ptr<RDaosObject >(new RDaosObject (*this , vec[i].fOid )),
153+ RDaosObject ::FetchUpdateArgs{
170154 vec[i].fDistributionKey , vec[i].fAttributeKey ,
171155 vec[i].fIovs , &eventQueue.fEvs [i]}));
172156 fn (std::get<0 >(requests.back ()).get (), std::get<1 >(requests.back ()));
@@ -189,14 +173,7 @@ public:
189173 \param akey The attribute key used for this operation.
190174 \return 0 if the operation succeeded; a negative DAOS error number otherwise.
191175 */
192- template <typename DKeyT, typename AKeyT>
193- int ReadObject (daos_obj_id_t oid, void *buffer, std::size_t length, DKeyT dkey, AKeyT akey)
194- {
195- std::vector<d_iov_t > iovs (1 );
196- d_iov_set (&iovs[0 ], buffer, length);
197- typename RDaosObject<DKeyT, AKeyT>::FetchUpdateArgs args (dkey, akey, iovs);
198- return RDaosObject<DKeyT, AKeyT>(*this , oid).Fetch (args);
199- }
176+ int ReadObject (daos_obj_id_t oid, void *buffer, std::size_t length, DistributionKey_t dkey, AttributeKey_t akey);
200177
201178 /* *
202179 \brief Write the given buffer to an object in this container.
@@ -207,14 +184,7 @@ public:
207184 \param akey The attribute key used for this operation.
208185 \return 0 if the operation succeeded; a negative DAOS error number otherwise.
209186 */
210- template <typename DKeyT, typename AKeyT>
211- int WriteObject (daos_obj_id_t oid, const void *buffer, std::size_t length, DKeyT dkey, AKeyT akey)
212- {
213- std::vector<d_iov_t > iovs (1 );
214- d_iov_set (&iovs[0 ], const_cast <void *>(buffer), length);
215- typename RDaosObject<DKeyT, AKeyT>::FetchUpdateArgs args (dkey, akey, iovs);
216- return RDaosObject<DKeyT, AKeyT>(*this , oid).Update (args);
217- }
187+ int WriteObject (daos_obj_id_t oid, const void *buffer, std::size_t length, DistributionKey_t dkey, AttributeKey_t akey);
218188
219189 /* *
220190 \brief Write the given buffer to an object in this container and return a generated OID.
@@ -224,32 +194,24 @@ public:
224194 \param akey The attribute key used for this operation.
225195 \return A `std::tuple<>` that contains the generated OID and a DAOS error number (0 if the operation succeeded).
226196 */
227- template <typename DKeyT, typename AKeyT>
228- std::tuple<daos_obj_id_t , int > WriteObject (const void *buffer, std::size_t length, DKeyT dkey, AKeyT akey)
229- {
230- auto ret = std::make_tuple (fSequentialWrOid ,
231- WriteObject (fSequentialWrOid , buffer, length, dkey, akey));
232- fSequentialWrOid .lo ++;
233- return ret;
234- }
197+ std::tuple<daos_obj_id_t , int >
198+ WriteObject (const void *buffer, std::size_t length, DistributionKey_t dkey, AttributeKey_t akey);
235199
236200 /* *
237201 \brief Perform a vector read operation on (possibly) multiple objects.
238202 \param vec A `std::vector<RWOperation>` that describes read operations to perform.
239203 \return Number of operations that could not complete.
240204 */
241- template <typename DKeyT, typename AKeyT>
242- int ReadV (std::vector<RWOperation<DKeyT, AKeyT>> &vec)
243- { return VectorReadWrite (vec, std::mem_fn (&RDaosObject<DKeyT, AKeyT>::Fetch)); }
205+ int ReadV (std::vector<RWOperation> &vec)
206+ { return VectorReadWrite (vec, std::mem_fn (&RDaosObject::Fetch)); }
244207
245208 /* *
246209 \brief Perform a vector write operation on (possibly) multiple objects.
247210 \param vec A `std::vector<RWOperation>` that describes write operations to perform.
248211 \return Number of operations that could not complete.
249212 */
250- template <typename DKeyT, typename AKeyT>
251- int WriteV (std::vector<RWOperation<DKeyT, AKeyT>> &vec)
252- { return VectorReadWrite (vec, std::mem_fn (&RDaosObject<DKeyT, AKeyT>::Update)); }
213+ int WriteV (std::vector<RWOperation> &vec)
214+ { return VectorReadWrite (vec, std::mem_fn (&RDaosObject::Update)); }
253215};
254216
255217} // namespace Detail
0 commit comments