Skip to content

Commit e608bd7

Browse files
committed
chore: add docs, part of #37
- add pragma `#![warn(missing_docs)]` to `arrow`, `arrow-arith`, `arrow-avro` - add docs to the same to remove lint warnings
1 parent 1390283 commit e608bd7

File tree

9 files changed

+62
-21
lines changed

9 files changed

+62
-21
lines changed

arrow-array/src/ffi_stream.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,18 @@ const ENOSYS: i32 = 78;
8383
/// This was created by bindgen
8484
#[repr(C)]
8585
#[derive(Debug)]
86-
#[allow(missing_docs)]
86+
#[allow(non_camel_case_types)]
8787
pub struct FFI_ArrowArrayStream {
88-
pub get_schema: Option<
89-
unsafe extern "C" fn(arg1: *mut FFI_ArrowArrayStream, out: *mut FFI_ArrowSchema) -> c_int,
90-
>,
91-
pub get_next: Option<
92-
unsafe extern "C" fn(arg1: *mut FFI_ArrowArrayStream, out: *mut FFI_ArrowArray) -> c_int,
93-
>,
94-
pub get_last_error:
95-
Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowArrayStream) -> *const c_char>,
96-
pub release: Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowArrayStream)>,
88+
/// C function to get schema from the stream
89+
pub get_schema:
90+
Option<unsafe extern "C" fn(arg1: *mut Self, out: *mut FFI_ArrowSchema) -> c_int>,
91+
/// C function to get next array from the stream
92+
pub get_next: Option<unsafe extern "C" fn(arg1: *mut Self, out: *mut FFI_ArrowArray) -> c_int>,
93+
/// C function to get the error from last operation on the stream
94+
pub get_last_error: Option<unsafe extern "C" fn(arg1: *mut Self) -> *const c_char>,
95+
/// C function to release the stream
96+
pub release: Option<unsafe extern "C" fn(arg1: *mut Self)>,
97+
/// Private data used by the stream
9798
pub private_data: *mut c_void,
9899
}
99100

arrow-avro/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
//! [Apache Arrow]: https://arrow.apache.org
2121
//! [Apache Avro]: https://avro.apache.org/
2222
23+
#![warn(missing_docs)]
2324
#![allow(unused)] // Temporary
2425

2526
pub mod reader;

arrow/src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@
1919
2020
pub use arrow_schema::ArrowError;
2121

22+
/// A specialized `Result` type for Arrow operations.
2223
pub type Result<T> = std::result::Result<T, ArrowError>;

arrow/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@
364364
365365
#![deny(clippy::redundant_clone)]
366366
#![warn(missing_debug_implementations)]
367+
#![warn(missing_docs)]
367368
#![allow(rustdoc::invalid_html_tags)]
368369
pub use arrow_array::{downcast_dictionary_array, downcast_primitive_array};
369370

@@ -389,6 +390,7 @@ pub use arrow_json as json;
389390
#[cfg(feature = "pyarrow")]
390391
pub mod pyarrow;
391392

393+
/// Contains the `RecordBatch` type and associated traits
392394
pub mod record_batch {
393395
pub use arrow_array::{
394396
RecordBatch, RecordBatchIterator, RecordBatchOptions, RecordBatchReader, RecordBatchWriter,

arrow/src/tensor.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,36 +80,67 @@ pub struct Tensor<'a, T: ArrowPrimitiveType> {
8080
_marker: PhantomData<T>,
8181
}
8282

83+
/// [Tensor] of type [BooleanType]
8384
pub type BooleanTensor<'a> = Tensor<'a, BooleanType>;
85+
/// [Tensor] of type [Int8Type]
8486
pub type Date32Tensor<'a> = Tensor<'a, Date32Type>;
87+
/// [Tensor] of type [Int16Type]
8588
pub type Date64Tensor<'a> = Tensor<'a, Date64Type>;
89+
/// [Tensor] of type [Decimal128Type]
8690
pub type Decimal128Tensor<'a> = Tensor<'a, Decimal128Type>;
91+
/// [Tensor] of type [Decimal256Type]
8792
pub type Decimal256Tensor<'a> = Tensor<'a, Decimal256Type>;
93+
/// [Tensor] of type [DurationMicrosecondType]
8894
pub type DurationMicrosecondTensor<'a> = Tensor<'a, DurationMicrosecondType>;
95+
/// [Tensor] of type [DurationMillisecondType]
8996
pub type DurationMillisecondTensor<'a> = Tensor<'a, DurationMillisecondType>;
97+
/// [Tensor] of type [DurationNanosecondType]
9098
pub type DurationNanosecondTensor<'a> = Tensor<'a, DurationNanosecondType>;
99+
/// [Tensor] of type [DurationSecondType]
91100
pub type DurationSecondTensor<'a> = Tensor<'a, DurationSecondType>;
101+
/// [Tensor] of type [Float16Type]
92102
pub type Float16Tensor<'a> = Tensor<'a, Float16Type>;
103+
/// [Tensor] of type [Float32Type]
93104
pub type Float32Tensor<'a> = Tensor<'a, Float32Type>;
105+
/// [Tensor] of type [Float64Type]
94106
pub type Float64Tensor<'a> = Tensor<'a, Float64Type>;
107+
/// [Tensor] of type [Int8Type]
95108
pub type Int8Tensor<'a> = Tensor<'a, Int8Type>;
109+
/// [Tensor] of type [Int16Type]
96110
pub type Int16Tensor<'a> = Tensor<'a, Int16Type>;
111+
/// [Tensor] of type [Int32Type]
97112
pub type Int32Tensor<'a> = Tensor<'a, Int32Type>;
113+
/// [Tensor] of type [Int64Type]
98114
pub type Int64Tensor<'a> = Tensor<'a, Int64Type>;
115+
/// [Tensor] of type [IntervalDayTimeType]
99116
pub type IntervalDayTimeTensor<'a> = Tensor<'a, IntervalDayTimeType>;
117+
/// [Tensor] of type [IntervalMonthDayNanoType]
100118
pub type IntervalMonthDayNanoTensor<'a> = Tensor<'a, IntervalMonthDayNanoType>;
119+
/// [Tensor] of type [IntervalYearMonthType]
101120
pub type IntervalYearMonthTensor<'a> = Tensor<'a, IntervalYearMonthType>;
121+
/// [Tensor] of type [Time32MillisecondType]
102122
pub type Time32MillisecondTensor<'a> = Tensor<'a, Time32MillisecondType>;
123+
/// [Tensor] of type [Time32SecondType]
103124
pub type Time32SecondTensor<'a> = Tensor<'a, Time32SecondType>;
125+
/// [Tensor] of type [Time64MicrosecondType]
104126
pub type Time64MicrosecondTensor<'a> = Tensor<'a, Time64MicrosecondType>;
127+
/// [Tensor] of type [Time64NanosecondType]
105128
pub type Time64NanosecondTensor<'a> = Tensor<'a, Time64NanosecondType>;
129+
/// [Tensor] of type [TimestampMicrosecondType]
106130
pub type TimestampMicrosecondTensor<'a> = Tensor<'a, TimestampMicrosecondType>;
131+
/// [Tensor] of type [TimestampMillisecondType]
107132
pub type TimestampMillisecondTensor<'a> = Tensor<'a, TimestampMillisecondType>;
133+
/// [Tensor] of type [TimestampNanosecondType]
108134
pub type TimestampNanosecondTensor<'a> = Tensor<'a, TimestampNanosecondType>;
135+
/// [Tensor] of type [TimestampSecondType]
109136
pub type TimestampSecondTensor<'a> = Tensor<'a, TimestampSecondType>;
137+
/// [Tensor] of type [UInt8Type]
110138
pub type UInt8Tensor<'a> = Tensor<'a, UInt8Type>;
139+
/// [Tensor] of type [UInt16Type]
111140
pub type UInt16Tensor<'a> = Tensor<'a, UInt16Type>;
141+
/// [Tensor] of type [UInt32Type]
112142
pub type UInt32Tensor<'a> = Tensor<'a, UInt32Type>;
143+
/// [Tensor] of type [UInt64Type]
113144
pub type UInt64Tensor<'a> = Tensor<'a, UInt64Type>;
114145

115146
impl<'a, T: ArrowPrimitiveType> Tensor<'a, T> {

arrow/src/util/bench_util.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ where
5050
.collect()
5151
}
5252

53+
/// Creates a [`PrimitiveArray`] of a given `size` and `null_density`
54+
/// filling it with random numbers generated using the provided `seed`.
5355
pub fn create_primitive_array_with_seed<T>(
5456
size: usize,
5557
null_density: f32,
@@ -72,6 +74,8 @@ where
7274
.collect()
7375
}
7476

77+
/// Creates a [`PrimitiveArray`] of a given `size` and `null_density`
78+
/// filling it with random [`IntervalMonthDayNano`] generated using the provided `seed`.
7579
pub fn create_month_day_nano_array_with_seed(
7680
size: usize,
7781
null_density: f32,

arrow/src/util/data_gen.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,15 +394,18 @@ fn create_random_null_buffer(size: usize, null_density: f32) -> Buffer {
394394
/// Useful for testing. The range of values are not likely to be representative of the
395395
/// actual bounds.
396396
pub trait RandomTemporalValue: ArrowTemporalType {
397+
/// Returns the range of values for `impl`'d type
397398
fn value_range() -> impl SampleRange<Self::Native>;
398399

400+
/// Generate a random value within the range of the type
399401
fn gen_range<R: Rng>(rng: &mut R) -> Self::Native
400402
where
401403
Self::Native: SampleUniform,
402404
{
403405
rng.gen_range(Self::value_range())
404406
}
405407

408+
/// Generate a random value of the type
406409
fn random<R: Rng>(rng: &mut R) -> Self::Native
407410
where
408411
Self::Native: SampleUniform,

arrow/src/util/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
//! Utility functions for working with Arrow data
1819
pub use arrow_buffer::{bit_chunk_iterator, bit_util};
1920

2021
pub use arrow_data::bit_iterator;

arrow/src/util/string_writer.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,24 @@
6363
//! }
6464
//! ```
6565
66+
use core::str;
6667
use std::fmt::Formatter;
6768
use std::io::{Error, ErrorKind, Result, Write};
6869

69-
#[derive(Debug)]
70+
/// A writer that allows writing to a `String`
71+
/// like an `std::io::Write` object.
72+
#[derive(Debug, Default)]
7073
pub struct StringWriter {
7174
data: String,
7275
}
7376

7477
impl StringWriter {
78+
/// Create a new `StringWriter`
7579
pub fn new() -> Self {
76-
StringWriter {
77-
data: String::new(),
78-
}
80+
Self::default()
7981
}
8082
}
8183

82-
impl Default for StringWriter {
83-
fn default() -> Self {
84-
Self::new()
85-
}
86-
}
8784
impl std::fmt::Display for StringWriter {
8885
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
8986
write!(f, "{}", self.data)
@@ -92,13 +89,13 @@ impl std::fmt::Display for StringWriter {
9289

9390
impl Write for StringWriter {
9491
fn write(&mut self, buf: &[u8]) -> Result<usize> {
95-
let string = match String::from_utf8(buf.to_vec()) {
92+
let string = match str::from_utf8(buf) {
9693
Ok(x) => x,
9794
Err(e) => {
9895
return Err(Error::new(ErrorKind::InvalidData, e));
9996
}
10097
};
101-
self.data.push_str(&string);
98+
self.data.push_str(string);
10299
Ok(string.len())
103100
}
104101

0 commit comments

Comments
 (0)