Search in sources :

Example 1 with Sink

use of com.google.api.services.dataflow.model.Sink in project beam by apache.

the class LengthPrefixUnknownCodersTest method testLengthPrefixWriteInstructionCoder.

@Test
public void testLengthPrefixWriteInstructionCoder() throws Exception {
    WriteInstruction writeInstruction = new WriteInstruction();
    writeInstruction.setSink(new Sink().setCodec(CloudObjects.asCloudObject(windowedValueCoder, /*sdkComponents=*/
    null)));
    instruction.setWrite(writeInstruction);
    ParallelInstruction prefixedInstruction = forParallelInstruction(instruction, false);
    assertEqualsAsJson(CloudObjects.asCloudObject(prefixedWindowedValueCoder, /*sdkComponents=*/
    null), prefixedInstruction.getWrite().getSink().getCodec());
    // Should not mutate the instruction.
    assertEqualsAsJson(CloudObjects.asCloudObject(windowedValueCoder, /*sdkComponents=*/
    null), writeInstruction.getSink().getCodec());
}
Also used : LengthPrefixUnknownCoders.forParallelInstruction(org.apache.beam.runners.dataflow.worker.graph.LengthPrefixUnknownCoders.forParallelInstruction) ParallelInstruction(com.google.api.services.dataflow.model.ParallelInstruction) Sink(com.google.api.services.dataflow.model.Sink) WriteInstruction(com.google.api.services.dataflow.model.WriteInstruction) Test(org.junit.Test)

Example 2 with Sink

use of com.google.api.services.dataflow.model.Sink in project beam by apache.

the class StreamingDataflowWorkerTest method makeSinkInstruction.

private ParallelInstruction makeSinkInstruction(String streamId, Coder<?> coder, int producerIndex, Coder<? extends BoundedWindow> windowCoder) {
    CloudObject spec = CloudObject.forClass(WindmillSink.class);
    addString(spec, "stream_id", streamId);
    return new ParallelInstruction().setSystemName(DEFAULT_SINK_SYSTEM_NAME).setOriginalName(DEFAULT_SINK_ORIGINAL_NAME).setWrite(new WriteInstruction().setInput(new InstructionInput().setProducerInstructionIndex(producerIndex).setOutputNum(0)).setSink(new Sink().setSpec(spec).setCodec(CloudObjects.asCloudObject(WindowedValue.getFullCoder(coder, windowCoder), /*sdkComponents=*/
    null))));
}
Also used : ParallelInstruction(com.google.api.services.dataflow.model.ParallelInstruction) CloudObject(org.apache.beam.runners.dataflow.util.CloudObject) Sink(com.google.api.services.dataflow.model.Sink) WriteInstruction(com.google.api.services.dataflow.model.WriteInstruction) InstructionInput(com.google.api.services.dataflow.model.InstructionInput)

Aggregations

ParallelInstruction (com.google.api.services.dataflow.model.ParallelInstruction)2 Sink (com.google.api.services.dataflow.model.Sink)2 WriteInstruction (com.google.api.services.dataflow.model.WriteInstruction)2 InstructionInput (com.google.api.services.dataflow.model.InstructionInput)1 CloudObject (org.apache.beam.runners.dataflow.util.CloudObject)1 LengthPrefixUnknownCoders.forParallelInstruction (org.apache.beam.runners.dataflow.worker.graph.LengthPrefixUnknownCoders.forParallelInstruction)1 Test (org.junit.Test)1