This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new be33ec5a3 Add Type Declarations for All Primitive Tensors and Buffer
Builders (#4113)
be33ec5a3 is described below
commit be33ec5a397b8ece12c9baf87af66a73848a24ab
Author: Igor Izvekov <[email protected]>
AuthorDate: Tue Apr 25 20:03:03 2023 +0300
Add Type Declarations for All Primitive Tensors and Buffer Builders (#4113)
* feat: support all primitive tensors and buffer builders
* fix: cargo fmt
---
arrow-array/src/builder/buffer_builder.rs | 10 ++++++++++
arrow/src/tensor.rs | 25 ++++++++++++++++++++++---
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/arrow-array/src/builder/buffer_builder.rs
b/arrow-array/src/builder/buffer_builder.rs
index d4eed0de9..f88a63920 100644
--- a/arrow-array/src/builder/buffer_builder.rs
+++ b/arrow-array/src/builder/buffer_builder.rs
@@ -17,6 +17,7 @@
use crate::array::ArrowPrimitiveType;
use arrow_buffer::{ArrowNativeType, Buffer, MutableBuffer};
+use half::f16;
use std::marker::PhantomData;
use crate::types::*;
@@ -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>;
diff --git a/arrow/src/tensor.rs b/arrow/src/tensor.rs
index b2abffc51..299c4f2b8 100644
--- a/arrow/src/tensor.rs
+++ b/arrow/src/tensor.rs
@@ -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`