-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added threshold for running ftd and match #958
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
aee3202
added threshold for running ftd and match
Nitish1814 06db8c1
updated matchCount logic
Nitish1814 04b40d8
updated matchCount logic
Nitish1814 36c171c
changed class name
Nitish1814 b4bcb88
increased REQUIRED_MATCH_COUNT to 20
Nitish1814 b5e9b74
made REQUIRED_MATCH_COUNT as static int
Nitish1814 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
common/core/src/test/java/zingg/common/core/executor/FtdLabelCombinedExecutorTester.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,65 @@ | ||
package zingg.common.core.executor; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import zingg.common.client.ClientOptions; | ||
import zingg.common.client.ZFrame; | ||
import zingg.common.client.ZinggClientException; | ||
import zingg.common.core.executor.validate.ExecutorValidator; | ||
|
||
import java.io.IOException; | ||
|
||
public class FtdLabelCombinedExecutorTester<S, D, R, C, T> extends ExecutorTester<S, D, R, C, T> { | ||
|
||
private static final Log LOG = LogFactory.getLog(FtdLabelCombinedExecutorTester.class); | ||
private final ZinggBase<S, D, R, C, T> labelExecutor; | ||
private final ExecutorValidator<S, D, R, C, T> labelValidator; | ||
//max how many times we want to run | ||
//to avoid infinite loops in rare cases | ||
private int MAX_RUN_COUNT = 5; | ||
private int REQUIRED_MATCH_COUNT = 10; | ||
|
||
//setting labeller properties here | ||
//ftd properties are already set by super | ||
public FtdLabelCombinedExecutorTester(ZinggBase<S, D, R, C, T> ftdExecutor, ExecutorValidator<S, D, R, C, T> ftdValidator, String configFile, | ||
ZinggBase<S, D, R, C, T> labelExecutor, ExecutorValidator<S, D, R, C, T> labelValidator) throws ZinggClientException, IOException { | ||
super(ftdExecutor, ftdValidator, configFile); | ||
this.labelExecutor = labelExecutor; | ||
this.labelValidator = labelValidator; | ||
} | ||
|
||
//need to execute until we get | ||
//required number of matches | ||
@Override | ||
public void initAndExecute(S session) throws ZinggClientException { | ||
executor.init(args,session, new ClientOptions()); | ||
labelExecutor.init(args, session, new ClientOptions()); | ||
runUntilThreshold(); | ||
} | ||
|
||
@Override | ||
public void validateResults() throws ZinggClientException { | ||
validator.validateResults(); | ||
labelValidator.validateResults(); | ||
} | ||
|
||
//run until max run count reached or | ||
//required match count reached, whichever | ||
//reaches earlier | ||
private void runUntilThreshold() throws ZinggClientException { | ||
long matchCount = 0; | ||
while(MAX_RUN_COUNT > 0 && matchCount < REQUIRED_MATCH_COUNT) { | ||
executor.execute(); | ||
labelExecutor.execute(); | ||
ZFrame<D, R, C> markedRecords = labelExecutor.getMarkedRecords(); | ||
matchCount = getMatchRecordCount(markedRecords); | ||
MAX_RUN_COUNT--; | ||
} | ||
LOG.info("total number of matches discovered, " + matchCount); | ||
} | ||
|
||
private long getMatchRecordCount(ZFrame<D, R, C> markedRecords) { | ||
return markedRecords.filter(markedRecords.equalTo("z_isMatch", 1.0)).count(); | ||
} | ||
|
||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / PMD
Logger calls should be surrounded by log level guards. Warning test