Package org.apache.spark.unsafe.types
Class CalendarInterval
Object
org.apache.spark.unsafe.types.CalendarInterval
- All Implemented Interfaces:
Serializable
,Comparable<CalendarInterval>
@Unstable
public final class CalendarInterval
extends Object
implements Serializable, Comparable<CalendarInterval>
The class representing calendar intervals. The calendar interval is stored internally in
three components:
- an integer value representing the number of `months` in this interval,
- an integer value representing the number of `days` in this interval,
- a long value representing the number of `microseconds` in this interval.
- Since:
- 3.0.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
months
public final int months -
days
public final int days -
microseconds
public final long microseconds
-
-
Constructor Details
-
CalendarInterval
public CalendarInterval(int months, int days, long microseconds)
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
toString
-
extractAsPeriod
Extracts the date part of the interval.- Returns:
- an instance of
java.time.Period
based on the months and days fields of the given interval, not null.
-
extractAsDuration
Extracts the time part of the interval.- Returns:
- an instance of
java.time.Duration
based on the microseconds field of the given interval, not null. - Throws:
ArithmeticException
- if a numeric overflow occurs
-
compareTo
This method is not used to order CalendarInterval instances, as they are not orderable and cannot be used in a ORDER BY statement. Instead, it is used to find identical interval instances for aggregation purposes. It compares the 'months', 'days', and 'microseconds' fields of this CalendarInterval with another instance. The comparison is done first on the 'months', then on the 'days', and finally on the 'microseconds'.- Specified by:
compareTo
in interfaceComparable<CalendarInterval>
- Parameters:
o
- The CalendarInterval instance to compare with.- Returns:
- Zero if this object is equal to the specified object, and non-zero otherwise
-