@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); }
@Override public void encode(Result<DestinationT> value, OutputStream outStream) throws IOException { if (value == null) { throw new CoderException("cannot encode a null value"); } stringCoder.encode(value.filename, outStream); longCoder.encode(value.fileByteSize, outStream); destinationCoder.encode(value.destination, outStream); }
@Override public void encode(IsmShard value, OutputStream outStream) throws CoderException, IOException { checkState( value.getIndexOffset() >= 0, "%s attempting to be written without index offset.", value); VarIntCoder.of().encode(value.getId(), outStream); VarLongCoder.of().encode(value.getBlockOffset(), outStream); VarLongCoder.of().encode(value.getIndexOffset(), outStream); }
@Override public void encode(Metadata value, OutputStream os) throws IOException { RESOURCE_ID_CODER.encode(value.resourceId(), os); INT_CODER.encode(value.isReadSeekEfficient() ? 1 : 0, os); LONG_CODER.encode(value.sizeBytes(), os); }
@Override public void encode(KafkaRecord<K, V> value, OutputStream outStream) throws IOException { stringCoder.encode(value.getTopic(), outStream); intCoder.encode(value.getPartition(), outStream); longCoder.encode(value.getOffset(), outStream); longCoder.encode(value.getTimestamp(), outStream); intCoder.encode(value.getTimestampType().ordinal(), outStream); headerCoder.encode(toIterable(value), outStream); kvCoder.encode(value.getKV(), outStream); }
@Override public void encode(KafkaRecord<K, V> value, OutputStream outStream) throws IOException { stringCoder.encode(value.getTopic(), outStream); intCoder.encode(value.getPartition(), outStream); longCoder.encode(value.getOffset(), outStream); longCoder.encode(value.getTimestamp(), outStream); intCoder.encode(value.getTimestampType().ordinal(), outStream); headerCoder.encode(toIterable(value), outStream); kvCoder.encode(value.getKV(), outStream); }
private KeyedOneInputStreamOperatorTestHarness< ByteBuffer, WindowedValue<KeyedWorkItem<Long, Long>>, WindowedValue<KV<Long, Long>>> createTestHarness(WindowDoFnOperator<Long, Long, Long> windowDoFnOperator) throws Exception { return new KeyedOneInputStreamOperatorTestHarness<>( windowDoFnOperator, (KeySelector<WindowedValue<KeyedWorkItem<Long, Long>>, ByteBuffer>) o -> { try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { VarLongCoder.of().encode(o.getValue().key(), baos); return ByteBuffer.wrap(baos.toByteArray()); } }, new GenericTypeInfo<>(ByteBuffer.class)); }
private KeyedOneInputStreamOperatorTestHarness< ByteBuffer, WindowedValue<KeyedWorkItem<Long, Long>>, WindowedValue<KV<Long, Long>>> createTestHarness(WindowDoFnOperator<Long, Long, Long> windowDoFnOperator) throws Exception { return new KeyedOneInputStreamOperatorTestHarness<>( windowDoFnOperator, (KeySelector<WindowedValue<KeyedWorkItem<Long, Long>>, ByteBuffer>) o -> { try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { VarLongCoder.of().encode(o.getValue().key(), baos); return ByteBuffer.wrap(baos.toByteArray()); } }, new GenericTypeInfo<>(ByteBuffer.class)); }
@Override public void encode(TestType value, OutputStream outStream, Context context) throws IOException { VarIntCoder.of().encode(3, outStream); jaxbCoder.encode(value, outStream); VarLongCoder.of().encode(22L, outStream, context); }
@Override public void encode(KinesisRecord value, OutputStream outStream) throws IOException { BYTE_ARRAY_CODER.encode(value.getData().array(), outStream); STRING_CODER.encode(value.getSequenceNumber(), outStream); STRING_CODER.encode(value.getPartitionKey(), outStream); INSTANT_CODER.encode(value.getApproximateArrivalTimestamp(), outStream); VAR_LONG_CODER.encode(value.getSubSequenceNumber(), outStream); INSTANT_CODER.encode(value.getReadTime(), outStream); STRING_CODER.encode(value.getStreamName(), outStream); STRING_CODER.encode(value.getShardId(), outStream); }