locked
How is the Table continuation token calculated? Can I store a retrieved value offline and use it in the future? RRS feed

  • Question

  • I have a very large partition that is requiring me to enumerate the entire table before getting the bottom row.

    How can I calculate the continuation token so I can skip all previous data pages?

    If that's not possible, I'm thinking of querying the table for the first 10,000 rows and saving the last continuation token for later.  Perhaps later that day.

     

    That leads me to another question, can I reuse a continuation token?  What would happen if I did so?

    Monday, October 31, 2011 12:37 AM

All replies

  • Hi,

    Basically the continuation token is an encoded value of the next partition/row key. You can safely store it for future usage, if your data has not been updated. But if you insert/delete entities to the table, the continuation token may become unusable. This makes sense since continuation token is used in paging scenarios, and insert/delete entities will change the page numbers as well as which entity belongs to which page.

      >> That leads me to another question, can I reuse a continuation token?  What would happen if I did so?

    Based on my understanding, I would like to suggest you to check the link below for a similar thread which provides some solutions for this kind of issue:

    http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/a8105d7e-11d4-47d5-af2c-0d4bd685750e/

     

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    Monday, October 31, 2011 3:11 AM
  • >>  the continuation token is an encoded value of the next partition/row key.

     

    Can you elaborate on how this is encoded?

     

     


    • Edited by ChrisLaMont Tuesday, November 1, 2011 5:41 PM
    Monday, October 31, 2011 3:06 PM
  • The encoding is not shared at this point as it can be changed. In addition, the key used is the last row the engine stopped at and it may not have returned it in the results since it did not match the filter. So just using the last row in the result received is not efficient.  In addition continuation is > (LastPK, LastRK) which results in the following being appended: (PK == LastPK && RK > LastRK) || (PK > LastPK)

     

    Thanks,

    Jai

    Tuesday, November 1, 2011 6:03 PM
  • I would think that if such a change would happen, then all in-flight transactions would be affected.  Especially those that store the continuation token offline for an extended period of time.  I'll bet that Microsoft will notify people before such a drastic change takes place, or it will be opt-in based on the version header of the service.

     

    That being said, I'll accept the burden of having to revise my code for the ability to skip rows.  I want the feature and knowledge to implement it!

     

    How can I best petition Microsoft to share this?



    • Edited by ChrisLaMont Tuesday, November 1, 2011 9:54 PM
    Tuesday, November 1, 2011 8:37 PM
  • We do have the format version embedded in the token so the service does accept old continuations. But we would need to ensure that applications trying to interpret the continuation does not break with our change  (and we would have to change it only with a protocol version change).

    We have taken it down as a feature request. In addition, you can also petition for one here.

    Thanks,

    Jai

    Tuesday, November 1, 2011 10:34 PM