public class JavaPairDStream<K,V>
extends Object
reduceByKey
and join
.Constructor and Description |
---|
JavaPairDStream(DStream<scala.Tuple2<K,V>> dstream,
scala.reflect.ClassTag<K> kManifest,
scala.reflect.ClassTag<V> vManifest) |
Modifier and Type | Method and Description |
---|---|
JavaPairDStream<K,V> |
cache()
Persist RDDs of this DStream with the default storage level (MEMORY_ONLY_SER)
|
scala.reflect.ClassTag<scala.Tuple2<K,V>> |
classTag() |
<W> JavaPairDStream<K,scala.Tuple2<Iterable<V>,Iterable<W>>> |
cogroup(JavaPairDStream<K,W> other)
Return a new DStream by applying 'cogroup' between RDDs of
this DStream and other DStream. |
<W> JavaPairDStream<K,scala.Tuple2<Iterable<V>,Iterable<W>>> |
cogroup(JavaPairDStream<K,W> other,
int numPartitions)
Return a new DStream by applying 'cogroup' between RDDs of
this DStream and other DStream. |
<W> JavaPairDStream<K,scala.Tuple2<Iterable<V>,Iterable<W>>> |
cogroup(JavaPairDStream<K,W> other,
Partitioner partitioner)
Return a new DStream by applying 'cogroup' between RDDs of
this DStream and other DStream. |
<C> JavaPairDStream<K,C> |
combineByKey(Function<V,C> createCombiner,
Function2<C,V,C> mergeValue,
Function2<C,C,C> mergeCombiners,
Partitioner partitioner)
Combine elements of each key in DStream's RDDs using custom function.
|
<C> JavaPairDStream<K,C> |
combineByKey(Function<V,C> createCombiner,
Function2<C,V,C> mergeValue,
Function2<C,C,C> mergeCombiners,
Partitioner partitioner,
boolean mapSideCombine)
Combine elements of each key in DStream's RDDs using custom function.
|
JavaPairRDD<K,V> |
compute(Time validTime)
Method that generates an RDD for the given Duration
|
DStream<scala.Tuple2<K,V>> |
dstream() |
JavaPairDStream<K,V> |
filter(Function<scala.Tuple2<K,V>,Boolean> f)
Return a new DStream containing only the elements that satisfy a predicate.
|
<U> JavaPairDStream<K,U> |
flatMapValues(FlatMapFunction<V,U> f)
Return a new DStream by applying a flatmap function to the value of each key-value pairs in
'this' DStream without changing the key.
|
static <K,V> JavaPairDStream<K,V> |
fromJavaDStream(JavaDStream<scala.Tuple2<K,V>> dstream) |
static <K,V> JavaPairDStream<K,V> |
fromPairDStream(DStream<scala.Tuple2<K,V>> dstream,
scala.reflect.ClassTag<K> evidence$1,
scala.reflect.ClassTag<V> evidence$2) |
<W> JavaPairDStream<K,scala.Tuple2<Optional<V>,Optional<W>>> |
fullOuterJoin(JavaPairDStream<K,W> other)
Return a new DStream by applying 'full outer join' between RDDs of
this DStream and
other DStream. |
<W> JavaPairDStream<K,scala.Tuple2<Optional<V>,Optional<W>>> |
fullOuterJoin(JavaPairDStream<K,W> other,
int numPartitions)
Return a new DStream by applying 'full outer join' between RDDs of
this DStream and
other DStream. |
<W> JavaPairDStream<K,scala.Tuple2<Optional<V>,Optional<W>>> |
fullOuterJoin(JavaPairDStream<K,W> other,
Partitioner partitioner)
Return a new DStream by applying 'full outer join' between RDDs of
this DStream and
other DStream. |
JavaPairDStream<K,Iterable<V>> |
groupByKey()
Return a new DStream by applying
groupByKey to each RDD. |
JavaPairDStream<K,Iterable<V>> |
groupByKey(int numPartitions)
Return a new DStream by applying
groupByKey to each RDD. |
JavaPairDStream<K,Iterable<V>> |
groupByKey(Partitioner partitioner)
Return a new DStream by applying
groupByKey on each RDD of this DStream. |
JavaPairDStream<K,Iterable<V>> |
groupByKeyAndWindow(Duration windowDuration)
Return a new DStream by applying
groupByKey over a sliding window. |
JavaPairDStream<K,Iterable<V>> |
groupByKeyAndWindow(Duration windowDuration,
Duration slideDuration)
Return a new DStream by applying
groupByKey over a sliding window. |
JavaPairDStream<K,Iterable<V>> |
groupByKeyAndWindow(Duration windowDuration,
Duration slideDuration,
int numPartitions)
Return a new DStream by applying
groupByKey over a sliding window on this DStream. |
JavaPairDStream<K,Iterable<V>> |
groupByKeyAndWindow(Duration windowDuration,
Duration slideDuration,
Partitioner partitioner)
Return a new DStream by applying
groupByKey over a sliding window on this DStream. |
<W> JavaPairDStream<K,scala.Tuple2<V,W>> |
join(JavaPairDStream<K,W> other)
Return a new DStream by applying 'join' between RDDs of
this DStream and other DStream. |
<W> JavaPairDStream<K,scala.Tuple2<V,W>> |
join(JavaPairDStream<K,W> other,
int numPartitions)
Return a new DStream by applying 'join' between RDDs of
this DStream and other DStream. |
<W> JavaPairDStream<K,scala.Tuple2<V,W>> |
join(JavaPairDStream<K,W> other,
Partitioner partitioner)
Return a new DStream by applying 'join' between RDDs of
this DStream and other DStream. |
scala.reflect.ClassTag<K> |
kManifest() |
<W> JavaPairDStream<K,scala.Tuple2<V,Optional<W>>> |
leftOuterJoin(JavaPairDStream<K,W> other)
Return a new DStream by applying 'left outer join' between RDDs of
this DStream and
other DStream. |
<W> JavaPairDStream<K,scala.Tuple2<V,Optional<W>>> |
leftOuterJoin(JavaPairDStream<K,W> other,
int numPartitions)
Return a new DStream by applying 'left outer join' between RDDs of
this DStream and
other DStream. |
<W> JavaPairDStream<K,scala.Tuple2<V,Optional<W>>> |
leftOuterJoin(JavaPairDStream<K,W> other,
Partitioner partitioner)
Return a new DStream by applying 'left outer join' between RDDs of
this DStream and
other DStream. |
<U> JavaPairDStream<K,U> |
mapValues(Function<V,U> f)
Return a new DStream by applying a map function to the value of each key-value pairs in
'this' DStream without changing the key.
|
<StateType,MappedType> |
mapWithState(StateSpec<K,V,StateType,MappedType> spec)
Return a
JavaMapWithStateDStream by applying a function to every key-value element of
this stream, while maintaining some state data for each unique key. |
JavaPairDStream<K,V> |
persist()
Persist RDDs of this DStream with the default storage level (MEMORY_ONLY_SER)
|
JavaPairDStream<K,V> |
persist(StorageLevel storageLevel)
Persist the RDDs of this DStream with the given storage level
|
JavaPairDStream<K,V> |
reduceByKey(Function2<V,V,V> func)
Return a new DStream by applying
reduceByKey to each RDD. |
JavaPairDStream<K,V> |
reduceByKey(Function2<V,V,V> func,
int numPartitions)
Return a new DStream by applying
reduceByKey to each RDD. |
JavaPairDStream<K,V> |
reduceByKey(Function2<V,V,V> func,
Partitioner partitioner)
Return a new DStream by applying
reduceByKey to each RDD. |
JavaPairDStream<K,V> |
reduceByKeyAndWindow(Function2<V,V,V> reduceFunc,
Duration windowDuration)
Create a new DStream by applying
reduceByKey over a sliding window on this DStream. |
JavaPairDStream<K,V> |
reduceByKeyAndWindow(Function2<V,V,V> reduceFunc,
Duration windowDuration,
Duration slideDuration)
Return a new DStream by applying
reduceByKey over a sliding window. |
JavaPairDStream<K,V> |
reduceByKeyAndWindow(Function2<V,V,V> reduceFunc,
Duration windowDuration,
Duration slideDuration,
int numPartitions)
Return a new DStream by applying
reduceByKey over a sliding window. |
JavaPairDStream<K,V> |
reduceByKeyAndWindow(Function2<V,V,V> reduceFunc,
Duration windowDuration,
Duration slideDuration,
Partitioner partitioner)
Return a new DStream by applying
reduceByKey over a sliding window. |
JavaPairDStream<K,V> |
reduceByKeyAndWindow(Function2<V,V,V> reduceFunc,
Function2<V,V,V> invReduceFunc,
Duration windowDuration,
Duration slideDuration)
Return a new DStream by reducing over a using incremental computation.
|
JavaPairDStream<K,V> |
reduceByKeyAndWindow(Function2<V,V,V> reduceFunc,
Function2<V,V,V> invReduceFunc,
Duration windowDuration,
Duration slideDuration,
int numPartitions,
Function<scala.Tuple2<K,V>,Boolean> filterFunc)
Return a new DStream by applying incremental
reduceByKey over a sliding window. |
JavaPairDStream<K,V> |
reduceByKeyAndWindow(Function2<V,V,V> reduceFunc,
Function2<V,V,V> invReduceFunc,
Duration windowDuration,
Duration slideDuration,
Partitioner partitioner,
Function<scala.Tuple2<K,V>,Boolean> filterFunc)
Return a new DStream by applying incremental
reduceByKey over a sliding window. |
JavaPairDStream<K,V> |
repartition(int numPartitions)
Return a new DStream with an increased or decreased level of parallelism.
|
<W> JavaPairDStream<K,scala.Tuple2<Optional<V>,W>> |
rightOuterJoin(JavaPairDStream<K,W> other)
Return a new DStream by applying 'right outer join' between RDDs of
this DStream and
other DStream. |
<W> JavaPairDStream<K,scala.Tuple2<Optional<V>,W>> |
rightOuterJoin(JavaPairDStream<K,W> other,
int numPartitions)
Return a new DStream by applying 'right outer join' between RDDs of
this DStream and
other DStream. |
<W> JavaPairDStream<K,scala.Tuple2<Optional<V>,W>> |
rightOuterJoin(JavaPairDStream<K,W> other,
Partitioner partitioner)
Return a new DStream by applying 'right outer join' between RDDs of
this DStream and
other DStream. |
void |
saveAsHadoopFiles(String prefix,
String suffix)
Save each RDD in
this DStream as a Hadoop file. |
<F extends org.apache.hadoop.mapred.OutputFormat<?,?>> |
saveAsHadoopFiles(String prefix,
String suffix,
Class<?> keyClass,
Class<?> valueClass,
Class<F> outputFormatClass)
Save each RDD in
this DStream as a Hadoop file. |
<F extends org.apache.hadoop.mapred.OutputFormat<?,?>> |
saveAsHadoopFiles(String prefix,
String suffix,
Class<?> keyClass,
Class<?> valueClass,
Class<F> outputFormatClass,
org.apache.hadoop.mapred.JobConf conf)
Save each RDD in
this DStream as a Hadoop file. |
void |
saveAsNewAPIHadoopFiles(String prefix,
String suffix)
Save each RDD in
this DStream as a Hadoop file. |
<F extends org.apache.hadoop.mapreduce.OutputFormat<?,?>> |
saveAsNewAPIHadoopFiles(String prefix,
String suffix,
Class<?> keyClass,
Class<?> valueClass,
Class<F> outputFormatClass)
Save each RDD in
this DStream as a Hadoop file. |
<F extends org.apache.hadoop.mapreduce.OutputFormat<?,?>> |
saveAsNewAPIHadoopFiles(String prefix,
String suffix,
Class<?> keyClass,
Class<?> valueClass,
Class<F> outputFormatClass,
org.apache.hadoop.conf.Configuration conf)
Save each RDD in
this DStream as a Hadoop file. |
static <K> JavaPairDStream<K,Long> |
scalaToJavaLong(JavaPairDStream<K,Object> dstream,
scala.reflect.ClassTag<K> evidence$3) |
JavaDStream<scala.Tuple2<K,V>> |
toJavaDStream()
Convert to a JavaDStream
|
JavaPairDStream<K,V> |
union(JavaPairDStream<K,V> that)
Return a new DStream by unifying data of another DStream with this DStream.
|
<S> JavaPairDStream<K,S> |
updateStateByKey(Function2<java.util.List<V>,Optional<S>,Optional<S>> updateFunc)
Return a new "state" DStream where the state for each key is updated by applying
the given function on the previous state of the key and the new values of each key.
|
<S> JavaPairDStream<K,S> |
updateStateByKey(Function2<java.util.List<V>,Optional<S>,Optional<S>> updateFunc,
int numPartitions)
Return a new "state" DStream where the state for each key is updated by applying
the given function on the previous state of the key and the new values of each key.
|
<S> JavaPairDStream<K,S> |
updateStateByKey(Function2<java.util.List<V>,Optional<S>,Optional<S>> updateFunc,
Partitioner partitioner)
Return a new "state" DStream where the state for each key is updated by applying
the given function on the previous state of the key and the new values of the key.
|
<S> JavaPairDStream<K,S> |
updateStateByKey(Function2<java.util.List<V>,Optional<S>,Optional<S>> updateFunc,
Partitioner partitioner,
JavaPairRDD<K,S> initialRDD)
Return a new "state" DStream where the state for each key is updated by applying
the given function on the previous state of the key and the new values of the key.
|
scala.reflect.ClassTag<V> |
vManifest() |
JavaPairDStream<K,V> |
window(Duration windowDuration)
Return a new DStream which is computed based on windowed batches of this DStream.
|
JavaPairDStream<K,V> |
window(Duration windowDuration,
Duration slideDuration)
Return a new DStream which is computed based on windowed batches of this DStream.
|
JavaPairRDD<K,V> |
wrapRDD(RDD<scala.Tuple2<K,V>> rdd) |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
checkpoint, context, count, countByValue, countByValue, countByValueAndWindow, countByValueAndWindow, countByWindow, flatMap, flatMapToPair, foreachRDD, foreachRDD, glom, map, mapPartitions, mapPartitionsToPair, mapToPair, print, print, reduce, reduceByWindow, reduceByWindow, scalaIntToJavaLong, slice, transform, transform, transformToPair, transformToPair, transformWith, transformWith, transformWithToPair, transformWithToPair
public static <K,V> JavaPairDStream<K,V> fromPairDStream(DStream<scala.Tuple2<K,V>> dstream, scala.reflect.ClassTag<K> evidence$1, scala.reflect.ClassTag<V> evidence$2)
public static <K,V> JavaPairDStream<K,V> fromJavaDStream(JavaDStream<scala.Tuple2<K,V>> dstream)
public static <K> JavaPairDStream<K,Long> scalaToJavaLong(JavaPairDStream<K,Object> dstream, scala.reflect.ClassTag<K> evidence$3)
public scala.reflect.ClassTag<K> kManifest()
public scala.reflect.ClassTag<V> vManifest()
public JavaPairDStream<K,V> filter(Function<scala.Tuple2<K,V>,Boolean> f)
public JavaPairDStream<K,V> cache()
public JavaPairDStream<K,V> persist()
public JavaPairDStream<K,V> persist(StorageLevel storageLevel)
public JavaPairDStream<K,V> repartition(int numPartitions)
numPartitions
- (undocumented)public JavaPairRDD<K,V> compute(Time validTime)
public JavaPairDStream<K,V> window(Duration windowDuration)
windowDuration
- width of the window; must be a multiple of this DStream's interval.public JavaPairDStream<K,V> window(Duration windowDuration, Duration slideDuration)
windowDuration
- duration (i.e., width) of the window;
must be a multiple of this DStream's intervalslideDuration
- sliding interval of the window (i.e., the interval after which
the new DStream will generate RDDs); must be a multiple of this
DStream's intervalpublic JavaPairDStream<K,V> union(JavaPairDStream<K,V> that)
that
- Another DStream having the same interval (i.e., slideDuration) as this DStream.public JavaPairDStream<K,Iterable<V>> groupByKey()
groupByKey
to each RDD. Hash partitioning is used to
generate the RDDs with Spark's default number of partitions.public JavaPairDStream<K,Iterable<V>> groupByKey(int numPartitions)
groupByKey
to each RDD. Hash partitioning is used to
generate the RDDs with numPartitions
partitions.numPartitions
- (undocumented)public JavaPairDStream<K,Iterable<V>> groupByKey(Partitioner partitioner)
groupByKey
on each RDD of this
DStream.
Therefore, the values for each key in this
DStream's RDDs are grouped into a
single sequence to generate the RDDs of the new DStream. org.apache.spark.Partitioner
is used to control the partitioning of each RDD.partitioner
- (undocumented)public JavaPairDStream<K,V> reduceByKey(Function2<V,V,V> func)
reduceByKey
to each RDD. The values for each key are
merged using the associative and commutative reduce function. Hash partitioning is used to
generate the RDDs with Spark's default number of partitions.func
- (undocumented)public JavaPairDStream<K,V> reduceByKey(Function2<V,V,V> func, int numPartitions)
reduceByKey
to each RDD. The values for each key are
merged using the supplied reduce function. Hash partitioning is used to generate the RDDs
with numPartitions
partitions.func
- (undocumented)numPartitions
- (undocumented)public JavaPairDStream<K,V> reduceByKey(Function2<V,V,V> func, Partitioner partitioner)
reduceByKey
to each RDD. The values for each key are
merged using the supplied reduce function. org.apache.spark.Partitioner is used to control
the partitioning of each RDD.func
- (undocumented)partitioner
- (undocumented)public <C> JavaPairDStream<K,C> combineByKey(Function<V,C> createCombiner, Function2<C,V,C> mergeValue, Function2<C,C,C> mergeCombiners, Partitioner partitioner)
createCombiner
- (undocumented)mergeValue
- (undocumented)mergeCombiners
- (undocumented)partitioner
- (undocumented)public <C> JavaPairDStream<K,C> combineByKey(Function<V,C> createCombiner, Function2<C,V,C> mergeValue, Function2<C,C,C> mergeCombiners, Partitioner partitioner, boolean mapSideCombine)
createCombiner
- (undocumented)mergeValue
- (undocumented)mergeCombiners
- (undocumented)partitioner
- (undocumented)mapSideCombine
- (undocumented)public JavaPairDStream<K,Iterable<V>> groupByKeyAndWindow(Duration windowDuration)
groupByKey
over a sliding window. This is similar to
DStream.groupByKey()
but applies it over a sliding window. The new DStream generates RDDs
with the same interval as this DStream. Hash partitioning is used to generate the RDDs with
Spark's default number of partitions.windowDuration
- width of the window; must be a multiple of this DStream's
batching intervalpublic JavaPairDStream<K,Iterable<V>> groupByKeyAndWindow(Duration windowDuration, Duration slideDuration)
groupByKey
over a sliding window. Similar to
DStream.groupByKey()
, but applies it over a sliding window. Hash partitioning is used to
generate the RDDs with Spark's default number of partitions.windowDuration
- width of the window; must be a multiple of this DStream's
batching intervalslideDuration
- sliding interval of the window (i.e., the interval after which
the new DStream will generate RDDs); must be a multiple of this
DStream's batching intervalpublic JavaPairDStream<K,Iterable<V>> groupByKeyAndWindow(Duration windowDuration, Duration slideDuration, int numPartitions)
groupByKey
over a sliding window on this
DStream.
Similar to DStream.groupByKey()
, but applies it over a sliding window.
Hash partitioning is used to generate the RDDs with numPartitions
partitions.windowDuration
- width of the window; must be a multiple of this DStream's
batching intervalslideDuration
- sliding interval of the window (i.e., the interval after which
the new DStream will generate RDDs); must be a multiple of this
DStream's batching intervalnumPartitions
- Number of partitions of each RDD in the new DStream.public JavaPairDStream<K,Iterable<V>> groupByKeyAndWindow(Duration windowDuration, Duration slideDuration, Partitioner partitioner)
groupByKey
over a sliding window on this
DStream.
Similar to DStream.groupByKey()
, but applies it over a sliding window.windowDuration
- width of the window; must be a multiple of this DStream's
batching intervalslideDuration
- sliding interval of the window (i.e., the interval after which
the new DStream will generate RDDs); must be a multiple of this
DStream's batching intervalpartitioner
- Partitioner for controlling the partitioning of each RDD in the new
DStream.public JavaPairDStream<K,V> reduceByKeyAndWindow(Function2<V,V,V> reduceFunc, Duration windowDuration)
reduceByKey
over a sliding window on this
DStream.
Similar to DStream.reduceByKey()
, but applies it over a sliding window. The new DStream
generates RDDs with the same interval as this DStream. Hash partitioning is used to generate
the RDDs with Spark's default number of partitions.reduceFunc
- associative and commutative reduce functionwindowDuration
- width of the window; must be a multiple of this DStream's
batching intervalpublic JavaPairDStream<K,V> reduceByKeyAndWindow(Function2<V,V,V> reduceFunc, Duration windowDuration, Duration slideDuration)
reduceByKey
over a sliding window. This is similar to
DStream.reduceByKey()
but applies it over a sliding window. Hash partitioning is used to
generate the RDDs with Spark's default number of partitions.reduceFunc
- associative and commutative reduce functionwindowDuration
- width of the window; must be a multiple of this DStream's
batching intervalslideDuration
- sliding interval of the window (i.e., the interval after which
the new DStream will generate RDDs); must be a multiple of this
DStream's batching intervalpublic JavaPairDStream<K,V> reduceByKeyAndWindow(Function2<V,V,V> reduceFunc, Duration windowDuration, Duration slideDuration, int numPartitions)
reduceByKey
over a sliding window. This is similar to
DStream.reduceByKey()
but applies it over a sliding window. Hash partitioning is used to
generate the RDDs with numPartitions
partitions.reduceFunc
- associative and commutative reduce functionwindowDuration
- width of the window; must be a multiple of this DStream's
batching intervalslideDuration
- sliding interval of the window (i.e., the interval after which
the new DStream will generate RDDs); must be a multiple of this
DStream's batching intervalnumPartitions
- Number of partitions of each RDD in the new DStream.public JavaPairDStream<K,V> reduceByKeyAndWindow(Function2<V,V,V> reduceFunc, Duration windowDuration, Duration slideDuration, Partitioner partitioner)
reduceByKey
over a sliding window. Similar to
DStream.reduceByKey()
, but applies it over a sliding window.reduceFunc
- associative rand commutative educe functionwindowDuration
- width of the window; must be a multiple of this DStream's
batching intervalslideDuration
- sliding interval of the window (i.e., the interval after which
the new DStream will generate RDDs); must be a multiple of this
DStream's batching intervalpartitioner
- Partitioner for controlling the partitioning of each RDD in the new
DStream.public JavaPairDStream<K,V> reduceByKeyAndWindow(Function2<V,V,V> reduceFunc, Function2<V,V,V> invReduceFunc, Duration windowDuration, Duration slideDuration)
reduceFunc
- associative and commutative reduce functioninvReduceFunc
- inverse function; such that for all y, invertible x:
invReduceFunc(reduceFunc(x, y), x) = y
windowDuration
- width of the window; must be a multiple of this DStream's
batching intervalslideDuration
- sliding interval of the window (i.e., the interval after which
the new DStream will generate RDDs); must be a multiple of this
DStream's batching intervalpublic JavaPairDStream<K,V> reduceByKeyAndWindow(Function2<V,V,V> reduceFunc, Function2<V,V,V> invReduceFunc, Duration windowDuration, Duration slideDuration, int numPartitions, Function<scala.Tuple2<K,V>,Boolean> filterFunc)
reduceByKey
over a sliding window.
The reduced value of over a new window is calculated using the old window's reduce value :
1. reduce the new values that entered the window (e.g., adding new counts)
2. "inverse reduce" the old values that left the window (e.g., subtracting old counts)
This is more efficient that reduceByKeyAndWindow without "inverse reduce" function.
However, it is applicable to only "invertible reduce functions".
Hash partitioning is used to generate the RDDs with numPartitions
partitions.reduceFunc
- associative and commutative reduce functioninvReduceFunc
- inverse functionwindowDuration
- width of the window; must be a multiple of this DStream's
batching intervalslideDuration
- sliding interval of the window (i.e., the interval after which
the new DStream will generate RDDs); must be a multiple of this
DStream's batching intervalnumPartitions
- number of partitions of each RDD in the new DStream.filterFunc
- function to filter expired key-value pairs;
only pairs that satisfy the function are retained
set this to null if you do not want to filterpublic JavaPairDStream<K,V> reduceByKeyAndWindow(Function2<V,V,V> reduceFunc, Function2<V,V,V> invReduceFunc, Duration windowDuration, Duration slideDuration, Partitioner partitioner, Function<scala.Tuple2<K,V>,Boolean> filterFunc)
reduceByKey
over a sliding window.
The reduced value of over a new window is calculated using the old window's reduce value :
1. reduce the new values that entered the window (e.g., adding new counts)
2. "inverse reduce" the old values that left the window (e.g., subtracting old counts)
This is more efficient that reduceByKeyAndWindow without "inverse reduce" function.
However, it is applicable to only "invertible reduce functions".reduceFunc
- associative and commutative reduce functioninvReduceFunc
- inverse functionwindowDuration
- width of the window; must be a multiple of this DStream's
batching intervalslideDuration
- sliding interval of the window (i.e., the interval after which
the new DStream will generate RDDs); must be a multiple of this
DStream's batching intervalpartitioner
- Partitioner for controlling the partitioning of each RDD in the new
DStream.filterFunc
- function to filter expired key-value pairs;
only pairs that satisfy the function are retained
set this to null if you do not want to filterpublic <StateType,MappedType> JavaMapWithStateDStream<K,V,StateType,MappedType> mapWithState(StateSpec<K,V,StateType,MappedType> spec)
JavaMapWithStateDStream
by applying a function to every key-value element of
this
stream, while maintaining some state data for each unique key. The mapping function
and other specification (e.g. partitioners, timeouts, initial state data, etc.) of this
transformation can be specified using StateSpec
class. The state data is accessible in
as a parameter of type State
in the mapping function.
Example of using mapWithState
:
// A mapping function that maintains an integer state and return a string
Function3<String, Optional<Integer>, State<Integer>, String> mappingFunction =
new Function3<String, Optional<Integer>, State<Integer>, String>() {
@Override
public Optional<String> call(Optional<Integer> value, State<Integer> state) {
// Use state.exists(), state.get(), state.update() and state.remove()
// to manage state, and return the necessary string
}
};
JavaMapWithStateDStream<String, Integer, Integer, String> mapWithStateDStream =
keyValueDStream.mapWithState(StateSpec.function(mappingFunc));
spec
- Specification of this transformationpublic <S> JavaPairDStream<K,S> updateStateByKey(Function2<java.util.List<V>,Optional<S>,Optional<S>> updateFunc)
updateFunc
- State update function. If this
function returns None, then
corresponding state key-value pair will be eliminated.public <S> JavaPairDStream<K,S> updateStateByKey(Function2<java.util.List<V>,Optional<S>,Optional<S>> updateFunc, int numPartitions)
numPartitions
partitions.updateFunc
- State update function. If this
function returns None, then
corresponding state key-value pair will be eliminated.numPartitions
- Number of partitions of each RDD in the new DStream.public <S> JavaPairDStream<K,S> updateStateByKey(Function2<java.util.List<V>,Optional<S>,Optional<S>> updateFunc, Partitioner partitioner)
updateFunc
- State update function. If this
function returns None, then
corresponding state key-value pair will be eliminated.partitioner
- Partitioner for controlling the partitioning of each RDD in the new
DStream.public <S> JavaPairDStream<K,S> updateStateByKey(Function2<java.util.List<V>,Optional<S>,Optional<S>> updateFunc, Partitioner partitioner, JavaPairRDD<K,S> initialRDD)
updateFunc
- State update function. If this
function returns None, then
corresponding state key-value pair will be eliminated.partitioner
- Partitioner for controlling the partitioning of each RDD in the new
DStream.initialRDD
- initial state value of each key.public <U> JavaPairDStream<K,U> mapValues(Function<V,U> f)
f
- (undocumented)public <U> JavaPairDStream<K,U> flatMapValues(FlatMapFunction<V,U> f)
f
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<Iterable<V>,Iterable<W>>> cogroup(JavaPairDStream<K,W> other)
this
DStream and other
DStream.
Hash partitioning is used to generate the RDDs with Spark's default number
of partitions.other
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<Iterable<V>,Iterable<W>>> cogroup(JavaPairDStream<K,W> other, int numPartitions)
this
DStream and other
DStream.
Hash partitioning is used to generate the RDDs with numPartitions
partitions.other
- (undocumented)numPartitions
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<Iterable<V>,Iterable<W>>> cogroup(JavaPairDStream<K,W> other, Partitioner partitioner)
this
DStream and other
DStream.
Hash partitioning is used to generate the RDDs with numPartitions
partitions.other
- (undocumented)partitioner
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<V,W>> join(JavaPairDStream<K,W> other)
this
DStream and other
DStream.
Hash partitioning is used to generate the RDDs with Spark's default number of partitions.other
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<V,W>> join(JavaPairDStream<K,W> other, int numPartitions)
this
DStream and other
DStream.
Hash partitioning is used to generate the RDDs with numPartitions
partitions.other
- (undocumented)numPartitions
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<V,W>> join(JavaPairDStream<K,W> other, Partitioner partitioner)
this
DStream and other
DStream.
The supplied org.apache.spark.Partitioner is used to control the partitioning of each RDD.other
- (undocumented)partitioner
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<V,Optional<W>>> leftOuterJoin(JavaPairDStream<K,W> other)
this
DStream and
other
DStream. Hash partitioning is used to generate the RDDs with Spark's default
number of partitions.other
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<V,Optional<W>>> leftOuterJoin(JavaPairDStream<K,W> other, int numPartitions)
this
DStream and
other
DStream. Hash partitioning is used to generate the RDDs with numPartitions
partitions.other
- (undocumented)numPartitions
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<V,Optional<W>>> leftOuterJoin(JavaPairDStream<K,W> other, Partitioner partitioner)
this
DStream and
other
DStream. The supplied org.apache.spark.Partitioner is used to control
the partitioning of each RDD.other
- (undocumented)partitioner
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<Optional<V>,W>> rightOuterJoin(JavaPairDStream<K,W> other)
this
DStream and
other
DStream. Hash partitioning is used to generate the RDDs with Spark's default
number of partitions.other
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<Optional<V>,W>> rightOuterJoin(JavaPairDStream<K,W> other, int numPartitions)
this
DStream and
other
DStream. Hash partitioning is used to generate the RDDs with numPartitions
partitions.other
- (undocumented)numPartitions
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<Optional<V>,W>> rightOuterJoin(JavaPairDStream<K,W> other, Partitioner partitioner)
this
DStream and
other
DStream. The supplied org.apache.spark.Partitioner is used to control
the partitioning of each RDD.other
- (undocumented)partitioner
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<Optional<V>,Optional<W>>> fullOuterJoin(JavaPairDStream<K,W> other)
this
DStream and
other
DStream. Hash partitioning is used to generate the RDDs with Spark's default
number of partitions.other
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<Optional<V>,Optional<W>>> fullOuterJoin(JavaPairDStream<K,W> other, int numPartitions)
this
DStream and
other
DStream. Hash partitioning is used to generate the RDDs with numPartitions
partitions.other
- (undocumented)numPartitions
- (undocumented)public <W> JavaPairDStream<K,scala.Tuple2<Optional<V>,Optional<W>>> fullOuterJoin(JavaPairDStream<K,W> other, Partitioner partitioner)
this
DStream and
other
DStream. The supplied org.apache.spark.Partitioner is used to control
the partitioning of each RDD.other
- (undocumented)partitioner
- (undocumented)public void saveAsHadoopFiles(String prefix, String suffix)
this
DStream as a Hadoop file. The file name at each batch interval is
generated based on prefix
and suffix
: "prefix-TIME_IN_MS.suffix".prefix
- (undocumented)suffix
- (undocumented)public <F extends org.apache.hadoop.mapred.OutputFormat<?,?>> void saveAsHadoopFiles(String prefix, String suffix, Class<?> keyClass, Class<?> valueClass, Class<F> outputFormatClass)
this
DStream as a Hadoop file. The file name at each batch interval is
generated based on prefix
and suffix
: "prefix-TIME_IN_MS.suffix".prefix
- (undocumented)suffix
- (undocumented)keyClass
- (undocumented)valueClass
- (undocumented)outputFormatClass
- (undocumented)public <F extends org.apache.hadoop.mapred.OutputFormat<?,?>> void saveAsHadoopFiles(String prefix, String suffix, Class<?> keyClass, Class<?> valueClass, Class<F> outputFormatClass, org.apache.hadoop.mapred.JobConf conf)
this
DStream as a Hadoop file. The file name at each batch interval is
generated based on prefix
and suffix
: "prefix-TIME_IN_MS.suffix".prefix
- (undocumented)suffix
- (undocumented)keyClass
- (undocumented)valueClass
- (undocumented)outputFormatClass
- (undocumented)conf
- (undocumented)public void saveAsNewAPIHadoopFiles(String prefix, String suffix)
this
DStream as a Hadoop file. The file name at each batch interval is
generated based on prefix
and suffix
: "prefix-TIME_IN_MS.suffix".prefix
- (undocumented)suffix
- (undocumented)public <F extends org.apache.hadoop.mapreduce.OutputFormat<?,?>> void saveAsNewAPIHadoopFiles(String prefix, String suffix, Class<?> keyClass, Class<?> valueClass, Class<F> outputFormatClass)
this
DStream as a Hadoop file. The file name at each batch interval is
generated based on prefix
and suffix
: "prefix-TIME_IN_MS.suffix".prefix
- (undocumented)suffix
- (undocumented)keyClass
- (undocumented)valueClass
- (undocumented)outputFormatClass
- (undocumented)public <F extends org.apache.hadoop.mapreduce.OutputFormat<?,?>> void saveAsNewAPIHadoopFiles(String prefix, String suffix, Class<?> keyClass, Class<?> valueClass, Class<F> outputFormatClass, org.apache.hadoop.conf.Configuration conf)
this
DStream as a Hadoop file. The file name at each batch interval is
generated based on prefix
and suffix
: "prefix-TIME_IN_MS.suffix".prefix
- (undocumented)suffix
- (undocumented)keyClass
- (undocumented)valueClass
- (undocumented)outputFormatClass
- (undocumented)conf
- (undocumented)public JavaDStream<scala.Tuple2<K,V>> toJavaDStream()