@@ -52,7 +52,7 @@ use super::ByteArrayType;
52
52
/// not by value. as there are many different buffer layouts to represent the
53
53
/// same data (e.g. different offsets, different buffer sizes, etc).
54
54
///
55
- /// # Layout
55
+ /// # Layout: "views" and buffers
56
56
///
57
57
/// A `GenericByteViewArray` stores variable length byte strings. An array of
58
58
/// `N` elements is stored as `N` fixed length "views" and a variable number
@@ -75,10 +75,12 @@ use super::ByteArrayType;
75
75
/// 0 31 63 95 127
76
76
/// ```
77
77
///
78
- /// * Strings with length <= 12 are stored directly in the view.
78
+ /// * Strings with length <= 12 are stored directly in the view. See
79
+ /// [`Self::inline_value`] to access the inlined prefix from a short view.
79
80
///
80
81
/// * Strings with length > 12: The first four bytes are stored inline in the
81
- /// view and the entire string is stored in one of the buffers.
82
+ /// view and the entire string is stored in one of the buffers. See [`ByteView`]
83
+ /// to access the fields of the these views.
82
84
///
83
85
/// Unlike [`GenericByteArray`], there are no constraints on the offsets other
84
86
/// than they must point into a valid buffer. However, they can be out of order,
@@ -89,6 +91,8 @@ use super::ByteArrayType;
89
91
/// separate buffer while the string "LavaMonster" is stored inlined in the
90
92
/// view. In this case, the same bytes for "Fish" are used to store both strings.
91
93
///
94
+ /// [`ByteView`]: arrow_data::ByteView
95
+ ///
92
96
/// ```text
93
97
/// ┌───┐
94
98
/// ┌──────┬──────┬──────┬──────┐ offset │...│
@@ -261,9 +265,12 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> {
261
265
unsafe { self . value_unchecked ( i) }
262
266
}
263
267
264
- /// Returns the element at index `i`
268
+ /// Returns the element at index `i` without bounds checking
269
+ ///
265
270
/// # Safety
266
- /// Caller is responsible for ensuring that the index is within the bounds of the array
271
+ ///
272
+ /// Caller is responsible for ensuring that the index is within the bounds
273
+ /// of the array
267
274
pub unsafe fn value_unchecked ( & self , idx : usize ) -> & T :: Native {
268
275
let v = self . views . get_unchecked ( idx) ;
269
276
let len = * v as u32 ;
@@ -278,7 +285,7 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> {
278
285
T :: Native :: from_bytes_unchecked ( b)
279
286
}
280
287
281
- /// Returns the inline value of the view.
288
+ /// Returns the first `len` bytes the inline value of the view.
282
289
///
283
290
/// # Safety
284
291
/// - The `view` must be a valid element from `Self::views()` that adheres to the view layout.
@@ -289,7 +296,7 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> {
289
296
std:: slice:: from_raw_parts ( ( view as * const u128 as * const u8 ) . wrapping_add ( 4 ) , len)
290
297
}
291
298
292
- /// constructs a new iterator
299
+ /// Constructs a new iterator for iterating over the values of this array
293
300
pub fn iter ( & self ) -> ArrayIter < & Self > {
294
301
ArrayIter :: new ( self )
295
302
}
@@ -358,7 +365,7 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> {
358
365
builder. finish ( )
359
366
}
360
367
361
- /// Comparing two [`GenericByteViewArray`] at index `left_idx` and `right_idx`
368
+ /// Compare two [`GenericByteViewArray`] at index `left_idx` and `right_idx`
362
369
///
363
370
/// Comparing two ByteView types are non-trivial.
364
371
/// It takes a bit of patience to understand why we don't just compare two &[u8] directly.
0 commit comments