[
https://issues.apache.org/jira/browse/BEAM-2953?focusedWorklogId=150812&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-150812
]
ASF GitHub Bot logged work on BEAM-2953:
----------------------------------------
Author: ASF GitHub Bot
Created on: 03/Oct/18 16:29
Start Date: 03/Oct/18 16:29
Worklog Time Spent: 10m
Work Description: akedin commented on a change in pull request #6540:
[BEAM-2953] Advanced Timeseries examples.
URL: https://github.com/apache/beam/pull/6540#discussion_r222142674
##########
File path:
examples/java/src/main/java/org/apache/beam/examples/timeseries/transforms/TSAccumToFixedWindowSeq.java
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.
+ */
+
+package org.apache.beam.examples.timeseries.transforms;
+
+import com.google.common.collect.Lists;
+import com.google.protobuf.util.Durations;
+import com.google.protobuf.util.Timestamps;
+import javax.annotation.Nullable;
+import java.util.List;
+import java.util.Optional;
+import org.apache.beam.examples.timeseries.configuration.TSConfiguration;
+import org.apache.beam.examples.timeseries.protos.TimeSeriesData;
+import org.apache.beam.examples.timeseries.utils.TSAccums;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.transforms.DoFn;
+import org.apache.beam.sdk.transforms.GroupByKey;
+import org.apache.beam.sdk.transforms.PTransform;
+import org.apache.beam.sdk.transforms.ParDo;
+import org.apache.beam.sdk.transforms.windowing.FixedWindows;
+import org.apache.beam.sdk.transforms.windowing.IntervalWindow;
+import org.apache.beam.sdk.transforms.windowing.Window;
+import org.apache.beam.sdk.values.KV;
+import org.apache.beam.sdk.values.PCollection;
+import org.joda.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Converts a series of TSAccum into a TSAccumSequence. */
+@Experimental
+public class TSAccumToFixedWindowSeq
+ extends PTransform<
+ PCollection<KV<TimeSeriesData.TSKey, TimeSeriesData.TSAccum>>,
+ PCollection<KV<TimeSeriesData.TSKey, TimeSeriesData.TSAccumSequence>>>
{
+
+ private static final Logger LOG =
LoggerFactory.getLogger(TSAccumToFixedWindowSeq.class);
+
+ TSConfiguration configuration;
+ private Duration fixedWindowDuration;
+
+ public TSAccumToFixedWindowSeq(TSConfiguration configuration, Duration
fixedWindowDuration) {
+ this.configuration = configuration;
+ this.fixedWindowDuration = fixedWindowDuration;
+ }
+
+ public TSAccumToFixedWindowSeq(@Nullable String name, TSConfiguration
configuration,
Review comment:
Do you actually need the `TSConfiguration` class, and pass its instances
around? I would recommend doing the following instead:
* convert `TSConfiguration` to `PipelineOptions` interface and combine it
with `TimeSeriesOptions`, see `NexmarkOptions` for example;
* inherit from existing options like `GcpOptions` that already have things
like `projectId`;
* give meaningful defaults to the values;
* don't pass the configuration around but get the `PipelineOptions`
directly in the `PTransform.expand()` implementations, like
`input.getPipeline().getOptions().as(YourPipelineOptions.class)`. Or in `DoFns`
I think there's `c.getPipelineOptions().as(...)` in `@ProcessElement` method as
well;
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 150812)
Time Spent: 1h 20m (was: 1h 10m)
> Create more advanced Timeseries processing examples using state API
> -------------------------------------------------------------------
>
> Key: BEAM-2953
> URL: https://issues.apache.org/jira/browse/BEAM-2953
> Project: Beam
> Issue Type: Improvement
> Components: examples-java
> Affects Versions: 2.1.0
> Reporter: Reza ardeshir rokni
> Assignee: Reuven Lax
> Priority: Minor
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> As described in the phase 1 portion of this solution outline:
> https://cloud.google.com/solutions/correlating-time-series-dataflow
> BEAM can be used to build out some very interesting pre-processing stages for
> time series data. Some examples that will be useful:
> - Downsampling time series based on simple AVG, MIN, MAX
> - Creating a value for each time window using generatesequence as a seed
> - Loading the value of a downsample with the previous value (used in FX with
> previous close being brought into current open value)
> This will show some concrete examples of keyed state as well as the use of
> combiners.
> The samples can also be used to show how you can create a ordered list of
> values per key from a unbounded topic which has multiple time series keys.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)