Skip to content

Commit

Permalink
Add Type Declarations for All Primitive Tensors and Buffer Builders (#…
Browse files Browse the repository at this point in the history
…4113)

* feat: support all primitive tensors and buffer builders

* fix: cargo fmt
  • Loading branch information
izveigor authored Apr 25, 2023
1 parent b26d943 commit be33ec5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
10 changes: 10 additions & 0 deletions arrow-array/src/builder/buffer_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use crate::array::ArrowPrimitiveType;
use arrow_buffer::{ArrowNativeType, Buffer, MutableBuffer};
use half::f16;
use std::marker::PhantomData;

use crate::types::*;
Expand All @@ -37,11 +38,20 @@ pub type UInt16BufferBuilder = BufferBuilder<u16>;
pub type UInt32BufferBuilder = BufferBuilder<u32>;
/// Buffer builder for usigned 64-bit integer type.
pub type UInt64BufferBuilder = BufferBuilder<u64>;
/// Buffer builder for 16-bit floating point type.
pub type Float16BufferBuilder = BufferBuilder<f16>;
/// Buffer builder for 32-bit floating point type.
pub type Float32BufferBuilder = BufferBuilder<f32>;
/// Buffer builder for 64-bit floating point type.
pub type Float64BufferBuilder = BufferBuilder<f64>;

/// Buffer builder for 128-bit decimal type.
pub type Decimal128BufferBuilder =
BufferBuilder<<Decimal128Type as ArrowPrimitiveType>::Native>;
/// Buffer builder for 256-bit decimal type.
pub type Decimal256BufferBuilder =
BufferBuilder<<Decimal256Type as ArrowPrimitiveType>::Native>;

/// Buffer builder for timestamp type of second unit.
pub type TimestampSecondBufferBuilder =
BufferBuilder<<TimestampSecondType as ArrowPrimitiveType>::Native>;
Expand Down
25 changes: 22 additions & 3 deletions arrow/src/tensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,36 @@ pub struct Tensor<'a, T: ArrowPrimitiveType> {
}

pub type BooleanTensor<'a> = Tensor<'a, BooleanType>;
pub type Date32Tensor<'a> = Tensor<'a, Date32Type>;
pub type Date64Tensor<'a> = Tensor<'a, Date64Type>;
pub type Decimal128Tensor<'a> = Tensor<'a, Decimal128Type>;
pub type Decimal256Tensor<'a> = Tensor<'a, Decimal256Type>;
pub type DurationMicrosecondTensor<'a> = Tensor<'a, DurationMicrosecondType>;
pub type DurationMillisecondTensor<'a> = Tensor<'a, DurationMillisecondType>;
pub type DurationNanosecondTensor<'a> = Tensor<'a, DurationNanosecondType>;
pub type DurationSecondTensor<'a> = Tensor<'a, DurationSecondType>;
pub type Float16Tensor<'a> = Tensor<'a, Float16Type>;
pub type Float32Tensor<'a> = Tensor<'a, Float32Type>;
pub type Float64Tensor<'a> = Tensor<'a, Float64Type>;
pub type Int8Tensor<'a> = Tensor<'a, Int8Type>;
pub type Int16Tensor<'a> = Tensor<'a, Int16Type>;
pub type Int32Tensor<'a> = Tensor<'a, Int32Type>;
pub type Int64Tensor<'a> = Tensor<'a, Int64Type>;
pub type IntervalDayTimeTensor<'a> = Tensor<'a, IntervalDayTimeType>;
pub type IntervalMonthDayNanoTensor<'a> = Tensor<'a, IntervalMonthDayNanoType>;
pub type IntervalYearMonthTensor<'a> = Tensor<'a, IntervalYearMonthType>;
pub type Time32MillisecondTensor<'a> = Tensor<'a, Time32MillisecondType>;
pub type Time32SecondTensor<'a> = Tensor<'a, Time32SecondType>;
pub type Time64MicrosecondTensor<'a> = Tensor<'a, Time64MicrosecondType>;
pub type Time64NanosecondTensor<'a> = Tensor<'a, Time64NanosecondType>;
pub type TimestampMicrosecondTensor<'a> = Tensor<'a, TimestampMicrosecondType>;
pub type TimestampMillisecondTensor<'a> = Tensor<'a, TimestampMillisecondType>;
pub type TimestampNanosecondTensor<'a> = Tensor<'a, TimestampNanosecondType>;
pub type TimestampSecondTensor<'a> = Tensor<'a, TimestampSecondType>;
pub type UInt8Tensor<'a> = Tensor<'a, UInt8Type>;
pub type UInt16Tensor<'a> = Tensor<'a, UInt16Type>;
pub type UInt32Tensor<'a> = Tensor<'a, UInt32Type>;
pub type UInt64Tensor<'a> = Tensor<'a, UInt64Type>;
pub type Float16Tensor<'a> = Tensor<'a, Float16Type>;
pub type Float32Tensor<'a> = Tensor<'a, Float32Type>;
pub type Float64Tensor<'a> = Tensor<'a, Float64Type>;

impl<'a, T: ArrowPrimitiveType> Tensor<'a, T> {
/// Creates a new `Tensor`
Expand Down

0 comments on commit be33ec5

Please sign in to comment.