viirya commented on code in PR #2031:
URL: https://github.com/apache/arrow-rs/pull/2031#discussion_r917149020


##########
arrow/src/datatypes/types.rs:
##########
@@ -191,3 +194,166 @@ impl ArrowTimestampType for TimestampNanosecondType {
         TimeUnit::Nanosecond
     }
 }
+
+impl IntervalYearMonthType {
+    /// Creates a IntervalYearMonthType
+    ///
+    /// # Arguments
+    ///
+    /// * `years` - The number of years (+/-) represented in this interval
+    /// * `months` - The number of months (+/-) represented in this interval
+    pub fn new(
+        years: i32,
+        months: i32,
+    ) -> <IntervalYearMonthType as ArrowPrimitiveType>::Native {
+        years * 12 + months
+    }
+
+    pub fn to_months(i: <IntervalYearMonthType as ArrowPrimitiveType>::Native) 
-> i32 {
+        i
+    }
+}
+
+impl IntervalDayTimeType {
+    /// Creates a IntervalDayTimeType
+    ///
+    /// # Arguments
+    ///
+    /// * `days` - The number of days (+/-) represented in this interval
+    /// * `millis` - The number of milliseconds (+/-) represented in this 
interval
+    pub fn new(
+        days: i32,
+        millis: i32,
+    ) -> <IntervalDayTimeType as ArrowPrimitiveType>::Native {
+        let m = millis as u64 & u32::MAX as u64;
+        let d = (days as u64 & u32::MAX as u64) << 32;
+        (m | d) as <IntervalDayTimeType as ArrowPrimitiveType>::Native
+    }
+
+    pub fn to_parts(
+        i: <IntervalDayTimeType as ArrowPrimitiveType>::Native,
+    ) -> (i32, i32) {
+        let days = (i >> 32) as i32;
+        let ms = i as i32;
+        (days, ms)
+    }
+}
+
+impl IntervalMonthDayNanoType {
+    /// Creates a IntervalMonthDayNanoType
+    ///
+    /// # Arguments
+    ///
+    /// * `months` - The number of months (+/-) represented in this interval
+    /// * `days` - The number of days (+/-) represented in this interval
+    /// * `nanos` - The number of nanoseconds (+/-) represented in this 
interval
+    pub fn new(
+        months: i32,
+        days: i32,
+        nanos: i64,
+    ) -> <IntervalMonthDayNanoType as ArrowPrimitiveType>::Native {
+        let m = months as u128 & u32::MAX as u128;
+        let d = (days as u128 & u32::MAX as u128) << 32;
+        let n = (nanos as u128) << 64;
+        (m | d | n) as <IntervalMonthDayNanoType as ArrowPrimitiveType>::Native
+    }
+
+    pub fn to_parts(
+        i: <IntervalMonthDayNanoType as ArrowPrimitiveType>::Native,
+    ) -> (i32, i32, i64) {
+        let nanos = (i >> 64) as i64;
+        let days = (i >> 32) as i32;
+        let months = i as i32;
+        (months, days, nanos)
+    }
+}
+
+impl Date32Type {

Review Comment:
   It's better to add doc to public methods.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to