Conversation
|
More details please? |
0061a4a to
7250253
Compare
|
R: @kennknowles |
Add ParDoPayloadTranslator to PTransformTranslator
7250253 to
a1a66d1
Compare
kennknowles
left a comment
There was a problem hiding this comment.
This is a really good start.
| import org.apache.beam.sdk.values.TupleTag; | ||
| import org.apache.beam.sdk.values.WindowingStrategy; | ||
|
|
||
| /** Created by tgroh on 5/15/17. */ |
| string id = 1; | ||
| Type type = 2; | ||
|
|
||
| enum Type { |
There was a problem hiding this comment.
Prefer top-level definitions, like StateType, so we don't couple names or generated classes.
There was a problem hiding this comment.
Reverted for the time being.
| private static final Map<Class<? extends PTransform>, TransformPayloadTranslator> | ||
| KNOWN_PAYLOAD_TRANSLATORS = | ||
| ImmutableMap.<Class<? extends PTransform>, TransformPayloadTranslator>builder().build(); | ||
| ImmutableMap.<Class<? extends PTransform>, TransformPayloadTranslator>builder() |
There was a problem hiding this comment.
You can remove ParDoPayload from the TODO (or just remove the TODO)
| /** | ||
| * The URN for a {@link ParDoPayload}. | ||
| */ | ||
| public static final String PAR_DO_PAYLOAD_URN = "urn:beam:runnerapi:pardo:v1"; |
There was a problem hiding this comment.
I don't think we need runnerapi in the URNs. This is the spec for a "Beam ParDo transform" (v1).
| */ | ||
| public static final String CUSTOM_JAVA_WINDOW_MAPPING_FN_URN = | ||
| "urn:beam:windowmappingfn:javasdk:0.1"; | ||
|
|
| return null; | ||
| } | ||
| }; | ||
| Type parameterType = parameter.match(runnerApiCases); |
There was a problem hiding this comment.
(nit) I prefer putting the new Cases inline so it reads like the enhanced switch that it is.
| return builder.build(); | ||
| } | ||
|
|
||
| public static PCollectionView<?> fromProto( |
There was a problem hiding this comment.
At some point fromProto and toProto are going to get unreadable if they depend on a variety of params for override.
There was a problem hiding this comment.
It's not a great scene. This one ends up needing a bunch of context because things like the PCollection are inputs of the PTransform and are only referenced by (two-indirection name) within the SideInput.
Some other things are fooFromProto, which I'm not opposed to.
Also reordered the parameters to make the conversion target first, then context
| components); | ||
| Coder<?> elemCoder = | ||
| Coders.fromProto(components.getCodersOrThrow(inputCollection.getCoderId()), components); | ||
| Coder<Iterable<WindowedValue<?>>> coder = |
There was a problem hiding this comment.
This should be keyed on the materialization. This is the appropriate coder for our current "iterable of full windowed values" materialization. It is OK to not implement any others, but there should be a checkArgument or a conditional with a failing else branch with a meaningful message in an Unsupported exception.
There was a problem hiding this comment.
Throwing an exception if an unknown type for the time being.
| Any.pack( | ||
| BytesValue.newBuilder() | ||
| .setValue( | ||
| ByteString.copyFrom(SerializableUtils.serializeToByteArray(viewFn))) |
There was a problem hiding this comment.
I think we could probably add a couple more layers of indirection here...
| import org.apache.beam.sdk.values.WindowingStrategy; | ||
|
|
||
| /** Created by tgroh on 5/15/17. */ | ||
| class RunnerPCollectionView<T> extends PValueBase |
There was a problem hiding this comment.
I suspect this class is a harbinger of things to come in terms of RunnerParDo, etc. These should only include the primitive constructs. It might turn out quite nice, actually.
ea46bb1 to
cf52b9c
Compare
cf52b9c to
4643106
Compare
|
|
||
| private static Optional<RunnerApi.Parameter> toProto(Parameter parameter) { | ||
| return parameter.match( | ||
| new Cases<Optional<RunnerApi.Parameter>>() { |
There was a problem hiding this comment.
I think there's a Cases.Default that lets you put all the unimplemented cases in one place a la switch..default:. Not important, just a tidying.
e543656 to
f11c673
Compare
f11c673 to
207085c
Compare
Add ParDoPayloadTranslator to PTransformTranslator
Be sure to do all of the following to help us incorporate your contribution
quickly and easily:
[BEAM-<Jira issue #>] Description of pull requestmvn clean verify. (Even better, enableTravis-CI on your fork and ensure the whole test matrix passes).
<Jira issue #>in the title with the actual Jira issuenumber, if there is one.
Individual Contributor License Agreement.