File tree 5 files changed +45
-12
lines changed
5 files changed +45
-12
lines changed Original file line number Diff line number Diff line change 15
15
// specific language governing permissions and limitations
16
16
// under the License.
17
17
18
- //! Functions for Base64 encoding/decoding
18
+ //! Functions for converting data in [`GenericBinaryArray`] such as [`StringArray`] to/from base64 encoded strings
19
+ //!
20
+ //! [`StringArray`]: arrow_array::StringArray
19
21
20
22
use arrow_array:: { Array , GenericBinaryArray , GenericStringArray , OffsetSizeTrait } ;
21
23
use arrow_buffer:: OffsetBuffer ;
@@ -25,7 +27,7 @@ use base64::engine::Config;
25
27
26
28
pub use base64:: prelude:: * ;
27
29
28
- /// Bas64 encode each element of `array` with the provided `engine`
30
+ /// Bas64 encode each element of `array` with the provided [`Engine`]
29
31
pub fn b64_encode < E : Engine , O : OffsetSizeTrait > (
30
32
engine : & E ,
31
33
array : & GenericBinaryArray < O > ,
@@ -51,7 +53,7 @@ pub fn b64_encode<E: Engine, O: OffsetSizeTrait>(
51
53
unsafe { GenericStringArray :: new_unchecked ( offsets, buffer. into ( ) , array. nulls ( ) . cloned ( ) ) }
52
54
}
53
55
54
- /// Base64 decode each element of `array` with the provided `engine`
56
+ /// Base64 decode each element of `array` with the provided [`Engine`]
55
57
pub fn b64_decode < E : Engine , O : OffsetSizeTrait > (
56
58
engine : & E ,
57
59
array : & GenericBinaryArray < O > ,
Original file line number Diff line number Diff line change 15
15
// specific language governing permissions and limitations
16
16
// under the License.
17
17
18
- //! Functions for printing array values, as strings, for debugging
19
- //! purposes. See the `pretty` crate for additional functions for
18
+ //! Functions for printing array values as human-readable strings.
19
+ //!
20
+ //! This is often used for debugging or logging purposes.
21
+ //!
22
+ //! See the [`pretty`] crate for additional functions for
20
23
//! record batch pretty printing.
21
-
24
+ //!
25
+ //! [`pretty`]: crate::pretty
22
26
use std:: fmt:: { Display , Formatter , Write } ;
23
27
use std:: ops:: Range ;
24
28
Original file line number Diff line number Diff line change 15
15
// specific language governing permissions and limitations
16
16
// under the License.
17
17
18
- //! Cast kernel for [Apache Arrow](https://docs.rs/arrow)
19
-
18
+ //! Functions for converting from one data type to another in [Apache Arrow](https://docs.rs/arrow)
20
19
pub mod cast;
21
20
pub use cast:: * ;
22
21
pub mod display;
Original file line number Diff line number Diff line change 15
15
// specific language governing permissions and limitations
16
16
// under the License.
17
17
18
+ //! [`Parser`] implementations for converting strings to Arrow types
19
+ //!
20
+ //! Used by the CSV and JSON readers to convert strings to Arrow types
18
21
use arrow_array:: timezone:: Tz ;
19
22
use arrow_array:: types:: * ;
20
23
use arrow_array:: ArrowNativeTypeOp ;
@@ -405,8 +408,29 @@ fn string_to_time(s: &str) -> Option<NaiveTime> {
405
408
)
406
409
}
407
410
408
- /// Specialized parsing implementations
409
- /// used by csv and json reader
411
+ /// Specialized parsing implementations to convert strings to Arrow types.
412
+ ///
413
+ /// This is used by csv and json reader and can be used directly as well.
414
+ ///
415
+ /// # Example
416
+ ///
417
+ /// To parse a string to a [`Date32Type`]:
418
+ ///
419
+ /// ```
420
+ /// use arrow_cast::parse::Parser;
421
+ /// use arrow_array::types::Date32Type;
422
+ /// let date = Date32Type::parse("2021-01-01").unwrap();
423
+ /// assert_eq!(date, 18628);
424
+ /// ```
425
+ ///
426
+ /// To parse a string to a [`TimestampNanosecondType`]:
427
+ ///
428
+ /// ```
429
+ /// use arrow_cast::parse::Parser;
430
+ /// use arrow_array::types::TimestampNanosecondType;
431
+ /// let ts = TimestampNanosecondType::parse("2021-01-01T00:00:00.123456789Z").unwrap();
432
+ /// assert_eq!(ts, 1609459200123456789);
433
+ /// ```
410
434
pub trait Parser : ArrowPrimitiveType {
411
435
fn parse ( string : & str ) -> Option < Self :: Native > ;
412
436
Original file line number Diff line number Diff line change 15
15
// specific language governing permissions and limitations
16
16
// under the License.
17
17
18
- //! Utilities for pretty printing record batches. Note this module is not
19
- //! available unless `feature = "prettyprint"` is enabled.
18
+ //! Utilities for pretty printing [`RecordBatch`]es and [`Array`]s.
19
+ //!
20
+ //! Note this module is not available unless `feature = "prettyprint"` is enabled.
21
+ //!
22
+ //! [`RecordBatch`]: arrow_array::RecordBatch
23
+ //! [`Array`]: arrow_array::Array
20
24
21
25
use std:: fmt:: Display ;
22
26
You can’t perform that action at this time.
0 commit comments