Skip to content

Commit 9e7877f

Browse files
committed
[ntuple] Add additional comments related to user-provided ptrs
To squash with #8ea3951.
1 parent bee2e08 commit 9e7877f

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

tree/ntuple/inc/ROOT/RNTupleProcessor.hxx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public:
105105
}
106106

107107
/////////////////////////////////////////////////////////////////////////////
108-
/// \brief Get a raw pointer to the field value managed by the processor's entry.
108+
/// \brief Get a non-owning pointer to the field value managed by the processor's entry.
109109
///
110110
/// \return A `T*` if the field is valid in the current entry, or a `nullptr` otherwise.
111111
T *GetRawPtr() const { return GetPtr().get(); }
@@ -114,6 +114,12 @@ public:
114114
/// \brief Bind the value to `valuePtr`.
115115
///
116116
/// \param[in] valuePtr Pointer to bind the value to.
117+
///
118+
/// \warning Use this function with care! Values may not always be valid for every entry during processing, for
119+
/// example when a field is not present in one of the chained processors or when during a join operation, no matching
120+
/// entry in the auxiliary processor can be found. Reading `valuePtr` as-is therefore comes with the risk of reading
121+
/// invalid data. After binding a pointer to an `RNTupleProcessorOptionalPtr`, we *strongly* recommend only accessing
122+
/// its data through this interface, to ensure that only valid data can be read.
117123
void BindRawPtr(T *valuePtr) { fProcessorEntry->BindRawPtr(fFieldIndex, valuePtr); }
118124

119125
/////////////////////////////////////////////////////////////////////////////
@@ -182,7 +188,7 @@ public:
182188
}
183189

184190
/////////////////////////////////////////////////////////////////////////////
185-
/// \brief Get a raw pointer to the field value managed by the processor's entry.
191+
/// \brief Get a non-owning pointer to the field value managed by the processor's entry.
186192
///
187193
/// \return A `void*` if the field is valid in the current entry, or a `nullptr` otherwise.
188194
void *GetRawPtr() const { return GetPtr().get(); }
@@ -191,6 +197,12 @@ public:
191197
/// \brief Bind the value to `valuePtr`.
192198
///
193199
/// \param[in] valuePtr Pointer to bind the value to.
200+
///
201+
/// \warning Use this function with care! Values may not always be valid for every entry during processing, for
202+
/// example when a field is not present in one of the chained processors or when during a join operation, no matching
203+
/// entry in the auxiliary processor can be found. Reading `valuePtr` as-is therefore comes with the risk of reading
204+
/// invalid data. After binding a pointer to an `RNTupleProcessorOptionalPtr`, we *strongly* recommend only accessing
205+
/// its data through this interface, to ensure that only valid data can be read.
194206
void BindRawPtr(void *valuePtr) { fProcessorEntry->BindRawPtr(fFieldIndex, valuePtr); }
195207
};
196208

@@ -374,6 +386,12 @@ public:
374386
/// \param[in] fieldName Name of the requested field.
375387
///
376388
/// \return An RNTupleProcessorOptionalPtr, which provides access to the field's value.
389+
///
390+
/// \warning Provide a `valuePtr` with care! Values may not always be valid for every entry during processing, for
391+
/// example when a field is not present in one of the chained processors or when during a join operation, no matching
392+
/// entry in the auxiliary processor can be found. Reading `valuePtr` as-is therefore comes with the risk of reading
393+
/// invalid data. After passing a pointer to `RequestField`, we *strongly* recommend only accessing its data through
394+
/// the interface of the returned `RNTupleProcessorOptionalPtr`, to ensure that only valid data can be read.
377395
template <typename T>
378396
RNTupleProcessorOptionalPtr<T> RequestField(std::string_view fieldName, void *valuePtr = nullptr)
379397
{

0 commit comments

Comments
 (0)