OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.tests.DateTimeTest.DateExtractUnit Enum Reference
+ Collaboration diagram for com.mapd.tests.DateTimeTest.DateExtractUnit:

Public Attributes

 daYEAR
 
 daQUARTER
 
 daMONTH
 
 daDAY
 
 daHOUR
 
 daMINUTE
 
 daSECOND
 
 daMILLISECOND
 
 daMICROSECOND
 
 daNANOSECOND
 
 daWEEK
 
 daDAYOFYEAR
 

Private Member Functions

 DateExtractUnit (String token, Function< LocalDateTime, Long > f)
 

Private Attributes

String sqlToken
 
Function< LocalDateTime, Long > extract
 

Detailed Description

Definition at line 203 of file DateTimeTest.java.

Constructor & Destructor Documentation

com.mapd.tests.DateTimeTest.DateExtractUnit.DateExtractUnit ( String  token,
Function< LocalDateTime, Long >  f 
)
inlineprivate

Definition at line 334 of file DateTimeTest.java.

References f().

334  {
335  this.sqlToken = token;
336  this.extract = f;
337  }
torch::Tensor f(torch::Tensor x, torch::Tensor W_target, torch::Tensor b_target)

+ Here is the call graph for this function:

Member Data Documentation

com.mapd.tests.DateTimeTest.DateExtractUnit.daDAY
Initial value:
@Override
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.DAY_OF_MONTH);
}
})

Definition at line 240 of file DateTimeTest.java.

com.mapd.tests.DateTimeTest.DateExtractUnit.daDAYOFYEAR
Initial value:
@Override
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.DAY_OF_YEAR);
}
})

Definition at line 324 of file DateTimeTest.java.

com.mapd.tests.DateTimeTest.DateExtractUnit.daHOUR
Initial value:
@Override
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.HOUR_OF_DAY);
}
})

Definition at line 246 of file DateTimeTest.java.

com.mapd.tests.DateTimeTest.DateExtractUnit.daMICROSECOND
Initial value:
=("MICROSECOND", new Function<LocalDateTime, Long>() {
@Override
public Long apply(LocalDateTime t) {
return t.get(ChronoField.MICRO_OF_SECOND)
+ (1000_000L * t.get(ChronoField.SECOND_OF_MINUTE));
}
})

Definition at line 274 of file DateTimeTest.java.

com.mapd.tests.DateTimeTest.DateExtractUnit.daMILLISECOND
Initial value:
=("MILLISECOND", new Function<LocalDateTime, Long>() {
@Override
public Long apply(LocalDateTime t) {
return t.get(ChronoField.MILLI_OF_SECOND)
+ (1000L * t.get(ChronoField.SECOND_OF_MINUTE));
}
})

Definition at line 267 of file DateTimeTest.java.

com.mapd.tests.DateTimeTest.DateExtractUnit.daMINUTE
Initial value:
=("MINUTE", new Function<LocalDateTime, Long>() {
@Override
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.MINUTE_OF_HOUR);
}
})

Definition at line 252 of file DateTimeTest.java.

com.mapd.tests.DateTimeTest.DateExtractUnit.daMONTH
Initial value:
@Override
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.MONTH_OF_YEAR);
}
})

Definition at line 234 of file DateTimeTest.java.

com.mapd.tests.DateTimeTest.DateExtractUnit.daNANOSECOND
Initial value:
=("NANOSECOND", new Function<LocalDateTime, Long>() {
@Override
public Long apply(LocalDateTime t) {
return t.get(ChronoField.NANO_OF_SECOND)
+ (1000_000_000L * t.get(ChronoField.SECOND_OF_MINUTE));
}
})

Definition at line 281 of file DateTimeTest.java.

com.mapd.tests.DateTimeTest.DateExtractUnit.daQUARTER
Initial value:
=("QUARTER", new Function<LocalDateTime, Long>() {
@Override
public Long apply(LocalDateTime t) {
int month = t.get(ChronoField.MONTH_OF_YEAR);
switch (month) {
case 1:
case 2:
case 3:
return 1l;
case 4:
case 5:
case 6:
return 2l;
case 7:
case 8:
case 9:
return 3l;
case 10:
case 11:
case 12:
return 4l;
}
return -1l;
}
})

Definition at line 209 of file DateTimeTest.java.

com.mapd.tests.DateTimeTest.DateExtractUnit.daSECOND
Initial value:
=("SECOND", new Function<LocalDateTime, Long>() {
@Override
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.SECOND_OF_MINUTE);
}
})

Definition at line 258 of file DateTimeTest.java.

com.mapd.tests.DateTimeTest.DateExtractUnit.daWEEK
Initial value:
@Override
public Long apply(LocalDateTime t) {
LocalDateTime year = DateTruncUnit.dtYEAR.trunc.apply(t);
year = year.plusDays(3);
LocalDateTime week = DateTruncUnit.dtWEEK.trunc.apply(year);
if (week.compareTo(t) > 0) {
year = year.minusYears(1);
week = DateTruncUnit.dtWEEK.trunc.apply(year);
}
int weeks = 0;
while (week.compareTo(t) <= 0) {
weeks++;
week = week.plusWeeks(1);
}
return (long) weeks;
}
})

Definition at line 288 of file DateTimeTest.java.

com.mapd.tests.DateTimeTest.DateExtractUnit.daYEAR
Initial value:
public Long apply(LocalDateTime t) {
return (long) t.get(ChronoField.YEAR);
}
})

Definition at line 204 of file DateTimeTest.java.

Function<LocalDateTime, Long> com.mapd.tests.DateTimeTest.DateExtractUnit.extract
private

Definition at line 332 of file DateTimeTest.java.

String com.mapd.tests.DateTimeTest.DateExtractUnit.sqlToken
private

Definition at line 331 of file DateTimeTest.java.


The documentation for this enum was generated from the following file: