本文整理汇总了Java中com.google.common.primitives.Doubles.min方法的典型用法代码示例。如果您正苦于以下问题:Java Doubles.min方法的具体用法?Java Doubles.min怎么用?Java Doubles.min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.primitives.Doubles
的用法示例。
在下文中一共展示了Doubles.min方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValue
import com.google.common.primitives.Doubles; //导入方法依赖的package包/类
@Override
protected double getValue(ContextVector source, ContextVector target, Explanation expl) {
double infSum = 0;
double supSum = 0;
Set<Term> terms = Sets.newHashSet();
terms.addAll(source.terms());
terms.addAll(target.terms());
double sourceValue;
double targetValue;
double partialInf;
double partialSup;
for (Term term : terms) {
sourceValue = source.getAssocRate(term);
targetValue = target.getAssocRate(term);
partialInf = Doubles.min(sourceValue, targetValue);
partialSup = Doubles.max(sourceValue, targetValue);
infSum += partialInf;
supSum += partialSup;
if(partialInf > 0)
expl.addExplanation(term, partialInf);
}
return supSum == 0 ? 0 : infSum / supSum;
}
示例2: checkBroadcastConditions
import com.google.common.primitives.Doubles; //导入方法依赖的package包/类
protected boolean checkBroadcastConditions(RelOptPlanner planner, JoinRel join, RelNode left, RelNode right) {
final RelMetadataQuery mq = join.getCluster().getMetadataQuery();
// right node is the one that is being considered to be broadcasted
final double rightRowCount = mq.getRowCount(right);
if (rightRowCount < PrelUtil.getSettings(join.getCluster()).getBroadcastThreshold()
&& ! left.getTraitSet().getTrait(DistributionTraitDef.INSTANCE).equals(DistributionTrait.SINGLETON)
&& (join.getJoinType() == JoinRelType.INNER || join.getJoinType() == JoinRelType.LEFT)) {
// DX-3862: For broadcast joins, the cost should not just consider the traits and join type. If the broadcast table is small enough,
// we shouldn't need to worry too much and allow broadcast join and see what the planner picks.
final PlannerSettings plannerSettings = PrelUtil.getSettings(join.getCluster());
if (rightRowCount <= plannerSettings.getOptions().getOption(PlannerSettings.BROADCAST_MIN_THRESHOLD)) {
logger.debug("Enable broadcast plan? true (rightRowCount %d smaller than minimum broadcast threshold)", rightRowCount);
return true;
}
// In this case, the broadcast table is big-ish. So, we should check to see if it is reasonable to do broadcast.
// The broadcasted table will be sent at most (numEndPoints * maxWidthPerNode) times, (rightRowCount) rows. We add a
// penalty to broadcast (broadcastFactor).
final double broadcastFactor = plannerSettings.getBroadcastFactor();
final double leftRowCount = mq.getRowCount(left);
final int numEndPoints = plannerSettings.numEndPoints();
final long maxWidthPerNode = plannerSettings.getNumCoresPerExecutor();
final long maxWidthPerQuery = plannerSettings.getOptions().getOption(ExecConstants.MAX_WIDTH_GLOBAL);
final long sliceTarget = plannerSettings.getSliceTarget();
final double minFactor = Doubles.min(leftRowCount * 1.0 / sliceTarget, numEndPoints * maxWidthPerNode, maxWidthPerQuery);
final boolean enableBroadCast = (minFactor * broadcastFactor < leftRowCount);
logger.debug("Enable broadcast plan? %s minFactor %d (numEndPoints %d, maxWidthPerNode %d, rightRowCount %d, broadcastFactor %d, leftRowCount %d, sliceTarget %d, maxWidthPerQuery %d)",
enableBroadCast, minFactor, numEndPoints, maxWidthPerNode, rightRowCount, broadcastFactor, leftRowCount, sliceTarget, maxWidthPerQuery);
return enableBroadCast;
}
return false;
}