shunping commented on code in PR #35379:
URL: https://github.com/apache/beam/pull/35379#discussion_r2161955731


##########
sdks/python/apache_beam/ml/ts/ordered_sliding_window.py:
##########
@@ -0,0 +1,154 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import apache_beam as beam
+from apache_beam.coders import PickleCoder, BooleanCoder
+from apache_beam.transforms.userstate import OrderedListStateSpec, TimerSpec, 
on_timer, ReadModifyWriteStateSpec
+from apache_beam.utils.timestamp import Timestamp, MIN_TIMESTAMP, MAX_TIMESTAMP
+from apache_beam.transforms.timeutil import TimeDomain
+import typing
+from collections import defaultdict
+import numpy as np
+import logging
+logging.basicConfig(level=logging.INFO)
+
+class OrderedSlidingWindowFn(beam.DoFn):
+
+  ORDERED_BUFFER_STATE = OrderedListStateSpec('ordered_buffer', PickleCoder())
+  WINDOW_TIMER = TimerSpec('window_timer', TimeDomain.WATERMARK)
+  TIMER_STATE = ReadModifyWriteStateSpec('timer_state', BooleanCoder())
+  EARLIEST_TS_STATE = ReadModifyWriteStateSpec('earliest_ts', PickleCoder())
+
+
+  def __init__(self, window_size, slide_interval):
+    self.window_size = window_size

Review Comment:
   Can they be floating point number too? It looks like the unit here is second 
for both argument, but can we do sub-second window_size and interval?
   
   Internally, the timestamp is represented in microseconds.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to