Java Code Examples for org.apache.beam.sdk.state.TimeDomain#valueOf()

The following examples show how to use org.apache.beam.sdk.state.TimeDomain#valueOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyedTimerData.java    From beam with Apache License 2.0 6 votes vote down vote up
@Override
public KeyedTimerData<K> decode(InputStream inStream) throws CoderException, IOException {
  // decode the timestamp first
  final Instant timestamp = INSTANT_CODER.decode(inStream);
  final String timerId = STRING_CODER.decode(inStream);
  final StateNamespace namespace =
      StateNamespaces.fromString(STRING_CODER.decode(inStream), windowCoder);
  final TimeDomain domain = TimeDomain.valueOf(STRING_CODER.decode(inStream));
  final TimerData timer = TimerData.of(timerId, namespace, timestamp, timestamp, domain);

  byte[] keyBytes = null;
  K key = null;
  if (keyCoder != null) {
    key = keyCoder.decode(inStream);

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
      keyCoder.encode(key, baos);
    } catch (IOException e) {
      throw new RuntimeException("Could not encode key: " + key, e);
    }
    keyBytes = baos.toByteArray();
  }

  return new KeyedTimerData(keyBytes, key, timer);
}
 
Example 2
Source File: TimerInternals.java    From beam with Apache License 2.0 5 votes vote down vote up
@Override
public TimerData decode(InputStream inStream) throws CoderException, IOException {
  String timerId = STRING_CODER.decode(inStream);
  String timerFamilyId = STRING_CODER.decode(inStream);
  StateNamespace namespace =
      StateNamespaces.fromString(STRING_CODER.decode(inStream), windowCoder);
  Instant timestamp = INSTANT_CODER.decode(inStream);
  Instant outputTimestamp = INSTANT_CODER.decode(inStream);
  TimeDomain domain = TimeDomain.valueOf(STRING_CODER.decode(inStream));
  return TimerData.of(timerId, timerFamilyId, namespace, timestamp, outputTimestamp, domain);
}
 
Example 3
Source File: TimerInternals.java    From beam with Apache License 2.0 5 votes vote down vote up
@Override
public TimerData decode(InputStream inStream) throws CoderException, IOException {
  String timerId = STRING_CODER.decode(inStream);
  StateNamespace namespace =
      StateNamespaces.fromString(STRING_CODER.decode(inStream), windowCoder);
  Instant timestamp = INSTANT_CODER.decode(inStream);
  TimeDomain domain = TimeDomain.valueOf(STRING_CODER.decode(inStream));
  return TimerData.of(timerId, namespace, timestamp, timestamp, domain);
}