本文整理匯總了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;
}