@Override public ReadableDuration decode(InputStream inStream) throws CoderException, IOException { return fromLong(LONG_CODER.decode(inStream)); }
@Override public void registerByteSizeObserver(ReadableDuration value, ElementByteSizeObserver observer) throws Exception { LONG_CODER.registerByteSizeObserver(toLong(value), observer); }
@Override public Coder<KV<Instant, ReadableDuration>> getStateCoder() { return KvCoder.of(InstantCoder.of(), DurationCoder.of()); }
@Test public void testEncodedTypeDescriptor() throws Exception { assertThat( TEST_CODER.getEncodedTypeDescriptor(), equalTo(TypeDescriptor.of(ReadableDuration.class))); } }
@Override public Coder<KV<Instant, ReadableDuration>> getStateCoder() { return KvCoder.of(NullableCoder.of(InstantCoder.of()), DurationCoder.of()); }
/** * {@inheritDoc} * * @return {@code true}, because it is cheap to ascertain the byte size of a long. */ @Override public boolean isRegisterByteSizeObserverCheap(ReadableDuration value) { return LONG_CODER.isRegisterByteSizeObserverCheap(toLong(value)); }
@Override public void encode(ReadableDuration value, OutputStream outStream) throws CoderException, IOException { if (value == null) { throw new CoderException("cannot encode a null ReadableDuration"); } LONG_CODER.encode(toLong(value), outStream); }