Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/5855#discussion_r43822533
--- Diff: mllib/src/main/scala/org/apache/spark/mllib/rdd/SlidingRDD.scala
---
@@ -66,36 +69,54 @@ class SlidingRDD[T: ClassTag](@transient val parent:
RDD[T], val windowSize: Int
if (n == 0) {
Array.empty
} else if (n == 1) {
- Array(new SlidingRDDPartition[T](0, parentPartitions(0), Seq.empty))
+ Array(new SlidingRDDPartition[T](0, parentPartitions(0), Seq.empty,
0))
} else {
val n1 = n - 1
- val w1 = windowSize - 1
- // Get the first w1 items of each partition, starting from the
second partition.
- val nextHeads =
- parent.context.runJob(parent, (iter: Iterator[T]) =>
iter.take(w1).toArray, 1 until n)
+ // Get partitions sizes
+ val sizes =
+ parent.context.runJob(parent, (iter: Iterator[T]) => iter.length,
0 until n)
--- End diff --
If `step > 1`, in a single Spark job, we can collect the following:
1. the first `w1` elements from each partition (except the first one)
2. the size of each partition
Then we can compute the offset for each partition.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]