@@ -26,6 +26,9 @@ use std::fmt::Write;
26
26
use std:: sync:: Arc ;
27
27
28
28
/// Builder for [`GenericByteArray`]
29
+ ///
30
+ /// For building strings, see docs on [`GenericStringBuilder`].
31
+ /// For building binary, see docs on [`GenericBinaryBuilder`].
29
32
pub struct GenericByteBuilder < T : ByteArrayType > {
30
33
value_builder : UInt8BufferBuilder ,
31
34
offsets_builder : BufferBuilder < T :: Offset > ,
@@ -222,11 +225,12 @@ impl<T: ByteArrayType, V: AsRef<T::Native>> Extend<Option<V>> for GenericByteBui
222
225
/// Array builder for [`GenericStringArray`][crate::GenericStringArray]
223
226
///
224
227
/// Values can be appended using [`GenericByteBuilder::append_value`], and nulls with
225
- /// [`GenericByteBuilder::append_null`] as normal .
228
+ /// [`GenericByteBuilder::append_null`].
226
229
///
227
- /// Additionally implements [`std::fmt::Write`] with any written data included in the next
230
+ /// Additionally, implements [`std::fmt::Write`] with any written data included in the next
228
231
/// appended value. This allows use with [`std::fmt::Display`] without intermediate allocations
229
232
///
233
+ /// # Example
230
234
/// ```
231
235
/// # use std::fmt::Write;
232
236
/// # use arrow_array::builder::GenericStringBuilder;
@@ -257,6 +261,26 @@ impl<O: OffsetSizeTrait> Write for GenericStringBuilder<O> {
257
261
}
258
262
259
263
/// Array builder for [`GenericBinaryArray`][crate::GenericBinaryArray]
264
+ ///
265
+ /// Values can be appended using [`GenericByteBuilder::append_value`], and nulls with
266
+ /// [`GenericByteBuilder::append_null`].
267
+ ///
268
+ /// # Example
269
+ /// ```
270
+ /// # use arrow_array::builder::GenericBinaryBuilder;
271
+ /// let mut builder = GenericBinaryBuilder::<i32>::new();
272
+ ///
273
+ /// // Write data
274
+ /// builder.append_value("foo");
275
+ ///
276
+ /// // Write second value
277
+ /// builder.append_value(&[0,1,2]);
278
+ ///
279
+ /// let array = builder.finish();
280
+ /// // binary values
281
+ /// assert_eq!(array.value(0), b"foo");
282
+ /// assert_eq!(array.value(1), b"\x00\x01\x02");
283
+ /// ```
260
284
pub type GenericBinaryBuilder < O > = GenericByteBuilder < GenericBinaryType < O > > ;
261
285
262
286
#[ cfg( test) ]
0 commit comments