This commit is contained in:
2021-04-06 00:45:28 +02:00
commit 17fabc368e
836 changed files with 3042963 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
package org.fog.application.selectivity;
/**
* Generates an output tuple for an incoming input tuple with a fixed probability
* @author Harshit Gupta
*
*/
public class FractionalSelectivity implements SelectivityModel{
/**
* The fixed probability of output tuple creation per incoming input tuple
*/
double selectivity;
public FractionalSelectivity(double selectivity){
setSelectivity(selectivity);
}
public double getSelectivity() {
return selectivity;
}
public void setSelectivity(double selectivity) {
this.selectivity = selectivity;
}
@Override
public boolean canSelect() {
if(Math.random() < getSelectivity()) // if the probability condition is satisfied
return true;
return false;
}
@Override
public double getMeanRate() {
return getSelectivity(); // the average rate of tuple generation is the fixed probability value
}
@Override
public double getMaxRate() {
return getSelectivity(); // the maximum rate of tuple generation is the fixed probability value
}
}