title: Apache Beam - Delta between windows
body: <p><em>Apologies</em>, in trying to be concise and clear my previous description of my question turned into a special case of the general case I'm trying to solve.</p>
  
  <p><strong>New Description</strong></p>
  
  <p>I'm trying to Compare the last emitted value of an Aggregation Function (Let's say Sum()) with a each element that I aggregate over in the current window.</p>
  
  <p><a href="https://i.stack.imgur.com/ERLkF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ERLkF.png" alt="enter image description here"></a></p>
  
  <p><strong>Worth noting, that the ideal (I think) solution would include</strong></p>
  
  <ul>
  <li>The T2(from t-1) element used at time = t is the one that was created during the previous window.</li>
  </ul>
  
  <p>I've been playing with several ideas/experiments but I'm struggling to find a way to accomplish this in a way is elegant and "empathetic" to Beam's compute model (which I'm still trying to fully Grock after many an article/blog/doc and book :)</p>
  
  <p>Side inputs seem unwieldy because It looks like I have to shift the emitted 5M@T-1 Aggregation's timestamp into the 5M@T's window in order to align it with the current 5M window</p>
  
  <p>In attempting this with side inputs (as I understand them), I ended up with some nasty code that was quite "circularly referential", but not in an elegant recursive way :)</p>
  
  <p>Any help in the right direction would be much appreciated.</p>
  
  <p><strong>Edit:</strong>
  Modified diagram and improved description to more clearly show:</p>
  
  <ul>
  <li>the intent of using emitted T2(from t-1) to calculate T2 at t</li>
  <li>that the desired T2(from t-1) used to calculate T2 is the one with the correct key</li>
  </ul>