}
@Override
protected void setBatchSize(EquiJoinComponent joinComponent, Map<String, CostParams> compCost) {
final Component[] parents = joinComponent.getParents();
final CostParams leftParams = compCost.get(parents[0].getName());
final CostParams rightParams = compCost.get(parents[1].getName());
final CostParams params = compCost.get(joinComponent.getName());
final double ratio = params.getSelectivity();
final int parallelism = params.getParallelism(); // batch size has to be set
// after the parallelism
final int leftBatchSize = leftParams.getBatchSize();
final int leftBatchIn = leftBatchSize / parallelism;
final int rightBatchSize = rightParams.getBatchSize();
final int rightBatchIn = rightBatchSize / parallelism;
final int leftParallelism = leftParams.getParallelism();
final int rightParallelism = rightParams.getParallelism();
// TODO: this implies that both components finish at the same time
// (optimization of parallelism of sources won't work)
final double iqs = leftParallelism * leftBatchIn + rightParallelism * rightBatchIn;
int batchSize = (int) (ratio * iqs);
if (batchSize < 1)
batchSize = 1; // cannot be less than 1
params.setBatchSize(batchSize);
}