Skip to content

[BEAM-1467] Add cross-SDK implementations and tests of WindowedValueCoder#2018

Closed
vikkyrk wants to merge 6 commits intoapache:masterfrom
vikkyrk:common_windowed_value_coder
Closed

[BEAM-1467] Add cross-SDK implementations and tests of WindowedValueCoder#2018
vikkyrk wants to merge 6 commits intoapache:masterfrom
vikkyrk:common_windowed_value_coder

Conversation

@vikkyrk
Copy link
Copy Markdown
Contributor

@vikkyrk vikkyrk commented Feb 16, 2017

Be sure to do all of the following to help us incorporate your contribution
quickly and easily:

  • Tests for GlobalWindowCoder

  • Cross-sdk implementation / tests for WindowedValueCoder

  • Note: PaneInfo isn't supported in python SDK yet, so we hard code the value to 0x0F which represents PaneInfo.NO_FIRING

  • Make sure the PR title is formatted like:
    [BEAM-<Jira issue #>] Description of pull request

  • Make sure tests pass via mvn clean verify. (Even better, enable
    Travis-CI on your fork and ensure the whole test matrix passes).

  • Replace <Jira issue #> in the title with the actual Jira issue
    number, if there is one.

  • If this contribution is large, please file an Apache
    Individual Contributor License Agreement.


@vikkyrk vikkyrk changed the title [BEAM-1467] dd cross-SDK implementations and tests of WindowedValueCoder [BEAM-1467] Add cross-SDK implementations and tests of WindowedValueCoder Feb 16, 2017
@vikkyrk
Copy link
Copy Markdown
Contributor Author

vikkyrk commented Feb 16, 2017

R: @dhalperi @aaltay
CC: @robertwb @tgroh

# lower negative number. For ex: -3 / 2 = -2, but we expect it to be -1,
# to be consistent across SDKs.
self._from_normal_time(
restore_sign * (abs(wv.timestamp_micros) / 1000)))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better ways to fix this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int(-3/2.0) should work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better! Any performance implications dividing by float and converting to int? (I think not)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know, but I do not think so.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually float division loses precision for large long numbers, so this won't work.

@coveralls
Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 61b964d on vikkyrk:common_windowed_value_coder into ** on apache:master**.

@asfbot
Copy link
Copy Markdown

asfbot commented Feb 16, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7464/
--none--

@coveralls
Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 61b964d on vikkyrk:common_windowed_value_coder into ** on apache:master**.

@asfbot
Copy link
Copy Markdown

asfbot commented Feb 16, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7467/
--none--

@aaltay
Copy link
Copy Markdown
Member

aaltay commented Feb 16, 2017

Attach JIRA issues to TODOs, I will defer to R: @charlesccychen for review.

Copy link
Copy Markdown
Contributor

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java and standard_coders LGTM, with minor comments. @aaltay , feel free to merge once you're happy with Python side?

convertValue(element, coderSpec.getComponents().get(0), elementCoder));
}
return convertedElements;
case "urn:beam:coders:global_window:0.1":
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must have missed this prior for IterableCoder, but it can be useful to put these case statements fully inside of {} (see interval_window case above) -- that lets each case use a different set of local variables.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

windowCoder));
}
// Note: Until Python SDK supports PaneInfo, we default to PaneInfo.NO_FIRING.
return WindowedValue.of(windowValue, timestamp, windows, PaneInfo.NO_FIRING);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest that:

  1. document the Python issue with a JIRA.
  2. Restrict the test values to those with PaneInfo.NO_FIRING, and add a TODO in standard_coders.yaml referencing the JIRA.
  3. return the correct value in Java.

Seems cleaner -- fewer places to clean up once Python has PaneInfo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

restore_sign * (abs(wv.timestamp_micros) / 1000)))
self._windows_coder.encode_to_stream(wv.windows, out, True)
# Default PaneInfo encoded byte representing NO_FIRING.
# TODO(vikasrk): Remove the hard coding here once PaneInfo is supported.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of TODO(vikasrk) make it TODO(BEAM_XXX) to a JIRA. :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


# TODO: Fn Harness only supports millis. Is this important enough to fix?
def _to_normal_time(self, value):
"""Convert "lexicographically ordered unsigned" to signed."""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document what "normal time" means for coders? What is "lexicographically ordered unsigned"?

self._value_coder.encode_to_stream(wv.value, out, True)
# Avoid creation of Timestamp object.
out.write_bigendian_int64(wv.timestamp_micros)
restore_sign = -1 if wv.timestamp_micros < 0 else 1
Copy link
Copy Markdown
Contributor

@charlesccychen charlesccychen Feb 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment that this workaround is to maintain compatibility with the Java SDK and point to a jira issue to resolve this in the future?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

# of precision while converting to millis.
# Note: This is only a best effort here as there is no way to know if these
# were indeed MIN/MAX timestamps.
# TODO(vikasrk): Clean this up once we have a BEAM wide consensus on
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please point to jira.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

# were indeed MIN/MAX timestamps.
# TODO(vikasrk): Clean this up once we have a BEAM wide consensus on
# precision of timestamps.
if timestamp == -(abs(MIN_TIMESTAMP.micros) / 1000):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to do <= and >= here and below? This is somewhat fragile. Can you also document the Java min and max values?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be go away once the BEAM-1524 is fixed. Added a jira.


windows = self._windows_coder.decode_from_stream(in_stream, True)
# Read PaneInfo encoded byte.
in_stream.read_byte()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make it clearer in the comment that this is ignored for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.02%) to 69.307% when pulling f3cc9f8 on vikkyrk:common_windowed_value_coder into 154c543 on apache:master.

@asfbot
Copy link
Copy Markdown

asfbot commented Feb 21, 2017

@vikkyrk
Copy link
Copy Markdown
Contributor Author

vikkyrk commented Feb 21, 2017

R: @charlesccychen addressed comments, PTAL.

@charlesccychen
Copy link
Copy Markdown
Contributor

Thanks! LGTM.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 69.314% when pulling f3cc9f8 on vikkyrk:common_windowed_value_coder into 154c543 on apache:master.

@asfbot
Copy link
Copy Markdown

asfbot commented Feb 22, 2017

@vikkyrk
Copy link
Copy Markdown
Contributor Author

vikkyrk commented Feb 22, 2017

Retest this please.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.04%) to 69.323% when pulling f3cc9f8 on vikkyrk:common_windowed_value_coder into 154c543 on apache:master.

@asfbot
Copy link
Copy Markdown

asfbot commented Feb 22, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7664/
--none--

@asfgit asfgit closed this in ede77c1 Feb 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants