@Test public void testGetKey() { TemporalElement element = getConfig().getTemporalGraphFactory().getVertexFactory().createVertex(); element.setTxFrom(1L); element.setTxTo(2L); element.setValidFrom(3L); element.setValidTo(4L); KeyFunctionWithDefaultValue<TemporalElement, Long> function = TemporalGroupingKeys.timeStamp( TimeDimension.TRANSACTION_TIME, TimeDimension.Field.FROM); assertEquals((Long) 1L, function.getKey(element)); function = TemporalGroupingKeys.timeStamp(TimeDimension.TRANSACTION_TIME, TimeDimension.Field.TO); assertEquals((Long) 2L, function.getKey(element)); function = TemporalGroupingKeys.timeStamp(TimeDimension.VALID_TIME, TimeDimension.Field.FROM); assertEquals((Long) 3L, function.getKey(element)); function = TemporalGroupingKeys.timeStamp(TimeDimension.VALID_TIME, TimeDimension.Field.TO); assertEquals((Long) 4L, function.getKey(element)); }
@Override public Long getKey(T element) { final Tuple2<Long, Long> interval; switch (timeDimension) { case TRANSACTION_TIME: interval = element.getTransactionTime(); break; case VALID_TIME: interval = element.getValidTime(); break; default: throw new UnsupportedOperationException( "Time interval not supported by this element: " + timeDimension); } final Long fieldValue; switch (timeDimensionField) { case FROM: fieldValue = interval.f0; if (fieldValue.equals(TemporalElement.DEFAULT_TIME_FROM) && (fieldOfTimeStamp != null)) { return getDefaultKey(); } break; case TO: fieldValue = interval.f1; if (fieldValue.equals(TemporalElement.DEFAULT_TIME_TO) && (fieldOfTimeStamp != null)) { return getDefaultKey(); } break; default: throw new UnsupportedOperationException("Field is not supported: " + timeDimensionField); } if (fieldOfTimeStamp == null) { return fieldValue; } final LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(fieldValue), UTC); return fieldOfTimeStamp.getFrom(date); }
TimeStampKeyFunction implements KeyFunctionWithDefaultValue<T, Long> { @Override public Long getKey(T element) { final Tuple2<Long, Long> interval; switch (timeDimension) { case TRANSACTION_TIME: interval = element.getTransactionTime(); break; case VALID_TIME: interval = element.getValidTime(); break; default: throw new UnsupportedOperationException( "Time interval not supported by this element: " + timeDimension); } final Long fieldValue; switch (timeDimensionField) { case FROM: fieldValue = interval.f0; if (fieldValue.equals(TemporalElement.DEFAULT_TIME_FROM) && (fieldOfTimeStamp != null)) { return getDefaultKey(); } break; case TO: fieldValue = interval.f1; if (fieldValue.equals(TemporalElement.DEFAULT_TIME_TO) && (fieldOfTimeStamp != null)) { return getDefaultKey(); } break; default: throw new UnsupportedOperationException("Field is not supported: " + timeDimensionField); } if (fieldOfTimeStamp == null) { return fieldValue; } final LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(fieldValue), UTC); return fieldOfTimeStamp.getFrom(date); } }
TimeStampKeyFunction implements KeyFunctionWithDefaultValue<T, Long> { @Override public Long getKey(T element) { final Tuple2<Long, Long> interval; switch (timeDimension) { case TRANSACTION_TIME: interval = element.getTransactionTime(); break; case VALID_TIME: interval = element.getValidTime(); break; default: throw new UnsupportedOperationException( "Time interval not supported by this element: " + timeDimension); } final Long fieldValue; switch (timeDimensionField) { case FROM: fieldValue = interval.f0; if (fieldValue.equals(TemporalElement.DEFAULT_TIME_FROM) && (fieldOfTimeStamp != null)) { return getDefaultKey(); } break; case TO: fieldValue = interval.f1; if (fieldValue.equals(TemporalElement.DEFAULT_TIME_TO) && (fieldOfTimeStamp != null)) { return getDefaultKey(); } break; default: throw new UnsupportedOperationException("Field is not supported: " + timeDimensionField); } if (fieldOfTimeStamp == null) { return fieldValue; } final LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(fieldValue), UTC); return fieldOfTimeStamp.getFrom(date); } TimeStampKeyFunction(TimeDimension timeDimension,
    TimeDimension.Field timeDimensionField, TemporalField fieldOfTimeStamp); }
TimeStampKeyFunction implements KeyFunctionWithDefaultValue<T, Long> { @Override public Long getKey(T element) { final Tuple2<Long, Long> interval; switch (timeDimension) { case TRANSACTION_TIME: interval = element.getTransactionTime(); break; case VALID_TIME: interval = element.getValidTime(); break; default: throw new UnsupportedOperationException( "Time interval not supported by this element: " + timeDimension); } final Long fieldValue; switch (timeDimensionField) { case FROM: fieldValue = interval.f0; if (fieldValue.equals(TemporalElement.DEFAULT_TIME_FROM) && (fieldOfTimeStamp != null)) { return getDefaultKey(); } break; case TO: fieldValue = interval.f1; if (fieldValue.equals(TemporalElement.DEFAULT_TIME_TO) && (fieldOfTimeStamp != null)) { return getDefaultKey(); } break; default: throw new UnsupportedOperationException("Field is not supported: " + timeDimensionField); } if (fieldOfTimeStamp == null) { return fieldValue; } final LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(fieldValue), UTC); return fieldOfTimeStamp.getFrom(date); } TimeStampKeyFunction(TimeDimension timeDimension,
    TimeDimension.Field timeDimensionField, TemporalField fieldOfTimeStamp); @Override Long getKey(T element); @Override void addKeyToElement(T element, Object key); @Override TypeInformation<Long> getType(); @Override Long getDefaultKey(); }
TimeStampKeyFunction implements KeyFunctionWithDefaultValue<T, Long> { @Override public Long getKey(T element) { final Tuple2<Long, Long> interval; switch (timeDimension) { case TRANSACTION_TIME: interval = element.getTransactionTime(); break; case VALID_TIME: interval = element.getValidTime(); break; default: throw new UnsupportedOperationException( "Time interval not supported by this element: " + timeDimension); } final Long fieldValue; switch (timeDimensionField) { case FROM: fieldValue = interval.f0; if (fieldValue.equals(TemporalElement.DEFAULT_TIME_FROM) && (fieldOfTimeStamp != null)) { return getDefaultKey(); } break; case TO: fieldValue = interval.f1; if (fieldValue.equals(TemporalElement.DEFAULT_TIME_TO) && (fieldOfTimeStamp != null)) { return getDefaultKey(); } break; default: throw new UnsupportedOperationException("Field is not supported: " + timeDimensionField); } if (fieldOfTimeStamp == null) { return fieldValue; } final LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(fieldValue), UTC); return fieldOfTimeStamp.getFrom(date); } TimeStampKeyFunction(TimeDimension timeDimension,
    TimeDimension.Field timeDimensionField, TemporalField fieldOfTimeStamp); @Override Long getKey(T element); @Override void addKeyToElement(T element, Object key); @Override TypeInformation<Long> getType(); @Override Long getDefaultKey();  }