Refine search
canonical example by Tabnine
private static String formatNanos(List<Long> list) { LongSummaryStatistics stats = list.stream().mapToLong(Long::new).summaryStatistics(); return String.format("Min: %8s Max: %8s Avg: %8s Sum: %8s", succinctNanos(stats.getMin() == Long.MAX_VALUE ? 0 : stats.getMin()), succinctNanos(stats.getMax() == Long.MIN_VALUE ? 0 : stats.getMax()), succinctNanos((long) stats.getAverage()), succinctNanos(stats.getSum())); } }
public static PrimitiveNodeStream of( Object list ) { if ( list == null ) { return empty; } if ( list instanceof List ) { return new PrimitiveNodeStream( ((List<Node>) list).stream().mapToLong( Node::getId ) ); } else if ( list instanceof Node[] ) { return new PrimitiveNodeStream( Arrays.stream( (Node[]) list ).mapToLong( Node::getId ) ); } throw new IllegalArgumentException( format( "Can not convert to stream: %s", list.getClass().getName() ) ); }
public static PrimitiveRelationshipStream of( Object list ) { if ( null == list ) { return empty; } else if ( list instanceof List ) { return new PrimitiveRelationshipStream( ((List<Relationship>) list).stream().mapToLong( Relationship::getId ) ); } else if ( list instanceof Relationship[] ) { return new PrimitiveRelationshipStream( Arrays.stream( (Relationship[]) list ).mapToLong( Relationship::getId ) ); } throw new IllegalArgumentException( format( "Can not convert to stream: %s", list.getClass().getName() ) ); }
private static void printStats(Map<String, List<Long>> results) { for (Map.Entry<String, List<Long>> entry : results.entrySet()) { System.out.printf("Results for %s%n", entry.getKey()); System.out.printf("Min merge time=%d%n", entry.getValue().stream().min(Long::compare).get()); System.out.printf("Max merge time=%d%n", entry.getValue().stream().max(Long::compare).get()); System.out.printf("Avg merge time=%s%n", entry.getValue().stream().mapToLong(x -> x).average().getAsDouble()); System.out.printf("===================================================================%n"); } } }
public StripeStatistics(List<ColumnStatistics> columnStatistics) { this.columnStatistics = ImmutableList.copyOf(requireNonNull(columnStatistics, "columnStatistics is null")); this.retainedSizeInBytes = INSTANCE_SIZE + columnStatistics.stream().mapToLong(ColumnStatistics::getRetainedSizeInBytes).sum(); }
@VisibleForTesting public Backoff(int minTries, Duration maxFailureInterval, Ticker ticker, List<Duration> backoffDelayIntervals) { checkArgument(minTries > 0, "minTries must be at least 1"); requireNonNull(maxFailureInterval, "maxFailureInterval is null"); requireNonNull(ticker, "ticker is null"); requireNonNull(backoffDelayIntervals, "backoffDelayIntervals is null"); checkArgument(!backoffDelayIntervals.isEmpty(), "backoffDelayIntervals must contain at least one entry"); this.minTries = minTries; this.maxFailureIntervalNanos = maxFailureInterval.roundTo(NANOSECONDS); this.ticker = ticker; this.backoffDelayIntervalsNanos = backoffDelayIntervals.stream() .mapToLong(duration -> duration.roundTo(NANOSECONDS)) .toArray(); }
@Override public long getLastSequenceId() { // Return the highest sequence id across all partitions. This will be correct, // since there is a single id generator across all partitions for the same producer return producers.stream().map(Producer::getLastSequenceId).mapToLong(Long::longValue).max().orElse(-1); }