public static final @Nullable Tuple4<Long, Long, Long, Long> contentSizeStats( JavaRDD<ApacheAccessLog> accessLogRDD) { JavaDoubleRDD contentSizes = accessLogRDD.mapToDouble(new GetContentSize()).cache(); long count = contentSizes.count(); if (count == 0) { return null; } Object ordering = Ordering.natural(); final Comparator<Double> cmp = (Comparator<Double>)ordering; return new Tuple4<>(count, contentSizes.reduce(new SumReducer()).longValue(), contentSizes.min(cmp).longValue(), contentSizes.max(cmp).longValue()); }
@Test public void naturalMin() { JavaDoubleRDD rdd = sc.parallelizeDoubles(Arrays.asList(1.0, 2.0, 3.0, 4.0)); double max = rdd.min(); assertEquals(1.0, max, 0.0); }
@Test public void naturalMin() { JavaDoubleRDD rdd = sc.parallelizeDoubles(Arrays.asList(1.0, 2.0, 3.0, 4.0)); double max = rdd.min(); assertEquals(1.0, max, 0.0); }
@Test public void naturalMin() { JavaDoubleRDD rdd = sc.parallelizeDoubles(Arrays.asList(1.0, 2.0, 3.0, 4.0)); double max = rdd.min(); assertEquals(1.0, max, 0.0); }
@Test public void min() { JavaDoubleRDD rdd = sc.parallelizeDoubles(Arrays.asList(1.0, 2.0, 3.0, 4.0)); double max = rdd.min(new DoubleComparator()); assertEquals(1.0, max, 0.001); }
@Test public void min() { JavaDoubleRDD rdd = sc.parallelizeDoubles(Arrays.asList(1.0, 2.0, 3.0, 4.0)); double max = rdd.min(new DoubleComparator()); assertEquals(1.0, max, 0.001); }
@Test public void min() { JavaDoubleRDD rdd = sc.parallelizeDoubles(Arrays.asList(1.0, 2.0, 3.0, 4.0)); double max = rdd.min(new DoubleComparator()); assertEquals(1.0, max, 0.001); }
@Override public OptionalDouble min() { if (doubleStream.isEmpty()) { return OptionalDouble.empty(); } return OptionalDouble.of(doubleStream.min()); }
/** * The main function to take the input IDs. * @param args the arguments for the function * @throws IOException due to an error reading from the URL */ public static void main(String[] args) throws IOException { long start = System.currentTimeMillis(); StructureDataRDD structureDataRDD = new StructureDataRDD("/path/to/hadoopfolder"); SegmentDataRDD calphaChains = structureDataRDD.getCalpha().filterLength(10, 300); JavaDoubleRDD lengthDist = calphaChains.getLengthDist().cache(); System.out.println(lengthDist.mean()); System.out.println(lengthDist.min()); System.out.println(lengthDist.max()); System.out.println(lengthDist.count()); System.out.println(System.currentTimeMillis()-start); }