johnyangk commented on a change in pull request #122: [NEMO-213] Use Beam's
DoFnRunners to execute DoFn
URL: https://github.com/apache/incubator-nemo/pull/122#discussion_r223653285
##########
File path:
compiler/frontend/beam/src/main/java/org/apache/nemo/compiler/frontend/beam/BeamKeyExtractor.java
##########
@@ -25,12 +26,19 @@
final class BeamKeyExtractor implements KeyExtractor {
@Override
public Object extractKey(final Object element) {
- if (element instanceof KV) {
- // Handle null keys, since Beam allows KV with null keys.
- final Object key = ((KV) element).getKey();
- return key == null ? 0 : key;
- } else {
- return element;
+ // TODO #: do not dynamically check the types for performance improvement
+ if (element instanceof WindowedValue) {
+ final WindowedValue windowedValue = (WindowedValue) element;
+ final Object value = windowedValue.getValue();
+ if (value instanceof KV) {
+ // Handle null keys, since Beam allows KV with null keys.
+ final Object key = ((KV) value).getKey();
+ return key == null ? 0 : key;
+ } else {
+ return element;
+ }
}
Review comment:
else {
throw IllegalStateException
}
I believe we're always expecting `WindowedValue` now?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services