Github user corneadoug commented on the pull request:

    https://github.com/apache/incubator-zeppelin/pull/804#issuecomment-206663670
  
    Maybe the GIFs are not obvious enough :)
    
    The PR is mainly trying to improve the rendering of the streaming 
capability introduced in https://github.com/apache/incubator-zeppelin/pull/611.
    
    So I will try to explain more in detail what is happening and how things 
work on the front-end side.
    
    
    ### How It Works
    
    First of all, its good to know that this is only a case for TEXT type of 
return values.
    
    The way the back-end communicates data to the front-end end is through 2 
different websocket events:
    
    * PARAGRAPH_UPDATE_OUTPUT: Which remove previous result and replace it by 
the event content
    
    * PARAGRAPH_APPEND_OUTPUT: Which add to the end of previous result
    
    So for example, if we take this code:
    
    ```
    (1 to 40).foreach{ i=>
        Thread.sleep(1000)
        println(i) 
    }
    ```
    
    It would send numbers from 1 to 40 with 1000ms interval, and this is what 
would happen:
    
    ```
    - PARAGRAPH_UPDATE_OUTPUT (sent: 1)
    
      -- PARAGRAPH_APPEND_OUTPUT (sent: 2)
    
      -- PARAGRAPH_APPEND_OUTPUT (sent: 3)
    
      -- PARAGRAPH_APPEND_OUTPUT (sent: 4)
      
      ...
    
    - PARAGRAPH_UPDATE_OUTPUT (sent: 1/n2/n3/n......40)
    ```
    
    So the way it works is that the job results are never persisted inside the 
Notebook before the end of the job.
    
    
    ### The Current Problem
    
    Since the temporary results are not persisted, whenever you navigate in and 
out of the Running Notebook, it will first reload the previous saved result in 
that paragraph.
    
    So if you did run a loop through the ABC before, The paragraph will render 
that result.
    
    Then you will receive some PARAGRAPH_APPEND_OUTPUT events from your running 
job, which will transform the result you see in your paragraph into something 
like:
    
    ```
    A
    B
    ...
    Z
    21 (PARAGRAPH_APPEND_OUTPUT)
    22 (PARAGRAPH_APPEND_OUTPUT)
    23 (PARAGRAPH_APPEND_OUTPUT)
    ```
    
    Mainly because the flush of previous result (visually) was done in the 
PARAGRAPH_UPDATE_OUTPUT event at the beginning of the job.
    
    
    
    ### What the PR achieve
    
    In this PR, we try to clear the previous unrelated result of the paragraph 
when the paragraph receives an PARAGRAPH_APPEND_OUTPUT event for the first time 
in the Notebook, in order to keep result of that job only.
    



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

Reply via email to