Skip to content

Commit

Permalink
fully translate back
Browse files Browse the repository at this point in the history
  • Loading branch information
damccorm committed Sep 26, 2024
1 parent fed480e commit e2705dd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sdks/python/apache_beam/coders/coder_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
if TYPE_CHECKING:
import proto
from apache_beam.transforms import userstate
from apache_beam.transforms.window import GlobalWindow
from apache_beam.transforms.window import IntervalWindow

try:
Expand Down Expand Up @@ -806,6 +807,7 @@ def estimate_size(self, unused_value, nested=False):

if not TYPE_CHECKING:
IntervalWindow = None
GlobalWindow = None


class IntervalWindowCoderImpl(StreamCoderImpl):
Expand Down Expand Up @@ -834,13 +836,18 @@ def decode_from_stream(self, in_, nested):
if not TYPE_CHECKING:
global IntervalWindow # pylint: disable=global-variable-not-assigned
if IntervalWindow is None:
from apache_beam.transforms.window import GlobalWindow
from apache_beam.transforms.window import IntervalWindow
# instantiating with None is not part of the public interface
typed_value = IntervalWindow(None, None) # type: ignore[arg-type]
typed_value._end_micros = (
1000 * self._to_normal_time(in_.read_bigendian_uint64()))
typed_value._start_micros = (
typed_value._end_micros - 1000 * in_.read_var_int64())
gw = GlobalWindow()
if typed_value == gw:
return gw

return typed_value

def estimate_size(self, value, nested=False):
Expand Down

0 comments on commit e2705dd

Please sign in to comment.