org.apache.spark.api.java
Class JavaDoubleRDD

Object
  extended by org.apache.spark.api.java.JavaDoubleRDD
All Implemented Interfaces:
java.io.Serializable, JavaRDDLike<Double,JavaDoubleRDD>

public class JavaDoubleRDD
extends Object

See Also:
Serialized Form

Constructor Summary
JavaDoubleRDD(RDD<Object> srdd)
           
 
Method Summary
 JavaDoubleRDD cache()
          Persist this RDD with the default storage level (`MEMORY_ONLY`).
 scala.reflect.ClassTag<Double> classTag()
           
 JavaDoubleRDD coalesce(int numPartitions)
          Return a new RDD that is reduced into numPartitions partitions.
 JavaDoubleRDD coalesce(int numPartitions, boolean shuffle)
          Return a new RDD that is reduced into numPartitions partitions.
 JavaDoubleRDD distinct()
          Return a new RDD containing the distinct elements in this RDD.
 JavaDoubleRDD distinct(int numPartitions)
          Return a new RDD containing the distinct elements in this RDD.
 JavaDoubleRDD filter(Function<Double,Boolean> f)
          Return a new RDD containing only the elements that satisfy a predicate.
 Double first()
          Return the first element in this RDD.
static JavaDoubleRDD fromRDD(RDD<Object> rdd)
           
 long[] histogram(double[] buckets)
          Compute a histogram using the provided buckets.
 long[] histogram(Double[] buckets, boolean evenBuckets)
           
 scala.Tuple2<double[],long[]> histogram(int bucketCount)
          Compute a histogram of the data using bucketCount number of buckets evenly spaced between the minimum and maximum of the RDD.
 JavaDoubleRDD intersection(JavaDoubleRDD other)
          Return the intersection of this RDD and another one.
 Double max()
          Returns the maximum element from this RDD as defined by the default comparator natural order.
 Double mean()
          Compute the mean of this RDD's elements.
 PartialResult<BoundedDouble> meanApprox(long timeout)
          :: Experimental :: Approximate operation to return the mean within a timeout.
 PartialResult<BoundedDouble> meanApprox(long timeout, Double confidence)
          Return the approximate mean of the elements in this RDD.
 Double min()
          Returns the minimum element from this RDD as defined by the default comparator natural order.
 JavaDoubleRDD persist(StorageLevel newLevel)
          Set this RDD's storage level to persist its values across operations after the first time it is computed.
 RDD<Double> rdd()
           
 JavaDoubleRDD repartition(int numPartitions)
          Return a new RDD that has exactly numPartitions partitions.
 JavaDoubleRDD sample(boolean withReplacement, Double fraction)
          Return a sampled subset of this RDD.
 JavaDoubleRDD sample(boolean withReplacement, Double fraction, long seed)
          Return a sampled subset of this RDD.
 Double sampleStdev()
          Compute the sample standard deviation of this RDD's elements (which corrects for bias in estimating the standard deviation by dividing by N-1 instead of N).
 Double sampleVariance()
          Compute the sample variance of this RDD's elements (which corrects for bias in estimating the standard variance by dividing by N-1 instead of N).
 JavaDoubleRDD setName(String name)
          Assign a name to this RDD
 RDD<Object> srdd()
           
 StatCounter stats()
          Return a StatCounter object that captures the mean, variance and count of the RDD's elements in one operation.
 Double stdev()
          Compute the standard deviation of this RDD's elements.
 JavaDoubleRDD subtract(JavaDoubleRDD other)
          Return an RDD with the elements from this that are not in other.
 JavaDoubleRDD subtract(JavaDoubleRDD other, int numPartitions)
          Return an RDD with the elements from this that are not in other.
 JavaDoubleRDD subtract(JavaDoubleRDD other, Partitioner p)
          Return an RDD with the elements from this that are not in other.
 Double sum()
          Add up the elements in this RDD.
 PartialResult<BoundedDouble> sumApprox(long timeout)
          :: Experimental :: Approximate operation to return the sum within a timeout.
 PartialResult<BoundedDouble> sumApprox(long timeout, Double confidence)
          :: Experimental :: Approximate operation to return the sum within a timeout.
static RDD<Object> toRDD(JavaDoubleRDD rdd)
           
 JavaDoubleRDD union(JavaDoubleRDD other)
          Return the union of this RDD and another one.
 JavaDoubleRDD unpersist()
          Mark the RDD as non-persistent, and remove all blocks for it from memory and disk.
 JavaDoubleRDD unpersist(boolean blocking)
          Mark the RDD as non-persistent, and remove all blocks for it from memory and disk.
 Double variance()
          Compute the variance of this RDD's elements.
 JavaDoubleRDD wrapRDD(RDD<Double> rdd)
           
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.spark.api.java.JavaRDDLike
aggregate, cartesian, checkpoint, collect, collectAsync, collectPartitions, context, count, countApprox, countApprox, countApproxDistinct, countAsync, countByValue, countByValueApprox, countByValueApprox, flatMap, flatMapToDouble, flatMapToPair, fold, foreach, foreachAsync, foreachPartition, foreachPartitionAsync, getCheckpointFile, getStorageLevel, glom, groupBy, groupBy, id, isCheckpointed, isEmpty, iterator, keyBy, map, mapPartitions, mapPartitions, mapPartitionsToDouble, mapPartitionsToDouble, mapPartitionsToPair, mapPartitionsToPair, mapPartitionsWithIndex, mapToDouble, mapToPair, max, min, name, partitions, pipe, pipe, pipe, reduce, saveAsObjectFile, saveAsTextFile, saveAsTextFile, splits, take, takeAsync, takeOrdered, takeOrdered, takeSample, takeSample, toArray, toDebugString, toLocalIterator, top, top, treeAggregate, treeAggregate, treeReduce, treeReduce, zip, zipPartitions, zipWithIndex, zipWithUniqueId
 

Constructor Detail

JavaDoubleRDD

public JavaDoubleRDD(RDD<Object> srdd)
Method Detail

fromRDD

public static JavaDoubleRDD fromRDD(RDD<Object> rdd)

toRDD

public static RDD<Object> toRDD(JavaDoubleRDD rdd)

srdd

public RDD<Object> srdd()

classTag

public scala.reflect.ClassTag<Double> classTag()

rdd

public RDD<Double> rdd()

wrapRDD

public JavaDoubleRDD wrapRDD(RDD<Double> rdd)

cache

public JavaDoubleRDD cache()
Persist this RDD with the default storage level (`MEMORY_ONLY`).


persist

public JavaDoubleRDD persist(StorageLevel newLevel)
Set this RDD's storage level to persist its values across operations after the first time it is computed. Can only be called once on each RDD.

Parameters:
newLevel - (undocumented)
Returns:
(undocumented)

unpersist

public JavaDoubleRDD unpersist()
Mark the RDD as non-persistent, and remove all blocks for it from memory and disk. This method blocks until all blocks are deleted.

Returns:
(undocumented)

unpersist

public JavaDoubleRDD unpersist(boolean blocking)
Mark the RDD as non-persistent, and remove all blocks for it from memory and disk.

Parameters:
blocking - Whether to block until all blocks are deleted.
Returns:
(undocumented)

first

public Double first()
Description copied from interface: JavaRDDLike
Return the first element in this RDD.

Returns:
(undocumented)

distinct

public JavaDoubleRDD distinct()
Return a new RDD containing the distinct elements in this RDD.

Returns:
(undocumented)

distinct

public JavaDoubleRDD distinct(int numPartitions)
Return a new RDD containing the distinct elements in this RDD.

Parameters:
numPartitions - (undocumented)
Returns:
(undocumented)

filter

public JavaDoubleRDD filter(Function<Double,Boolean> f)
Return a new RDD containing only the elements that satisfy a predicate.

Parameters:
f - (undocumented)
Returns:
(undocumented)

coalesce

public JavaDoubleRDD coalesce(int numPartitions)
Return a new RDD that is reduced into numPartitions partitions.

Parameters:
numPartitions - (undocumented)
Returns:
(undocumented)

coalesce

public JavaDoubleRDD coalesce(int numPartitions,
                              boolean shuffle)
Return a new RDD that is reduced into numPartitions partitions.

Parameters:
numPartitions - (undocumented)
shuffle - (undocumented)
Returns:
(undocumented)

repartition

public JavaDoubleRDD repartition(int numPartitions)
Return a new RDD that has exactly numPartitions partitions.

Can increase or decrease the level of parallelism in this RDD. Internally, this uses a shuffle to redistribute data.

If you are decreasing the number of partitions in this RDD, consider using coalesce, which can avoid performing a shuffle.

Parameters:
numPartitions - (undocumented)
Returns:
(undocumented)

subtract

public JavaDoubleRDD subtract(JavaDoubleRDD other)
Return an RDD with the elements from this that are not in other.

Uses this partitioner/partition size, because even if other is huge, the resulting RDD will be &lt;= us.

Parameters:
other - (undocumented)
Returns:
(undocumented)

subtract

public JavaDoubleRDD subtract(JavaDoubleRDD other,
                              int numPartitions)
Return an RDD with the elements from this that are not in other.

Parameters:
other - (undocumented)
numPartitions - (undocumented)
Returns:
(undocumented)

subtract

public JavaDoubleRDD subtract(JavaDoubleRDD other,
                              Partitioner p)
Return an RDD with the elements from this that are not in other.

Parameters:
other - (undocumented)
p - (undocumented)
Returns:
(undocumented)

sample

public JavaDoubleRDD sample(boolean withReplacement,
                            Double fraction)
Return a sampled subset of this RDD.

Parameters:
withReplacement - (undocumented)
fraction - (undocumented)
Returns:
(undocumented)

sample

public JavaDoubleRDD sample(boolean withReplacement,
                            Double fraction,
                            long seed)
Return a sampled subset of this RDD.

Parameters:
withReplacement - (undocumented)
fraction - (undocumented)
seed - (undocumented)
Returns:
(undocumented)

union

public JavaDoubleRDD union(JavaDoubleRDD other)
Return the union of this RDD and another one. Any identical elements will appear multiple times (use .distinct() to eliminate them).

Parameters:
other - (undocumented)
Returns:
(undocumented)

intersection

public JavaDoubleRDD intersection(JavaDoubleRDD other)
Return the intersection of this RDD and another one. The output will not contain any duplicate elements, even if the input RDDs did.

Note that this method performs a shuffle internally.

Parameters:
other - (undocumented)
Returns:
(undocumented)

sum

public Double sum()
Add up the elements in this RDD.


min

public Double min()
Returns the minimum element from this RDD as defined by the default comparator natural order.

Returns:
the minimum of the RDD

max

public Double max()
Returns the maximum element from this RDD as defined by the default comparator natural order.

Returns:
the maximum of the RDD

stats

public StatCounter stats()
Return a StatCounter object that captures the mean, variance and count of the RDD's elements in one operation.

Returns:
(undocumented)

mean

public Double mean()
Compute the mean of this RDD's elements.


variance

public Double variance()
Compute the variance of this RDD's elements.


stdev

public Double stdev()
Compute the standard deviation of this RDD's elements.


sampleStdev

public Double sampleStdev()
Compute the sample standard deviation of this RDD's elements (which corrects for bias in estimating the standard deviation by dividing by N-1 instead of N).

Returns:
(undocumented)

sampleVariance

public Double sampleVariance()
Compute the sample variance of this RDD's elements (which corrects for bias in estimating the standard variance by dividing by N-1 instead of N).

Returns:
(undocumented)

meanApprox

public PartialResult<BoundedDouble> meanApprox(long timeout,
                                               Double confidence)
Return the approximate mean of the elements in this RDD.


meanApprox

public PartialResult<BoundedDouble> meanApprox(long timeout)
:: Experimental :: Approximate operation to return the mean within a timeout.

Parameters:
timeout - (undocumented)
Returns:
(undocumented)

sumApprox

public PartialResult<BoundedDouble> sumApprox(long timeout,
                                              Double confidence)
:: Experimental :: Approximate operation to return the sum within a timeout.

Parameters:
timeout - (undocumented)
confidence - (undocumented)
Returns:
(undocumented)

sumApprox

public PartialResult<BoundedDouble> sumApprox(long timeout)
:: Experimental :: Approximate operation to return the sum within a timeout.

Parameters:
timeout - (undocumented)
Returns:
(undocumented)

histogram

public scala.Tuple2<double[],long[]> histogram(int bucketCount)
Compute a histogram of the data using bucketCount number of buckets evenly spaced between the minimum and maximum of the RDD. For example if the min value is 0 and the max is 100 and there are two buckets the resulting buckets will be [0,50) [50,100]. bucketCount must be at least 1 If the RDD contains infinity, NaN throws an exception If the elements in RDD do not vary (max == min) always returns a single bucket.

Parameters:
bucketCount - (undocumented)
Returns:
(undocumented)

histogram

public long[] histogram(double[] buckets)
Compute a histogram using the provided buckets. The buckets are all open to the left except for the last which is closed e.g. for the array [1,10,20,50] the buckets are [1,10) [10,20) [20,50] e.g 1&lt;=x&lt;10 , 10&lt;=x&lt;20, 20&lt;=x&lt;50 And on the input of 1 and 50 we would have a histogram of 1,0,0

Note: if your histogram is evenly spaced (e.g. [0, 10, 20, 30]) this can be switched from an O(log n) insertion to O(1) per element. (where n = # buckets) if you set evenBuckets to true. buckets must be sorted and not contain any duplicates. buckets array must be at least two elements All NaN entries are treated the same. If you have a NaN bucket it must be the maximum value of the last position and all NaN entries will be counted in that bucket.

Parameters:
buckets - (undocumented)
Returns:
(undocumented)

histogram

public long[] histogram(Double[] buckets,
                        boolean evenBuckets)

setName

public JavaDoubleRDD setName(String name)
Assign a name to this RDD