本文整理汇总了Java中com.google.common.collect.Range.openClosed方法的典型用法代码示例。如果您正苦于以下问题:Java Range.openClosed方法的具体用法?Java Range.openClosed怎么用?Java Range.openClosed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Range
的用法示例。
在下文中一共展示了Range.openClosed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.google.common.collect.Range; //导入方法依赖的package包/类
/**
* Returns a new {@link MetricPoint} representing a value at a specific {@link Instant}.
*
* <p>Callers should insure that the count of {@code labelValues} matches the count of labels for
* the given metric.
*/
@VisibleForTesting
public static <V> MetricPoint<V> create(
Metric<V> metric, ImmutableList<String> labelValues, Instant timestamp, V value) {
MetricsUtils.checkLabelValuesLength(metric, labelValues);
return new AutoValue_MetricPoint<>(
metric, labelValues, Range.openClosed(timestamp, timestamp), value);
}
示例2: computeLocality
import com.google.common.collect.Range; //导入方法依赖的package包/类
private void computeLocality(ParquetMetadata footer) throws ExecutionSetupException {
try {
BlockMetaData block = footer.getBlocks().get(readEntry.getRowGroupIndex());
BlockLocation[] blockLocations = fs.getFileBlockLocations(new Path(readEntry.getPath()), block.getStartingPos(), block.getCompressedSize());
String localHost = InetAddress.getLocalHost().getCanonicalHostName();
List<Range<Long>> intersectingRanges = new ArrayList<>();
Range<Long> rowGroupRange = Range.openClosed(block.getStartingPos(), block.getStartingPos() + block.getCompressedSize());
for (BlockLocation loc : blockLocations) {
for (String host : loc.getHosts()) {
if (host.equals(localHost)) {
intersectingRanges.add(Range.closedOpen(loc.getOffset(), loc.getOffset() + loc.getLength()).intersection(rowGroupRange));
}
}
}
long totalIntersect = 0;
for (Range<Long> range : intersectingRanges) {
totalIntersect += (range.upperEndpoint() - range.lowerEndpoint());
}
if (totalIntersect < block.getCompressedSize()) {
context.getStats().addLongStat(Metric.NUM_REMOTE_READERS, 1);
} else {
context.getStats().addLongStat(Metric.NUM_REMOTE_READERS, 0);
}
} catch (IOException e) {
throw new ExecutionSetupException(e);
}
}