Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3026#discussion_r19834651
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/dstream/ReceiverInputDStream.scala
 ---
    @@ -58,24 +54,45 @@ abstract class ReceiverInputDStream[T: 
ClassTag](@transient ssc_ : StreamingCont
     
       def stop() {}
     
    -  /** Ask ReceiverInputTracker for received data blocks and generates RDDs 
with them. */
    +  /**
    +   * Generates RDDs with blocks received by the receiver of this stream. */
       override def compute(validTime: Time): Option[RDD[T]] = {
    -    // If this is called for any time before the start time of the context,
    -    // then this returns an empty RDD. This may happen when recovering 
from a
    -    // master failure
    -    if (validTime >= graph.startTime) {
    -      val blockInfo = 
ssc.scheduler.receiverTracker.getReceivedBlockInfo(id)
    -      receivedBlockInfo(validTime) = blockInfo
    -      val blockIds = blockInfo.map { 
_.blockStoreResult.blockId.asInstanceOf[BlockId] }
    -      Some(new BlockRDD[T](ssc.sc, blockIds))
    -    } else {
    -      Some(new BlockRDD[T](ssc.sc, Array.empty))
    -    }
    -  }
    +    val blockRDD = {
     
    -  /** Get information on received blocks. */
    -  private[streaming] def getReceivedBlockInfo(time: Time) = {
    -    receivedBlockInfo.get(time).getOrElse(Array.empty[ReceivedBlockInfo])
    +      if (validTime < graph.startTime) {
    +        // If this is called for any time before the start time of the 
context,
    +        // then this returns an empty RDD. This may happen when recovering 
from a
    +        // driver failure without any write ahead log to recover 
pre-failure data.
    +        new BlockRDD[T](ssc.sc, Array.empty)
    +      } else {
    +        // Otherwise, ask the tracker for all the blocks that have been 
allocated to this stream
    +        // for this batch
    +        val blockInfos =
    +          
ssc.scheduler.receiverTracker.getBlocksOfBatch(validTime).get(id).getOrElse(Seq.empty)
    +        val blockStoreResults = blockInfos.map { _.blockStoreResult }
    +        val blockIds = blockStoreResults.map { 
_.blockId.asInstanceOf[BlockId] }.toArray
    +
    +        // Check whether all the results are of the same type
    +        val resultTypes = blockStoreResults.map { _.getClass }.distinct
    +        if (resultTypes.size > 1) {
    +          logWarning("Multiple result types in block information, WAL 
information will be ignored.")
    +        }
    +
    +        // If all the results are of type WriteAheadLogBasedStoreResult, 
then create
    +        // WriteAheadLogBackedBlockRDD else create simple BlockRDD.
    +        if (resultTypes.size == 1 && resultTypes.head == 
classOf[WriteAheadLogBasedStoreResult]) {
    +          val logSegments = blockStoreResults.map {
    +            _.asInstanceOf[WriteAheadLogBasedStoreResult].segment
    +          }.toArray
    +          // Since storeInBlockManager = false, the storage level does not 
matter.
    +          new WriteAheadLogBackedBlockRDD[T](ssc.sparkContext,
    +            blockIds, logSegments, storeInBlockManager = false, 
StorageLevel.NONE)
    --- End diff --
    
    There can be an additional cost of putting the data back into BM, which is 
unnecessary for simple workloads where the data is probably going to be used 
only once. I see your point as well. So what we can do is that we allows the 
data to be stored in BM only in the serialized form  (so storage level = 
MEMORY_ONLY_SER). That should be a no-overhead solution.


---
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]

Reply via email to