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