forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WindowMappingFn maps from a main input window to a side input window, and provides a maximum amount of lookback that is possible to generate using the MappingFn. This separates the logic of assigning windows from the logic of mapping main and side inputs. Additionally, it permits pipeline runners to garbage collect side inputs when they are no longer accessible. This is currently unused. See BEAM-846 and BEAM-260 for additional context.
- Loading branch information
Showing
16 changed files
with
239 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/WindowMappingFn.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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 | ||
* | ||
* https://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.sdk.transforms.windowing; | ||
|
||
import java.io.Serializable; | ||
import org.apache.beam.sdk.transforms.ParDo.BoundMulti; | ||
import org.apache.beam.sdk.values.PCollectionView; | ||
import org.joda.time.Duration; | ||
|
||
/** | ||
* A function that takes the windows of elements in a main input and maps them to the appropriate | ||
* window in a {@link PCollectionView} consumed as a | ||
* {@link BoundMulti#withSideInputs(PCollectionView[]) side input}. | ||
*/ | ||
public abstract class WindowMappingFn<TargetWindowT extends BoundedWindow> implements Serializable { | ||
/** | ||
* Returns the window of the side input corresponding to the given window of the main input. | ||
*/ | ||
public abstract TargetWindowT getSideInputWindow(BoundedWindow mainWindow); | ||
|
||
/** | ||
* The maximum distance between the end of any main input window {@code mainWindow} | ||
* and the end of the side input window returned by {@link #getSideInputWindow(BoundedWindow)} | ||
* | ||
* <p>A side input window {@code w} becomes unreachable when the input watermarks for all | ||
* consumers surpasses the timestamp: | ||
* | ||
* <p>(end of side input window) + (maximum lookback) + (main input allowed lateness). | ||
* | ||
* <p>At this point, every main input window that could map to {@code w} is expired. | ||
*/ | ||
public abstract Duration maximumLookback(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.