本文整理了Java中java.util.stream.LongStream.sum()
方法的一些代码示例,展示了LongStream.sum()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LongStream.sum()
方法的具体详情如下:
包路径:java.util.stream.LongStream
类名称:LongStream
方法名:sum
[英]Returns the sum of elements in this stream. This is a special case of a reduction and is equivalent to:
return reduce(0, Long::sum);
This is a terminal operation.
[中]返回此流中元素的总和。这是reduction的一个特例,相当于:
return reduce(0, Long::sum);
这是一个terminal operation。
代码示例来源:origin: google/guava
/**
* Returns the sum of all values in this map.
*
* <p>This method is not atomic: the sum may or may not include other concurrent operations.
*/
public long sum() {
return map.values().stream().mapToLong(Long::longValue).sum();
}
代码示例来源:origin: prestodb/presto
public long getPhysicalWrittenDataSize()
{
return drivers.stream()
.mapToLong(DriverContext::getPphysicalWrittenDataSize)
.sum();
}
代码示例来源:origin: prestodb/presto
public long getPphysicalWrittenDataSize()
{
return operatorContexts.stream()
.mapToLong(OperatorContext::getPhysicalWrittenDataSize)
.sum();
}
代码示例来源:origin: prestodb/presto
@Override
public long getJoinPositionCount()
{
return Arrays.stream(lookupSources)
.mapToLong(LookupSource::getJoinPositionCount)
.sum();
}
代码示例来源:origin: prestodb/presto
@Override
public long getSizeInBytes()
{
return INSTANCE_SIZE + channels.stream()
.flatMap(List::stream)
.mapToLong(Block::getRetainedSizeInBytes)
.sum();
}
代码示例来源:origin: prestodb/presto
@Override
public long getInMemorySizeInBytes()
{
return Arrays.stream(lookupSources).mapToLong(LookupSource::getInMemorySizeInBytes).sum();
}
代码示例来源:origin: neo4j/neo4j
@Override
public long maxCount()
{
return partitionReaders.stream().mapToLong( LucenePartitionAllDocumentsReader::maxCount ).sum();
}
代码示例来源:origin: prestodb/presto
/**
* Returns the sum of all values in this map.
*
* <p>This method is not atomic: the sum may or may not include other concurrent operations.
*/
public long sum() {
return map.values().stream().mapToLong(Long::longValue).sum();
}
代码示例来源:origin: prestodb/presto
public StripeStatistics(List<ColumnStatistics> columnStatistics)
{
this.columnStatistics = ImmutableList.copyOf(requireNonNull(columnStatistics, "columnStatistics is null"));
this.retainedSizeInBytes = INSTANCE_SIZE + columnStatistics.stream().mapToLong(ColumnStatistics::getRetainedSizeInBytes).sum();
}
代码示例来源:origin: prestodb/presto
public long getUserMemoryReservation()
{
return stages.values().stream()
.mapToLong(SqlStageExecution::getUserMemoryReservation)
.sum();
}
代码示例来源:origin: prestodb/presto
public void compact()
{
checkState(!finished, "NestedLoopJoinPagesBuilder is finished");
pages.stream()
.forEach(Page::compact);
estimatedSize = pages.stream()
.mapToLong(Page::getRetainedSizeInBytes)
.sum();
}
代码示例来源:origin: prestodb/presto
public long getTotalMemoryReservation()
{
return stages.values().stream()
.mapToLong(SqlStageExecution::getTotalMemoryReservation)
.sum();
}
代码示例来源:origin: prestodb/presto
@JsonProperty
public long getWrittenPositions()
{
return operatorSummaries.stream()
.filter(stats -> stats.getOperatorType().equals(TableWriterOperator.class.getSimpleName()))
.mapToLong(OperatorStats::getInputPositions)
.sum();
}
代码示例来源:origin: prestodb/presto
private synchronized void addPages(Collection<SerializedPageReference> pages)
{
pages.forEach(SerializedPageReference::addReference);
this.pages.addAll(pages);
long rowCount = pages.stream().mapToLong(SerializedPageReference::getPositionCount).sum();
rowsAdded.addAndGet(rowCount);
pagesAdded.addAndGet(pages.size());
long bytesAdded = pages.stream().mapToLong(SerializedPageReference::getRetainedSizeInBytes).sum();
bufferedBytes.addAndGet(bytesAdded);
}
代码示例来源:origin: prestodb/presto
public long getTotalPartitionsCount(String keyspace, String table, Optional<Long> sessionSplitsPerNode)
{
if (sessionSplitsPerNode.isPresent()) {
return sessionSplitsPerNode.get();
}
else if (configSplitsPerNode.isPresent()) {
return configSplitsPerNode.get();
}
List<SizeEstimate> estimates = session.getSizeEstimates(keyspace, table);
return estimates.stream()
.mapToLong(SizeEstimate::getPartitionsCount)
.sum();
}
代码示例来源:origin: AsyncHttpClient/async-http-client
/**
* @return A long representing the number of active connections in the connection pool.
*/
public long getTotalActiveConnectionCount() {
return statsPerHost
.values()
.stream()
.mapToLong(HostStats::getHostActiveConnectionCount)
.sum();
}
代码示例来源:origin: RichardWarburton/java-8-lambdas-exercises
public long countFeature(ToLongFunction<Album> function) {
return albums.stream()
.mapToLong(function)
.sum();
}
代码示例来源:origin: AsyncHttpClient/async-http-client
/**
* @return The sum of {@link #getTotalActiveConnectionCount()} and {@link #getTotalIdleConnectionCount()},
* a long representing the total number of connections in the connection pool.
*/
public long getTotalConnectionCount() {
return statsPerHost
.values()
.stream()
.mapToLong(HostStats::getHostConnectionCount)
.sum();
}
代码示例来源:origin: prestodb/presto
public Optional<IndexInfo> build()
{
List<Integer> partitions = partitionsSizes.build();
if (partitions.size() == 0) {
return Optional.empty();
}
double avgSize = partitions.stream().mapToLong(Integer::longValue).average().getAsDouble();
double squaredDifferences = partitions.stream().mapToDouble(size -> Math.pow(size - avgSize, 2)).sum();
checkState(partitions.stream().mapToLong(Integer::longValue).sum() == rowsNumber, "Total number of rows in index does not match number of rows in partitions within that index");
return Optional.of(new IndexInfo(rowsNumber, sizeInBytes, squaredDifferences, partitions.size()));
}
}
代码示例来源:origin: AsyncHttpClient/async-http-client
/**
* @return A long representing the number of idle connections in the connection pool.
*/
public long getTotalIdleConnectionCount() {
return statsPerHost
.values()
.stream()
.mapToLong(HostStats::getHostIdleConnectionCount)
.sum();
}
内容来源于网络,如有侵权,请联系作者删除!