forked from apache/hadoop
-
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.
SAMZA-1155; Validate users configure window.ms when using the fluent API
We will compute triggering duration as follows: - If user configures `task.window.ms` we will honor it as the triggering duration - If not, we will use the `GCD(windowTriggerDurations, joinTTLs)` as the triggering duration. Changes in this PR: - Common Interface for all time based triggers - Additional APIs in `StreamGraphImpl` to recursively traverse all `OperatorSpec`s - Recursive computation of `triggerInterval` for each `WindowOperatorSpec` - Tests for all the above Author: vjagadish1989 <[email protected]> Reviewers: Prateek Maheshwari <[email protected]>, Jacob Maes <[email protected]>, Xinyu Liu <[email protected]> Closes apache#160 from vjagadish1989/samza-1155
- Loading branch information
1 parent
d8534b5
commit e6cc3b7
Showing
12 changed files
with
479 additions
and
4 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
36 changes: 36 additions & 0 deletions
36
samza-api/src/main/java/org/apache/samza/operators/triggers/TimeBasedTrigger.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,36 @@ | ||
/* | ||
* 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.samza.operators.triggers; | ||
|
||
import org.apache.samza.annotation.InterfaceStability; | ||
|
||
import java.time.Duration; | ||
|
||
/** | ||
* A {@link Trigger} whose firing logic is determined by a time duration. | ||
* | ||
* <p> Use the {@link Triggers} APIs to create a {@link Trigger}. | ||
* | ||
* @param <M> the type of the incoming message | ||
*/ | ||
|
||
@InterfaceStability.Unstable | ||
public interface TimeBasedTrigger<M> extends Trigger<M> { | ||
Duration getDuration(); | ||
} |
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
50 changes: 50 additions & 0 deletions
50
samza-core/src/main/java/org/apache/samza/operators/util/MathUtils.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,50 @@ | ||
/* | ||
* 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.samza.operators.util; | ||
|
||
import java.util.List; | ||
|
||
public class MathUtils { | ||
|
||
public static long gcd(long a, long b) { | ||
// use the euclid gcd algorithm | ||
while (b > 0) { | ||
long temp = b; | ||
b = a % b; | ||
a = temp; | ||
} | ||
return a; | ||
} | ||
|
||
public static long gcd(List<Long> numbers) { | ||
if (numbers == null) { | ||
throw new IllegalArgumentException("Null list provided"); | ||
} | ||
if (numbers.size() == 0) { | ||
throw new IllegalArgumentException("List of size 0 provided"); | ||
} | ||
|
||
long result = numbers.get(0); | ||
for (int i = 1; i < numbers.size(); i++) { | ||
result = gcd(result, numbers.get(i)); | ||
} | ||
return result; | ||
} | ||
} |
Oops, something went wrong.