TimestampDatum extends Datum { @Override public int compareTo(Datum datum) { if (datum.type() == TajoDataTypes.Type.TIMESTAMP) { TimestampDatum another = (TimestampDatum) datum; return Longs.compare(timestamp, another.timestamp); } else if (datum.type() == TajoDataTypes.Type.DATE) { DateDatum another = (DateDatum) datum; TimeMeta myMeta, otherMeta; myMeta = toTimeMeta(); otherMeta = another.toTimeMeta(); return myMeta.compareTo(otherMeta); } else if (datum.isNull()) { return -1; } else { throw new InvalidOperationException(datum.type()); } } TimestampDatum(long timestamp); long getTimestamp(); int getEpoch(); long getJavaTimestamp(); int getCenturyOfEra(); int getYear(); int getMonthOfYear(); int getDayOfYear(); int getDayOfWeek(); int getWeekOfYear(); int getDayOfMonth(); int getHourOfDay(); int getMinuteOfHour(); int getSecondOfMinute(); int getMillisOfSecond(); int getUnixTime(); String toString(); String asChars(TimeZone timeZone, boolean includeTimeZone); String toString(TimeZone timeZone, boolean includeTimeZone); @Override long asInt8(); @Override String asChars(); String toChars(String format); @Override int size(); @Override byte [] asByteArray(); @Override Datum equalsTo(Datum datum); @Override int compareTo(Datum datum); @Override boolean equals(Object obj); @Override Datum plus(Datum datum); @Override Datum minus(Datum datum); @Override int hashCode(); TimeMeta toTimeMeta(); static final int SIZE; }
@Test public void testCompareTo() { TimestampDatum theday = DatumFactory.createTimestamp("2014-11-12 15:00:00.68"); TimestampDatum thedaybefore = DatumFactory.createTimestamp("2014-11-11 15:00:00.56"); assertThat(theday.compareTo(thedaybefore) > 0, is(true)); assertThat(thedaybefore.compareTo(theday) > 0, is(false)); DateDatum date = DatumFactory.createDate("2014-11-12"); assertThat(theday.compareTo(date) > 0, is(true)); }