@@ -37,10 +37,24 @@ struct roaring_bitmap_storage_ref {
3737 static_assert (cuco::dependent_false<T>, " T must be either uint32_t or uint64_t" );
3838};
3939
40+ /* *
41+ * @brief Reference type for 32-bit roaring bitmap storage
42+ *
43+ * Provides a lightweight reference to a 32-bit roaring bitmap stored in device memory,
44+ * allowing access to the bitmap data and metadata without ownership.
45+ */
4046template <>
4147class roaring_bitmap_storage_ref <cuda::std::uint32_t > {
4248 public:
49+ // / Metadata type for this storage reference
4350 using metadata_type = roaring_bitmap_metadata<cuda::std::uint32_t >;
51+
52+ /* *
53+ * @brief Constructs a storage reference from bitmap data and metadata
54+ *
55+ * @param bitmap Pointer to the serialized bitmap in a device-accessible memory location
56+ * @param metadata Metadata describing the bitmap structure
57+ */
4458 __host__ __device__ roaring_bitmap_storage_ref (cuda::std::byte const * bitmap,
4559 metadata_type const & metadata)
4660 : metadata_{metadata},
@@ -52,24 +66,61 @@ class roaring_bitmap_storage_ref<cuda::std::uint32_t> {
5266 assert (metadata.valid );
5367 }
5468
69+ /* *
70+ * @brief Constructs a storage reference from bitmap data
71+ *
72+ * Automatically parses metadata from the bitmap data.
73+ *
74+ * @param bitmap Pointer to the serialized bitmap in a device-accessible memory location
75+ */
5576 __device__ roaring_bitmap_storage_ref (cuda::std::byte const * bitmap)
5677 : roaring_bitmap_storage_ref{bitmap, metadata_type{bitmap}}
5778 {
5879 }
5980
81+ /* *
82+ * @brief Returns the metadata for this bitmap
83+ *
84+ * @return Reference to the bitmap metadata
85+ */
6086 __host__ __device__ metadata_type const & metadata () const noexcept { return metadata_; }
6187
88+ /* *
89+ * @brief Returns pointer to the raw bitmap data
90+ *
91+ * @return Pointer to the beginning of the bitmap data
92+ */
6293 __host__ __device__ cuda::std::byte const * data () const noexcept { return data_; }
6394
95+ /* *
96+ * @brief Returns the size of the bitmap in bytes
97+ *
98+ * @return Size of the bitmap data in bytes
99+ */
64100 __host__ __device__ cuda::std::size_t size_bytes () const noexcept { return metadata_.size_bytes ; }
65101
102+ /* *
103+ * @brief Returns pointer to the run container bitmap
104+ *
105+ * @return Pointer to the run container bitmap data
106+ */
66107 __host__ __device__ cuda::std::byte const * run_container_bitmap () const noexcept
67108 {
68109 return run_container_bitmap_;
69110 }
70111
112+ /* *
113+ * @brief Returns pointer to the key cardinalities data
114+ *
115+ * @return Pointer to the key cardinalities data
116+ */
71117 __host__ __device__ cuda::std::byte const * key_cards () const noexcept { return key_cards_; }
72118
119+ /* *
120+ * @brief Returns pointer to the container offsets data
121+ *
122+ * @return Pointer to the container offsets data
123+ */
73124 __host__ __device__ cuda::std::byte const * container_offsets () const noexcept
74125 {
75126 return container_offsets_;
@@ -83,11 +134,25 @@ class roaring_bitmap_storage_ref<cuda::std::uint32_t> {
83134 cuda::std::byte const * container_offsets_;
84135};
85136
137+ /* *
138+ * @brief Reference type for 64-bit roaring bitmap storage
139+ *
140+ * Provides a lightweight reference to a 64-bit roaring bitmap stored in device memory,
141+ * allowing access to the bitmap data, metadata, and bucket information without ownership.
142+ */
86143template <>
87144class roaring_bitmap_storage_ref <cuda::std::uint64_t > {
88145 public:
146+ // / Metadata type for this storage reference
89147 using metadata_type = roaring_bitmap_metadata<cuda::std::uint64_t >;
90148
149+ /* *
150+ * @brief Constructs a storage reference from bitmap data, metadata, and buckets
151+ *
152+ * @param bitmap Pointer to the serialized bitmap in a device-accessible memory location
153+ * @param metadata Metadata describing the bitmap structure
154+ * @param buckets Pointer to the array of bucket references in a device-accessible memory location
155+ */
91156 __host__ __device__ roaring_bitmap_storage_ref (
92157 cuda::std::byte const * bitmap,
93158 metadata_type const & metadata,
@@ -96,12 +161,32 @@ class roaring_bitmap_storage_ref<cuda::std::uint64_t> {
96161 {
97162 }
98163
164+ /* *
165+ * @brief Returns the metadata for this bitmap
166+ *
167+ * @return Reference to the bitmap metadata
168+ */
99169 __host__ __device__ metadata_type const & metadata () const noexcept { return metadata_; }
100170
171+ /* *
172+ * @brief Returns pointer to the raw bitmap data
173+ *
174+ * @return Pointer to the beginning of the bitmap data
175+ */
101176 __host__ __device__ cuda::std::byte const * data () const noexcept { return data_; }
102177
178+ /* *
179+ * @brief Returns the size of the bitmap in bytes
180+ *
181+ * @return Size of the bitmap data in bytes
182+ */
103183 __host__ __device__ cuda::std::size_t size_bytes () const noexcept { return metadata_.size_bytes ; }
104184
185+ /* *
186+ * @brief Returns pointer to the bucket array
187+ *
188+ * @return Pointer to the array of bucket key-reference pairs
189+ */
105190 __host__ __device__
106191 cuda::std::pair<cuda::std::uint32_t , roaring_bitmap_storage_ref<cuda::std::uint32_t >>*
107192 buckets () const noexcept
@@ -120,20 +205,62 @@ struct roaring_bitmap_storage {
120205 static_assert (cuco::dependent_false<T>, " T must be either uint32_t or uint64_t" );
121206};
122207
208+ /* *
209+ * @brief Storage container for 32-bit roaring bitmap
210+ *
211+ * Manages device memory for a 32-bit roaring bitmap, providing ownership
212+ * and automatic memory management.
213+ *
214+ * @tparam Allocator Allocator type for device memory management
215+ */
123216template <class Allocator >
124217class roaring_bitmap_storage <cuda::std::uint32_t , Allocator> {
125218 public:
219+ // / Allocator type for device memory allocation
126220 using allocator_type =
127221 typename std::allocator_traits<Allocator>::template rebind_alloc<cuda::std::byte>;
222+ // / Reference type for this storage
128223 using ref_type = roaring_bitmap_storage_ref<cuda::std::uint32_t >;
129224
130- roaring_bitmap_storage (roaring_bitmap_storage const & other) = default ;
131- roaring_bitmap_storage (roaring_bitmap_storage&& other) = default ;
225+ /* *
226+ * @brief Copy constructor
227+ *
228+ * @param other The roaring_bitmap_storage to copy from
229+ */
230+ roaring_bitmap_storage (roaring_bitmap_storage const & other) = default ;
231+
232+ /* *
233+ * @brief Move constructor
234+ *
235+ * @param other The roaring_bitmap_storage to move from
236+ */
237+ roaring_bitmap_storage (roaring_bitmap_storage&& other) = default ;
238+
239+ /* *
240+ * @brief Copy assignment operator
241+ *
242+ * @param other The roaring_bitmap_storage to copy from
243+ * @return Reference to this roaring_bitmap_storage
244+ */
132245 roaring_bitmap_storage& operator =(roaring_bitmap_storage const & other) = default ;
133- roaring_bitmap_storage& operator =(roaring_bitmap_storage&& other) = default ;
246+
247+ /* *
248+ * @brief Move assignment operator
249+ *
250+ * @param other The roaring_bitmap_storage to move from
251+ * @return Reference to this roaring_bitmap_storage
252+ */
253+ roaring_bitmap_storage& operator =(roaring_bitmap_storage&& other) = default ;
134254
135255 ~roaring_bitmap_storage () = default ;
136256
257+ /* *
258+ * @brief Constructs storage by copying bitmap data to device memory
259+ *
260+ * @param bitmap Pointer to the serialized bitmap data in host memory
261+ * @param alloc Allocator for device memory allocation
262+ * @param stream CUDA stream for memory operations
263+ */
137264 roaring_bitmap_storage (cuda::std::byte const * bitmap,
138265 Allocator const & alloc,
139266 cuda::stream_ref stream)
@@ -148,6 +275,11 @@ class roaring_bitmap_storage<cuda::std::uint32_t, Allocator> {
148275 data_.get (), bitmap, metadata_.size_bytes , cudaMemcpyHostToDevice, stream.get ()));
149276 }
150277
278+ /* *
279+ * @brief Returns a reference to the stored bitmap
280+ *
281+ * @return Reference to the bitmap storage
282+ */
151283 ref_type ref () const noexcept { return ref_; }
152284
153285 private:
@@ -158,23 +290,67 @@ class roaring_bitmap_storage<cuda::std::uint32_t, Allocator> {
158290 ref_type ref_;
159291};
160292
293+ /* *
294+ * @brief Storage container for 64-bit roaring bitmap
295+ *
296+ * Manages device memory for a 64-bit roaring bitmap, providing ownership
297+ * and automatic memory management including bucket storage.
298+ *
299+ * @tparam Allocator Allocator type for device memory management
300+ */
161301template <class Allocator >
162302class roaring_bitmap_storage <cuda::std::uint64_t , Allocator> {
163303 public:
304+ // / Allocator type for device memory allocation
164305 using allocator_type =
165306 typename std::allocator_traits<Allocator>::template rebind_alloc<cuda::std::byte>;
166- using ref_type = roaring_bitmap_storage_ref<cuda::std::uint64_t >;
167- using bucket_ref_type = roaring_bitmap_storage_ref<cuda::std::uint32_t >;
307+ // / Reference type for this storage
308+ using ref_type = roaring_bitmap_storage_ref<cuda::std::uint64_t >;
309+ // / Reference type for individual buckets
310+ using bucket_ref_type = roaring_bitmap_storage_ref<cuda::std::uint32_t >;
311+ // / Allocator type for bucket array allocation
168312 using bucket_allocator_type = typename std::allocator_traits<Allocator>::template rebind_alloc<
169313 cuda::std::pair<cuda::std::uint32_t , bucket_ref_type>>;
170314
171- roaring_bitmap_storage (roaring_bitmap_storage const & other) = default ;
172- roaring_bitmap_storage (roaring_bitmap_storage&& other) = default ;
315+ /* *
316+ * @brief Copy constructor
317+ *
318+ * @param other The roaring_bitmap_storage to copy from
319+ */
320+ roaring_bitmap_storage (roaring_bitmap_storage const & other) = default ;
321+
322+ /* *
323+ * @brief Move constructor
324+ *
325+ * @param other The roaring_bitmap_storage to move from
326+ */
327+ roaring_bitmap_storage (roaring_bitmap_storage&& other) = default ;
328+
329+ /* *
330+ * @brief Copy assignment operator
331+ *
332+ * @param other The roaring_bitmap_storage to copy from
333+ * @return Reference to this roaring_bitmap_storage
334+ */
173335 roaring_bitmap_storage& operator =(roaring_bitmap_storage const & other) = default ;
174- roaring_bitmap_storage& operator =(roaring_bitmap_storage&& other) = default ;
336+
337+ /* *
338+ * @brief Move assignment operator
339+ *
340+ * @param other The roaring_bitmap_storage to move from
341+ * @return Reference to this roaring_bitmap_storage
342+ */
343+ roaring_bitmap_storage& operator =(roaring_bitmap_storage&& other) = default ;
175344
176345 ~roaring_bitmap_storage () = default ;
177346
347+ /* *
348+ * @brief Constructs storage by copying bitmap data to device memory
349+ *
350+ * @param bitmap Pointer to the serialized bitmap data in host memory
351+ * @param alloc Allocator for device memory allocation
352+ * @param stream CUDA stream for memory operations
353+ */
178354 roaring_bitmap_storage (cuda::std::byte const * bitmap,
179355 Allocator const & alloc,
180356 cuda::stream_ref stream)
@@ -210,6 +386,11 @@ class roaring_bitmap_storage<cuda::std::uint64_t, Allocator> {
210386 stream.get ()));
211387 }
212388
389+ /* *
390+ * @brief Returns a reference to the stored bitmap
391+ *
392+ * @return Reference to the bitmap storage
393+ */
213394 ref_type ref () const noexcept { return ref_; }
214395
215396 private:
0 commit comments